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