From 8771b1f9baef41aa2d62eabcd8124a1cd742417b Mon Sep 17 00:00:00 2001
From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de>
Date: Thu, 18 Oct 2018 14:38:06 +0200
Subject: [PATCH] better error messages when creating feedback

---
 frontend/src/store/modules/submission-notes.ts | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/frontend/src/store/modules/submission-notes.ts b/frontend/src/store/modules/submission-notes.ts
index 4dfd9d29..7d5ba093 100644
--- a/frontend/src/store/modules/submission-notes.ts
+++ b/frontend/src/store/modules/submission-notes.ts
@@ -141,14 +141,17 @@ async function submitFeedback ({state}: BareActionContext<SubmissionNotesState,
     isFinal: isFinal,
     ofSubmission: state.submission.pk
   }
-  if (Object.keys(state.updatedFeedback.feedbackLines || {}).length > 0) {
-    feedback.feedbackLines = state.updatedFeedback.feedbackLines
-  }
   if (state.origFeedback.score === undefined && state.updatedFeedback.score === undefined) {
     throw new Error('You need to give a score.')
-  } else if (state.updatedFeedback.score !== undefined) {
-    feedback.score = state.updatedFeedback.score
+  } else {
+    feedback.score = state.updatedFeedback.score || state.origFeedback.score || 0
+  }
+  if (Object.keys(state.updatedFeedback.feedbackLines || {}).length > 0) {
+    feedback.feedbackLines = state.updatedFeedback.feedbackLines
+  } else if (feedback.score! < SubmissionNotes.submissionType.fullScore!) {
+    throw new Error('You need to provide a reason for a reduced score.')
   }
+  // delete those comments that have been marked for deletion
   await SubmissionNotes.deleteComments()
   if (!state.hasOrigFeedback) {
     return api.submitFeedbackForAssignment({feedback})
-- 
GitLab