-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 搜索
- 重置
-
-
-
-
-
@@ -111,6 +86,7 @@ const bankModel = ref(null);
const examListVisible = ref(false);
const examListBankId = ref(null);
+const examListBankName = ref('');
const auth = useAuthStore();
@@ -156,7 +132,7 @@ const handleBatchImport = () => {
ElMessage.info('批量导入功能开发中');
};
-const handleView = async (row) => {};
+const handleView = async (row) => { };
const handleRefresh = () => {
fetchBankList();
@@ -171,6 +147,7 @@ const handleBankSaved = async (payload) => {
}
ElMessage.success('保存成功');
bankVisible.value = false;
+ await fetchBankList();
} catch (e) {
ElMessage.error('保存失败');
}
@@ -184,6 +161,7 @@ const handleEdit = (row) => {
const handleAdd = (row) => {
examListBankId.value = row?.id || null;
+ examListBankName.value = row?.bank_name || '';
examListVisible.value = true;
};
@@ -214,7 +192,7 @@ const handleDelete = async (row) => {
ElMessage.success('删除成功');
fetchBankList();
} catch (error) {
-
+
}
};
@@ -301,6 +279,7 @@ onMounted(() => {
.form-actions {
display: flex;
gap: 12px;
+ justify-content: space-between;
}
}
diff --git a/pc/src/views/apps/exams/examinee/index.vue b/pc/src/views/apps/exams/examinee/index.vue
index e69de29..05d7448 100644
--- a/pc/src/views/apps/exams/examinee/index.vue
+++ b/pc/src/views/apps/exams/examinee/index.vue
@@ -0,0 +1,3 @@
+
+ Examinee
+
diff --git a/pc/src/views/apps/exams/practice/index.vue b/pc/src/views/apps/exams/practice/index.vue
index e69de29..6582c14 100644
--- a/pc/src/views/apps/exams/practice/index.vue
+++ b/pc/src/views/apps/exams/practice/index.vue
@@ -0,0 +1,3 @@
+
+ Practice
+
diff --git a/pc/src/views/apps/exams/training/index.vue b/pc/src/views/apps/exams/training/index.vue
index e69de29..a6316c9 100644
--- a/pc/src/views/apps/exams/training/index.vue
+++ b/pc/src/views/apps/exams/training/index.vue
@@ -0,0 +1,3 @@
+
+ Training
+
diff --git a/server/conf/app.conf b/server/conf/app.conf
index 54495d3..cdf9ebe 100644
--- a/server/conf/app.conf
+++ b/server/conf/app.conf
@@ -6,7 +6,7 @@ runmode = dev
# MySQL - 远程连接配置
mysqluser = gotest
mysqlpass = 2nZhRdMPCNZrdzsd
-mysqlurls = 192.168.31.10:3306
+mysqlurls = 212.64.112.158:3388
mysqldb = gotest
# ORM配置
diff --git a/server/controllers/exam.go b/server/controllers/exam.go
index 7526a63..7bbbfc7 100644
--- a/server/controllers/exam.go
+++ b/server/controllers/exam.go
@@ -24,6 +24,8 @@ func (c *ExamQuestionController) GetList() {
tenantId, _ := c.Ctx.Input.GetData("tenantId").(int)
keyword := c.GetString("keyword")
typeStr := c.GetString("type")
+ bankId, _ := c.GetInt64("bank_id", 0)
+
var qtype *int8
if typeStr != "" {
if iv, err := strconv.Atoi(typeStr); err == nil {
@@ -31,12 +33,15 @@ func (c *ExamQuestionController) GetList() {
qtype = &v
}
}
+
page, _ := c.GetInt("page", 1)
pageSize, _ := c.GetInt("pageSize", 10)
+
list, total, err := services.GetExamQuestions(services.QuestionListParams{
TenantId: tenantId,
Keyword: keyword,
QuestionType: qtype,
+ BankId: bankId,
Page: page,
PageSize: pageSize,
})
@@ -45,7 +50,7 @@ func (c *ExamQuestionController) GetList() {
c.ServeJSON()
return
}
- // build minimal DTO to limit fields in response
+
items := make([]map[string]interface{}, 0, len(list))
for _, q := range list {
if q == nil {
@@ -59,6 +64,7 @@ func (c *ExamQuestionController) GetList() {
"score": q.Score,
})
}
+
c.Data["json"] = map[string]interface{}{
"code": 0,
"message": "ok",
@@ -101,6 +107,7 @@ func (c *ExamQuestionController) Create() {
QuestionAnalysis string `json:"question_analysis"`
Options []map[string]string `json:"options"`
Answer interface{} `json:"answer"`
+ BankId int64 `json:"bank_id"`
}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &payload); err != nil {
c.Data["json"] = map[string]interface{}{"code": 1, "message": "请求参数错误: " + err.Error(), "data": nil}
@@ -115,6 +122,9 @@ func (c *ExamQuestionController) Create() {
Score: payload.Score,
Status: 1,
}
+ if payload.BankId > 0 {
+ q.BankId = payload.BankId
+ }
var opts []models.ExamQuestionOption
for _, o := range payload.Options {
opts = append(opts, models.ExamQuestionOption{OptionLabel: o["label"], OptionContent: o["content"]})
@@ -149,6 +159,7 @@ func (c *ExamQuestionController) Create() {
func (c *ExamQuestionController) BatchCreate() {
tenantId, _ := c.Ctx.Input.GetData("tenantId").(int)
var payload struct {
+ BankId int64 `json:"bank_id"`
Items []struct {
QuestionTitle string `json:"question_title"`
QuestionType int8 `json:"question_type"`
@@ -182,6 +193,9 @@ func (c *ExamQuestionController) BatchCreate() {
Score: item.Score,
Status: 1,
}
+ if payload.BankId > 0 {
+ q.BankId = payload.BankId
+ }
var opts []models.ExamQuestionOption
for _, o := range item.Options {
opts = append(opts, models.ExamQuestionOption{OptionLabel: o["label"], OptionContent: o["content"]})
@@ -251,6 +265,7 @@ func (c *ExamQuestionController) Update() {
QuestionAnalysis string `json:"question_analysis"`
Options []map[string]string `json:"options"`
Answer interface{} `json:"answer"`
+ BankId int64 `json:"bank_id"`
}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &payload); err != nil {
c.Data["json"] = map[string]interface{}{"code": 1, "message": "请求参数错误: " + err.Error(), "data": nil}
@@ -258,6 +273,9 @@ func (c *ExamQuestionController) Update() {
return
}
q := &models.ExamQuestion{QuestionType: payload.QuestionType, QuestionTitle: payload.QuestionTitle, QuestionAnalysis: payload.QuestionAnalysis, Score: payload.Score}
+ if payload.BankId > 0 {
+ q.BankId = payload.BankId
+ }
var opts []models.ExamQuestionOption
for _, o := range payload.Options {
opts = append(opts, models.ExamQuestionOption{OptionLabel: o["label"], OptionContent: o["content"]})
diff --git a/server/models/exam.go b/server/models/exam.go
index 1208d6a..a1ca7d4 100644
--- a/server/models/exam.go
+++ b/server/models/exam.go
@@ -10,6 +10,7 @@ import (
type ExamQuestion struct {
Id int64 `orm:"column(id);auto" json:"id"`
TenantId int `orm:"column(tenant_id)" json:"tenant_id"`
+ BankId int64 `orm:"column(bank_id);null" json:"bank_id"`
QuestionType int8 `orm:"column(question_type)" json:"question_type"`
QuestionTitle string `orm:"column(question_title);size(1000)" json:"question_title"`
QuestionAnalysis string `orm:"column(question_analysis);size(2000);null" json:"question_analysis"`
diff --git a/server/services/exam.go b/server/services/exam.go
index 0f79893..d60f764 100644
--- a/server/services/exam.go
+++ b/server/services/exam.go
@@ -13,6 +13,7 @@ type QuestionListParams struct {
TenantId int
Keyword string
QuestionType *int8
+ BankId int64
Page int
PageSize int
}
@@ -42,6 +43,9 @@ func GetExamQuestions(params QuestionListParams) ([]*models.ExamQuestion, int64,
if params.QuestionType != nil {
qs = qs.Filter("question_type", *params.QuestionType)
}
+ if params.BankId > 0 {
+ qs = qs.Filter("bank_id", params.BankId)
+ }
total, err := qs.Count()
if err != nil {
return nil, 0, err
@@ -121,7 +125,13 @@ func UpdateExamQuestion(tenantId int, id int64, q *models.ExamQuestion, options
existing.QuestionTitle = q.QuestionTitle
existing.QuestionAnalysis = q.QuestionAnalysis
existing.Score = q.Score
- if _, err := o.Update(&existing, "QuestionType", "QuestionTitle", "QuestionAnalysis", "Score"); err != nil {
+ // 可选更新题库归属
+ fields := []string{"QuestionType", "QuestionTitle", "QuestionAnalysis", "Score"}
+ if q.BankId > 0 {
+ existing.BankId = q.BankId
+ fields = append(fields, "BankId")
+ }
+ if _, err := o.Update(&existing, fields...); err != nil {
return err
}
// soft delete old options and answer