MDL-66074 gradingform_guide: Documentation and selectors

This commit is contained in:
Mathew May 2019-10-28 12:55:01 +08:00
parent dc0145b19e
commit 9c2c79f5fb
16 changed files with 180 additions and 39 deletions

View File

@ -1 +1 @@
{"version":3,"sources":["../../../src/grades/grader/gradingpanel.js"],"names":["fetchCurrentGrade","component","contextid","itemname","gradeduserid","methodname","args","storeCurrentGrade","rootNode","form","querySelector","normaliseResult","formdata","serialize"],"mappings":"0QA4BA,uD,mVAEiC,QAApBA,CAAAA,iBAAoB,CAACC,CAAD,CAAYC,CAAZ,CAAuBC,CAAvB,CAAiCC,CAAjC,CAAkD,CAC/E,MAAO,WAAU,CAAC,CACdC,UAAU,8CADI,CAEdC,IAAI,CAAE,CACFL,SAAS,CAATA,CADE,CAEFC,SAAS,CAATA,CAFE,CAGFC,QAAQ,CAARA,CAHE,CAIFC,YAAY,CAAZA,CAJE,CAFQ,CAAD,CAAV,EAQH,CARG,CASV,C,CAGM,GAAMG,CAAAA,CAAiB,4CAAG,WAAMN,CAAN,CAAiBC,CAAjB,CAA4BC,CAA5B,CAAsCC,CAAtC,CAAoDI,CAApD,yFACvBC,CADuB,CAChBD,CAAQ,CAACE,aAAT,CAAuB,MAAvB,CADgB,MAGtBC,iBAHsB,gBAGA,WAAU,CAAC,CACpCN,UAAU,8CAD0B,CAEpCC,IAAI,CAAE,CACFL,SAAS,CAATA,CADE,CAEFC,SAAS,CAATA,CAFE,CAGFC,QAAQ,CAARA,CAHE,CAIFC,YAAY,CAAZA,CAJE,CAKFQ,QAAQ,CAAE,cAAOH,CAAP,EAAaI,SAAb,EALR,CAF8B,CAAD,CAAV,EASzB,CATyB,CAHA,qGAAH,uDAAvB,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Grading panel for gradingform_guide.\n *\n * @module gradingform_guide/grades/grader/gradingpanel\n * @package gradingform_guide\n * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {call as fetchMany} from 'core/ajax';\nimport {normaliseResult} from 'core_grades/grades/grader/gradingpanel/normalise';\n\n// Note: We use jQuery.serializer here until we can rewrite Ajax to use XHR.send()\nimport jQuery from 'jquery';\n\nexport const fetchCurrentGrade = (component, contextid, itemname, gradeduserid) => {\n return fetchMany([{\n methodname: `gradingform_guide_grader_gradingpanel_fetch`,\n args: {\n component,\n contextid,\n itemname,\n gradeduserid,\n },\n }])[0];\n};\n\n\nexport const storeCurrentGrade = async(component, contextid, itemname, gradeduserid, rootNode) => {\n const form = rootNode.querySelector('form');\n\n return normaliseResult(await fetchMany([{\n methodname: `gradingform_guide_grader_gradingpanel_store`,\n args: {\n component,\n contextid,\n itemname,\n gradeduserid,\n formdata: jQuery(form).serialize(),\n },\n }])[0]);\n};\n"],"file":"gradingpanel.min.js"} {"version":3,"sources":["../../../src/grades/grader/gradingpanel.js"],"names":["fetchCurrentGrade","component","contextid","itemname","gradeduserid","methodname","args","storeCurrentGrade","rootNode","form","querySelector","normaliseResult","formdata","serialize"],"mappings":"0QA4BA,uD,mVAYiC,QAApBA,CAAAA,iBAAoB,CAACC,CAAD,CAAYC,CAAZ,CAAuBC,CAAvB,CAAiCC,CAAjC,CAAkD,CAC/E,MAAO,WAAU,CAAC,CACdC,UAAU,8CADI,CAEdC,IAAI,CAAE,CACFL,SAAS,CAATA,CADE,CAEFC,SAAS,CAATA,CAFE,CAGFC,QAAQ,CAARA,CAHE,CAIFC,YAAY,CAAZA,CAJE,CAFQ,CAAD,CAAV,EAQH,CARG,CASV,C,CAaM,GAAMG,CAAAA,CAAiB,4CAAG,WAAMN,CAAN,CAAiBC,CAAjB,CAA4BC,CAA5B,CAAsCC,CAAtC,CAAoDI,CAApD,yFACvBC,CADuB,CAChBD,CAAQ,CAACE,aAAT,CAAuB,MAAvB,CADgB,MAGtBC,iBAHsB,gBAGA,WAAU,CAAC,CACpCN,UAAU,8CAD0B,CAEpCC,IAAI,CAAE,CACFL,SAAS,CAATA,CADE,CAEFC,SAAS,CAATA,CAFE,CAGFC,QAAQ,CAARA,CAHE,CAIFC,YAAY,CAAZA,CAJE,CAKFQ,QAAQ,CAAE,cAAOH,CAAP,EAAaI,SAAb,EALR,CAF8B,CAAD,CAAV,EASzB,CATyB,CAHA,qGAAH,uDAAvB,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Grading panel for gradingform_guide.\n *\n * @module gradingform_guide/grades/grader/gradingpanel\n * @package gradingform_guide\n * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport {call as fetchMany} from 'core/ajax';\nimport {normaliseResult} from 'core_grades/grades/grader/gradingpanel/normalise';\n\n// Note: We use jQuery.serializer here until we can rewrite Ajax to use XHR.send()\nimport jQuery from 'jquery';\n\n/**\n * For a given component, contextid, itemname & gradeduserid we can fetch the currently assigned grade.\n *\n * @param {String} component\n * @param {Number} contextid\n * @param {String} itemname\n * @param {Number} gradeduserid\n *\n * @returns {Promise}\n */\nexport const fetchCurrentGrade = (component, contextid, itemname, gradeduserid) => {\n return fetchMany([{\n methodname: `gradingform_guide_grader_gradingpanel_fetch`,\n args: {\n component,\n contextid,\n itemname,\n gradeduserid,\n },\n }])[0];\n};\n\n/**\n * For a given component, contextid, itemname & gradeduserid we can store the currently assigned grade in a given form.\n *\n * @param {String} component\n * @param {Number} contextid\n * @param {String} itemname\n * @param {Number} gradeduserid\n * @param {HTMLElement} rootNode\n *\n * @returns {Promise}\n */\nexport const storeCurrentGrade = async(component, contextid, itemname, gradeduserid, rootNode) => {\n const form = rootNode.querySelector('form');\n\n return normaliseResult(await fetchMany([{\n methodname: `gradingform_guide_grader_gradingpanel_store`,\n args: {\n component,\n contextid,\n itemname,\n gradeduserid,\n formdata: jQuery(form).serialize(),\n },\n }])[0]);\n};\n"],"file":"gradingpanel.min.js"}

