|
@@ -0,0 +1,89 @@
|
|
|
+import { watch } from "vue";
|
|
|
+import { message } from "ant-design-vue";
|
|
|
+import vls from "@/utils/storage";
|
|
|
+import { useMarkStore } from "@/store";
|
|
|
+import { Setting } from "@/types";
|
|
|
+
|
|
|
+interface TaskTips {
|
|
|
+ studentId: string;
|
|
|
+ questionNos: string;
|
|
|
+ questionModel: Setting["questionModel"] | null;
|
|
|
+}
|
|
|
+
|
|
|
+export default function useTaskTips() {
|
|
|
+ const markStore = useMarkStore();
|
|
|
+
|
|
|
+ function getPrevTips(): TaskTips {
|
|
|
+ return vls.get("prevTips", {
|
|
|
+ studentId: "",
|
|
|
+ questionNos: "",
|
|
|
+ questionModel: null,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function setPrevTips() {
|
|
|
+ const { studentId, questionList } = markStore.currentTask || {};
|
|
|
+ const { questionModel } = markStore.setting || {};
|
|
|
+ const questionNos = (questionList || [])
|
|
|
+ .map((q) => `${q.mainNumber}-${q.subNumber}`)
|
|
|
+ .join(",");
|
|
|
+
|
|
|
+ vls.set("prevTips", {
|
|
|
+ studentId,
|
|
|
+ questionNos,
|
|
|
+ questionModel,
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function checkShowTips() {
|
|
|
+ if (!markStore.currentTask || !markStore.setting) return;
|
|
|
+
|
|
|
+ const prevTips = getPrevTips();
|
|
|
+ if (!prevTips.studentId) return;
|
|
|
+
|
|
|
+ const questionNos = (markStore.currentTask.questionList || [])
|
|
|
+ .map((q) => `${q.mainNumber}-${q.subNumber}`)
|
|
|
+ .join(",");
|
|
|
+ const { questionModel } = markStore.setting;
|
|
|
+
|
|
|
+ // 按小题阅卷
|
|
|
+ // 前一个题结束切换到下一个题时提示信息:
|
|
|
+ // “当前评阅3-2题已经评完,切换到3-3题进行评卷”
|
|
|
+ if (
|
|
|
+ prevTips.questionModel === questionModel &&
|
|
|
+ questionModel === "SINGLE"
|
|
|
+ ) {
|
|
|
+ if (prevTips.questionNos !== questionNos) {
|
|
|
+ void message.info({
|
|
|
+ content: `当前评阅${prevTips.questionNos}题已经评完,切换到${questionNos}题进行评卷`,
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 整卷阅
|
|
|
+ // 从按小题阅卷切换到阅全部题目提示信息:
|
|
|
+ // “开始评3-1,3-2,3-2小题,请将全部题目都给分再提交”
|
|
|
+ if (prevTips.questionModel !== questionModel && questionModel === "MULTI") {
|
|
|
+ void message.info({
|
|
|
+ content: `开始评${questionNos}小题,请将全部题目都给分再提交`,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function registTaskChangeTips() {
|
|
|
+ watch(
|
|
|
+ () => markStore.currentTask,
|
|
|
+ () => {
|
|
|
+ checkShowTips();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return {
|
|
|
+ getPrevTips,
|
|
|
+ setPrevTips,
|
|
|
+ checkShowTips,
|
|
|
+ registTaskChangeTips,
|
|
|
+ };
|
|
|
+}
|