From 9f1195fa660727a052ee40474a952bd35c54fa08 Mon Sep 17 00:00:00 2001 From: Mathew May Date: Mon, 28 Oct 2019 12:57:22 +0800 Subject: [PATCH] MDL-66074 core_grade: Documentation --- grade/classes/component_gradeitem.php | 10 +++++++++- .../grader/gradingpanel/point/external/fetch.php | 7 ++++++- .../grader/gradingpanel/point/external/store.php | 6 ++++++ .../grader/gradingpanel/scale/external/fetch.php | 8 +++++++- .../grader/gradingpanel/scale/external/store.php | 6 ++++++ grade/grading/form/lib.php | 4 +++- grade/grading/tests/coverage.php | 6 +++--- .../grades/grader/gradingpanel/scale.mustache | 8 +++++--- grade/tests/coverage.php | 6 +++--- 9 files changed, 48 insertions(+), 13 deletions(-) diff --git a/grade/classes/component_gradeitem.php b/grade/classes/component_gradeitem.php index 115d61d0aef..a8f6b34b5f6 100644 --- a/grade/classes/component_gradeitem.php +++ b/grade/classes/component_gradeitem.php @@ -58,6 +58,14 @@ abstract class component_gradeitem { /** @var int The grade itemnumber */ protected $itemnumber; + /** + * component_gradeitem constructor. + * + * @param string $component + * @param context $context + * @param string $itemname + * @throws \coding_exception + */ final protected function __construct(string $component, context $context, string $itemname) { $this->component = $component; $this->context = $context; @@ -364,6 +372,7 @@ abstract class component_gradeitem { * * @param int $gradeid * @return stdClass + * @throws \dml_exception */ public function get_grade(int $gradeid): stdClass { global $DB; @@ -385,7 +394,6 @@ abstract class component_gradeitem { /** * Get grades for all users for the specified gradeitem. * - * @param int $itemnumber The specific grade item to fetch for the user * @return stdClass[] The grades */ abstract public function get_all_grades(): array; diff --git a/grade/classes/grades/grader/gradingpanel/point/external/fetch.php b/grade/classes/grades/grader/gradingpanel/point/external/fetch.php index 63260083d2e..b8332e51988 100644 --- a/grade/classes/grades/grader/gradingpanel/point/external/fetch.php +++ b/grade/classes/grades/grader/gradingpanel/point/external/fetch.php @@ -89,6 +89,11 @@ class fetch extends external_api { * @param string $itemname * @param int $gradeduserid * @return array + * @throws \dml_exception + * @throws \invalid_parameter_exception + * @throws \restricted_context_exception + * @throws coding_exception + * @throws moodle_exception * @since Moodle 3.8 */ public static function execute(string $component, int $contextid, string $itemname, int $gradeduserid): array { @@ -132,7 +137,7 @@ class fetch extends external_api { /** * Get the data to be fetched. * - * @param component_gradeitem $gradeitem + * @param stdClass $grade * @return array */ public static function get_fetch_data(stdClass $grade): array { diff --git a/grade/classes/grades/grader/gradingpanel/point/external/store.php b/grade/classes/grades/grader/gradingpanel/point/external/store.php index 4f54a33ffff..3649e5382a8 100644 --- a/grade/classes/grades/grader/gradingpanel/point/external/store.php +++ b/grade/classes/grades/grader/gradingpanel/point/external/store.php @@ -92,7 +92,13 @@ class store extends external_api { * @param int $contextid * @param string $itemname * @param int $gradeduserid + * @param string $formdata * @return array + * @throws \dml_exception + * @throws \invalid_parameter_exception + * @throws \restricted_context_exception + * @throws coding_exception + * @throws moodle_exception * @since Moodle 3.8 */ public static function execute(string $component, int $contextid, string $itemname, int $gradeduserid, string $formdata): array { diff --git a/grade/classes/grades/grader/gradingpanel/scale/external/fetch.php b/grade/classes/grades/grader/gradingpanel/scale/external/fetch.php index 3e88e4ce08c..dfd9acd38a9 100644 --- a/grade/classes/grades/grader/gradingpanel/scale/external/fetch.php +++ b/grade/classes/grades/grader/gradingpanel/scale/external/fetch.php @@ -89,6 +89,11 @@ class fetch extends external_api { * @param string $itemname * @param int $gradeduserid * @return array + * @throws \dml_exception + * @throws \invalid_parameter_exception + * @throws \restricted_context_exception + * @throws coding_exception + * @throws moodle_exception * @since Moodle 3.8 */ public static function execute(string $component, int $contextid, string $itemname, int $gradeduserid): array { @@ -130,7 +135,8 @@ class fetch extends external_api { /** * Get the data to be fetched. * - * @param component_gradeitem $gradeitem + * @param gradeitem $gradeitem + * @param stdClass $gradeduser * @return array */ public static function get_fetch_data(gradeitem $gradeitem, stdClass $gradeduser): array { diff --git a/grade/classes/grades/grader/gradingpanel/scale/external/store.php b/grade/classes/grades/grader/gradingpanel/scale/external/store.php index 2a5fd7be453..6c7fa5b8427 100644 --- a/grade/classes/grades/grader/gradingpanel/scale/external/store.php +++ b/grade/classes/grades/grader/gradingpanel/scale/external/store.php @@ -92,7 +92,13 @@ class store extends external_api { * @param int $contextid * @param string $itemname * @param int $gradeduserid + * @param string $formdata * @return array + * @throws \dml_exception + * @throws \invalid_parameter_exception + * @throws \restricted_context_exception + * @throws coding_exception + * @throws moodle_exception * @since Moodle 3.8 */ public static function execute(string $component, int $contextid, string $itemname, int $gradeduserid, string $formdata): array { diff --git a/grade/grading/form/lib.php b/grade/grading/form/lib.php index a0653e8c5ad..9c94f0d5dad 100644 --- a/grade/grading/form/lib.php +++ b/grade/grading/form/lib.php @@ -521,6 +521,7 @@ abstract class gradingform_controller { * @param int $raterid * @param int $itemid * @return gradingform_instance + * @throws dml_exception */ public function get_or_create_instance($instanceid, $raterid, $itemid) { if (!is_numeric($instanceid)) { @@ -538,10 +539,11 @@ abstract class gradingform_controller { * * If the instanceid is falsey, or no instance was found, then create a new instance for the specified rater and item. * - * @param int $instanceid * @param int $raterid * @param int $itemid + * @param int $instanceid * @return gradingform_instance + * @throws dml_exception */ public function fetch_instance(int $raterid, int $itemid, ?int $instanceid): gradingform_instance { global $DB; diff --git a/grade/grading/tests/coverage.php b/grade/grading/tests/coverage.php index 97c219b70dd..9b2b565097d 100644 --- a/grade/grading/tests/coverage.php +++ b/grade/grading/tests/coverage.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -defined('MOODLE_INTERNAL') || die(); - /** * Coverage information for the core_grading subsystem. * @@ -25,6 +23,8 @@ defined('MOODLE_INTERNAL') || die(); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + /** * Coverage information for the core_grading subsystem. * @@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die(); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ return new class extends phpunit_coverage_info { - /** @var array The list of folders relative to the plugin root to whitelist in coverage generation. */ + // Array The list of folders relative to the plugin root to whitelist in coverage generation. protected $whitelistfolders = [ 'classes', 'tests/generator', diff --git a/grade/templates/grades/grader/gradingpanel/scale.mustache b/grade/templates/grades/grader/gradingpanel/scale.mustache index 6c6ef78da92..fdac05d3873 100644 --- a/grade/templates/grades/grader/gradingpanel/scale.mustache +++ b/grade/templates/grades/grader/gradingpanel/scale.mustache @@ -15,15 +15,17 @@ along with Moodle. If not, see . }} {{! - @template core_grades/grades/grader/gradingpanel/point + @template core_grades/grades/grader/gradingpanel/scale - Point-based grading template for use in the grading panel. + Scale-based grading template for use in the grading panel. Context variables required for this template: Example context (json): { - "grade": 47 + "value": 1, + "selected": true, + "title": "Motivational" } }}
diff --git a/grade/tests/coverage.php b/grade/tests/coverage.php index 187e4534e69..7480fcc88bb 100644 --- a/grade/tests/coverage.php +++ b/grade/tests/coverage.php @@ -14,8 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . -defined('MOODLE_INTERNAL') || die(); - /** * Coverage information for the grades component. * @@ -25,6 +23,8 @@ defined('MOODLE_INTERNAL') || die(); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + /** * Coverage information for the core_grades subsystem. * @@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die(); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ return new class extends phpunit_coverage_info { - /** @var array The list of folders relative to the plugin root to whitelist in coverage generation. */ + // Array The list of folders relative to the plugin root to whitelist in coverage generation. protected $whitelistfolders = [ 'classes', ];