Skip to content

Commit 5fc9623

Browse files
lucaboeschFelixDiLenardamchurchward
authored
Allow localized answer options to be displayed correctly in conditions. (#449)
* Resized the monologo.svg and png to 24x24 px (#477) * Fixing issues from plugins database checks (#483) * Removing illegal console commands. Script may not be needed. * Fixing illegal line length. * Fixing docblocks and unused variables. * Fixing css spaces. * Adding a true return. * Fixing JSON context. * Allow localized answer options to be displayed correctly in conditions. --------- Co-authored-by: FelixDiLenarda <[email protected]> Co-authored-by: Mike Churchward <[email protected]>
1 parent 686880b commit 5fc9623

File tree

11 files changed

+135
-130
lines changed

11 files changed

+135
-130
lines changed

appjs/uncheckother.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
(function(t) {
22
t.toggleRatebox = function($event, $fieldkey) {
3-
console.log($fieldkey);
4-
console.log($event);
5-
console.log($event.value);
6-
console.log(this.CONTENT_OTHERDATA[$fieldkey]);
7-
// this.CONTENT_OTHERDATA[$fieldkey] = "4";
83
}
94
})(this);

db/upgrade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ function xmldb_questionnaire_upgrade($oldversion=0) {
997997
upgrade_mod_savepoint(true, 2022092200, 'questionnaire');
998998
}
999999

1000-
return $result;
1000+
return true;
10011001
}
10021002

10031003
/**

javascript/mobile.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ this.questionsFormErrors = {};
2323
for (const fieldkey in this.CONTENT_OTHERDATA.fields) {
2424
questionsFormFields[fieldkey] = [];
2525
questionsFormFields[fieldkey][0] = '';
26-
for (const itemid in this.CONTENT_OTHERDATA.questions[this.CONTENT_OTHERDATA.pagenum][this.CONTENT_OTHERDATA.fields[fieldkey].id]) {
27-
questionsFormFields[fieldkey][0] = this.CONTENT_OTHERDATA.questions[this.CONTENT_OTHERDATA.pagenum][this.CONTENT_OTHERDATA.fields[fieldkey].id][itemid].value;
26+
for (const itemid in
27+
this.CONTENT_OTHERDATA.questions[this.CONTENT_OTHERDATA.pagenum][this.CONTENT_OTHERDATA.fields[fieldkey].id]) {
28+
questionsFormFields[fieldkey][0] =
29+
this.CONTENT_OTHERDATA.questions[this.CONTENT_OTHERDATA.pagenum][this.CONTENT_OTHERDATA.fields[fieldkey].id]
30+
[itemid].value;
2831
}
2932
if (this.CONTENT_OTHERDATA.fields[fieldkey].required === 'y') {
3033
questionsFormFields[fieldkey][1] = this.Validators.required;

module.js

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,21 @@
2727
* http://stackoverflow.com/questions/6787383/what-is-the-solution-to-remove-add-a-class-in-pure-javascript.
2828
* */
2929

30-
function addClass(el, aclass){
30+
/**
31+
* @param {HTMLElement} el
32+
* @param {string} aclass
33+
*/
34+
function addClass(el, aclass) {
3135
el.className += ' ' + aclass;
3236
}
3337

34-
function removeClass(el, aclass){
38+
/**
39+
* @param {HTMLElement} el
40+
* @param {string} aclass
41+
*/
42+
function removeClass(el, aclass) {
3543
var elClass = ' ' + el.className + ' ';
36-
while(elClass.indexOf(' ' + aclass + ' ') != - 1) {
44+
while (elClass.indexOf(' ' + aclass + ' ') != -1) {
3745
elClass = elClass.replace(' ' + aclass + ' ', '');
3846
}
3947
el.className = elClass;
@@ -44,7 +52,6 @@ function removeClass(el, aclass){
4452
* Javascript for hiding/displaying children questions on preview page of
4553
* questionnaire with conditional branching.
4654
*/
47-
4855
function depend(children, choices) {
4956
children = children.split(',');
5057
choices = choices.split(',');
@@ -82,7 +89,7 @@ function depend(children, choices) {
8289
droplist.disabled = false;
8390
}
8491
delete children[i];
85-
} else if (children[i]){
92+
} else if (children[i]) {
8693
if (typeof document !== "undefined" && ("classList" in document.createElement("a"))) {
8794
q.classList.remove('qn-container');
8895
q.classList.add('hidedependquestion');
@@ -114,6 +121,10 @@ function depend(children, choices) {
114121

115122
/* exported dependdrop */
116123

124+
/**
125+
* @param {string} qId
126+
* @param {*} children
127+
*/
117128
function dependdrop(qId, children) {
118129
var e = document.getElementById(qId);
119130
var choice = e.options[e.selectedIndex].value;
@@ -124,9 +135,12 @@ function dependdrop(qId, children) {
124135
// When respondent enters text in !other field, corresponding
125136
// radio button OR check box is automatically checked.
126137
/* exported other_check */
138+
/**
139+
* @param {string | void} name
140+
*/
127141
function other_check(name) {
128142
var other = name.split("_");
129-
var other = name.slice(name.indexOf("o")+1);
143+
var other = name.slice(name.indexOf("o") + 1);
130144
if (other.indexOf("]") != -1) {
131145
other = other.slice(0, other.indexOf("]"));
132146
}
@@ -141,6 +155,9 @@ function other_check(name) {
141155

142156
// Automatically empty an !other text input field if another Radio button is clicked.
143157
/* exported other_check_empty */
158+
/**
159+
* @param {string} name
160+
*/
144161
function other_check_empty(name, value) {
145162
var f = document.getElementById("phpesp_response");
146163
var i;
@@ -149,7 +166,7 @@ function other_check_empty(name, value) {
149166
f.elements[i].checked = true;
150167
var otherid = f.elements[i].name + "_" + f.elements[i].value.substring(6);
151168
var other = document.getElementsByName(otherid);
152-
if (value.substr(0,6) != "other_") {
169+
if (value.substr(0, 6) != "other_") {
153170
other[0].value = "";
154171
} else {
155172
other[0].focus();
@@ -169,6 +186,10 @@ function other_check_empty(name, value) {
169186
// In a Rate question type of sub-type Order : automatically uncheck a Radio button
170187
// when another radio button in the same column is clicked.
171188
/* exported other_rate_uncheck */
189+
/**
190+
* @param {string} name
191+
* @param {string} value
192+
*/
172193
function other_rate_uncheck(name, value) {
173194
var col_name = name.substr(0, name.indexOf("_"));
174195
var inputbuttons = document.getElementsByTagName("input");
@@ -183,6 +204,9 @@ function other_rate_uncheck(name, value) {
183204

184205
// Empty an !other text input when corresponding Check Box is clicked (supposedly to empty it).
185206
/* exported checkbox_empty */
207+
/**
208+
* @param {string} name
209+
*/
186210
function checkbox_empty(name) {
187211
var actualbuttons = document.getElementsByName(name);
188212
for (var i = 0; i <= actualbuttons.length; i++) {
@@ -204,24 +228,24 @@ M.mod_questionnaire = M.mod_questionnaire || {};
204228

205229
/* exported Y */
206230
/* exported e */
207-
M.mod_questionnaire.init_attempt_form = function(Y) {
231+
M.mod_questionnaire.init_attempt_form = function() {
208232
M.core_formchangechecker.init({formid: 'phpesp_response'});
209233
};
210234

211235
M.mod_questionnaire.init_sendmessage = function(Y) {
212-
Y.on('click', function(e) {
236+
Y.on('click', function() {
213237
Y.all('input.usercheckbox').each(function() {
214238
this.set('checked', 'checked');
215239
});
216240
}, '#checkall');
217241

218-
Y.on('click', function(e) {
242+
Y.on('click', function() {
219243
Y.all('input.usercheckbox').each(function() {
220244
this.set('checked', '');
221245
});
222246
}, '#checknone');
223247

224-
Y.on('click', function(e) {
248+
Y.on('click', function() {
225249
Y.all('input.usercheckbox').each(function() {
226250
if (this.get('alt') == 0) {
227251
this.set('checked', 'checked');
@@ -231,7 +255,7 @@ M.mod_questionnaire.init_sendmessage = function(Y) {
231255
});
232256
}, '#checknotstarted');
233257

234-
Y.on('click', function(e) {
258+
Y.on('click', function() {
235259
Y.all('input.usercheckbox').each(function() {
236260
if (this.get('alt') == 1) {
237261
this.set('checked', 'checked');
@@ -242,7 +266,7 @@ M.mod_questionnaire.init_sendmessage = function(Y) {
242266
}, '#checkstarted');
243267

244268
};
245-
M.mod_questionnaire.init_slider = function(Y) {
269+
M.mod_questionnaire.init_slider = function() {
246270
const allRanges = document.querySelectorAll(".slider");
247271
allRanges.forEach(wrap => {
248272
const range = wrap.querySelector("input.questionnaire-slider");

pix/monologo.png

-4.53 KB
Loading

0 commit comments

Comments
 (0)