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

External tool js causes incorrect preconfigured tool to be selected on instance edit

XMLWordPrintable

    • MOODLE_401_STABLE, MOODLE_402_STABLE

      I noticed this when working on MDL-78597, where I'd been working on mod/lti's mod_form.

      There's a preconfigured tools select on the mod's edit form, which is a plain 1-dimensional select with options on page load. The selected option shows fine for a split second (or if you set a breakpoint in the early js) right up until the mod_form.js comes into play.

      That JS rearranges the select options, adding optgroups, so that we have 'site' and 'course' categories for tools. For some reason, the YUI code dealing with adding the nodes back into the select causes the select to show the incorrect selected option in the browser (firefox linux here, perhaps others are affected too). The option is properly declared with selected="" attribute in the html node - it just doesn't work when added the way it is currently using .append. This results in the wrong option being shown on the form meaning that someone coming in to the form to change something else, will unknowingly change the tool type to which the instance is linked, and they may not even notice they've done it.

      To reproduce:

      1. Login as the admin
      2. Go to "Site admin >Plugins > Activity plugins > External tool > Manage tools"
      3. Click the link to manually configure a tool
      4. Set the following form data:
      5. Save
      6. Go to a course
      7. Click "Add activity or resource > External tool" in a course
      8. Next to the preconfigured tool select, click the '+' sign
      9. In the popup, set the following info in the form:
      10. Save
      11. Repeat the process to add another preconfigured tool with the following data:
      12. Save
      13. Now, back on the activity instance add form, you should see that the select has categories inside it 'Preconfigured tools' (which are site), and 'Course tools' - this is expected.
      14. Now enter the following form data:
        • Tool name: Testing
        • Preconfigured tool : Select the "Course tool 1" option
      15. Save the activity instance
      16. Edit the activity instance settings, waiting for the page to fully load
        Expected: You see the "Course tool 1" option selected
        Actual: The "Yet another course tool" option is selected

            jaked Jake Dallimore
            jaked Jake Dallimore
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

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