Skip to content

Commit

Permalink
MDL-66074 core_grade: Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocolate-lightning committed Oct 30, 2019
1 parent 47919bb commit 9f1195f
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 13 deletions.
10 changes: 9 additions & 1 deletion grade/classes/component_gradeitem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -364,6 +372,7 @@ abstract public function create_empty_grade(stdClass $gradeduser, stdClass $grad
*
* @param int $gradeid
* @return stdClass
* @throws \dml_exception
*/
public function get_grade(int $gradeid): stdClass {
global $DB;
Expand All @@ -385,7 +394,6 @@ abstract public function get_grade_for_user(stdClass $gradeduser, stdClass $grad
/**
* 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public static function execute_parameters(): external_function_parameters {
* @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 {
Expand Down Expand Up @@ -132,7 +137,7 @@ public static function execute(string $component, int $contextid, string $itemna
/**
* Get the data to be fetched.
*
* @param component_gradeitem $gradeitem
* @param stdClass $grade
* @return array
*/
public static function get_fetch_data(stdClass $grade): array {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ public static function execute_parameters(): external_function_parameters {
* @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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public static function execute_parameters(): external_function_parameters {
* @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 {
Expand Down Expand Up @@ -130,7 +135,8 @@ public static function execute(string $component, int $contextid, string $itemna
/**
* 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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,13 @@ public static function execute_parameters(): external_function_parameters {
* @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 {
Expand Down
4 changes: 3 additions & 1 deletion grade/grading/form/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ public function create_instance($raterid, $itemid = null) {
* @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)) {
Expand All @@ -538,10 +539,11 @@ public function get_or_create_instance($instanceid, $raterid, $itemid) {
*
* 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;
Expand Down
6 changes: 3 additions & 3 deletions grade/grading/tests/coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die();

/**
* Coverage information for the core_grading subsystem.
*
Expand All @@ -25,6 +23,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Coverage information for the core_grading subsystem.
*
Expand All @@ -33,7 +33,7 @@
* @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',
Expand Down
8 changes: 5 additions & 3 deletions grade/templates/grades/grader/gradingpanel/scale.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,17 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@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"
}
}}
<form>
Expand Down
6 changes: 3 additions & 3 deletions grade/tests/coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die();

/**
* Coverage information for the grades component.
*
Expand All @@ -25,6 +23,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Coverage information for the core_grades subsystem.
*
Expand All @@ -33,7 +33,7 @@
* @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',
];
Expand Down

0 comments on commit 9f1195f

Please sign in to comment.