diff --git a/client/src/entities/teacher-reported-today.jsx b/client/src/entities/teacher-reported-today.jsx index 43900c04..09bc946a 100644 --- a/client/src/entities/teacher-reported-today.jsx +++ b/client/src/entities/teacher-reported-today.jsx @@ -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; @@ -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 ( {showDate && `${formatDate(row.reportDate)} `}{formatHour(row.reportHour)} + {period && ( + + שיעור {period.number} + + )} {row.lessonReferenceId ? ( @@ -241,7 +246,7 @@ const TeacherReportCards = ({ isAdmin }) => { )} {(isAdmin ? klass.lessons : withLessonGaps(klass.lessons, lessonTimes)).map((row) => (row.isGap ? - : + : ))} ); diff --git a/client/src/roadmapFeatures.js b/client/src/roadmapFeatures.js index 841f15c6..cd7fecdd 100644 --- a/client/src/roadmapFeatures.js +++ b/client/src/roadmapFeatures.js @@ -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' }, diff --git a/client/src/utils/lessonGaps.js b/client/src/utils/lessonGaps.js index 6868ee51..f7f7e40e 100644 --- a/client/src/utils/lessonGaps.js +++ b/client/src/utils/lessonGaps.js @@ -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. diff --git a/client/src/utils/lessonGaps.test.js b/client/src/utils/lessonGaps.test.js index afb25282..a5093e94 100644 --- a/client/src/utils/lessonGaps.test.js +++ b/client/src/utils/lessonGaps.test.js @@ -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 = [ @@ -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(); + }); +});