✅ roll call leads with Present and says when students are done
Browse files at this commit6e42004f2e288c4650f8e1aaecc2901d397090d4Parent: 321d831- style
- ✅ roll call leads with Present and says when students are done
2 changed files +15 -5
src/components/sessions/session-roll-call.tsxmodified+12 -5
| @@ -36,9 +36,12 @@ export function SessionRollCall(props: { | |||
| 36 | }) { | 36 | }) { |
| 37 | const t = useT(); | 37 | const t = useT(); |
| 38 | const [settings] = createResource(() => getSettings()); | 38 | const [settings] = createResource(() => getSettings()); |
| 39 | - const statuses = createMemo<AttendanceStatus[]>( | 39 | + // The school's statuses in its own order, except "present" leads: it is |
| 40 | - () => settings.latest?.attendance_statuses ?? ATTENDANCE_STATUSES.map((item) => item.value), | 40 | + // the one a teacher taps most, so it sits first on every row. |
| 41 | - ); | 41 | + const statuses = createMemo<AttendanceStatus[]>(() => { |
| 42 | + const list = settings.latest?.attendance_statuses ?? ATTENDANCE_STATUSES.map((item) => item.value); | ||
| 43 | + return list.includes("present") ? ["present", ...list.filter((status) => status !== "present")] : list; | ||
| 44 | + }); | ||
| 42 | const [attendance] = createResource( | 45 | const [attendance] = createResource( |
| 43 | () => props.sessionId, | 46 | () => props.sessionId, |
| 44 | async (sessionId) => (await getSessionAttendance(sessionId)).items, | 47 | async (sessionId) => (await getSessionAttendance(sessionId)).items, |
| @@ -76,6 +79,7 @@ export function SessionRollCall(props: { | |||
| 76 | } | 79 | } |
| 77 | return tally; | 80 | return tally; |
| 78 | }); | 81 | }); |
| 82 | + const studentsLeft = createMemo(() => unmarked().filter((target) => !target.isTeacher).length); | ||
| 79 | const visibleTargets = createMemo(() => (onlyUnmarked() ? unmarked() : targets())); | 83 | const visibleTargets = createMemo(() => (onlyUnmarked() ? unmarked() : targets())); |
| 80 | 84 | ||
| 81 | const setBusy = (userId: string, busy: boolean) => | 85 | const setBusy = (userId: string, busy: boolean) => |
| @@ -193,14 +197,17 @@ export function SessionRollCall(props: { | |||
| 193 | <Button | 197 | <Button |
| 194 | type="button" | 198 | type="button" |
| 195 | size="sm" | 199 | size="sm" |
| 200 | + variant={studentsLeft() > 0 || bulk() ? "default" : "outline"} | ||
| 196 | class="h-9 rounded-lg" | 201 | class="h-9 rounded-lg" |
| 197 | - disabled={!ready() || bulk() != null || unmarked().filter((target) => !target.isTeacher).length === 0} | 202 | + disabled={!ready() || bulk() != null || studentsLeft() === 0} |
| 198 | onClick={() => void markRestPresent()} | 203 | onClick={() => void markRestPresent()} |
| 199 | > | 204 | > |
| 200 | <IconCheck class="h-4 w-4" /> | 205 | <IconCheck class="h-4 w-4" /> |
| 201 | {bulk() | 206 | {bulk() |
| 202 | ? t("rollCall.marking", { done: bulk()!.done, total: bulk()!.total }) | 207 | ? t("rollCall.marking", { done: bulk()!.done, total: bulk()!.total }) |
| 203 | - : t("rollCall.markRestPresent")} | 208 | + : studentsLeft() > 0 |
| 209 | + ? t("rollCall.markRestPresent") | ||
| 210 | + : t("rollCall.studentsDone")} | ||
| 204 | </Button> | 211 | </Button> |
| 205 | <Button | 212 | <Button |
| 206 | type="button" | 213 | type="button" |
src/i18n/messages.tsmodified+3 -0
| @@ -633,6 +633,7 @@ export type MessageKey = | |||
| 633 | | "today.upcoming" | 633 | | "today.upcoming" |
| 634 | | "rollCall.progress" | 634 | | "rollCall.progress" |
| 635 | | "rollCall.markRestPresent" | 635 | | "rollCall.markRestPresent" |
| 636 | + | "rollCall.studentsDone" | ||
| 636 | | "rollCall.marking" | 637 | | "rollCall.marking" |
| 637 | | "rollCall.onlyUnmarked" | 638 | | "rollCall.onlyUnmarked" |
| 638 | | "rollCall.allMarked" | 639 | | "rollCall.allMarked" |
| @@ -2799,6 +2800,7 @@ const en: Dict = { | |||
| 2799 | "today.upcoming": "Not started", | 2800 | "today.upcoming": "Not started", |
| 2800 | "rollCall.progress": "{marked} of {total} marked", | 2801 | "rollCall.progress": "{marked} of {total} marked", |
| 2801 | "rollCall.markRestPresent": "Mark the rest present", | 2802 | "rollCall.markRestPresent": "Mark the rest present", |
| 2803 | + "rollCall.studentsDone": "Every student is marked", | ||
| 2802 | "rollCall.marking": "Saving {done} of {total}…", | 2804 | "rollCall.marking": "Saving {done} of {total}…", |
| 2803 | "rollCall.onlyUnmarked": "Only unmarked", | 2805 | "rollCall.onlyUnmarked": "Only unmarked", |
| 2804 | "rollCall.allMarked": "Everyone is marked.", | 2806 | "rollCall.allMarked": "Everyone is marked.", |
| @@ -4967,6 +4969,7 @@ const tr: Dict = { | |||
| 4967 | "today.upcoming": "Başlamadı", | 4969 | "today.upcoming": "Başlamadı", |
| 4968 | "rollCall.progress": "{total} kişiden {marked} işaretlendi", | 4970 | "rollCall.progress": "{total} kişiden {marked} işaretlendi", |
| 4969 | "rollCall.markRestPresent": "Kalanları Var işaretle", | 4971 | "rollCall.markRestPresent": "Kalanları Var işaretle", |
| 4972 | + "rollCall.studentsDone": "Tüm öğrenciler işaretli", | ||
| 4970 | "rollCall.marking": "{total} kişiden {done} kaydedildi…", | 4973 | "rollCall.marking": "{total} kişiden {done} kaydedildi…", |
| 4971 | "rollCall.onlyUnmarked": "Yalnızca işaretlenmemişler", | 4974 | "rollCall.onlyUnmarked": "Yalnızca işaretlenmemişler", |
| 4972 | "rollCall.allMarked": "Herkes işaretlendi.", | 4975 | "rollCall.allMarked": "Herkes işaretlendi.", |