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_dev@12408 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
tmswhite committed Feb 8, 2012
1 parent 2b2d541 commit 99684d3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
51 changes: 38 additions & 13 deletions classes/eval/ExpressionManager.php
Expand Up @@ -47,7 +47,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 @@ -1083,23 +1083,37 @@ 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 @@ -1661,11 +1675,22 @@ 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->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.
// return (isset($var['jsName_on']) ? $var['jsName_on'] : (isset($var['jsName'])) ? $var['jsName'] : $default);
// }
// return (isset($var['jsName']) ? $var['jsName'] : $default);
//
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 @@ -1927,11 +1952,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=false,$allOnOnePage=false)
public function StartProcessingGroup($sid=NULL,$rooturl='',$hyperlinkSyntaxHighlighting=false,$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->rooturl=$rooturl;
$this->hyperlinkSyntaxHighlighting=$hyperlinkSyntaxHighlighting;
Expand Down
9 changes: 7 additions & 2 deletions classes/eval/LimeExpressionManager.php
Expand Up @@ -4664,7 +4664,8 @@ static function StartProcessingGroup($groupNum=NULL,$anonymized=false,$surveyid=
$LEM->em->StartProcessingGroup(
isset($surveyid) ? $surveyid : NULL,
isset($LEM->surveyOptions['rooturl']) ? $LEM->surveyOptions['rooturl'] : '',
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 @@ -4820,7 +4821,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 @@ -5221,6 +5222,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 99684d3

Please sign in to comment.