Skip to content
Snippets Groups Projects
Commit 441fc54a authored by Thomas Lenz's avatar Thomas Lenz
Browse files

Add dummy-content to build yes or no - component's view

parent 41814376
No related merge requests found
<p>
content-yes-no-creator works!
</p>
<form (ngSubmit)="submitContent()">
<mat-form-field class="input-block">
<input matInput #subject [(ngModel)]="content.subject" placeholder="Subject" name="subject">
</mat-form-field>
<mat-form-field class="input-block">
<textarea matInput #body [(ngModel)]="content.body" placeholder="Body" name="body"></textarea>
</mat-form-field>
<mat-divider></mat-divider>
<mat-table #table [dataSource]="displayAnswers">
<ng-container matColumnDef="label">
<mat-header-cell *matHeaderCellDef>Answer</mat-header-cell>
<mat-cell *matCellDef="let answer">
<!-- ToDo: Check ngModel -->
<mat-checkbox color="primary" [(ngModel)]="answer.correct" [checked]="answer.correct"
name="{{ answer.answerOption.label }}">{{ answer.answerOption.label }} is {{ answer.correct }}
</mat-checkbox>
</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>
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
<mat-row *matRowDef="let row; columns: displayedColumns;"></mat-row>
</mat-table>
<mat-divider></mat-divider>
<button mat-raised-button type="submit" color="primary">Submit</button>
</form>
import { Component, OnInit } from '@angular/core';
import { ContentChoice } from '../../../models/content-choice';
import { DisplayAnswer } from '../content-choice-creator/content-choice-creator.component';
import { AnswerOption } from '../../../models/answer-option';
@Component({
selector: 'app-content-yes-no-creator',
......@@ -6,10 +9,43 @@ import { Component, OnInit } from '@angular/core';
styleUrls: ['./content-yes-no-creator.component.scss']
})
export class ContentYesNoCreatorComponent implements OnInit {
answerLabels = [
'yes',
'no'
];
content: ContentChoice = new ContentChoice('0',
'1',
'',
'',
'',
1,
[],
[],
false);
constructor() { }
displayedColumns = ['label', 'points'];
displayAnswers: DisplayAnswer[] = [];
newAnswerOptionPoints = '';
constructor() {
}
ngOnInit() {
for (let i = 0; i < this.answerLabels.length; i++) {
this.content.options.push(new AnswerOption(this.answerLabels[i], this.newAnswerOptionPoints));
}
this.fillCorrectAnswers();
}
fillCorrectAnswers() {
this.displayAnswers = [];
for (let i = 0; i < this.content.options.length; i++) {
this.displayAnswers.push(new DisplayAnswer(this.content.options[i], this.content.correctOptionIndexes.includes(i)));
}
}
submitContent(): void {
console.log('submit content');
}
}
......@@ -18,7 +18,7 @@
</mat-tab>
<mat-tab label="Yes / No">
<div class="tab-container">
<app-content-choice-creator></app-content-choice-creator>
<app-content-yes-no-creator></app-content-yes-no-creator>
</div>
</mat-tab>
</mat-tab-group>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment