Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions client/src/entities/teacher-reported-today.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { filterArrayByParams } from '@shared/utils/filtersUtil';
import { useIsAdmin } from '@shared/utils/permissionsUtil';
import { MAX_PAGE_SIZE } from '@shared/config/settings';
import { useLessonTimes } from 'src/settings/settingsUtil';
import { withLessonGaps } from 'src/utils/lessonGaps';
import { getReportPeriod, withLessonGaps } from 'src/utils/lessonGaps';

// This is a card view, not a table, so cap high rather than paginate at 10 rows.
const LIST_PAGE_SIZE = 1000;
Expand Down Expand Up @@ -158,12 +158,17 @@ const SummaryTiles = ({ rows, klassCount }) => {

const displayNameOrName = (record) => record.displayName || record.name;

const LessonRow = ({ row, showDate, until }) => {
const LessonRow = ({ row, showDate, until, period }) => {
return (
<RecordContextProvider value={row}>
<Box sx={{ display: 'grid', gridTemplateColumns: showDate ? '96px minmax(0, 1fr) minmax(0, 1fr) 44px' : '48px minmax(0, 1fr) minmax(0, 1fr) 44px', gap: 1.5, alignItems: 'center', px: 2, py: 1.25, borderTop: 1, borderColor: 'divider' }}>
<Typography variant="body2" sx={{ fontWeight: 500, fontVariantNumeric: 'tabular-nums' }}>
{showDate && `${formatDate(row.reportDate)} `}{formatHour(row.reportHour)}
{period && (
<Typography component="span" variant="caption" color="text.secondary" sx={{ display: 'block' }}>
שיעור {period.number}
</Typography>
)}
</Typography>
<Typography variant="body2" component="div" sx={{ fontWeight: 500 }}>
{row.lessonReferenceId ? (
Expand Down Expand Up @@ -241,7 +246,7 @@ const TeacherReportCards = ({ isAdmin }) => {
)}
{(isAdmin ? klass.lessons : withLessonGaps(klass.lessons, lessonTimes)).map((row) => (row.isGap
? <GapRow key={row.id} gap={row} showDate={showDate} />
: <LessonRow key={row.id} row={row} showDate={showDate} until={nextLessonStart(row, klass.lessons)} />
: <LessonRow key={row.id} row={row} showDate={showDate} until={nextLessonStart(row, klass.lessons)} period={isAdmin ? undefined : getReportPeriod(row, lessonTimes)} />
))}
</Card>
);
Expand Down
1 change: 1 addition & 0 deletions client/src/roadmapFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default [
{ html: 'רשימת דיווחי נוכחות: פעולה "עריכה מרוכזת" לשינוי תאריך, כיתה, מורה, שיעור ועוד במספר רשומות יחד (שדה ריק לא משתנה)', status: 'בוצע', statusColor: 'success' },
{ html: 'דוחות "מורות שדיווחו נוכחות" ו"מעקב חיסורים": הצגת שם לתצוגה של כיתה, שיעור ומורה כשהוגדר', status: 'בוצע', statusColor: 'success' },
{ html: 'הגדרת זמני שיעורים לכל יום במסך ההגדרות, ובדוח המורות שדיווחו: ריבוע ריק לשיעור שלא דווח באמצע היום', status: 'בוצע', statusColor: 'success' },
{ html: 'דוח המורות שדיווחו: מספר השיעור (שיעור 1, 2, 3...) ליד כל שיעור שדווח, לפי זמני השיעורים בהגדרות', status: 'בוצע', statusColor: 'success' },

// { html: 'הגדרת תקופת זמן לפי תאריכים', status: 'בקרוב', statusColor: 'warning' },
// { html: 'הגדרת תקופת זמן לפי יום בשבוע', status: 'בוצע', statusColor: 'success' },
Expand Down
9 changes: 9 additions & 0 deletions client/src/utils/lessonGaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ const getPeriodIndex = (row, periods) => {
return periods.findLastIndex((period) => period.startMinutes <= minutes);
};

// The lesson from the lessonTimes setting that a reported lesson belongs to, if any.
export function getReportPeriod(row, lessonTimes) {
if (!Array.isArray(lessonTimes) || !lessonTimes.length) {
return undefined;
}
const periods = getDayPeriods(lessonTimes, toDateOnly(row.reportDate));
return periods[getPeriodIndex(row, periods)];
}

// The class's lessons with an empty slot ({ isGap: true, period, reportDate }) before each reported lesson
// that comes after one or more unreported lessons of the same day. Nothing is added after the last report of the day.
// A lesson is placed by the time it was reported, so a report entered late counts for the lesson it was entered in.
Expand Down
15 changes: 14 additions & 1 deletion client/src/utils/lessonGaps.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getDayPeriods, withLessonGaps } from './lessonGaps';
import { getDayPeriods, getReportPeriod, withLessonGaps } from './lessonGaps';

// 2026-10-14 is a Wednesday (weekday 3); Israel is UTC+3 on that date.
const lessonTimes = [
Expand Down Expand Up @@ -93,3 +93,16 @@ describe('withLessonGaps', () => {
expect(withLessonGaps(lessons, [{ days: '3', periods: 'x' }, null])).toEqual(lessons);
});
});

describe('getReportPeriod', () => {
it('returns the lesson a report belongs to', () => {
// 09:35 is the break after lesson 2.
expect(getReportPeriod(lesson(1, '2026-10-14T06:35:00Z'), lessonTimes)?.number).toBe(2);
});

it('returns nothing without lesson times, before the first lesson, or for a late entry', () => {
expect(getReportPeriod(lesson(1, '2026-10-14T05:10:00Z'), [])).toBeUndefined();
expect(getReportPeriod(lesson(1, '2026-10-14T04:30:00Z'), lessonTimes)).toBeUndefined();
expect(getReportPeriod(lesson(1, '2026-10-14T05:10:00Z', '2026-10-13'), lessonTimes)).toBeUndefined();
});
});
Loading