From 5c69edf059bd8db82f891a5e62c2133f2d0bf914 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Tue, 20 Nov 2018 15:51:21 +0100
Subject: [PATCH] Fix content-choice answer sending

---
 .../content-choice-participant.component.ts          | 12 +++++++++---
 src/app/models/answer-choice.ts                      |  4 ++++
 src/app/services/http/content-answer.service.ts      |  2 +-
 3 files changed, 14 insertions(+), 4 deletions(-)

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 c2668f661..2c10e85ca 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 fd5e7ea04..9c3bf8e44 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 ecb5d815f..389f9a916 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'))
     );
-- 
GitLab