Differences Between: [Versions 310 and 311]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 defined('MOODLE_INTERNAL') || die(); 18 19 require_once($CFG->dirroot . '/course/format/lib.php'); 20 21 /** 22 * Fixture for fake course format testing course format API. 23 * 24 * @package core_course 25 * @copyright 2014 Marina Glancy 26 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 27 */ 28 class format_theunittest extends format_base { 29 30 /** 31 * Definitions of the additional options that format uses 32 * 33 * @param bool $foreditform 34 * @return array of options 35 */ 36 public function course_format_options($foreditform = false) { 37 static $courseformatoptions = false; 38 if ($courseformatoptions === false) { 39 $courseformatoptions = array( 40 'hideoddsections' => array( 41 'default' => 0, 42 'type' => PARAM_INT, 43 ), 44 ); 45 } 46 if ($foreditform && !isset($courseformatoptions['hideoddsections']['label'])) { 47 $sectionmenu = array( 48 0 => 'Never', 49 1 => 'Hide without notice', 50 2 => 'Hide with notice' 51 ); 52 $courseformatoptionsedit = array( 53 'hideoddsections' => array( 54 'label' => 'Hide odd sections', 55 'element_type' => 'select', 56 'element_attributes' => array($sectionmenu), 57 ), 58 ); 59 $courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsedit); 60 } 61 return $courseformatoptions; 62 } 63 64 /** 65 * Allows to specify for modinfo that section is not available even when it is visible and conditionally available. 66 * 67 * @param section_info $section 68 * @param bool $available 69 * @param string $availableinfo 70 */ 71 public function section_get_available_hook(section_info $section, &$available, &$availableinfo) { 72 if (($section->section % 2) && ($hideoddsections = $this->get_course()->hideoddsections)) { 73 $available = false; 74 if ($hideoddsections == 2) { 75 $availableinfo = 'Odd sections are oddly hidden'; 76 } else { 77 $availableinfo = ''; 78 } 79 } 80 } 81 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body