+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+export default {
+ frequentComment: '[data-gradingform_guide-role="frequent-comment"]',
+ criterion: '[data-gradingform-guide-role="criterion"]',
+ remark: '[data-gradingform-guide-role="remark"]',
+};
diff --git a/grade/grading/form/guide/classes/grades/grader/gradingpanel/external/fetch.php b/grade/grading/form/guide/classes/grades/grader/gradingpanel/external/fetch.php
index 3f9c8108f92..fe341825f37 100644
--- a/grade/grading/form/guide/classes/grades/grader/gradingpanel/external/fetch.php
+++ b/grade/grading/form/guide/classes/grades/grader/gradingpanel/external/fetch.php
@@ -26,6 +26,8 @@ declare(strict_types = 1);
namespace gradingform_guide\grades\grader\gradingpanel\external;
+global $CFG;
+
use coding_exception;
use context;
use core_user;
@@ -40,6 +42,7 @@ use external_value;
use external_warnings;
use moodle_exception;
use stdClass;
+require_once($CFG->dirroot.'/grade/grading/form/guide/lib.php');
/**
* Web services relating to fetching of a marking guide for the grading panel.
@@ -89,6 +92,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 {
@@ -118,7 +126,7 @@ class fetch extends external_api {
// Fetch the gradeitem instance.
$gradeitem = gradeitem::instance($component, $context, $itemname);
- if ('guide' !== $gradeitem->get_advanced_grading_method()) {
+ if (MARKING_GUIDE !== $gradeitem->get_advanced_grading_method()) {
throw new moodle_exception(
"The {$itemname} item in {$component}/{$contextid} is not configured for advanced grading with a marking guide"
);
@@ -133,7 +141,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/grading/form/guide/classes/grades/grader/gradingpanel/external/store.php b/grade/grading/form/guide/classes/grades/grader/gradingpanel/external/store.php
index c9fdaae91a2..f1300e0e2ba 100644
--- a/grade/grading/form/guide/classes/grades/grader/gradingpanel/external/store.php
+++ b/grade/grading/form/guide/classes/grades/grader/gradingpanel/external/store.php
@@ -26,6 +26,8 @@ declare(strict_types = 1);
namespace gradingform_guide\grades\grader\gradingpanel\external;
+global $CFG;
+
use coding_exception;
use context;
use core_grades\component_gradeitem as gradeitem;
@@ -36,6 +38,7 @@ use external_function_parameters;
use external_single_structure;
use external_value;
use moodle_exception;
+require_once($CFG->dirroot.'/grade/grading/form/guide/lib.php');
/**
* Web services relating to storing of a marking guide for the grading panel.
@@ -89,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 {
@@ -132,7 +141,7 @@ class store extends external_api {
// Require that this user can save grades.
$gradeitem->require_user_can_grade($gradeduser, $USER);
- if ('guide' !== $gradeitem->get_advanced_grading_method()) {
+ if (MARKING_GUIDE !== $gradeitem->get_advanced_grading_method()) {
throw new moodle_exception(
"The {$itemname} item in {$component}/{$contextid} is not configured for advanced grading with a marking guide"
);
diff --git a/grade/grading/form/guide/db/services.php b/grade/grading/form/guide/db/services.php
index 24a947ed81a..88ea5fda701 100644
--- a/grade/grading/form/guide/db/services.php
+++ b/grade/grading/form/guide/db/services.php
@@ -1,5 +1,4 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+defined('MOODLE_INTERNAL') || die;
+
$functions = [
'gradingform_guide_grader_gradingpanel_fetch' => [
'classname' => 'gradingform_guide\\grades\\grader\\gradingpanel\\external\\fetch',
diff --git a/grade/grading/form/guide/lib.php b/grade/grading/form/guide/lib.php
index ffec06cbdec..f878c5e66a9 100644
--- a/grade/grading/form/guide/lib.php
+++ b/grade/grading/form/guide/lib.php
@@ -26,6 +26,9 @@ defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/grade/grading/form/lib.php');
+/** guide: Used to compare our gradeitem_type against. */
+const MARKING_GUIDE = 'guide';
+
/**
* This controller encapsulates the guide grading logic
*
diff --git a/grade/grading/form/guide/templates/grades/grader/gradingpanel.mustache b/grade/grading/form/guide/templates/grades/grader/gradingpanel.mustache
index 258832829b9..7d816e66af1 100644
--- a/grade/grading/form/guide/templates/grades/grader/gradingpanel.mustache
+++ b/grade/grading/form/guide/templates/grades/grader/gradingpanel.mustache
@@ -1,15 +1,75 @@
+{{!
+ 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 .
+}}
+{{!
+ @template gradingform_rubric/grades/grader/gradingpanel
+
+ Classes required for JS:
+ * none
+
+ Data attributes required for JS:
+ * none
+
+ Context variables required for this template:
+ * instanceid: Instance of the module this grading form belongs too
+ * criterion: A gradeable item in the Marking Guide
+ * name: Name of the gradeable item
+ * id: ID of the gradeable item
+ * description: Description shown to students for this gradeable item
+ * descriptionmarkers: Description shown to teachers for this gradeable item
+ * maxscore: Max allowable assinable points for this item
+ * score: Current score assigned to the learner for this item
+ * remark: Text input for the teacher to relay to the student
+ * hascomments: Flag for frequently used comments
+ * comments: Array of frequently used comments
+ * description: Description of a frequently used comment
+
+ Example context (json):
+ {
+ "instanceid": "42",
+ "criterion": [
+ {
+ "name": "Motivation",
+ "id": 13,
+ "description": "Show your motivation to rock climbing",
+ "descriptionmarkers": "Does the student show interest in climbing?",
+ "maxscore": 37,
+ "score": 20,
+ "remark": "That's great!",
+ "hascomments": true,
+ "comments": [
+ {"description": "Great work!"},
+ {"description": "You should really try it before jumping to conclusions"}
+ ]
+ }
+ ]
+ }
+}}