diff --git a/src/components/exams/grade-form.tsx b/src/components/exams/grade-form.tsx index f97a336..1201d3c 100644 --- a/src/components/exams/grade-form.tsx +++ b/src/components/exams/grade-form.tsx @@ -1,8 +1,8 @@ -import { For, createMemo, createSignal } from "solid-js"; +import { For, Show, createMemo, createSignal } from "solid-js"; import { formatApiError } from "@/api/client"; import { Button } from "@/components/ui/button"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; -import { IconCheck } from "@/components/ui/icons"; +import { IconCheck, IconEye } from "@/components/ui/icons"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Select } from "@/components/ui/select"; @@ -16,6 +16,7 @@ export type GradeFormValues = { export function GradeForm(props: { students: { id: string; label: string }[]; onSubmit: (values: GradeFormValues) => Promise; + onViewAnswers?: (userId: string) => void; }) { const t = useT(); const [userId, setUserId] = createSignal(""); @@ -87,10 +88,18 @@ export function GradeForm(props: { /> - +
+ + + + +
{error() &&

{error()}

} diff --git a/src/pages/exam-detail-page.tsx b/src/pages/exam-detail-page.tsx index dd81cce..ddbaa0f 100644 --- a/src/pages/exam-detail-page.tsx +++ b/src/pages/exam-detail-page.tsx @@ -5,6 +5,7 @@ import { deleteExamById } from "@/api/exams"; import { deleteExamResultByUserId } from "@/api/exams"; import { getExamById } from "@/api/exams"; import { getExamAttempt } from "@/api/exams"; +import { getExamLive } from "@/api/exams"; import { getExamResult } from "@/api/exams"; import { getExamResults } from "@/api/exams"; import { getExamStatistics } from "@/api/exams"; @@ -221,6 +222,10 @@ function ExamDetailContent() { return t("exams.unscheduled"); }; const isDraft = () => exam()?.draft === true; + const [gradeLive] = createResource( + () => (hasCourseManagementRights() && gradeOpen() && !isFinished() ? id() : null), + async (examId) => examId ? getExamLive(examId) : null, + ); const resultTotal = () => results()?.total ?? 0; const resultTotalPages = () => Math.max(1, Math.ceil(resultTotal() / RESULT_PAGE_SIZE)); const setClampedAnswerMark = (value: string) => { @@ -259,6 +264,14 @@ function ExamDetailContent() { const gradeStudents = () => { if (gradeResults.loading) return []; const graded = new Set((gradeResults()?.items ?? []).map((row) => personId(row.user))); + if (!isFinished()) { + return (gradeLive()?.students ?? []) + .filter((row) => (row.status === "submitted" || row.status === "expired") && !graded.has(personId(row.user))) + .map((row) => ({ + id: personId(row.user), + label: personLabelWithId(row.user), + })); + } return (roster() ?? []) .filter((row) => !graded.has(row.user.id)) .map((row) => ({ @@ -671,6 +684,10 @@ function ExamDetailContent() { > { + setGradeOpen(false); + setAnswerSheetUserId(userId); + }} onSubmit={async (values) => { await postExamResult(id(), values); await refetchResults(); @@ -688,10 +705,7 @@ function ExamDetailContent() { actions={
- - {t("exams.gradeAfterExam")} - -