Skip to content

Commit

Permalink
Dev: Move loop to check for EM question dependencies for JavaScript (…
Browse files Browse the repository at this point in the history
…here, questions MUST be dependent on themselfes
  • Loading branch information
olleharstedt committed Dec 7, 2017
1 parent 33d76d5 commit b10b5ad
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -7633,6 +7633,20 @@ public static function GetRelevanceAndTailoringJavaScript($bReturnArray=false)
continue; // don't make dependent upon off-page variables
}
$_qid = $knownVar['qid'];

/**
* https://bugs.limesurvey.org/view.php?id=8308#c26972
* Thomas White explained: "LEMrelXX functions were specifically designed to only be called for questions that have some dependency upon others "
* So $qrelQIDs contains those questions.
*/
$sQid = str_replace("relChange","",$_qid);
if(!in_array($sQid, $aQuestionsWithDependencies) ){
$aQuestionsWithDependencies[]=$sQid;
}

// We add the question having condition itself to the array of question to check
$aQuestionsWithDependencies[] = $arg['qid'];

if ($_qid == $arg['qid']) {
continue; // don't make dependent upon itself
}
Expand All @@ -7641,27 +7655,11 @@ public static function GetRelevanceAndTailoringJavaScript($bReturnArray=false)
}
}
$qrelQIDs = array_unique($qrelQIDs);
$aQuestionsWithDependencies = array_unique($aQuestionsWithDependencies);
if ($LEM->surveyMode=='question') {
$qrelQIDs=array(); // in question-by-questin mode, should never test for dependencies on self or other questions.
}

/**
* https://bugs.limesurvey.org/view.php?id=8308#c26972
* Thomas White explained: "LEMrelXX functions were specifically designed to only be called for questions that have some dependency upon others "
* So $qrelQIDs contains those questions.
*/
foreach($qrelQIDs as $qrelQID)
{
$sQid = str_replace("relChange","",$qrelQID);
if(!in_array($sQid, $aQuestionsWithDependencies) ){
$aQuestionsWithDependencies[]=$sQid;
}

// We add the question having condition itself to the array of question to check
$aQuestionsWithDependencies[] = $arg['qid'];
}


$qrelJS = "function LEMrel" . $arg['qid'] . "(sgqa){\n";
$qrelJS .= " var UsesVars = ' " . implode(' ', $relJsVarsUsed) . " ';\n";
// if (count($qrelQIDs) > 0)
Expand Down

0 comments on commit b10b5ad

Please sign in to comment.