-
Bug
-
Resolution: Fixed
-
Minor
-
4.4.4, 4.5
-
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:
- Login into the Moodle site as an administrator
- Create a course in «Custom sections» format
- Enter course
- Turn «Edit mode» on
- Drag&Drop a zip file on any section
- With «Add an activity or resource» modal, confirm
- 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>
|