2023-12-11 09:32:50 +01:00
|
|
|
package models
|
2023-12-12 09:21:55 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"crypto/sha256"
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Session struct {
|
|
|
|
Meta
|
|
|
|
|
|
|
|
Name string
|
|
|
|
Exams map[string]*Exam
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Session) String() string {
|
|
|
|
return s.Name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Session) GetHash() string {
|
|
|
|
return fmt.Sprintf("%x", sha256.Sum256([]byte(s.Name)))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Session) Marshal() ([]byte, error) {
|
|
|
|
return json.Marshal(s)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Session) Unmarshal(data []byte) error {
|
|
|
|
return json.Unmarshal(data, s)
|
|
|
|
}
|