Skip to content

Commit

Permalink
Fixing issues from plugins database checks (PoetOS#483)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mchurchward authored May 16, 2023
1 parent fbb842e commit 458cedc
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 31 deletions.
5 changes: 0 additions & 5 deletions appjs/uncheckother.js
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ function xmldb_questionnaire_upgrade($oldversion=0) {
upgrade_mod_savepoint(true, 2022092200, 'questionnaire');
}

return $result;
return true;
}

/**
Expand Down
7 changes: 5 additions & 2 deletions javascript/mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
50 changes: 37 additions & 13 deletions module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(',');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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;
Expand All @@ -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("]"));
}
Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -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");
Expand All @@ -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++) {
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion styles_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions templates/local/mobile/ionic3/select_question.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@
"fieldkey": 985,
"choices": [
{
"id": 200,
"content": "Red",
"completed": 0,
"value": 1
},
{
"id": 201,
"content": "Blue",
"completed": 0,
"value": 0
Expand Down
16 changes: 7 additions & 9 deletions templates/local/mobile/ionic3/slider_question.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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%>
Expand Down

0 comments on commit 458cedc

Please sign in to comment.