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

Drag&Drop zip file in course section uses a modal form with wrong field ids

XMLWordPrintable

    • 1
    • HQ 2024 Sprint I4.1 Moppies

      When a user drags and drops a zip file into a course section, the "Add an activity or resource" modal form does not work correctly If the user clicks on the radio element, everything works fine. However, if the user clicks on the radio label it selects the first radio no matter what. For example, clicking on the text "Add a SCORM package" (which is label for the third radio) selects "Unzip files and create a folder" option (which is the first one).

      This happens because all the radio elements shares the same element id, instead of increasing one number on each element.

      Steps to reproduce:

      1. Login into the Moodle site as an administrator
      2. Create a course in «Custom sections» format
      3. Enter course
      4. Turn «Edit mode» on
      5. Drag&Drop a zip file on any section
      6. With «Add an activity or resource» modal, confirm
        1. Click on "Create file resource" label, near the radio button (clicking the radio button will work... the problem is only with the label).

      Expected behaviour

      The radio near the label is selected

       

      Current behaviour

      The first radio button is always selected.

       

      Note from the reporter

      Inspect code, all input share same id fileuploader_1 (as shown in attached file «Dnd_zip_course_section_same_input_for_id.png»)

       

      A (good ?) workaround is to edit course/format/templates/fileuploader.mustache where labelid seem to be different from the json example (always fileuploader_X) and add _{{value}} where labelid is used («id» and «for») :

       

      <div id="dndupload_handlers{{uploadid}}">
      {{#handlers}}
          <input
              type="radio"
              name="handler"
              value="{{value}}"
              id="{{labelid}}_{{value}}"
              {{#selected}} checked="checked" {{/selected}}
          />
          <label for="{{labelid}}_{{value}}">{{message}}</label>
          <br/>
      {{/handlers}}
      </div>
      

        1. (1) 3 Passed -- (Main)MDL-83661.png
          63 kB
          Kim Jared Lucas
        2. (1) 4 Passed -- (Main)MDL-83661.png
          54 kB
          Kim Jared Lucas
        3. (1) 5 Passed -- (Main)MDL-83661.png
          56 kB
          Kim Jared Lucas
        4. (1) 6 Passed -- (Main)MDL-83661.png
          51 kB
          Kim Jared Lucas
        5. (1) 7 Passed -- (Main)MDL-83661.png
          49 kB
          Kim Jared Lucas
        6. Dnd_zip_course_section_same_input_for_id.png
          95 kB
          Laurent Wafflard
        7. Screencast from 08-11-24 10_39_00.gif
          61 kB
          Ferran Recio

            tusefomal Ferran Recio
            lwafflard Laurent Wafflard
            Carlos Escobedo Carlos Escobedo
            Amaia Anabitarte Amaia Anabitarte
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 hours, 29 minutes
                2h 29m

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