View File

@ -1,2 +1,2 @@
define ("gradingform_guide/grades/grader/gradingpanel/comments",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;a.init=function init(a){var b=document.querySelector("#".concat(a));b.addEventListener("click",function(a){if(!a.target.matches("[data-gradingform_guide-role=\"frequent-comment\"]")){return}a.preventDefault();var b=a.target.closest("[data-gradingform_guide-role=\"frequent-comment\"]"),c=b.closest("[data-gradingform-guide-role=\"criterion\"]"),d=c.querySelector("[data-gradingform-guide-role=\"remark\"]");if(!d){return}if(d.value.trim()){d.value+="\n".concat(b.innerHTML)}else{d.value+=b.innerHTML}})}}); define ("gradingform_guide/grades/grader/gradingpanel/comments",["exports","./comments/selectors"],function(a,b){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.init=void 0;b=function(a){return a&&a.__esModule?a:{default:a}}(b);a.init=function init(a){var c=document.querySelector("#".concat(a));c.addEventListener("click",function(a){if(!a.target.matches(b.default.frequentComment)){return}a.preventDefault();var c=a.target.closest(b.default.frequentComment),d=c.closest(b.default.criterion),e=d.querySelector(b.default.remark);if(!e){return}if(e.value.trim()){e.value+="\n".concat(c.innerHTML)}else{e.value+=c.innerHTML}})}});
//# sourceMappingURL=comments.min.js.map //# sourceMappingURL=comments.min.js.map

