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

API enhancement: Way to prevent modules appearing on 'Add...' dropdowns

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3
    • Component/s: Course
    • Labels:
    • Testing Instructions:
      Hide

      Level: DIFFICULT (needs code access).

      0. If necessary, turn on the restrict modules feature for all courses.

      1. Load a course page. Turn editing on. Select an 'Add a resource...' dropdown.
      + Verify that the URL module is included on the list.

      2. Add a URL (any settings).

      3. Edit mod/url/lib.php. Change the line in url_supports, 'return MOD_ARCHETYPE_RESOURCE' to return MOD_ARCHETYPE_SYSTEM.

      4. Reload the course page.
      + Verify that the URL module now does not appear on the list.
      + Verify that the existing URL still appears and can still be edited.

      5. Edit course settings.
      + Verify that the URL module now is not listed on the 'restrict modules' list (there's no point as you cannot add it there anyhow)
      + Verify that the 'restrict modules' list shows the human-readable names of each module not the lower-case codes (Forum vs. forum)

      Show
      Level: DIFFICULT (needs code access). 0. If necessary, turn on the restrict modules feature for all courses. 1. Load a course page. Turn editing on. Select an 'Add a resource...' dropdown. + Verify that the URL module is included on the list. 2. Add a URL (any settings). 3. Edit mod/url/lib.php. Change the line in url_supports, 'return MOD_ARCHETYPE_RESOURCE' to return MOD_ARCHETYPE_SYSTEM. 4. Reload the course page. + Verify that the URL module now does not appear on the list. + Verify that the existing URL still appears and can still be edited. 5. Edit course settings. + Verify that the URL module now is not listed on the 'restrict modules' list (there's no point as you cannot add it there anyhow) + Verify that the 'restrict modules' list shows the human-readable names of each module not the lower-case codes (Forum vs. forum)
    • Workaround:
      Hide

      function oucontent_get_types() {
          // This prevents it being on the Add Activity menu
          return array();
      }

      Show
      function oucontent_get_types() { // This prevents it being on the Add Activity menu return array(); }
    • Affected Branches:
      MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_23_STABLE
    • Pull Master Branch:
      MDL-30408-master

      Description

      (Change proposed for 2.3, please ignore until that starts.)

      In several cases at the OU we have modules which you cannot create using the normal 'Add a resource/activity' dropdowns. This is because either:

      a) the creation process is complicated and must be initiated within another system
      or
      b) the module is created by the system automatically independent of user

      To support these I propose adding a fourth ARCHETYPE constant: MOD_ARCHETYPE_SYSTEM for modules which can only be added by the system and do not appear in the list.

      There is a hack to do this in current (including 2.2) system but it is horrible and seems likely to die in future, now that assignment module has done. See workaround below.

      In addition while implementing this feature I observed that the 'restrict modules' list uses the internal names for modules (e.g. 'forum') rather than the translated language strings. This seems bizarre, so I fixed it.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  6 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    25/Jun/12