Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into feature/#688-auto-fix-linting
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickSkowronek committed May 4, 2018
2 parents c44f9f9 + 79269e1 commit 1851f75
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Refactored register and resend activation to use geli email validator with top level domain check. [#713] (https://github.com/h-da/geli/issues/713)

### Fixed
- Fixed Course progress mechanism
- Fixed wasteful course data usage via specialized course model interfaces. [#654](https://github.com/h-da/geli/issues/654)
- Fixed a broken documentation link. [#583](https://github.com/h-da/geli/issues/583)
- Limited the first and last name to 64 characters in the registration- and edit page. [#585](https://github.com/h-da/geli/issues/585)
Expand Down
4 changes: 2 additions & 2 deletions app/webFrontend/src/app/shared/services/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ export abstract class DataService {
.toPromise();
}

readSingleItem<T>(id: string): Promise<T> {
readSingleItem<T>(id: string, apiPath = this.apiPath): Promise<T> {
return new Promise((resolve, reject) => {
this.backendService.get(this.apiPath + id)
this.backendService.get(apiPath + id)
.subscribe(
(responseItems: any) => {
if (this.changeProps2Date) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@ export class ProgressService extends DataService {
super('progress/', backendService);
}

getUnitProgress(unitId: string) {
const originalApiPath = this.apiPath;
this.apiPath += 'units/';
const promise = this.readSingleItem(unitId);
this.apiPath = originalApiPath;
return promise;
async getUnitProgress<T>(unitId: string): Promise<T> {
const unitProgress = await this.readSingleItem<any[]>(unitId, this.apiPath + 'units/');
return unitProgress.length > 0 ? unitProgress[0] : null;
}

getCourseProgress(courseId: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,15 @@ export class CodeKataComponent implements OnInit {
this.progress = this.codeKataUnit.progressData;
}
}

this.applyProgressData();
}

async applyProgressData() {
const progress = await this.progressService.getUnitProgress<ICodeKataUnitProgress>(this.codeKataUnit._id);
if (progress) {
this.progress = progress;
}
}

ngAfterViewInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[class.correct]="validationMode && answer.value"
[class.incorrect]="validationMode && !answer.value">

<mat-checkbox [disabled]="validationMode" [(ngModel)]="progress.answers[task._id][answer._id]">
<mat-checkbox [disabled]="validationMode" *ngIf="progress.answers[task._id]" [(ngModel)]="progress.answers[task._id][answer._id]">
<span class="answer-text">{{answer.text}}</span>
</mat-checkbox>
</li>
Expand Down
11 changes: 10 additions & 1 deletion app/webFrontend/src/app/unit/task-unit/task-unit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ export class TaskUnitComponent implements OnInit {
this.progress = this.taskUnit.progressData;
}

this.applyProgressData();
this.shuffleAnswers();
}

async applyProgressData() {
const progress = await this.progressService.getUnitProgress<ITaskUnitProgress>(this.taskUnit._id);
if (progress) {
this.progress = progress;
}

if (!this.progress.answers) {
this.resetProgressAnswers();
} else {
Expand All @@ -49,7 +59,6 @@ export class TaskUnitComponent implements OnInit {
}
});
}
this.shuffleAnswers();
}

resetProgressAnswers() {
Expand Down

0 comments on commit 1851f75

Please sign in to comment.