Skip to content
Snippets Groups Projects
Commit 8771b1f9 authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

better error messages when creating feedback

parent 8aae4459
No related branches found
No related tags found
1 merge request!128Merge improve testing
...@@ -141,14 +141,17 @@ async function submitFeedback ({state}: BareActionContext<SubmissionNotesState, ...@@ -141,14 +141,17 @@ async function submitFeedback ({state}: BareActionContext<SubmissionNotesState,
isFinal: isFinal, isFinal: isFinal,
ofSubmission: state.submission.pk 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) { if (state.origFeedback.score === undefined && state.updatedFeedback.score === undefined) {
throw new Error('You need to give a score.') throw new Error('You need to give a score.')
} else if (state.updatedFeedback.score !== undefined) { } else {
feedback.score = state.updatedFeedback.score 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() await SubmissionNotes.deleteComments()
if (!state.hasOrigFeedback) { if (!state.hasOrigFeedback) {
return api.submitFeedbackForAssignment({feedback}) return api.submitFeedbackForAssignment({feedback})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment