mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-82393 course: Deprecate the $course argument in group_selector
Deprecates the $course parameter in the constructor of the core_course\output\actionbar\group_selector class. This parameter is no longer used, as the $course object can now be obtained through the $context class property. Additionaly, the $course class property has been removed in accordance with this change.
This commit is contained in:
parent
02755c4f95
commit
b7481cf4aa
6 changed files with 32 additions and 18 deletions
12
.upgradenotes/MDL-82393-2024071205253416.yml
Normal file
12
.upgradenotes/MDL-82393-2024071205253416.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
issueNumber: MDL-82393
|
||||||
|
notes:
|
||||||
|
core_course:
|
||||||
|
- message: >-
|
||||||
|
The $course parameter in the constructor of the
|
||||||
|
core_course\output\actionbar\group_selector class has been deprecated
|
||||||
|
and is no longer used.
|
||||||
|
type: deprecated
|
||||||
|
- message: >-
|
||||||
|
The $course class property in the
|
||||||
|
core_course\output\actionbar\group_selector class has been removed.
|
||||||
|
type: removed
|
|
@ -28,11 +28,6 @@ use stdClass;
|
||||||
*/
|
*/
|
||||||
class group_selector extends comboboxsearch {
|
class group_selector extends comboboxsearch {
|
||||||
|
|
||||||
/**
|
|
||||||
* @var stdClass The course object.
|
|
||||||
*/
|
|
||||||
protected $course;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var stdClass The context object.
|
* @var stdClass The context object.
|
||||||
*/
|
*/
|
||||||
|
@ -41,11 +36,16 @@ class group_selector extends comboboxsearch {
|
||||||
/**
|
/**
|
||||||
* The class constructor.
|
* The class constructor.
|
||||||
*
|
*
|
||||||
* @param stdClass $course The course object.
|
* @param null|stdClass $course This parameter has been deprecated since Moodle 4.5 and should not be used anymore.
|
||||||
* @param stdClass $context The context object.
|
* @param stdClass $context The context object.
|
||||||
*/
|
*/
|
||||||
public function __construct(stdClass $course, stdClass $context) {
|
public function __construct(null|stdClass $course = null, stdClass $context) {
|
||||||
$this->course = $course;
|
if ($course !== null) {
|
||||||
|
debugging(
|
||||||
|
'The course argument has been deprecated. Please remove it from your group_selector class instances.',
|
||||||
|
DEBUG_DEVELOPER,
|
||||||
|
);
|
||||||
|
}
|
||||||
$this->context = $context;
|
$this->context = $context;
|
||||||
parent::__construct(false, $this->get_button_content(), $this->get_dropdown_content(), 'group-search',
|
parent::__construct(false, $this->get_button_content(), $this->get_dropdown_content(), 'group-search',
|
||||||
'groupsearchwidget', 'groupsearchdropdown overflow-auto', null, true, $this->get_label(), 'group',
|
'groupsearchwidget', 'groupsearchdropdown overflow-auto', null, true, $this->get_label(), 'group',
|
||||||
|
@ -69,7 +69,7 @@ class group_selector extends comboboxsearch {
|
||||||
if ($activegroup) {
|
if ($activegroup) {
|
||||||
$group = groups_get_group($activegroup);
|
$group = groups_get_group($activegroup);
|
||||||
$buttondata['selectedgroup'] = format_string($group->name, true,
|
$buttondata['selectedgroup'] = format_string($group->name, true,
|
||||||
['context' => \context_course::instance($this->course->id)]);
|
['context' => $this->context->get_course_context()]);
|
||||||
} else if ($activegroup === 0) {
|
} else if ($activegroup === 0) {
|
||||||
$buttondata['selectedgroup'] = get_string('allparticipants');
|
$buttondata['selectedgroup'] = get_string('allparticipants');
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ class group_selector extends comboboxsearch {
|
||||||
global $OUTPUT;
|
global $OUTPUT;
|
||||||
|
|
||||||
return $OUTPUT->render_from_template('core_group/comboboxsearch/searchbody', [
|
return $OUTPUT->render_from_template('core_group/comboboxsearch/searchbody', [
|
||||||
'courseid' => $this->course->id,
|
'courseid' => $this->context->get_course_context()->instanceid,
|
||||||
'currentvalue' => optional_param('groupsearchvalue', '', PARAM_NOTAGS),
|
'currentvalue' => optional_param('groupsearchvalue', '', PARAM_NOTAGS),
|
||||||
'instance' => rand(),
|
'instance' => rand(),
|
||||||
]);
|
]);
|
||||||
|
@ -112,6 +112,7 @@ class group_selector extends comboboxsearch {
|
||||||
|
|
||||||
$canaccessallgroups = has_capability('moodle/site:accessallgroups', $this->context);
|
$canaccessallgroups = has_capability('moodle/site:accessallgroups', $this->context);
|
||||||
$userid = $this->get_group_mode() == VISIBLEGROUPS || $canaccessallgroups ? 0 : $USER->id;
|
$userid = $this->get_group_mode() == VISIBLEGROUPS || $canaccessallgroups ? 0 : $USER->id;
|
||||||
|
$course = get_course($this->context->get_course_context()->instanceid);
|
||||||
// Based on the current context level, retrieve the correct grouping ID and specify whether only groups with the
|
// Based on the current context level, retrieve the correct grouping ID and specify whether only groups with the
|
||||||
// participation field set to true should be returned.
|
// participation field set to true should be returned.
|
||||||
if ($this->context->contextlevel === CONTEXT_MODULE) {
|
if ($this->context->contextlevel === CONTEXT_MODULE) {
|
||||||
|
@ -120,12 +121,12 @@ class group_selector extends comboboxsearch {
|
||||||
$participationonly = true;
|
$participationonly = true;
|
||||||
} else {
|
} else {
|
||||||
$cm = null;
|
$cm = null;
|
||||||
$groupingid = $this->course->defaultgroupingid;
|
$groupingid = $course->defaultgroupingid;
|
||||||
$participationonly = false;
|
$participationonly = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$allowedgroups = groups_get_all_groups(
|
$allowedgroups = groups_get_all_groups(
|
||||||
courseid: $this->course->id,
|
courseid: $course->id,
|
||||||
userid: $userid,
|
userid: $userid,
|
||||||
groupingid: $groupingid,
|
groupingid: $groupingid,
|
||||||
participationonly: $participationonly
|
participationonly: $participationonly
|
||||||
|
@ -134,7 +135,7 @@ class group_selector extends comboboxsearch {
|
||||||
if ($cm) {
|
if ($cm) {
|
||||||
return groups_get_activity_group($cm, true, $allowedgroups);
|
return groups_get_activity_group($cm, true, $allowedgroups);
|
||||||
}
|
}
|
||||||
return groups_get_course_group($this->course, true, $allowedgroups);
|
return groups_get_course_group($course, true, $allowedgroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,6 +148,7 @@ class group_selector extends comboboxsearch {
|
||||||
$cm = get_coursemodule_from_id(false, $this->context->instanceid);
|
$cm = get_coursemodule_from_id(false, $this->context->instanceid);
|
||||||
return groups_get_activity_groupmode($cm);
|
return groups_get_activity_groupmode($cm);
|
||||||
}
|
}
|
||||||
return $this->course->groupmode;
|
$course = get_course($this->context->instanceid);
|
||||||
|
return $course->groupmode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ class action_bar extends \core_grades\output\action_bar {
|
||||||
if ($course->groupmode) {
|
if ($course->groupmode) {
|
||||||
$actionbarrenderer = $PAGE->get_renderer('core_course', 'actionbar');
|
$actionbarrenderer = $PAGE->get_renderer('core_course', 'actionbar');
|
||||||
$data['groupselector'] = $actionbarrenderer->render(
|
$data['groupselector'] = $actionbarrenderer->render(
|
||||||
new \core_course\output\actionbar\group_selector($course, $this->context));
|
new \core_course\output\actionbar\group_selector(null, $this->context));
|
||||||
}
|
}
|
||||||
|
|
||||||
$resetlink = new moodle_url('/grade/report/grader/index.php', ['id' => $courseid]);
|
$resetlink = new moodle_url('/grade/report/grader/index.php', ['id' => $courseid]);
|
||||||
|
|
|
@ -147,7 +147,7 @@ class singleview extends grade_report {
|
||||||
global $PAGE;
|
global $PAGE;
|
||||||
|
|
||||||
$renderer = $PAGE->get_renderer('core_course', 'actionbar');
|
$renderer = $PAGE->get_renderer('core_course', 'actionbar');
|
||||||
return $renderer->render(new \core_course\output\actionbar\group_selector($course, $PAGE->context));
|
return $renderer->render(new \core_course\output\actionbar\group_selector(null, $PAGE->context));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -94,7 +94,7 @@ class action_bar extends \core_grades\output\action_bar {
|
||||||
$userreportrenderer = $PAGE->get_renderer('gradereport_user');
|
$userreportrenderer = $PAGE->get_renderer('gradereport_user');
|
||||||
$course = get_course($courseid);
|
$course = get_course($courseid);
|
||||||
if ($course->groupmode) {
|
if ($course->groupmode) {
|
||||||
$groupselector = new \core_course\output\actionbar\group_selector($course, $this->context);
|
$groupselector = new \core_course\output\actionbar\group_selector(null, $this->context);
|
||||||
$data['groupselector'] = $PAGE->get_renderer('core_course', 'actionbar')->render($groupselector);
|
$data['groupselector'] = $PAGE->get_renderer('core_course', 'actionbar')->render($groupselector);
|
||||||
}
|
}
|
||||||
$data['userselector'] = [
|
$data['userselector'] = [
|
||||||
|
|
|
@ -104,7 +104,7 @@ class grading_actionmenu implements templatable, renderable {
|
||||||
|
|
||||||
if (groups_get_activity_groupmode($cm, $course)) {
|
if (groups_get_activity_groupmode($cm, $course)) {
|
||||||
$data['groupselector'] = $actionbarrenderer->render(
|
$data['groupselector'] = $actionbarrenderer->render(
|
||||||
new \core_course\output\actionbar\group_selector($course, $PAGE->context));
|
new \core_course\output\actionbar\group_selector(null, $PAGE->context));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groups_get_activity_group($cm)) {
|
if (groups_get_activity_group($cm)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue