diff --git a/appjs/uncheckother.js b/appjs/uncheckother.js index dd06d8b4..c76a4df6 100644 --- a/appjs/uncheckother.js +++ b/appjs/uncheckother.js @@ -1,9 +1,4 @@ (function(t) { t.toggleRatebox = function($event, $fieldkey) { - console.log($fieldkey); - console.log($event); - console.log($event.value); - console.log(this.CONTENT_OTHERDATA[$fieldkey]); -// this.CONTENT_OTHERDATA[$fieldkey] = "4"; } })(this); \ No newline at end of file diff --git a/db/upgrade.php b/db/upgrade.php index 3861f365..fe91ab16 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -997,7 +997,7 @@ function xmldb_questionnaire_upgrade($oldversion=0) { upgrade_mod_savepoint(true, 2022092200, 'questionnaire'); } - return $result; + return true; } /** diff --git a/javascript/mobile.js b/javascript/mobile.js index 1291f57a..e46928da 100644 --- a/javascript/mobile.js +++ b/javascript/mobile.js @@ -23,8 +23,11 @@ this.questionsFormErrors = {}; for (const fieldkey in this.CONTENT_OTHERDATA.fields) { questionsFormFields[fieldkey] = []; questionsFormFields[fieldkey][0] = ''; - for (const itemid in this.CONTENT_OTHERDATA.questions[this.CONTENT_OTHERDATA.pagenum][this.CONTENT_OTHERDATA.fields[fieldkey].id]) { - questionsFormFields[fieldkey][0] = this.CONTENT_OTHERDATA.questions[this.CONTENT_OTHERDATA.pagenum][this.CONTENT_OTHERDATA.fields[fieldkey].id][itemid].value; + for (const itemid in + this.CONTENT_OTHERDATA.questions[this.CONTENT_OTHERDATA.pagenum][this.CONTENT_OTHERDATA.fields[fieldkey].id]) { + questionsFormFields[fieldkey][0] = + this.CONTENT_OTHERDATA.questions[this.CONTENT_OTHERDATA.pagenum][this.CONTENT_OTHERDATA.fields[fieldkey].id] + [itemid].value; } if (this.CONTENT_OTHERDATA.fields[fieldkey].required === 'y') { questionsFormFields[fieldkey][1] = this.Validators.required; diff --git a/module.js b/module.js index f3eb8d60..9eb3e93d 100644 --- a/module.js +++ b/module.js @@ -27,13 +27,21 @@ * http://stackoverflow.com/questions/6787383/what-is-the-solution-to-remove-add-a-class-in-pure-javascript. * */ -function addClass(el, aclass){ +/** + * @param {HTMLElement} el + * @param {string} aclass + */ +function addClass(el, aclass) { el.className += ' ' + aclass; } -function removeClass(el, aclass){ +/** + * @param {HTMLElement} el + * @param {string} aclass + */ +function removeClass(el, aclass) { var elClass = ' ' + el.className + ' '; - while(elClass.indexOf(' ' + aclass + ' ') != - 1) { + while (elClass.indexOf(' ' + aclass + ' ') != -1) { elClass = elClass.replace(' ' + aclass + ' ', ''); } el.className = elClass; @@ -44,7 +52,6 @@ function removeClass(el, aclass){ * Javascript for hiding/displaying children questions on preview page of * questionnaire with conditional branching. */ - function depend(children, choices) { children = children.split(','); choices = choices.split(','); @@ -82,7 +89,7 @@ function depend(children, choices) { droplist.disabled = false; } delete children[i]; - } else if (children[i]){ + } else if (children[i]) { if (typeof document !== "undefined" && ("classList" in document.createElement("a"))) { q.classList.remove('qn-container'); q.classList.add('hidedependquestion'); @@ -114,6 +121,10 @@ function depend(children, choices) { /* exported dependdrop */ +/** + * @param {string} qId + * @param {*} children + */ function dependdrop(qId, children) { var e = document.getElementById(qId); var choice = e.options[e.selectedIndex].value; @@ -124,9 +135,12 @@ function dependdrop(qId, children) { // When respondent enters text in !other field, corresponding // radio button OR check box is automatically checked. /* exported other_check */ +/** + * @param {string | void} name + */ function other_check(name) { var other = name.split("_"); - var other = name.slice(name.indexOf("o")+1); + var other = name.slice(name.indexOf("o") + 1); if (other.indexOf("]") != -1) { other = other.slice(0, other.indexOf("]")); } @@ -141,6 +155,9 @@ function other_check(name) { // Automatically empty an !other text input field if another Radio button is clicked. /* exported other_check_empty */ +/** + * @param {string} name + */ function other_check_empty(name, value) { var f = document.getElementById("phpesp_response"); var i; @@ -149,7 +166,7 @@ function other_check_empty(name, value) { f.elements[i].checked = true; var otherid = f.elements[i].name + "_" + f.elements[i].value.substring(6); var other = document.getElementsByName(otherid); - if (value.substr(0,6) != "other_") { + if (value.substr(0, 6) != "other_") { other[0].value = ""; } else { other[0].focus(); @@ -169,6 +186,10 @@ function other_check_empty(name, value) { // In a Rate question type of sub-type Order : automatically uncheck a Radio button // when another radio button in the same column is clicked. /* exported other_rate_uncheck */ +/** + * @param {string} name + * @param {string} value + */ function other_rate_uncheck(name, value) { var col_name = name.substr(0, name.indexOf("_")); var inputbuttons = document.getElementsByTagName("input"); @@ -183,6 +204,9 @@ function other_rate_uncheck(name, value) { // Empty an !other text input when corresponding Check Box is clicked (supposedly to empty it). /* exported checkbox_empty */ +/** + * @param {string} name + */ function checkbox_empty(name) { var actualbuttons = document.getElementsByName(name); for (var i = 0; i <= actualbuttons.length; i++) { @@ -204,24 +228,24 @@ M.mod_questionnaire = M.mod_questionnaire || {}; /* exported Y */ /* exported e */ -M.mod_questionnaire.init_attempt_form = function(Y) { +M.mod_questionnaire.init_attempt_form = function() { M.core_formchangechecker.init({formid: 'phpesp_response'}); }; M.mod_questionnaire.init_sendmessage = function(Y) { - Y.on('click', function(e) { + Y.on('click', function() { Y.all('input.usercheckbox').each(function() { this.set('checked', 'checked'); }); }, '#checkall'); - Y.on('click', function(e) { + Y.on('click', function() { Y.all('input.usercheckbox').each(function() { this.set('checked', ''); }); }, '#checknone'); - Y.on('click', function(e) { + Y.on('click', function() { Y.all('input.usercheckbox').each(function() { if (this.get('alt') == 0) { this.set('checked', 'checked'); @@ -231,7 +255,7 @@ M.mod_questionnaire.init_sendmessage = function(Y) { }); }, '#checknotstarted'); - Y.on('click', function(e) { + Y.on('click', function() { Y.all('input.usercheckbox').each(function() { if (this.get('alt') == 1) { this.set('checked', 'checked'); @@ -242,7 +266,7 @@ M.mod_questionnaire.init_sendmessage = function(Y) { }, '#checkstarted'); }; -M.mod_questionnaire.init_slider = function(Y) { +M.mod_questionnaire.init_slider = function() { const allRanges = document.querySelectorAll(".slider"); allRanges.forEach(wrap => { const range = wrap.querySelector("input.questionnaire-slider"); diff --git a/styles_app.css b/styles_app.css index e1b368db..e752eca3 100644 --- a/styles_app.css +++ b/styles_app.css @@ -7,7 +7,7 @@ span.mobileratequestion { -webkit-transform: translate3d(0, 0, 0) scale(1); transform: translate3d(0, 0, 0) scale(1); } -.mod_questionnaire_slider .range-has-pin::part(pin){ +.mod_questionnaire_slider .range-has-pin::part(pin) { -webkit-transform: translate3d(0, -24px, 0) scale(1); transform: translate3d(0, -24px, 0) scale(1); } diff --git a/templates/local/mobile/ionic3/select_question.mustache b/templates/local/mobile/ionic3/select_question.mustache index 30777db4..cf41de04 100644 --- a/templates/local/mobile/ionic3/select_question.mustache +++ b/templates/local/mobile/ionic3/select_question.mustache @@ -28,11 +28,13 @@ "fieldkey": 985, "choices": [ { + "id": 200, "content": "Red", "completed": 0, "value": 1 }, { + "id": 201, "content": "Blue", "completed": 0, "value": 0 diff --git a/templates/local/mobile/ionic3/slider_question.mustache b/templates/local/mobile/ionic3/slider_question.mustache index 64aef335..27ccb7c2 100644 --- a/templates/local/mobile/ionic3/slider_question.mustache +++ b/templates/local/mobile/ionic3/slider_question.mustache @@ -27,18 +27,16 @@ { "fieldkey": 985, "extradata": { - "minrange" : 1 - "maxrange" : 10 - "startingvalue" : 5 - "stepvalue" : 1 - "leftlabel" : "left label" - "rightlabel" : "right label" + "minrange" : 1, + "maxrange" : 10, + "startingvalue" : 5, + "stepvalue" : 1, + "leftlabel" : "left label", + "rightlabel" : "right label", "centerlabel": "center label" }, - completed: 0 - + "completed": 0 } - }} {{=<% %>=}} <%#extradata%>