Documentation
¶
Index ¶
- Constants
- func NewLocalRapid(teamName string, log *slog.Logger, ignoredCategories []string) (*rapid, error)
- func NewRapid(teamName string, config RapidConfig) (*rapid, error)
- type ErrorIncorrectAnswer
- type FeedbackMessage
- type FeedbackType
- type Message
- type MessageType
- type Question
- type RapidConfig
Constants ¶
const ( MessageTypeQuestion MessageType = "SPØRSMÅL" MessageTypeAnswer MessageType = "SVAR" MessageTypeFeedback MessageType = "KORREKTUR" FeedbackTypeCorrect FeedbackType = "KORREKT" FeedbackTypeIncorrect FeedbackType = "FEIL" )
const (
// LeesahTimeformat is Python's time format for Leesah messages, which is a form of RFC3339.
LeesahTimeformat = "2006-01-02T15:04:05.999999"
)
Variables ¶
This section is empty.
Functions ¶
func NewLocalRapid ¶
NewLocalRapid creates a new Rapid instance with a local configuration. The local configuration is read from "leesah-certs.yaml". It is used when playing the local edition of Leesah. You can override the path to the local certification by setting the environment variable QUIZ_CERTS. You can also override the topic by setting the environment variable QUIZ_TOPIC, or else the first topic in the file will be used.
func NewRapid ¶
func NewRapid(teamName string, config RapidConfig) (*rapid, error)
NewRapid creates a new Rapid instance with the given configuration. It is used when playing the Nais-edition of Leesah.
Types ¶
type ErrorIncorrectAnswer ¶ added in v1.0.0
type ErrorIncorrectAnswer struct { // QuestionID is the ID of the question that was answered incorrectly. QuestionID string Category string }
func NewErrorIncorrectAnswer ¶ added in v1.0.0
func NewErrorIncorrectAnswer(questionID, category string) *ErrorIncorrectAnswer
func (*ErrorIncorrectAnswer) Error ¶ added in v1.0.0
func (e *ErrorIncorrectAnswer) Error() string
type FeedbackMessage ¶ added in v1.0.0
type FeedbackMessage struct { QuestionID string `json:"spørsmålId"` Feedback FeedbackType `json:"korrektur"` Category string `json:"kategori"` }
FeedbackMessage is a message with just the fields needed when you have received feedback.
type FeedbackType ¶ added in v1.0.0
type FeedbackType string
FeedbackType is an enum for the type of feedback in the Leesah Kafka topic.
type Message ¶
type Message struct { Answer string `json:"svar"` Category string `json:"kategori"` Created string `json:"@opprettet"` AnswerID string `json:"svarId"` Question string `json:"spørsmål,omitempty"` QuestionID string `json:"spørsmålId"` AnswerFormat string `json:"svarformat,omitempty"` TeamName string `json:"lagnavn"` Type MessageType `json:"@event_name"` Documentation string `json:"dokumentasjon"` Feedback FeedbackType `json:"korrektur,omitempty"` }
Message is a struct that represents a message in the Leesah Kafka topic.
func (Message) ToQuestion ¶
ToQuestion converts a Message to a simpler Question model.
type MessageType ¶
type MessageType string
MessageType is an enum for the type of message in the Leesah Kafka topic.
type Question ¶
type Question struct { ID string Category string Question string AnswerFormat string Documentation string }
Question is a simplified version of a Message with just the fields you need to play the game.
type RapidConfig ¶
type RapidConfig struct { Broker string CAPath string CertPath string GroupID string IgnoredCategories []string KafkaDir string Log *slog.Logger PrivateKeyPath string Topic string }
RapidConfig is a struct that represents the configuration for a Rapid instance. This is used when creating a new Rapid instance for the NAIS platform.