diff --git a/course/classes/output/course_module_name.php b/course/classes/output/course_module_name.php deleted file mode 100644 index 62d354e3329..00000000000 --- a/course/classes/output/course_module_name.php +++ /dev/null @@ -1,107 +0,0 @@ -. - -/** - * Contains class core_tag\output\course_module_name - * - * @package core_course - * @copyright 2016 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -namespace core_course\output; - -use cm_info; -use context_module; -use core_external\external_api; -use lang_string; - -/** - * Class to prepare a course module name for display and in-place editing - * - * @deprecated since Moodle 4.0 MDL-72656 - please do not use this class any more. - * @package core_course - * @copyright 2016 Marina Glancy - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class course_module_name extends \core\output\inplace_editable { - - /** @var cm_info */ - protected $cm; - - /** @var array */ - protected $displayoptions; - - /** - * Constructor. - * - * @param cm_info $cm - * @param bool $editable - * @param array $displayoptions - */ - public function __construct(cm_info $cm, $editable, $displayoptions = array()) { - debugging( - 'course_section_cm_list is deprecated. Use core_courseformat\\output\\local\\cm\\cmname instead', - DEBUG_DEVELOPER - ); - $this->cm = $cm; - $this->displayoptions = $displayoptions; - $value = $cm->name; - $edithint = new lang_string('edittitle'); - $editlabel = new lang_string('newactivityname', '', $cm->get_formatted_name()); - $editable = $editable && has_capability('moodle/course:manageactivities', - context_module::instance($cm->id)); - parent::__construct( - 'core_course', 'activityname', $cm->id, $editable, $value, $value, $edithint, $editlabel); - } - - /** - * Export this data so it can be used as the context for a mustache template (core/inplace_editable). - * - * @param \renderer_base $output typically, the renderer that's calling this function - * @return array data context for a mustache template - */ - public function export_for_template(\renderer_base $output) { - global $PAGE; - $courserenderer = $PAGE->get_renderer('core', 'course'); - $this->displayvalue = $courserenderer->course_section_cm_name_title($this->cm, $this->displayoptions); - if (strval($this->displayvalue) === '') { - $this->editable = false; - } - return parent::export_for_template($output); - } - - /** - * Updates course module name - * - * @param int $itemid course module id - * @param string $newvalue new name - * @return static - */ - public static function update($itemid, $newvalue) { - $context = context_module::instance($itemid); - // Check access. - external_api::validate_context($context); - require_capability('moodle/course:manageactivities', $context); - - // Trim module name and Update value. - set_coursemodule_name($itemid, trim($newvalue)); - $coursemodulerecord = get_coursemodule_from_id('', $itemid, 0, false, MUST_EXIST); - // Return instance. - $cm = get_fast_modinfo($coursemodulerecord->course)->get_cm($itemid); - return new static($cm, true); - } -} diff --git a/course/format/classes/base.php b/course/format/classes/base.php index 3faf702a909..2c7df4624b6 100644 --- a/course/format/classes/base.php +++ b/course/format/classes/base.php @@ -563,8 +563,7 @@ abstract class base { /** * Set if the current format instance will show multiple sections or an individual one. * - * Some formats has the hability to swith from one section to multiple sections per page, - * this method replaces the old print_multiple_section_page and print_single_section_page. + * Some formats has the hability to swith from one section to multiple sections per page. * * @param int $singlesection zero for all sections or a section number */ diff --git a/course/format/classes/output/section_renderer.php b/course/format/classes/output/section_renderer.php index c3133997dbc..c90b8e0cece 100644 --- a/course/format/classes/output/section_renderer.php +++ b/course/format/classes/output/section_renderer.php @@ -14,14 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -/** - * Contains the default section course format output class. - * - * @package core_courseformat - * @copyright 2020 Ferran Recio - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - namespace core_courseformat\output; defined('MOODLE_INTERNAL') || die(); @@ -29,24 +21,17 @@ defined('MOODLE_INTERNAL') || die(); global $CFG; require_once($CFG->dirroot . '/course/renderer.php'); -use action_menu; -use action_menu_link_secondary; use cm_info; use coding_exception; -use context_course; use core_course_renderer; use core_courseformat\base as course_format; use html_writer; -use moodle_page; -use moodle_url; -use pix_icon; use renderable; use section_info; -use templatable; -use url_select; +use stdClass; /** - * Base class to render a course add section buttons. + * Contains the default section course format output class. * * @package core_courseformat * @copyright 2020 Ferran Recio @@ -54,29 +39,6 @@ use url_select; */ abstract class section_renderer extends core_course_renderer { - /** - * @var core_course_renderer contains an instance of core course renderer - * @deprecated since 4.0 - use $this to access course renderer methods - */ - protected $courserenderer; - - /** - * Constructor method, calls the parent constructor. - * - * @deprecated since 4.0 - * - * Note: this method exists only for compatibilitiy with legacy course formats. Legacy formats - * depends on $this->courserenderer to access the course renderer methods. Since Moodle 4.0 - * core_courseformat\output\section_renderer extends core_course_renderer and all metdhos can be used directly from $this. - * - * @param moodle_page $page - * @param string $target one of rendering target constants - */ - public function __construct(moodle_page $page, $target) { - parent::__construct($page, $target); - $this->courserenderer = $this->page->get_renderer('core', 'course'); - } - /** * Renders the provided widget and returns the HTML to display it. * @@ -139,7 +101,6 @@ abstract class section_renderer extends core_course_renderer { * Get the updated rendered version of a cm list item. * * This method is used when an activity is duplicated or copied in on the client side without refreshing the page. - * It replaces the course renderer course_section_cm_list_item method but it's scope is different. * Note that the previous method is used every time an activity is rendered, independent of it is the initial page * loading or an Ajax update. In this case, course_section_updated_cm_item will only be used when the course editor * requires to get an updated cm item HTML to perform partial page refresh. It will be used for suporting the course @@ -222,237 +183,72 @@ abstract class section_renderer extends core_course_renderer { } /** - * Generate the edit control action menu - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * The section edit controls are now part of the main core_courseformat\output\local\content\section output - * and does not use renderer methods anymore. - * - * @param array $controls The edit control items from section_edit_control_items - * @param stdClass $course The course entry from DB (not used) - * @param stdClass $section The course_section entry from DB - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function section_edit_control_menu($controls, $course, $section) { - debugging('section_edit_control_menu() can not be used anymore. Please use ' . + + throw new coding_exception('section_edit_control_menu() can not be used anymore. Please use ' . 'core_courseformat\\output\\local\\content\\section to render a section. In case you need to modify those controls ' . - 'override core_courseformat\\output\\local\\content\\section\\controlmenu in your format plugin.', DEBUG_DEVELOPER); - - $o = ""; - if (!empty($controls)) { - $menu = new action_menu(); - $menu->set_menu_trigger(get_string('edit')); - $menu->attributes['class'] .= ' section-actions'; - foreach ($controls as $value) { - $url = empty($value['url']) ? '' : $value['url']; - $icon = empty($value['icon']) ? '' : $value['icon']; - $name = empty($value['name']) ? '' : $value['name']; - $attr = empty($value['attr']) ? array() : $value['attr']; - $class = empty($value['pixattr']['class']) ? '' : $value['pixattr']['class']; - $al = new action_menu_link_secondary( - new moodle_url($url), - new pix_icon($icon, '', null, array('class' => "smallicon " . $class)), - $name, - $attr - ); - $menu->add($al); - } - - $o .= html_writer::div( - $this->render($menu), - 'section_action_menu', - array('data-sectionid' => $section->id) - ); - } - - return $o; + 'override core_courseformat\\output\\local\\content\\section\\controlmenu in your format plugin.'); } /** - * Generate the content to displayed on the right part of a section - * before course modules are included - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * Spatial references like "left" or "right" are limiting the way formats and themes can - * extend courses. The elements from this method are now included in the - * core_courseformat\output\local\content\section output components. - * - * @param stdClass $section The course_section entry from DB - * @param stdClass $course The course entry from DB - * @param bool $onsectionpage true if being printed on a section page - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function section_right_content($section, $course, $onsectionpage) { - debugging('section_right_content() can not be used anymore. Please use ' . - 'core_courseformat\\output\\local\\content\\section to render a section.', DEBUG_DEVELOPER); - - $o = $this->output->spacer(); - - $controls = $this->section_edit_control_items($course, $section, $onsectionpage); - $o .= $this->section_edit_control_menu($controls, $course, $section); - - return $o; + throw new coding_exception('section_right_content() can not be used anymore. Please use ' . + 'core_courseformat\\output\\local\\content\\section to render a section.'); } /** - * Generate the content to displayed on the left part of a section - * before course modules are included - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * Spatial references like "left" or "right" are limiting the way formats and themes can - * extend courses. The elements from this method are now included in the - * core_courseformat\output\local\content\section output components. - * - * @param stdClass $section The course_section entry from DB - * @param stdClass $course The course entry from DB - * @param bool $onsectionpage true if being printed on a section page - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function section_left_content($section, $course, $onsectionpage) { - debugging('section_left_content() can not be used anymore. Please use ' . - 'core_courseformat\\output\\local\\content\\section to render a section.', DEBUG_DEVELOPER); - - $o = ''; - - if ($section->section != 0) { - // Only in the non-general sections. - if (course_get_format($course)->is_section_current($section)) { - $o = get_accesshide(get_string('currentsection', 'format_' . $course->format)); - } - } - - return $o; + throw new coding_exception('section_left_content() can not be used anymore. Please use ' . + 'core_courseformat\\output\\local\\content\\section to render a section.'); } /** - * Generate the display of the header part of a section before - * course modules are included - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is now a core_courseformat\output\content\section output component and it is displayed using - * mustache templates instead of a renderer method. - * - * @param stdClass $section The course_section entry from DB - * @param stdClass $course The course entry from DB - * @param bool $onsectionpage true if being printed on a single-section page - * @param int $sectionreturn The section to return to after an action - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function section_header($section, $course, $onsectionpage, $sectionreturn = null) { - debugging('section_header() is deprecated. Please use ' . + + throw new coding_exception('section_header() can not be used any more. Please use ' . 'core_courseformat\\output\\local\\content\\section to render a section ' . 'or core_courseformat\output\\local\\content\\section\\header ' . - 'to print only the header.', DEBUG_DEVELOPER); - - $o = ''; - $sectionstyle = ''; - - if ($section->section != 0) { - // Only in the non-general sections. - if (!$section->visible) { - $sectionstyle = ' hidden'; - } - if (course_get_format($course)->is_section_current($section)) { - $sectionstyle = ' current'; - } - } - - $o .= html_writer::start_tag('li', [ - 'id' => 'section-' . $section->section, - 'class' => 'section main clearfix' . $sectionstyle, - 'role' => 'region', - 'aria-labelledby' => "sectionid-{$section->id}-title", - 'data-sectionid' => $section->section, - 'data-sectionreturnid' => $sectionreturn - ]); - - $leftcontent = $this->section_left_content($section, $course, $onsectionpage); - $o .= html_writer::tag('div', $leftcontent, array('class' => 'left side')); - - $rightcontent = $this->section_right_content($section, $course, $onsectionpage); - $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); - $o .= html_writer::start_tag('div', array('class' => 'content')); - - // When not on a section page, we display the section titles except the general section if null. - $hasnamenotsecpg = (!$onsectionpage && ($section->section != 0 || !is_null($section->name))); - - // When on a section page, we only display the general section title, if title is not the default one. - $hasnamesecpg = ($onsectionpage && ($section->section == 0 && !is_null($section->name))); - - $classes = ' accesshide'; - if ($hasnamenotsecpg || $hasnamesecpg) { - $classes = ''; - } - $sectionname = html_writer::tag('span', $this->section_title($section, $course)); - $o .= $this->output->heading($sectionname, 3, 'sectionname' . $classes, "sectionid-{$section->id}-title"); - - $o .= $this->section_availability($section); - - $o .= html_writer::start_tag('div', array('class' => 'summary')); - if ($section->uservisible || $section->visible) { - // Show summary if section is available or has availability restriction information. - // Do not show summary if section is hidden but we still display it because of course setting - // "Hidden sections are shown as not available". - $o .= $this->format_summary_text($section); - } - $o .= html_writer::end_tag('div'); - - return $o; + 'to print only the header.'); } /** - * Generate the display of the footer part of a section. - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is integrated into core_courseformat\output\local\content\section output component and it is - * displayed using mustache templates instead of a renderer method. - * - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function section_footer() { - debugging('section_footer() is deprecated. Please use ' . + throw new coding_exception('section_footer() can not be used any more. Please use ' . 'core_courseformat\\output\\local\\content\\section to render individual sections or .' . - 'core_courseformat\\output\\local\\content to render the full course', DEBUG_DEVELOPER); - - $o = html_writer::end_tag('div'); - $o .= html_writer::end_tag('li'); - return $o; + 'core_courseformat\\output\\local\\content to render the full course'); } /** - * Generate the starting container html for a list of sections. - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function start_section_list() { - debugging('start_section_list() is deprecated. Please use ' . + + throw new coding_exception('start_section_list() can not be used any more. Please use ' . 'core_courseformat\\output\\local\\content\\section to render individual sections or .' . - 'core_courseformat\\output\\local\\content to render the full course', DEBUG_DEVELOPER); - return html_writer::start_tag('ul', ['class' => 'sections']); + 'core_courseformat\\output\\local\\content to render the full course'); } /** - * Generate the closing container html for a list of sections. - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead.y - * - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead.y */ protected function end_section_list() { - debugging('end_section_list() is deprecated. Please use ' . + + throw new coding_exception('end_section_list() can not be used any more. Please use ' . 'core_courseformat\\output\\local\\content\\section to render individual sections or .' . - 'core_courseformat\\output\\local\\content to render the full course', DEBUG_DEVELOPER); - return html_writer::end_tag('ul'); + 'core_courseformat\\output\\local\\content to render the full course'); } /** @@ -466,333 +262,87 @@ abstract class section_renderer extends core_course_renderer { } /** - * Generate the edit control items of a section - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is now a core_courseformat\output\content\section output component and it is displayed using - * mustache templates instead of a renderer method. - * - * @param stdClass $course The course entry from DB - * @param stdClass $section The course_section entry from DB - * @param bool $onsectionpage true if being printed on a section page - * @return array of edit control items + * @deprecated since 4.0 - use core_course output components instead. */ protected function section_edit_control_items($course, $section, $onsectionpage = false) { - debugging('section_edit_control_items() is deprecated, please use or extend' . - 'core_courseformat\output\\local\\content\\section\\controlmenu instead (like topics format does).', DEBUG_DEVELOPER); - $format = course_get_format($course); - $modinfo = $format->get_modinfo(); - - if ($onsectionpage) { - $format->set_section_number($section->section); - } - - // We need a section_info object, not a record. - $section = $modinfo->get_section_info($section->section); - - $widgetclass = $format->get_output_classname('content\\section\\controlmenu'); - $widget = new $widgetclass($format, $section); - return $widget->section_control_items(); + throw new coding_exception('section_edit_control_items() can not be used any more. Please use or extend' . + 'core_courseformat\output\\local\\content\\section\\controlmenu instead (like topics format does).'); } /** - * Generate a summary of a section for display on the 'course index page' - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is now a core_courseformat\output\content\section output component and it is displayed using - * mustache templates instead of a renderer method. - * - * @param stdClass $section The course_section entry from DB - * @param stdClass $course The course entry from DB - * @param array $mods (argument not used) - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function section_summary($section, $course, $mods) { - debugging('section_summary() is deprecated. Please use ' . + + throw new coding_exception('section_summary() can not be used any more. Please use ' . 'core_courseformat\output\\local\\content\\section to render sections. If you need to modify those summary, extend ' . - 'core_courseformat\output\\local\\content\\section\\summary in your format plugin.', DEBUG_DEVELOPER); - - $classattr = 'section main section-summary clearfix'; - $linkclasses = ''; - - // If section is hidden then display grey section link. - if (!$section->visible) { - $classattr .= ' hidden'; - $linkclasses .= ' dimmed_text'; - } else if (course_get_format($course)->is_section_current($section)) { - $classattr .= ' current'; - } - - $title = get_section_name($course, $section); - $o = ''; - $o .= html_writer::start_tag('li', [ - 'id' => 'section-' . $section->section, - 'class' => $classattr, - 'role' => 'region', - 'aria-label' => $title, - 'data-sectionid' => $section->section - ]); - - $o .= html_writer::tag('div', '', array('class' => 'left side')); - $o .= html_writer::tag('div', '', array('class' => 'right side')); - $o .= html_writer::start_tag('div', array('class' => 'content')); - - if ($section->uservisible) { - $title = html_writer::tag( - 'a', - $title, - array('href' => course_get_url($course, $section->section), 'class' => $linkclasses) - ); - } - $o .= $this->output->heading($title, 3, 'section-title'); - - $o .= $this->section_availability($section); - $o .= html_writer::start_tag('div', array('class' => 'summarytext')); - - if ($section->uservisible || $section->visible) { - // Show summary if section is available or has availability restriction information. - // Do not show summary if section is hidden but we still display it because of course setting - // "Hidden sections are shown as not available". - $o .= $this->format_summary_text($section); - } - $o .= html_writer::end_tag('div'); - $o .= $this->section_activity_summary($section, $course, null); - - $o .= html_writer::end_tag('div'); - $o .= html_writer::end_tag('li'); - - return $o; + 'core_courseformat\output\\local\\content\\section\\summary in your format plugin.'); } /** - * Generate a summary of the activites in a section - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is now a core_courseformat\output\content\section output component and it is displayed using - * mustache templates instead of a renderer method. - * - * @param stdClass $section The course_section entry from DB - * @param stdClass $course the course record from DB - * @param array $mods (argument not used) - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function section_activity_summary($section, $course, $mods) { - debugging('section_activity_summary() is deprecated. Please use ' . + throw new coding_exception('section_activity_summary() can not be used any more. Please use ' . 'core_courseformat\output\\local\\content\\section to render sections. ' . 'If you need to modify those information, extend ' . - 'core_courseformat\output\\local\\content\\section\\cmsummary in your format plugin.', DEBUG_DEVELOPER); - - $format = course_get_format($course); - $widgetclass = $format->get_output_classname('content\\section\\cmsummary'); - $widget = new $widgetclass($format, $section); - $this->render($widget); + 'core_courseformat\output\\local\\content\\section\\cmsummary in your format plugin.'); } /** - * If section is not visible, display the message about that ('Not available - * until...', that sort of thing). Otherwise, returns blank. - * - * For users with the ability to view hidden sections, it shows the - * information even though you can view the section and also may include - * slightly fuller information (so that teachers can tell when sections - * are going to be unavailable etc). This logic is the same as for - * activities. - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is now a core_courseformat\output\content\section output component and it is displayed using - * mustache templates instead of a renderer method. - * - * @param section_info $section The course_section entry from DB - * @param bool $canviewhidden True if user can view hidden sections - * @return string HTML to output + * @deprecated since 4.0 - use core_course output components instead. */ protected function section_availability_message($section, $canviewhidden) { - global $CFG; - debugging('section_availability_message() is deprecated. Please use ' . + throw new coding_exception('section_availability_message() can not be used any more. Please use ' . 'core_courseformat\output\\local\\content\\section to render sections. If you need to modify this element, extend ' . - 'core_courseformat\output\\local\\content\\section\\availability in your format plugin.', DEBUG_DEVELOPER); - - $course = $section->course; - $format = course_get_format($course); - $widgetclass = $format->get_output_classname('content\\section\\availability'); - $widget = new $widgetclass($format, $section); - $this->render($widget); + 'core_courseformat\output\\local\\content\\section\\availability in your format plugin.'); } /** - * Displays availability information for the section (hidden, not available unles, etc.) - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is now a core_courseformat\output\content\section output component and it is displayed using - * mustache templates instead of a renderer method. - * - * @param section_info $section - * @return string + * @deprecated since 4.0 - use core_course output components instead. */ public function section_availability($section) { - debugging('section_availability() is deprecated. Please use ' . + throw new coding_exception('section_availability() can not be used any more. Please use ' . 'core_courseformat\output\\local\\content\\section to render sections. If you need to modify this element, extend ' . - 'core_courseformat\output\\local\\content\\section\\availability in your format plugin.', DEBUG_DEVELOPER); - - $context = context_course::instance($section->course); - $canviewhidden = has_capability('moodle/course:viewhiddensections', $context); - return html_writer::div($this->section_availability_message($section, $canviewhidden), 'section_availability'); + 'core_courseformat\output\\local\\content\\section\\availability in your format plugin.'); } /** - * Show if something is on on the course clipboard (moving around) - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * While the non ajax course eidtion is still supported, the old clipboard will be - * emulated by core_courseformat\output\local\content\section\cmlist. - * - * @param stdClass $course The course entry from DB - * @param int $sectionno The section number in the course which is being displayed - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function course_activity_clipboard($course, $sectionno = null) { - global $USER; - debugging('Non ajax course edition using course_activity_clipboard is not supported anymore.', DEBUG_DEVELOPER); - - $o = ''; - // If currently moving a file then show the current clipboard. - if (ismoving($course->id)) { - $url = new moodle_url( - '/course/mod.php', - array( - 'sesskey' => sesskey(), - 'cancelcopy' => true, - 'sr' => $sectionno, - ) - ); - - $o .= html_writer::start_tag('div', array('class' => 'clipboard')); - $o .= strip_tags(get_string('activityclipboard', '', $USER->activitycopyname)); - $o .= ' (' . html_writer::link($url, get_string('cancel')) . ')'; - $o .= html_writer::end_tag('div'); - } - - return $o; + throw new coding_exception('Non ajax course edition using course_activity_clipboard is not supported anymore.'); } /** - * Generate next/previous section links for naviation. - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is now a core_courseformat\output\content\section output component and it is displayed using - * mustache templates instead of a renderer method. - * - * @param stdClass $course The course entry from DB - * @param array $sections The course_sections entries from the DB - * @param int $sectionno The section number in the course which is being displayed - * @return array associative array with previous and next section link + * @deprecated since 4.0 - use core_course output components instead. */ protected function get_nav_links($course, $sections, $sectionno) { - debugging('get_nav_links() is deprecated. Please use ' . + throw new coding_exception('get_nav_links() can not be used any more. Please use ' . 'core_courseformat\\output\\local\\content to render a course. If you need to modify this element, extend ' . - 'core_courseformat\\output\\local\\content\\sectionnavigation in your format plugin.', DEBUG_DEVELOPER); - - // FIXME: This is really evil and should by using the navigation API. - $course = course_get_format($course)->get_course(); - $canviewhidden = has_capability('moodle/course:viewhiddensections', context_course::instance($course->id)) - or !$course->hiddensections; - - $links = array('previous' => '', 'next' => ''); - $back = $sectionno - 1; - while ($back > 0 and empty($links['previous'])) { - if ($canviewhidden || $sections[$back]->uservisible) { - $params = array(); - if (!$sections[$back]->visible) { - $params = array('class' => 'dimmed_text'); - } - $previouslink = html_writer::tag('span', $this->output->larrow(), array('class' => 'larrow')); - $previouslink .= get_section_name($course, $sections[$back]); - $links['previous'] = html_writer::link(course_get_url($course, $back), $previouslink, $params); - } - $back--; - } - - $forward = $sectionno + 1; - $numsections = course_get_format($course)->get_last_section_number(); - while ($forward <= $numsections and empty($links['next'])) { - if ($canviewhidden || $sections[$forward]->uservisible) { - $params = array(); - if (!$sections[$forward]->visible) { - $params = array('class' => 'dimmed_text'); - } - $nextlink = get_section_name($course, $sections[$forward]); - $nextlink .= html_writer::tag('span', $this->output->rarrow(), array('class' => 'rarrow')); - $links['next'] = html_writer::link(course_get_url($course, $forward), $nextlink, $params); - } - $forward++; - } - - return $links; + 'core_courseformat\\output\\local\\content\\sectionnavigation in your format plugin.'); } /** - * Generate the header html of a stealth section - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is now a core_courseformat\output\content\section output component and it is displayed using - * mustache templates instead of a renderer method. - * - * @param int $sectionno The section number in the course which is being displayed - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function stealth_section_header($sectionno) { - debugging('stealth_section_header() is deprecated. Please use ' . - 'core_courseformat\output\\local\\content\\section to render sections.', DEBUG_DEVELOPER); - $o = ''; - $o .= html_writer::start_tag('li', [ - 'id' => 'section-' . $sectionno, - 'class' => 'section main clearfix orphaned hidden', - 'data-sectionid' => $sectionno - ]); - $o .= html_writer::tag('div', '', array('class' => 'left side')); - $course = course_get_format($this->page->course)->get_course(); - $section = course_get_format($this->page->course)->get_section($sectionno); - $rightcontent = $this->section_right_content($section, $course, false); - $o .= html_writer::tag('div', $rightcontent, array('class' => 'right side')); - $o .= html_writer::start_tag('div', array('class' => 'content')); - $o .= $this->output->heading( - get_string('orphanedactivitiesinsectionno', '', $sectionno), - 3, - 'sectionname' - ); - return $o; + throw new coding_exception('stealth_section_header() can not be used any more. Please use ' . + 'core_courseformat\output\\local\\content\\section to render sections.'); } /** - * Generate footer html of a stealth section - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is now a core_courseformat\output\content\section output component and it is displayed using - * mustache templates instead of a renderer method. - * - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function stealth_section_footer() { - debugging('stealth_section_footer() is deprecated. Please use ' . - 'core_courseformat\output\\local\\content\\section to render sections.', DEBUG_DEVELOPER); - $o = html_writer::end_tag('div'); - $o .= html_writer::end_tag('li'); - return $o; + throw new coding_exception('stealth_section_footer() can not be used any more. Please use ' . + 'core_courseformat\output\\local\\content\\section to render sections.'); } /** @@ -826,320 +376,51 @@ abstract class section_renderer extends core_course_renderer { } /** - * Generate the html for the 'Jump to' menu on a single section page. - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This element is now a core_courseformat\output\content\section output component and it is displayed using - * mustache templates instead of a renderer method. - * - * @param stdClass $course The course entry from DB - * @param array $sections The course_sections entries from the DB - * @param int $displaysection the current displayed section number. - * - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function section_nav_selection($course, $sections, $displaysection) { - debugging('section_nav_selection() can not be used anymore. Please use ' . + throw new coding_exception('section_nav_selection() can not be used anymore. Please use ' . 'core_courseformat\\output\\local\\content to render a course. If you need to modify this element, extend ' . 'core_courseformat\\output\\local\\content\\sectionnavigation or ' . - 'core_courseformat\\output\\local\\content\\sectionselector in your format plugin.', DEBUG_DEVELOPER); - - $o = ''; - $sectionmenu = array(); - $sectionmenu[course_get_url($course)->out(false)] = get_string('maincoursepage'); - $modinfo = get_fast_modinfo($course); - $section = 1; - $numsections = course_get_format($course)->get_last_section_number(); - while ($section <= $numsections) { - $thissection = $modinfo->get_section_info($section); - if (($thissection->uservisible) && ($section != $displaysection) && ($url = course_get_url($course, $section))) { - $sectionmenu[$url->out(false)] = get_section_name($course, $section); - } - $section++; - } - - $select = new url_select($sectionmenu, '', array('' => get_string('jumpto'))); - $select->class = 'jumpmenu'; - $select->formid = 'sectionmenu'; - $o .= $this->output->render($select); - - return $o; + 'core_courseformat\\output\\local\\content\\sectionselector in your format plugin.'); } /** - * Output the html for a single section page. - * * @deprecated since 4.0 - * - * This is a deprecated method and it is mantain only for compatibilitiy with legacy course formats. - * Please, to render a single section page use: - * - * $format = course_get_format($course); - * // Set the section to display. - * $format->set_section_number($displaysection); - * $outputclass = $format->get_output_classname('content'); - * $widget = new $outputclass($format); - * echo $this->render($widget); - * - * @param stdClass $course The course entry from DB - * @param array $sections (argument not used) - * @param array $mods (argument not used) - * @param array $modnames (argument not used) - * @param array $modnamesused (argument not used) - * @param int $displaysection The section number in the course which is being displayed */ public function print_single_section_page($course, $sections, $mods, $modnames, $modnamesused, $displaysection) { - debugging('Method print_single_section_page is deprecated, please use' . + throw new coding_exception('Method print_single_section_page can not be used anymore. Please use' . 'core_courseformat\\output\\local\\content instead ' . - 'or override render_content method to use a different template', DEBUG_DEVELOPER); - - // Some abstract methods are not needed anymore. We simulate them in case they are not present. - if (method_exists($this, 'start_section_list')) { - $startlist = $this->start_section_list(); - } else { - $startlist = html_writer::start_tag('ul', ['class' => '']); - } - if (method_exists($this, 'end_section_list')) { - $endlist = $this->end_section_list(); - } else { - $endlist = html_writer::end_tag('ul'); - } - - $format = course_get_format($course); - - // Set the section to display. - $format->set_section_number($displaysection); - - $modinfo = $format->get_modinfo(); - $course = $format->get_course(); - - // Can we view the section in question? - if (!($sectioninfo = $modinfo->get_section_info($displaysection)) || !$sectioninfo->uservisible) { - // This section doesn't exist or is not available for the user. - // We actually already check this in course/view.php but just in case exit from this function as well. - throw new \moodle_exception( - 'unknowncoursesection', - 'error', - course_get_url($course), - format_string($course->fullname) - ); - } - - // Copy activity clipboard.. - echo $this->course_activity_clipboard($course, $displaysection); - $thissection = $modinfo->get_section_info(0); - if ($thissection->summary or !empty($modinfo->sections[0]) or $format->show_editor()) { - echo $startlist; - echo $this->section_header($thissection, $course, true, $displaysection); - echo $this->course_section_cm_list($course, $thissection, $displaysection); - echo $this->course_section_add_cm_control($course, 0, $displaysection); - echo $this->section_footer(); - echo $endlist; - } - - // Start single-section div. - echo html_writer::start_tag('div', array('class' => 'single-section')); - - // The requested section page. - $thissection = $modinfo->get_section_info($displaysection); - - // Title with section navigation links. - $sectionnavlinks = $this->get_nav_links($course, $modinfo->get_section_info_all(), $displaysection); - $sectiontitle = ''; - $sectiontitle .= html_writer::start_tag('div', array('class' => 'section-navigation navigationtitle')); - $sectiontitle .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left')); - $sectiontitle .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right')); - // Title attributes. - $classes = 'sectionname'; - if (!$thissection->visible) { - $classes .= ' dimmed_text'; - } - $sectionname = html_writer::tag('span', $this->section_title_without_link($thissection, $course)); - $sectiontitle .= $this->output->heading($sectionname, 3, $classes); - - $sectiontitle .= html_writer::end_tag('div'); - echo $sectiontitle; - - // Now the list of sections. - echo $startlist; - - echo $this->section_header($thissection, $course, true, $displaysection); - - echo $this->course_section_cm_list($course, $thissection, $displaysection); - echo $this->course_section_add_cm_control($course, $displaysection, $displaysection); - echo $this->section_footer(); - echo $endlist; - - // Display section bottom navigation. - $sectionbottomnav = ''; - $sectionbottomnav .= html_writer::start_tag('div', array('class' => 'section-navigation mdl-bottom')); - $sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left')); - $sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right')); - $sectionbottomnav .= html_writer::tag( - 'div', - $this->section_nav_selection($course, $sections, $displaysection), - array('class' => 'mdl-align') - ); - $sectionbottomnav .= html_writer::end_tag('div'); - echo $sectionbottomnav; - - // Close single-section div. - echo html_writer::end_tag('div'); + 'or override render_content method to use a different template'); } /** - * Output the html for a multiple section page - * * @deprecated since 4.0 - * - * This is a deprecated method and it is mantain only for compatibilitiy with legacy course formats. - * Please, to render a single section page use: - * - * $format = course_get_format($course); - * $outputclass = $format->get_output_classname('content'); - * $widget = new $outputclass($format); - * echo $this->render($widget); - * - * @param stdClass $course The course entry from DB - * @param array $sections (argument not used) - * @param array $mods (argument not used) - * @param array $modnames (argument not used) - * @param array $modnamesused (argument not used) */ public function print_multiple_section_page($course, $sections, $mods, $modnames, $modnamesused) { - debugging('Method print_multiple_section_page is deprecated, please use' . + throw new coding_exception('Method print_multiple_section_page can not be used anymore. Please use' . 'core_courseformat\\output\\local\\content instead ' . - 'or override render_content method to use a diferent template', DEBUG_DEVELOPER); - - // Some abstract methods are not needed anymore. We simulate them in case they are not present. - if (method_exists($this, 'start_section_list')) { - $startlist = $this->start_section_list(); - } else { - $startlist = html_writer::start_tag('ul', ['class' => '']); - } - if (method_exists($this, 'end_section_list')) { - $endlist = $this->end_section_list(); - } else { - $endlist = html_writer::end_tag('ul'); - } - if (method_exists($this, 'page_title')) { - $pagetitle = $this->page_title(); - } else { - $pagetitle = ''; - } - - $format = course_get_format($course); - - $modinfo = $format->get_modinfo(); - $course = $format->get_course(); - - $context = context_course::instance($course->id); - echo $this->output->heading($pagetitle, 2, 'accesshide'); - - // Copy activity clipboard.. - echo $this->course_activity_clipboard($course, 0); - - // Now the list of sections.. - echo $startlist; - $numsections = course_get_format($course)->get_last_section_number(); - - foreach ($modinfo->get_section_info_all() as $section => $thissection) { - if ($section == 0) { - // 0-section is displayed a little different then the others - if ($thissection->summary or !empty($modinfo->sections[0]) or $format->show_editor()) { - echo $this->section_header($thissection, $course, false, 0); - echo $this->course_section_cm_list($course, $thissection, 0); - echo $this->course_section_add_cm_control($course, 0, 0); - echo $this->section_footer(); - } - continue; - } - if ($section > $numsections) { - // Activities inside this section are 'orphaned', this section will be printed as 'stealth' below. - continue; - } - - if (!$format->is_section_visible($thissection)) { - continue; - } - - if (!$format->show_editor() && $format->get_course_display() == COURSE_DISPLAY_MULTIPAGE) { - // Display section summary only. - echo $this->section_summary($thissection, $course, null); - } else { - echo $this->section_header($thissection, $course, false, 0); - if ($thissection->uservisible) { - echo $this->course_section_cm_list($course, $thissection, 0); - echo $this->course_section_add_cm_control($course, $section, 0); - } - echo $this->section_footer(); - } - } - - if ($format->show_editor()) { - // Print stealth sections if present. - foreach ($modinfo->get_section_info_all() as $section => $thissection) { - if ($section <= $numsections or empty($modinfo->sections[$section])) { - // This is not stealth section or it is empty. - continue; - } - echo $this->stealth_section_header($section); - echo $this->course_section_cm_list($course, $thissection, 0); - echo $this->stealth_section_footer(); - } - - echo $endlist; - - echo $this->change_number_sections($course, 0); - } else { - echo $endlist; - } + 'or override render_content method to use a diferent template'); } /** - * Returns controls in the bottom of the page to increase/decrease number of sections - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * @param stdClass $course - * @param int|null $sectionreturn + * @deprecated since 4.0 - use core_course output components instead. */ protected function change_number_sections($course, $sectionreturn = null) { - debugging('Method change_number_sections is deprecated, please use' . - 'core_courseformat\\output\\local\\content\\addsection instead', DEBUG_DEVELOPER); - $format = course_get_format($course); - if ($sectionreturn) { - $format->set_section_number($sectionreturn); - } - $outputclass = $format->get_output_classname('content\\addsection'); - $widget = new $outputclass($format); - echo $this->render($widget); + throw new coding_exception('Method change_number_sections can not be used anymore. Please use' . + 'core_courseformat\\output\\local\\content\\addsection instead'); } /** - * Generate html for a section summary text - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * @param stdClass $section The course_section entry from DB - * @return string HTML to output. + * @deprecated since 4.0 - use core_course output components instead. */ protected function format_summary_text($section) { - debugging('Method format_summary_text is deprecated, please use' . - 'core_courseformat\output\\local\\content\\section\\summary::format_summary_text instead', DEBUG_DEVELOPER); - $format = course_get_format($section->course); - if (!($section instanceof section_info)) { - $modinfo = $format->get_modinfo(); - $section = $modinfo->get_section_info($section->section); - } - $summaryclass = $format->get_output_classname('content\\section\\summary'); - $summary = new $summaryclass($format, $section); - return $summary->format_summary_text(); + throw new coding_exception('Method format_summary_text can not be used anymore. Please use' . + 'core_courseformat\output\\local\\content\\section\\summary::format_summary_text instead'); } } diff --git a/course/format/renderer.php b/course/format/renderer.php deleted file mode 100644 index 33caed9e7dd..00000000000 --- a/course/format/renderer.php +++ /dev/null @@ -1,30 +0,0 @@ -. - -/** - * Legacy course format renderer file. - * - * This file exists only for legacy reasons. Most third party format - * plugins include this file to extend the course format renderer. Now all - * format renderers are located in core_courseformat\output and uses autoload. - * - * @deprecated since Moodle 4.0 MDL-72656 - * - * @package core_courseformat - * @copyright 2012 Dan Poltawski - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - * @since Moodle 2.3 - */ diff --git a/course/format/topics/renderer.php b/course/format/topics/renderer.php deleted file mode 100644 index 277aa1d4480..00000000000 --- a/course/format/topics/renderer.php +++ /dev/null @@ -1,26 +0,0 @@ -. - -/** - * Legacy file to aviod exceptions when formats require it. - * - * @deprecated since Moodle 4.0 MDL-72656 - * @package format_topics - * @copyright 2021 Ferran Recio - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); diff --git a/course/format/upgrade.txt b/course/format/upgrade.txt index 5e4c0233f9d..0aeb8026889 100644 --- a/course/format/upgrade.txt +++ b/course/format/upgrade.txt @@ -9,6 +9,43 @@ Overview of this plugin type at https://moodledev.io/docs/apis/plugintypes/forma replaced by core_courseformat\stateactions::section_move_after. * $CFG->linkcoursesections setting has been completely removed because it's not required anymore. From now on, sections will be always linked because a new page, section.php, has been created to display any single section. +* Final deprecation for: + - core_courseformat\output\section_renderer::section_edit_control_menu + - core_courseformat\output\section_renderer::section_right_content + - core_courseformat\output\section_renderer::section_left_content + - core_courseformat\output\section_renderer::section_header + - core_courseformat\output\section_renderer::section_footer + - core_courseformat\output\section_renderer::start_section_list + - core_courseformat\output\section_renderer::end_section_list + - core_courseformat\output\section_renderer::section_edit_control_items + - core_courseformat\output\section_renderer::section_summary + - core_courseformat\output\section_renderer::section_activity_summary + - core_courseformat\output\section_renderer::section_availability_message + - core_courseformat\output\section_renderer::section_availability + - core_courseformat\output\section_renderer::course_activity_clipboard + - core_courseformat\output\section_renderer::get_nav_links + - core_courseformat\output\section_renderer::stealth_section_header + - core_courseformat\output\section_renderer::stealth_section_footer + - core_courseformat\output\section_renderer::section_nav_selection + - core_courseformat\output\section_renderer::print_single_section_page + - core_courseformat\output\section_renderer::print_multiple_section_page + - core_courseformat\output\section_renderer::change_number_sections + - core_courseformat\output\section_renderer::format_summary_text + - core_course_renderer::course_section_cm_edit_actions + - core_course_renderer::is_cm_conditionally_hidden + - core_course_renderer::course_section_cm_name + - core_course_renderer::course_section_cm_classes + - core_course_renderer::course_section_cm_name_title + - core_course_renderer::course_section_cm_text + - core_course_renderer::availability_info + - core_course_renderer::course_section_cm_availability + - core_course_renderer::course_section_cm_list_item + - core_course_renderer::course_section_cm + - core_course_renderer::course_section_cm_list + - core_course\output\course_module_name + - course/format/renderer.php + - course/format/topics/renderer.php + - course/format/weeks/renderer.php === 4.3 === * New core_courseformat\output\activitybadge class that can be extended by any module to display content near the activity name. diff --git a/course/format/weeks/renderer.php b/course/format/weeks/renderer.php deleted file mode 100644 index f277b8f79ae..00000000000 --- a/course/format/weeks/renderer.php +++ /dev/null @@ -1,26 +0,0 @@ -. - -/** - * Legacy file to aviod exceptions when formats require it. - * - * @deprecated since Moodle 4.0 MDL-72656 - * @package format_weeks - * @copyright 2021 Ferran Recio - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); diff --git a/course/renderer.php b/course/renderer.php index 089feb89750..41b197f0702 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -1,5 +1,4 @@ A JS/CSS selector that can be used to find an cm node. - * If specified the owning node will be given the class 'action-menu-shown' when the action - * menu is being displayed. - * donotenhance => If set to true the action menu that gets displayed won't be enhanced by JS. - * @return string + * @deprecated since 4.0 - please do not use this function any more. */ public function course_section_cm_edit_actions($actions, cm_info $mod = null, $displayoptions = array()) { - global $CFG; - debugging( - 'course_section_cm_edit_actions is deprecated. Use core_courseformat\\output\\local\\content\\cm\\controlmenu instead.', - DEBUG_DEVELOPER + throw new coding_exception( + 'course_section_cm_edit_actions can not be used any more. Please, use ' . + 'core_courseformat\\output\\local\\content\\cm\\controlmenu instead.' ); - - if (empty($actions)) { - return ''; - } - - if (isset($displayoptions['ownerselector'])) { - $ownerselector = $displayoptions['ownerselector']; - } else if ($mod) { - $ownerselector = '#module-'.$mod->id; - } else { - debugging('You should upgrade your call to '.__FUNCTION__.' and provide $mod', DEBUG_DEVELOPER); - $ownerselector = 'li.activity'; - } - - $menu = new action_menu(); - $menu->set_owner_selector($ownerselector); - $menu->set_menu_trigger(get_string('edit')); - - foreach ($actions as $action) { - if ($action instanceof action_menu_link) { - $action->add_class('cm-edit-action'); - } - $menu->add($action); - } - $menu->attributes['class'] .= ' section-cm-edit-actions commands'; - - // Prioritise the menu ahead of all other actions. - $menu->prioritise = true; - - return $this->render($menu); } /** @@ -306,349 +263,98 @@ class core_course_renderer extends plugin_renderer_base { } /** - * Checks if course module has any conditions that may make it unavailable for - * all or some of the students - * - * @deprecated since Moodle 4.0 MDL-72656 - please do not use this function any more. - * - * @param cm_info $mod - * @return bool + * @deprecated since 4.0 - please do not use this function any more. */ public function is_cm_conditionally_hidden(cm_info $mod) { - global $CFG; - debugging( - 'is_cm_conditionally_hidden is deprecated. Use \core_availability\info_module::is_available_for_all instead', - DEBUG_DEVELOPER + throw new coding_exception( + 'is_cm_conditionally_hidden can not be used any more. Please, use ' . + '\core_availability\info_module::is_available_for_all instead' ); - - $conditionalhidden = false; - if (!empty($CFG->enableavailability)) { - $info = new \core_availability\info_module($mod); - $conditionalhidden = !$info->is_available_for_all(); - } - return $conditionalhidden; } /** - * Renders html to display a name with the link to the course module on a course page - * - * If module is unavailable for user but still needs to be displayed - * in the list, just the name is returned without a link - * - * Note, that for course modules that never have separate pages (i.e. labels) - * this function return an empty string - * - * @deprecated since Moodle 4.0 MDL-72656 - please do not use this function any more. - * - * @param cm_info $mod - * @param array $displayoptions - * @return string + * @deprecated since 4.0 - please do not use this function any more. */ public function course_section_cm_name(cm_info $mod, $displayoptions = array()) { - debugging( - 'course_section_cm_name is deprecated. Use core_courseformat\\output\\local\\content\\cm\\cmname class instead.', - DEBUG_DEVELOPER + + throw new coding_exception( + 'course_section_cm_name can not be used any more. Please, use ' . + 'core_courseformat\\output\\local\\content\\cm\\cmname class instead.' ); - - if (!$mod->is_visible_on_course_page() || !$mod->url) { - // Nothing to be displayed to the user. - return ''; - } - - list($linkclasses, $textclasses) = $this->course_section_cm_classes($mod); - $groupinglabel = $mod->get_grouping_label($textclasses); - - // Render element that allows to edit activity name inline. - $format = course_get_format($mod->course); - $cmnameclass = $format->get_output_classname('content\\cm\\cmname'); - // Mod inplace name editable. - $cmname = new $cmnameclass( - $format, - $mod->get_section_info(), - $mod, - null, - $displayoptions - ); - - $renderer = $format->get_renderer($this->page); - return $renderer->render($cmname) . $groupinglabel; } /** - * Returns the CSS classes for the activity name/content - * - * @deprecated since Moodle 4.0 MDL-72656 - please do not use this function any more. - * - * For items which are hidden, unavailable or stealth but should be displayed - * to current user ($mod->is_visible_on_course_page()), we show those as dimmed. - * Students will also see as dimmed activities names that are not yet available - * but should still be displayed (without link) with availability info. - * - * @param cm_info $mod - * @return array array of two elements ($linkclasses, $textclasses) + * @deprecated since 4.0 - please do not use this function any more. */ protected function course_section_cm_classes(cm_info $mod) { - debugging( - 'course_section_cm_classes is deprecated. Now it is part of core_courseformat\\output\\local\\content\\cm ', - DEBUG_DEVELOPER + throw new coding_exception( + 'course_section_cm_classes can not be used any more. Now it is part of core_courseformat\\output\\local\\content\\cm' ); - - $format = course_get_format($mod->course); - - $cmclass = $format->get_output_classname('content\\cm'); - $cmoutput = new $cmclass( - $format, - $mod->get_section_info(), - $mod, - ); - return [ - $cmoutput->get_link_classes(), - $cmoutput->get_text_classes(), - ]; } /** - * Renders html to display a name with the link to the course module on a course page - * - * If module is unavailable for user but still needs to be displayed - * in the list, just the name is returned without a link - * - * Note, that for course modules that never have separate pages (i.e. labels) - * this function return an empty string - * - * @deprecated since Moodle 4.0 MDL-72656 - please do not use this function any more. - * - * @param cm_info $mod - * @param array $displayoptions - * @return string + * @deprecated since 4.0 - please do not use this function any more. */ public function course_section_cm_name_title(cm_info $mod, $displayoptions = array()) { - debugging( - 'course_section_cm_name_title is deprecated. Use core_courseformat\\output\\local\\cm\\title class instead.', - DEBUG_DEVELOPER + throw new coding_exception( + 'course_section_cm_name_title can not be used any more. Please, use ' . + 'core_courseformat\\output\\local\\cm\\title class instead' ); - - $output = ''; - $url = $mod->url; - if (!$mod->is_visible_on_course_page() || !$url) { - // Nothing to be displayed to the user. - return $output; - } - - //Accessibility: for files get description via icon, this is very ugly hack! - $instancename = $mod->get_formatted_name(); - $altname = $mod->modfullname; - // Avoid unnecessary duplication: if e.g. a forum name already - // includes the word forum (or Forum, etc) then it is unhelpful - // to include that in the accessible description that is added. - if (false !== strpos(core_text::strtolower($instancename), - core_text::strtolower($altname))) { - $altname = ''; - } - // File type after name, for alphabetic lists (screen reader). - if ($altname) { - $altname = get_accesshide(' '.$altname); - } - - list($linkclasses, $textclasses) = $this->course_section_cm_classes($mod); - - // Get on-click attribute value if specified and decode the onclick - it - // has already been encoded for display (puke). - $onclick = htmlspecialchars_decode($mod->onclick, ENT_QUOTES); - - // Display link itself. - $instancename = html_writer::tag('span', $instancename . $altname, ['class' => 'instancename ml-1']); - - $imageicon = html_writer::empty_tag('img', ['src' => $mod->get_icon_url(), - 'class' => 'activityicon', 'alt' => '', 'role' => 'presentation', 'aria-hidden' => 'true']); - $imageicon = html_writer::tag('span', $imageicon, ['class' => 'activityiconcontainer courseicon']); - $activitylink = $imageicon . $instancename; - - if ($mod->uservisible) { - $output .= html_writer::link($url, $activitylink, array('class' => 'aalink' . $linkclasses, 'onclick' => $onclick)); - } else { - // We may be displaying this just in order to show information - // about visibility, without the actual link ($mod->is_visible_on_course_page()). - $output .= html_writer::tag('div', $activitylink, array('class' => $textclasses)); - } - return $output; } /** - * Renders html to display the module content on the course page (i.e. text of the labels) - * - * @deprecated since Moodle 4.0 MDL-72656 - please do not use this function any more. - * - * @param cm_info $mod - * @param array $displayoptions - * @return string + * @deprecated since 4.0 - please do not use this function any more. */ public function course_section_cm_text(cm_info $mod, $displayoptions = array()) { - debugging( - 'course_section_cm_text is deprecated. Now it is part of core_courseformat\\output\\local\\content\\cm ', - DEBUG_DEVELOPER + throw new coding_exception( + 'course_section_cm_text can not be used any more. Now it is part of core_courseformat\\output\\local\\content\\cm' ); - - $output = ''; - if (!$mod->is_visible_on_course_page()) { - // nothing to be displayed to the user - return $output; - } - $content = $mod->get_formatted_content(array('overflowdiv' => true, 'noclean' => true)); - list($linkclasses, $textclasses) = $this->course_section_cm_classes($mod); - if ($mod->url && $mod->uservisible) { - if ($content) { - // If specified, display extra content after link. - $output = html_writer::tag('div', $content, array('class' => - trim('contentafterlink ' . $textclasses))); - } - } else { - $groupinglabel = $mod->get_grouping_label($textclasses); - - // No link, so display only content. - $output = html_writer::tag('div', $content . $groupinglabel, - array('class' => 'contentwithoutlink ' . $textclasses)); - } - return $output; } /** - * Displays availability info for a course section or course module - * - * @deprecated since Moodle 4.0 MDL-72656 - please do not use this function any more. - * @param string $text - * @param string $additionalclasses - * @return string + * @deprecated since 4.0 - please do not use this function any more. */ public function availability_info($text, $additionalclasses = '') { - debugging( - 'availability_info is deprecated. Use core_courseformat\\output\\local\\content\\section\\availability instead', - DEBUG_DEVELOPER + throw new coding_exception( + 'availability_info can not be used any more. Please, use ' . + 'core_courseformat\\output\\local\\content\\section\\availability instead' ); - - $data = ['text' => $text, 'classes' => $additionalclasses]; - $additionalclasses = array_filter(explode(' ', $additionalclasses)); - - if (in_array('ishidden', $additionalclasses)) { - $data['ishidden'] = 1; - - } else if (in_array('isstealth', $additionalclasses)) { - $data['isstealth'] = 1; - - } else if (in_array('isrestricted', $additionalclasses)) { - $data['isrestricted'] = 1; - - if (in_array('isfullinfo', $additionalclasses)) { - $data['isfullinfo'] = 1; - } - } - - return $this->render_from_template('core/availability_info', $data); } /** - * Renders HTML to show course module availability information (for someone who isn't allowed - * to see the activity itself, or for staff) - * - * @deprecated since Moodle 4.0 MDL-72656 - please do not use this function any more. - * @param cm_info $mod - * @param array $displayoptions - * @return string + * @deprecated since 4.0 - please do not use this function any more. */ public function course_section_cm_availability(cm_info $mod, $displayoptions = array()) { - debugging( - 'course_section_cm_availability is deprecated. Use core_courseformat\\output\\local\\content\\cm\\availability instead', - DEBUG_DEVELOPER + throw new coding_exception( + 'course_section_cm_availability can not be used any more. Please, use ' . + 'core_courseformat\\output\\local\\content\\cm\\availability instead' ); - - $format = course_get_format($mod->course); - - $availabilityclass = $format->get_output_classname('content\\cm\\availability'); - $availability = new $availabilityclass( - $format, - $mod->get_section_info(), - $mod, - ); - $renderer = $format->get_renderer($this->page); - return $renderer->render($availability); } /** - * Renders HTML to display one course module for display within a section. - * * @deprecated since 4.0 - use core_course output components or course_format::course_section_updated_cm_item instead. - * - * This function calls: - * {@link core_course_renderer::course_section_cm()} - * - * @param stdClass $course - * @param completion_info $completioninfo - * @param cm_info $mod - * @param int|null $sectionreturn - * @param array $displayoptions - * @return String */ public function course_section_cm_list_item($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = []) { - debugging( - 'course_section_cm_list_item is deprecated. Use renderer course_section_updated_cm_item instead', - DEBUG_DEVELOPER + throw new coding_exception( + 'course_section_cm_list_item can not be used any more. Please, use renderer course_section_updated_cm_item instead' ); - - $output = ''; - if ($modulehtml = $this->course_section_cm($course, $completioninfo, $mod, $sectionreturn, $displayoptions)) { - $modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->extraclasses; - $output .= html_writer::tag('li', $modulehtml, array('class' => $modclasses, 'id' => 'module-' . $mod->id)); - } - return $output; } /** - * Renders HTML to display one course module in a course section - * - * This includes link, content, availability, completion info and additional information - * that module type wants to display (i.e. number of unread forum posts) - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * @param stdClass $course - * @param completion_info $completioninfo - * @param cm_info $mod - * @param int|null $sectionreturn - * @param array $displayoptions - * @return string + * @deprecated since 4.0 - use core_course output components instead. */ public function course_section_cm($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = []) { - debugging( - 'course_section_cm is deprecated. Use core_courseformat\\output\\content\\cm output class instead.', - DEBUG_DEVELOPER + throw new coding_exception( + 'course_section_cm can not be used any more. Please, use core_courseformat\\output\\content\\cm output class instead' ); - - if (!$mod->is_visible_on_course_page()) { - return ''; - } - - $format = course_get_format($course); - $modinfo = $format->get_modinfo(); - // Output renderers works only with real section_info objects. - if ($sectionreturn) { - $format->set_section_number($sectionreturn); - } - $section = $modinfo->get_section_info($format->get_section_number()); - - $cmclass = $format->get_output_classname('content\\cm'); - $cm = new $cmclass($format, $section, $mod, $displayoptions); - // The course outputs works with format renderers, not with course renderers. - $renderer = $format->get_renderer($this->page); - $data = $cm->export_for_template($renderer); - return $this->output->render_from_template('core_courseformat/local/content/cm', $data); } /** @@ -680,87 +386,14 @@ class core_course_renderer extends plugin_renderer_base { } /** - * Renders HTML to display a list of course modules in a course section - * Also displays "move here" controls in Javascript-disabled mode. - * - * @deprecated since 4.0 MDL-72656 - use core_course output components instead. - * - * This function calls {@link core_course_renderer::course_section_cm()} - * - * @param stdClass $course course object - * @param int|stdClass|section_info $section relative section number or section object - * @param int $sectionreturn section number to return to - * @param int $displayoptions - * @return void + * @deprecated since 4.0 - use core_course output components instead. */ public function course_section_cm_list($course, $section, $sectionreturn = null, $displayoptions = []) { - global $USER; - debugging('course_section_cm_list is deprecated. Use core_courseformat\\output\\local\\content\\section\\cmlist '. - 'classes instead.', DEBUG_DEVELOPER); - - $output = ''; - - $format = course_get_format($course); - $modinfo = $format->get_modinfo(); - - if (is_object($section)) { - $section = $modinfo->get_section_info($section->section); - } else { - $section = $modinfo->get_section_info($section); - } - $completioninfo = new completion_info($course); - - // check if we are currently in the process of moving a module with JavaScript disabled - $ismoving = $format->show_editor() && ismoving($course->id); - - if ($ismoving) { - $strmovefull = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'")); - } - - // Get the list of modules visible to user (excluding the module being moved if there is one) - $moduleshtml = []; - if (!empty($modinfo->sections[$section->section])) { - foreach ($modinfo->sections[$section->section] as $modnumber) { - $mod = $modinfo->cms[$modnumber]; - - if ($ismoving and $mod->id == $USER->activitycopy) { - // do not display moving mod - continue; - } - - if ($modulehtml = $this->course_section_cm_list_item($course, - $completioninfo, $mod, $sectionreturn, $displayoptions)) { - $moduleshtml[$modnumber] = $modulehtml; - } - } - } - - $sectionoutput = ''; - if (!empty($moduleshtml) || $ismoving) { - foreach ($moduleshtml as $modnumber => $modulehtml) { - if ($ismoving) { - $movingurl = new moodle_url('/course/mod.php', array('moveto' => $modnumber, 'sesskey' => sesskey())); - $sectionoutput .= html_writer::tag('li', - html_writer::link($movingurl, '', array('title' => $strmovefull, 'class' => 'movehere')), - array('class' => 'movehere')); - } - - $sectionoutput .= $modulehtml; - } - - if ($ismoving) { - $movingurl = new moodle_url('/course/mod.php', array('movetosection' => $section->id, 'sesskey' => sesskey())); - $sectionoutput .= html_writer::tag('li', - html_writer::link($movingurl, '', array('title' => $strmovefull, 'class' => 'movehere')), - array('class' => 'movehere')); - } - } - - // Always output the section module list. - $output .= html_writer::tag('ul', $sectionoutput, array('class' => 'section img-text')); - - return $output; + throw new coding_exception( + 'course_section_cm_list can not be used any more. Please, use ' . + 'core_courseformat\\output\\local\\content\\section\\cmlist class instead' + ); } /** diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index b0f33079c36..c0d687ba78f 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -846,9 +846,6 @@ function print_section_add_menus() { /** * @deprecated since 2.5. Please use: - * $courserenderer = $PAGE->get_renderer('core', 'course'); - * $actions = course_get_cm_edit_actions($mod, $indent, $section); - * return ' ' . $courserenderer->course_section_cm_edit_actions($actions); */ function make_editing_buttons() { throw new coding_exception('Function make_editing_buttons() is removed, please see PHPdocs in '. diff --git a/lib/templates/availability_info.mustache b/lib/templates/availability_info.mustache deleted file mode 100644 index a56f309c42a..00000000000 --- a/lib/templates/availability_info.mustache +++ /dev/null @@ -1,63 +0,0 @@ -{{! - This file is part of Moodle - http://moodle.org/ - - Moodle is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - Moodle is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Moodle. If not, see . -}} -{{! - @template core/availability_info - - @deprecated since Moodle 3.9 MDL-68612 - Use core_courseformat\\output\\local\\content\\section\\availability instead - - Renders the availability info on the course outline page. - - Availability info can be displayed for activity modules or whole course - sections. Activity modules can be either hidden from students, or available - but not shown on course page (stealth), or the access can be restricted by - configured conditions. Sections can be hidden. - - Classes required for JS: - * none - - Data attributes required for JS: - * none - - Context variables required for this template: - * classes String list of CSS classes for the wrapping element - * text HTML formatted text with the actual availability information - * ishidden Boolean flag indiciating that the item is hidden from students - * isstealth Boolean flag indicating that the item is in stealth mode - * isrestricted Boolean flag indicating that restricted access conditions apply - * isfullinfo Boolean flag indicating that the full list of restricted - access conditions is displayed (aka teacher's view). - - Example context (json): - { - "classes": "", - "text": "Not available unless:
  • It is on or after 8 June 2012
", - "ishidden": 0, - "isstealth": 0, - "isrestricted": 1, - "isfullinfo": 1 - } -}} -{{#text}} -
- {{^isrestricted}} - {{{text}}} - {{/isrestricted}} - {{#isrestricted}} - {{#str}}restricted, core{{/str}} {{{text}}} - {{/isrestricted}} -
-{{/text}}