From 9da2e604ca5aa9cbdf186bf9b3f3d14162bc2149 Mon Sep 17 00:00:00 2001 From: Ruben Young On <r.d.youngon@student.tudelft.nl> Date: Sun, 19 May 2019 14:39:39 +0200 Subject: [PATCH] Moved check to see if exam is finalized --- zesje/api/feedback.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/zesje/api/feedback.py b/zesje/api/feedback.py index 01c2e98e..630ac52a 100644 --- a/zesje/api/feedback.py +++ b/zesje/api/feedback.py @@ -125,6 +125,9 @@ class Feedback(Resource): problem = fb.problem if problem.id != problem_id: return dict(status=409, message="Feedback does not match the problem."), 409 + if problem.exam.finalized: + return dict(status=401, message='Cannot delete feedback option' + + ' attached to a multiple choice option in a finalized exam.'), 401 db.session.delete(fb) @@ -141,10 +144,6 @@ class Feedback(Resource): # Delete mc_options associated with this feedback option if fb.mc_option: - if fb.problem.exam.finalized: - return dict(status=401, message='Cannot delete feedback option' - + ' attached to a multiple choice option in a finalized exam.'), 401 - db.session.delete(fb.mc_option) db.session.commit() -- GitLab