diff --git a/src/app/components/participant/content-choice-participant/content-choice-participant.component.ts b/src/app/components/participant/content-choice-participant/content-choice-participant.component.ts index c2668f6618f98b1b7088e6150f8fec285613af07..2c10e85ca6dee4cadfe67c363de8391b1845042d 100644 --- a/src/app/components/participant/content-choice-participant/content-choice-participant.component.ts +++ b/src/app/components/participant/content-choice-participant/content-choice-participant.component.ts @@ -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 } diff --git a/src/app/models/answer-choice.ts b/src/app/models/answer-choice.ts index fd5e7ea04d8302701b5dc421a4fca563d540fc09..9c3bf8e4484219da25c1816efbec7f9e51353c47 100644 --- a/src/app/models/answer-choice.ts +++ b/src/app/models/answer-choice.ts @@ -1,7 +1,11 @@ +import { ContentType } from './content-type.enum'; + export class AnswerChoice { id: string; revision: string; contentId: string; round: number; selectedChoiceIndexes: number[]; + creationTimestamp: Date; + format: ContentType; } diff --git a/src/app/services/http/content-answer.service.ts b/src/app/services/http/content-answer.service.ts index ecb5d815f68e4d8a780f647ff5b82c8f4a1245a5..389f9a9161ebe513128a656e2b9dac7ce32fa84a 100644 --- a/src/app/services/http/content-answer.service.ts +++ b/src/app/services/http/content-answer.service.ts @@ -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')) );