Issue 7854#7993
Merged
Merged
Conversation
…divisions assigned to it before uploading scans
Collaborator
Coverage Report for CI Build 27313877833Coverage increased (+0.001%) to 90.304%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
david-yz-liu
reviewed
Jun 9, 2026
| const selectedExamTemplate = examTemplates.find(template => String(template.exam_template_id) === dropdown.value); | ||
|
|
||
| if (selectedExamTemplate && selectedExamTemplate.template_division_count === 0) { | ||
| const proceed = confirm('The selected exam template has no template divisions assigned to it. Are you sure you would like to proceed?'); |
Collaborator
There was a problem hiding this comment.
This string should be internationalized
| @@ -1,12 +1,20 @@ | |||
| <%= form_with url: split_course_assignment_exam_templates_path(@current_course), | |||
| <% exam_template_data = @exam_templates.map{ | |||
Collaborator
There was a problem hiding this comment.
Okay so overall this approach works but is not ideal. Instead you can define a variable within view_logs.js.erb itself, with value equal to exam_template_data:
let template_division_counts = <%= exam_template_data.to_json.html_safe %>;Here, template_division_counts is a Javascript variable, and exam_template_data is a Ruby variable that's being rendered as JSON into the Javascript code. This variable can then be passed directly into init_upload_scans_form
| ### 🚨 Breaking changes | ||
|
|
||
| ### ✨ New features and improvements | ||
| - Added a confirm dialog to the Upload Scans form that appears when no template divisions are assigned to the selected exam template. |
Collaborator
There was a problem hiding this comment.
Add the PR number here
david-yz-liu
approved these changes
Jun 11, 2026
david-yz-liu
left a comment
Collaborator
There was a problem hiding this comment.
Nice work, @danielrafailov1!
david-yz-liu
pushed a commit
to MarkUsProject/Wiki
that referenced
this pull request
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
(Describe your changes here. Also describe the motivation for your changes: what problem do they solve, or how do they improve the application or codebase? If this pull request fixes an open issue, use a keyword to link this pull request to the issue.)
The issue: If no template divisions are assigned to an exam template and then the user goes to upload a scan with that same exam template, there is no easy way for them to go back and add template divisions afterwords.
The fix: As requested, I added a confirmation dialog on submit of the Upload Scans form. This dialog will warn the user when no template divisions are assigned to the selected exam template and ask them if it's okay to proceed.
The implementation: In _split_form.html.erb I wrote embedded ruby code to build an array of { exam_template_id, template_division_count } using the @exam_templates variable which was initialized in exam_templates_controller#view_logs. Then I embedded this array into the form via the data-exam-templates HTML attribute.
When view_logs.js.erb gets returned to the browser after the AJAX request, the JavaScript inside this file gets executed to first build and inject the Upload Scans into #editing_pane_menu, and then call the new function I defined called init_upload_scans_form().
The init_upload_scans_form() was defined in _boot.js.erb. This function reads template division counts from the form's data-eexam-templates attribute, and listens for the form's submit event in the capture phase. If the selected template has template_division_count === 0 then we show the confirm dialog. On cancel, we prevent submission so that the user can configure template divisions first.
Tests: Added controller specs for #view_logs (JS format, with render_views) to verify that the form embeds template division data and calls init_upload_scans_form().
Documentation: Updated the relevant wiki page to mention the confirmation dialog when uploading without template divisions and further emphasize the need for them.
closes #7854
Screenshots of your changes (if applicable)
Associated documentation repository pull request (if applicable)
https://github.com/MarkUsProject/Wiki/pull/265Type of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]into a[x]in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
(Include any questions or comments you have regarding your changes.)