Show lesson marks and attendance on the person card.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Leonid Pershin
2026-08-21 13:42:37 +03:00
co-authored by Cursor
parent 564776883a
commit db6e60929d
18 changed files with 800 additions and 20 deletions
+78 -1
View File
@@ -110,7 +110,84 @@ internal static partial class PersonCardReader
TalkTopicId: circle?.TopicId,
ClassTeacherId: classTeacherId,
ClassTeacherName: classTeacherName,
Offenses: Offenses(roster, person, catalog, locale));
Offenses: Offenses(roster, person, catalog, locale),
LessonMarks: LessonMarks(person, catalog, locale),
Attendance: Attendance(person, catalog, locale));
}
private static IReadOnlyList<LessonMarkEntryResponse> LessonMarks(
Person person,
DefCatalog? catalog,
string locale)
{
var rows = person.LessonMarks;
if (rows is null || rows.Count == 0)
{
return [];
}
var result = new LessonMarkEntryResponse[rows.Count];
for (var i = 0; i < rows.Count; i++)
{
var row = rows[i];
result[i] = new LessonMarkEntryResponse(
row.Subject,
SubjectLabel(catalog, locale, row.Subject),
row.Value,
row.Time,
row.Period);
}
return result;
}
private static IReadOnlyList<AttendanceEntryResponse> Attendance(
Person person,
DefCatalog? catalog,
string locale)
{
var rows = person.Attendance;
if (rows is null || rows.Count == 0)
{
return [];
}
var result = new AttendanceEntryResponse[rows.Count];
for (var i = 0; i < rows.Count; i++)
{
var row = rows[i];
result[i] = new AttendanceEntryResponse(
row.Subject,
SubjectLabel(catalog, locale, row.Subject),
row.Status,
StatusLabel(catalog, locale, row.Status),
row.Time,
row.Period,
row.AbsenceReason);
}
return result;
}
private static string SubjectLabel(DefCatalog? catalog, string locale, string subject)
{
if (catalog is not null && catalog.Subjects.TryGetValue(subject, out var def))
{
return catalog.Label(locale, def);
}
return subject;
}
private static string StatusLabel(DefCatalog? catalog, string locale, string status)
{
var key = AttendanceStatuses.LocaleKey(status);
if (catalog is not null && catalog.HasText(locale, key))
{
return catalog.Text(locale, key);
}
return status;
}
private static IReadOnlyList<OffenseEntryResponse> Offenses(