View File

@ -1 +1 @@
{"version":3,"sources":["../../../../src/grades/grader/gradingpanel/comments.js"],"names":["init","rootId","rootNode","document","querySelector","addEventListener","e","target","matches","preventDefault","clicked","closest","criterion","remark","value","trim","innerHTML"],"mappings":"2KAwBoB,QAAPA,CAAAA,IAAO,CAACC,CAAD,CAAY,CAC5B,GAAMC,CAAAA,CAAQ,CAAGC,QAAQ,CAACC,aAAT,YAA2BH,CAA3B,EAAjB,CAEAC,CAAQ,CAACG,gBAAT,CAA0B,OAA1B,CAAmC,SAACC,CAAD,CAAO,CACtC,GAAI,CAACA,CAAC,CAACC,MAAF,CAASC,OAAT,CAAiB,oDAAjB,CAAL,CAA2E,CACvE,MACH,CAEDF,CAAC,CAACG,cAAF,GALsC,GAOhCC,CAAAA,CAAO,CAAGJ,CAAC,CAACC,MAAF,CAASI,OAAT,CAAiB,oDAAjB,CAPsB,CAQhCC,CAAS,CAAGF,CAAO,CAACC,OAAR,CAAgB,6CAAhB,CARoB,CAShCE,CAAM,CAAGD,CAAS,CAACR,aAAV,CAAwB,0CAAxB,CATuB,CAWtC,GAAI,CAACS,CAAL,CAAa,CACT,MACH,CAED,GAAIA,CAAM,CAACC,KAAP,CAAaC,IAAb,EAAJ,CAAyB,CACrBF,CAAM,CAACC,KAAP,cAAqBJ,CAAO,CAACM,SAA7B,CACH,CAFD,IAEO,CACHH,CAAM,CAACC,KAAP,EAAgBJ,CAAO,CAACM,SAC3B,CACJ,CApBD,CAqBH,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Grading panel frequently used comments selector.\n *\n * @module gradingform_guide/grades/grader/gradingpanel/comments\n * @package gradingform_guide\n * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nexport const init = (rootId) => {\n const rootNode = document.querySelector(`#${rootId}`);\n\n rootNode.addEventListener('click', (e) => {\n if (!e.target.matches('[data-gradingform_guide-role=\"frequent-comment\"]')) {\n return;\n }\n\n e.preventDefault();\n\n const clicked = e.target.closest('[data-gradingform_guide-role=\"frequent-comment\"]');\n const criterion = clicked.closest('[data-gradingform-guide-role=\"criterion\"]');\n const remark = criterion.querySelector('[data-gradingform-guide-role=\"remark\"]');\n\n if (!remark) {\n return;\n }\n\n if (remark.value.trim()) {\n remark.value += `\\n${clicked.innerHTML}`;\n } else {\n remark.value += clicked.innerHTML;\n }\n });\n};\n"],"file":"comments.min.js"} {"version":3,"sources":["../../../../src/grades/grader/gradingpanel/comments.js"],"names":["init","rootId","rootNode","document","querySelector","addEventListener","e","target","matches","Selectors","frequentComment","preventDefault","clicked","closest","criterion","remark","value","trim","innerHTML"],"mappings":"6LAwBA,uD,OAOoB,QAAPA,CAAAA,IAAO,CAACC,CAAD,CAAY,CAC5B,GAAMC,CAAAA,CAAQ,CAAGC,QAAQ,CAACC,aAAT,YAA2BH,CAA3B,EAAjB,CAEAC,CAAQ,CAACG,gBAAT,CAA0B,OAA1B,CAAmC,SAACC,CAAD,CAAO,CACtC,GAAI,CAACA,CAAC,CAACC,MAAF,CAASC,OAAT,CAAiBC,UAAUC,eAA3B,CAAL,CAAkD,CAC9C,MACH,CAEDJ,CAAC,CAACK,cAAF,GALsC,GAOhCC,CAAAA,CAAO,CAAGN,CAAC,CAACC,MAAF,CAASM,OAAT,CAAiBJ,UAAUC,eAA3B,CAPsB,CAQhCI,CAAS,CAAGF,CAAO,CAACC,OAAR,CAAgBJ,UAAUK,SAA1B,CARoB,CAShCC,CAAM,CAAGD,CAAS,CAACV,aAAV,CAAwBK,UAAUM,MAAlC,CATuB,CAWtC,GAAI,CAACA,CAAL,CAAa,CACT,MACH,CAGD,GAAIA,CAAM,CAACC,KAAP,CAAaC,IAAb,EAAJ,CAAyB,CACrBF,CAAM,CAACC,KAAP,cAAqBJ,CAAO,CAACM,SAA7B,CACH,CAFD,IAEO,CACHH,CAAM,CAACC,KAAP,EAAgBJ,CAAO,CAACM,SAC3B,CACJ,CArBD,CAsBH,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Grading panel frequently used comments selector.\n *\n * @module gradingform_guide/grades/grader/gradingpanel/comments\n * @package gradingform_guide\n * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Selectors from './comments/selectors';\n\n/**\n * Manage the frequently used comments in the Marking Guide form.\n *\n * @param {String} rootId\n */\nexport const init = (rootId) => {\n const rootNode = document.querySelector(`#${rootId}`);\n\n rootNode.addEventListener('click', (e) => {\n if (!e.target.matches(Selectors.frequentComment)) {\n return;\n }\n\n e.preventDefault();\n\n const clicked = e.target.closest(Selectors.frequentComment);\n const criterion = clicked.closest(Selectors.criterion);\n const remark = criterion.querySelector(Selectors.remark);\n\n if (!remark) {\n return;\n }\n\n // Either append the comment to an existing comment or set it as the comment.\n if (remark.value.trim()) {\n remark.value += `\\n${clicked.innerHTML}`;\n } else {\n remark.value += clicked.innerHTML;\n }\n });\n};\n"],"file":"comments.min.js"}

