From 3215185b5b5552a5ae3b78d1e7823c3bc8614fda Mon Sep 17 00:00:00 2001 From: Ruben Young On <r.d.youngon@student.tudelft.nl> Date: Wed, 22 May 2019 20:28:25 +0200 Subject: [PATCH] Changed pregrade function --- zesje/pregrader.py | 20 ++++++++++++++------ zesje/scans.py | 3 +-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/zesje/pregrader.py b/zesje/pregrader.py index 2339d325..a70fbf14 100644 --- a/zesje/pregrader.py +++ b/zesje/pregrader.py @@ -9,7 +9,7 @@ # coupled feedback cannot be deleted -from zesje.database import db, Exam, Submission +from zesje.database import db, Exam, Submission, Solution def pregrade(exam_token, image): @@ -28,24 +28,32 @@ def pregrade(exam_token, image): def add_feedback_to_solution(page_img, barcode): + """ + Adds the multiple choice options that are identified as marked as a feedback option to a solution + + Params + ------ + page_img: image of the page + barcode: data from the barcode on the page + """ 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() - problems = exam.problems - problems_on_page = list(filter(lambda p: p.widget.page == barcode.page, problems)) + problems_on_page = [p for p in exam.problems if p.widget.page == barcode.page] 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 + sol = [s for s in sub.solutions if s.submission_id == sub.id] + # check if box is filled if box_is_filled(box, page_img): - sub.feedback = mc_option.feedback + sol.feedback = mc_option.feedback db.session.commit() -def box_is_filled(box, image): +def box_is_filled(box, page_img): pass diff --git a/zesje/scans.py b/zesje/scans.py index 580e4653..cb44b6dd 100644 --- a/zesje/scans.py +++ b/zesje/scans.py @@ -241,8 +241,7 @@ def process_page(image_data, exam_config, output_dir=None, strict=False): return True, "Testing, image not saved and database not updated." update_database(image_path, barcode) - - add_feedback_to_solution() + add_feedback_to_solution(image_array, barcode) if barcode.page == 0: description = guess_student( -- GitLab