hackathon/api/v1/quest.gunk

82 lines
1.7 KiB
Go

package codequest
import (
"github.com/gunk/opt/http"
"github.com/gunk/opt/openapiv2"
"github.com/gunk/opt/proto"
"time"
)
type QuestService interface {
// +gunk http.Match{
// Method: "GET",
// Path: "/v1/questions",
// }
Questions() QuestionsResponse
// +gunk http.Match{
// Method: "GET",
// Path: "/v1/questions/{ID}",
// }
QuestionByID(QuestionByIDRequest) Question
// +gunk http.Match{
// Method: "GET",
// Path: "/v1/questions/{ID}/input",
// }
QuestionInput(QuestionInputRequest) QuestionInput
// +gunk http.Match{
// Method: "POST",
// Path: "/v1/questions/{ID}",
// Body: "Body",
// }
Submit(SubmitRequest) SubmitResponse
}
type PartData struct {
Completed bool `pb:"2" json:"completed"`
PointsWorth int `pb:"3" json:"points_worth"`
}
type Question struct {
2021-12-22 14:38:22 +07:00
ID string `pb:"1" json:"id"`
Title string `pb:"2" json:"title"`
Text string `pb:"3" json:"text"`
Part1 PartData `pb:"4" json:"part1"`
Part2 PartData `pb:"5" json:"part2"`
}
type QuestionsResponse struct {
Questions []Question `pb:"1" json:"questions"`
}
type QuestionByIDRequest struct {
ID string `pb:"1" json:"id"`
}
type QuestionInputRequest struct {
ID string `pb:"1" json:"id"`
}
type QuestionInput struct {
ID string `pb:"1" json:"id"`
Input string `pb:"2" json:"input"`
}
type SubmitRequestData struct {
Answer string `pb:"2" json:"answer"`
Part int `pb:"3" json:"part"`
Code string `pb:"4" json:"code"`
}
type SubmitRequest struct {
ID string `pb:"1" json:"id"`
Body SubmitRequestData `pb:"2" json:"body"`
}
type SubmitResponse struct {
Correct bool `pb:"3" json:"correct"`
Points int `pb:"5" json:"points"`
}