From 4199200300431c8433af90c989ac8bc6c5a987e8 Mon Sep 17 00:00:00 2001 From: Ruben Young On <r.d.youngon@student.tudelft.nl> Date: Sun, 19 May 2019 14:14:32 +0200 Subject: [PATCH] Deleting a feedback option will throw an error if it is associated with an mc_option in a finalized exam --- zesje/api/feedback.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/zesje/api/feedback.py b/zesje/api/feedback.py index f81ef406..0ed472b1 100644 --- a/zesje/api/feedback.py +++ b/zesje/api/feedback.py @@ -141,6 +141,12 @@ class Feedback(Resource): # Delete mc_options associated with this feedback option if fb.mc_option: + + # Check if the exam with this feedback 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