From 3070ef816167f379ea9692248db9c65cb794537d Mon Sep 17 00:00:00 2001 From: Daniel Ziegenberg Date: Mon, 10 Feb 2025 13:35:25 +0100 Subject: [PATCH 1/4] MDL-78926 course: Removed core_course\output\activity_information Signed-off-by: Daniel Ziegenberg --- .upgradenotes/MDL-78926-2025021013150477.yml | 5 + .../classes/output/activity_information.php | 209 ------------------ 2 files changed, 5 insertions(+), 209 deletions(-) create mode 100644 .upgradenotes/MDL-78926-2025021013150477.yml delete mode 100644 course/classes/output/activity_information.php diff --git a/.upgradenotes/MDL-78926-2025021013150477.yml b/.upgradenotes/MDL-78926-2025021013150477.yml new file mode 100644 index 00000000000..3e20d160c7e --- /dev/null +++ b/.upgradenotes/MDL-78926-2025021013150477.yml @@ -0,0 +1,5 @@ +issueNumber: MDL-78926 +notes: + core_course: + - message: Final removal of core_course\output\activity_information + type: removed diff --git a/course/classes/output/activity_information.php b/course/classes/output/activity_information.php deleted file mode 100644 index 779cc91b797..00000000000 --- a/course/classes/output/activity_information.php +++ /dev/null @@ -1,209 +0,0 @@ -. - -/** - * File containing the class activity information renderable. - * - * @package core_course - * @copyright 2021 Jun Pataleta - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -namespace core_course\output; - -defined('MOODLE_INTERNAL') || die(); - -use cm_info; -use completion_info; -use context; -use core\activity_dates; -use core_availability\info; -use core_completion\cm_completion_details; -use core_user; -use core_user\fields; -use renderable; -use renderer_base; -use stdClass; -use templatable; - -/** - * The activity information renderable class. - * - * @deprecated since Moodle 4.3 MDL-78744 - * @todo MDL-78926 This class will be deleted in Moodle 4.7 - * - * @package core_course - * @copyright 2021 Jun Pataleta - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class activity_information implements renderable, templatable { - - /** @var cm_info The course module information. */ - protected $cminfo = null; - - /** @var array The array of relevant dates for this activity. */ - protected $activitydates = []; - - /** @var cm_completion_details The user's completion details for this activity. */ - protected $cmcompletion = null; - - /** - * Constructor. - * - * @deprecated since Moodle 4.3 - * - * @param cm_info $cminfo The course module information. - * @param cm_completion_details $cmcompletion The course module information. - * @param array $activitydates The activity dates. - */ - public function __construct(cm_info $cminfo, cm_completion_details $cmcompletion, array $activitydates) { - debugging('activity_information class is deprecated. Use activity_completion and activity_dates instead.', DEBUG_DEVELOPER); - $this->cminfo = $cminfo; - $this->cmcompletion = $cmcompletion; - $this->activitydates = $activitydates; - } - - /** - * Export this data so it can be used as the context for a mustache template. - * - * @deprecated since Moodle 4.3 - * - * @param renderer_base $output Renderer base. - * @return stdClass - */ - public function export_for_template(renderer_base $output): stdClass { - debugging('activity_information class is deprecated. Use activity_completion and activity_dates instead.', DEBUG_DEVELOPER); - - $data = $this->build_completion_data(); - - $data->cmid = $this->cminfo->id; - $data->activityname = $this->cminfo->get_formatted_name(); - $this->build_dates_data($data); - $data->hasdates = !empty($this->activitydates); - - return $data; - } - - /** - * Builds the dates data for export. - * - * @param stdClass $data - */ - protected function build_dates_data(stdClass $data): void { - foreach ($this->activitydates as $date) { - if (empty($date['relativeto'])) { - $date['datestring'] = userdate($date['timestamp'], get_string('strftimedaydatetime', 'core_langconfig')); - } else { - $diffstr = get_time_interval_string($date['timestamp'], $date['relativeto']); - if ($date['timestamp'] >= $date['relativeto']) { - $date['datestring'] = get_string('relativedatessubmissionduedateafter', 'core_course', - ['datediffstr' => $diffstr]); - } else { - $date['datestring'] = get_string('relativedatessubmissionduedatebefore', 'core_course', - ['datediffstr' => $diffstr]); - } - } - $data->activitydates[] = $date; - } - } - - /** - * Builds the completion data for export. - * - * @return stdClass - */ - protected function build_completion_data(): stdClass { - global $CFG; - - $data = new stdClass(); - - $data->hascompletion = $this->cmcompletion->has_completion(); - $data->isautomatic = $this->cmcompletion->is_automatic(); - $data->ismanual = $this->cmcompletion->is_manual(); - $data->showmanualcompletion = $this->cmcompletion->show_manual_completion(); - - // Get the name of the user overriding the completion condition, if available. - $data->overrideby = null; - $overrideby = $this->cmcompletion->overridden_by(); - $overridebyname = null; - if (!empty($overrideby)) { - $userfields = fields::for_name(); - $overridebyrecord = core_user::get_user($overrideby, 'id ' . $userfields->get_sql()->selects, MUST_EXIST); - $data->overrideby = fullname($overridebyrecord); - } - - // We'll show only the completion conditions and not the completion status if we're not tracking completion for this user - // (e.g. a teacher, admin). - $data->istrackeduser = $this->cmcompletion->is_tracked_user(); - - // Overall completion states. - $overallcompletion = $this->cmcompletion->get_overall_completion(); - $data->overallcomplete = $overallcompletion == COMPLETION_COMPLETE; - $data->overallincomplete = $overallcompletion == COMPLETION_INCOMPLETE; - - // Set an accessible description for manual completions with overridden completion state. - if (!$data->isautomatic && $data->overrideby) { - $setbydata = (object)[ - 'activityname' => $this->cminfo->get_formatted_name(), - 'setby' => $data->overrideby, - ]; - $setbylangkey = $data->overallcomplete ? 'completion_setby:manual:done' : 'completion_setby:manual:markdone'; - $data->accessibledescription = get_string($setbylangkey, 'course', $setbydata); - } - - // Whether the completion of this activity controls the availability of other activities/sections in the course. - $data->withavailability = false; - $course = $this->cminfo->get_course(); - // An activity with manual completion tracking which is used to enable access to other activities/sections in - // the course needs to refresh the page after having its completion state toggled. This withavailability flag will enable - // this functionality on the course homepage. Otherwise, the completion toggling will just happen normally via ajax. - if ($this->cmcompletion->has_completion() && !$this->cmcompletion->is_automatic()) { - $data->withavailability = !empty($CFG->enableavailability) && info::completion_value_used($course, $this->cminfo->id); - } - - // Whether this activity is visible to the user. If not, completion information will not be shown. - $data->uservisible = $this->cminfo->uservisible; - - // Build automatic completion details. - $details = []; - foreach ($this->cmcompletion->get_details() as $key => $detail) { - // Set additional attributes for the template. - $detail->key = $key; - $detail->statuscomplete = in_array($detail->status, [COMPLETION_COMPLETE, COMPLETION_COMPLETE_PASS]); - $detail->statuscompletefail = $detail->status == COMPLETION_COMPLETE_FAIL; - // This is not used by core themes but may be needed in custom themes. - $detail->statuscompletepass = $detail->status == COMPLETION_COMPLETE_PASS; - $detail->statusincomplete = $detail->status == COMPLETION_INCOMPLETE; - - // Add an accessible description to be used for title and aria-label attributes for overridden completion details. - if ($data->overrideby) { - $setbydata = (object)[ - 'condition' => $detail->description, - 'setby' => $data->overrideby, - ]; - $overridestatus = $detail->statuscomplete ? 'done' : 'todo'; - $detail->accessibledescription = get_string('completion_setby:auto:' . $overridestatus, 'course', $setbydata); - } - - // We don't need the status in the template. - unset($detail->status); - - $details[] = $detail; - } - $data->completiondetails = $details; - - return $data; - } -} From e405cf89a920efc91d7bfb720638586cf94c385f Mon Sep 17 00:00:00 2001 From: Daniel Ziegenberg Date: Mon, 10 Feb 2025 14:00:57 +0100 Subject: [PATCH 2/4] MDL-78926 course: Final deprecation of render_activity_information Signed-off-by: Daniel Ziegenberg --- .upgradenotes/MDL-78926-2025021013150477.yml | 2 ++ course/renderer.php | 14 +++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.upgradenotes/MDL-78926-2025021013150477.yml b/.upgradenotes/MDL-78926-2025021013150477.yml index 3e20d160c7e..d7df7861502 100644 --- a/.upgradenotes/MDL-78926-2025021013150477.yml +++ b/.upgradenotes/MDL-78926-2025021013150477.yml @@ -3,3 +3,5 @@ notes: core_course: - message: Final removal of core_course\output\activity_information type: removed + - message: Final deprecation of core_course_renderer\render_activity_information() + type: removed diff --git a/course/renderer.php b/course/renderer.php index 3d8b7e5f5ae..661a4b73a55 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -1505,19 +1505,11 @@ class core_course_renderer extends plugin_renderer_base { } /** - * Renders the activity information. - * - * Defer to template. - * * @deprecated since Moodle 4.3 MDL-78744 - * @todo MDL-78926 This method will be deleted in Moodle 4.7 - * @param \core_course\output\activity_information $page - * @return string html for the page */ - public function render_activity_information(\core_course\output\activity_information $page) { - debugging('render_activity_information method is deprecated.', DEBUG_DEVELOPER); - $data = $page->export_for_template($this->output); - return $this->output->render_from_template('core_course/activity_info', $data); + #[\core\attribute\deprecated(null, since: '4.3', mdl: 'MDL-78744', final: true)] + public function render_activity_information() { + \core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]); } /** From be4b3e3d03a2d79e68321587c7ea99fc49912a71 Mon Sep 17 00:00:00 2001 From: Daniel Ziegenberg Date: Mon, 10 Feb 2025 14:02:32 +0100 Subject: [PATCH 3/4] MDL-78926 core: Final deprecation of activity_information Signed-off-by: Daniel Ziegenberg --- .upgradenotes/MDL-78926-2025021013150477.yml | 3 +++ lib/classes/output/core_renderer.php | 21 +++----------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/.upgradenotes/MDL-78926-2025021013150477.yml b/.upgradenotes/MDL-78926-2025021013150477.yml index d7df7861502..6c65af8a411 100644 --- a/.upgradenotes/MDL-78926-2025021013150477.yml +++ b/.upgradenotes/MDL-78926-2025021013150477.yml @@ -5,3 +5,6 @@ notes: type: removed - message: Final deprecation of core_course_renderer\render_activity_information() type: removed + core: + - message: Final deprecation of core_renderer\activity_information() + type: removed diff --git a/lib/classes/output/core_renderer.php b/lib/classes/output/core_renderer.php index 99a156e0f2c..36ae356c4f5 100644 --- a/lib/classes/output/core_renderer.php +++ b/lib/classes/output/core_renderer.php @@ -23,7 +23,6 @@ use core_block\output\block_contents; use core_block\output\block_move_target; use core_completion\cm_completion_details; use core\context; -use core_course\output\activity_information; use core_tag\output\taglist; use core_text; use core_useragent; @@ -462,25 +461,11 @@ class core_renderer extends renderer_base { } /** - * Returns information about an activity. - * * @deprecated since Moodle 4.3 MDL-78744 - * @todo MDL-78926 This method will be deleted in Moodle 4.7 - * @param cm_info $cminfo The course module information. - * @param cm_completion_details $completiondetails The completion details for this activity module. - * @param array $activitydates The dates for this activity module. - * @return string the activity information HTML. - * @throws coding_exception */ - public function activity_information(cm_info $cminfo, cm_completion_details $completiondetails, array $activitydates): string { - debugging('activity_information method is deprecated.', DEBUG_DEVELOPER); - if (!$completiondetails->has_completion() && empty($activitydates)) { - // No need to render the activity information when there's no completion info and activity dates to show. - return ''; - } - $activityinfo = new activity_information($cminfo, $completiondetails, $activitydates); - $renderer = $this->page->get_renderer('core', 'course'); - return $renderer->render($activityinfo); + #[\core\attribute\deprecated(null, since: '4.3', mdl: 'MDL-78744', final: true)] + public function activity_information() { + \core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]); } /** From 9c832095358161e6b135a2dcc6ee05692140c537 Mon Sep 17 00:00:00 2001 From: Daniel Ziegenberg Date: Mon, 10 Feb 2025 14:03:17 +0100 Subject: [PATCH 4/4] MDL-78926 wiki: Final deprecation of mod_wiki_renderer\wiki_info() Signed-off-by: Daniel Ziegenberg --- .upgradenotes/MDL-78926-2025021013150477.yml | 3 +++ mod/wiki/renderer.php | 25 +++----------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/.upgradenotes/MDL-78926-2025021013150477.yml b/.upgradenotes/MDL-78926-2025021013150477.yml index 6c65af8a411..d5405504471 100644 --- a/.upgradenotes/MDL-78926-2025021013150477.yml +++ b/.upgradenotes/MDL-78926-2025021013150477.yml @@ -8,3 +8,6 @@ notes: core: - message: Final deprecation of core_renderer\activity_information() type: removed + mod_wiki: + - message: Final deprecation of mod_wiki_renderer\wiki_info() + type: removed diff --git a/mod/wiki/renderer.php b/mod/wiki/renderer.php index dcd68384dbf..514d2794e95 100644 --- a/mod/wiki/renderer.php +++ b/mod/wiki/renderer.php @@ -236,30 +236,11 @@ class mod_wiki_renderer extends plugin_renderer_base { } /** - * Print the wiki activity information and intro - * - * @return string - * @deprecated since 4.0. Now handled in PAGE's activity header + * @deprecated since Moodle 4.0 MDL-72413. Now handled in PAGE's activity header */ + #[\core\attribute\deprecated(null, since: '4.3', mdl: 'MDL-72413', final: true)] public function wiki_info() { - global $USER; - - debugging( - 'wiki_info() is deprecated. Output is handled within the $PAGE->activityheader instead.', - DEBUG_DEVELOPER - ); - - // Display any activity information (eg completion requirements / dates). - $cminfo = cm_info::create($this->page->cm); - $completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id); - $activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id); - $info = $this->output->activity_information($cminfo, $completiondetails, $activitydates); - - // Add the rest of the wiki info. - $info .= $this->output->box(format_module_intro('wiki', - $this->page->activityrecord, $this->page->cm->id), 'generalbox', 'intro'); - - return $info; + \core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]); } public function tabs($page, $tabitems, $options) {