mirror of
https://github.com/moodle/moodle.git
synced 2025-06-02 06:05:31 +02:00
MDL-78164 lib: Added class properties that are not declared in grade
In PHP 8.2 and later, setting a value to an undeclared class property is deprecated and emits a deprecation notice. So we need to add missing class properties that still need to be declared. Co-authored-by: Andrew Nicols <andrew@nicols.co.uk>
This commit is contained in:
parent
1b1a15a308
commit
337bc1554a
40
grade/classes/privacy/grade_grade_with_history.php
Normal file
40
grade/classes/privacy/grade_grade_with_history.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace core_grades\privacy;
|
||||
|
||||
use grade_grade;
|
||||
|
||||
/**
|
||||
* A grade_item which has a reference to its historical content.
|
||||
*
|
||||
* @package core_grades
|
||||
* @category grade
|
||||
* @copyright 2023 Andrew Lyons <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
class grade_grade_with_history extends grade_grade {
|
||||
public int $historyid;
|
||||
|
||||
public function __construct(\stdClass $params = null, $fetch = true) {
|
||||
// The grade history is not a real grade_grade so we remove the ID.
|
||||
$this->historyid = $params->id;
|
||||
unset($params->id);
|
||||
|
||||
parent::__construct($params, $fetch);
|
||||
}
|
||||
}
|
@ -33,6 +33,7 @@ use grade_item;
|
||||
use grade_grade;
|
||||
use grade_scale;
|
||||
use stdClass;
|
||||
use core_grades\privacy\grade_grade_with_history;
|
||||
use core_privacy\local\metadata\collection;
|
||||
use core_privacy\local\request\approved_contextlist;
|
||||
use core_privacy\local\request\transform;
|
||||
@ -543,6 +544,7 @@ class provider implements
|
||||
get_string('feedbackhistoryfiles', 'core_grades')
|
||||
];
|
||||
foreach ($data as $key => $grades) {
|
||||
/** @var grade_grade_with_history */
|
||||
$gg = $grades['gradeobject'];
|
||||
writer::with_context($gg->get_context())->export_area_files($pathtofiles, GRADE_FILE_COMPONENT,
|
||||
GRADE_HISTORY_FEEDBACK_FILEAREA, $gg->historyid);
|
||||
@ -676,6 +678,7 @@ class provider implements
|
||||
get_string('feedbackhistoryfiles', 'core_grades')
|
||||
];
|
||||
foreach ($data as $key => $grades) {
|
||||
/** @var grade_grade_with_history */
|
||||
$gg = $grades['gradeobject'];
|
||||
writer::with_context($gg->get_context())->export_area_files($pathtofiles, GRADE_FILE_COMPONENT,
|
||||
GRADE_HISTORY_FEEDBACK_FILEAREA, $gg->historyid);
|
||||
@ -1037,11 +1040,10 @@ class provider implements
|
||||
$prefix = $ishistory ? 'ggh_' : 'gg_';
|
||||
$ggrecord = static::extract_record($record, $prefix);
|
||||
if ($ishistory) {
|
||||
// The grade history is not a real grade_grade so we remove the ID.
|
||||
$historyid = $ggrecord->id;
|
||||
unset($ggrecord->id);
|
||||
$gg = new grade_grade_with_history($ggrecord, false);
|
||||
} else {
|
||||
$gg = new grade_grade($ggrecord, false);
|
||||
}
|
||||
$gg = new grade_grade($ggrecord, false);
|
||||
|
||||
// There is a grade item in the record.
|
||||
if (!empty($record->gi_id)) {
|
||||
@ -1056,10 +1058,6 @@ class provider implements
|
||||
$gi->scale->load_items();
|
||||
}
|
||||
|
||||
if ($ishistory) {
|
||||
$gg->historyid = $historyid;
|
||||
}
|
||||
|
||||
return $gg;
|
||||
}
|
||||
|
||||
@ -1197,9 +1195,15 @@ class provider implements
|
||||
$timemodified = $gg->timemodified ? transform::datetime($gg->timemodified) : null;
|
||||
$timecreated = $gg->timecreated ? transform::datetime($gg->timecreated) : $timemodified; // When null we use timemodified.
|
||||
|
||||
$filearea = $ishistory ? GRADE_HISTORY_FEEDBACK_FILEAREA : GRADE_FEEDBACK_FILEAREA;
|
||||
$itemid = $ishistory ? $gg->historyid : $gg->id;
|
||||
$subpath = $ishistory ? get_string('feedbackhistoryfiles', 'core_grades') : get_string('feedbackfiles', 'core_grades');
|
||||
if ($gg instanceof grade_grade_with_history) {
|
||||
$filearea = GRADE_HISTORY_FEEDBACK_FILEAREA;
|
||||
$itemid = $gg->historyid;
|
||||
$subpath = get_string('feedbackhistoryfiles', 'core_grades');
|
||||
} else {
|
||||
$filearea = GRADE_FEEDBACK_FILEAREA;
|
||||
$itemid = $gg->id;
|
||||
$subpath = get_string('feedbackfiles', 'core_grades');
|
||||
}
|
||||
|
||||
$pathtofiles = [
|
||||
get_string('grades', 'core_grades'),
|
||||
@ -1272,7 +1276,11 @@ class provider implements
|
||||
$grades = $DB->get_recordset_sql($sql, $params);
|
||||
foreach ($grades as $grade) {
|
||||
$gg = static::extract_grade_grade_from_record($grade, $ishistory);
|
||||
$fileitemid = ($ishistory) ? $gg->historyid : $gg->id;
|
||||
if ($gg instanceof grade_grade_with_history) {
|
||||
$fileitemid = $gg->historyid;
|
||||
} else {
|
||||
$fileitemid = $gg->id;
|
||||
}
|
||||
$fs->delete_area_files($gg->get_context()->id, GRADE_FILE_COMPONENT, $filearea, $fileitemid);
|
||||
}
|
||||
$grades->close();
|
||||
|
@ -105,10 +105,10 @@ class grade_edit_tree {
|
||||
|
||||
$object = $element['object'];
|
||||
$eid = $element['eid'];
|
||||
$object->name = $this->gtree->get_element_header($element, true, false, true, false, true);
|
||||
$object->icon = $this->gtree->get_element_icon($element);
|
||||
$object->type = $this->gtree->get_element_type_string($element);
|
||||
$object->stripped_name = $this->gtree->get_element_header($element, false, false, false);
|
||||
$name = $this->gtree->get_element_header($element, true, false, true, false, true);
|
||||
$icon = $this->gtree->get_element_icon($element);
|
||||
$type = $this->gtree->get_element_type_string($element);
|
||||
$strippedname = $this->gtree->get_element_header($element, false, false, false);
|
||||
$is_category_item = false;
|
||||
if ($element['type'] == 'categoryitem' || $element['type'] == 'courseitem') {
|
||||
$is_category_item = true;
|
||||
@ -142,7 +142,7 @@ class grade_edit_tree {
|
||||
$cell->colspan = 12;
|
||||
$cell->attributes['class'] = $element['type'] . ' moving column-name level' .
|
||||
($level + 1) . ' level' . ($level % 2 ? 'even' : 'odd');
|
||||
$cell->text = $object->name.' ('.get_string('move').')';
|
||||
$cell->text = $name.' ('.get_string('move').')';
|
||||
|
||||
// Create a row that represents the available area to move a grade item or a category into.
|
||||
$movingarea = new html_table_row();
|
||||
@ -160,7 +160,7 @@ class grade_edit_tree {
|
||||
|
||||
if ($element['type'] == 'category') {
|
||||
$level++;
|
||||
$this->categories[$object->id] = $object->stripped_name;
|
||||
$this->categories[$object->id] = $strippedname;
|
||||
$category = grade_category::fetch(array('id' => $object->id));
|
||||
$item = $category->get_grade_item();
|
||||
|
||||
@ -285,7 +285,7 @@ class grade_edit_tree {
|
||||
if (!($this->moving && $column->hide_when_moving)) {
|
||||
$categoryrow->cells[] = $column->get_category_cell($category, $levelclass, [
|
||||
'id' => $id,
|
||||
'name' => $object->name,
|
||||
'name' => $name,
|
||||
'level' => $level,
|
||||
'actions' => $actions,
|
||||
'moveaction' => $moveaction,
|
||||
@ -353,15 +353,15 @@ class grade_edit_tree {
|
||||
$item,
|
||||
[
|
||||
'id' => $id,
|
||||
'name' => $object->name,
|
||||
'name' => $name,
|
||||
'level' => $level,
|
||||
'actions' => $actions,
|
||||
'element' => $element,
|
||||
'eid' => $eid,
|
||||
'moveaction' => $moveaction,
|
||||
'itemtype' => $object->itemtype,
|
||||
'icon' => $object->icon,
|
||||
'type' => $object->type
|
||||
'icon' => $icon,
|
||||
'type' => $type
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -160,6 +160,12 @@ class grade_category extends grade_object {
|
||||
*/
|
||||
protected $canapplylimitrules;
|
||||
|
||||
/**
|
||||
* e.g. 'category', 'course' and 'mod', 'blocks', 'import', etc...
|
||||
* @var string $itemtype
|
||||
*/
|
||||
public $itemtype;
|
||||
|
||||
/**
|
||||
* Builds this category's path string based on its parents (if any) and its own id number.
|
||||
* This is typically done just before inserting this object in the DB for the first time,
|
||||
|
@ -188,6 +188,36 @@ class grade_grade extends grade_object {
|
||||
*/
|
||||
public $feedbackfiles = [];
|
||||
|
||||
/**
|
||||
* Feedback content.
|
||||
* @var string $feedback
|
||||
*/
|
||||
public $feedback;
|
||||
|
||||
/**
|
||||
* Feedback format.
|
||||
* @var int $feedbackformat
|
||||
*/
|
||||
public $feedbackformat = FORMAT_PLAIN;
|
||||
|
||||
/**
|
||||
* Information text.
|
||||
* @var string $information
|
||||
*/
|
||||
public $information;
|
||||
|
||||
/**
|
||||
* Information text format.
|
||||
* @var int $informationformat
|
||||
*/
|
||||
public $informationformat = FORMAT_PLAIN;
|
||||
|
||||
/**
|
||||
* label text.
|
||||
* @var string $label
|
||||
*/
|
||||
public $label;
|
||||
|
||||
/**
|
||||
* Returns array of grades for given grade_item+users
|
||||
*
|
||||
|
@ -262,6 +262,22 @@ class grade_item extends grade_object {
|
||||
*/
|
||||
public $markasoverriddenwhengraded = true;
|
||||
|
||||
/**
|
||||
* @var int course module ID
|
||||
*/
|
||||
public $cmid;
|
||||
|
||||
/**
|
||||
* @var string average information.
|
||||
*/
|
||||
public $avg;
|
||||
|
||||
/**
|
||||
* Category name.
|
||||
* @var string
|
||||
*/
|
||||
public $category;
|
||||
|
||||
/**
|
||||
* Constructor. Optionally (and by default) attempts to fetch corresponding row from the database
|
||||
*
|
||||
|
@ -94,6 +94,9 @@ class grade_outcome extends grade_object {
|
||||
*/
|
||||
public $usermodified;
|
||||
|
||||
/** @var int Identifier of the text format to be used. */
|
||||
public $descriptionformat = FORMAT_MOODLE;
|
||||
|
||||
/**
|
||||
* Deletes this outcome from the database.
|
||||
*
|
||||
|
@ -86,6 +86,18 @@ class grade_scale extends grade_object {
|
||||
*/
|
||||
public $description;
|
||||
|
||||
/**
|
||||
* Standard event.
|
||||
* @var bool $standard
|
||||
*/
|
||||
public $standard;
|
||||
|
||||
/**
|
||||
* Identifier of the text format to be used.
|
||||
* @var int $descriptionformat
|
||||
*/
|
||||
public int $descriptionformat;
|
||||
|
||||
/**
|
||||
* Finds and returns a grade_scale instance based on params.
|
||||
*
|
||||
|
6
lib/grade/tests/fixtures/lib.php
vendored
6
lib/grade/tests/fixtures/lib.php
vendored
@ -49,6 +49,12 @@ abstract class grade_base_testcase extends advanced_testcase {
|
||||
protected $courseid;
|
||||
protected $userid;
|
||||
|
||||
/** @var array user object collection. */
|
||||
protected $user = [];
|
||||
|
||||
/** @var array module object collection. */
|
||||
protected $course_module = [];
|
||||
|
||||
protected function setUp(): void {
|
||||
global $CFG;
|
||||
parent::setup();
|
||||
|
@ -731,7 +731,6 @@ class grade_grade_test extends \grade_base_testcase {
|
||||
$gradegrade->itemid = $gradeitem->id;
|
||||
$grades[$itemid] = $gradegrade;
|
||||
}
|
||||
$gradeitem->grade_item = $gradeitem;
|
||||
}
|
||||
|
||||
return \grade_grade::get_hiding_affected($grades, $items);
|
||||
|
Loading…
x
Reference in New Issue
Block a user