Commit 3c5bad24 authored by Adrià Labay's avatar Adrià Labay
Browse files

show all pages in single paged exams

parent 248562f2
......@@ -36,15 +36,26 @@ def get(exam_id, problem_id, submission_id, full_page=False):
if (sub := Submission.query.get(submission_id)) is None:
abort(404, 'Submission does not exist.')
pages = None
if exam.layout == ExamLayout.unstructured:
full_page = True
page_number = problem.widget.page
# get the pages
pages = Page.query.filter(Page.copy_id == Copy.id,
Copy.submission == sub,
Page.number == page_number).all()
if max(problem.widget.page for problem in exam.problems) == 0:
# single paged exam, show all pages from all copies
pages = Page.query.filter(Page.copy_id == Copy.id,
Copy.submission == sub)\
.order_by(Page.number, Copy.number)\
.all()
if not pages:
page_number = problem.widget.page
# get the pages
pages = Page.query.filter(Page.copy_id == Copy.id,
Copy.submission == sub,
Page.number == page_number)\
.order_by(Copy.number)\
.all()
if len(pages) == 0:
abort(404, f'Page #{page_number} is missing for all copies of submission #{submission_id}.')
......
......@@ -19,11 +19,6 @@ def process_page(image, page_info, file_info, exam_config, output_directory):
exam = Exam.query.filter(Exam.token == exam_config.token).one()
if max(problem.widget.page for problem in exam.problems) == 0 and any('.pdf' in info for info in file_info):
# single paged exam, each page of the pdf is treated as a different copy instead of a different page
# this ensures that in the frontend the images are concatenated vertically
page, copy = copy - 1, page + 1
copy = retrieve_copy(exam, student_id, copy)
image_dir = Path(output_directory) / 'submissions' / f'{copy.number}'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment