diff --git a/.upgradenotes/MDL-82157-2024061105175092.yml b/.upgradenotes/MDL-82157-2024061105175092.yml new file mode 100644 index 00000000000..0f72147b766 --- /dev/null +++ b/.upgradenotes/MDL-82157-2024061105175092.yml @@ -0,0 +1,7 @@ +issueNumber: MDL-82157 +notes: + core: + - message: >- + The following method has been deprecated and should not be used any + longer: `print_grade_menu`. + type: deprecated diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 77f7dacceb4..bff47b7e1e3 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -3313,3 +3313,51 @@ function search_generate_text_SQL() { function disable_output_buffering(): void { \core\deprecation::emit_deprecation_if_present(__FUNCTION__); } + + +/** + * Prints a grade menu (as part of an existing form) with help showing all possible numerical grades and scales. + * + * @todo Finish documenting this function + * @todo Deprecate: this is only used in a few contrib modules + * + * @param int $courseid The course ID + * @param string $name + * @param string $current + * @param boolean $includenograde Include those with no grades + * @param boolean $return If set to true returns rather than echo's + * @return string|bool|null Depending on value of $return + * @deprecated Since Moodle 4.5 + */ +#[\core\attribute\deprecated('This method should not be used', since: '4.5', mdl: 'MDL-82157')] +function print_grade_menu($courseid, $name, $current, $includenograde=true, $return=false) { + \core\deprecation::emit_deprecation_if_present(__FUNCTION__); + global $OUTPUT; + + $output = ''; + $strscale = get_string('scale'); + $strscales = get_string('scales'); + + $scales = get_scales_menu($courseid); + foreach ($scales as $i => $scalename) { + $grades[-$i] = $strscale .': '. $scalename; + } + if ($includenograde) { + $grades[0] = get_string('nograde'); + } + for ($i=100; $i>=1; $i--) { + $grades[$i] = $i; + } + $output .= html_writer::select($grades, $name, $current, false); + + $linkobject = '' . $OUTPUT->pix_icon('help', $strscales) . ''; + $link = new moodle_url('/course/scales.php', array('id' => $courseid, 'list' => 1)); + $action = new popup_action('click', $link, 'ratingscales', array('height' => 400, 'width' => 500)); + $output .= $OUTPUT->action_link($link, $linkobject, $action, array('title' => $strscales)); + + if ($return) { + return $output; + } else { + echo $output; + } +} diff --git a/lib/weblib.php b/lib/weblib.php index 05b081747bb..d6351ea2fb2 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2850,50 +2850,6 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid return implode("\n", $menu); } -/** - * Prints a grade menu (as part of an existing form) with help showing all possible numerical grades and scales. - * - * @todo Finish documenting this function - * @todo Deprecate: this is only used in a few contrib modules - * - * @param int $courseid The course ID - * @param string $name - * @param string $current - * @param boolean $includenograde Include those with no grades - * @param boolean $return If set to true returns rather than echo's - * @return string|bool|null Depending on value of $return - */ -function print_grade_menu($courseid, $name, $current, $includenograde=true, $return=false) { - global $OUTPUT; - - $output = ''; - $strscale = get_string('scale'); - $strscales = get_string('scales'); - - $scales = get_scales_menu($courseid); - foreach ($scales as $i => $scalename) { - $grades[-$i] = $strscale .': '. $scalename; - } - if ($includenograde) { - $grades[0] = get_string('nograde'); - } - for ($i=100; $i>=1; $i--) { - $grades[$i] = $i; - } - $output .= html_writer::select($grades, $name, $current, false); - - $linkobject = '' . $OUTPUT->pix_icon('help', $strscales) . ''; - $link = new moodle_url('/course/scales.php', array('id' => $courseid, 'list' => 1)); - $action = new popup_action('click', $link, 'ratingscales', array('height' => 400, 'width' => 500)); - $output .= $OUTPUT->action_link($link, $linkobject, $action, array('title' => $strscales)); - - if ($return) { - return $output; - } else { - echo $output; - } -} - /** * Print an error to STDOUT and exit with a non-zero code. For commandline scripts. *