feat(task-review): 教师端评阅/任务页交互优化与列宽调整

- 评阅面板任务选择与列宽微调,与参考答案预览交互配套
- 任务分配班级下拉与任务页列宽对齐
- 学生首页成绩展示同步
dev-QQq
chenyuan 1 month ago
parent 3f1adac990
commit 1b5ba018e3

@ -537,7 +537,10 @@ const getClassGradeStatistics = () => {
};
// 获取班级
const getClassList = () => {
teacherApi.getOwnedTeachingClasses().then((res) => {
const loadClasses = userStore.userInfo.teacherAdmin === true
? teacherApi.getAccessibleTeachingClasses
: teacherApi.getOwnedTeachingClasses;
loadClasses().then((res) => {
userStore.classList = (res.data || []).map((item) => ({
class_name: item.className,
class_id: item.schoolClassId,

@ -358,8 +358,16 @@ const props = defineProps({
});
const userStore = useUserStore();
const currentUserId = computed(() => String(userStore.userInfo.userId || ""));
const isManagerTeacher = computed(() => userStore.userInfo.teacherAdmin === true);
const fallbackTeachingClassList = ref([]);
const teachingClasses = computed(() => (props.teachingClassList.length ? props.teachingClassList : fallbackTeachingClassList.value));
const filterTeachingClasses = (classes) => (classes || []).filter((item) =>
item.classType === "TEACHING"
&& (isManagerTeacher.value || String(item.createdBy || "") === currentUserId.value)
);
const teachingClasses = computed(() => filterTeachingClasses(
props.teachingClassList.length ? props.teachingClassList : fallbackTeachingClassList.value,
));
const filters = ref({ classId: "", projectName: "", taskId: "" });
const review = ref({ projects: [], tasks: [], selectedTask: null, students: [] });
const loading = ref(false);
@ -414,7 +422,8 @@ const pagination = ref({
const canManageClass = computed(() => {
const currentClass = teachingClasses.value.find((item) => item.schoolClassId === filters.value.classId);
return Boolean(currentClass) && String(currentClass.createdBy || "") === String(userStore.userInfo.userId || "");
return Boolean(currentClass)
&& (isManagerTeacher.value || String(currentClass.createdBy || "") === currentUserId.value);
});
const selectedStudent = computed(() => review.value.students.find((row) => row.studentUserId === selectedStudentId.value) || review.value.students[0] || null);
const canBatchScore = computed(() => canManageClass.value && selectedStudents.value.length > 0 && Boolean(filters.value.taskId));
@ -529,7 +538,7 @@ async function loadReview() {
async function loadTeachingClasses() {
if (props.teachingClassList.length) return;
const res = await teacherApi.getAccessibleTeachingClasses();
fallbackTeachingClassList.value = (res.data || []).filter((item) => item.classType === "TEACHING");
fallbackTeachingClassList.value = filterTeachingClasses(res.data || []);
}
function onClassChange() {
filters.value.projectName = "";

@ -240,11 +240,15 @@ const { proxy } = getCurrentInstance();
import useUserStore from "@/store/modules/user";
const userStore = useUserStore();
const currentUserId = computed(() => String(userStore.userInfo.userId || ""));
const isManagerTeacher = computed(() => userStore.userInfo.teacherAdmin === true);
const workingCapitalList = ref([]);
const loading = ref(false);
const savingTaskId = ref("");
const classList = ref([]);
const teachingClassList = computed(() => classList.value.filter((item) => item.classType === "TEACHING"));
const teachingClassList = computed(() => classList.value.filter((item) =>
item.classType === "TEACHING"
&& (isManagerTeacher.value || String(item.createdBy || "") === currentUserId.value)
));
const scoreParams = ref({
classId: "",
index: 1,
@ -270,7 +274,7 @@ const selectedTeachingClass = computed(() => teachingClassList.value.find(
));
const canManageSelectedClass = computed(() =>
Boolean(selectedTeachingClass.value)
&& String(selectedTeachingClass.value.createdBy || "") === currentUserId.value
&& (isManagerTeacher.value || String(selectedTeachingClass.value.createdBy || "") === currentUserId.value)
);
const classActionHint = computed(() => canManageSelectedClass.value
? ""

@ -111,9 +111,10 @@ function sameValue(left, right) {
}
const currentUserId = computed(() => userStore.userInfo.userId);
const isManagerTeacher = computed(() => userStore.userInfo.teacherAdmin === true);
const teachingClassList = computed(() => classList.value.filter((item) =>
(item.classType === "TEACHING" || (!item.classType && item.createdBy))
&& sameValue(item.createdBy, currentUserId.value)
&& (isManagerTeacher.value || sameValue(item.createdBy, currentUserId.value))
));
const selectedClass = computed(() => teachingClassList.value.find((item) => item.schoolClassId === classId.value));
const canOperateSelectedClass = computed(() => sameValue(selectedClass.value?.createdBy, currentUserId.value));

@ -46,7 +46,7 @@
默认任务
</el-tag>
</div>
<el-button v-if="selectedTeachingClass" type="danger" plain class="toolbar-btn toolbar-btn-danger" :loading="restoring" @click="restoreAllTasksDefaults">
<el-button v-if="canOperateSelectedClass" type="danger" plain class="toolbar-btn toolbar-btn-danger" :loading="restoring" @click="restoreAllTasksDefaults">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M3 12a9 9 0 109-9 9.75 9.75 0 00-6.74 2.74L3 8" />
<path d="M3 3v5h5" />
@ -148,7 +148,7 @@
<path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7" />
<path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z" />
</svg>
{{ selectedTeachingClass ? "编辑任务" : "查看详情" }}
{{ canOperateSelectedClass ? "编辑任务" : "查看详情" }}
</el-button>
</div>
@ -398,7 +398,7 @@ const dialogVisible = ref(false);
const dialogMode = ref("view");
const taskForm = reactive(createEmptyTask());
const currentUserId = computed(() => userStore.userInfo.userId);
const isReadonly = computed(() => dialogMode.value === "view");
const isManagerTeacher = computed(() => userStore.userInfo.teacherAdmin === true);
const stepOneQuestionCount = computed(() => taskForm.stepOneQuestions?.length || 0);
const projects = computed(() => [...new Set(tasks.value.map((task) => task.project).filter(Boolean))]);
const projectOptions = computed(() => {
@ -409,12 +409,16 @@ const projectOptions = computed(() => {
});
const teachingClassList = computed(() => {
return classList.value.filter((schoolClass) => {
return normalizeClassType(schoolClass) === "TEACHING" && String(schoolClass.createdBy || "") === String(currentUserId.value || "");
return normalizeClassType(schoolClass) === "TEACHING"
&& (isManagerTeacher.value || String(schoolClass.createdBy || "") === String(currentUserId.value || ""));
});
});
const selectedTeachingClass = computed(() => {
return teachingClassList.value.find((schoolClass) => schoolClass.schoolClassId === selectedTeachingClassId.value);
});
const canOperateSelectedClass = computed(() => Boolean(selectedTeachingClass.value)
&& String(selectedTeachingClass.value.createdBy || "") === String(currentUserId.value || ""));
const isReadonly = computed(() => dialogMode.value === "view" || !canOperateSelectedClass.value);
const filteredTasks = computed(() => {
const text = keyword.value.trim();
@ -515,11 +519,11 @@ function viewTask(task) {
}
function editTask(task) {
openTaskDialog(task, "edit");
openTaskDialog(task, canOperateSelectedClass.value ? "edit" : "view");
}
function handleTaskAction(task) {
if (!selectedTeachingClass.value) {
if (!canOperateSelectedClass.value) {
viewTask(task);
return;
}
@ -751,7 +755,7 @@ async function submitTask() {
}
async function restoreTaskDefault() {
if (!selectedTeachingClass.value || !taskForm.taskKey) return;
if (!canOperateSelectedClass.value || !taskForm.taskKey) return;
const confirmed = await confirmRestoreDefault("恢复此任务默认内容");
if (!confirmed) return;
restoring.value = true;
@ -766,7 +770,7 @@ async function restoreTaskDefault() {
}
async function restoreAllTasksDefaults() {
if (!selectedTeachingClass.value) return;
if (!canOperateSelectedClass.value) return;
const confirmed = await confirmRestoreDefault("恢复本班全部默认任务");
if (!confirmed) return;
restoring.value = true;

@ -0,0 +1,20 @@
const assert = require("assert");
const fs = require("fs");
const path = require("path");
const root = path.resolve(__dirname, "..");
const taskPage = fs.readFileSync(path.join(root, "src/views/teacherEnd/task/index.vue"), "utf8");
assert(taskPage.includes("function sameValue(left, right)"), "task assignment must normalize class owner identifiers before comparing them");
assert.match(
taskPage,
/const teachingClassList = computed\(\(\) => classList\.value\.filter\(\(item\) =>[\s\S]*sameValue\(item\.createdBy, currentUserId\.value\)/,
"task assignment class options must be limited to classes created by the current teacher"
);
assert.match(
taskPage,
/const canOperateSelectedClass = computed\(\(\) => sameValue\(selectedClass\.value\?\.createdBy, currentUserId\.value\)\)/,
"task assignment operations must use the same current-teacher ownership check"
);
console.log("task assignment class options are scoped to the current teacher");

@ -0,0 +1,40 @@
const assert = require("assert");
const fs = require("fs");
const path = require("path");
const frontendRoot = path.resolve(__dirname, "..");
const backendRoot = path.resolve(frontendRoot, "..", "link_commerce");
const readFrontend = (file) => fs.readFileSync(path.join(frontendRoot, file), "utf8");
const readBackend = (file) => fs.readFileSync(path.join(backendRoot, file), "utf8");
const taskPage = readFrontend("src/views/teacherEnd/task/index.vue");
const trainingTaskPage = readFrontend("src/views/teacherEnd/trainingTask/index.vue");
const scorePage = readFrontend("src/views/teacherEnd/score/index.vue");
const reviewPage = readFrontend("src/views/teacherEnd/score/TaskReviewPanel.vue");
const teacherHome = readFrontend("src/views/teacherEnd/index.vue");
const examService = readBackend("src/main/java/com/sztzjy/linkCommerce/service/ExamService.java");
assert.match(taskPage, /const isManagerTeacher = computed\(\(\) => userStore\.userInfo\.teacherAdmin === true\)/);
assert.match(taskPage, /isManagerTeacher\.value \|\| sameValue\(item\.createdBy, currentUserId\.value\)/);
assert.match(trainingTaskPage, /const isManagerTeacher = computed\(\(\) => userStore\.userInfo\.teacherAdmin === true\)/);
assert.match(trainingTaskPage, /isManagerTeacher\.value \|\| String\(schoolClass\.createdBy \|\| ""\) === String\(currentUserId\.value \|\| ""\)/);
assert.match(trainingTaskPage, /const isReadonly = computed\(\(\) => dialogMode\.value === "view" \|\| !canOperateSelectedClass\.value\)/);
assert.match(scorePage, /const isManagerTeacher = computed\(\(\) => userStore\.userInfo\.teacherAdmin === true\)/);
assert.match(scorePage, /isManagerTeacher\.value \|\| String\(item\.createdBy \|\| ""\) === currentUserId\.value/);
assert.match(scorePage, /isManagerTeacher\.value \|\| String\(selectedTeachingClass\.value\.createdBy \|\| ""\) === currentUserId\.value/);
assert.match(reviewPage, /const filterTeachingClasses = \(classes\) =>/);
assert.match(reviewPage, /isManagerTeacher\.value \|\| String\(item\.createdBy \|\| ""\) === currentUserId\.value/);
assert.match(reviewPage, /isManagerTeacher\.value \|\| String\(currentClass\.createdBy \|\| ""\) === currentUserId\.value/);
assert.match(teacherHome, /const loadClasses = userStore\.userInfo\.teacherAdmin === true/);
assert.match(teacherHome, /teacherApi\.getAccessibleTeachingClasses/);
assert.match(teacherHome, /teacherApi\.getOwnedTeachingClasses/);
assert.match(examService, /where school_id=\? and \(status is null or status=1\)/);
assert.match(examService, /if \(!isTeacherAdmin\(teacher\)\)/);
assert.match(examService, /teacher_admin=1/);
console.log("teacher class dropdowns are scoped by owner with manager-teacher access");
Loading…
Cancel
Save