aufräumen
This commit is contained in:
@@ -16,7 +16,7 @@ public partial class ParticipationGradeDialogViewModel : ObservableObject
|
||||
private readonly IParticipationRepository _entries;
|
||||
private readonly IParticipationAspectRepository _aspects;
|
||||
private readonly IStudentRepository _students;
|
||||
private readonly IEnrollmentRepository _enrollments;
|
||||
private readonly IGroupMembershipRepository _memberships;
|
||||
private readonly IGradeRepository _grades;
|
||||
private readonly GradingService _grading;
|
||||
private readonly Guid _groupId;
|
||||
@@ -39,11 +39,11 @@ public partial class ParticipationGradeDialogViewModel : ObservableObject
|
||||
public ParticipationGradeDialogViewModel(
|
||||
IParticipationSessionRepository sessions, IParticipationRepository entries,
|
||||
IParticipationAspectRepository aspects, IStudentRepository students,
|
||||
IEnrollmentRepository enrollments, IGradeRepository grades, GradingService grading,
|
||||
IGroupMembershipRepository memberships, IGradeRepository grades, GradingService grading,
|
||||
Guid groupId, string schoolYear, GradingSystem gradingSystem)
|
||||
{
|
||||
_sessions = sessions; _entries = entries; _aspects = aspects;
|
||||
_students = students; _enrollments = enrollments; _grades = grades;
|
||||
_students = students; _memberships = memberships; _grades = grades;
|
||||
_grading = grading; _groupId = groupId; _schoolYear = schoolYear;
|
||||
_gradingSystem = gradingSystem;
|
||||
|
||||
@@ -83,14 +83,14 @@ public partial class ParticipationGradeDialogViewModel : ObservableObject
|
||||
.OrderBy(s => s.Date)
|
||||
.ToList();
|
||||
|
||||
var studentList = _students.GetByGroup(_groupId, _schoolYear);
|
||||
var enrollmentList = _enrollments.GetByGroupAndYear(_groupId, _schoolYear);
|
||||
var studentList = _students.GetByGroup(_groupId);
|
||||
var membershipList = _memberships.GetByGroup(_groupId);
|
||||
|
||||
foreach (var student in studentList.OrderBy(s => s.LastName).ThenBy(s => s.FirstName))
|
||||
{
|
||||
var enrollment = enrollmentList.FirstOrDefault(e => e.StudentId == student.Id);
|
||||
var membership = membershipList.FirstOrDefault(e => e.StudentId == student.Id);
|
||||
var relevantSessions = sessions
|
||||
.Where(s => enrollment is null || IsEnrolledAtDate(enrollment, s.Date))
|
||||
.Where(s => membership is null || IsMemberAtDate(membership, s.Date))
|
||||
.ToList();
|
||||
|
||||
var points = new List<(DateOnly Date, double Rating)>();
|
||||
@@ -132,7 +132,6 @@ public partial class ParticipationGradeDialogViewModel : ObservableObject
|
||||
{
|
||||
StudentId = row.StudentId,
|
||||
GroupId = _groupId,
|
||||
SchoolYear = _schoolYear,
|
||||
Category = GradeCategory.Participation,
|
||||
Note = noteTag,
|
||||
};
|
||||
@@ -153,12 +152,12 @@ public partial class ParticipationGradeDialogViewModel : ObservableObject
|
||||
_ => true,
|
||||
};
|
||||
|
||||
private static bool IsEnrolledAtDate(Enrollment e, DateOnly date) => e.Period switch
|
||||
private static bool IsMemberAtDate(GroupMembership membership, DateOnly date) => membership.Period switch
|
||||
{
|
||||
EnrollmentPeriod.H1Only => date.Month >= 8 || date.Month <= 1,
|
||||
EnrollmentPeriod.H2Only => date.Month >= 2 && date.Month <= 7,
|
||||
EnrollmentPeriod.Custom => (e.JoinedAt is null || date >= e.JoinedAt.Value)
|
||||
&& (e.LeftAt is null || date <= e.LeftAt.Value),
|
||||
MembershipPeriod.H1Only => date.Month >= 8 || date.Month <= 1,
|
||||
MembershipPeriod.H2Only => date.Month >= 2 && date.Month <= 7,
|
||||
MembershipPeriod.Custom => (membership.JoinedAt is null || date >= membership.JoinedAt.Value)
|
||||
&& (membership.LeftAt is null || date <= membership.LeftAt.Value),
|
||||
_ => true,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user