update
Some checks failed
Deploy / deploy (build, debian, 22) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822) (push) Has been cancelled

This commit is contained in:
2026-05-02 09:15:49 -06:00
parent 64dc1c9234
commit 2e6e3aacec
2 changed files with 28 additions and 3 deletions

View File

@@ -94,6 +94,7 @@ import {
} from "naive-ui"
import { useRouter } from "vue-router"
import { Account, Gradebook } from "../api"
import { displayGradebookStudentName } from "../utils/gradebook"
import type {
GradebookCell,
GradebookOut,
@@ -172,7 +173,11 @@ function renderTaskHeader(task: GradebookTask) {
function renderScore(row: GradebookRow, task: GradebookTask) {
const cell = row.scores[task.id]
if (!cell || !cell.submitted) {
return h("span", { class: "missing-cell" }, "缺交")
return h(
NText,
{ class: "missing-cell", type: "error" },
{ default: () => "缺交" },
)
}
return h(
NButton,
@@ -189,6 +194,11 @@ function renderScore(row: GradebookRow, task: GradebookTask) {
)
}
function renderMissingCount(value: number) {
if (value <= 0) return "0"
return h(NText, { type: "error" }, { default: () => String(value) })
}
const columns = computed<DataTableColumn<GradebookRow>[]>(() => {
const tasks = gradebook.value?.tasks ?? []
return [
@@ -215,8 +225,10 @@ const columns = computed<DataTableColumn<GradebookRow>[]>(() => {
key: "username",
width: 140,
fixed: "left",
render: (row) =>
h(NText, { title: row.username }, { default: () => row.username }),
render: (row) => {
const studentName = displayGradebookStudentName(row)
return h(NText, { title: studentName }, { default: () => studentName })
},
},
{
title: "班级",
@@ -271,6 +283,7 @@ const columns = computed<DataTableColumn<GradebookRow>[]>(() => {
key: "missing_task_count",
width: 70,
fixed: "right",
render: (row) => renderMissingCount(row.missing_task_count),
},
]
})

12
src/utils/gradebook.ts Normal file
View File

@@ -0,0 +1,12 @@
export interface GradebookStudentIdentity {
username: string
classname: string
}
export function displayGradebookStudentName(student: GradebookStudentIdentity) {
const generatedPrefix = `web${student.classname}`
if (!student.classname || !student.username.startsWith(generatedPrefix)) {
return student.username
}
return student.username.slice(generatedPrefix.length)
}