Skip to content

Commit

Permalink
Dev EM-based validation and navigation sub-system:
Browse files Browse the repository at this point in the history
Dev Survey (All-in-one) mode now 99% functional. Works perfectly with EM debug level = 3, but not for lesser debug levels

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev_tms@11569 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Dec 3, 2011
1 parent 6fb9e27 commit 95fe84d
Show file tree
Hide file tree
Showing 5 changed files with 190 additions and 138 deletions.
2 changes: 1 addition & 1 deletion classes/eval/ExpressionManager.php
Expand Up @@ -1374,7 +1374,7 @@ public function GetPrettyPrintString()
}

$stringParts[] = "<span title='" . implode('; ',$messages) . "' style='color: ". $color . "; font-weight: bold'";
if ($this->hyperlinkSyntaxHighlighting) {
if ($this->hyperlinkSyntaxHighlighting && isset($gid) && isset($qid)) {
// Modify this link to utilize a different framework
$editlink = $this->rooturl . '/admin/admin.php?sid=' . $this->sid . '&gid=' . $gid . '&qid=' . $qid;
$stringParts[] = " onclick='window.open(\"" . $editlink . "\");'";
Expand Down
103 changes: 38 additions & 65 deletions classes/eval/LimeExpressionManager.php
Expand Up @@ -1981,42 +1981,7 @@ static function NavigateBackwards()
switch ($LEM->surveyMode)
{
case 'survey':
$LEM->StartProcessingPage(true);
/* What is right way to check validity after a submit?
if ($LEM->currentGroupSeq != -1) {
// then a repeated showing of survey
if (!$force)
{
$result = $LEM->_ValidateSurvey($debug);
if ($result['mandViolation'] || !$result['valid'])
{
// redisplay the current group
}
}
// have submitted the survey
return array(
'finished'=>true,
'message'=>$result['message'],
);
}
*/

$LEM->currentQset = array(); // reset active list of questions
$result = $LEM->_ValidateSurvey();
if (!$result['relevant'] || $result['hidden'])
{
// then there are no relevant, visible questions in the survey
}
else
{
// display the survey
$LEM->runtimeTimings[] = array(__METHOD__,(microtime(true) - $now));
return array(
'finished'=>true,
'message'=>$result['message'],
);
}
// should never be called?
break;
case 'group':
// First validate the current group
Expand Down Expand Up @@ -2142,42 +2107,35 @@ static function NavigateForwards($force=false) {
switch ($LEM->surveyMode)
{
case 'survey':
$startingGroup = $LEM->currentGroupSeq;
$LEM->StartProcessingPage(true);
/* What is right way to check validity after a submit?
if ($LEM->currentGroupSeq != -1) {
// then a repeated showing of survey
if (!$force)
{
$result = $LEM->_ValidateSurvey($debug);
if ($result['mandViolation'] || !$result['valid'])
{
// redisplay the current group
}
}
// have submitted the survey
return array(
'finished'=>true,
'message'=>$result['message'],
);
}
*/
$updatedValues=$LEM->ProcessCurrentResponses();
$message = '';

$LEM->currentQset = array(); // reset active list of questions
$result = $LEM->_ValidateSurvey();
if (!$result['relevant'] || $result['hidden'])
$message .= $result['message'];
$updatedValues = array_merge($updatedValues,$result['updatedValues']);
if (!$force && !is_null($result) && ($result['mandViolation'] || !$result['valid'] || $startingGroup == -1))
{
// then there are no relevant, visible questions in the survey
$finished=false;
}
else
{
// display the survey
$LEM->runtimeTimings[] = array(__METHOD__,(microtime(true) - $now));
return array(
'finished'=>true,
'message'=>$result['message'],
);
$finished = true;
}
$message .= $LEM->_UpdateValuesInDatabase($updatedValues,$finished);
$LEM->runtimeTimings[] = array(__METHOD__,(microtime(true) - $now));
return array(
'finished'=>$finished,
'message'=>$message,
'gseq'=>1,
'seq'=>1,
'mandViolation'=>$result['mandViolation'],
'valid'=>$result['valid'],
'unansweredSQs'=>$result['unansweredSQs'],
'invalidSQs'=>$result['invalidSQs'],
);
break;
case 'group':
// First validate the current group
Expand Down Expand Up @@ -2645,7 +2603,7 @@ static function JumpTo($seq,$force=false,$preview=false) {
}
}

function _ValidateSurvey()
private function _ValidateSurvey()
{
$LEM =& $this;

Expand All @@ -2654,6 +2612,9 @@ function _ValidateSurvey()
$shidden=true;
$smandViolation=false;
$svalid=true;
$unansweredSQs = array();
$invalidSQs = array();
$updatedValues = array();

for ($i=0;$i<$LEM->numGroups;++$i) {
$LEM->currentGroupSeq=$i;
Expand All @@ -2673,7 +2634,15 @@ function _ValidateSurvey()
$svalid=false;
}

// TODO - Note, this is needed to generate proper JavaScript - will this prevent tailoring of questions and answers since it closes the group?
if (strlen($gStatus['unansweredSQs']) > 0) {
$unansweredSQs = array_merge($unansweredSQs, explode('|',$gStatus['unansweredSQs']));
}
if (strlen($gStatus['invalidSQs']) > 0) {
$invalidSQs = array_merge($invalidSQs, explode('|',$gStatus['invalidSQs']));
}
$updatedValues = array_merge($updatedValues, $gStatus['updatedValues']);
$LEM->currentQset = array_merge($LEM->currentQset, $gStatus['qset']);

$LEM->FinishProcessingGroup();
}
return array(
Expand All @@ -2682,6 +2651,10 @@ function _ValidateSurvey()
'mandViolation' => $smandViolation,
'valid' => $svalid,
'message' => $message,
'unansweredSQs' => implode('|',$unansweredSQs),
'invalidSQs' => implode('|',$invalidSQs),
'updatedValues' => $updatedValues,
'seq'=>1,
);
}

Expand Down
2 changes: 1 addition & 1 deletion classes/eval/test/navigation_test.php
Expand Up @@ -39,7 +39,7 @@
{
print '<h3>Starting survey ' . $surveyid . "</h3>";
$now = microtime(true);
LimeExpressionManager::StartSurvey($surveyid, 'group', $surveyOptions, true,$LEMdebugLevel);
LimeExpressionManager::StartSurvey($surveyid, 'survey', $surveyOptions, true,$LEMdebugLevel);
print '<b>[StartSurvey() took ' . (microtime(true) - $now) . ' seconds]</b><br/>';

while(true) {
Expand Down

0 comments on commit 95fe84d

Please sign in to comment.