Show lesson marks and attendance on the person card.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user