diff --git a/src/app/components/fragments/content-choice-creator/content-choice-creator.component.html b/src/app/components/fragments/content-choice-creator/content-choice-creator.component.html index 39efb1df06858dfa6f12514760859fca5cf825ae..068ed615616157d5d321faef1d02c8fd3e2c5e73 100644 --- a/src/app/components/fragments/content-choice-creator/content-choice-creator.component.html +++ b/src/app/components/fragments/content-choice-creator/content-choice-creator.component.html @@ -10,7 +10,7 @@ <markdown [data]="content.body"></markdown> <mat-divider></mat-divider> - <mat-radio-group [(ngModel)]="singleChoice" fxLayout="row" fxLayoutAlign="center" fxLayoutGap="20px"> + <mat-radio-group [(ngModel)]="singleChoice" [ngModelOptions]="{standalone: true}" fxLayout="row" fxLayoutAlign="center" fxLayoutGap="20px"> <mat-radio-button [value]=true [checked]=true> Single Choice </mat-radio-button> @@ -32,16 +32,11 @@ </mat-cell> </ng-container> - <ng-container matColumnDef="points"> - <mat-header-cell *matHeaderCellDef>Points</mat-header-cell> - <mat-cell *matCellDef="let answer">{{ answer.answerOption.points }}</mat-cell> - </ng-container> - <ng-container matColumnDef="actions"> <mat-header-cell *matHeaderCellDef>Actions</mat-header-cell> <mat-cell *matCellDef="let answer"> <button mat-icon-button - (click)="openAnswerModificationDialog($event, answer.answerOption.label, answer.answerOption.points, answer.correct)" + (click)="openAnswerModificationDialog($event, answer.answerOption.label, answer.correct)" color="primary" matTooltip="Edit answer"> <mat-icon>edit</mat-icon> </button> @@ -60,11 +55,7 @@ <mat-form-field class="input-block"> <input matInput #answerLabel [(ngModel)]="newAnswerOptionLabel" placeholder="Answer" name="answer"> </mat-form-field> - <mat-form-field class="input-block"> - <input matInput #answerPoints [(ngModel)]="newAnswerOptionPoints" placeholder="Points" name="points"> - </mat-form-field> - <button mat-button type="button" - (click)="addAnswer($event); answerLabel.value = ''; answerPoints.value = ''"> + <button mat-button type="button" (click)="addAnswer($event); answerLabel.value = '';"> Add Answer </button> </div> diff --git a/src/app/components/fragments/content-choice-creator/content-choice-creator.component.ts b/src/app/components/fragments/content-choice-creator/content-choice-creator.component.ts index 9b26a2c25a44824abd66fae2dc27acf4ac3946d1..ba3176466ad6138af8ea8b108fe02b681507eab3 100644 --- a/src/app/components/fragments/content-choice-creator/content-choice-creator.component.ts +++ b/src/app/components/fragments/content-choice-creator/content-choice-creator.component.ts @@ -41,14 +41,13 @@ export class ContentChoiceCreatorComponent implements OnInit { ContentType.CHOICE ); - displayedColumns = ['label', 'points', 'actions']; + displayedColumns = ['label', 'actions']; displayAnswers: DisplayAnswer[] = []; lastDeletedDisplayAnswer: DisplayAnswer; newAnswerOptionChecked = false; newAnswerOptionLabel = ''; - newAnswerOptionPoints = ''; editDisplayAnswer: DisplayAnswer; originalDisplayAnswer: DisplayAnswer; @@ -97,14 +96,12 @@ export class ContentChoiceCreatorComponent implements OnInit { this.notificationService.show('No empty answers allowed.'); this.newAnswerOptionChecked = false; this.newAnswerOptionLabel = ''; - this.newAnswerOptionPoints = ''; return; } if (this.singleChoice && this.content.correctOptionIndexes.length > 0 && this.newAnswerOptionChecked) { this.notificationService.show('In single choice mode is only 1 true answer allowed.'); this.newAnswerOptionChecked = false; this.newAnswerOptionLabel = ''; - this.newAnswerOptionPoints = ''; return; } for (let i = 0; i < this.content.options.length; i++) { @@ -113,10 +110,10 @@ export class ContentChoiceCreatorComponent implements OnInit { return; } } - this.content.options.push(new AnswerOption(this.newAnswerOptionLabel, this.newAnswerOptionPoints)); + let points = (this.newAnswerOptionChecked) ? '10' : '-10'; + this.content.options.push(new AnswerOption(this.newAnswerOptionLabel, points)); this.newAnswerOptionChecked = false; this.newAnswerOptionLabel = ''; - this.newAnswerOptionPoints = ''; this.fillCorrectAnswers(); } @@ -139,7 +136,7 @@ export class ContentChoiceCreatorComponent implements OnInit { saveChanges(index: number, answer: DisplayAnswer, matDialogOutput: boolean) { this.content.options[index].label = answer.answerOption.label; - this.content.options[index].points = answer.answerOption.points; + this.content.options[index].points = (answer.correct) ? '10' : '-10'; const indexInCorrectOptionIndexes = this.content.correctOptionIndexes.indexOf(index); if (indexInCorrectOptionIndexes === -1 && answer.correct) { if (this.singleChoice) { diff --git a/src/app/services/http/content.service.ts b/src/app/services/http/content.service.ts index ac6c6d158feade528300a5a2628834013c32e0d8..9acf7e21fe6486c91ceffb9b5586c4b19766970a 100644 --- a/src/app/services/http/content.service.ts +++ b/src/app/services/http/content.service.ts @@ -33,6 +33,8 @@ export class ContentService extends BaseHttpService { } addContent(content: Content): Observable<Content> { + delete content.id; + delete content.revision; const connectionUrl = this.apiUrl.base + this.apiUrl.content + '/'; return this.http.post<Content>(connectionUrl, content,