Skip to content

Commit

Permalink
Add course, study class & study course student lists #712 #713
Browse files Browse the repository at this point in the history
  • Loading branch information
caebr committed Dec 12, 2024
1 parent 9d4dce7 commit 6a666ad
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/app/events/services/study-course-selection.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from "@angular/core/testing";
import { buildTestModuleMetadata } from "src/spec-helpers";
import { StudyCourseSelectionService } from "./study-course-selection.service";

describe("StudyCourseSelectionService", () => {
let service: StudyCourseSelectionService;

beforeEach(() => {
TestBed.configureTestingModule(buildTestModuleMetadata({}));
service = TestBed.inject(StudyCourseSelectionService);
});

it("should be created", () => {
expect(service).toBeTruthy();
});
});
8 changes: 8 additions & 0 deletions src/app/events/services/study-course-selection.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Injectable } from "@angular/core";
import { SelectionService } from "src/app/shared/services/selection.service";
import { StudentEntry } from "./events-students-state.service";

@Injectable({
providedIn: "root",
})
export class StudyCourseSelectionService extends SelectionService<StudentEntry> {}
26 changes: 26 additions & 0 deletions src/app/shared/services/students-rest.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { TestBed } from "@angular/core/testing";
import {
buildApprenticeshipContract,
buildLegalRepresentative,
buildStudent,
} from "src/spec-builders";
import { buildTestModuleMetadata } from "src/spec-helpers";
import { StudentSummary } from "../models/student.model";
import { StudentsRestService } from "./students-rest.service";

describe("StudentsRestService", () => {
Expand Down Expand Up @@ -56,4 +58,28 @@ describe("StudentsRestService", () => {
]);
});
});

describe(".getStudentSummaries", () => {
it("should request the student summaries for the given ids", () => {
const studentSummaries: ReadonlyArray<StudentSummary> = [
buildStudent(54425),
buildStudent(56200),
].map(({ Id, FirstName, LastName, DisplayEmail }) => ({
Id,
FirstName,
LastName,
DisplayEmail,
}));

service.getStudentSummaries([54425, 56200]).subscribe((result) => {
expect(result).toEqual(studentSummaries);
});

httpTestingController
.expectOne(
"https://eventotest.api/Students/?filter.Id=;54425,56200&fields=Id,FirstName,LastName,DisplayEmail",
)
.flush(studentSummaries);
});
});
});
15 changes: 14 additions & 1 deletion src/app/shared/services/students-rest.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { LegalRepresentative } from "../models/legal-representative.model";
import { LessonAbsence } from "../models/lesson-absence.model";
import { LessonDispensation } from "../models/lesson-dispensation.model";
import { LessonIncident } from "../models/lesson-incident.model";
import { Student } from "../models/student.model";
import { Student, StudentSummary } from "../models/student.model";
import { TimetableEntry } from "../models/timetable-entry.model";
import { decodeArray } from "../utils/decode";
import { TypeaheadRestService } from "./typeahead-rest.service";
Expand Down Expand Up @@ -97,4 +97,17 @@ export class StudentsRestService extends TypeaheadRestService<typeof Student> {
)
.pipe(switchMap(decodeArray(TimetableEntry)));
}

getStudentSummaries(
ids: ReadonlyArray<number>,
): Observable<ReadonlyArray<StudentSummary>> {
return this.http
.get<unknown>(`${this.baseUrl}/`, {
params: {
"filter.Id": `;${ids.join(";")}`,
fields: ["Id", "FirstName", "LastName", "DisplayEmail"].join(","),
},
})
.pipe(switchMap(decodeArray(StudentSummary)));
}
}

0 comments on commit 6a666ad

Please sign in to comment.