From b90a977077c9d56e76b7ca44c29f21c86e583db2 Mon Sep 17 00:00:00 2001 From: Stephan Robotta Date: Fri, 20 Dec 2024 17:37:27 +0100 Subject: [PATCH] Adapt ci config. --- .github/workflows/moodle-plugin-ci.yml | 13 ++++++------ amd/build/questionnaire.min.js.map | 2 +- amd/src/questionnaire.js | 29 +++++++++++++------------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.github/workflows/moodle-plugin-ci.yml b/.github/workflows/moodle-plugin-ci.yml index 33cdbc8..c0c9927 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,7 +138,7 @@ jobs: env: DB: ${{ matrix.database }} MOODLE_BRANCH: ${{ matrix.moodle-branch }} - IGNORE_PATHS: 'moodle/tests/fixtures,moodle/Sniffs,classes/vendor' + IGNORE_PATHS: 'moodle/tests/fixtures,moodle/Sniffs,classes/vendor,fonts' PHPCS_IGNORE_PATHS: /^classes\/vendor/ PHPDOCCHECKER_IGNORE_PATHS: /^classes\/vendor/ MUSTACHE_IGNORE_NAMES: 'report.mustache,questionnaire.mustache' @@ -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/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,SAGLK,WAAa,SAASC,IAAK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AAS,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,cAE1DK,UAAYP,IAAIK,K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ACnCA,EAAEC,qBAEEK,eADMpH,EAAEqC,MAAM6B,QAAQ,gCACD/C,KAAK,oBAC1BiG,eAAeJ,SAAS,WACxBI,eAAexD,YAAY,UAC3B5D,EAAEqC,MAAMjB,KAAK,OAEbgG,eAAevD,SAAS,UACxB7D,EAAEqC,MAAMjB,KAAK,UAsJlBc"} \ No newline at end of file diff --git a/amd/src/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',