Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/337 student dossier report #396

Merged
merged 16 commits into from
May 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/app/events/services/test-state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,8 @@ export class TestStateService {
)
);

private gradingScales$ = this.gradingScaleIds$.pipe(
switchMap((ids) =>
forkJoin(
ids.map((id) => this.gradingScalesRestService.getGradingScale(id))
)
),
shareReplay(1)
private gradingScales$ = this.gradingScalesRestService.loadGradingScales(
this.gradingScaleIds$
);

private gradingScalesOptions$: Observable<GradingScaleOptions> = this.gradingScales$.pipe(
Expand Down
1 change: 1 addition & 0 deletions src/app/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const Settings = t.type({
studentConfirmationReportId: t.number,
evaluateAbsencesReportId: t.number,
testsByCourseReportId: t.number,
testsBySubscriptionReportId: t.number,
subscriptionDetailGroupId: t.number,
headerRoleRestriction: t.record(t.string, t.string),
notificationRefreshTime: t.number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class DossierAbsencesComponent implements OnInit, OnDestroy {
public absencesSelectionService: ConfirmAbsencesSelectionService
) {
this.state.isOverview$.next(false);
this.state.currentDossier$.next('absences');
}

ngOnInit(): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { BehaviorSubject, of } from 'rxjs';
import { DossierStateService } from 'src/app/shared/services/dossier-state.service';
import {
DossierPage,
DossierStateService,
} from 'src/app/shared/services/dossier-state.service';
import { buildStudent } from 'src/spec-builders';
import { buildTestModuleMetadata } from 'src/spec-helpers';
import { StudentDossierAddressComponent } from '../student-dossier-address/student-dossier-address.component';
Expand All @@ -14,9 +17,11 @@ describe('DossierAddressesComponent', () => {
let fixture: ComponentFixture<DossierAddressesComponent>;
let stateServiceMock: DossierStateService;
let isOverview$: BehaviorSubject<boolean>;
let currentDossier$: BehaviorSubject<DossierPage>;

beforeEach(async () => {
isOverview$ = new BehaviorSubject<boolean>(false);
currentDossier$ = new BehaviorSubject<DossierPage>('addresses');

stateServiceMock = ({
profile$: of({
Expand All @@ -25,6 +30,7 @@ describe('DossierAddressesComponent', () => {
apprenticeshipCompanies: [],
}),
isOverview$,
currentDossier$,
} as unknown) as DossierStateService;

await TestBed.configureTestingModule(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { DossierStateService } from 'src/app/shared/services/dossier-state.service';

@Component({
Expand All @@ -10,5 +10,6 @@ import { DossierStateService } from 'src/app/shared/services/dossier-state.servi
export class DossierAddressesComponent {
constructor(public state: DossierStateService) {
this.state.isOverview$.next(false);
this.state.currentDossier$.next('addresses');
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { DebugElement } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import {
Course,
FinalGrading,
Grading,
} from 'src/app/shared/models/course.model';
import { Grade, GradingScale } from 'src/app/shared/models/grading-scale.model';
import { FinalGrade } from 'src/app/shared/models/student-grades';
import { Course } from 'src/app/shared/models/course.model';
import { GradingScale } from 'src/app/shared/models/grading-scale.model';
import { buildTestModuleMetadata } from 'src/spec-helpers';
import { expectText } from 'src/specs/expectations';
import { DossierCourseTestsComponent } from './dossier-course-tests.component';
import { DossierGradesService } from '../../../services/dossier-grades.service';
import { StorageService } from '../../../services/storage.service';

describe('DossierCourseTestsComponent', () => {
let component: DossierCourseTestsComponent;
Expand All @@ -22,6 +19,17 @@ describe('DossierCourseTestsComponent', () => {
await TestBed.configureTestingModule(
buildTestModuleMetadata({
declarations: [DossierCourseTestsComponent],
providers: [
DossierGradesService,
{
provide: StorageService,
useValue: {
getPayload(): Option<object> {
return { id_person: 42 };
},
},
},
],
})
).compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { buildTestModuleMetadata } from 'src/spec-helpers';
import { expectText } from 'src/specs/expectations';
import { DossierGradesViewComponent } from './dossier-grades-view.component';
import { DossierGradesService } from '../../../services/dossier-grades.service';
import { StorageService } from '../../../services/storage.service';

describe('DossierGradesViewComponent', () => {
let component: DossierGradesViewComponent;
Expand All @@ -13,6 +15,18 @@ describe('DossierGradesViewComponent', () => {
await TestBed.configureTestingModule(
buildTestModuleMetadata({
declarations: [DossierGradesViewComponent],
providers: [
DossierGradesService,
StorageService,
{
provide: StorageService,
useValue: {
getPayload(): Option<object> {
return { id_person: 42 };
},
},
},
],
})
).compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input } from '@angular/core';
import { Course } from 'src/app/shared/models/course.model';
import { GradingScale } from 'src/app/shared/models/grading-scale.model';
import { DossierGradesService } from 'src/app/shared/services/dossier-grades.service';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ng-container
*erzLet="{
studentId: state.studentId$ | async,
courses: dossierGradesService.studentCourses$ | async,
loading: dossierGradesService.loading$ | async,
courses: dossierGradesService.studentCourses$ | async,
gradingScales: dossierGradesService.gradingScales$ | async
} as data"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,73 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { DossierStateService } from 'src/app/shared/services/dossier-state.service';
import { DossierGradesService } from 'src/app/shared/services/dossier-grades.service';
import {
DossierPage,
DossierStateService,
} from 'src/app/shared/services/dossier-state.service';
import { StorageService } from 'src/app/shared/services/storage.service';
import { buildTestModuleMetadata } from 'src/spec-helpers';

import { DossierGradesComponent } from './dossier-grades.component';
import { BehaviorSubject, of } from 'rxjs';
import { Course } from '../../../models/course.model';
import { buildCourse, buildGradingScale } from '../../../../../spec-builders';
import { GradingScale } from '../../../models/grading-scale.model';

describe('StudentGradesComponent', () => {
describe('DossierGradesComponent', () => {
let component: DossierGradesComponent;
let fixture: ComponentFixture<DossierGradesComponent>;

let dossierStateServiceMock: DossierStateService;
let isOverview$: BehaviorSubject<boolean>;
let currentDossier$: BehaviorSubject<DossierPage>;

let dossierGradesServiceMock: DossierGradesService;
let loading$: BehaviorSubject<boolean>;
let studentCourses$: BehaviorSubject<Course[]>;
let gradingScales$: BehaviorSubject<readonly GradingScale[]>;

let courses = [buildCourse(1234)];
const gradingScales = [buildGradingScale(1)];

beforeEach(async () => {
isOverview$ = new BehaviorSubject<boolean>(false);
currentDossier$ = new BehaviorSubject<DossierPage>('grades');

dossierStateServiceMock = ({
isOverview$,
currentDossier$,
studentId$: of(123),
} as unknown) as DossierStateService;

loading$ = new BehaviorSubject<any>(false);
studentCourses$ = new BehaviorSubject<Course[]>(courses);
gradingScales$ = new BehaviorSubject<readonly GradingScale[]>(
gradingScales
);

dossierGradesServiceMock = ({
loading$,
studentCourses$,
gradingScales$,
} as unknown) as DossierGradesService;

await TestBed.configureTestingModule(
buildTestModuleMetadata({
declarations: [DossierGradesComponent],
providers: [DossierStateService],
providers: [
{ provide: DossierStateService, useValue: dossierStateServiceMock },
{
provide: DossierGradesService,
useValue: {
dossierGradesServiceMock,
setStudentId: jasmine.createSpy('setStudentId'),
},
},
{
provide: StorageService,
useValue: jasmine.createSpyObj('StorageService', ['getPayload']),
},
],
})
).compileComponents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class DossierGradesComponent implements OnInit, OnDestroy {

ngOnInit(): void {
this.state.isOverview$.next(false);
this.state.currentDossier$.next('grades');

this.state.studentId$
.pipe(takeUntil(this.destroy$))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ import { DossierStateService } from 'src/app/shared/services/dossier-state.servi
export class DossierOverviewComponent {
constructor(public state: DossierStateService) {
this.state.isOverview$.next(true);
this.state.currentDossier$.next('overview');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,31 @@
>
<ng-container
*erzLet="{
profile: state.profile$ | async
profile: state.profile$ | async,
currentDossierSection: state.currentDossier$ | async,
reportUrl: dossierGradesService.testReportUrl$ | async
} as data"
>
<ng-container *ngIf="(state.loading$ | async) === false; else loading">
<erz-student-backlink
class="mb-2"
[link]="link$ | async"
[queryParams]="queryParams$ | async"
[studentId]="state.studentId$ | async"
[student]="data.profile && data.profile.student"
></erz-student-backlink>

<div class="d-flex w-100 justify-content-between">
<erz-student-backlink
class="mb-2"
[link]="link$ | async"
[queryParams]="queryParams$ | async"
[studentId]="state.studentId$ | async"
[student]="data.profile && data.profile.student"
></erz-student-backlink>
<div class="mr-3">
<a
*ngIf="data.currentDossierSection === 'grades'"
class="edit btn btn-primary ml-2"
target="_blank"
[href]="data.reportUrl"
>
<i class="material-icons">description</i>
</a>
</div>
</div>
<div *ngIf="data.profile; else noProfile">
<router-outlet></router-outlet>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { buildTestModuleMetadata } from 'src/spec-helpers';
import { StudentDossierComponent } from './student-dossier.component';
import { DossierStateService } from '../../../services/dossier-state.service';
import { DossierGradesService } from 'src/app/shared/services/dossier-grades.service';
import { ReportsService } from 'src/app/shared/services/reports.service';
import { StorageService } from 'src/app/shared/services/storage.service';

describe('StudentDossierComponent', () => {
let component: StudentDossierComponent;
Expand All @@ -13,7 +16,15 @@ describe('StudentDossierComponent', () => {
TestBed.configureTestingModule(
buildTestModuleMetadata({
declarations: [StudentDossierComponent],
providers: [DossierStateService],
providers: [
DossierStateService,
DossierGradesService,
ReportsService,
{
provide: StorageService,
useValue: jasmine.createSpyObj('StorageService', ['getPayload']),
},
],
})
).compileComponents();
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { map, switchMap } from 'rxjs';
import { DossierGradesService } from 'src/app/shared/services/dossier-grades.service';
import { DossierStateService } from '../../../services/dossier-state.service';

@Component({
selector: 'erz-student-dossier',
templateUrl: './student-dossier.component.html',
styleUrls: ['./student-dossier.component.scss'],
providers: [DossierStateService],
providers: [DossierStateService, DossierGradesService],
changeDetection: ChangeDetectionStrategy.OnPush,
})

// TODO: on Destroy
export class StudentDossierComponent {
link$ = this.state.isOverview$.pipe(
map((isOverview) => (isOverview ? ['../..'] : ['.']))
Expand All @@ -26,5 +29,8 @@ export class StudentDossierComponent {
)
);

constructor(public state: DossierStateService) {}
constructor(
public state: DossierStateService,
public dossierGradesService: DossierGradesService
) {}
}
34 changes: 34 additions & 0 deletions src/app/shared/models/subscription-detail.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,39 @@ const SubscriptionDetail = t.type({
// HRef: t.string,
});

const IdSubscription = t.type({
Id: t.number,
CurrentWorkProgressId: Option(t.string || Option(t.number)),
EventId: Option(t.number),
PersonId: Option(t.number),
Status: t.string,
StatusId: Option(t.number),
IsOkay: Option(t.boolean),
IsQueued: Option(t.boolean),
EventDesignation: Option(t.string),
EventInformation: Option(t.string || t.number),
EventNotes: Option(t.string || t.number),
CheckPersonalInformation: Option(t.boolean),
CorrespondencePersonId: Option(t.number),
CorrespondenceAddressTypeId: Option(t.string || t.number),
Billing1PersonId: Option(t.number),
Billing1AddressTypeId: Option(t.string || t.number),
Billing2PersonId: Option(t.string || t.number),
Billing2AddressTypeId: Option(t.string || t.number),
KindOfPaymentId1: Option(t.string || t.number),
KindOfPaymentEmail1: Option(t.string || t.number),
KindOfPaymentId2: Option(t.string || t.number),
KindOfPaymentEmail2: Option(t.string || t.number),
IdObject: Option(t.number),
IdSubscription: Option(t.number),
IdStatus: Option(t.number),
AnsweredQuestions: Option(t.string || t.number),
Messages: Option(t.string || t.number),
SubscriptionDetails: Option(t.array(SubscriptionDetail)),
HRef: Option(t.string),
});

type SubscriptionDetail = t.TypeOf<typeof SubscriptionDetail>;
type IdSubscription = t.TypeOf<typeof IdSubscription>;
export { SubscriptionDetail as SubscriptionDetail };
export { IdSubscription as IdSubscription };
Loading