openedx / frontend-lib-content-components

[Moved to openedx/frontend-app-course-authoring] A library of high-level components for content handling (viewing, editing, etc. of HTML, video, problems, etc.), to be shared by multiple MFEs.
GNU Affero General Public License v3.0
11 stars 33 forks source link

fix: parser not saving unlimited attempts #483

Closed KristinAoki closed 5 months ago

KristinAoki commented 5 months ago

Description

This PR fixes problems where the maximum attempts is null by default. Previously, when a course had unlimited attempts by default and a user created a new problem, the unlimited option was not checked so the scoring card said, "1 point • 0 attempts". Now for new problems the unlimited option is checked and the card reads, "1 point • Unlimited attempts". This PR allows resolved the issue when changing a problems number of attempts from unlimited to a number and back to unlimited, the revert back to unlimited was not saved. This is because the default value of settings is not saved to problems so that it is able to automatically update if the default settings are changed. However, not saving the unlimited value did not revert the problem back to use the default maximum attempts. Now the unlimited value is saved even when it is the default value to reset the problem. The backend value is null so it does not inhibit the updating of the problem dynamically to match the advanced setting changes.

Supporting information

Github Issue #480

Testing

  1. Open a course
  2. Navigate to the Advanced settings page and confirm that "Maximum attempts" is set to null
  3. Navigate to a unit page
  4. Add a new simple problem
  5. Check that the scoring card reads, "1 point • Unlimited attempts"
  6. Click on the scoring card
  7. Confirm that the unlimited checkbox is checked
  8. Uncheck the box and add a new number of attempts
  9. Click "Save"
  10. Click "Edit" for the problem you just saved
  11. Click on the scoring card
  12. Check the unlimited checkbox
  13. Click "Save"
  14. Should not mention the number of attempts in the problem preview
  15. Navigate to the Advanced settings page
  16. Set "Maximum attempts" is set to 5
  17. Navigate back to unit page
  18. Confirm that problem preview shows the text "You have used 0 of 5 attempts"