diff --git a/.github/workflows/moodle-plugin-ci.yml b/.github/workflows/moodle-plugin-ci.yml
index 33cdbc8..b9b3fc2 100644
--- a/.github/workflows/moodle-plugin-ci.yml
+++ b/.github/workflows/moodle-plugin-ci.yml
@@ -17,7 +17,7 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
mariadb:
- image: mariadb:10.6
+ image: mariadb:10
env:
MYSQL_USER: 'root'
MYSQL_ALLOW_EMPTY_PASSWORD: "true"
@@ -138,9 +138,9 @@ jobs:
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
- IGNORE_PATHS: 'moodle/tests/fixtures,moodle/Sniffs,classes/vendor'
- PHPCS_IGNORE_PATHS: /^classes\/vendor/
- PHPDOCCHECKER_IGNORE_PATHS: /^classes\/vendor/
+ IGNORE_PATHS: 'moodle/tests/fixtures,moodle/Sniffs,classes/vendor,fonts'
+ PHPCS_IGNORE_PATHS: '/^classes\/vendor/,/^fonts/'
+ PHPDOCCHECKER_IGNORE_PATHS: '/^classes\/vendor/,/^fonts/'
MUSTACHE_IGNORE_NAMES: 'report.mustache,questionnaire.mustache'
- name: PHP Lint
@@ -154,11 +154,11 @@ jobs:
- name: Moodle Code Checker
if: ${{ always() }}
- run: moodle-plugin-ci phpcs --max-warnings 0 || true
+ run: moodle-plugin-ci phpcs --max-warnings 0
- name: Moodle PHPDoc Checker
if: ${{ always() }}
- run: moodle-plugin-ci phpdoc || true
+ run: moodle-plugin-ci phpdoc
- name: Validating
if: ${{ always() }}
@@ -169,17 +169,16 @@ jobs:
run: moodle-plugin-ci savepoints
- name: Mustache Lint
- continue-on-error: true # This step will show errors but will not fail
if: ${{ always() }}
run: moodle-plugin-ci mustache
- name: Grunt
if: ${{ always() }}
- run: moodle-plugin-ci grunt || true
+ run: moodle-plugin-ci grunt --max-lint-warnings 0
- name: PHPUnit tests
if: ${{ always() }}
- run: moodle-plugin-ci phpunit --coverage-text || true
+ run: moodle-plugin-ci phpunit --fail-on-warning
- name: Behat features
if: ${{ always() }}
diff --git a/amd/build/edit_items.min.js.map b/amd/build/edit_items.min.js.map
index 9df38ef..87347ea 100644
--- a/amd/build/edit_items.min.js.map
+++ b/amd/build/edit_items.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"edit_items.min.js","sources":["../src/edit_items.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 .\n\n/**\n * AMD code for the frequently used comments chooser for the marking guide grading form.\n *\n * @module mod_verbalfeedback/edit_items\n * @class edit_items\n * @copyright 2020 Kevin Tippenhauer \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'core/ajax',\n 'core/str',\n 'core/yui'\n], function($, Templates, Notification, Ajax) {\n\n /**\n * List of action selectors.\n *\n * @type {{CATEGORY_PERCENTAGE_CHANGED: string}, {ITEM_MULTIPLIER_CHANGED: string}}\n */\n let ACTIONS = {\n CATEGORY_PERCENTAGE_CHANGED: '[data-action=\"change-category-percentage\"]',\n ITEM_MULTIPLIER_CHANGED: '[data-action=\"change-item-multiplier\"]',\n };\n\n let editItems = function() {\n this.registerEvents();\n };\n\n let updateSum = function() {\n let sum = 0.00;\n $('.category-percentage').each(function() {\n sum += parseFloat($(this).val());\n });\n\n if(sum != 1) {\n $('.category-percentage').addClass('is-invalid');\n $('#percentage-total').addClass('text-danger');\n $('#percentage-total-value').text(parseFloat(sum * 100).toFixed(2));\n } else {\n $('.category-percentage').removeClass('is-invalid');\n $('#percentage-total').removeClass('text-danger');\n $('#percentage-total-value').text(parseFloat(sum * 100).toFixed(2));\n }\n };\n\n editItems.callCategoryAction = function(action, elem) {\n updateSum();\n\n let promises = Ajax.call([\n {\n methodname: action,\n args: {\n categoryid: elem.data('categoryid'),\n percentage: elem.val()\n }\n }\n ]);\n promises[0].done(function(response) {\n if (response.success) {\n elem.next().stop(true, true).show().fadeOut(1000);\n } else {\n let warnings = response.warnings.join($('
'));\n throw new Error(warnings);\n }\n }).fail(Notification.exception);\n };\n\n editItems.callItemAction = function(action, elem) {\n let promises = Ajax.call([\n {\n methodname: action,\n args: {\n itemid: elem.data('itemid'),\n multiplier: elem.val()\n }\n }\n ]);\n promises[0].done(function(response) {\n if (response.success) {\n elem.next().stop(true, true).show().fadeOut(1000);\n } else {\n let warnings = response.warnings.join($('
'));\n throw new Error(warnings);\n }\n }).fail(Notification.exception);\n };\n\n editItems.prototype.registerEvents = function() {\n\n $(ACTIONS.CATEGORY_PERCENTAGE_CHANGED).change(function(e) {\n e.preventDefault();\n editItems.callCategoryAction('mod_verbalfeedback_update_category_percentage', $(this));\n\n });\n\n $(ACTIONS.ITEM_MULTIPLIER_CHANGED).change(function(e) {\n e.preventDefault();\n if(this.value > 5) {\n this.value = 5.00;\n }\n this.value = parseFloat(this.value).toFixed(2);\n editItems.callItemAction('mod_verbalfeedback_update_item_multiplier', $(this));\n });\n };\n\n editItems.prototype.updatePercentageSum = updateSum;\n return editItems;\n});\n"],"names":["define","$","Templates","Notification","Ajax","ACTIONS","editItems","registerEvents","updateSum","sum","each","parseFloat","this","val","addClass","text","toFixed","removeClass","callCategoryAction","action","elem","call","methodname","args","categoryid","data","percentage","done","response","success","warnings","join","Error","next","stop","show","fadeOut","fail","exception","callItemAction","itemid","multiplier","prototype","change","e","preventDefault","value","updatePercentageSum"],"mappings":";;;;;;;;AAuBAA,uCAAO,CACH,SACA,iBACA,oBACA,YACA,WACA,aACD,SAASC,EAAGC,UAAWC,aAAcC,UAOhCC,oCAC6B,6CAD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EAAEC,iBACCjC,KAAKkC,MAAQ,SACTA,MAAQ,QAEVA,MAAQnC,WAAWC,KAAKkC,OAAO9B,QAAQ,GAC5CV,UAAUiC,eAAe,4CAA6CtC,EAAEW,WAIhFN,UAAUoC,UAAUK,oBAAsBvC,UACnCF"}
\ No newline at end of file
+{"version":3,"file":"edit_items.min.js","sources":["../src/edit_items.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 .\n\n/**\n * AMD code for the frequently used comments chooser for the marking guide grading form.\n *\n * @module mod_verbalfeedback/edit_items\n * @class edit_items\n * @copyright 2020 Kevin Tippenhauer \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine([\n 'jquery',\n 'core/templates',\n 'core/notification',\n 'core/ajax',\n 'core/str',\n 'core/yui'\n], function($, Templates, Notification, Ajax) {\n\n /**\n * List of action selectors.\n *\n * @type {{CATEGORY_PERCENTAGE_CHANGED: string}, {ITEM_MULTIPLIER_CHANGED: string}}\n */\n let ACTIONS = {\n CATEGORY_PERCENTAGE_CHANGED: '[data-action=\"change-category-percentage\"]',\n ITEM_MULTIPLIER_CHANGED: '[data-action=\"change-item-multiplier\"]',\n };\n\n let editItems = function() {\n this.registerEvents();\n };\n\n let updateSum = function() {\n let sum = 0.00;\n $('.category-percentage').each(function() {\n sum += parseFloat($(this).val());\n });\n\n if (sum != 1) {\n $('.category-percentage').addClass('is-invalid');\n $('#percentage-total').addClass('text-danger');\n $('#percentage-total-value').text(parseFloat(sum * 100).toFixed(2));\n } else {\n $('.category-percentage').removeClass('is-invalid');\n $('#percentage-total').removeClass('text-danger');\n $('#percentage-total-value').text(parseFloat(sum * 100).toFixed(2));\n }\n };\n\n editItems.callCategoryAction = function(action, elem) {\n updateSum();\n\n let promises = Ajax.call([\n {\n methodname: action,\n args: {\n categoryid: elem.data('categoryid'),\n percentage: elem.val()\n }\n }\n ]);\n promises[0].done(function(response) {\n if (response.success) {\n elem.next().stop(true, true).show().fadeOut(1000);\n } else {\n let warnings = response.warnings.join($('
'));\n throw new Error(warnings);\n }\n }).fail(Notification.exception);\n };\n\n editItems.callItemAction = function(action, elem) {\n let promises = Ajax.call([\n {\n methodname: action,\n args: {\n itemid: elem.data('itemid'),\n multiplier: elem.val()\n }\n }\n ]);\n promises[0].done(function(response) {\n if (response.success) {\n elem.next().stop(true, true).show().fadeOut(1000);\n } else {\n let warnings = response.warnings.join($('
'));\n throw new Error(warnings);\n }\n }).fail(Notification.exception);\n };\n\n editItems.prototype.registerEvents = function() {\n\n $(ACTIONS.CATEGORY_PERCENTAGE_CHANGED).change(function(e) {\n e.preventDefault();\n editItems.callCategoryAction('mod_verbalfeedback_update_category_percentage', $(this));\n\n });\n\n $(ACTIONS.ITEM_MULTIPLIER_CHANGED).change(function(e) {\n e.preventDefault();\n if (this.value > 5) {\n this.value = 5.00;\n }\n this.value = parseFloat(this.value).toFixed(2);\n editItems.callItemAction('mod_verbalfeedback_update_item_multiplier', $(this));\n });\n };\n\n editItems.prototype.updatePercentageSum = updateSum;\n return editItems;\n});\n"],"names":["define","$","Templates","Notification","Ajax","ACTIONS","editItems","registerEvents","updateSum","sum","each","parseFloat","this","val","addClass","text","toFixed","removeClass","callCategoryAction","action","elem","call","methodname","args","categoryid","data","percentage","done","response","success","warnings","join","Error","next","stop","show","fadeOut","fail","exception","callItemAction","itemid","multiplier","prototype","change","e","preventDefault","value","updatePercentageSum"],"mappings":";;;;;;;;AAuBAA,uCAAO,CACH,SACA,iBACA,oBACA,YACA,WACA,aACD,SAASC,EAAGC,UAAWC,aAAcC,UAOh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O,SAASC,GAC/CA,EAAEC,iBACEjC,KAAKkC,MAAQ,SACVA,MAAQ,QAEVA,MAAQnC,WAAWC,KAAKkC,OAAO9B,QAAQ,GAC5CV,UAAUiC,eAAe,4CAA6CtC,EAAEW,WAIhFN,UAAUoC,UAAUK,oBAAsBvC,UACnCF"}
\ No newline at end of file
diff --git a/amd/build/questionnaire.min.js.map b/amd/build/questionnaire.min.js.map
index 19d9207..3fc9a31 100644
--- a/amd/build/questionnaire.min.js.map
+++ b/amd/build/questionnaire.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"questionnaire.min.js","sources":["../src/questionnaire.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 .\n\n/**\n * AMD code for the frequently used comments chooser for the marking guide grading form.\n *\n * @module mod_verbalfeedback/questionnaire\n * @class view\n * @copyright 2020 Kevin Tippenhauer \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/notification',\n 'core/ajax',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'\n], function($, Templates, Notification, Ajax, Str, ModalFactory, ModalEvents) {\n\n var responses = [];\n\n let editor;\n const getEditor = function() {\n if (editor) {\n return editor;\n }\n if ($('.editor_atto').length > 0) {\n editor = 'atto';\n } else if (window.tinyMCE) {\n editor = 'tiny';\n } else {\n editor = 'textarea';\n }\n return editor;\n };\n\n const setComment = function(row, classSelector, comment, append = false) {\n if (getEditor() === 'atto') {\n const editorcontent = row.find(classSelector + '.editor_atto_content');\n if (append) {\n editorcontent.append(\"\");\n return;\n }\n editorcontent.html(comment);\n return;\n }\n const commentId = row.find(classSelector).attr('id');\n if (commentId) {\n const $input = $('#' + commentId);\n if (getEditor() === 'tiny') {\n if (append) {\n window.tinyMCE.get(commentId).insertContent('
');\n return;\n }\n window.tinyMCE.get(commentId).setContent(comment);\n return;\n }\n if (append) {\n const oldComment = $input.val();\n if (oldComment.trim() !== '') {\n $input.val(oldComment + \"\\n\\n\" + comment);\n return;\n }\n }\n $input.val(comment);\n }\n };\n\n const getComment = function (row, classSel) {\n if (getEditor() === 'atto') {\n let comment = row.find(classSel + '.editor_atto_content').html();\n return comment.replace(/<[^>]+>/g,'').trim() === '' ? '' : comment; // drop empty comments\n }\n const commentId = row.find(classSel).attr('id');\n if (commentId) {\n let comment = '';\n if (getEditor() === 'tiny') {\n comment = window.tinyMCE.get(commentId).getContent();\n } else {\n comment = $('#' + commentId).val();\n }\n return comment.replace(/<[^>]+>/g,'').trim() === '' ? '' : comment; // drop empty comments\n }\n return '';\n };\n\n var questionnaire = function() {\n this.registerEvents();\n\n // Prefill responses array.\n $('[data-region=\"question-row\"]').each(function() {\n responses[$(this).data('criterionid')] = {\n criterionid: $(this).data('criterionid'),\n value: null,\n studentcomment: \"\",\n privatecomment: \"\"\n };\n });\n\n let questionnaireTable = $('[data-region=\"questionnaire\"]');\n\n if(questionnaireTable.data('preview') == true) { // dont use '===' as $preview is '1' not 'true'.\n // do not look for existing submission on preview page\n return;\n }\n\n let fromUser = questionnaireTable.data('fromuserid');\n let toUser = questionnaireTable.data('touserid');\n let verbalfeedbackId = questionnaireTable.data('verbalfeedbackid');\n let submissionId = questionnaireTable.data('submissionid');\n\n let promises = Ajax.call([\n {\n methodname: 'mod_verbalfeedback_get_responses',\n args: {\n verbalfeedbackid: verbalfeedbackId,\n fromuserid: fromUser,\n touserid: toUser,\n submissionid: submissionId\n }\n }\n ]);\n\n promises[0].done(function(result) {\n $.each(result.responses, function() {\n let response = this;\n responses[response.criterionid]['criterionid'] = response.criterionid;\n responses[response.criterionid]['value'] = response.value;\n responses[response.criterionid]['studentcomment'] = response.studentcomment;\n responses[response.criterionid]['privatecomment'] = response.privatecomment;\n\n $('[data-region=\"question-row\"]').each(function() {\n if ($(this).data('criterionid') === response.criterionid) {\n let options = $(this).find('.scaleoption');\n if (options) {\n options.each(function() {\n // Mark selected option as selected.\n let selected = $(this).find('label');\n if (selected.data('value') === response.value) {\n selected.removeClass('badge-secondary');\n selected.removeClass('badge-info');\n selected.addClass('badge-success');\n } else if (selected.data('value') === \"\" && response.value === null) {\n selected.removeClass('badge-secondary');\n selected.removeClass('badge-info');\n selected.addClass('badge-success');\n }\n });\n }\n if (response.studentcomment !== '') {\n setComment($(this), '.student-comment', response.studentcomment);\n }\n if (response.privatecomment !== '') {\n setComment($(this), '.private-comment', response.privatecomment);\n }\n }\n });\n });\n }).fail(Notification.exception);\n };\n\n questionnaire.prototype.registerEvents = function() {\n $('.scaleoption').click(function(e) {\n e.preventDefault();\n\n let row = $(this).parents('[data-region=\"question-row\"]');\n let options = row.find('label');\n\n // Deselect the option that has been selected.\n $.each(options, function() {\n if ($(this).hasClass('badge-success')) {\n $(this).removeClass('badge-success');\n $(this).addClass('badge-secondary');\n\n var forId = $(this).attr('for');\n var optionRadio = $(\"#\" + forId);\n optionRadio.removeAttr('checked');\n }\n });\n\n // Mark selected option as selected.\n let selected = $(this).find('label');\n selected.removeClass('badge-secondary');\n selected.removeClass('badge-info');\n selected.addClass('badge-success');\n\n // Mark hidden radio button as checked.\n let radio = $(\"#\" + selected.attr('for'));\n radio.attr('checked', 'checked');\n let criterionid = row.data('criterionid');\n\n // Add this selected value to the array of responses.\n if (selected.data('value') === \"\") { // === is necessary because == \"0\" equals true;\n responses[criterionid]['value'] = null;\n } else {\n responses[criterionid]['value'] = selected.data('value');\n }\n });\n\n $('.scaleoptionlabel').hover(function(e) {\n e.preventDefault();\n\n if (!$(this).hasClass('badge-success')) {\n if ($(this).hasClass('badge-secondary')) {\n $(this).removeClass('badge-secondary');\n $(this).addClass('badge-info');\n } else {\n $(this).addClass('badge-secondary');\n $(this).removeClass('badge-info');\n }\n }\n });\n\n $('.detail-scaleoption').click(function(e) {\n e.preventDefault();\n\n let row = $(this).parents('[data-region=\"detailed-rating\"]');\n let value = $(this).find('.detail-scaleoptionlabel').data(\"value\");\n setComment(row, '.student-comment', value, true);\n });\n\n $('.detail-scaleoptionlabel').hover(function(e) {\n e.preventDefault();\n\n if (!$(this).hasClass('badge-success')) {\n if ($(this).hasClass('badge-secondary')) {\n $(this).removeClass('badge-secondary');\n $(this).addClass('badge-info');\n } else {\n $(this).addClass('badge-secondary');\n $(this).removeClass('badge-info');\n }\n }\n });\n\n $(\"#save-feedback\").click(function() {\n saveResponses(false);\n });\n\n $(\"#submit-feedback\").click(function() {\n saveResponses(true);\n });\n\n $(\".btn-detail-rating\").click(function(e) {\n e.preventDefault();\n let row = $(this).parents('[data-region=\"question-row\"]');\n let detailedRating = row.find(\".detailed-rating\");\n if(detailedRating.hasClass(\"hidden\")) {\n detailedRating.removeClass(\"hidden\");\n $(this).html(\"−\");\n } else {\n detailedRating.addClass(\"hidden\");\n $(this).html(\"+\");\n }\n\n });\n };\n\n /**\n * Save the responses.\n *\n * @param {boolean} finalise\n */\n function saveResponses(finalise) {\n\n $('.student-comment').each(function() {\n let row = $(this).parents('[data-region=\"question-row\"]');\n responses[row.data('criterionid')]['studentcomment'] = getComment(row,'.student-comment');\n });\n $('.private-comment').each(function() {\n let row = $(this).parents('[data-region=\"question-row\"]');\n responses[row.data('criterionid')]['privatecomment'] = getComment(row, '.private-comment');\n });\n\n let questionnaireTable = $('[data-region=\"questionnaire\"]');\n let toUser = questionnaireTable.data('touserid');\n let toUserFullname = questionnaireTable.data('tousername');\n let verbalfeedbackId = questionnaireTable.data('verbalfeedbackid');\n let submissionId = questionnaireTable.data('submissionid');\n let anonymous = questionnaireTable.data('anonymous');\n\n if (anonymous && finalise) {\n // Show confirmation dialogue to anonymise the feedback responses.\n let messageStrings = [\n {\n key: 'finaliseanonymousfeedback',\n component: 'mod_verbalfeedback'\n },\n {\n key: 'confirmfinaliseanonymousfeedback',\n component: 'mod_verbalfeedback',\n param: {\n 'name': toUserFullname\n }\n }\n ];\n\n Str.get_strings(messageStrings, 'mod_verbalfeedback').done(function(messages) {\n showConfirmationDialogue(messages[0], messages[1], verbalfeedbackId, submissionId, toUser, responses, finalise);\n }).fail(Notification.exception);\n } else {\n // Just save the responses.\n submitResponses(verbalfeedbackId, submissionId, toUser, responses, finalise);\n }\n }\n\n /**\n * Send the responses to the server.\n *\n * @param {number} verbalfeedbackId\n * @param {number} submissionId\n * @param {number} toUser\n * @param {array} responses\n * @param {boolean} finalise\n */\n function submitResponses(verbalfeedbackId, submissionId, toUser, responses, finalise) {\n let responseObjects = [];\n for (const tuple of Object.entries(responses)) {\n if (tuple[1] !== null) {\n responseObjects.push(tuple[1]);\n }\n }\n\n let promises = Ajax.call([\n {\n methodname: 'mod_verbalfeedback_save_responses',\n args: {\n verbalfeedbackid: verbalfeedbackId,\n submissionid: submissionId,\n touserid: toUser,\n responses: responseObjects,\n complete: finalise\n }\n }\n ]);\n\n promises[0].done(function(response) {\n // console.log(response);\n let messageStrings = [\n {\n key: 'responsessaved',\n component: 'mod_verbalfeedback'\n },\n {\n key: 'errorresponsesavefailed',\n component: 'mod_verbalfeedback'\n }\n ];\n\n Str.get_strings(messageStrings).done(function(messages) {\n let notificationData = {};\n if (response.result) {\n notificationData.message = messages[0];\n notificationData.type = \"success\";\n } else {\n notificationData.message = messages[1];\n notificationData.type = \"error\";\n }\n Notification.addNotification(notificationData);\n }).fail(Notification.exception);\n\n window.location = response.redirurl;\n }).fail(Notification.exception);\n }\n\n /**\n * Renders the confirmation dialogue to submit and finalise the responses.\n *\n * @param {string} title\n * @param {string} confirmationMessage\n * @param {number} verbalfeedbackId\n * @param {number} submissionId\n * @param {number} toUser\n * @param {Array} responses\n * @param {boolean} finalise\n */\n function showConfirmationDialogue(title, confirmationMessage, verbalfeedbackId, submissionId, toUser, responses, finalise) {\n let confirmButtonTextPromise = Str.get_string('finalise', 'mod_verbalfeedback');\n let confirmModalPromise = ModalFactory.create({\n title: title,\n body: confirmationMessage,\n large: true,\n type: ModalFactory.types.SAVE_CANCEL\n });\n $.when(confirmButtonTextPromise, confirmModalPromise).done(function(confirmButtonText, modal) {\n modal.setSaveButtonText(confirmButtonText);\n\n // Display the dialogue.\n modal.show();\n\n // On hide handler.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Empty modal contents when it's hidden.\n modal.setBody('');\n });\n\n modal.getRoot().on(ModalEvents.save, function() {\n submitResponses(verbalfeedbackId, submissionId, toUser, responses, finalise);\n });\n });\n\n }\n\n return questionnaire;\n});\n"],"names":["define","$","Templates","Notification","Ajax","Str","ModalFactory","ModalEvents","responses","editor","getEditor","length","window","tinyMCE","setComment","row","classSelector","comment","append","editorcontent","find","html","commentId","attr","$input","get","insertContent","setContent","oldComment","val","trim","getComment","classSel","replace","getContent","questionnaire","registerEvents","each","this","data","criterionid","value","studentcomment","privatecomment","questionnaireTable","fromUser","toUser","verbalfeedbackId","submissionId","call","methodname","args","verbalfeedbackid","fromuserid","touserid","submissionid","done","result","response","options","selected","removeClass","addClass","fail","exception","saveResponses","finalise","parents","toUserFullname","messageStrings","key","component","param","get_strings","messages","title","confirmationMessage","confirmButtonTextPromise","get_string","confirmModalPromise","create","body","large","type","types","SAVE_CANCEL","when","confirmButtonText","modal","setSaveButtonText","show","getRoot","on","hidden","setBody","save","submitResponses","showConfirmationDialogue","responseObjects","tuple","Object","entries","push","complete","notificationData","message","addNotification","location","redirurl","prototype","click","e","preventDefault","hasClass","forId","removeAttr","hover","detailedRating"],"mappings":";;;;;;;;AAuBAA,0CAAO,CAAC,SACJ,iBACA,oBACA,YACA,WACA,qBACA,sBACD,SAASC,EAAGC,UAAWC,aAAcC,KAAMC,IAAKC,aAAcC,iBAEzDC,UAAY,OAEZC,aACEC,UAAY,kBACVD,SAIAA,OADAR,EAAE,gBAAgBU,O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SAAS,oBACjBhH,EAAEqC,MAAMuB,YAAY,mBACpB5D,EAAEqC,MAAMwB,SAAS,gBAEjB7D,EAAEqC,MAAMwB,SAAS,mBACjB7D,EAAEqC,MAAMuB,YAAY,mBAKhC5D,EAAE,uBAAuB6G,OAAM,SAASC,GACpCA,EAAEC,qBAEEjG,IAAMd,EAAEqC,MAAM6B,QAAQ,mCACtB1B,MAAQxC,EAAEqC,MAAMlB,KAAK,4BAA4BmB,KAAK,SAC1DzB,WAAWC,IAAK,mBAAoB0B,OAAO,MAG/CxC,EAAE,4BAA4BmH,OAAM,SAASL,GACzCA,EAAEC,iBAEG/G,EAAEqC,MAAM2E,SAAS,mBACdhH,EAAEqC,MAAM2E,SAAS,oBACjBhH,EAAEqC,MAAMuB,YAAY,mBACpB5D,EAAEqC,MAAMwB,SAAS,gBAEjB7D,EAAEqC,MAAMwB,SAAS,mBACjB7D,EAAEqC,MAAMuB,YAAY,mBAKhC5D,EAAE,kBAAkB6G,OAAM,WACtB7C,eAAc,MAGlBhE,EAAE,oBAAoB6G,OAAM,WACxB7C,eAAc,MAGlBhE,EAAE,sBAAsB6G,OAAM,SAASC,GACnCA,EAAEC,qBAEEK,eADMpH,EAAEqC,MAAM6B,QAAQ,gCACD/C,KAAK,oBAC3BiG,eAAeJ,SAAS,WACvBI,eAAexD,YAAY,UAC3B5D,EAAEqC,MAAMjB,KAAK,OAEbgG,eAAevD,SAAS,UACxB7D,EAAEqC,MAAMjB,KAAK,UAuJlBc"}
\ No newline at end of file
+{"version":3,"file":"questionnaire.min.js","sources":["../src/questionnaire.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 .\n\n/**\n * AMD code for the frequently used comments chooser for the marking guide grading form.\n *\n * @module mod_verbalfeedback/questionnaire\n * @class view\n * @copyright 2020 Kevin Tippenhauer \n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(['jquery',\n 'core/templates',\n 'core/notification',\n 'core/ajax',\n 'core/str',\n 'core/modal_factory',\n 'core/modal_events'\n], function($, Templates, Notification, Ajax, Str, ModalFactory, ModalEvents) {\n\n var responses = [];\n\n let editor;\n const getEditor = function() {\n if (editor) {\n return editor;\n }\n if ($('.editor_atto').length > 0) {\n editor = 'atto';\n } else if (window.tinyMCE) {\n editor = 'tiny';\n } else {\n editor = 'textarea';\n }\n return editor;\n };\n\n const setComment = function(row, classSelector, comment, append = false) {\n if (getEditor() === 'atto') {\n const editorcontent = row.find(classSelector + '.editor_atto_content');\n if (append) {\n editorcontent.append(\"\");\n return;\n }\n editorcontent.html(comment);\n return;\n }\n const commentId = row.find(classSelector).attr('id');\n if (commentId) {\n const $input = $('#' + commentId);\n if (getEditor() === 'tiny') {\n if (append) {\n window.tinyMCE.get(commentId).insertContent('
');\n return;\n }\n window.tinyMCE.get(commentId).setContent(comment);\n return;\n }\n if (append) {\n const oldComment = $input.val();\n if (oldComment.trim() !== '') {\n $input.val(oldComment + \"\\n\\n\" + comment);\n return;\n }\n }\n $input.val(comment);\n }\n };\n\n const getComment = function(row, classSel) {\n if (getEditor() === 'atto') {\n let comment = row.find(classSel + '.editor_atto_content').html();\n return comment.replace(/<[^>]+>/g, '').trim() === '' ? '' : comment; // Drop empty comments.\n }\n const commentId = row.find(classSel).attr('id');\n if (commentId) {\n let comment = '';\n if (getEditor() === 'tiny') {\n comment = window.tinyMCE.get(commentId).getContent();\n } else {\n comment = $('#' + commentId).val();\n }\n return comment.replace(/<[^>]+>/g, '').trim() === '' ? '' : comment; // Drop empty comments.\n }\n return '';\n };\n\n var questionnaire = function() {\n this.registerEvents();\n\n // Prefill responses array.\n $('[data-region=\"question-row\"]').each(function() {\n responses[$(this).data('criterionid')] = {\n criterionid: $(this).data('criterionid'),\n value: null,\n studentcomment: \"\",\n privatecomment: \"\"\n };\n });\n\n let questionnaireTable = $('[data-region=\"questionnaire\"]');\n\n if (questionnaireTable.data('preview') == true) { // Dont use '===' as $preview is '1' not 'true'.\n // Do not look for existing submission on preview page.\n return;\n }\n\n let fromUser = questionnaireTable.data('fromuserid');\n let toUser = questionnaireTable.data('touserid');\n let verbalfeedbackId = questionnaireTable.data('verbalfeedbackid');\n let submissionId = questionnaireTable.data('submissionid');\n\n let promises = Ajax.call([\n {\n methodname: 'mod_verbalfeedback_get_responses',\n args: {\n verbalfeedbackid: verbalfeedbackId,\n fromuserid: fromUser,\n touserid: toUser,\n submissionid: submissionId\n }\n }\n ]);\n\n promises[0].done(function(result) {\n $.each(result.responses, function() {\n let response = this;\n responses[response.criterionid].criterionid = response.criterionid;\n responses[response.criterionid].value = response.value;\n responses[response.criterionid].studentcomment = response.studentcomment;\n responses[response.criterionid].privatecomment = response.privatecomment;\n\n $('[data-region=\"question-row\"]').each(function() {\n if ($(this).data('criterionid') === response.criterionid) {\n let options = $(this).find('.scaleoption');\n if (options) {\n options.each(function() {\n // Mark selected option as selected.\n let selected = $(this).find('label');\n if (selected.data('value') === response.value) {\n selected.removeClass('badge-secondary');\n selected.removeClass('badge-info');\n selected.addClass('badge-success');\n } else if (selected.data('value') === \"\" && response.value === null) {\n selected.removeClass('badge-secondary');\n selected.removeClass('badge-info');\n selected.addClass('badge-success');\n }\n });\n }\n if (response.studentcomment !== '') {\n setComment($(this), '.student-comment', response.studentcomment);\n }\n if (response.privatecomment !== '') {\n setComment($(this), '.private-comment', response.privatecomment);\n }\n }\n });\n });\n }).fail(Notification.exception);\n };\n\n questionnaire.prototype.registerEvents = function() {\n $('.scaleoption').click(function(e) {\n e.preventDefault();\n\n let row = $(this).parents('[data-region=\"question-row\"]');\n let options = row.find('label');\n\n // Deselect the option that has been selected.\n $.each(options, function() {\n if ($(this).hasClass('badge-success')) {\n $(this).removeClass('badge-success');\n $(this).addClass('badge-secondary');\n\n var forId = $(this).attr('for');\n var optionRadio = $(\"#\" + forId);\n optionRadio.removeAttr('checked');\n }\n });\n\n // Mark selected option as selected.\n let selected = $(this).find('label');\n selected.removeClass('badge-secondary');\n selected.removeClass('badge-info');\n selected.addClass('badge-success');\n\n // Mark hidden radio button as checked.\n let radio = $(\"#\" + selected.attr('for'));\n radio.attr('checked', 'checked');\n let criterionid = row.data('criterionid');\n\n // Add this selected value to the array of responses.\n if (selected.data('value') === \"\") { // === is necessary because == \"0\" equals true;\n responses[criterionid].value = null;\n } else {\n responses[criterionid].value = selected.data('value');\n }\n });\n\n $('.scaleoptionlabel').hover(function(e) {\n e.preventDefault();\n\n if (!$(this).hasClass('badge-success')) {\n if ($(this).hasClass('badge-secondary')) {\n $(this).removeClass('badge-secondary');\n $(this).addClass('badge-info');\n } else {\n $(this).addClass('badge-secondary');\n $(this).removeClass('badge-info');\n }\n }\n });\n\n $('.detail-scaleoption').click(function(e) {\n e.preventDefault();\n\n let row = $(this).parents('[data-region=\"detailed-rating\"]');\n let value = $(this).find('.detail-scaleoptionlabel').data(\"value\");\n setComment(row, '.student-comment', value, true);\n });\n\n $('.detail-scaleoptionlabel').hover(function(e) {\n e.preventDefault();\n\n if (!$(this).hasClass('badge-success')) {\n if ($(this).hasClass('badge-secondary')) {\n $(this).removeClass('badge-secondary');\n $(this).addClass('badge-info');\n } else {\n $(this).addClass('badge-secondary');\n $(this).removeClass('badge-info');\n }\n }\n });\n\n $(\"#save-feedback\").click(function() {\n saveResponses(false);\n });\n\n $(\"#submit-feedback\").click(function() {\n saveResponses(true);\n });\n\n $(\".btn-detail-rating\").click(function(e) {\n e.preventDefault();\n let row = $(this).parents('[data-region=\"question-row\"]');\n let detailedRating = row.find(\".detailed-rating\");\n if (detailedRating.hasClass(\"hidden\")) {\n detailedRating.removeClass(\"hidden\");\n $(this).html(\"−\");\n } else {\n detailedRating.addClass(\"hidden\");\n $(this).html(\"+\");\n }\n\n });\n };\n\n /**\n * Save the responses.\n *\n * @param {boolean} finalise\n */\n function saveResponses(finalise) {\n\n $('.student-comment').each(function() {\n let row = $(this).parents('[data-region=\"question-row\"]');\n responses[row.data('criterionid')].studentcomment = getComment(row, '.student-comment');\n });\n $('.private-comment').each(function() {\n let row = $(this).parents('[data-region=\"question-row\"]');\n responses[row.data('criterionid')].privatecomment = getComment(row, '.private-comment');\n });\n\n let questionnaireTable = $('[data-region=\"questionnaire\"]');\n let toUser = questionnaireTable.data('touserid');\n let toUserFullname = questionnaireTable.data('tousername');\n let verbalfeedbackId = questionnaireTable.data('verbalfeedbackid');\n let submissionId = questionnaireTable.data('submissionid');\n let anonymous = questionnaireTable.data('anonymous');\n\n if (anonymous && finalise) {\n // Show confirmation dialogue to anonymise the feedback responses.\n let messageStrings = [\n {\n key: 'finaliseanonymousfeedback',\n component: 'mod_verbalfeedback'\n },\n {\n key: 'confirmfinaliseanonymousfeedback',\n component: 'mod_verbalfeedback',\n param: {\n 'name': toUserFullname\n }\n }\n ];\n\n Str.get_strings(messageStrings, 'mod_verbalfeedback').done(function(messages) {\n showConfirmationDialogue(messages[0], messages[1], verbalfeedbackId, submissionId, toUser, responses, finalise);\n }).fail(Notification.exception);\n } else {\n // Just save the responses.\n submitResponses(verbalfeedbackId, submissionId, toUser, responses, finalise);\n }\n }\n\n /**\n * Send the responses to the server.\n *\n * @param {number} verbalfeedbackId\n * @param {number} submissionId\n * @param {number} toUser\n * @param {array} responses\n * @param {boolean} finalise\n */\n function submitResponses(verbalfeedbackId, submissionId, toUser, responses, finalise) {\n let responseObjects = [];\n for (const tuple of Object.entries(responses)) {\n if (tuple[1] !== null) {\n responseObjects.push(tuple[1]);\n }\n }\n\n let promises = Ajax.call([\n {\n methodname: 'mod_verbalfeedback_save_responses',\n args: {\n verbalfeedbackid: verbalfeedbackId,\n submissionid: submissionId,\n touserid: toUser,\n responses: responseObjects,\n complete: finalise\n }\n }\n ]);\n\n promises[0].done(function(response) {\n let messageStrings = [\n {\n key: 'responsessaved',\n component: 'mod_verbalfeedback'\n },\n {\n key: 'errorresponsesavefailed',\n component: 'mod_verbalfeedback'\n }\n ];\n\n Str.get_strings(messageStrings).done(function(messages) {\n let notificationData = {};\n if (response.result) {\n notificationData.message = messages[0];\n notificationData.type = \"success\";\n } else {\n notificationData.message = messages[1];\n notificationData.type = \"error\";\n }\n Notification.addNotification(notificationData);\n }).fail(Notification.exception);\n\n window.location = response.redirurl;\n }).fail(Notification.exception);\n }\n\n /**\n * Renders the confirmation dialogue to submit and finalise the responses.\n *\n * @param {string} title\n * @param {string} confirmationMessage\n * @param {number} verbalfeedbackId\n * @param {number} submissionId\n * @param {number} toUser\n * @param {Array} responses\n * @param {boolean} finalise\n */\n function showConfirmationDialogue(title, confirmationMessage, verbalfeedbackId, submissionId, toUser, responses, finalise) {\n let confirmButtonTextPromise = Str.get_string('finalise', 'mod_verbalfeedback');\n let confirmModalPromise = ModalFactory.create({\n title: title,\n body: confirmationMessage,\n large: true,\n type: ModalFactory.types.SAVE_CANCEL\n });\n $.when(confirmButtonTextPromise, confirmModalPromise).done(function(confirmButtonText, modal) {\n modal.setSaveButtonText(confirmButtonText);\n\n // Display the dialogue.\n modal.show();\n\n // On hide handler.\n modal.getRoot().on(ModalEvents.hidden, function() {\n // Empty modal contents when it's hidden.\n modal.setBody('');\n });\n\n modal.getRoot().on(ModalEvents.save, function() {\n submitResponses(verbalfeedbackId, submissionId, toUser, responses, finalise);\n });\n });\n\n }\n\n return questionnaire;\n});\n"],"names":["define","$","Templates","Notification","Ajax","Str","ModalFactory","ModalEvents","responses","editor","getEditor","length","window","tinyMCE","setComment","row","classSelector","comment","append","editorcontent","find","html","commentId","attr","$input","get","insertContent","setContent","oldComment","val","trim","getComment","classSel","replace","getContent","questionnaire","registerEvents","each","this","data","criterionid","value","studentcomment","privatecomment","questionnaireTable","fromUser","toUser","verbalfeedbackId","submissionId","call","methodname","args","verbalfeedbackid","fromuserid","touserid","submissionid","done","result","response","options","selected","removeClass","addClass","fail","exception","saveResponses","finalise","parents","toUserFullname","messageStrings","key","component","param","get_strings","messages","title","confirmationMessage","confirmButtonTextPromise","get_string","confirmModalPromise","create","body","large","type","types","SAVE_CANCEL","when","confirmButtonText","modal","setSaveButtonText","show","getRoot","on","hidden","setBody","save","submitResponses","showConfirmationDialogue","responseObjects","tuple","Object","entries","push","complete","notificationData","message","addNotification","location","redirurl","prototype","click","e","preventDefault","hasClass","forId","removeAttr","hover","detailedRating"],"mappings":";;;;;;;;AAuBAA,0CAAO,CAAC,SACJ,iBACA,oBACA,YACA,WACA,qBACA,sBACD,SAASC,EAAGC,UAAWC,aAAcC,KAAMC,IAAKC,aAAcC,iBAEzDC,UAAY,OAEZC,aACEC,UAAY,kBACVD,SAIAA,OADAR,EAAE,gBAAgBU,OAAS,EAClB,OACFC,OAAOC,QACL,OAEA,WAENJ,SAGLK,WAAa,SAASC,IAAKC,cAAeC,aAASC,kEACjC,SAAhBR,YAAwB,OAClBS,cAAgBJ,IAAIK,KAAKJ,cAAgB,+BAC3CE,YACAC,cAAcD,OAAO,WAAaD,QAAU,mBAGhDE,cAAcE,KAAKJ,eAGjBK,UAAYP,IAAIK,KAAKJ,eAAeO,KAAK,SAC3CD,UAAW,OACLE,OAASvB,EAAE,IAAMqB,cACH,SAAhBZ,mBACIQ,YACAN,OAAOC,QAAQY,IAAIH,WAAWI,cAAc,WAAaT,QAAU,wBAGvEL,OAAOC,QAAQY,IAAIH,WAAWK,WAAWV,YAGzCC,OAAQ,OACFU,WAAaJ,OAAOK,SACA,KAAtBD,WAAWE,mBACXN,OAAOK,IAAID,WAAa,OAASX,SAIzCO,OAAOK,IAAIZ,WAIbc,WAAa,SAAShB,IAAKiB,aACT,SAAhBtB,YAAwB,KACpBO,QAAUF,IAAIK,KAAKY,SAAW,wBAAwBX,aACR,KAA3CJ,QAAQgB,QAAQ,WAAY,IAA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c,MAGlBhE,EAAE,sBAAsB6G,OAAM,SAASC,GACnCA,EAAEC,qBAEEK,eADMpH,EAAEqC,MAAM6B,QAAQ,gCACD/C,KAAK,oBAC1BiG,eAAeJ,SAAS,WACxBI,eAAexD,YAAY,UAC3B5D,EAAEqC,MAAMjB,KAAK,OAEbgG,eAAevD,SAAS,UACxB7D,EAAEqC,MAAMjB,KAAK,UAsJlBc"}
\ No newline at end of file
diff --git a/amd/src/edit_items.js b/amd/src/edit_items.js
index 01e9a65..a850cc9 100644
--- a/amd/src/edit_items.js
+++ b/amd/src/edit_items.js
@@ -50,7 +50,7 @@ define([
sum += parseFloat($(this).val());
});
- if(sum != 1) {
+ if (sum != 1) {
$('.category-percentage').addClass('is-invalid');
$('#percentage-total').addClass('text-danger');
$('#percentage-total-value').text(parseFloat(sum * 100).toFixed(2));
@@ -113,7 +113,7 @@ define([
$(ACTIONS.ITEM_MULTIPLIER_CHANGED).change(function(e) {
e.preventDefault();
- if(this.value > 5) {
+ if (this.value > 5) {
this.value = 5.00;
}
this.value = parseFloat(this.value).toFixed(2);
diff --git a/amd/src/questionnaire.js b/amd/src/questionnaire.js
index 9f90320..836c55c 100644
--- a/amd/src/questionnaire.js
+++ b/amd/src/questionnaire.js
@@ -79,10 +79,10 @@ define(['jquery',
}
};
- const getComment = function (row, classSel) {
+ const getComment = function(row, classSel) {
if (getEditor() === 'atto') {
let comment = row.find(classSel + '.editor_atto_content').html();
- return comment.replace(/<[^>]+>/g,'').trim() === '' ? '' : comment; // drop empty comments
+ return comment.replace(/<[^>]+>/g, '').trim() === '' ? '' : comment; // Drop empty comments.
}
const commentId = row.find(classSel).attr('id');
if (commentId) {
@@ -92,7 +92,7 @@ define(['jquery',
} else {
comment = $('#' + commentId).val();
}
- return comment.replace(/<[^>]+>/g,'').trim() === '' ? '' : comment; // drop empty comments
+ return comment.replace(/<[^>]+>/g, '').trim() === '' ? '' : comment; // Drop empty comments.
}
return '';
};
@@ -112,8 +112,8 @@ define(['jquery',
let questionnaireTable = $('[data-region="questionnaire"]');
- if(questionnaireTable.data('preview') == true) { // dont use '===' as $preview is '1' not 'true'.
- // do not look for existing submission on preview page
+ if (questionnaireTable.data('preview') == true) { // Dont use '===' as $preview is '1' not 'true'.
+ // Do not look for existing submission on preview page.
return;
}
@@ -137,10 +137,10 @@ define(['jquery',
promises[0].done(function(result) {
$.each(result.responses, function() {
let response = this;
- responses[response.criterionid]['criterionid'] = response.criterionid;
- responses[response.criterionid]['value'] = response.value;
- responses[response.criterionid]['studentcomment'] = response.studentcomment;
- responses[response.criterionid]['privatecomment'] = response.privatecomment;
+ responses[response.criterionid].criterionid = response.criterionid;
+ responses[response.criterionid].value = response.value;
+ responses[response.criterionid].studentcomment = response.studentcomment;
+ responses[response.criterionid].privatecomment = response.privatecomment;
$('[data-region="question-row"]').each(function() {
if ($(this).data('criterionid') === response.criterionid) {
@@ -204,9 +204,9 @@ define(['jquery',
// Add this selected value to the array of responses.
if (selected.data('value') === "") { // === is necessary because == "0" equals true;
- responses[criterionid]['value'] = null;
+ responses[criterionid].value = null;
} else {
- responses[criterionid]['value'] = selected.data('value');
+ responses[criterionid].value = selected.data('value');
}
});
@@ -258,7 +258,7 @@ define(['jquery',
e.preventDefault();
let row = $(this).parents('[data-region="question-row"]');
let detailedRating = row.find(".detailed-rating");
- if(detailedRating.hasClass("hidden")) {
+ if (detailedRating.hasClass("hidden")) {
detailedRating.removeClass("hidden");
$(this).html("−");
} else {
@@ -278,11 +278,11 @@ define(['jquery',
$('.student-comment').each(function() {
let row = $(this).parents('[data-region="question-row"]');
- responses[row.data('criterionid')]['studentcomment'] = getComment(row,'.student-comment');
+ responses[row.data('criterionid')].studentcomment = getComment(row, '.student-comment');
});
$('.private-comment').each(function() {
let row = $(this).parents('[data-region="question-row"]');
- responses[row.data('criterionid')]['privatecomment'] = getComment(row, '.private-comment');
+ responses[row.data('criterionid')].privatecomment = getComment(row, '.private-comment');
});
let questionnaireTable = $('[data-region="questionnaire"]');
@@ -348,7 +348,6 @@ define(['jquery',
]);
promises[0].done(function(response) {
- // console.log(response);
let messageStrings = [
{
key: 'responsessaved',
diff --git a/classes/api.php b/classes/api.php
index bdc313e..ade4c9b 100644
--- a/classes/api.php
+++ b/classes/api.php
@@ -73,7 +73,7 @@ class api {
/** Activity close event type. */
const VERBALFEEDBACK_EVENT_TYPE_CLOSE = 'close';
- /** Cache for verbalfeedback instances */
+ /** @var array Cache for verbalfeedback instances. */
private static $instances = [];
/**
@@ -89,7 +89,7 @@ public static function get_instance($verbalfeedbackid) {
$id = (int)$verbalfeedbackid;
if (!array_key_exists($id, static::$instances) || PHPUNIT_TEST) {
static::$instances[$id] = $DB->get_record(tables::INSTANCE_TABLE, ['id' => $id], '*', MUST_EXIST);
- }
+ }
return static::$instances[$id];
}
diff --git a/classes/model/language.php b/classes/model/language.php
index 41201fa..0ffe924 100644
--- a/classes/model/language.php
+++ b/classes/model/language.php
@@ -46,7 +46,7 @@ public function __construct(?int $id = null, string $language = '') {
/**
* Sets the id.
*
- * @param ?int|null $id The id.
+ * @param int|null $id The id.
*/
public function set_id(?int $id = null) {
$this->id = $id;
diff --git a/classes/output/report_download.php b/classes/output/report_download.php
index 61dc9f1..c05db07 100644
--- a/classes/output/report_download.php
+++ b/classes/output/report_download.php
@@ -72,8 +72,8 @@ class report_download implements renderable, templatable {
* @param int $coursestart The course start date
* @param int $courseend The course end date
* @param string $instancename The verbal feedback instance name.
- * @param font $font The font object.
* @param int $touser The user this report is being generated for.
+ * @param font $font The font object.
*/
public function __construct(ModelReport $report, $coursename, $coursestart, $courseend, $instancename, $touser, font $font) {
$this->report = $report;
diff --git a/classes/repository/model/localized_string_type.php b/classes/repository/model/localized_string_type.php
index 31d629c..b26694a 100644
--- a/classes/repository/model/localized_string_type.php
+++ b/classes/repository/model/localized_string_type.php
@@ -65,9 +65,9 @@ class localized_string_type {
* Return all existing types in a order, so that the numeric value + 1 can
* be used as a string.
*
- * @return string[]
+ * @return string[]
*/
- public static function getStringTypes(): array {
+ public static function get_string_types(): array {
return [
self::INSTANCE_CRITERION,
self::INSTANCE_CATEGORY_HEADER,
@@ -94,7 +94,7 @@ public static function getStringTypes(): array {
* @return bool If a string type exists
*/
public static function exists(string $type) {
- return in_array($type, self::getStringTypes());
+ return in_array($type, self::get_string_types());
}
/**
@@ -104,8 +104,8 @@ public static function exists(string $type) {
* @return int
* @throws \InvalidArgumentException
*/
- public static function str2id(string $type):int {
- $key = array_search($type, self::getStringTypes());
+ public static function str2id(string $type): int {
+ $key = array_search($type, self::get_string_types());
if ($key === false) {
throw new \InvalidArgumentException("Invalid str: $type");
}
@@ -119,7 +119,7 @@ public static function str2id(string $type):int {
* @return string
* @throws \InvalidArgumentException
*/
- public static function id2str(int $id):string {
+ public static function id2str(int $id): string {
$constants = self::getStringTypes();
if ($id < 1 || $id > count($constants)) {
throw new \InvalidArgumentException("Invalid id: $id");
diff --git a/classes/repository/template_category_repository.php b/classes/repository/template_category_repository.php
index c156b67..89fcd4c 100644
--- a/classes/repository/template_category_repository.php
+++ b/classes/repository/template_category_repository.php
@@ -164,8 +164,10 @@ public function delete_by_id(int $id): bool {
private function get_headers($foreignkey): array {
global $DB;
- $dboheaders = $DB->get_records(tables::LOCALIZED_STRING_TABLE,
- ['foreignkey' => $foreignkey, 'typeid' => localized_string_type::str2id(localized_string_type::TEMPLATE_CATEGORY_HEADER)]);
+ $dboheaders = $DB->get_records(tables::LOCALIZED_STRING_TABLE, [
+ 'foreignkey' => $foreignkey,
+ 'typeid' => localized_string_type::str2id(localized_string_type::TEMPLATE_CATEGORY_HEADER),
+ ]);
$headers = [];
foreach ($dboheaders as $dboheader) {
$headers[] = db_localized_string::to_localized_string($dboheader);
diff --git a/classes/utils/font.php b/classes/utils/font.php
index 14eb3ae..2ee9e50 100644
--- a/classes/utils/font.php
+++ b/classes/utils/font.php
@@ -52,16 +52,16 @@ class font {
protected $report;
/** @var string The selected font for the entire document. */
- protected $font_base;
+ protected $fontbase;
/** @var string The selected font for the students name. */
- protected $font_student;
+ protected $fontstudent;
/** @var string The selected font for the teachers name. */
- protected $font_teacher;
+ protected $fontteacher;
/**
* Constructor.
*
- * @param report $course The report object.
+ * @param report $report The report object.
*/
public function __construct(report $report) {
$this->report = $report;
@@ -71,21 +71,21 @@ public function __construct(report $report) {
* Get the base font for the PDF.
*/
public function get_font_base() {
- if (!$this->font_base) {
+ if (!$this->fontbase) {
$lang = substr(current_language(), 0, 2);
if ($lang === 'ar') {
- $this->font_base = static::FONT_ARABIC;
+ $this->fontbase = static::FONT_ARABIC;
} else if ($lang === 'he') {
- $this->font_base = static::FONT_HEBREW;
+ $this->fontbase = static::FONT_HEBREW;
} else if ($lang === 'ja') {
- $this->font_base = static::FONT_JAPANESE;
+ $this->fontbase = static::FONT_JAPANESE;
} else if ($lang === 'zh') {
- $this->font_base = static::FONT_CHINESE;
+ $this->fontbase = static::FONT_CHINESE;
} else {
- $this->font_base = static::FONT_BASE;
+ $this->fontbase = static::FONT_BASE;
}
}
- return $this->font_base;
+ return $this->fontbase;
}
/**
@@ -94,12 +94,12 @@ public function get_font_base() {
* @return string The font name (one of the class constants)
*/
public function get_font_student() {
- if (!$this->font_student) {
+ if (!$this->fontstudent) {
$touser = \core_user::get_user($this->report->get_to_user_id());
$font = $this->eval_string(fullname($touser));
- $this->font_student = $font === $this->get_font_base() ? 'inherit' : $font;
+ $this->fontstudent = $font === $this->get_font_base() ? 'inherit' : $font;
}
- return $this->font_student;
+ return $this->fontstudent;
}
/**
@@ -108,16 +108,16 @@ public function get_font_student() {
* @return string The font name (one of the class constants)
*/
public function get_font_teacher() {
- if (!$this->font_teacher) {
- $this->font_teacher = 'inherit';
+ if (!$this->fontteacher) {
+ $this->fontteacher = 'inherit';
foreach ($this->report->get_from_user_ids() as $fromuserid) {
$fromuser = \core_user::get_user($fromuserid);
$font = $this->eval_string(fullname($fromuser));
- $this->font_teacher = $font === $this->get_font_base() ? 'inherit' : $font;
+ $this->fontteacher = $font === $this->get_font_base() ? 'inherit' : $font;
break;
}
}
- return $this->font_teacher;
+ return $this->fontteacher;
}
/**
@@ -127,7 +127,7 @@ public function get_font_teacher() {
* @return string The font name (one of the class constants)
*/
protected function eval_string(string $input): string {
-
+
$n = mb_ord(mb_substr($input, 0, 1));
if ($n >= 0x600 && $n <= 0x6ff) {
return static::FONT_ARABIC;
@@ -167,7 +167,7 @@ public function set_font_for_pdf(\pdf $pdf) {
$pdf->AddFont($font, 'I', $file . 'i.php');
$pdf->AddFont($font, 'BI', $file . 'bi.php');
$pdf->SetFont($font, '', 12);
- } elseif ($font === static::FONT_ARABIC) {
+ } else if ($font === static::FONT_ARABIC) {
$this->set_font_two($pdf, $font, 'notonaskharabic');
} else if ($font === static::FONT_HEBREW) {
$this->set_font_two($pdf, $font, 'notosanshebrew');
@@ -195,4 +195,4 @@ protected function set_font_two(\pdf $pdf, $name, $file) {
$pdf->AddFont($name, 'BI', $fontdir . 'b.php');
$pdf->SetFont($name, '', 12);
}
-}
\ No newline at end of file
+}
diff --git a/classes/utils/user_utils.php b/classes/utils/user_utils.php
index 328f023..1830b47 100644
--- a/classes/utils/user_utils.php
+++ b/classes/utils/user_utils.php
@@ -78,11 +78,11 @@ public static function can_view_all_reports(context_module $context, $userid) {
* Whether the user can view their own report.
*
* @param instance $instance The verbal feedback instance data.
- * @param ?context_module|null $context The context the verbal feedback belongs to
+ * @param context_module|null $context The context the verbal feedback belongs to
* @return bool
* @throws coding_exception
*/
- public static function can_view_own_report(instance $instance, ?context_module $context = null) {
+ public static function can_view_own_report(instance $instance, ?context_module $context = null): bool {
$isreleased = $instance->reports_are_released();
// Get context if not provided.
if (empty($context)) {
diff --git a/db/upgrade.php b/db/upgrade.php
index de5b19a..e63de38 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -94,7 +94,7 @@ function xmldb_verbalfeedback_upgrade($oldversion) {
}
// Convert all strings to ids.
- foreach (localized_string_type::getStringTypes() as $type) {
+ foreach (localized_string_type::get_string_types() as $type) {
$DB->execute(
'UPDATE {verbalfeedback_local_string} SET typeid = ? WHERE type = ?',
[localized_string_type::str2id($type), $type]
@@ -193,4 +193,4 @@ function add_instance_to_localized_string() {
]
);
}
-}
\ No newline at end of file
+}
diff --git a/tests/font_test.php b/tests/font_test.php
index 8a171d1..49de14a 100644
--- a/tests/font_test.php
+++ b/tests/font_test.php
@@ -47,7 +47,7 @@ public function setUp(): void {
$this->cm = $this->getDataGenerator()->create_module('verbalfeedback', ['course' => $this->course->id]);
$this->students = [];
- foreach ($this->getStudents() as $name) {
+ foreach ($this->get_students() as $name) {
$this->students[] = $this->getDataGenerator()->create_and_enrol($this->course, 'student', $name);
}
}
@@ -57,7 +57,7 @@ public function setUp(): void {
*
* @return array
*/
- protected function getTeachers(): array {
+ protected function get_teachers(): array {
return [
['firstname' => 'John', 'lastname' => 'White'],
['firstname' => 'Eliška', 'lastname' => 'Němcová'],
@@ -74,7 +74,7 @@ protected function getTeachers(): array {
*
* @return array
*/
- protected function getStudents(): array {
+ protected function get_students(): array {
return [
['firstname' => 'John', 'lastname' => 'Doe'],
['firstname' => 'Matěj', 'lastname' => 'Černý'],
@@ -91,7 +91,7 @@ protected function getStudents(): array {
/**
* Test get_font_base().
*
- * @covers font::get_font_base
+ * @covers \mod_verbalfeedback\font::get_font_base
*/
public function test_get_font_base() {
global $SESSION;
@@ -119,7 +119,7 @@ public function test_get_font_base() {
/**
* Test get_font_student().
*
- * @covers font::get_font_student
+ * @covers \mod_verbalfeedback\font::get_font_student
*/
public function test_get_font_student() {
$this->getDataGenerator()->create_and_enrol($this->course, 'editingteacher', $this->getTeachers()[0]);
@@ -146,7 +146,7 @@ public function test_get_font_student() {
/**
* Test get_font_teacher.
*
- * @covers font::get_font_teacher
+ * @covers \mod_verbalfeedback\font::get_font_teacher
*/
public function test_get_font_teacher() {
$this->resetAfterTest();
@@ -157,10 +157,10 @@ public function test_get_font_teacher() {
font::FONT_HEBREW,
font::FONT_ARABIC,
font::FONT_CHINESE,
- font::FONT_JAPANESE,
+ font::FONT_JAPANESE,
];
$enroledTeachers = [];
- foreach ($this->getTeachers() as $key => $teacher) {
+ foreach ($this->get_teachers() as $key => $teacher) {
$enroledTeachers[] = $this->getDataGenerator()->create_and_enrol($this->course, 'editingteacher', $teacher);
api::generate_verbalfeedback_feedback_states($this->cm->id, $enroledTeachers[$key]->id);
$reportservice = new report_service();
@@ -172,12 +172,12 @@ public function test_get_font_teacher() {
// Now delete all submissions skeletons from teachers.
(new submission_repository())->delete_by_instance($this->cm->id);
- foreach ($this->getTeachers() as $key => $teacher) {
+ foreach ($this->get_teachers() as $key => $teacher) {
api::generate_verbalfeedback_feedback_states($this->cm->id, $enroledTeachers[$key]->id);
$reportservice = new report_service();
$report = $reportservice->create_report($this->cm->id, $this->students[3]->id);
$font = new font($report);
- $this->assertEquals($expected[$key], $font->get_font_teacher(), "Did not get font {$expected[$key]} for teacher {$key}.");
+ $this->assertEquals($expected[$key], $font->get_font_teacher(), "Wrong font {$expected[$key]} for teacher {$key}.");
// Remove submission skeletons by current teacher.
(new submission_repository())->delete_by_instance($this->cm->id);
}
@@ -186,7 +186,7 @@ public function test_get_font_teacher() {
/**
* Test set_font_for_pdf.
*
- * @covers font::set_font_for_pdf
+ * @covers \mod_verbalfeedback\font::set_font_for_pdf
*/
public function test_set_font_for_pdf() {
global $CFG;
@@ -194,7 +194,7 @@ public function test_set_font_for_pdf() {
require_once($CFG->libdir . '/pdflib.php');
$this->resetAfterTest();
-
+
foreach ($this->students as $student) {
$pdf = new pdf(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$font = new font((new report_service())->create_report($this->cm->id, $student->id));
@@ -205,4 +205,4 @@ public function test_set_font_for_pdf() {
$this->assertTrue($pdf->isCharDefined($charlast), "char $charlast not defined");
}
}
-}
\ No newline at end of file
+}
diff --git a/tests/repository/model/localized_string_type_test.php b/tests/repository/model/localized_string_type_test.php
index effc99e..1ec1c71 100644
--- a/tests/repository/model/localized_string_type_test.php
+++ b/tests/repository/model/localized_string_type_test.php
@@ -115,7 +115,7 @@ public function test_id2str(): void {
* @covers \mod_verbalfeedback\repository\model\localized_string_type::getStringTypes
*/
public function test_getStringTypes(): void {
- $this->assertEquals($this->stringConstants, localized_string_type::getStringTypes());
+ $this->assertEquals($this->stringConstants, localized_string_type::get_string_types());
}
/**