Skip to content

Issue 7854#7993

Merged
david-yz-liu merged 10 commits into
MarkUsProject:masterfrom
danielrafailov1:issue-7854
Jun 11, 2026
Merged

Issue 7854#7993
david-yz-liu merged 10 commits into
MarkUsProject:masterfrom
danielrafailov1:issue-7854

Conversation

@danielrafailov1

@danielrafailov1 danielrafailov1 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

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) Screenshot 2026-06-08 at 4 59 51 PM
Associated documentation repository pull request (if applicable) https://github.com/MarkUsProject/Wiki/pull/265

Type of Change

(Write an X or a brief description next to the type or types that best describe your changes.)

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality) X
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

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:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

(Include any questions or comments you have regarding your changes.)

@coveralls

coveralls commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 27313877833

Coverage increased (+0.001%) to 90.304%

Details

  • Coverage increased (+0.001%) from the base build.
  • Patch coverage: 8 of 8 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 50172
Covered Lines: 46277
Line Coverage: 92.24%
Relevant Branches: 2243
Covered Branches: 1056
Branch Coverage: 47.08%
Branches in Coverage %: Yes
Coverage Strength: 126.25 hits per line

💛 - Coveralls

Comment thread app/views/exam_templates/_boot.js.erb Outdated
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?');

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread Changelog.md Outdated
### 🚨 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the PR number here

@david-yz-liu david-yz-liu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, @danielrafailov1!

@david-yz-liu david-yz-liu merged commit b31174d into MarkUsProject:master Jun 11, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need an error message or warning when uploading scans with no template divisions

3 participants