Merge branch 'MDL-78561-master' of https://github.com/kevpercy/moodle

This commit is contained in:
Jun Pataleta 2023-08-10 11:46:36 +08:00 committed by Huong Nguyen
commit ad81e6f315
No known key found for this signature in database
GPG Key ID: 40D88AB693A3E72A
10 changed files with 52 additions and 46 deletions

View File

@ -1065,7 +1065,7 @@ class grade_edit_tree_column_status extends grade_edit_tree_column {
$context = new stdClass();
if ($category->grade_item->is_calculated()) {
$context->calculatedgrade = grade_helper::get_lang_string('calculatedgrade', 'grades');
$context->calculatedgrade = get_string('calculatedgrade', 'grades');
} else {
// Aggregation type.
$aggrstrings = grade_helper::get_aggregation_strings();

View File

@ -1755,7 +1755,7 @@ class grade_structure {
return null;
}
$gradeanalysisstring = grade_helper::get_lang_string('gradeanalysis', 'grades');
$gradeanalysisstring = get_string('gradeanalysis', 'grades');
return html_writer::link($url, $gradeanalysisstring,
['class' => 'dropdown-item', 'aria-label' => $gradeanalysisstring, 'role' => 'menuitem']);
}
@ -1903,7 +1903,7 @@ class grade_structure {
return null;
}
$title = grade_helper::get_lang_string('resetweightsshort', 'grades');
$title = get_string('resetweightsshort', 'grades');
$str = get_string('resetweights', 'grades', $this->get_params_for_iconstr($element));
$url = new moodle_url('/grade/edit/tree/action.php', [
'id' => $this->courseid,
@ -1934,7 +1934,7 @@ class grade_structure {
'sesskey' => sesskey(),
]);
$gpr->add_url_params($deleteconfirmationurl);
$title = grade_helper::get_lang_string('delete');
$title = get_string('delete');
return html_writer::link(
'',
$title,
@ -1974,7 +1974,7 @@ class grade_structure {
$duplicateparams['eid'] = $element['eid'];
$duplicateparams['sesskey'] = sesskey();
$url = new moodle_url('index.php', $duplicateparams);
$title = grade_helper::get_lang_string('duplicate');
$title = get_string('duplicate');
$gpr->add_url_params($url);
return html_writer::link($url, $title,
['class' => 'dropdown-item', 'aria-label' => $title, 'role' => 'menuitem']);
@ -2098,7 +2098,7 @@ class grade_structure {
['courseid' => $this->courseid, 'id' => $object->id]);
}
$url = $gpr->add_url_params($url);
$title = grade_helper::get_lang_string('editgrade', 'grades');
$title = get_string('editgrade', 'grades');
} else if (($element['type'] == 'item') || ($element['type'] == 'categoryitem') ||
($element['type'] == 'courseitem')) {
$url = new moodle_url('#');
@ -2123,7 +2123,7 @@ class grade_structure {
}
} else if ($element['type'] == 'category') {
$url = new moodle_url('#');
$title = grade_helper::get_lang_string('categoryedit', 'grades');
$title = get_string('categoryedit', 'grades');
return html_writer::link($url, $title, [
'class' => 'dropdown-item',
'aria-label' => $title,
@ -2276,10 +2276,10 @@ class grade_structure {
if ($element['object']->is_hidden()) {
$url->param('action', 'show');
$title = grade_helper::get_lang_string('show');
$title = get_string('show');
} else {
$url->param('action', 'hide');
$title = grade_helper::get_lang_string('hide');
$title = get_string('hide');
}
$url = html_writer::link($url, $title,
@ -2381,19 +2381,19 @@ class grade_structure {
$strparamobj = new stdClass();
$strparamobj->itemname = $element['object']->grade_item->get_name(true, true);
$strnonunlockable = get_string('nonunlockableverbose', 'grades', $strparamobj);
$title = grade_helper::get_lang_string('unlock', 'grades');
$title = get_string('unlock', 'grades');
return html_writer::span($title, 'text-muted dropdown-item', ['title' => $strnonunlockable,
'aria-label' => $title, 'role' => 'menuitem']);
} else if ($element['object']->is_locked()) {
if (has_capability('moodle/grade:unlock', $this->context)) {
$title = grade_helper::get_lang_string('unlock', 'grades');
$title = get_string('unlock', 'grades');
$url->param('action', 'unlock');
} else {
return null;
}
} else {
if (has_capability('moodle/grade:lock', $this->context)) {
$title = grade_helper::get_lang_string('lock', 'grades');
$title = get_string('lock', 'grades');
$url->param('action', 'lock');
} else {
return null;
@ -2476,7 +2476,7 @@ class grade_structure {
// Show calculation icon only when calculation possible.
if (!$object->is_external_item() && ($isscale || $isvalue)) {
$editcalculationstring = grade_helper::get_lang_string('editcalculation', 'grades');
$editcalculationstring = get_string('editcalculation', 'grades');
$url = new moodle_url('/grade/edit/tree/calculation.php',
['courseid' => $this->courseid, 'id' => $object->id]);
$url = $gpr->add_url_params($url);
@ -2659,7 +2659,7 @@ class grade_structure {
}
if ($element['type'] != 'text' && !empty($element['object']->feedback)) {
$viewfeedbackstring = grade_helper::get_lang_string('viewfeedback', 'grades');
$viewfeedbackstring = get_string('viewfeedback', 'grades');
$context->viewfeedbackurl = html_writer::link('#', $viewfeedbackstring, ['class' => 'dropdown-item',
'aria-label' => $viewfeedbackstring, 'role' => 'menuitem', 'data-action' => 'feedback',
'data-courseid' => $this->courseid]);
@ -2699,9 +2699,9 @@ class grade_structure {
public function get_sorting_link(moodle_url $sortlink, object $gpr, string $direction = 'asc'): string {
if ($direction == 'asc') {
$title = grade_helper::get_lang_string('asc');
$title = get_string('asc');
} else {
$title = grade_helper::get_lang_string('desc');
$title = get_string('desc');
}
$sortlink->param('sort', $direction);
@ -3553,11 +3553,16 @@ abstract class grade_helper {
* First checks the cached language strings, then returns match if found, or uses get_string()
* to get it from the DB, caches it then returns it.
*
* @deprecated since 4.3
* @todo MDL-78780 This will be deleted in Moodle 4.7.
* @param string $strcode
* @param string|null $section Optional language section
* @return string
*/
public static function get_lang_string(string $strcode, ?string $section = null): string {
debugging('grade_helper::get_lang_string() is deprecated, please use' .
' get_string() instead.', DEBUG_DEVELOPER);
if (empty(self::$langstrings[$strcode])) {
self::$langstrings[$strcode] = get_string($strcode, $section);
}

View File

@ -773,7 +773,7 @@ class grade_report_grader extends grade_report {
$this->rowcount = 0;
$numusers = count($this->users);
$gradetabindex = 1;
$strgrade = \grade_helper::get_lang_string('gradenoun');
$strgrade = get_string('gradenoun');
$this->get_sort_arrows();
// Get preferences once.
@ -1090,9 +1090,9 @@ class grade_report_grader extends grade_report {
if ($quickgrading && $grade->is_editable()) {
$context->iseditable = true;
if (empty($item->outcomeid)) {
$nogradestr = \grade_helper::get_lang_string('nograde');
$nogradestr = get_string('nograde');
} else {
$nogradestr = \grade_helper::get_lang_string('nooutcome', 'grades');
$nogradestr = get_string('nooutcome', 'grades');
}
$attributes = [
'tabindex' => $tabindices[$item->id]['grade'],
@ -1276,7 +1276,7 @@ class grade_report_grader extends grade_report {
$controlscell->attributes['class'] = 'header controls';
$controlscell->header = true;
$controlscell->colspan = $colspan;
$controlscell->text = \grade_helper::get_lang_string('controls', 'grades');
$controlscell->text = get_string('controls', 'grades');
$controlsrow->cells[] = $controlscell;
$rows[] = $controlsrow;
@ -1301,7 +1301,7 @@ class grade_report_grader extends grade_report {
$rangecell->colspan = $colspan;
$rangecell->header = true;
$rangecell->scope = 'row';
$rangecell->text = \grade_helper::get_lang_string('range', 'grades');
$rangecell->text = get_string('range', 'grades');
$rangerow->cells[] = $rangecell;
$rows[] = $rangerow;
}
@ -1935,7 +1935,7 @@ class grade_report_grader extends grade_report {
if (!empty($requirednames)) {
foreach ($requirednames as $name) {
$arrows['studentname'] .= html_writer::link(
new moodle_url($this->baseurl, array('sortitemid' => $name)), \grade_helper::get_lang_string($name)
new moodle_url($this->baseurl, array('sortitemid' => $name)), get_string($name)
);
if ($this->sortitemid == $name) {
$sortlink->param('sortitemid', $name);
@ -2067,9 +2067,9 @@ function gradereport_grader_get_report_link(context_course $context, int $course
$categoryid = $element['object']->id;
// Load language strings.
$strswitchminus = grade_helper::get_lang_string('aggregatesonly', 'grades');
$strswitchplus = grade_helper::get_lang_string('gradesonly', 'grades');
$strswitchwhole = grade_helper::get_lang_string('fullmode', 'grades');
$strswitchminus = get_string('aggregatesonly', 'grades');
$strswitchplus = get_string('gradesonly', 'grades');
$strswitchwhole = get_string('fullmode', 'grades');
$url = new moodle_url($gpr->get_return_url(null, ['target' => $element['eid'], 'sesskey' => sesskey()]));

View File

@ -344,7 +344,7 @@ abstract class grade_report {
*/
public function get_lang_string($strcode, $section=null) {
debugging('grade_report::get_lang_string() is deprecated, please use' .
' grade_helper::get_lang_string() instead.', DEBUG_DEVELOPER);
' get_string() instead.', DEBUG_DEVELOPER);
if (empty($this->lang_strings[$strcode])) {
$this->lang_strings[$strcode] = get_string($strcode, $section);
@ -596,7 +596,7 @@ abstract class grade_report {
global $OUTPUT;
$pix = ['up' => 't/sort_desc', 'down' => 't/sort_asc'];
$matrix = ['up' => 'desc', 'down' => 'asc'];
$strsort = grade_helper::get_lang_string($matrix[$direction], 'moodle');
$strsort = get_string($matrix[$direction], 'moodle');
$arrow = $OUTPUT->pix_icon($pix[$direction], '', '', ['class' => 'sorticon']);
return html_writer::link($sortlink, $arrow, ['title' => $strsort, 'aria-label' => $strsort, 'data-collapse' => 'sort']);
}

View File

@ -151,13 +151,13 @@ class grade_report_overview extends grade_report {
// setting up table headers
if ($this->showrank['any']) {
$tablecolumns = array('coursename', 'grade', 'rank');
$tableheaders = array(grade_helper::get_lang_string('coursename', 'grades'),
grade_helper::get_lang_string('gradenoun'),
grade_helper::get_lang_string('rank', 'grades'));
$tableheaders = array(get_string('coursename', 'grades'),
get_string('gradenoun'),
get_string('rank', 'grades'));
} else {
$tablecolumns = array('coursename', 'grade');
$tableheaders = array(grade_helper::get_lang_string('coursename', 'grades'),
grade_helper::get_lang_string('gradenoun'));
$tableheaders = array(get_string('coursename', 'grades'),
get_string('gradenoun'));
}
$this->table = new flexible_table('grade-report-overview-'.$this->user->id);

View File

@ -36,7 +36,7 @@
function gradereport_singleview_get_report_link(context_course $context, int $courseid,
array $element, grade_plugin_return $gpr, string $mode, ?stdClass $templatecontext): ?stdClass {
$reportstring = grade_helper::get_lang_string('singleviewreport_' . $mode, 'gradereport_singleview');
$reportstring = get_string('singleviewreport_' . $mode, 'gradereport_singleview');
if (!isset($templatecontext)) {
$templatecontext = new stdClass();
}

View File

@ -32,7 +32,7 @@ information provided here is intended especially for developers.
20.
* The get_grade_item_id() function in behat_gradereport_grader.php has been deprecated. Please use
behat_grades::get_grade_item_id() instead.
* The grade_report::get_lang_string() has been deprecated. Please use grade_helper::get_lang_string() instead.
* The grade_report::get_lang_string() has been deprecated. Please use get_string() instead.
=== 3.6 ===
* External function gradereport_user_external::get_grade_items now return the following information (only for course managers).

View File

@ -375,51 +375,51 @@ class user extends grade_report {
// Setting up table headers.
$this->tablecolumns = ['itemname'];
$this->tableheaders = [\grade_helper::get_lang_string('gradeitem', 'grades')];
$this->tableheaders = [get_string('gradeitem', 'grades')];
if ($this->showweight) {
$this->tablecolumns[] = 'weight';
$this->tableheaders[] = \grade_helper::get_lang_string('weightuc', 'grades');
$this->tableheaders[] = get_string('weightuc', 'grades');
}
if ($this->showgrade) {
$this->tablecolumns[] = 'grade';
$this->tableheaders[] = \grade_helper::get_lang_string('grade', 'grades');
$this->tableheaders[] = get_string('grade', 'grades');
}
if ($this->showrange) {
$this->tablecolumns[] = 'range';
$this->tableheaders[] = \grade_helper::get_lang_string('range', 'grades');
$this->tableheaders[] = get_string('range', 'grades');
}
if ($this->showpercentage) {
$this->tablecolumns[] = 'percentage';
$this->tableheaders[] = \grade_helper::get_lang_string('percentage', 'grades');
$this->tableheaders[] = get_string('percentage', 'grades');
}
if ($this->showlettergrade) {
$this->tablecolumns[] = 'lettergrade';
$this->tableheaders[] = \grade_helper::get_lang_string('lettergrade', 'grades');
$this->tableheaders[] = get_string('lettergrade', 'grades');
}
if ($this->showrank) {
$this->tablecolumns[] = 'rank';
$this->tableheaders[] = \grade_helper::get_lang_string('rank', 'grades');
$this->tableheaders[] = get_string('rank', 'grades');
}
if ($this->showaverage) {
$this->tablecolumns[] = 'average';
$this->tableheaders[] = \grade_helper::get_lang_string('average', 'grades');
$this->tableheaders[] = get_string('average', 'grades');
}
if ($this->showfeedback) {
$this->tablecolumns[] = 'feedback';
$this->tableheaders[] = \grade_helper::get_lang_string('feedback', 'grades');
$this->tableheaders[] = get_string('feedback', 'grades');
}
if ($this->showcontributiontocoursetotal) {
$this->tablecolumns[] = 'contributiontocoursetotal';
$this->tableheaders[] = \grade_helper::get_lang_string('contributiontocoursetotal', 'grades');
$this->tableheaders[] = get_string('contributiontocoursetotal', 'grades');
}
}
@ -1021,7 +1021,7 @@ class user extends grade_report {
$table = new \html_table();
$table->attributes = [
'summary' => s(\grade_helper::get_lang_string('tablesummary', 'gradereport_user')),
'summary' => s(get_string('tablesummary', 'gradereport_user')),
'class' => 'generaltable boxaligncenter user-grade',
];

View File

@ -255,7 +255,7 @@ function gradereport_user_get_report_link(context_course $context, int $courseid
global $CFG;
if ($mode == 'user') {
$reportstring = grade_helper::get_lang_string('userreport_' . $mode, 'gradereport_user');
$reportstring = get_string('userreport_' . $mode, 'gradereport_user');
if (!isset($templatecontext)) {
$templatecontext = new stdClass();

View File

@ -17,6 +17,7 @@ Information provided here is intended especially for developers.
- grade/classes/external/get_groups_for_selector
- Has been relocated to core_group_external::get_groups_for_selector()
- groupimageurl is now available as an optional parameter to give the user an image either set or generated for the group.
* The grade_helper::get_lang_string() function has been deprecated. Please use get_string() instead.
=== 4.1 ===
* The $importactiveurl parameter in the constructor of the core_grades\output\import_action_bar class has been deprecated and is not used anymore.