fix: fix conflict
This commit is contained in:
commit
fc883594fd
|
@ -3,15 +3,15 @@ package controllers
|
|||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"math"
|
||||
"openscore/models"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type testStruct struct {
|
||||
Name string
|
||||
}
|
||||
|
||||
func (c *TestPaperApiController) Display() {
|
||||
defer c.ServeJSON()
|
||||
var requestBody map[string]interface{}
|
||||
json.Unmarshal(c.Ctx.Input.RequestBody, &requestBody)
|
||||
|
||||
|
@ -28,20 +28,305 @@ func (c *TestPaperApiController) Display() {
|
|||
var subTopic []models.SubTopic
|
||||
testPaper.GetTestPaper(testId)
|
||||
topic.GetTopic(testPaper.Question_id)
|
||||
models.GetSubTopicsByQuestionId(testPaper.Question_id, &subTopic)
|
||||
var picSrcs []string
|
||||
models.GetSubTopicsByTestId(testPaper.Question_id, &subTopic)
|
||||
var testInfoList []models.TestPaperInfo
|
||||
for i := 0; i < len(subTopic); i++ {
|
||||
var testPaperInfo models.TestPaperInfo
|
||||
testPaperInfo.GetTestPaperInfoByTestIdAndQuestionDetailId(subTopic[i].Question_id, subTopic[i].Question_detail_id)
|
||||
picSrcs = append(picSrcs, testPaperInfo.Pic_src)
|
||||
testInfoList = append(testInfoList, testPaperInfo)
|
||||
}
|
||||
data := make(map[string]interface{})
|
||||
data["questionId"] = testPaper.Question_id
|
||||
|
||||
data["questionName"] = topic.Question_name
|
||||
data["subTopic"] = subTopic
|
||||
data["picSrcs"] = picSrcs
|
||||
data["picSrcs"] = testInfoList
|
||||
resp := Response{"10000", "OK", data}
|
||||
c.Data["json"] = resp
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *TestPaperApiController) List() {
|
||||
defer c.ServeJSON()
|
||||
var requestBody map[string]interface{}
|
||||
json.Unmarshal(c.Ctx.Input.RequestBody, &requestBody)
|
||||
|
||||
userIdstr := requestBody["userId"].(string)
|
||||
|
||||
userId, err := strconv.ParseInt(userIdstr, 10, 64)
|
||||
if err != nil {
|
||||
log.Println("parse userId fail")
|
||||
}
|
||||
var papers []models.UnderCorrectedPaper
|
||||
models.GetDistributedPaperByUserId(userId, &papers)
|
||||
data := make(map[string]interface{})
|
||||
data["papers"] = papers
|
||||
resp := Response{"10000", "OK", data}
|
||||
c.Data["json"] = resp
|
||||
|
||||
}
|
||||
|
||||
func (c *TestPaperApiController) Point() {
|
||||
defer c.ServeJSON()
|
||||
var requestBody map[string]interface{}
|
||||
json.Unmarshal(c.Ctx.Input.RequestBody, &requestBody)
|
||||
userIdstr := requestBody["userId"].(string)
|
||||
scoresstr := requestBody["scores"].(string)
|
||||
testIdstr := requestBody["testId"].(string)
|
||||
testDetailIdstr := requestBody["testDetailId"].(string)
|
||||
userId, _ := strconv.ParseInt(userIdstr, 10, 64)
|
||||
scores := strings.Split(scoresstr, "-")
|
||||
testDetailIds := strings.Split(testDetailIdstr, "-")
|
||||
testId, _ := strconv.ParseInt(testIdstr, 10, 64)
|
||||
var scoreArr []int64
|
||||
var sum int64 = 0
|
||||
for _, i := range scores {
|
||||
j, err := strconv.ParseInt(i, 10, 64)
|
||||
sum += j
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
scoreArr = append(scoreArr, j)
|
||||
}
|
||||
|
||||
var test models.TestPaper
|
||||
var topic models.Topic
|
||||
test.GetTestPaper(testId)
|
||||
topic.GetTopic(test.Question_id)
|
||||
// var testInfos []models.TestPaperInfo
|
||||
// models.GetTestInfoListByTestId(testId, &testInfos)
|
||||
|
||||
var underTest models.UnderCorrectedPaper
|
||||
underTest.GetUnderCorrectedPaper(userId, testId)
|
||||
// underTest.Delete()
|
||||
|
||||
final := false
|
||||
|
||||
if topic.Score_type == 1 {
|
||||
test.Examiner_first_id = userId
|
||||
test.Examiner_first_score = sum
|
||||
final = true
|
||||
} else if topic.Score_type == 2 && test.Examiner_first_id == 0 {
|
||||
test.Examiner_first_id = userId
|
||||
test.Examiner_first_score = sum
|
||||
} else if topic.Score_type == 2 && test.Examiner_second_id == 0 {
|
||||
test.Examiner_second_id = userId
|
||||
test.Examiner_second_score = sum
|
||||
if math.Abs(float64(test.Examiner_second_score)-float64(test.Examiner_first_score)) <= float64(topic.Standard_error) {
|
||||
log.Println(math.Abs(float64(test.Examiner_second_score) - float64(test.Examiner_first_score)))
|
||||
sum = int64(math.Abs(float64(test.Examiner_second_score+test.Examiner_first_score)) / 2)
|
||||
log.Println("hello world")
|
||||
final = true
|
||||
} else {
|
||||
newUnderTest := models.UnderCorrectedPaper{}
|
||||
newUnderTest.User_id = 10000
|
||||
newUnderTest.Test_question_type = 3
|
||||
newUnderTest.Test_id = underTest.Test_id
|
||||
newUnderTest.Question_id = underTest.Question_id
|
||||
newUnderTest.Save()
|
||||
}
|
||||
}
|
||||
if underTest.Test_question_type == 4 || underTest.Test_question_type == 5 {
|
||||
test.Leader_id = userId
|
||||
test.Leader_score = sum
|
||||
final = true
|
||||
} else if underTest.Test_question_type == 3 {
|
||||
test.Examiner_third_id = userId
|
||||
test.Examiner_third_score = sum
|
||||
first := math.Abs(float64(test.Examiner_third_score - test.Examiner_first_score))
|
||||
second := math.Abs(float64(test.Examiner_third_score - test.Examiner_second_score))
|
||||
var small float64
|
||||
if first <= second {
|
||||
small = first
|
||||
sum = (test.Examiner_third_score + test.Examiner_first_score) / 2
|
||||
} else {
|
||||
small = second
|
||||
sum = (test.Examiner_third_score + test.Examiner_second_score) / 2
|
||||
}
|
||||
if small <= float64(topic.Standard_error) {
|
||||
// test.Final_score = sum
|
||||
final = true
|
||||
} else {
|
||||
test.Question_status = 2
|
||||
|
||||
newUnderTest := models.UnderCorrectedPaper{}
|
||||
newUnderTest.User_id = 10000
|
||||
newUnderTest.Test_question_type = 4
|
||||
newUnderTest.Test_id = underTest.Test_id
|
||||
newUnderTest.Question_id = underTest.Question_id
|
||||
newUnderTest.Save()
|
||||
|
||||
}
|
||||
//??
|
||||
}
|
||||
if final {
|
||||
//???
|
||||
test.Final_score = sum
|
||||
}
|
||||
// else {
|
||||
// newUnderTest := underTest
|
||||
// newUnderTest.User_id = 10000
|
||||
// // newUnderTest.Test_question_type += 1
|
||||
// newUnderTest.Save()
|
||||
// }
|
||||
underTest.Delete()
|
||||
test.Update()
|
||||
for i := 0; i < len(scores); i++ {
|
||||
score := scoreArr[i]
|
||||
var tempTest models.TestPaperInfo
|
||||
id, _ := strconv.ParseInt(testDetailIds[i], 10, 64)
|
||||
log.Println(id)
|
||||
tempTest.GetTestPaperInfo(id)
|
||||
if topic.Score_type == 1 {
|
||||
tempTest.Examiner_first_id = userId
|
||||
tempTest.Examiner_first_score = score
|
||||
} else if topic.Score_type == 2 && tempTest.Examiner_first_id == 0 {
|
||||
tempTest.Examiner_first_id = userId
|
||||
tempTest.Examiner_first_score = score
|
||||
} else if topic.Score_type == 2 && tempTest.Examiner_second_id == 0 {
|
||||
tempTest.Examiner_second_id = userId
|
||||
tempTest.Examiner_second_score = score
|
||||
// if final{
|
||||
// score = int64(math.Abs(float64(tempTest.Examiner_second_score+tempTest.Examiner_first_score)) / 2)
|
||||
// }
|
||||
}
|
||||
if underTest.Test_question_type == 4 || underTest.Test_question_type == 5 {
|
||||
tempTest.Leader_id = userId
|
||||
tempTest.Leader_score = score
|
||||
} else if underTest.Test_question_type == 3 {
|
||||
tempTest.Examiner_third_id = userId
|
||||
tempTest.Examiner_third_score = score
|
||||
}
|
||||
if final {
|
||||
tempTest.Final_score = score
|
||||
}
|
||||
tempTest.Update()
|
||||
}
|
||||
|
||||
var record models.ScoreRecord
|
||||
record.Score = sum
|
||||
record.Question_id = topic.Question_id
|
||||
record.Test_id = testId
|
||||
record.Test_record_type = underTest.Test_question_type
|
||||
record.User_id = userId
|
||||
record.Score_time = time.Now()
|
||||
record.Save()
|
||||
}
|
||||
|
||||
func (c *TestPaperApiController) Problem() {
|
||||
defer c.ServeJSON()
|
||||
var requestBody map[string]interface{}
|
||||
json.Unmarshal(c.Ctx.Input.RequestBody, &requestBody)
|
||||
userIdstr := requestBody["userId"].(string)
|
||||
problemTypestr := requestBody["problemType"].(string)
|
||||
testIdstr := requestBody["testId"].(string)
|
||||
userId, _ := strconv.ParseInt(userIdstr, 10, 64)
|
||||
testId, _ := strconv.ParseInt(testIdstr, 10, 64)
|
||||
problemType, _ := strconv.ParseInt(problemTypestr, 10, 64)
|
||||
var underTest models.UnderCorrectedPaper
|
||||
var record models.ScoreRecord
|
||||
var test models.TestPaper
|
||||
|
||||
underTest.GetUnderCorrectedPaper(userId, testId)
|
||||
var newUnderTest = underTest
|
||||
underTest.Delete()
|
||||
newUnderTest.User_id = 10000
|
||||
newUnderTest.Test_question_type = 6
|
||||
newUnderTest.Problem_type = problemType
|
||||
has, _ := newUnderTest.IsDuplicate()
|
||||
if !has {
|
||||
log.Println("dup")
|
||||
newUnderTest.Save()
|
||||
test.GetTestPaper(testId)
|
||||
test.Question_status = 3
|
||||
test.Update()
|
||||
}
|
||||
|
||||
record.Test_record_type = 5
|
||||
record.Test_id = testId
|
||||
record.User_id = userId
|
||||
record.Question_id = test.Question_id
|
||||
record.Test_record_type = 5
|
||||
record.Save()
|
||||
}
|
||||
|
||||
func (c *TestPaperApiController) Answer() {
|
||||
defer c.ServeJSON()
|
||||
var requestBody map[string]interface{}
|
||||
json.Unmarshal(c.Ctx.Input.RequestBody, &requestBody)
|
||||
// userIdstr := requestBody["userId"].(string)
|
||||
testIdstr := requestBody["testId"].(string)
|
||||
testId, _ := strconv.ParseInt(testIdstr, 10, 64)
|
||||
var test models.TestPaper
|
||||
test.GetTestPaper(testId)
|
||||
var answerTest models.TestPaper
|
||||
answerTest.GetTestPaperByQuestionIdAndQuestionStatus(test.Question_id, 5)
|
||||
|
||||
var as []models.TestPaperInfo
|
||||
models.GetTestInfoListByTestId(answerTest.Test_id, &as)
|
||||
data := make(map[string]interface{})
|
||||
data["keyTest"] = as
|
||||
resp := Response{"10000", "ok", data}
|
||||
c.Data["json"] = resp
|
||||
}
|
||||
|
||||
func (c *TestPaperApiController) ExampleDeatil() {
|
||||
defer c.ServeJSON()
|
||||
var requestBody map[string]interface{}
|
||||
json.Unmarshal(c.Ctx.Input.RequestBody, &requestBody)
|
||||
// userIdstr := requestBody["userId"].(string)
|
||||
testIdstr := requestBody["exampleTestId"].(string)
|
||||
testId, _ := strconv.ParseInt(testIdstr, 10, 64)
|
||||
var test models.TestPaper
|
||||
test.GetTestPaper(testId)
|
||||
var exampleTest []models.TestPaper
|
||||
//??
|
||||
models.GetTestPaperListByQuestionIdAndQuestionStatus(test.Question_id, 6, &exampleTest)
|
||||
|
||||
var topic models.Topic
|
||||
topic.GetTopic(exampleTest[0].Question_id)
|
||||
var tests [][]models.TestPaperInfo
|
||||
for i := 0; i < len(exampleTest); i++ {
|
||||
var temp []models.TestPaperInfo
|
||||
models.GetTestInfoListByTestId(exampleTest[i].Test_id, &temp)
|
||||
tests = append(tests, temp)
|
||||
}
|
||||
data := make(map[string]interface{})
|
||||
data["questionName"] = topic.Question_name
|
||||
data["test"] = tests
|
||||
resp := Response{"10000", "ok", data}
|
||||
c.Data["json"] = resp
|
||||
|
||||
}
|
||||
|
||||
func (c *TestPaperApiController) ExampleList() {
|
||||
defer c.ServeJSON()
|
||||
var requestBody map[string]interface{}
|
||||
json.Unmarshal(c.Ctx.Input.RequestBody, &requestBody)
|
||||
// userIdstr := requestBody["userId"].(string)
|
||||
testIdstr := requestBody["testId"].(string)
|
||||
testId, _ := strconv.ParseInt(testIdstr, 10, 64)
|
||||
var testPaper models.TestPaper
|
||||
testPaper.GetTestPaper(testId)
|
||||
var exampleTest []models.TestPaper
|
||||
//??
|
||||
models.GetTestPaperListByQuestionIdAndQuestionStatus(testPaper.Question_id, 6, &exampleTest)
|
||||
data := make(map[string]interface{})
|
||||
data["exampleTestId"] = exampleTest
|
||||
resp := Response{"10000", "ok", data}
|
||||
c.Data["json"] = resp
|
||||
|
||||
}
|
||||
|
||||
func (c *TestPaperApiController) Review() {
|
||||
defer c.ServeJSON()
|
||||
var requestBody map[string]interface{}
|
||||
json.Unmarshal(c.Ctx.Input.RequestBody, &requestBody)
|
||||
userIdstr := requestBody["userId"].(string)
|
||||
userId, _ := strconv.ParseInt(userIdstr, 10, 64)
|
||||
var records []models.ScoreRecord
|
||||
models.GetLatestRecores(userId, &records)
|
||||
data := make(map[string]interface{})
|
||||
data["records"] = records
|
||||
resp := Response{"10000", "ok", data}
|
||||
c.Data["json"] = resp
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"C:\\Users\\yang\\Desktop\\阅卷系统\\controllers":1627556706151195000}
|
||||
{"C:\\Users\\yang\\Desktop\\阅卷系统\\controllers":1627556706151195000}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
// struct : Topic(大题)
|
||||
// comment: must capitalize the first letter of the field in Topic
|
||||
type Topic struct {
|
||||
Question_id int64 `xorm:"pk"`
|
||||
Question_id int64 `xorm:"pk autoincr"`
|
||||
Question_name string `xorm:"varchar(50)"`
|
||||
Subject_name string `xorm:"varchar(50)"`
|
||||
Standard_error int64
|
||||
|
@ -22,77 +22,80 @@ type Topic struct {
|
|||
}
|
||||
|
||||
type SubTopic struct {
|
||||
Question_detail_id int64 `xorm:"pk" `
|
||||
Question_detail_id int64 `xorm:"pk autoincr" `
|
||||
Question_detail_name string
|
||||
Question_id int64
|
||||
Question_detail_score int64
|
||||
}
|
||||
|
||||
type TestPaper struct {
|
||||
Test_id int64
|
||||
Test_id int64 `xorm:"pk autoincr"`
|
||||
Question_id int64
|
||||
Candidate string
|
||||
Correcting_status int64
|
||||
Question_status int64
|
||||
Examiner_first_id int64
|
||||
Examiner_first_id int64 `xorm:"default(0)"`
|
||||
Examiner_first_score int64
|
||||
Examiner_first_self_score int64
|
||||
Examiner_second_id int64
|
||||
Examiner_second_id int64 `xorm:"default(0)"`
|
||||
Examiner_second_score int64
|
||||
Examiner_second_self_score int64
|
||||
Examiner_third_id int64
|
||||
Examiner_third_id int64 `xorm:"default(0)"`
|
||||
Examiner_third_score int64
|
||||
Examiner_third_self_score int64
|
||||
Leader_id int64
|
||||
Leader_id int64 `xorm:"default(0)"`
|
||||
Leader_score int64
|
||||
Final_score int64
|
||||
Problem_type int64
|
||||
Final_score_id int64
|
||||
Pratice_error int64
|
||||
Answer_test_id int64
|
||||
Example_test_id int64
|
||||
}
|
||||
|
||||
type TestPaperInfo struct {
|
||||
Test_detail_id int64
|
||||
Test_detail_id int64 `xorm:"pk autoincr"`
|
||||
Question_detail_id int64
|
||||
Test_id int64
|
||||
Pic_src string
|
||||
Examiner_first_id int64
|
||||
Examiner_first_id int64 `xorm:"default(0)"`
|
||||
Examiner_first_score int64
|
||||
Examiner_first_self_score int64
|
||||
Examiner_second_id int64
|
||||
Examiner_second_id int64 `xorm:"default(0)"`
|
||||
Examiner_second_score int64
|
||||
Examiner_second_self_score int64
|
||||
Examiner_third_id int64
|
||||
Examiner_third_id int64 `xorm:"default(0)"`
|
||||
Examiner_third_score int64
|
||||
Examiner_third_self_score int64
|
||||
Leader_id int64
|
||||
Leader_id int64 `xorm:"default(0)"`
|
||||
Leader_score int64
|
||||
Final_score int64
|
||||
Final_score_id int64 `xorm:"default(0)"`
|
||||
}
|
||||
|
||||
type UnderCorrectedPaper struct {
|
||||
UnderCorrected_id int64 `xorm:"pk autoincr"`
|
||||
User_id int64
|
||||
Test_id int64
|
||||
Question_id int64
|
||||
Test_question_type int64
|
||||
Problem_type int64 `xorm:"default(-1)"`
|
||||
}
|
||||
|
||||
type ScoreRecord struct {
|
||||
Record_id int64
|
||||
Record_id int64 `xorm:"pk autoincr"`
|
||||
Question_id int64
|
||||
Test_id int64
|
||||
Tser_id int64
|
||||
Score_time int64
|
||||
User_id int64
|
||||
Score_time time.Time
|
||||
Score int64
|
||||
Self_score int64
|
||||
Test_record_type int64
|
||||
Score_type int64
|
||||
Problem_type int64 `xorm:"default(-1)"`
|
||||
}
|
||||
|
||||
type PaperDistribution struct {
|
||||
Distribution_id int64 `xorm:"pk autoincr"`
|
||||
User_id int64
|
||||
Question_id int64
|
||||
Test_distribution_number int64
|
||||
Test_success_number int64
|
||||
Test_remaining_number int64
|
||||
PaperType int64
|
||||
}
|
||||
|
||||
|
@ -119,6 +122,48 @@ func GetSubTopicsByQuestionId(id int64, st *[]SubTopic) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func GetSubTopicsByTestId(id int64, st *[]SubTopic) error {
|
||||
err := x.Where(builder.Eq{"question_id": id}).Find(st)
|
||||
if err != nil {
|
||||
log.Println("could not find any SubTopic")
|
||||
log.Println(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func GetDistributedPaperByUserId(id int64, up *[]UnderCorrectedPaper) error {
|
||||
err := x.Where("user_id = ?", id).Find(up)
|
||||
if err != nil {
|
||||
log.Println("could not find any paper")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func GetTestInfoListByTestId(id int64, as *[]TestPaperInfo) error {
|
||||
err := x.Where("test_id = ?", id).Find(as)
|
||||
if err != nil {
|
||||
log.Println("could not find any paper")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *TestPaper) GetTestPaperByQuestionIdAndQuestionStatus(question_id int64, question_statue int64) error {
|
||||
has, err := x.Where("question_id = ? and question_status = ?", question_id, question_statue).Get(t)
|
||||
if !has || err != nil {
|
||||
log.Println("could not specific test")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func GetTestPaperListByQuestionIdAndQuestionStatus(question_id int64, question_statue int64, tl *[]TestPaper) error {
|
||||
err := x.Where("question_id = ? and question_status = ?", question_id, question_statue).Find(tl)
|
||||
if err != nil {
|
||||
log.Println("could not specific test")
|
||||
log.Println(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *TestPaperInfo) GetTestPaperInfoByTestIdAndQuestionDetailId(testId int64, questionDetailId int64) error {
|
||||
has, err := x.Where("question_detail_id = ? and test_id = ?", questionDetailId, testId).Get(t)
|
||||
if !has || err != nil {
|
||||
|
@ -147,14 +192,24 @@ func (t *TestPaperInfo) GetTestPaperInfo(id int64) error {
|
|||
has, err := x.Where(builder.Eq{"test_detail_id": id}).Get(t)
|
||||
if !has || err != nil {
|
||||
log.Println("could not find test paper info")
|
||||
log.Println(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (u *UnderCorrectedPaper) GetUnderCorrectedPaper(id int64) error {
|
||||
has, err := x.Where(builder.Eq{"user_id": id}).Get(u)
|
||||
func (u *UnderCorrectedPaper) GetUnderCorrectedPaper(userId int64, testId int64) error {
|
||||
has, err := x.Where(builder.Eq{"test_id": testId, "user_id": userId}).Get(u)
|
||||
if !has || err != nil {
|
||||
log.Println("could not find under corrected paper")
|
||||
log.Println(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (u *UnderCorrectedPaper) Delete() error {
|
||||
code, err := x.Where(builder.Eq{"test_id": u.Test_id, "user_id": u.User_id}).Delete(u)
|
||||
if code == 0 || err != nil {
|
||||
log.Println("delete fail")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@ -174,3 +229,57 @@ func (s *ScoreRecord) GetTopic(id int64) error {
|
|||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *TestPaperInfo) Update() error {
|
||||
code, err := x.Where(builder.Eq{"test_detail_id": t.Test_detail_id}).Update(t)
|
||||
if code == 0 || err != nil {
|
||||
log.Println("update test paper info fail")
|
||||
log.Println(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (t *TestPaper) Update() error {
|
||||
code, err := x.Where(builder.Eq{"test_id": t.Test_id}).Update(t)
|
||||
if code == 0 || err != nil {
|
||||
log.Println("update test paper fail")
|
||||
log.Printf("%+v", err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *ScoreRecord) Save() error {
|
||||
code, err := x.Insert(r)
|
||||
if code == 0 || err != nil {
|
||||
log.Println("insert record fail")
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (u *UnderCorrectedPaper) Save() error {
|
||||
code, err := x.Insert(u)
|
||||
if code == 0 || err != nil {
|
||||
log.Println("insert paper fail")
|
||||
log.Println(err)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (u *UnderCorrectedPaper) IsDuplicate() (bool, error) {
|
||||
var temp UnderCorrectedPaper
|
||||
has, err := x.Where(builder.Eq{"test_id": u.Test_id, "problem_type": u.Problem_type}).Get(&temp)
|
||||
if !has || err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
return has, err
|
||||
}
|
||||
|
||||
func GetLatestRecores(userId int64, records *[]ScoreRecord) error {
|
||||
// x.QueryString("select top 10 * from scoreRecord where user_id = " + strconv.FormatInt(userId, 10) + " order by record_id desc")
|
||||
err := x.Limit(10).Where(builder.Eq{"user_id": userId}).Desc("record_id").Find(records)
|
||||
if err != nil {
|
||||
log.Println("could not find any paper")
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
67
openct.http
67
openct.http
|
@ -1,10 +1,67 @@
|
|||
|
||||
POST http://localhost:8080/openct/marking/score/test/display HTTP/1.1
|
||||
Content-Type: application/json
|
||||
# POST http://localhost:8080/openct/marking/score/test/display HTTP/1.1
|
||||
# Content-Type: application/json
|
||||
|
||||
{
|
||||
"testId":"100"
|
||||
}
|
||||
# {
|
||||
# "testId":"1"
|
||||
# }
|
||||
|
||||
# POST http://localhost:8080/openct/marking/score/test/list HTTP/1.1
|
||||
# Content-Type: application/json
|
||||
|
||||
# {
|
||||
# "userId":"100"
|
||||
# }
|
||||
|
||||
# POST http://localhost:8080/openct/marking/score/test/point HTTP/1.1
|
||||
# Content-Type: application/json
|
||||
|
||||
# {
|
||||
# "userId":"10000",
|
||||
# "scores": "6",
|
||||
# "testId":"6",
|
||||
# "testDetailId": "12"
|
||||
# }
|
||||
|
||||
# POST http://localhost:8080/openct/marking/score/test/problem HTTP/1.1
|
||||
# Content-Type: application/json
|
||||
|
||||
# {
|
||||
# "userId":"102",
|
||||
# "problemType": "2",
|
||||
# "testId":"1"
|
||||
# }
|
||||
|
||||
# POST http://localhost:8080/openct/marking/score/test/answer HTTP/1.1
|
||||
# Content-Type: application/json
|
||||
|
||||
# {
|
||||
# "userId":"101",
|
||||
# "testId":"1"
|
||||
# }
|
||||
|
||||
# POST http://localhost:8080/openct/marking/score/test/example/detail HTTP/1.1
|
||||
# Content-Type: application/json
|
||||
|
||||
# {
|
||||
# "userId":"101",
|
||||
# "exampleTestId":"1"
|
||||
# }
|
||||
|
||||
# POST http://localhost:8080/openct/marking/score/test/example/list HTTP/1.1
|
||||
# Content-Type: application/json
|
||||
|
||||
# {
|
||||
# "userId":"101",
|
||||
# "testId":"1"
|
||||
# }
|
||||
|
||||
# POST http://localhost:8080/openct/marking/score/test/review HTTP/1.1
|
||||
# Content-Type: application/json
|
||||
|
||||
# {
|
||||
# "userId":"101"
|
||||
# }
|
||||
|
||||
# POST http://localhost:8080 HTTP/1.1
|
||||
# Content-Type: application/json
|
||||
|
|
|
@ -20,6 +20,13 @@ func init() {
|
|||
beego.Router("/api/logout", &controllers.ApiController{}, "post:Logout")
|
||||
beego.Router("/api/get-account", &controllers.ApiController{}, "get:GetAccount")
|
||||
beego.Router("/openct/marking/score/test/display", &controllers.TestPaperApiController{}, "post:Display")
|
||||
beego.Router("/openct/marking/score/test/list", &controllers.TestPaperApiController{}, "post:List")
|
||||
beego.Router("/openct/marking/score/test/point", &controllers.TestPaperApiController{}, "post:Point")
|
||||
beego.Router("/openct/marking/score/test/problem", &controllers.TestPaperApiController{}, "post:Problem")
|
||||
beego.Router("/openct/marking/score/test/answer", &controllers.TestPaperApiController{}, "post:Answer")
|
||||
beego.Router("/openct/marking/score/test/example/detail", &controllers.TestPaperApiController{}, "post:ExampleDeatil")
|
||||
beego.Router("/openct/marking/score/test/example/list", &controllers.TestPaperApiController{}, "post:ExampleList")
|
||||
beego.Router("/openct/marking/score/test/review", &controllers.TestPaperApiController{}, "post:Review")
|
||||
|
||||
// beego.Router("/api/get-users", &controllers.ApiController{}, "GET:GetUsers")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue