probo/pkg/models/response.go
2024-05-12 10:15:48 +02:00

36 lines
706 B
Go

package models
import (
"encoding/json"
"fmt"
)
type ParticipantAnswer struct {
Quiz *Quiz `json:"question"`
Answer *Answer `json:"answer"`
Correct bool `json:"correct"`
}
type Response struct {
Meta
SessionID string `json:"session_id"`
Answers []*ParticipantAnswer `json:"answers"`
}
func (r *Response) String() string {
return fmt.Sprintf("Questions/Answers: %v", r.Answers)
}
func (r *Response) GetHash() string {
// return fmt.Sprintf("%x", sha256.Sum256([]byte(r.QuestionID+r.AnswerID)))
return ""
}
func (r *Response) Marshal() ([]byte, error) {
return json.Marshal(r)
}
func (r *Response) Unmarshal(data []byte) error {
return json.Unmarshal(data, r)
}