Skip to content

Commit

Permalink
WIP: fix @for-track-TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
hupf committed Oct 16, 2024
1 parent e09b43f commit 2def3ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@
<td class="border-end sticky student-average">
{{ studentGrade.finalGrade?.average | decimalOrDash: "1-3" }}
</td>
<!-- TODO: use "@let trackGrade = trackGradeOf(studentGrade.student.Id)", then "track trackGrade(grade.test.Id)" once updated to Angular 18.1 -->
@for (
grade of studentGrade.grades;
track grade;
gradeEntry of getGrades(studentGrade);
track gradeEntry.id;
let gradeIndex = $index
) {
@let grade = gradeEntry.grade;
<td
class="test-grade"
[ngClass]="
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
GradeOrNoResult,
StudentGrade,
} from "src/app/shared/models/student-grades";
import { Student } from "src/app/shared/models/student.model";
import { BkdModalService } from "src/app/shared/services/bkd-modal.service";
import { LetDirective } from "../../../shared/directives/let.directive";
import { Test } from "../../../shared/models/test.model";
Expand Down Expand Up @@ -80,6 +79,15 @@ export class TestEditGradesComponent implements OnInit {
);
}

getGrades(
studentGrade: StudentGrade,
): ReadonlyArray<{ id: string; grade: GradeOrNoResult }> {
return studentGrade.grades.flatMap((grade) => ({
id: `${studentGrade.student.Id}-${grade.test.Id}`,
grade,
}));
}

publish(test: Test) {
const modalRef = this.openModal(test);
this.onCloseModal(modalRef, () => this.state.publish(test));
Expand All @@ -90,12 +98,6 @@ export class TestEditGradesComponent implements OnInit {
this.onCloseModal(modalRef, () => this.state.unpublish(test));
}

trackGradeOf(student: Student) {
return function (grade: GradeOrNoResult) {
return `${student.Id}_${grade.test.Id}`;
};
}

calculatePointsAverage(test: Test) {
return this.safeAverage(test, averagePoints);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { DossierSingleTestComponent } from "../dossier-single-test/dossier-singl
export class DossierCourseTestsComponent implements OnChanges {
@Input() studentId: number;
@Input() decoratedCourse: CourseWithGrades;
@Input() gradingScales: GradingScale[];
@Input() gradingScales: ReadonlyArray<GradingScale>;
@Input() isEditable: boolean;

sortedTests$ = new BehaviorSubject<Test[]>([]);
Expand Down

0 comments on commit 2def3ec

Please sign in to comment.