diff --git a/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/models/QsvSubject.java b/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/models/QsvSubject.java
index 3d50e73..43811f2 100644
--- a/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/models/QsvSubject.java
+++ b/src/main/java/com/budwk/app/zhgh/dayofficework/qsv/models/QsvSubject.java
@@ -38,6 +38,15 @@ public class QsvSubject extends BaseModel implements Serializable {
@ColDefine(type = ColType.VARCHAR, width = 50)
private String type;
+ /**
+ * 是否必须作答;新题默认必填,历史空值由答题页面按必填兼容。
+ */
+ @Column
+ @Comment("是否必填")
+ @ColDefine(type = ColType.BOOLEAN)
+ @Default("1")
+ private Boolean required = true;
+
@Column
@Comment("正确答案")
@ColDefine(type = ColType.MYSQL_JSON)
diff --git a/src/main/resources/views/platform/zhgh/dayofficework/qsv/activity/subjectForm.js b/src/main/resources/views/platform/zhgh/dayofficework/qsv/activity/subjectForm.js
index bdf3dd3..fe174c6 100644
--- a/src/main/resources/views/platform/zhgh/dayofficework/qsv/activity/subjectForm.js
+++ b/src/main/resources/views/platform/zhgh/dayofficework/qsv/activity/subjectForm.js
@@ -48,6 +48,17 @@ const subjectForm = {
+
+ 是否必填:
+
+
+
+
+
最大选择数:
@@ -355,7 +366,11 @@ const subjectForm = {
})
$.post("/platform/qsv/activity/listSubjects", {activityId: id}).then((res) => {
if (res.code === 0) {
- this.subjects = res.data
+ // 旧题未设置必填属性时沿用必填规则,已设置的非必填值保持不变。
+ res.data.forEach((subject) => {
+ this.$set(subject, "required", subject.required !== false)
+ })
+ this.$set(this, "subjects", res.data)
}
})
}
@@ -373,6 +388,8 @@ const subjectForm = {
title: "",
hint: "",
type: "radio",
+ // 手工新增题目默认必填,允许在题目类型右侧切换为非必填。
+ required: true,
score: 0,
displayDate: "",
options: [
@@ -394,6 +411,11 @@ const subjectForm = {
})
},
+ // subject 为当前题目,required 为下拉框返回的布尔值;响应式更新必填设置,不返回结果。
+ subjectRequiredChange(subject, required) {
+ this.$set(subject, "required", required)
+ },
+
//题目类型切换
subjectTypeChange(subject, subjectIndex) {
if (subject.type === 'text') {
@@ -615,6 +637,8 @@ const subjectForm = {
// 更新导入题目的序号
importedQuestions.forEach((question, index) => {
question.sortNum = startSortNum + index;
+ // 文本导入没有必填配置时默认必填,保留明确的非必填设置。
+ this.$set(question, "required", question.required !== false);
});
// 将导入的题目添加到现有题目列表
diff --git a/src/main/resources/views/platform/zhghh5/dayofficework/qsv/quiz/index.html b/src/main/resources/views/platform/zhghh5/dayofficework/qsv/quiz/index.html
index a107bf9..2d9d53e 100644
--- a/src/main/resources/views/platform/zhghh5/dayofficework/qsv/quiz/index.html
+++ b/src/main/resources/views/platform/zhghh5/dayofficework/qsv/quiz/index.html
@@ -15,7 +15,8 @@ layout("/layouts/platform_h5.html"){
-
{{index+1}}、{{ subject.title }}
+
+
*{{index+1}}、{{ subject.title }}
多选
单选
@@ -261,6 +262,10 @@ layout("/layouts/platform_h5.html"){
//提示那些题没有作答
for (let i = 0; i < this.subjects.length; i++) {
let subject = this.subjects[i]
+ // 明确设置非必填的题目允许留空,旧题缺失该属性时仍须作答。
+ if (subject.required === false) {
+ continue
+ }
//["radio", "checkbox"].includes(subject.type) &&
if (!subject.userSelectOptionIds || subject.userSelectOptionIds.length === 0) {
this.$toast.fail("第" + (i + 1) + "题未做答")
diff --git a/src/main/resources/views/platform/zhghh5/dayofficework/qsv/survey/index.html b/src/main/resources/views/platform/zhghh5/dayofficework/qsv/survey/index.html
index b9b9bfe..0cf7f82 100644
--- a/src/main/resources/views/platform/zhghh5/dayofficework/qsv/survey/index.html
+++ b/src/main/resources/views/platform/zhghh5/dayofficework/qsv/survey/index.html
@@ -92,7 +92,8 @@ layout("/layouts/platform_h5.html"){
{{ activity.title }}
-
{{index+1}}、{{ subject.title }}
+
+
*{{index+1}}、{{ subject.title }}
多选
单选
@@ -341,6 +342,10 @@ layout("/layouts/platform_h5.html"){
//提示那些题没有作答
for (let i = 0; i < this.visibleSubjects.length; i++) {
const subject = this.visibleSubjects[i]
+ // 仅校验可见的必填题;旧题属性缺失或为空时仍按必填处理。
+ if (subject.required === false) {
+ continue
+ }
if (["radio", "checkbox"].includes(subject.type)) {
if (!subject.userSelectOptionIds || subject.userSelectOptionIds.length === 0) {
this.$toast.fail("第" + (i + 1) + "题未做答")