View File

@ -0,0 +1,2 @@
define ("gradingform_guide/grades/grader/gradingpanel/comments/selectors",["exports"],function(a){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.default=void 0;a.default={frequentComment:"[data-gradingform_guide-role=\"frequent-comment\"]",criterion:"[data-gradingform-guide-role=\"criterion\"]",remark:"[data-gradingform-guide-role=\"remark\"]"};return a.default});
//# sourceMappingURL=selectors.min.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/grades/grader/gradingpanel/comments/selectors.js"],"names":["frequentComment","criterion","remark"],"mappings":"2LAuBe,CACXA,eAAe,CAAE,oDADN,CAEXC,SAAS,CAAE,6CAFA,CAGXC,MAAM,CAAE,0CAHG,C","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Define all of the selectors we will be using on the Marking Guide interface.\n *\n * @module gradingform_guide/grades/grader/gradingpanel/comments/selectors\n * @package gradingform_guide\n * @copyright 2019 Mathew May <mathew.solutions>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\nexport default {\n frequentComment: '[data-gradingform_guide-role=\"frequent-comment\"]',\n criterion: '[data-gradingform-guide-role=\"criterion\"]',\n remark: '[data-gradingform-guide-role=\"remark\"]',\n};\n"],"file":"selectors.min.js"}

View File

