update
This commit is contained in:
@@ -94,6 +94,7 @@ import {
|
|||||||
} from "naive-ui"
|
} from "naive-ui"
|
||||||
import { useRouter } from "vue-router"
|
import { useRouter } from "vue-router"
|
||||||
import { Account, Gradebook } from "../api"
|
import { Account, Gradebook } from "../api"
|
||||||
|
import { displayGradebookStudentName } from "../utils/gradebook"
|
||||||
import type {
|
import type {
|
||||||
GradebookCell,
|
GradebookCell,
|
||||||
GradebookOut,
|
GradebookOut,
|
||||||
@@ -172,7 +173,11 @@ function renderTaskHeader(task: GradebookTask) {
|
|||||||
function renderScore(row: GradebookRow, task: GradebookTask) {
|
function renderScore(row: GradebookRow, task: GradebookTask) {
|
||||||
const cell = row.scores[task.id]
|
const cell = row.scores[task.id]
|
||||||
if (!cell || !cell.submitted) {
|
if (!cell || !cell.submitted) {
|
||||||
return h("span", { class: "missing-cell" }, "缺交")
|
return h(
|
||||||
|
NText,
|
||||||
|
{ class: "missing-cell", type: "error" },
|
||||||
|
{ default: () => "缺交" },
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return h(
|
return h(
|
||||||
NButton,
|
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 columns = computed<DataTableColumn<GradebookRow>[]>(() => {
|
||||||
const tasks = gradebook.value?.tasks ?? []
|
const tasks = gradebook.value?.tasks ?? []
|
||||||
return [
|
return [
|
||||||
@@ -215,8 +225,10 @@ const columns = computed<DataTableColumn<GradebookRow>[]>(() => {
|
|||||||
key: "username",
|
key: "username",
|
||||||
width: 140,
|
width: 140,
|
||||||
fixed: "left",
|
fixed: "left",
|
||||||
render: (row) =>
|
render: (row) => {
|
||||||
h(NText, { title: row.username }, { default: () => row.username }),
|
const studentName = displayGradebookStudentName(row)
|
||||||
|
return h(NText, { title: studentName }, { default: () => studentName })
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "班级",
|
title: "班级",
|
||||||
@@ -271,6 +283,7 @@ const columns = computed<DataTableColumn<GradebookRow>[]>(() => {
|
|||||||
key: "missing_task_count",
|
key: "missing_task_count",
|
||||||
width: 70,
|
width: 70,
|
||||||
fixed: "right",
|
fixed: "right",
|
||||||
|
render: (row) => renderMissingCount(row.missing_task_count),
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
12
src/utils/gradebook.ts
Normal file
12
src/utils/gradebook.ts
Normal 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)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user