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

Allow course format to overwrite section availability

    XMLWordPrintable

Details

    • MOODLE_27_STABLE
    • MOODLE_28_STABLE
    • wip-MDL-46937-master
    • 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.

    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

              marina Marina Glancy
              marina Marina Glancy
              Sam Hemelryk Sam Hemelryk
              Andrew Lyons Andrew Lyons
              Sam Marshall, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona), Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Ilya Tregubov, Laurent David, Raquel Ortega, Sara Arjona (@sarjona)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                10/Nov/14