@ -28,6 +28,16 @@ import {normaliseResult} from 'core_grades/grades/grader/gradingpanel/normalise'
// Note: We use jQuery.serializer here until we can rewrite Ajax to use XHR.send() // Note: We use jQuery.serializer here until we can rewrite Ajax to use XHR.send()
import jQuery from 'jquery'; import jQuery from 'jquery';
/**
* For a given component, contextid, itemname & gradeduserid we can fetch the currently assigned grade.
*
* @param {String} component
* @param {Number} contextid
* @param {String} itemname
* @param {Number} gradeduserid
*
* @returns {Promise}
*/
export const fetchCurrentGrade = (component, contextid, itemname, gradeduserid) => { export const fetchCurrentGrade = (component, contextid, itemname, gradeduserid) => {
return fetchMany([{ return fetchMany([{
methodname: `gradingform_guide_grader_gradingpanel_fetch`, methodname: `gradingform_guide_grader_gradingpanel_fetch`,
@ -40,7 +50,17 @@ export const fetchCurrentGrade = (component, contextid, itemname, gradeduserid)
}])[0]; }])[0];
}; };
/**
* For a given component, contextid, itemname & gradeduserid we can store the currently assigned grade in a given form.
*
* @param {String} component
* @param {Number} contextid
* @param {String} itemname
* @param {Number} gradeduserid
* @param {HTMLElement} rootNode
*
* @returns {Promise}
*/
export const storeCurrentGrade = async(component, contextid, itemname, gradeduserid, rootNode) => { export const storeCurrentGrade = async(component, contextid, itemname, gradeduserid, rootNode) => {
const form = rootNode.querySelector('form'); const form = rootNode.querySelector('form');

View File

@ -22,24 +22,32 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
import Selectors from './comments/selectors';
/**
* Manage the frequently used comments in the Marking Guide form.
*
* @param {String} rootId
*/
export const init = (rootId) => { export const init = (rootId) => {
const rootNode = document.querySelector(`#${rootId}`); const rootNode = document.querySelector(`#${rootId}`);
rootNode.addEventListener('click', (e) => { rootNode.addEventListener('click', (e) => {
if (!e.target.matches('[data-gradingform_guide-role="frequent-comment"]')) { if (!e.target.matches(Selectors.frequentComment)) {
return; return;
} }
e.preventDefault(); e.preventDefault();
const clicked = e.target.closest('[data-gradingform_guide-role="frequent-comment"]'); const clicked = e.target.closest(Selectors.frequentComment);
const criterion = clicked.closest('[data-gradingform-guide-role="criterion"]'); const criterion = clicked.closest(Selectors.criterion);
const remark = criterion.querySelector('[data-gradingform-guide-role="remark"]'); const remark = criterion.querySelector(Selectors.remark);
if (!remark) { if (!remark) {
return; return;
} }
// Either append the comment to an existing comment or set it as the comment.
if (remark.value.trim()) { if (remark.value.trim()) {
remark.value += `\n${clicked.innerHTML}`; remark.value += `\n${clicked.innerHTML}`;
} else { } else {

View File

@ -0,0 +1,28 @@
// 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/>.
/**
* Define all of the selectors we will be using on the Marking Guide interface.
*
* @module gradingform_guide/grades/grader/gradingpanel/comments/selectors
* @package gradingform_guide
* @copyright 2019 Mathew May <mathew.solutions>
* @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"]',
};

View File

@ -26,6 +26,8 @@ declare(strict_types = 1);
namespace gradingform_guide\grades\grader\gradingpanel\external; namespace gradingform_guide\grades\grader\gradingpanel\external;
global $CFG;
use coding_exception; use coding_exception;
use context; use context;
use core_user; use core_user;
@ -40,6 +42,7 @@ use external_value;
use external_warnings; use external_warnings;
use moodle_exception; use moodle_exception;
use stdClass; 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. * 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 string $itemname
* @param int $gradeduserid * @param int $gradeduserid
* @return array * @return array
* @throws \dml_exception
* @throws \invalid_parameter_exception
* @throws \restricted_context_exception
* @throws coding_exception
* @throws moodle_exception
* @since Moodle 3.8 * @since Moodle 3.8
*/ */
public static function execute(string $component, int $contextid, string $itemname, int $gradeduserid): array { 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. // Fetch the gradeitem instance.
$gradeitem = gradeitem::instance($component, $context, $itemname); $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( throw new moodle_exception(
"The {$itemname} item in {$component}/{$contextid} is not configured for advanced grading with a marking guide" "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. * Get the data to be fetched.
* *
* @param component_gradeitem $gradeitem * @param gradeitem $gradeitem
* @param stdClass $gradeduser
* @return array * @return array
*/ */
public static function get_fetch_data(gradeitem $gradeitem, stdClass $gradeduser): array { public static function get_fetch_data(gradeitem $gradeitem, stdClass $gradeduser): array {

View File

@ -26,6 +26,8 @@ declare(strict_types = 1);
namespace gradingform_guide\grades\grader\gradingpanel\external; namespace gradingform_guide\grades\grader\gradingpanel\external;
global $CFG;
use coding_exception; use coding_exception;
use context; use context;
use core_grades\component_gradeitem as gradeitem; use core_grades\component_gradeitem as gradeitem;
@ -36,6 +38,7 @@ use external_function_parameters;
use external_single_structure; use external_single_structure;
use external_value; use external_value;
use moodle_exception; 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. * 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 int $contextid
* @param string $itemname * @param string $itemname
* @param int $gradeduserid * @param int $gradeduserid
* @param string $formdata
* @return array * @return array
* @throws \dml_exception
* @throws \invalid_parameter_exception
* @throws \restricted_context_exception
* @throws coding_exception
* @throws moodle_exception
* @since Moodle 3.8 * @since Moodle 3.8
*/ */
public static function execute(string $component, int $contextid, string $itemname, int $gradeduserid, string $formdata): array { 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. // Require that this user can save grades.
$gradeitem->require_user_can_grade($gradeduser, $USER); $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( throw new moodle_exception(
"The {$itemname} item in {$component}/{$contextid} is not configured for advanced grading with a marking guide" "The {$itemname} item in {$component}/{$contextid} is not configured for advanced grading with a marking guide"
); );

View File

@ -1,5 +1,4 @@
<?php <?php
// This file is part of Moodle - http://moodle.org/ // This file is part of Moodle - http://moodle.org/
// //
// Moodle is free software: you can redistribute it and/or modify // Moodle is free software: you can redistribute it and/or modify
@ -18,11 +17,13 @@
/** /**
* External functions and service definitions for the Marking Guide advanced grading form. * External functions and service definitions for the Marking Guide advanced grading form.
* *
* @package mod_forum * @package gradingform_guide
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
defined('MOODLE_INTERNAL') || die;
$functions = [ $functions = [
'gradingform_guide_grader_gradingpanel_fetch' => [ 'gradingform_guide_grader_gradingpanel_fetch' => [
'classname' => 'gradingform_guide\\grades\\grader\\gradingpanel\\external\\fetch', 'classname' => 'gradingform_guide\\grades\\grader\\gradingpanel\\external\\fetch',

View File

@ -26,6 +26,9 @@ defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/grade/grading/form/lib.php'); 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 * This controller encapsulates the guide grading logic
* *

View File

@ -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 <http://www.gnu.org/licenses/>.
}}
{{!
@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"}
]
}
]
}
}}
<form id="gradingform_guide-{{uniqid}}"> <form id="gradingform_guide-{{uniqid}}">
<input type="hidden" name="instanceid" value="{{instanceid}}"> <input type="hidden" name="instanceid" value="{{instanceid}}">
{{#criterion}} {{#criterion}}
<div data-gradingform-guide-role="criterion"> <div data-gradingform-guide-role="criterion">
<h5> <h5>
{{name}} {{name}}
<a <a
href="#gradingform_guide-{{uniqid}}-criteria-{{id}}-description" href="#gradingform_guide-{{uniqid}}-criteria-{{id}}-description"
aria-controls="gradingform_guide-{{uniqid}}-criteria-{{id}}-description" aria-controls="gradingform_guide-{{uniqid}}-criteria-{{id}}-description"
aria-expanded="false" aria-expanded="false"
data-toggle="collapse" data-toggle="collapse"
role="button" role="button"
> >
{{# pix }} info, gradingform_guide {{/ pix }} {{# pix }} info, gradingform_guide {{/ pix }}
</a> </a>
@ -25,27 +85,27 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="gradingform_guide-{{uniqid}}-criteria-{{id}}-score">{{#str}}outof, gradingform_guide, {{maxscore}}{{/str}}</label> <label for="gradingform_guide-{{uniqid}}-criteria-{{id}}-score">{{#str}}outof, gradingform_guide, {{maxscore}}{{/str}}</label>
<input class="form-control" type="number" name="advancedgrading[criteria][{{id}}][score]" value="{{score}}" <input class="form-control" type="number" name="advancedgrading[criteria][{{id}}][score]" value="{{score}}"
id="gradingform_guide-{{uniqid}}-criteria-{{id}}-score" id="gradingform_guide-{{uniqid}}-criteria-{{id}}-score"
aria-describedby="gradingform_guide-{{uniqid}}-help-{{id}}-score"> aria-describedby="gradingform_guide-{{uniqid}}-help-{{id}}-score">
<small id="gradingform_guide-{{uniqid}}-help-{{id}}-score" class="sr-only">{{#str}}grade_help, gradingform_guide{{/str}}</small> <small id="gradingform_guide-{{uniqid}}-help-{{id}}-score" class="sr-only">{{#str}}grade_help, gradingform_guide{{/str}}</small>
</div> </div>
<div class="form-group "> <div class="form-group ">
<label for="gradingform_guide-{{uniqid}}-criteria-{{id}}-remark">{{#str}}additionalcomments, gradingform_guide{{/str}}</label> <label for="gradingform_guide-{{uniqid}}-criteria-{{id}}-remark">{{#str}}additionalcomments, gradingform_guide{{/str}}</label>
<div class="input-group mb-3 form-inset form-inset-right"> <div class="input-group mb-3 form-inset form-inset-right">
<textarea class="form-control" type="text" name="advancedgrading[criteria][{{id}}][remark]" <textarea class="form-control" type="text" name="advancedgrading[criteria][{{id}}][remark]"
id="gradingform_guide-{{uniqid}}-criteria-{{id}}-remark" id="gradingform_guide-{{uniqid}}-criteria-{{id}}-remark"
aria-describedby="gradingform_guide-{{uniqid}}-help-{{id}}-remark" aria-describedby="gradingform_guide-{{uniqid}}-help-{{id}}-remark"
data-gradingform-guide-role="remark" data-gradingform-guide-role="remark"
>{{remark}}</textarea> >{{remark}}</textarea>
{{#hascomments}} {{#hascomments}}
<a <a
class="form-inset-item" class="form-inset-item"
href="#gradingform_guide-{{uniqid}}-criteria-{{id}}-remark-frequent-comments" href="#gradingform_guide-{{uniqid}}-criteria-{{id}}-remark-frequent-comments"
aria-controls="gradingform_guide-{{uniqid}}-criteria-{{id}}-remark-frequent-comments" aria-controls="gradingform_guide-{{uniqid}}-criteria-{{id}}-remark-frequent-comments"
aria-expanded="false" aria-expanded="false"
data-toggle="collapse" data-toggle="collapse"
role="button" role="button"
> >
{{#pix}}plus, gradingform_guide{{/pix}} {{#pix}}plus, gradingform_guide{{/pix}}
</a> </a>

View File

@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
defined('MOODLE_INTERNAL') || die();
/** /**
* Coverage information for the gradingform_guide plugin. * Coverage information for the gradingform_guide plugin.
* *
@ -25,6 +23,8 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
defined('MOODLE_INTERNAL') || die();
/** /**
* Coverage information for the gradingform_guide plugin. * Coverage information for the gradingform_guide plugin.
* *
@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
return new class extends phpunit_coverage_info { 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 = [ protected $whitelistfolders = [
'classes', 'classes',
'tests/generator', 'tests/generator',

View File

@ -17,7 +17,7 @@
/** /**
* Unit tests for core_grades\component_gradeitems; * Unit tests for core_grades\component_gradeitems;
* *
* @package core_grades * @package gradingform_guide
* @category test * @category test
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
@ -37,7 +37,7 @@ use moodle_exception;
/** /**
* Unit tests for core_grades\component_gradeitems; * Unit tests for core_grades\component_gradeitems;
* *
* @package core_grades * @package gradingform_guide
* @category test * @category test
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

View File

@ -17,7 +17,7 @@
/** /**
* Unit tests for core_grades\component_gradeitems; * Unit tests for core_grades\component_gradeitems;
* *
* @package core_grades * @package gradingform_guide
* @category test * @category test
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
@ -37,7 +37,7 @@ use moodle_exception;
/** /**
* Unit tests for core_grades\component_gradeitems; * Unit tests for core_grades\component_gradeitems;
* *
* @package core_grades * @package gradingform_guide
* @category test * @category test
* @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later