cslms-api/internal/models/quiz.go

79 lines
3.5 KiB
Go
Raw Normal View History

2023-12-27 17:31:49 +09:00
package models
import (
"time"
"gorm.io/datatypes"
)
// 문항 json,
// option1~4는 구분이름일 뿐, 실제로는 셔플되어서 반환됨.
/*
{
"option1": {"content": "markdown 문서로 작성됨", "is_answer": false},
"option2": {"content": "markdown 문서로 작성됨", "is_answer": false},
"option3": {"content": "markdown 문서로 작성됨", "is_answer": false},
"option4": {"content": "markdown 문서로 작성됨", "is_answer": true},
"hint": "markdown문서로 작성됨",
"score": 10
}
*/
type Quiz struct {
ID int64 `json:"id" db:"id" example:"1000001" gorm:"column:id;primary_key;"`
GUID string `json:"guid_id" db:"guid_id" example:"2036023a-fb56-4b6c-b3bb-c787c681ada6" gorm:"column:guid_id;size:255;index;"`
CenterID int64 `json:"center_id" db:"center_id" example:"100001" gorm:"column:center_id;index;"`
QuizPaperID int64 `json:"quiz_paper_id" db:"quiz_paper_id" example:"100001" gorm:"column:quiz_paper_id;index;"`
No int `json:"vol_no" db:"vol_no" example:"5" gorm:"column:vol_no;index;"`
QuestionType string `json:"question_type" db:"question_type" example:"choice" gorm:"column:question_type;size:10;index;"`
Question string `json:"question" db:"question" example:"퀴즈 질문입니다." gorm:"column:question;size:512;"`
Content datatypes.JSON `json:"content" db:"content" gorm:"column:content;"`
Answer datatypes.JSON `json:"answer" db:"answer" gorm:"column:answer;"`
UpdatedAt time.Time `json:"-" gorm:"column:updated_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;index;->:false"`
CreatedAt time.Time `json:"-" gorm:"column:created_at;type:DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP;index;->:false;<-:create"`
}
// 테이블이름 정의
func (Quiz) TableName() string {
return "Quizs"
}
type QuizRequest struct {
QuizPaperID int64 `json:"quiz_paper_id" example:"1000001"`
CenterID int64 `json:"center_id" example:"1000001"`
No int `json:"vol_no" example:"1"`
QuestionType string `json:"question_type" example:"choice"`
Question string `json:"question" example:"질문입니다."`
Content QuizContent `json:"content"`
Answer []string `json:"answer" example:"option1,option2"`
}
type QuizResponse struct {
ID int64 `json:"id" example:"1000001"`
QuizPaperID int64 `json:"quiz_paper_id" example:"1000001"`
No int `json:"vol_no" example:"5"`
QuestionType string `json:"question_type" example:"check"`
Question string `json:"question" example:"퀴즈 질문입니다."`
Content QuizContent `json:"content"`
Answer []string `json:"answer" example:"option1,option2"`
}
type QuizListResponse struct {
2023-12-29 00:27:12 +09:00
Data []QuizResponse `json:"data"`
Total int64 `json:"total" example:"5"`
Page int `json:"page" example:"1"`
TotalPage int64 `json:"totalPage" example:"1"`
PageSize int `json:"pageSize" example:"10"`
2023-12-27 17:31:49 +09:00
}
type QuizContent struct {
Option1 string `json:"option1" example:"markdown 문서로 작성됨"`
Option2 string `json:"option2" example:"markdown 문서로 작성됨"`
Option3 string `json:"option3" example:"markdown 문서로 작성됨"`
Option4 string `json:"option4" example:"markdown 문서로 작성됨"`
Hint string `json:"hint" example:"markdown문서로 작성됨"`
}
type QuizAnswer struct {
}