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

Course custom field dropdown options can easily be messed up

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 3.9 regressions
    • Fix Version/s: None
    • Component/s: Course
    • Labels:
      None

      Description

      The dropdown menu field of the course custom field assigns each option a value based on its position in the list (an array, I guess). This means that if anyone ever inserts another option in the dropdown list (for example to keep the list alphabetical), all the data attached to his field is then inaccurate. This is very likely to occur eventually and is a considerable risk to administrators. It would be nice if any additional item to the list of options was assigned a sequential value rather than one based on it's position in the list.

      SETUP

      1. Create a course custom field of type Dropdown menu, with four options called:
        Option 1
        Option 2
        Option 3
        Option 4
        We'll refer to this field as DDM.
      2. Use a test course (id=xxxx) and set it to Option 1
      3. Using the Adhoc Report plugin (or any other DB query tool) to determine the field ID (yy) for the DDM field:
        Select *
        From prefix_customfield_field
        Let's call this report REPORT 1
      4. Using the Adhoc Report plugin (or any other DB query tool) to confirm that the intvalue (and value) fields are both '1'.
        Select *
        From prefix_customfield_data
        Where fieldid=yy
        And instanceid=xxxx
        Let's call this report REPORT 2
      5. Use the same test shell to repeat step 2-4 for all four options.
        You should find that the values in the database correspond to the drop-down menu options in the order that they appear on the list.
        In other words,
        Option 1 = intvalue/value=1
        Option 2 = intvalue/value=2
        Option 3 = intvalue/value=3
        Option 4 = intvalue/value=4

      TEST

      1. With the test course id=xxxx still set to Option 4,
        Edit the DDM options list, adding an Option 0 to the top of the list, above Option 1.
      2. Rerun REPORT 2 to confirm that the intvalue/value fields remain at 4
      3. Check the course setting page and confirm that the DDM field now shows Option 3 (in other words,  intvalue/value 4, now represents Option 3, instead of Option 4).
      4. Change the DDM to Option 0
      5. Rerun REPORT 2 to confirm that the intvalue/value field is now 1 (Option 0).

      DESIRABLE BEHAVIOUR

      1. With the test course id=xxxx still set to Option 4,
        Edit the DDM options list, adding an Option 0 to the top of the list, above Option 1.
      2. Rerun REPORT 2 to confirm that the intvalue/value fields remain at 4
      3. Check the course setting page and confirm that the DDM field still shows Option 4
      4. Change the DDM to Option 0
      5. Rerun REPORT 2 to confirm that the intvalue/value field is now 5 (Option 0).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              bfriesen B. Friesen
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: