30 lines
487 B
Go
30 lines
487 B
Go
package models
|
|
|
|
import (
|
|
"crypto/sha256"
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
type Session struct {
|
|
Meta
|
|
|
|
Title string `json:"name"`
|
|
Exams map[string]*Exam `json:"exams"`
|
|
}
|
|
|
|
func (s *Session) String() string {
|
|
return s.Title
|
|
}
|
|
|
|
func (s *Session) GetHash() string {
|
|
return fmt.Sprintf("%x", sha256.Sum256([]byte(s.Title)))
|
|
}
|
|
|
|
func (s *Session) Marshal() ([]byte, error) {
|
|
return json.Marshal(s)
|
|
}
|
|
|
|
func (s *Session) Unmarshal(data []byte) error {
|
|
return json.Unmarshal(data, s)
|
|
}
|