Skip to content
Snippets Groups Projects
Commit 6260f0d2 authored by Lukas Mauß's avatar Lukas Mauß
Browse files

Fix translation-service for content-choice-creation

parent 9d582a4e
No related merge requests found
<h3>Are you sure?</h3>
<h3>{{ 'room-page.sure' | translate}}</h3>
<p>Do you really want to delete content <strong>{{content.subject}}</strong>? This action can not be undone.</p>
<div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px">
<button mat-raised-button color="warn" (click)="closeDialog('delete')">
......
......@@ -71,8 +71,7 @@
<button mat-raised-button type="submit" color="accent">{{ 'content.create' | translate }}</button>
<button mat-raised-button (click)="reset($event)" color="primary">{{ 'content.reset' | translate }}</button>
<button mat-raised-button *ngIf="lastDeletedDisplayAnswer" (click)="recoverDeletedAnswer($event)" color="primary">
Undo
deletion
{{ 'content.undo' | translate}}
</button>
</div>
<div *ngIf="editDialogMode" fxLayout="row" fxLayoutAlign="center" fxLayoutGap="50px">
......
......@@ -111,20 +111,26 @@ export class ContentChoiceCreatorComponent implements OnInit {
addAnswer($event) {
$event.preventDefault();
if (this.newAnswerOptionLabel === '') {
this.notificationService.show('No empty answers allowed.');
this.translationService.get('content.no-empty2').subscribe(message => {
this.notificationService.show(message);
});
this.newAnswerOptionChecked = false;
this.newAnswerOptionLabel = '';
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.translationService.get('content.only-one').subscribe(message => {
this.notificationService.show(message);
});
this.newAnswerOptionChecked = false;
this.newAnswerOptionLabel = '';
return;
}
for (let i = 0; i < this.content.options.length; i++) {
if (this.content.options[i].label.valueOf() === this.newAnswerOptionLabel.valueOf()) {
this.notificationService.show('Same answer label is not allowed.');
this.translationService.get('content.same-answer').subscribe(message => {
this.notificationService.show(message);
});
return;
}
}
......@@ -169,7 +175,9 @@ export class ContentChoiceCreatorComponent implements OnInit {
}
this.fillCorrectAnswers();
if (matDialogOutput) {
this.notificationService.show('Update changes.');
this.translationService.get('content.changes-made').subscribe(message => {
this.notificationService.show(message);
});
}
}
......@@ -188,30 +196,32 @@ export class ContentChoiceCreatorComponent implements OnInit {
}
}
this.fillCorrectAnswers();
this.notificationService.show('Answer "' + this.lastDeletedDisplayAnswer.answerOption.label + '" successfully deleted.');
this.translationService.get('content.answer-deleted').subscribe(message => {
this.notificationService.show(message);
});
}
recoverDeletedAnswer($event) {
$event.preventDefault();
let msgAddon = 'Answer "' + this.lastDeletedDisplayAnswer.answerOption.label + '" successfully recovered.';
if (this.lastDeletedDisplayAnswer === null) {
this.notificationService.show('Nothing to recover.');
}
this.translationService.get('content.answer-recovered').subscribe(message => { this.notificationService.show(message);
});
for (let i = 0; i < this.content.options.length; i++) {
if (this.content.options[i].label.valueOf() === this.lastDeletedDisplayAnswer.answerOption.label.valueOf()) {
this.notificationService.show('Same answer label is not allowed.');
this.translationService.get('content.same-answer').subscribe(message => {
this.notificationService.show(message);
});
return;
}
}
this.content.options.push(this.lastDeletedDisplayAnswer.answerOption);
if (this.lastDeletedDisplayAnswer.correct) {
if (this.singleChoice && this.content.correctOptionIndexes.length > 0) {
msgAddon = 'In single mode is only 1 true answer allowed. Recovered item is set to false.';
this.translationService.get('content.only-one-true').subscribe(message => { this.notificationService.show(message);
});
} else {
this.content.correctOptionIndexes.push(this.content.options.length - 1);
}
}
this.notificationService.show(msgAddon);
this.lastDeletedDisplayAnswer = null;
this.fillCorrectAnswers();
}
......@@ -233,7 +243,9 @@ export class ContentChoiceCreatorComponent implements OnInit {
this.content.options = [];
this.content.correctOptionIndexes = [];
this.fillCorrectAnswers();
this.notificationService.show('Reset all inputs to default.');
this.translationService.get('content.reset-all').subscribe(message => {
this.notificationService.show(message);
});
}
resetAfterSubmit() {
......@@ -255,15 +267,21 @@ export class ContentChoiceCreatorComponent implements OnInit {
return;
}
if (this.content.options.length === 0) {
this.notificationService.show('Choice content needs answers. Please add some answers.');
this.translationService.get('content.need-answers').subscribe(message => {
this.notificationService.show(message);
});
return;
}
if (this.singleChoice && this.content.correctOptionIndexes.length !== 1) {
this.notificationService.show('In single choice mode you have to select 1 true answer.');
this.translationService.get('content.select-one').subscribe(message => {
this.notificationService.show(message);
});
return;
}
if (!this.singleChoice && this.content.correctOptionIndexes.length < 1) {
this.notificationService.show('In multiple choice mode you have to select at least 1 true answer.');
this.translationService.get('content.at-least-one').subscribe(message => {
this.notificationService.show(message);
});
return;
}
if (this.singleChoice) {
......
<div *ngIf="answer">
<mat-form-field class="input-block">
<input [(ngModel)]="answer.answerOption.label" #roomName matInput placeholder="Answer label" name="answer-label"/>
<input [(ngModel)]="answer.answerOption.label" #roomName matInput placeholder="{{ 'content.answer' | translate }}" name="answer-label"/>
</mat-form-field>
<mat-form-field class="input-block">
<textarea [(ngModel)]="answer.answerOption.points" #roomDescription matInput matTextareaAutosize
matAutosizeMinRows="2" matAutosizeMaxRows="5" placeholder="Points" name="points">
matAutosizeMinRows="2" matAutosizeMaxRows="5" placeholder="{{ 'content.points' | translate }}" name="points">
</textarea>
</mat-form-field>
<mat-checkbox [(ngModel)]="answer.correct" color="primary">Answer is {{answer.correct}}.</mat-checkbox>
<div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px">
<button (click)="dialogRef.close()" mat-button color="primary">
Leave
{{ 'room-page.abort' | translate }}
</button>
<button (click)="dialogRef.close('edit')" mat-raised-button color="primary">
Update
{{ 'room-page.update' | translate }}
</button>
</div>
</div>
......@@ -100,7 +100,20 @@
"contents": "Fragen",
"click-here": "Klicken Sie auf einen Inhalt, um diesen zu editieren",
"submitted": "Frage erstellt. Bereit für die Erstellung neuer Fragen.",
"no-empty": "Keine leeren Felder erlaubt. Bitte überprüfen sie Thema und Inhalt."
"no-empty": "Keine leeren Felder erlaubt. Bitte überprüfen sie Thema und Inhalt.",
"no-empty2": "Keine leeren Felder erlaubt.",
"only-one": "Im Single-Choice-Modus ist nur eine Antwort erlaubt.",
"same-answer": "Zweimal die selbe Antwort ist nicht erlaubt.",
"changes-made": "Änderungen gespeichert.",
"answer-deleted": "Antwort gelöscht.",
"answer-recovered": "Antwort wiederhergestellt.",
"only-one-true": "Im Single-Modus ist nur eine richtige Antwort erlaubt.",
"reset-all": "Alle Eingaben wurden zurückgesetzt.",
"need-answers": "Auswahlfragen brauchen Antworten. Bitte fügen Sie Antworten hinzu",
"select-one": "Im Single-Choice-Modus muss es eine richtige Antwort geben.",
"at-least-one": "Im Multiple-Choice-Modus muss es mindestens eine richtige Antwort geben.",
"undo": "Rückgängig",
"points": "Punkte"
},
"session": {
"session-name": "Name der Session",
......
......@@ -97,7 +97,20 @@
"contents": "Contents",
"click-here": "Click on a content to edit it",
"submitted": "Content submitted. Ready for creation of new content.",
"no-empty": "No empty fields allowed. Please check subject and body."
"no-empty": "No empty fields allowed. Please check subject and body.",
"no-empty2": "No empty filed allowed.",
"only-one": "In single choice mode is only 1 true answer allowed.",
"same-answer": "Same answer label is not allowed.",
"changes-made": "Changes are made.",
"answer-deleted": "Answer deleted.",
"answer-recovered": "Answer recovered.",
"only-one-true": "In single mode is only 1 true answer allowed.",
"reset-all": "Reseted all inputs",
"need-answers": "Choice content needs answers. Please add some answers.",
"select-one": "In single choice mode you have to select 1 true answer.",
"at-least-one": "In multiple choice mode you have to select at least 1 true answer.",
"undo": "Undo",
"points": "Points"
},
"session": {
"session-name": "Session name",
......
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