Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-74516

Create a quiz with passing grade completion causing error

    XMLWordPrintable

Details

    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MOODLE_311_STABLE, MOODLE_400_STABLE
    • MDL-74516_311
    • MDL-74516_400
    • Hide

      Requirements

      1. needs to be tested in 400 and master. In 311 the workshop activity does not have the "grade to pass" completion condition.
      2. needs a small change in code to be able to test a combination that, currently is not working (and is being fixed @ MDL-69690 ).

      Test workshop edit form with submission grade to pass completion rule.

      1. As admin.
      2. In any course, enable edition
      3. Add a new activity or resource and select "Workshop"
      4. Fill the Workshop name. Press "Save and display".
      5. Verify the form IS saved and you are redirected to the "Setup phase" page.
      6. Edit the activity settings again.
      7. Verify that the form shows "0.00" in both the "Submission grade to pass" and "Assessment grade to pass.
      8. In the form, expand the "Activity completion" fieldset.
      9. If you get a message about "completion options locked", just click on the "Unlock completion options" button. The page will reload and the lock message is gone.
      10. In "Completion tracking" select "Show activity as complete when conditions are met"
      11. Verify that some new fields appear in the form.
      12. In "Require grade", select "Submission" and tick the "Student must receive a passing grade to complete this activity".
      13. Press "Save and display".
      14. Verify that the form is NOT saved and you see the message "This activity does not have a valid grade to pass set. It may be set in the Grade section of the activity settings." in the completion field.
      15. Set the "Submission grade to pass" to empty (delete the 0.00) and press "Save and display".
      16. Verify that the form is NOT saved and you see the message "This activity does not have a valid grade to pass set. It may be set in the Grade section of the activity settings." in the completion field.
      17. Set the "Submission grade to pass" to 81 and press "Save and display".
      18. Verify that the form is NOT saved and you see the message "The grade to pass can not be greater than the maximum possible grade 80" in the grade to pass field.
      19. Set the "Submission grade to pass" to "hello" and press "Save and display".
      20. Verify that the form is NOT saved and you see the message "You must enter a number here." in the grade to pass field.
      21. Set the "Submission grade to pass" to "12,34" (using the comma!) and press "Save and display".
      22. Verify that the form is NOT saved and you see the message "You must enter a number here." in the grade to pass field.
      23. Set the "Submission grade to pass" to 50 and press "Save and display".
      24. Verify the form IS saved and you are redirected to the "Setup phase" page.

      Test workshop edit form with assessment grade to pass completion rule.

      1. To be able to test this, we need to modify the course/moodleform_mod.php file. Edit it with your favorite editor and change this line (around line 471), adding an exclamation mark before the empty:

        if (empty($data[$assessedfieldname]) && empty($data[$gradefieldname])) {
         
        to
         
        if (!empty($data[$assessedfieldname]) && empty($data[$gradefieldname])) {
        

      2. Repeat all the steps listed in the previous testing section, but always using the "assessment" fields instead of the "submission" ones (points #12, #15, #17, #19, #21 & #23).
      3. Verify that all the errors continue being the same.

      Note 1: When in some steps, an error is shown near the "grade to pass" fields ("must enter a number", ... ) the completion field also will continue showing the "This activity does not have a valid grade to pass..." error. That's correct, just in the verification of the instructions we are testing that exact error is happening.

      Note 2: The other activities fixed by this issue are covered by the new behat scenario with examples added as part of the fix (with the quiz module), so no manual testing is needed for quiz or other activities. Only workshop needs the manual steps above.

      Show
      Requirements needs to be tested in 400 and master. In 311 the workshop activity does not have the "grade to pass" completion condition. needs a small change in code to be able to test a combination that, currently is not working (and is being fixed @ MDL-69690 ). Test workshop edit form with submission grade to pass completion rule. As admin. In any course, enable edition Add a new activity or resource and select "Workshop" Fill the Workshop name. Press "Save and display". Verify the form IS saved and you are redirected to the "Setup phase" page. Edit the activity settings again. Verify that the form shows "0.00" in both the "Submission grade to pass" and "Assessment grade to pass. In the form, expand the "Activity completion" fieldset. If you get a message about "completion options locked", just click on the "Unlock completion options" button. The page will reload and the lock message is gone. In "Completion tracking" select "Show activity as complete when conditions are met" Verify that some new fields appear in the form. In "Require grade", select "Submission" and tick the "Student must receive a passing grade to complete this activity". Press "Save and display". Verify that the form is NOT saved and you see the message "This activity does not have a valid grade to pass set. It may be set in the Grade section of the activity settings." in the completion field. Set the "Submission grade to pass" to empty (delete the 0.00) and press "Save and display". Verify that the form is NOT saved and you see the message "This activity does not have a valid grade to pass set. It may be set in the Grade section of the activity settings." in the completion field. Set the "Submission grade to pass" to 81 and press "Save and display". Verify that the form is NOT saved and you see the message "The grade to pass can not be greater than the maximum possible grade 80" in the grade to pass field. Set the "Submission grade to pass" to "hello" and press "Save and display". Verify that the form is NOT saved and you see the message "You must enter a number here." in the grade to pass field. Set the "Submission grade to pass" to "12,34" (using the comma!) and press "Save and display". Verify that the form is NOT saved and you see the message "You must enter a number here." in the grade to pass field. Set the "Submission grade to pass" to 50 and press "Save and display". Verify the form IS saved and you are redirected to the "Setup phase" page. Test workshop edit form with assessment grade to pass completion rule. To be able to test this, we need to modify the course/moodleform_mod.php file. Edit it with your favorite editor and change this line (around line 471), adding an exclamation mark before the empty: if (empty($data[$assessedfieldname]) && empty($data[$gradefieldname])) {   to   if (!empty($data[$assessedfieldname]) && empty($data[$gradefieldname])) { Repeat all the steps listed in the previous testing section, but always using the "assessment" fields instead of the "submission" ones (points #12, #15, #17, #19, #21 & #23). Verify that all the errors continue being the same. Note 1: When in some steps, an error is shown near the "grade to pass" fields ("must enter a number", ... ) the completion field also will continue showing the "This activity does not have a valid grade to pass..." error. That's correct, just in the verification of the instructions we are testing that exact error is happening. Note 2: The other activities fixed by this issue are covered by the new behat scenario with examples added as part of the fix (with the quiz module), so no manual testing is needed for quiz or other activities. Only workshop needs the manual steps above.

    Description

       

      When I try to create a quiz with those manual completion condition:

      • Student must view this activity to complete it
      • Student must receive a grade to complete this activity
      • Student must receive a passing grade to complete this activity

      And Grade to pass is set to empty, it will bypass the validation of the form.

      When submit the form, the error will be thrown:

      Exception - Argument 1 passed to grade_floatval() must be of the type float or null, string given, called in [dirroot]\course\moodleform_mod.php on line 496

      It doesn't happen if the grade to pass is 0.

      Attachments

        1. 14&16_MDL-74516_master.png
          14&16_MDL-74516_master.png
          13 kB
        2. 14&16_MDL-74516_v400.png
          14&16_MDL-74516_v400.png
          13 kB
        3. 18_MDL-74516_master.png
          18_MDL-74516_master.png
          12 kB
        4. 18_MDL-74516_v400.png
          18_MDL-74516_v400.png
          8 kB
        5. 20_MDL-74516_master.png
          20_MDL-74516_master.png
          6 kB
        6. 20_MDL-74516_v400.png
          20_MDL-74516_v400.png
          6 kB
        7. 22_MDL-74516_master.png
          22_MDL-74516_master.png
          6 kB
        8. 22_MDL-74516_v400.png
          22_MDL-74516_v400.png
          6 kB
        9. 23_MDL-74516_master.png
          23_MDL-74516_master.png
          8 kB
        10. 23_MDL-74516_v400.png
          23_MDL-74516_v400.png
          4 kB

        Issue Links

          Activity

            People

              stronk7 Eloy Lafuente (stronk7)
              vuvanhieu143 Hieu Vu
              Mathew May Mathew May
              Jun Pataleta Jun Pataleta
              John Edward Pedregosa John Edward Pedregosa
              Amaia Anabitarte, Bas Brands, Carlos Escobedo, Laurent David, Raquel Ortega, Sabina Abellan, Sara Arjona (@sarjona), Amaia Anabitarte, Bas Brands, Carlos Escobedo, Laurent David, Raquel Ortega, Sabina Abellan, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                11/Jul/22

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 3 days, 1 hour, 20 minutes
                  3d 1h 20m