|
|
|
|
@ -23,7 +23,7 @@
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
import { ElMessage } from "element-plus";
|
|
|
|
|
import { readTrainingReviewPreview } from "@/utils/trainingReviewPreview";
|
|
|
|
|
import { isPreviewAnswerSubmitted, readTrainingReviewPreview } from "@/utils/trainingReviewPreview";
|
|
|
|
|
import { getPendingRequestCount } from "@/utils/request";
|
|
|
|
|
import { studentTaskPreviewComponentByKey, studentTaskPreviewPropsByKey } from "./studentTaskPreviewMap";
|
|
|
|
|
|
|
|
|
|
@ -35,6 +35,8 @@ const previewRoot = ref();
|
|
|
|
|
const activeTaskKey = ref("");
|
|
|
|
|
const activePreviewKey = ref("");
|
|
|
|
|
const previewBooting = ref(true);
|
|
|
|
|
/* 当前预览的学生是否已完成作答:未完成的学生没有内容可看,步骤导航一律不放行 */
|
|
|
|
|
const previewStudentSubmitted = ref(false);
|
|
|
|
|
const PREVIEW_HEIGHT_MESSAGE = "teacher-task-review-preview-height";
|
|
|
|
|
/* 与父页 TaskReviewPanel.vue 约定的热切换协议 */
|
|
|
|
|
const PARENT_LOAD_MESSAGE = "teacher-task-review-preview-load";
|
|
|
|
|
@ -84,6 +86,21 @@ function isolatePreviewStorage() {
|
|
|
|
|
}
|
|
|
|
|
isolatePreviewStorage();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 预览内被跳过的写请求会让页面走到「保存成功」分支(见 request.js 的跳过语义),
|
|
|
|
|
* 但实际上什么都没有保存——成功类 toast 一律不弹,避免误导教师以为改动已落库。
|
|
|
|
|
* 只抑制 success;error / warning / info(含本壳的只读操作提示)保持原样。
|
|
|
|
|
*/
|
|
|
|
|
function suppressPreviewSuccessToasts() {
|
|
|
|
|
if (typeof ElMessage !== "function") return;
|
|
|
|
|
try {
|
|
|
|
|
ElMessage.success = () => undefined;
|
|
|
|
|
} catch (_) {
|
|
|
|
|
/* 属性只读等极端情况下忽略,仅多一条无害提示 */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
suppressPreviewSuccessToasts();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 性能关键点:iframe 只冷启动一次(首次靠路由 query 加载),
|
|
|
|
|
* 之后父页切换学生/任务时通过 postMessage 热切换动态组件,
|
|
|
|
|
@ -108,6 +125,7 @@ async function loadPreview(taskKey, previewKey) {
|
|
|
|
|
bootStartAt = Date.now();
|
|
|
|
|
syncPreviewLocation(taskKey, previewKey);
|
|
|
|
|
const preview = readTrainingReviewPreview(previewKey);
|
|
|
|
|
previewStudentSubmitted.value = isPreviewAnswerSubmitted(preview?.answer);
|
|
|
|
|
const loader = studentTaskPreviewComponentByKey[taskKey];
|
|
|
|
|
if (!preview || preview.taskKey !== taskKey) {
|
|
|
|
|
emptyDescription.value = "学生作答预览已失效,请返回任务评阅重新选择学生";
|
|
|
|
|
@ -266,6 +284,16 @@ function guardPreviewInteraction(event) {
|
|
|
|
|
notifyReadonly();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* 未完成作答的学生没有任何作答内容可看,步骤导航一律拦住并说明原因;
|
|
|
|
|
* 已完成(有分数)的学生才允许在步骤间切换查看。
|
|
|
|
|
*/
|
|
|
|
|
if (!previewStudentSubmitted.value && (target.closest(PREVIEW_STEP_NAV_CONTAINER) || target.closest("[role='tab'], .el-step"))) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
event.stopImmediatePropagation();
|
|
|
|
|
notifyNotSubmitted();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const action = target.closest("button, a, [role='button'], [role='tab'], .el-step");
|
|
|
|
|
if (action && !isStepNavigation(action)) {
|
|
|
|
|
event.preventDefault();
|
|
|
|
|
@ -308,12 +336,26 @@ function notifyReadonly() {
|
|
|
|
|
if (now - lastReadonlyHintAt < 2500) return;
|
|
|
|
|
lastReadonlyHintAt = now;
|
|
|
|
|
ElMessage({
|
|
|
|
|
message: "任务评阅预览为只读模式,不能修改学生作答;步骤切换不受影响",
|
|
|
|
|
message: "任务评阅预览为只读模式,不能修改学生作答",
|
|
|
|
|
type: "info",
|
|
|
|
|
duration: 2000,
|
|
|
|
|
showClose: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 未完成作答的学生:步骤切换被拦住,明确告知原因 */
|
|
|
|
|
let lastNotSubmittedHintAt = 0;
|
|
|
|
|
function notifyNotSubmitted() {
|
|
|
|
|
const now = Date.now();
|
|
|
|
|
if (now - lastNotSubmittedHintAt < 2500) return;
|
|
|
|
|
lastNotSubmittedHintAt = now;
|
|
|
|
|
ElMessage({
|
|
|
|
|
message: "该学生尚未完成作答,暂不能切换步骤",
|
|
|
|
|
type: "info",
|
|
|
|
|
duration: 2200,
|
|
|
|
|
showClose: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|