Fix: generation failure for primary school

This commit is contained in:
cyp0633 2022-09-20 15:36:24 +08:00
parent 6094f1514a
commit 5eeb2730ea
Signed by: cyp0633
GPG Key ID: CF90D09FB1FDCE45
3 changed files with 5 additions and 4 deletions

BIN
cmd/server/server Normal file

Binary file not shown.

View File

@ -12,15 +12,15 @@ const router = useRouter();
const difficulty = [
{
value: 0,
value: 1,
label: "小学",
},
{
value: 1,
value: 2,
label: "初中",
},
{
value: 2,
value: 3,
label: "高中",
},
];
@ -56,7 +56,7 @@ function getProblems() {
if (res.code == 0) {
alert("生成试卷成功");
var i = ref(0);
global.answers=[]; //
global.answers = []; //
for (i = 0; i < global.problems.length; i++) { // NaN
global.answers[i] = NaN;
}

View File

@ -23,6 +23,7 @@ type problemPost struct {
// GetPaper 生成试卷并返回给前端。
func (s *GetPaperService) GetPaper(c *gin.Context) {
var pSet []problemPost
s.Level-- // 前端传入的参数 1 代表小学以此类推0 会触发绑定错误,暂不清楚原因
if s.Level < 0 || s.Level > 2 || s.Num < 0 {
c.JSON(http.StatusBadRequest, gin.H{
"code": -1,