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

Fix content-choice answer sending

parent 150c0a57
No related merge requests found
......@@ -50,6 +50,8 @@ export class ContentChoiceParticipantComponent implements OnInit {
}
}
// TODO: check answers
submitAnswer(): void {
let selectedAnswers: number[] = [];
if (this.content.multiple) {
......@@ -67,6 +69,8 @@ export class ContentChoiceParticipantComponent implements OnInit {
}
}
// TODO: i18n
if (!this.content.multiple && selectedAnswers.length !== 1) {
this.notificationService.show('In single choice mode is only 1 selection allowed');
this.isAnswerSent = false;
......@@ -79,11 +83,13 @@ export class ContentChoiceParticipantComponent implements OnInit {
}
this.isAnswerSent = true;
this.answerService.addAnswerChoice({
id: '',
revision: '',
id: null,
revision: null,
contentId: this.content.id,
round: 1,
selectedChoiceIndexes: []
selectedChoiceIndexes: [],
creationTimestamp: null,
format: ContentType.CHOICE
} as AnswerChoice).subscribe();
// TODO: Set isAnswerSent
}
......
import { ContentType } from './content-type.enum';
export class AnswerChoice {
id: string;
revision: string;
contentId: string;
round: number;
selectedChoiceIndexes: number[];
creationTimestamp: Date;
format: ContentType;
}
......@@ -42,7 +42,7 @@ export class ContentAnswerService extends BaseHttpService {
}
addAnswerChoice(answerChoice: AnswerChoice): Observable<AnswerChoice> {
const url = this.apiUrl.base + this.apiUrl.answer + this.apiUrl.choice + '/';
const url = this.apiUrl.base + this.apiUrl.answer + '/';
return this.http.post<AnswerChoice>(url, answerChoice, httpOptions).pipe(
catchError(this.handleError<AnswerChoice>('addAnswerChoice'))
);
......
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