MDL-80750 mod_assign: Move 'notify students' option into sticky footer
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
define("mod_assign/quick_grading",["exports","core_form/submit"],(function(_exports,formSubmit){function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,formSubmit=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}
|
||||
/**
|
||||
* Module for the quick grading functionality on the submissions page.
|
||||
*
|
||||
* @module mod_assign/quick_grading
|
||||
* @copyright 2024 Mihail Geshoski <mihail@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/(formSubmit);const Selectors_quickGradingSaveRegion='[data-region="quick-grading-save"]',Selectors_notifyStudentsCheckbox='input[type="checkbox"][name="sendstudentnotifications"]',Selectors_notifyStudentsHidden='input[type="hidden"][name="sendstudentnotifications"]',Selectors_saveButton='button[type="submit"]';_exports.init=()=>{const quickGradingSaveRegion=document.querySelector(Selectors_quickGradingSaveRegion);if(quickGradingSaveRegion){const quickGradingSaveButton=quickGradingSaveRegion.querySelector(Selectors_saveButton);formSubmit.init(quickGradingSaveButton),quickGradingSaveRegion.addEventListener("change",(e=>{const notifyStudentsCheckbox=e.target.closest(Selectors_notifyStudentsCheckbox);if(notifyStudentsCheckbox){notifyStudentsCheckbox.parentNode.querySelector(Selectors_notifyStudentsHidden).disabled=notifyStudentsCheckbox.checked}}))}}}));
|
||||
|
||||
//# sourceMappingURL=quick_grading.min.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"quick_grading.min.js","sources":["../src/quick_grading.js"],"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\nimport * as formSubmit from 'core_form/submit';\n\n/**\n * Module for the quick grading functionality on the submissions page.\n *\n * @module mod_assign/quick_grading\n * @copyright 2024 Mihail Geshoski <[email protected]>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\n/** @constant {Object} The object containing the relevant selectors. */\nconst Selectors = {\n quickGradingSaveRegion: '[data-region=\"quick-grading-save\"]',\n notifyStudentsCheckbox: 'input[type=\"checkbox\"][name=\"sendstudentnotifications\"]',\n notifyStudentsHidden: 'input[type=\"hidden\"][name=\"sendstudentnotifications\"]',\n saveButton: 'button[type=\"submit\"]'\n};\n\n/**\n * Initialize module.\n */\nexport const init = () => {\n const quickGradingSaveRegion = document.querySelector(Selectors.quickGradingSaveRegion);\n if (quickGradingSaveRegion) {\n const quickGradingSaveButton = quickGradingSaveRegion.querySelector(Selectors.saveButton);\n // Initialize the submit button.\n formSubmit.init(quickGradingSaveButton);\n // Add 'change' event listener to the quick grading save region.\n quickGradingSaveRegion.addEventListener('change', e => {\n const notifyStudentsCheckbox = e.target.closest(Selectors.notifyStudentsCheckbox);\n // The target is the 'Notify student' checkbox.\n if (notifyStudentsCheckbox) {\n // The 'Notify student' option uses a hidden input and a checkbox. The hidden input is used to submit '0'\n // as a workaround when the checkbox is unchecked since unchecked checkboxes are not submitted with the\n // form. Therefore, we need to enable or disable the hidden input based on the checkbox state.\n const notifyStudentsHidden = notifyStudentsCheckbox.parentNode.querySelector(Selectors.notifyStudentsHidden);\n notifyStudentsHidden.disabled = notifyStudentsCheckbox.checked;\n }\n });\n }\n};\n"],"names":["Selectors","quickGradingSaveRegion","document","querySelector","quickGradingSaveButton","formSubmit","init","addEventListener","e","notifyStudentsCheckbox","target","closest","parentNode","disabled","checked"],"mappings":";;;;;;;wBA0BMA,iCACsB,qCADtBA,iCAEsB,0DAFtBA,+BAGoB,wDAHpBA,qBAIU,sCAMI,WACVC,uBAAyBC,SAASC,cAAcH,qCAClDC,uBAAwB,OAClBG,uBAAyBH,uBAAuBE,cAAcH,sBAEpEK,WAAWC,KAAKF,wBAEhBH,uBAAuBM,iBAAiB,UAAUC,UACxCC,uBAAyBD,EAAEE,OAAOC,QAAQX,qCAE5CS,uBAAwB,CAIKA,uBAAuBG,WAAWT,cAAcH,gCACxDa,SAAWJ,uBAAuBK"}
|
||||
@@ -0,0 +1,56 @@
|
||||
// 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/>.
|
||||
|
||||
import * as formSubmit from 'core_form/submit';
|
||||
|
||||
/**
|
||||
* Module for the quick grading functionality on the submissions page.
|
||||
*
|
||||
* @module mod_assign/quick_grading
|
||||
* @copyright 2024 Mihail Geshoski <[email protected]>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/** @constant {Object} The object containing the relevant selectors. */
|
||||
const Selectors = {
|
||||
quickGradingSaveRegion: '[data-region="quick-grading-save"]',
|
||||
notifyStudentsCheckbox: 'input[type="checkbox"][name="sendstudentnotifications"]',
|
||||
notifyStudentsHidden: 'input[type="hidden"][name="sendstudentnotifications"]',
|
||||
saveButton: 'button[type="submit"]'
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize module.
|
||||
*/
|
||||
export const init = () => {
|
||||
const quickGradingSaveRegion = document.querySelector(Selectors.quickGradingSaveRegion);
|
||||
if (quickGradingSaveRegion) {
|
||||
const quickGradingSaveButton = quickGradingSaveRegion.querySelector(Selectors.saveButton);
|
||||
// Initialize the submit button.
|
||||
formSubmit.init(quickGradingSaveButton);
|
||||
// Add 'change' event listener to the quick grading save region.
|
||||
quickGradingSaveRegion.addEventListener('change', e => {
|
||||
const notifyStudentsCheckbox = e.target.closest(Selectors.notifyStudentsCheckbox);
|
||||
// The target is the 'Notify student' checkbox.
|
||||
if (notifyStudentsCheckbox) {
|
||||
// The 'Notify student' option uses a hidden input and a checkbox. The hidden input is used to submit '0'
|
||||
// as a workaround when the checkbox is unchecked since unchecked checkboxes are not submitted with the
|
||||
// form. Therefore, we need to enable or disable the hidden input based on the checkbox state.
|
||||
const notifyStudentsHidden = notifyStudentsCheckbox.parentNode.querySelector(Selectors.notifyStudentsHidden);
|
||||
notifyStudentsHidden.disabled = notifyStudentsCheckbox.checked;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -439,6 +439,7 @@ $string['noteamgrader'] = 'Not a member of any group, so unable to make submissi
|
||||
$string['notgraded'] = 'Not graded';
|
||||
$string['notgradedyet'] = 'Not graded yet';
|
||||
$string['notifications'] = 'Notifications';
|
||||
$string['notifystudents'] = 'Notify students';
|
||||
$string['nousersselected'] = 'No users selected';
|
||||
$string['nousers'] = 'No users';
|
||||
$string['numberofdraftsubmissions'] = 'Drafts';
|
||||
|
||||
@@ -4610,15 +4610,16 @@ class assign {
|
||||
'perpage' => $gradingtable->get_paging_selector(),
|
||||
'pagingbar' => $gradingtable->get_paging_bar(),
|
||||
'hassubmit' => $usequickgrading,
|
||||
'sendstudentnotifications' => $this->get_instance()->sendstudentnotifications,
|
||||
];
|
||||
$footer = new core\output\sticky_footer($OUTPUT->render_from_template('mod_assign/grading_sticky_footer', $footerdata));
|
||||
|
||||
if ($usequickgrading) {
|
||||
$page = optional_param('page', null, PARAM_INT);
|
||||
$PAGE->requires->js_call_amd('mod_assign/quick_grading', 'init', []);
|
||||
$quickformparams = [
|
||||
'cm' => $this->get_course_module()->id,
|
||||
'gradingtable' => $table,
|
||||
'sendstudentnotifications' => $this->get_instance()->sendstudentnotifications,
|
||||
'page' => $page,
|
||||
'footer' => $this->get_renderer()->render($footer),
|
||||
];
|
||||
|
||||
@@ -54,10 +54,6 @@ class mod_assign_quick_grading_form extends moodleform {
|
||||
$mform->addElement('hidden', 'lastpage', $instance['page']);
|
||||
$mform->setType('lastpage', PARAM_INT);
|
||||
|
||||
// Skip notifications option.
|
||||
$mform->addElement('selectyesno', 'sendstudentnotifications', get_string('sendstudentnotifications', 'assign'));
|
||||
$mform->setDefault('sendstudentnotifications', $instance['sendstudentnotifications']);
|
||||
|
||||
// No need to add a submit button.
|
||||
// The submit button is in the footer.
|
||||
$mform->addElement('html', $instance['footer']);
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
{
|
||||
"perpage": "<label>Show<select name='perpage' class='custom-select'><option value='-1'>All</select></label>",
|
||||
"pagingbar": "<nav class='pagination pagination-centered justify-content-center'><ul class='mt-1 pagination '><li class='page-item active'><a href='#' class='page-link'><span>1</span></a></li></ul></nav>",
|
||||
"hassubmit": true
|
||||
"hassubmit": true,
|
||||
"sendstudentnotifications": true
|
||||
}
|
||||
}}
|
||||
<div class="col-auto">
|
||||
@@ -38,13 +39,15 @@
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
{{#hassubmit}}
|
||||
<button type="submit" id="{{uniqid}}-submit" class="btn btn-primary">
|
||||
{{#str}}save{{/str}}
|
||||
</button>
|
||||
{{#js}}
|
||||
require(['core_form/submit'], function(Submit) {
|
||||
Submit.init("{{uniqid}}-submit");
|
||||
});
|
||||
{{/js}}
|
||||
<div class="d-flex align-items-center" data-region="quick-grading-save">
|
||||
<div class="me-4">
|
||||
<input type="hidden" name="sendstudentnotifications" value="0" {{#sendstudentnotifications}}disabled{{/sendstudentnotifications}}>
|
||||
<input type="checkbox" id="send-student-notifications-{{uniqid}}" name="sendstudentnotifications" {{#sendstudentnotifications}}checked="checked"{{/sendstudentnotifications}}>
|
||||
<label for="send-student-notifications-{{uniqid}}" class="m-0">{{#str}} notifystudents, mod_assign {{/str}}</label>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{#str}}save{{/str}}
|
||||
</button>
|
||||
</div>
|
||||
{{/hassubmit}}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user