Skip to content
Snippets Groups Projects
Commit 8d7a626a authored by Ruben Young On's avatar Ruben Young On
Browse files

Rewritten doc, update_database returns submission and exam, pregrading now...

Rewritten doc, update_database returns submission and exam, pregrading now checks for specific submission
parent f9c20767
No related branches found
No related tags found
1 merge request!17Add pregrading
Pipeline #17944 passed
......@@ -5,16 +5,20 @@ from zesje.database import db, Solution
from zesje.images import guess_dpi, get_box, fix_corner_markers
def add_feedback_to_solution(exam, page, page_img, corner_keypoints):
def add_feedback_to_solution(sub, exam, page, page_img, corner_keypoints):
"""
Adds the multiple choice options that are identified as marked as a feedback option to a solution
Params
Parameters
------
exam: the current exam
page_img: image of the page
barcode: data from the barcode on the page
corner_keypoints: locations of the corner keypoints
sub : Submission
the current submission
exam : Exam
the current exam
page_img : Image
image of the page
corner_keypoints : array
locations of the corner keypoints as (x, y) tuples
"""
problems_on_page = [problem for problem in exam.problems if problem.widget.page == page]
......@@ -25,7 +29,7 @@ def add_feedback_to_solution(exam, page, page_img, corner_keypoints):
top_left_point = sorted(fixed_corner_keypoints, key=lambda x: x[0])[0] if fixed_corner_keypoints else []
for problem in problems_on_page:
sol = Solution.query.filter(Solution.problem_id == problem.id).one_or_none()
sol = Solution.query.filter(Solution.problem_id == problem.id, Solution.submission_id == sub.id).one_or_none()
for mc_option in problem.mc_options:
box = (mc_option.x, mc_option.y)
......
......@@ -338,8 +338,8 @@ def process_page(image_data, exam_config, output_dir=None, strict=False):
else:
return True, "Testing, image not saved and database not updated."
exam = update_database(image_path, barcode)
add_feedback_to_solution(exam, barcode.page, image_array, corner_keypoints)
sub, exam = update_database(image_path, barcode)
add_feedback_to_solution(sub, exam, barcode.page, image_array, corner_keypoints)
if barcode.page == 0:
description = guess_student(
......@@ -387,8 +387,12 @@ def update_database(image_path, barcode):
Returns
-------
signature_validated : bool
If the corresponding submission has a validated signature.
sub, exam where
sub : Submission
the current submission
exam : Exam
the current exam
"""
exam = Exam.query.filter(Exam.token == barcode.token).first()
if exam is None:
......@@ -408,7 +412,7 @@ def update_database(image_path, barcode):
db.session.commit()
return exam
return sub, exam
def decode_barcode(image, exam_config):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment