package model

import (
	"encoding/json"

	"github.com/google/uuid"
)

type MTType struct {
	Id              uuid.UUID `json:"id"`
	CurrentQuestion CQType    `json:"current_question"`
	CurrentAnswers  []CAType  `json:"current_answers"`
	QuestionCount   int       `json:"questions_count"`
	QuestionNumber  int       `json:"question_number"`
	QuestionStatus  []int     `json:"questions_statuses"`
	ValidAnswer     uuid.UUID `json:"valid_answer"`
	QuestionPassed  int       `json:"questions_passed"`
	ValidAnswers    string    `json:"valid_answers"`
}

type CQType struct {
	Id            uuid.UUID `json:"id"`
	Content       string    `json:"content"`
	ResourcesPath []string  `json:"resources_path"`
	Types         string    `json:"type"`
	IsAdd         bool      `json:"id_additional"`
}

type CAType struct {
	Id            uuid.UUID `json:"id"`
	Title         string    `json:"title"`
	ResourcesPath []string  `json:"resources_path"`
}

func MTTypeToJSON(data *MTType) string {
	req, _ := json.Marshal(data)
	return string(req)
}

func UnmarshalJSONToMTType(in []byte) *MTType {
	var data MTType
	_ = json.Unmarshal(in, &data)
	return &data
}

type ReqAnswer struct {
	Answer uuid.UUID `json:"answer"`
}

type ReqNull struct {
	Answers string `json:"answers"`
}
