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/339 my grades #416

Merged
merged 19 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
6 changes: 6 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ const routes: Routes = [
loadChildren: () =>
import('./my-profile/my-profile.module').then((m) => m.MyProfileModule),
},
{
path: 'my-grades',
canActivate: [AuthGuard],
loadChildren: () =>
import('./my-grades/my-grades.module').then((m) => m.MyGradesModule),
},
{
path: 'my-settings',
canActivate: [AuthGuard],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('EvaluateAbsencesListComponent', () => {
provide: StorageService,
useValue: {
getPayload(): Option<object> {
return { id_person: 42 };
return { id_person: '42' };
},
},
},
Expand Down
1 change: 1 addition & 0 deletions src/app/home.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('HomeComponent', () => {
'/events',
'/my-absences',
'/my-profile',
'/my-grades',
'/my-settings',
]);
});
Expand Down
1 change: 1 addition & 0 deletions src/app/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class HomeComponent {
'events',
'my-absences',
'my-profile',
'my-grades',
'my-settings',
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
absenceCounts: myAbsencesService.counts$ | async
} as data"
>
<ngb-accordion ngb-accordion #acc="ngbAccordion">
<ngb-accordion #acc="ngbAccordion">
<ngb-panel id="report-absence">
<ng-template ngbPanelHeader>
<erz-my-absences-report-link></erz-my-absences-report-link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('MyAbsencesShowComponent', () => {
provide: StorageService,
useValue: {
getPayload(): Option<object> {
return { id_person: 42 };
return { id_person: '42' };
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('MyAbsencesReportStateService', () => {
provide: StorageService,
useValue: {
getPayload(): Option<object> {
return { id_person: 42 };
return { id_person: '42' };
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class MyAbsencesReportStateService extends PaginatedEntriesService<
if (id == null) {
throw new Error('No student id available');
}
return id;
return Number(id);
}

private loadTimetableEntries(
Expand Down
2 changes: 1 addition & 1 deletion src/app/my-absences/services/my-absences.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('MyAbsencesService', () => {
provide: StorageService,
useValue: {
getPayload(): any {
return { id_person: 123 };
return { id_person: '123' };
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions src/app/my-absences/services/my-absences.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export class MyAbsencesService {
private storageService: StorageService,
private studentsService: StudentsRestService
) {
const studentId = this.storageService.getPayload()?.id_person || null;
const studentId = this.storageService.getPayload()?.id_person;
if (studentId) {
this.studentId$.next(studentId);
this.studentId$.next(Number(studentId));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="d-flex justify-content-between header">
<div>{{ 'my-grades.header' | translate }}</div>
<div>
<a
[href]="myGradesService.testReportUrl$ | async"
class="report btn btn-primary"
target="_blank"
>
<i class="material-icons">description</i>
</a>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@import "../../../../bootstrap-variables";

.header {
padding-left: $spacer;
padding-bottom: $spacer;
}

@media (max-width: 750px) {
.header {
padding-right: $spacer;
}
}

.report {
margin-left: $spacer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MyGradesHeaderComponent } from './my-grades-header.component';
import { buildTestModuleMetadata } from '../../../../spec-helpers';
import { MyGradesService } from '../../services/my-grades.service';
import { of } from 'rxjs';

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

beforeEach(async () => {
await TestBed.configureTestingModule(
buildTestModuleMetadata({
declarations: [MyGradesHeaderComponent],
providers: [
{
provide: MyGradesService,
useValue: {
studentId$: of(1),
studentCourses$: of([]),
},
},
],
})
).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(MyGradesHeaderComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';
import { MyGradesService } from '../../services/my-grades.service';

@Component({
selector: 'erz-my-grades-header',
templateUrl: './my-grades-header.component.html',
styleUrls: ['./my-grades-header.component.scss'],
})
export class MyGradesHeaderComponent {
constructor(public myGradesService: MyGradesService) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div
class="erz-container erz-container-limited erz-container-padding-y erz-container-padding-x-responsive"
>
<ng-container
*erzLet="{
loading: myGradesService.loading$ | async,
studentId: myGradesService.studentId$ | async,
courses: myGradesService.studentCourses$ | async,
gradingScales: myGradesService.gradingScales$ | async
} as data"
>
<erz-my-grades-header></erz-my-grades-header>
<erz-dossier-grades-view
*ngIf="!data.loading"
[courses]="data.courses"
[studentId]="data.studentId"
[gradingScales]="data.gradingScales"
[isEditable]="false"
></erz-dossier-grades-view>
<ng-container *ngIf="data.loading">
<erz-spinner></erz-spinner>
</ng-container>
</ng-container>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MyGradesShowComponent } from './my-grades-show.component';
import { CoursesRestService } from '../../../shared/services/courses-rest.service';
import { StorageService } from '../../../shared/services/storage.service';
import { buildTestModuleMetadata } from 'src/spec-helpers';
import { MyGradesService } from '../../services/my-grades.service';
import { of } from 'rxjs';

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

beforeEach(async () => {
await TestBed.configureTestingModule(
buildTestModuleMetadata({
declarations: [MyGradesShowComponent],
providers: [
{
provide: MyGradesService,
useValue: {
studentId$: of(1),
studentCourses$: of([]),
},
},
{
provide: StorageService,
useValue: jasmine.createSpyObj('StorageService', ['getPayload']),
},
],
})
).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(MyGradesShowComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Component } from '@angular/core';
import { MyGradesService } from '../../services/my-grades.service';
import { DossierGradesService } from '../../../shared/services/dossier-grades.service';

@Component({
selector: 'erz-my-grades-show',
templateUrl: './my-grades-show.component.html',
styleUrls: ['./my-grades-show.component.scss'],
providers: [DossierGradesService],
})
export class MyGradesShowComponent {
constructor(public myGradesService: MyGradesService) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<router-outlet></router-outlet>
Empty file.
24 changes: 24 additions & 0 deletions src/app/my-grades/components/my-grades/my-grades.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MyGradesComponent } from './my-grades.component';

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

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [MyGradesComponent],
}).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(MyGradesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
12 changes: 12 additions & 0 deletions src/app/my-grades/components/my-grades/my-grades.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';
import { MyGradesService } from '../../services/my-grades.service';

@Component({
selector: 'erz-my-grades',
templateUrl: './my-grades.component.html',
styleUrls: ['./my-grades.component.scss'],
providers: [MyGradesService],
})
export class MyGradesComponent {
constructor() {}
}
18 changes: 18 additions & 0 deletions src/app/my-grades/my-grades-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { MyGradesComponent } from './components/my-grades/my-grades.component';
import { MyGradesShowComponent } from './components/my-grades-show/my-grades-show.component';

const routes: Routes = [
{
path: '',
component: MyGradesComponent,
children: [{ path: '', component: MyGradesShowComponent }],
},
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class MyGradesRoutingModule {}
18 changes: 18 additions & 0 deletions src/app/my-grades/my-grades.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { MyGradesRoutingModule } from './my-grades-routing.module';
import { MyGradesComponent } from './components/my-grades/my-grades.component';
import { MyGradesShowComponent } from './components/my-grades-show/my-grades-show.component';
import { SharedModule } from '../shared/shared.module';
import { MyGradesHeaderComponent } from './components/my-grades-header/my-grades-header.component';

@NgModule({
declarations: [
MyGradesComponent,
MyGradesShowComponent,
MyGradesHeaderComponent,
],
imports: [CommonModule, MyGradesRoutingModule, SharedModule],
})
export class MyGradesModule {}
Loading