Fix: generation failure for primary school
This commit is contained in:
parent
6094f1514a
commit
5eeb2730ea
Binary file not shown.
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue