diff --git a/grade/grading/form/guide/amd/build/grades/grader/gradingpanel.min.js.map b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel.min.js.map index c8e52e6d42c..93c16158ddc 100644 --- a/grade/grading/form/guide/amd/build/grades/grader/gradingpanel.min.js.map +++ b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel.min.js.map @@ -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 .\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 \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"} \ No newline at end of file +{"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 .\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 \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"} \ No newline at end of file diff --git a/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments.min.js b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments.min.js index 893922835c3..de22d4d0182 100644 --- a/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments.min.js +++ b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments.min.js @@ -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 diff --git a/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments.min.js.map b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments.min.js.map index 8d6f2a9e834..5f600058c5c 100644 --- a/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments.min.js.map +++ b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments.min.js.map @@ -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 .\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 \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"} \ No newline at end of file +{"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 .\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 \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"} \ No newline at end of file diff --git a/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments/selectors.min.js b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments/selectors.min.js new file mode 100644 index 00000000000..d325a53f68d --- /dev/null +++ b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments/selectors.min.js @@ -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 diff --git a/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments/selectors.min.js.map b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments/selectors.min.js.map new file mode 100644 index 00000000000..539a41d8769 --- /dev/null +++ b/grade/grading/form/guide/amd/build/grades/grader/gradingpanel/comments/selectors.min.js.map @@ -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 .\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 \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"} \ No newline at end of file diff --git a/grade/grading/form/guide/amd/src/grades/grader/gradingpanel.js b/grade/grading/form/guide/amd/src/grades/grader/gradingpanel.js index 567ec6a2afe..5f0860860ed 100644 --- a/grade/grading/form/guide/amd/src/grades/grader/gradingpanel.js +++ b/grade/grading/form/guide/amd/src/grades/grader/gradingpanel.js @@ -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() 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) => { return fetchMany([{ methodname: `gradingform_guide_grader_gradingpanel_fetch`, @@ -40,7 +50,17 @@ export const fetchCurrentGrade = (component, contextid, itemname, gradeduserid) }])[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) => { const form = rootNode.querySelector('form'); diff --git a/grade/grading/form/guide/amd/src/grades/grader/gradingpanel/comments.js b/grade/grading/form/guide/amd/src/grades/grader/gradingpanel/comments.js index 8e69154f0fb..c2cbfb58d6d 100644 --- a/grade/grading/form/guide/amd/src/grades/grader/gradingpanel/comments.js +++ b/grade/grading/form/guide/amd/src/grades/grader/gradingpanel/comments.js @@ -22,24 +22,32 @@ * @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) => { const rootNode = document.querySelector(`#${rootId}`); rootNode.addEventListener('click', (e) => { - if (!e.target.matches('[data-gradingform_guide-role="frequent-comment"]')) { + if (!e.target.matches(Selectors.frequentComment)) { return; } e.preventDefault(); - const clicked = e.target.closest('[data-gradingform_guide-role="frequent-comment"]'); - const criterion = clicked.closest('[data-gradingform-guide-role="criterion"]'); - const remark = criterion.querySelector('[data-gradingform-guide-role="remark"]'); + const clicked = e.target.closest(Selectors.frequentComment); + const criterion = clicked.closest(Selectors.criterion); + const remark = criterion.querySelector(Selectors.remark); if (!remark) { return; } + // Either append the comment to an existing comment or set it as the comment. if (remark.value.trim()) { remark.value += `\n${clicked.innerHTML}`; } else { diff --git a/grade/grading/form/guide/amd/src/grades/grader/gradingpanel/comments/selectors.js b/grade/grading/form/guide/amd/src/grades/grader/gradingpanel/comments/selectors.js new file mode 100644 index 00000000000..45bd89f4417 --- /dev/null +++ b/grade/grading/form/guide/amd/src/grades/grader/gradingpanel/comments/selectors.js @@ -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 . + +/** + * 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 + * @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"} + ] + } + ] + } +}}
{{#criterion}}
- {{#str}}grade_help, gradingform_guide{{/str}}
- {{#hascomments}} - diff --git a/grade/grading/form/guide/tests/coverage.php b/grade/grading/form/guide/tests/coverage.php index cdb8005af5b..84ed112e668 100644 --- a/grade/grading/form/guide/tests/coverage.php +++ b/grade/grading/form/guide/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 gradingform_guide plugin. * @@ -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 gradingform_guide plugin. * @@ -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/grading/form/guide/tests/grades_grader_gradingpanel_guide_external_fetch_test.php b/grade/grading/form/guide/tests/grades_grader_gradingpanel_guide_external_fetch_test.php index 1f58bbddb02..bee39c5a7d9 100644 --- a/grade/grading/form/guide/tests/grades_grader_gradingpanel_guide_external_fetch_test.php +++ b/grade/grading/form/guide/tests/grades_grader_gradingpanel_guide_external_fetch_test.php @@ -17,7 +17,7 @@ /** * Unit tests for core_grades\component_gradeitems; * - * @package core_grades + * @package gradingform_guide * @category test * @copyright 2019 Andrew Nicols * @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; * - * @package core_grades + * @package gradingform_guide * @category test * @copyright 2019 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later diff --git a/grade/grading/form/guide/tests/grades_grader_gradingpanel_guide_external_store_test.php b/grade/grading/form/guide/tests/grades_grader_gradingpanel_guide_external_store_test.php index bc4635091e1..c55badf01b7 100644 --- a/grade/grading/form/guide/tests/grades_grader_gradingpanel_guide_external_store_test.php +++ b/grade/grading/form/guide/tests/grades_grader_gradingpanel_guide_external_store_test.php @@ -17,7 +17,7 @@ /** * Unit tests for core_grades\component_gradeitems; * - * @package core_grades + * @package gradingform_guide * @category test * @copyright 2019 Andrew Nicols * @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; * - * @package core_grades + * @package gradingform_guide * @category test * @copyright 2019 Andrew Nicols * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later