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

modgrade form element has messed up value processing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 2.7.3
    • 2.7.2
    • Gradebook
    • MOODLE_27_STABLE
    • MOODLE_27_STABLE
    • 47752-28
    • Hide
      1. Log in as a teacher
      2. Turn on editing in a course
      3. Start adding a forum with the following details:
        • Name: ' ' (without the quotes)
        • Desc: what ever
        • Ratings > Aggregate type: Average of ratings
      4. Click save and display
      5. Check you get taken back to the forum and that there is not PHP code warning on the page about htmlspecialchars
      6. Check that the scale:scale and scale:maximum points fields are disabled.
      7. Change Scale to "Scale"
      8. Check that only maximum points is disabled now.
      9. Change Scale to "Point"
      10. Check that only scale:scale is disabled now.
      11. Change Aggregate type to "No ratings"
      12. Check that all other modgrade fields are disabled.
      13. Create a forum to make sure it still works.
      14. Run behat tests (or just confirm ci did it)
      Show
      Log in as a teacher Turn on editing in a course Start adding a forum with the following details: Name: ' ' (without the quotes) Desc: what ever Ratings > Aggregate type: Average of ratings Click save and display Check you get taken back to the forum and that there is not PHP code warning on the page about htmlspecialchars Check that the scale:scale and scale:maximum points fields are disabled. Change Scale to "Scale" Check that only maximum points is disabled now. Change Scale to "Point" Check that only scale:scale is disabled now. Change Aggregate type to "No ratings" Check that all other modgrade fields are disabled. Create a forum to make sure it still works. Run behat tests (or just confirm ci did it)

      This was first detected when testing MDL-47684 where validation was introduced into moodleform_mod and the value for a modgrade form element was processed by updateValue and came from _submitValues rather than _defaultValues.

      The problem comes because:

      • In _defaultValues an int is used and is mapped to either a scale (negative value) or point (positive value)
      • In _submitValues as the form element was an array of elements the value for a submit form is an array.

      I suspect the design of the modgrade component here is intrinsically wrong in that the modgrade element is based on a group and has no actual value.
      In the event a form is submitted the updateValue event is called for each individual element in the modgrade group as well as the modgrade (group) element itself.
      A bit of debugging shows that the updateValue is called first for the modgrade element, and then for the individual elements that make it up eg:

      1. scale
      2. scale[modgrade_type]
      3. scale[modgrade_scale]

      I would suspect that because of this ordering the setting of values logic in modgrade would be undone in the situation of a form submission.
      It is also the root of the problem detected in MDL-47684

            samhemelryk Sam Hemelryk
            samhemelryk Sam Hemelryk
            Andrew Lyons Andrew Lyons
            Dan Poltawski Dan Poltawski
            John Okely John Okely
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.