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

Allow course format to overwrite section availability

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      This issue does not change UI of any existing formats, just adds possibility to the API. To test you need to add to the format_weeks class in course/format/weeks/lib.php the following method:

          public function section_get_available_hook(section_info $section, &$available, &$availableinfo) {
              if ($section->section && ($dates = $this->get_section_dates($section)) && time() < $dates->start) {
                  $available = false;
                  $availableinfo = 'Not available yet';
              }
          }
      

      1. Browse the course in weeks format as a student and make sure that future weeks are displayed with "Not available yet" message and without any activities
      2. Check gradebook, student reports and/or pages such as /mod/assign/index.php, make sure that activities from the future weeks do not appear there.
      3. In the code snippet above change 'Not available yet' to '' (empty string)
      4. Browse the course in weeks format as a student and make sure that future weeks are not displayed at all.
      Show
      This issue does not change UI of any existing formats, just adds possibility to the API. To test you need to add to the format_weeks class in course/format/weeks/lib.php the following method: public function section_get_available_hook(section_info $section, &$available, &$availableinfo) { if ($section->section && ($dates = $this->get_section_dates($section)) && time() < $dates->start) { $available = false; $availableinfo = 'Not available yet'; } } Browse the course in weeks format as a student and make sure that future weeks are displayed with "Not available yet" message and without any activities Check gradebook, student reports and/or pages such as /mod/assign/index.php, make sure that activities from the future weeks do not appear there. In the code snippet above change 'Not available yet' to '' (empty string) Browse the course in weeks format as a student and make sure that future weeks are not displayed at all.
    • Affected Branches:
      MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_28_STABLE
    • Pull Master Branch:
      wip-MDL-46937-master

      Description

      I've come to this problem working on an issue for custom course format: CONTRIB-5052

      Currently function section_info::get_uservisible() checks section visibility and conditional availability. There is no way for course format to say that the section is not available for the current user because of some other courseformat-specific conditions. In my case section should become unavilable if the parent section is unavailable. Another use case maybe course format that has automatic time-based availability of sections, for example one section per week.

      Also cm_info::$uservisible does not take into account section availability unless $CFG->enableavailability is on, so it needs to be changed too

      For backward compatibility we still won't make module unavailable if parent section is invisible and the module is not.

      Forum: https://moodle.org/mod/forum/discuss.php?d=267455

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                marina Marina Glancy
                Reporter:
                marina Marina Glancy
                Integrator:
                Sam Hemelryk
                Tester:
                Andrew Nicols
                Participants:
                Component watchers:
                Sam Marshall, Jake Dallimore, Jun Pataleta, Ryan Wyllie, Amaia Anabitarte, Bas Brands, Carlos Escobedo, Sara Arjona (@sarjona), Víctor Déniz Falcón
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  10/Nov/14