���ѧۧݧ�ӧ�� �ާ֧ߧ֧էا֧� - ���֧էѧܧ�ڧ��ӧѧ�� - /home3/cpr76684/public_html/grader.tar
���ѧ٧ѧ�
gradingpanel/scale.js 0000644 00000003373 15152100203 0010617 0 ustar 00 // 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/>. /** * Grading panel for simple direct grading. * * @module core_grades/grades/grader/gradingpanel/scale * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ import {saveGrade, fetchGrade} from './repository'; import {compareData} from 'core_grades/grades/grader/gradingpanel/comparison'; // Note: We use jQuery.serializer here until we can rewrite Ajax to use XHR.send() import jQuery from 'jquery'; import {invalidResult} from './normalise'; export const fetchCurrentGrade = (...args) => fetchGrade('scale')(...args); export const storeCurrentGrade = (component, context, itemname, userId, notifyUser, rootNode) => { const form = rootNode.querySelector('form'); const grade = form.querySelector('select[name="grade"]'); if (!grade.checkValidity() || !grade.value.trim()) { return invalidResult; } if (compareData(form) === true) { return saveGrade('scale')(component, context, itemname, userId, notifyUser, jQuery(form).serialize()); } else { return ''; } }; gradingpanel/repository.js 0000644 00000003344 15152100203 0011745 0 ustar 00 // 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/>. /** * Repository for simple direct grading panel. * * @module core_grades/grades/grader/gradingpanel/repository * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ import {call as fetchMany} from 'core/ajax'; import {normaliseResult} from './normalise'; export const fetchGrade = type => (component, contextid, itemname, gradeduserid) => { return fetchMany([{ methodname: `core_grades_grader_gradingpanel_${type}_fetch`, args: { component, contextid, itemname, gradeduserid, }, }])[0]; }; export const saveGrade = type => async(component, contextid, itemname, gradeduserid, notifyUser, formdata) => { return normaliseResult(await fetchMany([{ methodname: `core_grades_grader_gradingpanel_${type}_store`, args: { component, contextid, itemname, gradeduserid, notifyuser: notifyUser, formdata, }, }])[0]); }; gradingpanel/normalise.js 0000644 00000003373 15152100203 0011521 0 ustar 00 // 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/>. /** * Error handling and normalisation of provided data. * * @module core_grades/grades/grader/gradingpanel/normalise * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ /** * Normalise a resultset for consumption by the grader. * * @param {Object} result The result returned from a grading web service * @return {Object} */ export const normaliseResult = result => { return { result, failed: !!result.warnings.length, success: !result.warnings.length, error: null, }; }; /** * Return the resultset used to describe an invalid result. * * @return {Object} */ export const invalidResult = () => { return { success: false, failed: false, result: {}, error: null, }; }; /** * Return the resultset used to describe a failed update. * * @param {Object} error * @return {Object} */ export const failedUpdate = error => { return { success: false, failed: true, result: {}, error, }; }; gradingpanel/point.js 0000644 00000004363 15152100203 0010661 0 ustar 00 // 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/>. /** * Grading panel for simple direct grading. * * @module core_grades/grades/grader/gradingpanel/point * @copyright 2019 Andrew Nicols <andrew@nicols.co.uk> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ import {saveGrade, fetchGrade} from './repository'; import {compareData} from 'core_grades/grades/grader/gradingpanel/comparison'; // Note: We use jQuery.serializer here until we can rewrite Ajax to use XHR.send() import jQuery from 'jquery'; import {invalidResult} from './normalise'; /** * Fetch the current grade for a user. * * @param {object} args * @param {String} args.component * @param {Number} args.context * @param {String} args.itemname * @param {Number} args.userId * @param {Element} args.rootNode * @returns {Object} */ export const fetchCurrentGrade = (...args) => fetchGrade('point')(...args); /** * Store a new grade for a user. * * @param {String} component * @param {Number} context * @param {String} itemname * @param {Number} userId * @param {Boolean} notifyUser * @param {Element} rootNode * @returns {Object} */ export const storeCurrentGrade = async(component, context, itemname, userId, notifyUser, rootNode) => { const form = rootNode.querySelector('form'); const grade = form.querySelector('input[name="grade"]'); if (!grade.checkValidity() || !grade.value.trim()) { return invalidResult; } if (compareData(form) === true) { return await saveGrade('point')(component, context, itemname, userId, notifyUser, jQuery(form).serialize()); } else { return ''; } }; gradingpanel/comparison.js 0000644 00000006046 15152100203 0011702 0 ustar 00 // 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/>. /** * Compare a given form's values and its previously set data attributes. * * @module core_grades/grades/grader/gradingpanel/comparison * @copyright 2019 Mathew May <mathew.solutions> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ export const fillInitialValues = (form) => { Array.prototype.forEach.call(form.elements, (input) => { if (input.type === 'submit' || input.type === 'button') { return; } else if (input.type === 'radio' || input.type === 'checkbox') { input.dataset.initialValue = JSON.stringify(input.checked); } else if (typeof input.value !== 'undefined') { input.dataset.initialValue = JSON.stringify(input.value); } else if (input.type === 'select-one') { Array.prototype.forEach.call(input.options, (option) => { option.dataset.initialValue = JSON.stringify(option.selected); }); } }); }; /** * Compare the form data with the initial form data from when the form was set up. * * If values have changed, return a truthy value. * * @param {HTMLElement} form * @return {Boolean} */ export const compareData = (form) => { const result = Array.prototype.some.call(form.elements, (input) => { if (input.type === 'submit' || input.type === 'button') { return false; } else if (input.type === 'radio' || input.type === 'checkbox') { if (typeof input.dataset.initialValue !== 'undefined') { return input.dataset.initialValue !== JSON.stringify(input.checked); } } else if (typeof input.value !== 'undefined') { if (typeof input.dataset.initialValue !== 'undefined') { return input.dataset.initialValue !== JSON.stringify(input.value); } } else if (input.type === 'select-one') { return Array.prototype.some.call(input.options, (option) => { if (typeof option.dataset.initialValue !== 'undefined') { return option.dataset.initialValue !== JSON.stringify(option.selected); } return false; }); } // No value found to check. Assume that there were changes. return true; }); // Fill the initial values again as the form may not be reloaded. fillInitialValues(form); return result; }; gradingpanel/scale.mustache 0000644 00000003064 15152344645 0012035 0 ustar 00 {{! 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 core_grades/grades/grader/gradingpanel/scale Scale-based grading template for use in the grading panel. Context variables required for this template: Example context (json): { "value": 1, "selected": true, "title": "Motivational" } }} <form> <div class="form-group"> <label for="core_grades-grade-{{uniqid}}">{{#str}}gradenoun, moodle{{/str}}</label> <select class="form-control" name="grade" id="core_grades-grade-{{uniqid}}" aria-describedby="core_grades-help-{{uniqid}}"> <option value="-1">{{#str}} nograde, moodle{{/str}}</option> {{#options}} <option value="{{value}}" {{#selected}}selected{{/selected}}>{{title}}</option> {{/options}} </select> <small id="core_grades-help-{{uniqid}}" class="form-text text-muted">{{#str}}grade_help, core_grades{{/str}}</small> </div> </form> gradingpanel/point_blank.mustache 0000644 00000001634 15152344645 0013247 0 ustar 00 {{! 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 core_grades/grades/grader/gradingpanel/point_black Point-based grading template for use in the grading panel. Context variables required for this template: Example context (json): { } }} gradingpanel/point.mustache 0000644 00000002512 15152344645 0012074 0 ustar 00 {{! 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 core_grades/grades/grader/gradingpanel/point Point-based grading template for use in the grading panel. Context variables required for this template: Example context (json): { "grade": 47 } }} <form> <div class="form-group"> <label for="core_grades-grade-{{uniqid}}">{{#str}}gradenoun, moodle{{/str}}</label> <input class="form-control" type="number" name="grade" value="{{grade}}" id="core_grades-grade-{{uniqid}}" aria-describedby="core_grades-help-{{uniqid}}"> <small id="core_grades-help-{{uniqid}}" class="form-text text-muted">{{#str}}grade_help, core_grades{{/str}}</small> </div> </form>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | ���֧ߧ֧�ѧ�ڧ� ����ѧߧڧ��: 0 |
proxy
|
phpinfo
|
���ѧ����ۧܧ