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

Change course module creation to support parameter for inserting modules at any place in the section

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_39_STABLE, MOODLE_400_STABLE, MOODLE_401_STABLE, MOODLE_402_STABLE
    • MOODLE_402_STABLE
    • MDL-75594-master
    • Easy
    • Hide

      Setup

      1. Go to a course and create two course modules in a section.
      2. Get the section id, the course id and the course module id of the second one.

      Testing instructions

      You'll need to run them, using different values for the beforemod parameter.

      1. Go to this URL, replacing the missing values:
        https://{yourmoodle}/course/modedit.php?add=page&type=&course={courseid}&section={sectionid}&return=0&sr={sectionid}&beforemod={coursemoduleid}
      2. Create a page with random content and save it.
      3. Check the new page item appears before the second-course module except if:
      • Use URL without the beforemod param
      • beforemod=0
      • beforemod=some_nonsense
      • beforemod=null
      • beforemod=SOME_MOD_ID where SOME_MOD_ID is either invalid or an id of a non existent/deleted course module etc.
      Show
      Setup Go to a course and create two course modules in a section. Get the section id, the course id and the course module id of the second one. Testing instructions You'll need to run them, using different values for the beforemod parameter. Go to this URL, replacing the missing values: https://{yourmoodle}/course/modedit.php?add=page&type=&course={courseid}&section={sectionid}&return=0&sr={sectionid}&beforemod={coursemoduleid} Create a page with random content and save it. Check the new page item appears before the second-course module except if: Use URL without the beforemod param beforemod=0 beforemod=some_nonsense beforemod=null beforemod=SOME_MOD_ID where SOME_MOD_ID is either invalid or an id of a non existent/deleted course module etc.

      A often requested feature is the ability to insert a new course module anywhere in a section not just at the end. This is especially important for trainers who update their courses very frequently.

      As a first step I'd propose to add an option to the API for course module creation that supports a parameter that indicates, where in the section the module has to be created.
      As the API already supports the parameter $beforemod in course_add_cm_to_section() it would be the easiest way to use this option to provide a consistent behavior:
      Every course module id in the section can be used as a value of $beforemod here. The new module is inserted before $beforemod in the corresponding section. If it is not set, the new module is inserted at the end of the section.

      If the course module in $beforemod is moved during creation of the module (maybe by another trainer, but that might be an edge case) there are two different options:

      • If it is moved inside the section, the new module will be created before the (new) position of $beforemod.
      • If it is moved outside the section, the new module will be created at the end of the section.

      Adding the new option to the theme and the activity chooser is a separate issue (MDL-75596).

            stefan.hanauska Stefan Hanauska
            stefan.hanauska Stefan Hanauska
            PhMemmel PhMemmel
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            14 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 5 hours, 39 minutes
                5h 39m

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