Skip to content

Add questionnaire reset functionality#1532

Open
reppuli92 wants to merge 1 commit into
apluslms:masterfrom
reppuli92:master
Open

Add questionnaire reset functionality#1532
reppuli92 wants to merge 1 commit into
apluslms:masterfrom
reppuli92:master

Conversation

@reppuli92

@reppuli92 reppuli92 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Description

What?

Make questionnaire exercises reset and not show model answer when they are edited or when the course language is changed

Why?

This is done so that the correct version of a questionnaire is always shown to students

How?

A-plus checks an exercise version hash from mooc-grader (separate PR on mooc-grader) and compares it to the latest submission's hash. The page's language is compared as well to the submission's, and if either mismatch, the form is reset.

Fixes #494

Testing

Remember to add or update unit tests for new features and changes.

What type of test did you run?

  • Accessibility test using the WAVE extension.
  • Django unit tests.
  • Playwright tests.
  • Other test. (Add a description below)
  • Manual testing.

I tested that the reset functionality works in the UI by editing aplus-manual and reloading a-plus while keeping old submission data cached. I also tested the language change.

Did you test the changes in

  • Chrome
  • Firefox
  • This pull request cannot be tested in the browser.

Think of what is affected by these changes and could become broken

Translation

Programming style

  • Did you follow our style guides?
  • Did you use Python type hinting in all functions that you added or edited? (type hints for function parameters and return values)

Have you updated the README or other relevant documentation?

  • documents inside the doc directory.
  • README.md.
  • Aplus Manual.
  • Other documentation (mention below which documentation).

Is it Done?

  • Reviewer has finished the code review
  • After the review, the developer has made changes accordingly
  • Customer/Teacher has accepted the implementation of the feature

Clean up your git commit history before submitting the pull request!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds “questionnaire reset” behavior by tracking an exercise content-version hash (from mooc-grader) and the submission language, and reloading a fresh exercise page when the latest submission no longer matches the current exercise version or UI language.

Changes:

  • Persist an exercise_version hash from the exercise service into ExercisePage and ExerciseCache.
  • Stamp the current exercise_version into new submissions’ metadata for later compatibility checks.
  • In the exercise view, compare the latest submission’s stored version/language against the current ones and reset (reload blank exercise) on mismatch.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
exercise/views.py Adds reset logic when current exercise version/language differs from the latest submission’s metadata.
exercise/submission_models.py Stamps exercise_version into submission metadata at submission creation time.
exercise/protocol/exercise_page.py Introduces exercise_version field on ExercisePage.
exercise/protocol/aplus.py Parses x-aplus-exercise-version from the remote page meta into ExercisePage.
exercise/cache/exercise.py Stores exercise_version in the cached exercise page data and refreshes legacy cache entries.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread exercise/submission_models.py Outdated
Comment thread exercise/views.py Outdated
Comment thread exercise/submission_models.py Outdated
@reppuli92 reppuli92 deleted the branch apluslms:master July 6, 2026 10:39
@reppuli92 reppuli92 closed this Jul 6, 2026
@reppuli92 reppuli92 deleted the master branch July 6, 2026 10:39
@github-project-automation github-project-automation Bot moved this from Todo to Done in A+ sprints Jul 6, 2026
@reppuli92 reppuli92 restored the master branch July 6, 2026 10:40
@reppuli92 reppuli92 reopened this Jul 6, 2026
@reppuli92

Copy link
Copy Markdown
Contributor Author

Sorry for the confusion :) tried to make things look nice on my repo but ended up breaking things

@reppuli92 reppuli92 moved this from Done to Todo in A+ sprints Jul 6, 2026
@ihalaij1 ihalaij1 force-pushed the master branch 2 times, most recently from f8f12ef to 8c19aa6 Compare July 10, 2026 12:14
@ihalaij1 ihalaij1 requested a review from Copilot July 10, 2026 12:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread exercise/cache/exercise.py Outdated
Comment thread exercise/cache/exercise.py
@ihalaij1 ihalaij1 moved this from Todo to Under review in A+ sprints Jul 10, 2026
@ihalaij1 ihalaij1 requested a review from murhum1 July 10, 2026 12:55

@ihalaij1 ihalaij1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice!

I tested this a bunch, found and fixed some bugs with the help of AI, but I would still want @murhum1 to go through this PR to increase the confidence that this doesn't cause any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Under review

Development

Successfully merging this pull request may close these issues.

Add a "Reset" button to questionnaires

4 participants