From e78b2cbe89bfffe0163f5899ace2f08b97bb69ef Mon Sep 17 00:00:00 2001 From: Ruben Young On <r.d.youngon@student.tudelft.nl> Date: Wed, 22 May 2019 20:14:20 +0200 Subject: [PATCH] Added pregrade function --- zesje/pregrader.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/zesje/pregrader.py b/zesje/pregrader.py index 0100cd1f..5fd216f6 100644 --- a/zesje/pregrader.py +++ b/zesje/pregrader.py @@ -27,20 +27,20 @@ def pregrade(exam_token, image): pass -def add_feedback_to_solution(image, barcode): +def add_feedback_to_solution(page_img, barcode): exam = Exam.query.filter(Exam.token == barcode.token).first() - sub = Submission.query.filter(Submission.copy_number == barcode.copy, Submission.exam_id == exam.id).one_or_none() - for solution in sub.solutions: - problem = solution.problem + problems = exam.problems + problems_on_page = list(filter(lambda p: p.widget.page == barcode.page, problems)) + for problem in problems_on_page: for mc_option in problem.mc_options: box = (mc_option.x, mc_option.y) # check width and so forth - if box_is_filled(box, image): - solution.feedback = mc_option.feedback + if box_is_filled(box, page_img): + problem.solution.feedback = mc_option.feedback db.session.commit() -- GitLab