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,6CAD7BA,gCAEyB,yCAGzBC,UAAY,gBACPC,kBAGLC,UAAY,eACRC,IAAM,EAC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C,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,UAOhCC,oCAC6B,6CAD7BA,gCAEyB,yCAGzBC,UAAY,gBACPC,kBAGLC,UAAY,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,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(\"
  • \" + comment + \"
\");\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('
  • ' + comment + '

');\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,OAAS,EAClB,OACFC,OAAOC,QACL,OAEA,WAENJ,SAGL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,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(\"
  • \" + comment + \"
\");\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('
  • ' + comment + '

');\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,IAAIH,OAAgB,GAAKb,cAE1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sB6G,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/build/report.min.js.map b/amd/build/report.min.js.map deleted file mode 100644 index 78b9d4e..0000000 --- a/amd/build/report.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"report.min.js","sources":[],"sourcesContent":[],"names":[],"mappings":""} \ 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/backup/moodle2/backup_verbalfeedback_stepslib.php b/backup/moodle2/backup_verbalfeedback_stepslib.php index c4bbb66..01d28c0 100644 --- a/backup/moodle2/backup_verbalfeedback_stepslib.php +++ b/backup/moodle2/backup_verbalfeedback_stepslib.php @@ -77,7 +77,11 @@ protected function define_structure() { $subratingdescription = new backup_nested_element('description', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); $subratingverynegatives = new backup_nested_element('verynegatives'); - $subratingverynegative = new backup_nested_element('verynegative', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); + $subratingverynegative = new backup_nested_element( + 'verynegative', + ['id'], + ['foreignkey', 'typeid', 'languageid', 'string'] + ); $subratingnegatives = new backup_nested_element('negatives'); $subratingnegative = new backup_nested_element('negative', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); @@ -86,7 +90,11 @@ protected function define_structure() { $subratingpositive = new backup_nested_element('positive', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); $subratingverypositives = new backup_nested_element('verypositives'); - $subratingverypositive = new backup_nested_element('verypositive', ['id'], ['foreignkey', 'typeid', 'languageid', 'string']); + $subratingverypositive = new backup_nested_element( + 'verypositive', + ['id'], + ['foreignkey', 'typeid', 'languageid', 'string'] + ); $submissions = new backup_nested_element('submissions'); $submission = new backup_nested_element('submission', ['id'], ['instanceid', 'fromuserid', 'touserid', 'status', 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..af812c0 100644 --- a/classes/model/language.php +++ b/classes/model/language.php @@ -28,8 +28,8 @@ */ class language { /** @var int|null The language id */ - private $id = null; - /** @var string The language string */ + private $id; + /** @var string|null The language string */ private $language; /** @@ -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/language_repository.php b/classes/repository/language_repository.php index 1f31173..2e2d9ef 100644 --- a/classes/repository/language_repository.php +++ b/classes/repository/language_repository.php @@ -43,7 +43,7 @@ class language_repository { public function save(language $language) { global $DB; $dbolanguage = db_language::from_language($language); - if ($language->get_id() == 0) { + if ((int)$language->get_id() === 0) { $id = $DB->insert_record(tables::LANGUAGE_TABLE, $dbolanguage); $language->set_id($id); } else { diff --git a/classes/repository/model/db_language.php b/classes/repository/model/db_language.php index a0f80d9..532b715 100644 --- a/classes/repository/model/db_language.php +++ b/classes/repository/model/db_language.php @@ -32,7 +32,7 @@ class db_language { /** * @var int The language id */ - public $id = 0; + public $id; /** * @var string The language */ @@ -59,10 +59,10 @@ public static function from_language(language $language): db_language { */ public static function to_language($dbo): language { $language = new language(); - if (isset($dbo->id)) { + if (isset($dbo->id) && !empty($dbo->id)) { $language->set_id($dbo->id); } - if (isset($dbo->language)) { + if (isset($dbo->language) && !empty($dbo->language)) { $language->set_language($dbo->language); } return $language; diff --git a/classes/repository/model/localized_string_type.php b/classes/repository/model/localized_string_type.php index 31d629c..5209858 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,8 +119,8 @@ public static function str2id(string $type):int { * @return string * @throws \InvalidArgumentException */ - public static function id2str(int $id):string { - $constants = self::getStringTypes(); + public static function id2str(int $id): string { + $constants = self::get_string_types(); 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/lang/de/verbalfeedback.php b/lang/de/verbalfeedback.php index d23a7cc..297d2d5 100644 --- a/lang/de/verbalfeedback.php +++ b/lang/de/verbalfeedback.php @@ -92,11 +92,11 @@ $string['errorroleconflict'] = 'Die/der aktuelle Nutzer/in ist für diese Instanz gleichzeitig Teilnehmer/in und Trainer/in, was nicht erlaubt ist.'; $string['errorverbalfeedbacknotfound'] = 'Verbales Feedback nicht gefunden.'; $string['factor'] = 'Faktor'; -$string['feedbacksurvey'] = 'Feedback-Umfrage für {$a}'; $string['feedbackgiven'] = 'Feedback gegeben'; $string['feedbackreceived'] = 'Feedback erhalten'; -$string['finalize'] = 'Bewertung abschliessen'; +$string['feedbacksurvey'] = 'Feedback-Umfrage für {$a}'; $string['finaliseanonymousfeedback'] = 'Anonymes Feedback abschliessen'; +$string['finalize'] = 'Bewertung abschliessen'; $string['finalresult'] = 'Schlussresultat'; $string['gotoquestionbank'] = 'Zur verbales Feedback-Fragensammlung gehen'; $string['id'] = 'ID'; @@ -104,10 +104,10 @@ $string['instancenotready'] = 'Klicken Sie auf die Schaltfläche „Verfügbar machen“, um den Fragebogen nach der Bearbeitung der Kriterien an die Lehrkräfte freizugeben.'; $string['instancenotreadystudents'] = 'Die verbale Feedback-Aktivität ist noch nicht bereit. Bitte versuchen Sie es später erneut.'; $string['instancenotyetopen'] = 'Die verbale Feedback-Aktivität ist noch nicht geöffnet.'; +$string['instancenowready'] = 'Der Bewertungsbogen ist nun freigeschaltet.'; $string['languageplural'] = 'Sprachen'; $string['listcategories'] = 'Liste der Kategorien'; $string['listcriteria'] = 'Liste der Kriterien'; -$string['instancenowready'] = 'Der Bewertungsbogen ist nun freigeschaltet.'; $string['managetemplates'] = 'Templates verwalten'; $string['messageafterdecline'] = 'Feedback abgelehnt.'; $string['modulename'] = 'Verbales Feedback'; @@ -131,8 +131,8 @@ $string['pick'] = 'Auswählen'; $string['pickfromquestionbank'] = 'Eine Frage aus der Fragensammlung auswählen'; $string['placeholderquestion'] = 'Fragetext eingeben'; -$string['pluginname'] = 'Verbales Feedback'; $string['pluginadministration'] = 'Verbales Feedback-Administration'; +$string['pluginname'] = 'Verbales Feedback'; $string['position'] = 'Position'; $string['positive'] = 'Positiv'; $string['preserveids'] = 'Preserve IDs?'; @@ -152,9 +152,9 @@ $string['qtypeinvalid'] = 'Ungültiger Fragetyp'; $string['qtyperated'] = 'Bewertet'; $string['question'] = 'Frage'; +$string['questioncategory'] = 'Kateogrie'; $string['questiontext'] = 'Fragetext'; $string['questiontype'] = 'Fragetyp'; -$string['questioncategory'] = 'Kateogrie'; $string['ratingaverage'] = 'Durchschnittliche Bewertung'; $string['ratings'] = 'Bewertungen'; $string['rel_after'] = 'Freigabe nach Abschluss der Aktivität'; @@ -200,9 +200,9 @@ $string['switchtouser'] = 'Zu Teilnehmer/in wechseln...'; $string['teachers'] = 'Dozierende'; $string['template'] = 'Template'; -$string['templateplural'] = 'Templates'; $string['templatecategoryplural'] = 'Template-Kategorien'; $string['templatecriteriaplural'] = 'Template-Kriterien'; +$string['templateplural'] = 'Templates'; $string['text'] = 'Text'; $string['title'] = 'Verbales Feedback'; $string['titlelabel'] = 'Titel'; @@ -217,19 +217,19 @@ $string['verbalfeedback:edititems'] = 'Verbales Feedback-Kriterien bearbeiten'; $string['verbalfeedback:editquestions'] = 'Verbales Feedback-Fragen bearbeiten'; $string['verbalfeedback:mapcourse'] = 'Verbales Feedback einem Kurs zuordnen'; -$string['verbalfeedback:receivemail'] = 'Verbales Feedback-E-Mails empfangen'; $string['verbalfeedback:receive_rating'] = 'Teilnehmer/in kann bewertet werden'; +$string['verbalfeedback:receivemail'] = 'Verbales Feedback-E-Mails empfangen'; $string['verbalfeedback:view'] = 'Verbales Feedback anzeigen'; -$string['verbalfeedback:viewanalysepage'] = 'Verbales Feedback-Analyse anzeigen'; $string['verbalfeedback:view_all_reports'] = 'Verbales Feedback-Berichte aller Teilnehmer/innen anzeigen'; -$string['verbalfeedbacklanguages'] = 'Verbales Feedback-Sprachen'; -$string['verbalfeedbacksettings'] = 'Verbales Feedback-Einstellungen'; -$string['viewfeedbackforuser'] = 'Verbales Feedback für die/den Teilnehmer/in'; -$string['viewfeedbackreport'] = 'Verbales Feedback-Bericht anzeigen'; +$string['verbalfeedback:viewanalysepage'] = 'Verbales Feedback-Analyse anzeigen'; $string['verbalfeedbackcategories'] = 'Verbales Feedback-Kategorien'; $string['verbalfeedbackcriteria'] = 'Verbales Feedback-Kriterien'; +$string['verbalfeedbacklanguages'] = 'Verbales Feedback-Sprachen'; +$string['verbalfeedbacksettings'] = 'Verbales Feedback-Einstellungen'; $string['verbalfeedbacktemplates'] = 'Verbales Feedback-Templates'; $string['verynegative'] = 'Sehr negativ'; $string['verypositive'] = 'Sehr positiv'; +$string['viewfeedbackforuser'] = 'Verbales Feedback für die/den Teilnehmer/in'; +$string['viewfeedbackreport'] = 'Verbales Feedback-Bericht anzeigen'; $string['weight'] = 'Gewichtung'; $string['weightedaverage'] = 'Gewichteter Ø'; diff --git a/lang/en/verbalfeedback.php b/lang/en/verbalfeedback.php index 50223f5..9dbb522 100644 --- a/lang/en/verbalfeedback.php +++ b/lang/en/verbalfeedback.php @@ -70,8 +70,9 @@ $string['edittemplate'] = 'Edit template'; $string['enableselfreview'] = 'Enable self-review'; $string['entercomment'] = 'Enter your comment here.'; -$string['errorblankquestion'] = 'Required.'; +$string['enterquestion'] = 'Enter question text...'; $string['errorblankdeclinereason'] = 'Required.'; +$string['errorblankquestion'] = 'Required.'; $string['errorcannotadditem'] = 'Cannot add the verbal feedback item.'; $string['errorcannotparticipate'] = 'You cannot participate in this verbal feedback activity.'; $string['errorcannotrespond'] = 'You cannot give feedback within this verbal feedback activity.'; @@ -83,18 +84,17 @@ $string['errornotenrolled'] = 'You need to be enrolled in this course in order to be able to participate in this verbal feedback activity.'; $string['errornothingtodecline'] = 'There is no feedback to decline to.'; $string['errornotingroup'] = 'You need to be in a group in order to be able to participate in this verbal feedback activity. Please contact your course administrator.'; -$string['enterquestion'] = 'Enter question text...'; $string['errorquestionstillinuse'] = 'This question cannot be deleted as it is still being used by at least one verbal feedback instance.'; $string['errorreportnotavailable'] = 'Your feedback report is not yet available.'; $string['errorresponsesavefailed'] = 'An error has occured while the responses are being saved. Please try again later.'; $string['errorroleconflict'] = 'The current user is student and teacher at the same time for this instance, which is not allowed.'; $string['errorverbalfeedbacknotfound'] = 'verbal feedback not found.'; $string['factor'] = 'Factor'; -$string['feedbacksurvey'] = 'Feedback survey for {$a}'; $string['feedbackgiven'] = 'Feedback given'; $string['feedbackreceived'] = 'Feedback received'; -$string['finalize'] = 'Finalize evaluation'; +$string['feedbacksurvey'] = 'Feedback survey for {$a}'; $string['finaliseanonymousfeedback'] = 'Finalise anonymous feedback'; +$string['finalize'] = 'Finalize evaluation'; $string['finalresult'] = 'Final result'; $string['gotoquestionbank'] = 'Go to the verbal question bank'; $string['id'] = 'ID'; @@ -102,10 +102,10 @@ $string['instancenotready'] = 'Click the "Make available" button to release the questionnaire to the teachers after editing the verbal feedback items.'; $string['instancenotreadystudents'] = 'The verbal feedback activity is not yet ready. Please try again later.'; $string['instancenotyetopen'] = 'The verbal feedback activity is not yet open.'; +$string['instancenowready'] = 'The verbal feedback activity is now ready for use by the participants!'; $string['languageplural'] = 'Languages'; $string['listcategories'] = 'List categories'; $string['listcriteria'] = 'List criteria'; -$string['instancenowready'] = 'The verbal feedback activity is now ready for use by the participants!'; $string['managetemplates'] = 'Manage templates'; $string['messageafterdecline'] = 'Feedback declined.'; $string['modulename'] = 'Verbal feedback'; @@ -129,8 +129,8 @@ $string['pick'] = 'Pick'; $string['pickfromquestionbank'] = 'Pick a question from the question bank'; $string['placeholderquestion'] = "Enter question text"; -$string['pluginname'] = 'Verbal feedback'; $string['pluginadministration'] = 'Verbal feedback administration'; +$string['pluginname'] = 'Verbal feedback'; $string['position'] = 'Position'; $string['positive'] = 'Positive'; $string['preserveids'] = 'Preserve IDs?'; @@ -150,9 +150,9 @@ $string['qtypeinvalid'] = 'Invalid question type'; $string['qtyperated'] = 'Rated'; $string['question'] = 'Question'; +$string['questioncategory'] = 'Category'; $string['questiontext'] = 'Question text'; $string['questiontype'] = 'Question type'; -$string['questioncategory'] = 'Category'; $string['ratingaverage'] = 'Average rating'; $string['ratings'] = 'Ratings'; $string['rel_after'] = 'Release after the activity has closed'; @@ -203,9 +203,9 @@ $string['switchtouser'] = 'Switch to user...'; $string['teachers'] = 'Teachers'; $string['template'] = 'Template'; -$string['templateplural'] = 'Templates'; $string['templatecategoryplural'] = 'Template categories'; $string['templatecriteriaplural'] = 'Template criteria'; +$string['templateplural'] = 'Templates'; $string['text'] = 'Text'; $string['title'] = 'Verbal feedback'; $string['titlelabel'] = 'Title'; @@ -223,11 +223,11 @@ $string['verbalfeedback:editquestions'] = 'Edit verbal feedback questions'; $string['verbalfeedback:managetemplates'] = 'Manage verbal feedback templates'; $string['verbalfeedback:mapcourse'] = 'Map verbal feedback to course'; -$string['verbalfeedback:receivemail'] = 'Receive verbal feedback email'; $string['verbalfeedback:receive_rating'] = 'User can be rated'; +$string['verbalfeedback:receivemail'] = 'Receive verbal feedback email'; $string['verbalfeedback:view'] = 'View verbal feedback'; -$string['verbalfeedback:viewanalysepage'] = 'View verbal feedback analysis'; $string['verbalfeedback:view_all_reports'] = 'View verbal feedback reports of all students'; +$string['verbalfeedback:viewanalysepage'] = 'View verbal feedback analysis'; $string['verbalfeedbacklanguages'] = 'Verbal feedback languages'; $string['verbalfeedbacksettings'] = 'Verbal feedback settings'; $string['viewfeedbackforuser'] = 'View feedback for user'; diff --git a/lang/fr/verbalfeedback.php b/lang/fr/verbalfeedback.php index eac68cf..6e278ff 100644 --- a/lang/fr/verbalfeedback.php +++ b/lang/fr/verbalfeedback.php @@ -73,8 +73,8 @@ $string['enableselfreview'] = 'Activer l\'autorévision'; $string['entercomment'] = 'Entrez votre commentaire ici'; $string['enterquestion'] = 'Saisir le texte de la question...'; -$string['errorblankquestion'] = 'Requis'; $string['errorblankdeclinereason'] = 'Requis'; +$string['errorblankquestion'] = 'Requis'; $string['errorcannotadditem'] = 'Impossible d\'ajouter l\'élément feedback.'; $string['errorcannotparticipate'] = 'Vous ne pouvez pas participer à cette activité de feedback verbal'; $string['errorcannotrespond'] = 'Vous ne pouvez pas répondre à cette activité de feedback verbal'; @@ -84,19 +84,19 @@ $string['erroritemnotfound'] = 'L\'élément n\'a pas été trouvé.'; $string['errornocaptoedititems'] = 'Désolé, mais vous n\'avez pas la possibilité de modifier les éléments de feedback verbal'; $string['errornotenrolled'] = 'Vous devez être inscrit à ce cours pour pouvoir participer à cette activité de feedback verbal'; -$string['errornotingroup'] = 'Vous devez être dans un groupe pour pouvoir participer à cette activité de feedback verbal. Veuillez contacter votre administrateur de cours.'; $string['errornothingtodecline'] = 'Il n\'y a pas de feedback à refuser'; +$string['errornotingroup'] = 'Vous devez être dans un groupe pour pouvoir participer à cette activité de feedback verbal. Veuillez contacter votre administrateur de cours.'; $string['errorquestionstillinuse'] = 'Cette question ne peut pas être supprimée car elle est toujours utilisée par au moins une instance de feedback verbal.'; $string['errorreportnotavailable'] = 'Votre rapport de feedback n\'est pas encore disponible'; $string['errorresponsesavefailed'] = 'Une erreur s\'est produite lors de la sauvegarde des réponses. Veuillez réessayer plus tard.'; $string['errorroleconflict'] = 'L\'utilisateur actuel est à la fois élève et professeur pour cette instance, ce qui n\'est pas autorisé'; $string['errorverbalfeedbacknotfound'] = 'Feedback verbal non trouvé'; $string['factor'] = 'Facteur'; -$string['feedbacksurvey'] = 'Questionnaire feedback pour {$a}'; $string['feedbackgiven'] = 'Feedback donné'; $string['feedbackreceived'] = 'Feedback reçu'; -$string['finalize'] = 'Terminer évaluation'; +$string['feedbacksurvey'] = 'Questionnaire feedback pour {$a}'; $string['finaliseanonymousfeedback'] = 'Terminer feedback anonyme'; +$string['finalize'] = 'Terminer évaluation'; $string['finalresult'] = 'Résultat final'; $string['gotoquestionbank'] = 'Aller à la banque de questions du feelback verbal'; $string['id'] = 'ID'; @@ -104,11 +104,11 @@ $string['instancenotready'] = 'Cliquez sur le bouton «Rendre disponible» pour diffuser le questionnaire aux enseignants après avoir modifié les éléments de rétroaction verbale.'; $string['instancenotreadystudents'] = 'L\'activité de rétroaction verbale n\'est pas encore prête. Veuillez réessayer plus tard. '; $string['instancenotyetopen'] = 'L\'activité de feedback verbal n\'est pas encore ouverte.'; -$string['languageplural'] = 'Langues'; +$string['instancenowready'] = 'L\'outil est prêt'; $string['labelettingcategoriesdescription'] = 'Catégories qui peuvent être utilisées pour organiser des questions de feedback verbal'; +$string['languageplural'] = 'Langues'; $string['listcategories'] = 'Liste des catégories'; $string['listcriteria'] = 'Liste des critères'; -$string['instancenowready'] = 'L\'outil est prêt'; $string['messageafterdecline'] = 'Feedback refusé.'; $string['modulename'] = 'Feedback verbal'; $string['modulename_help'] = 'Le module d\'activité de feedback verbal permet aux étudiant-e-s de fournir un feedback à tous les autres étudiant-e-s'; @@ -131,8 +131,8 @@ $string['pick'] = 'Sélectionner'; $string['pickfromquestionbank'] = 'Choisissez une question dans la banque de questions'; $string['placeholderquestion'] = 'Saisissez le texte de la question'; -$string['pluginname'] = 'Feedback verbal'; $string['pluginadministration'] = 'Administration des commentaires verbaux'; +$string['pluginname'] = 'Feedback verbal'; $string['position'] = 'Position'; $string['positive'] = 'Positif'; $string['preserveids'] = 'Preserve IDs?'; @@ -152,9 +152,9 @@ $string['qtypeinvalid'] = 'Type de question non valable'; $string['qtyperated'] = 'Noté'; $string['question'] = 'Question'; +$string['questioncategory'] = 'Catégorie'; $string['questiontext'] = 'Texte de la question'; $string['questiontype'] = 'Type de question'; -$string['questioncategory'] = 'Catégorie'; $string['ratingaverage'] = 'Note moyenne'; $string['ratings'] = 'Notes'; $string['rel_after'] = 'Publication après la fermeture de l\'activité'; @@ -200,9 +200,9 @@ $string['switchtouser'] = 'Changer vers étudiant-e ...'; $string['teachers'] = 'Professerus'; $string['template'] = 'Template'; -$string['templateplural'] = 'Templates'; $string['templatecategoryplural'] = 'Catégories pour les templates'; $string['templatecriteriaplural'] = 'Critères pour les templates'; +$string['templateplural'] = 'Templates'; $string['text'] = 'Text'; $string['title'] = 'Feedback verbal'; $string['titlelabel'] = 'Title'; @@ -217,20 +217,19 @@ $string['verbalfeedback:edititems'] = 'Éditer éléments'; $string['verbalfeedback:editquestions'] = 'Modifier les questions de feedback verbal'; $string['verbalfeedback:mapcourse'] = 'Adapter le feedback verbal au cours'; -$string['verbalfeedback:receivemail'] = 'Recevoir un courriel de feedback verbal'; $string['verbalfeedback:receive_rating'] = 'L\'utilisateur/utilisatrice peut être évalué-e'; +$string['verbalfeedback:receivemail'] = 'Recevoir un courriel de feedback verbal'; $string['verbalfeedback:view'] = 'Voir les commentaires verbaux'; -$string['verbalfeedback:viewanalysepage'] = 'Voir l\'analyse du feedback verbal'; $string['verbalfeedback:view_all_reports'] = 'Voir les rapports de feedback verbal de tous les étudiant-e-s'; -$string['verbalfeedbacksettings'] = 'Paramètres du feedback verbal'; -$string['verbalfeedbacklanguages'] = 'Langues du feedback verbal'; -$string['verbalfeedbacksettings'] = 'Paramètres du feedback verbal'; -$string['viewfeedbackforuser'] = 'Voir feedback pour étudiant-e'; -$string['viewfeedbackreport'] = 'Voir le rapport du feedback'; +$string['verbalfeedback:viewanalysepage'] = 'Voir l\'analyse du feedback verbal'; $string['verbalfeedbackcategories'] = 'Catégories de feedback verbal'; $string['verbalfeedbackcriteria'] = 'Critères de feedback verbal'; +$string['verbalfeedbacklanguages'] = 'Langues du feedback verbal'; +$string['verbalfeedbacksettings'] = 'Paramètres du feedback verbal'; $string['verbalfeedbacktemplates'] = 'Templates de feedback verbal'; $string['verynegative'] = 'Très négatif'; $string['verypositive'] = 'Très positif'; +$string['viewfeedbackforuser'] = 'Voir feedback pour étudiant-e'; +$string['viewfeedbackreport'] = 'Voir le rapport du feedback'; $string['weight'] = 'Poids'; $string['weightedaverage'] = 'Ø pondéré'; diff --git a/tests/externallib_test.php b/tests/externallib_test.php index 439e15c..99ba83e 100644 --- a/tests/externallib_test.php +++ b/tests/externallib_test.php @@ -52,6 +52,7 @@ final class externallib_test extends \externallib_advanced_testcase { * Setup verbalfeedback. */ public function setUp(): void { + parent::setUp(); $this->category = $this->getDataGenerator()->create_category(); $this->course = $this->getDataGenerator()->create_course(['category' => $this->category->id]); $this->getDataGenerator()->create_module('verbalfeedback', ['course' => $this->course->id]); diff --git a/tests/font_test.php b/tests/font_test.php index 8a171d1..f1e91bb 100644 --- a/tests/font_test.php +++ b/tests/font_test.php @@ -29,25 +29,26 @@ * @copyright 2024 Stephan Robotta * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class font_test extends \advanced_testcase { +final class font_test extends \advanced_testcase { - /** @var stdClass */ - protected $course; /** @var array */ protected $students; /** @var stdClass the verval feedback course module. */ protected $cm; + /** @var stdClass the current course with the verbal feedback activity. */ + protected $course; /** * Setup verbalfeedback. */ public function setUp(): void { + parent::setUp(); $category = $this->getDataGenerator()->create_category(); $this->course = $this->getDataGenerator()->create_course(['category' => $category->id]); $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 +58,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 +75,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,9 +92,9 @@ 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() { + public function test_get_font_base(): void { global $SESSION; $this->resetAfterTest(); @@ -112,17 +113,17 @@ public function test_get_font_base() { $SESSION->forcelang = $test['lang']; $report = $reportservice->create_report($this->cm->id, $this->students[0]->id); $font = new font($report); - $this->assertEquals($test['expected'], $font->get_font_base(), "Font for language {$test['lang']} is not {$test['expected']}."); + $this->assertEquals($test['expected'], $font->get_font_base(), "Font for {$test['lang']} is not {$test['expected']}."); } } /** * 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]); + public function test_get_font_student(): void { + $this->getDataGenerator()->create_and_enrol($this->course, 'editingteacher', $this->get_teachers()[0]); $this->resetAfterTest(); $expected = [ 'inherit', @@ -133,7 +134,7 @@ public function test_get_font_student() { 'inherit', font::FONT_CHINESE, font::FONT_CHINESE, - font::FONT_JAPANESE, + font::FONT_JAPANESE, ]; foreach ($this->students as $key => $student) { $reportservice = new report_service(); @@ -146,9 +147,9 @@ 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() { + public function test_get_font_teacher(): void { $this->resetAfterTest(); $expected = [ 'inherit', @@ -157,12 +158,12 @@ 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) { - $enroledTeachers[] = $this->getDataGenerator()->create_and_enrol($this->course, 'editingteacher', $teacher); - api::generate_verbalfeedback_feedback_states($this->cm->id, $enroledTeachers[$key]->id); + $enroledteachers = []; + 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(); $report = $reportservice->create_report($this->cm->id, $this->students[0]->id); $font = new font($report); @@ -172,12 +173,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) { - api::generate_verbalfeedback_feedback_states($this->cm->id, $enroledTeachers[$key]->id); + 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,15 +187,15 @@ 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() { + public function test_set_font_for_pdf(): void { global $CFG; 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 +206,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/import_data_test.php b/tests/repository/import_data_test.php index 81012fd..f333aee 100644 --- a/tests/repository/import_data_test.php +++ b/tests/repository/import_data_test.php @@ -37,6 +37,7 @@ use mod_verbalfeedback\model\template\template_category; use mod_verbalfeedback\model\template\template_criterion; use mod_verbalfeedback\repository\language_repository; +use mod_verbalfeedback\repository\tables; use mod_verbalfeedback\repository\template_category_repository; use mod_verbalfeedback\repository\template_criterion_repository; use mod_verbalfeedback\repository\template_repository; @@ -46,6 +47,20 @@ */ final class import_data_test extends \advanced_testcase { + /** + * Setup the test class. + */ + public function setUp(): void { + global $DB; + + parent::setUp(); + // Empty tables, while not necessary locally it is necessary for CI at github. + $DB->execute(sprintf('TRUNCATE TABLE {%s}', tables::LANGUAGE_TABLE)); + $DB->execute(sprintf('TRUNCATE TABLE {%s}', tables::TEMPLATE_CATEGORY_TABLE)); + $DB->execute(sprintf('TRUNCATE TABLE {%s}', tables::TEMPLATE_CRITERION_TABLE)); + $DB->execute(sprintf('TRUNCATE TABLE {%s}', tables::TEMPLATE_TABLE)); + } + /** * Tests data import * @@ -66,7 +81,7 @@ public function test_import(): void { // Test dallgoot/yaml. $importdata = helper::parseyamlfile('./mod/verbalfeedback/db/default.yaml'); foreach ($importdata->languages as $yamllang) { - if ($yamllang->id == null) { + if (empty($yamllang->id)) { $lang = new language(null, $yamllang->language); $id = $langrepo->save($lang); $yamllang->id = $id; @@ -83,7 +98,7 @@ public function test_import(): void { $criterion->add_description($localstring); } - if ($criterion->get_id() == null) { + if ((int)$criterion->get_id() === 0) { $id = $criterionrepo->save($criterion); $yamlcriteria->id = $id; } else { diff --git a/tests/repository/language_repository_test.php b/tests/repository/language_repository_test.php index efa4d36..d144f59 100644 --- a/tests/repository/language_repository_test.php +++ b/tests/repository/language_repository_test.php @@ -30,7 +30,6 @@ use mod_verbalfeedback\model\language; use mod_verbalfeedback\repository\language_repository; -use mod_verbalfeedback\repository\mapper; use mod_verbalfeedback\repository\tables; /** @@ -45,6 +44,11 @@ final class language_repository_test extends \advanced_testcase { * Setup the test class. */ public function setUp(): void { + global $DB; + + parent::setUp(); + // Empty table, while not necessary locally it is necessary for CI at github. + $DB->execute(sprintf('TRUNCATE TABLE {%s}', tables::LANGUAGE_TABLE)); $this->repo = new language_repository(); } @@ -163,11 +167,11 @@ public function test_delete_by_id(): void { ['id' => 2, 'language' => 'de'], ['id' => 3, 'language' => 'fr'], ]; - $DB->insert_records('verbalfeedback_language', $languages); + $DB->insert_records(tables::LANGUAGE_TABLE, $languages); $this->repo->delete_by_id(1); - $this->assertFalse($DB->get_record('verbalfeedback_language', ['id' => 1])); + $this->assertFalse($DB->get_record(tables::LANGUAGE_TABLE, ['id' => 1])); } /** diff --git a/tests/repository/model/localized_string_type_test.php b/tests/repository/model/localized_string_type_test.php index effc99e..9855adb 100644 --- a/tests/repository/model/localized_string_type_test.php +++ b/tests/repository/model/localized_string_type_test.php @@ -32,13 +32,30 @@ /** * Verbal feedback language repository test class + * @covers \mod_verbalfeedback\repository\model\localized_string_type::INSTANCE_CRITERION + * @covers \mod_verbalfeedback\repository\model\localized_string_type::INSTANCE_CATEGORY_HEADER + * @covers \mod_verbalfeedback\repository\model\localized_string_type::INSTANCE_SUBRATING_TITLE + * @covers \mod_verbalfeedback\repository\model\localized_string_type::INSTANCE_SUBRATING_DESCRIPTION + * @covers \mod_verbalfeedback\repository\model\localized_string_type::INSTANCE_SUBRATING_VERY_NEGATIVE + * @covers \mod_verbalfeedback\repository\model\localized_string_type::INSTANCE_SUBRATING_NEGATIVE + * @covers \mod_verbalfeedback\repository\model\localized_string_type::INSTANCE_SUBRATING_POSITIVE + * @covers \mod_verbalfeedback\repository\model\localized_string_type::INSTANCE_SUBRATING_VERY_POSITIVE + * @covers \mod_verbalfeedback\repository\model\localized_string_type::TEMPLATE_CRITERION + * @covers \mod_verbalfeedback\repository\model\localized_string_type::TEMPLATE_CATEGORY_HEADER + * @covers \mod_verbalfeedback\repository\model\localized_string_type::TEMPLATE_SUBRATING_TITLE + * @covers \mod_verbalfeedback\repository\model\localized_string_type::TEMPLATE_SUBRATING_DESCRIPTION + * @covers \mod_verbalfeedback\repository\model\localized_string_type::TEMPLATE_SUBRATING_VERY_NEGATIVE + * @covers \mod_verbalfeedback\repository\model\localized_string_type::TEMPLATE_SUBRATING_NEGATIVE + * @covers \mod_verbalfeedback\repository\model\localized_string_type::TEMPLATE_SUBRATING_POSITIVE + * @covers \mod_verbalfeedback\repository\model\localized_string_type::TEMPLATE_SUBRATING_VERY_POSITIVE */ final class localized_string_type_test extends \advanced_testcase { /** * The string constants that are used in the verbal feedback module but are stored as ids in the database. + * @var string[] */ - private $stringConstants = [ + private $stringconstants = [ 'instance_criterion', 'instance_category_header', 'instance_subrating_title', @@ -86,7 +103,7 @@ public function test_constants(): void { */ public function test_str2id(): void { $i = 1; - foreach ($this->stringConstants as $string) { + foreach ($this->stringconstants as $string) { $this->assertEquals($i, localized_string_type::str2id($string)); $i++; } @@ -99,7 +116,7 @@ public function test_str2id(): void { */ public function test_id2str(): void { $i = 1; - foreach ($this->stringConstants as $string) { + foreach ($this->stringconstants as $string) { $this->assertEquals($string, localized_string_type::id2str($i)); $i++; } @@ -112,10 +129,10 @@ public function test_id2str(): void { /** * Test the getStringTypes method. * - * @covers \mod_verbalfeedback\repository\model\localized_string_type::getStringTypes + * @covers \mod_verbalfeedback\repository\model\localized_string_type::get_string_types */ - public function test_getStringTypes(): void { - $this->assertEquals($this->stringConstants, localized_string_type::getStringTypes()); + public function test_get_string_types(): void { + $this->assertEquals($this->stringconstants, localized_string_type::get_string_types()); } /** @@ -124,11 +141,35 @@ public function test_getStringTypes(): void { * @covers \mod_verbalfeedback\repository\model\localized_string_type::exists */ public function test_exists(): void { - foreach ($this->stringConstants as $string) { + foreach ($this->stringconstants as $string) { $this->assertTrue(localized_string_type::exists($string)); $this->assertFalse(localized_string_type::exists(strtoupper($string))); $this->assertFalse(localized_string_type::exists(ucfirst($string))); } $this->assertFalse(localized_string_type::exists('nonexisting')); } + + /** + * Test the is_template_type method. + * + * @covers \mod_verbalfeedback\repository\model\localized_string_type::is_template_type + */ + public function test_is_template_type(): void { + $this->assertTrue(localized_string_type::is_template_type(localized_string_type::TEMPLATE_CRITERION)); + $this->assertTrue(localized_string_type::is_template_type(localized_string_type::TEMPLATE_CATEGORY_HEADER)); + $this->assertTrue(localized_string_type::is_template_type(localized_string_type::TEMPLATE_SUBRATING_TITLE)); + $this->assertTrue(localized_string_type::is_template_type(localized_string_type::TEMPLATE_SUBRATING_DESCRIPTION)); + $this->assertTrue(localized_string_type::is_template_type(localized_string_type::TEMPLATE_SUBRATING_VERY_NEGATIVE)); + $this->assertTrue(localized_string_type::is_template_type(localized_string_type::TEMPLATE_SUBRATING_NEGATIVE)); + $this->assertTrue(localized_string_type::is_template_type(localized_string_type::TEMPLATE_SUBRATING_POSITIVE)); + $this->assertTrue(localized_string_type::is_template_type(localized_string_type::TEMPLATE_SUBRATING_VERY_POSITIVE)); + $this->assertFalse(localized_string_type::is_template_type(localized_string_type::INSTANCE_CRITERION)); + $this->assertFalse(localized_string_type::is_template_type(localized_string_type::INSTANCE_CATEGORY_HEADER)); + $this->assertFalse(localized_string_type::is_template_type(localized_string_type::INSTANCE_SUBRATING_TITLE)); + $this->assertFalse(localized_string_type::is_template_type(localized_string_type::INSTANCE_SUBRATING_DESCRIPTION)); + $this->assertFalse(localized_string_type::is_template_type(localized_string_type::INSTANCE_SUBRATING_VERY_NEGATIVE)); + $this->assertFalse(localized_string_type::is_template_type(localized_string_type::INSTANCE_SUBRATING_NEGATIVE)); + $this->assertFalse(localized_string_type::is_template_type(localized_string_type::INSTANCE_SUBRATING_POSITIVE)); + $this->assertFalse(localized_string_type::is_template_type(localized_string_type::INSTANCE_SUBRATING_VERY_POSITIVE)); + } } diff --git a/tests/verbalfeedback_test.php b/tests/verbalfeedback_test.php index d0d06a0..82e7dff 100644 --- a/tests/verbalfeedback_test.php +++ b/tests/verbalfeedback_test.php @@ -51,11 +51,6 @@ final class verbalfeedback_test extends \advanced_testcase { */ protected $course; - /** - * @var int Course id used for testing - */ - protected $courseid; - /** * @var \core_user Teacher used for testing */ @@ -65,31 +60,22 @@ final class verbalfeedback_test extends \advanced_testcase { * @var array<\core_user> Array of students used for testion */ protected $students; + /** * @var instance Verbal feedback used for testing */ protected $verbalfeedback; - /** - * @var int Verbal feedback id used for testing - */ - protected $verbalfeedbackid; - /** - * @var string Verbal feedback name used for testing - */ - protected $verbalfeedbackname; /** * Setup verbalfeedback. */ public function setUp(): void { global $DB; + parent::setUp(); $this->category = $this->getDataGenerator()->create_category(); $this->course = $this->getDataGenerator()->create_course(['category' => $this->category->id]); - $this->courseid = $this->course->id; $this->verbalfeedback = $this->getDataGenerator()->create_module('verbalfeedback', ['course' => $this->course->id]); - $this->verbalfeedbackid = $this->verbalfeedback->id; - $this->verbalfeedbackname = $this->verbalfeedback->name; - $cm = $DB->get_record('course_modules', ['id' => $this->verbalfeedback->cmid], '*', MUST_EXIST); + $DB->get_record('course_modules', ['id' => $this->verbalfeedback->cmid], '*', MUST_EXIST); $this->create_and_enrol_users(); }