Skip to content

Commit

Permalink
Fixed issue #05785: in all-in-one survey mode, questions whose tailor…
Browse files Browse the repository at this point in the history
…ing depends entirely on out-of-group variables is not happening

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12409 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
tmswhite committed Feb 8, 2012
1 parent 1ca1cdc commit 1906014
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
45 changes: 32 additions & 13 deletions application/helpers/expressions/em_core_helper.php
Expand Up @@ -60,7 +60,7 @@ class ExpressionManager {

private $questionSeq; // sequence order of question - so can detect if try to use variable before it is set
private $groupSeq; // sequence order of groups - so can detect if try to use variable before it is set
private $allOnOnePage=false;
private $surveyMode='group';

// The following are only needed to enable click on variable names within pretty print and open new window to edit them
private $sid=NULL; // the survey ID
Expand Down Expand Up @@ -1095,21 +1095,35 @@ public function GetOnPageJsVarsUsed()
if (is_null($this->varsUsed)){
return array();
}
if ($this->allOnOnePage)
if ($this->surveyMode=='survey')
{
return GetJsVarsUsed();
return $this->GetJsVarsUsed();
}
$names = array_unique($this->varsUsed);
if (is_null($names)) {
return array();
}
$jsNames = array();
foreach ($names as $name)
if ($this->surveyMode=='group')
{
$val = $this->GetVarAttribute($name,'jsName','');
$gseq = $this->GetVarAttribute($name,'gseq','');
if ($val != '' && $gseq == $this->groupSeq) {
$jsNames[] = $val;
foreach ($names as $name)
{
$val = $this->GetVarAttribute($name,'jsName','');
$gseq = $this->GetVarAttribute($name,'gseq','');
if ($val != '' && $gseq == $this->groupSeq) {
$jsNames[] = $val;
}
}
}
else
{
foreach ($names as $name)
{
$val = $this->GetVarAttribute($name,'jsName','');
$qseq = $this->GetVarAttribute($name,'qseq','');
if ($val != '' && $qseq == $this->questionSeq) {
$jsNames[] = $val;
}
}
}
return array_unique($jsNames);
Expand Down Expand Up @@ -1673,11 +1687,16 @@ private function GetVarAttribute($name,$attr,$default)
}
break;
case 'jsName':
if ($this->allOnOnePage || ($this->groupSeq != -1 && isset($var['gseq']) && $this->groupSeq == $var['gseq'])) {
// then on the same page, so return the on-page javaScript name if there is one.
if ($this->surveyMode=='survey'
|| ($this->surveyMode=='group' && $this->groupSeq != -1 && isset($var['gseq']) && $this->groupSeq == $var['gseq'])
|| ($this->surveyMode=='question' && $this->questionSeq != -1 && isset($var['qseq']) && $this->questionSeq == $var['qseq']))
{
return (isset($var['jsName_on']) ? $var['jsName_on'] : (isset($var['jsName'])) ? $var['jsName'] : $default);
}
return (isset($var['jsName']) ? $var['jsName'] : $default);
else {
return (isset($var['jsName']) ? $var['jsName'] : $default);
}
break;
case 'sgqa':
case 'mandatory':
case 'qid':
Expand Down Expand Up @@ -1939,11 +1958,11 @@ public function ProcessBooleanExpression($expr,$groupSeq=-1,$questionSeq=-1)
* Start processing a group of substitions - will be incrementally numbered
*/

public function StartProcessingGroup($sid=NULL,$rooturl='',$hyperlinkSyntaxHighlighting=true,$allOnOnePage=false)
public function StartProcessingGroup($sid=NULL,$rooturl='',$hyperlinkSyntaxHighlighting=true,$surveyMode='group')
{
$this->substitutionNum=0;
$this->substitutionInfo=array(); // array of JavaScripts for managing each substitution
$this->allOnOnePage=$allOnOnePage;
$this->surveyMode=$surveyMode;
$this->sid=$sid;
$this->hyperlinkSyntaxHighlighting=$hyperlinkSyntaxHighlighting;
}
Expand Down
10 changes: 8 additions & 2 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -4690,7 +4690,9 @@ static function StartProcessingGroup($groupNum=NULL,$anonymized=false,$surveyid=
$LEM =& LimeExpressionManager::singleton();
$LEM->em->StartProcessingGroup(
isset($surveyid) ? $surveyid : NULL,
isset($LEM->surveyOptions['hyperlinkSyntaxHighlighting']) ? $LEM->surveyOptions['hyperlinkSyntaxHighlighting'] : false
'',
isset($LEM->surveyOptions['hyperlinkSyntaxHighlighting']) ? $LEM->surveyOptions['hyperlinkSyntaxHighlighting'] : false,
$LEM->surveyMode
);
$LEM->groupRelevanceInfo = array();
if (!is_null($groupNum))
Expand Down Expand Up @@ -4838,7 +4840,7 @@ static function GetRelevanceAndTailoringJavaScript()
{
$jsParts[] = "var LEMgid=" . $LEM->groupNum . ";\n"; // current group num so can compute isOnCurrentPage
}
if ($LEM->surveyMode == 'question')
if ($LEM->surveyMode == 'question' && isset($LEM->currentQID))
{
$jsParts[] = "var LEMqid=" . $LEM->currentQID . ";\n"; // current group num so can compute isOnCurrentPage
}
Expand Down Expand Up @@ -5239,6 +5241,10 @@ static function GetRelevanceAndTailoringJavaScript()
}
}
$qrelQIDs = array_unique($qrelQIDs);
if ($LEM->surveyMode=='question')
{
$qrelQIDs=array(); // in question-by-questin mode, should never test for dependencies on self or other questions.
}

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

0 comments on commit 1906014

Please sign in to comment.