diff --git a/backend/my_work/routers/apiQuiz.go b/backend/my_work/routers/apiQuiz.go
index 4ede6bd..eb5eb3b 100644
--- a/backend/my_work/routers/apiQuiz.go
+++ b/backend/my_work/routers/apiQuiz.go
@@ -434,21 +434,6 @@ func quizBankNameMap(sessions []TabQuizSession) map[uint]string { ids := []uint{
return m
}
-// quizDefaultCount 各题型默认抽题数
-func quizDefaultCount(qType string) int {
- switch qType {
- case QuizTypeSingle:
- return 20
- case QuizTypeMultiple:
- return 10
- case QuizTypeJudge:
- return 20
- case QuizTypeBlank:
- return 10
- }
- return 10
-}
-
// ApiQuizInit 初始化答题模块
func ApiQuizInit() {
models.DB.AutoMigrate(&TabQuizBank{})
@@ -503,17 +488,17 @@ func ApiQuiz(r *gin.RouterGroup) {
ReturnJson(ctx, "jsonErr", nil)
return
}
- if from.CountSingle <= 0 {
- from.CountSingle = quizDefaultCount(QuizTypeSingle)
+ if from.CountSingle < 0 {
+ from.CountSingle = 0
}
- if from.CountMultiple <= 0 {
- from.CountMultiple = quizDefaultCount(QuizTypeMultiple)
+ if from.CountMultiple < 0 {
+ from.CountMultiple = 0
}
- if from.CountJudge <= 0 {
- from.CountJudge = quizDefaultCount(QuizTypeJudge)
+ if from.CountJudge < 0 {
+ from.CountJudge = 0
}
- if from.CountBlank <= 0 {
- from.CountBlank = quizDefaultCount(QuizTypeBlank)
+ if from.CountBlank < 0 {
+ from.CountBlank = 0
}
if from.DurationSec < 0 {
from.DurationSec = 0
@@ -550,10 +535,10 @@ func ApiQuiz(r *gin.RouterGroup) {
ID uint `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
- CountSingle int `json:"countSingle"`
- CountMultiple int `json:"countMultiple"`
- CountJudge int `json:"countJudge"`
- CountBlank int `json:"countBlank"`
+ CountSingle *int `json:"countSingle"`
+ CountMultiple *int `json:"countMultiple"`
+ CountJudge *int `json:"countJudge"`
+ CountBlank *int `json:"countBlank"`
DurationSec int `json:"durationSec"`
Active *bool `json:"active"`
}
@@ -573,17 +558,29 @@ func ApiQuiz(r *gin.RouterGroup) {
if from.Description != "" {
bank.Description = from.Description
}
- if from.CountSingle > 0 {
- bank.CountSingle = from.CountSingle
+ if from.CountSingle != nil {
+ bank.CountSingle = *from.CountSingle
+ if bank.CountSingle < 0 {
+ bank.CountSingle = 0
+ }
}
- if from.CountMultiple > 0 {
- bank.CountMultiple = from.CountMultiple
+ if from.CountMultiple != nil {
+ bank.CountMultiple = *from.CountMultiple
+ if bank.CountMultiple < 0 {
+ bank.CountMultiple = 0
+ }
}
- if from.CountJudge > 0 {
- bank.CountJudge = from.CountJudge
+ if from.CountJudge != nil {
+ bank.CountJudge = *from.CountJudge
+ if bank.CountJudge < 0 {
+ bank.CountJudge = 0
+ }
}
- if from.CountBlank > 0 {
- bank.CountBlank = from.CountBlank
+ if from.CountBlank != nil {
+ bank.CountBlank = *from.CountBlank
+ if bank.CountBlank < 0 {
+ bank.CountBlank = 0
+ }
}
if from.DurationSec >= 0 {
bank.DurationSec = from.DurationSec
@@ -1096,7 +1093,7 @@ func ApiQuiz(r *gin.RouterGroup) {
questions := []TabQuizQuestion{}
for _, d := range typeDraws {
if d.count <= 0 {
- d.count = quizDefaultCount(d.qType)
+ continue
}
var pool []TabQuizQuestion
models.DB.Where("bank_id = ? AND active = ? AND type = ?", bank.ID, true, d.qType).Find(&pool)
diff --git a/frontend/ops_vue_js/src/i18n/en.json b/frontend/ops_vue_js/src/i18n/en.json
index 1df05a2..69e3c60 100644
--- a/frontend/ops_vue_js/src/i18n/en.json
+++ b/frontend/ops_vue_js/src/i18n/en.json
@@ -945,7 +945,7 @@
"delete_title": "Delete Bank",
"delete_msg": "Deleting \"{name}\" will also delete all its questions. Continue?",
"err_name_required": "Please enter the bank name",
- "draw_count_hint": "Random draw count per type; draws all of that type if fewer are available",
+ "draw_count_hint": "Random draw count per type; 0 = do not draw this type; draws all of that type if fewer are available",
"back": "Back to banks",
"manage_questions": "Manage Questions",
"single_short": "S",
diff --git a/frontend/ops_vue_js/src/i18n/zh-CN.json b/frontend/ops_vue_js/src/i18n/zh-CN.json
index a6bba6f..e81e3bd 100644
--- a/frontend/ops_vue_js/src/i18n/zh-CN.json
+++ b/frontend/ops_vue_js/src/i18n/zh-CN.json
@@ -946,7 +946,7 @@
"delete_title": "删除题库",
"delete_msg": "删除题库\"{name}\"将同时删除其下所有题目,确认继续?",
"err_name_required": "请填写题库名称",
- "draw_count_hint": "每种题型随机抽取数量,题目不足则该题型全部抽取",
+ "draw_count_hint": "每种题型随机抽取数量,填 0 表示该题型不抽取;题目不足则全部抽取",
"back": "返回题库列表",
"manage_questions": "管理题目",
"single_short": "单",
diff --git a/frontend/ops_vue_js/src/views/quiz/ManageBanks.vue b/frontend/ops_vue_js/src/views/quiz/ManageBanks.vue
index c9bfabe..83ac39a 100644
--- a/frontend/ops_vue_js/src/views/quiz/ManageBanks.vue
+++ b/frontend/ops_vue_js/src/views/quiz/ManageBanks.vue
@@ -169,10 +169,10 @@ function openEdit(row, event) {
editingId.value = row.id
form.name = row.name
form.description = row.description || ''
- form.countSingle = row.countSingle || 20
- form.countMultiple = row.countMultiple || 10
- form.countJudge = row.countJudge || 20
- form.countBlank = row.countBlank || 10
+ form.countSingle = row.countSingle ?? 20
+ form.countMultiple = row.countMultiple ?? 10
+ form.countJudge = row.countJudge ?? 20
+ form.countBlank = row.countBlank ?? 10
form.durationMin = Math.round((row.durationSec || 0) / 60)
showModal.value = true
}
@@ -437,7 +437,7 @@ onMounted(fetchBanks)
@@ -447,7 +447,7 @@ onMounted(fetchBanks)
@@ -457,7 +457,7 @@ onMounted(fetchBanks)
@@ -467,7 +467,7 @@ onMounted(fetchBanks)