Skip to content

Commit

Permalink
Dev: refix #09285 2 : condition : go after, do to : broke
Browse files Browse the repository at this point in the history
Dev: Adding $_SESSION[$LEM->sessid][$answer]=null in _validateQuestion , this ensure using $_SESSION[$LEM->sessid][$answer]
Dev: then remove the quick fix at qanda_helper only for $ia[1] (without sub question)
Dev: remove global $notanswered at each do_ function, get it by GetLastMoveResult
  • Loading branch information
Shnoulle committed Nov 10, 2014
1 parent be98370 commit 3f5fbf7
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 86 deletions.
5 changes: 2 additions & 3 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -387,16 +387,15 @@ function run($surveyid,$args) {
$LEMskipReprocessing=true;
}
}

if (isset($moveResult) && isset($moveResult['seq']) )// Reload at first page (welcome after click previous fill an empty $moveResult array
{
// With complete index, we need to revalidate whole group bug #08806. It's actually the only mode where we JumpTo with force
if($moveResult['finished'] == true && $thissurvey['questionindex']==2)// $thissurvey['questionindex']>=2
{
//LimeExpressionManager::JumpTo(-1, false, false, true);
LimeExpressionManager::StartSurvey($surveyid, $surveyMode, $surveyOptions);
$moveResult = LimeExpressionManager::JumpTo($moveResult['seq'], false, false, false);// no preview, no save data and NO force
if(!$moveResult['mandViolation'] && !$moveResult['valid'] && !$moveResult['invalidSQs'])
$moveResult = LimeExpressionManager::JumpTo($_SESSION[$LEMsessid]['totalsteps']+1, false, false, false);// no preview, no save data and NO force
if(!$moveResult['mandViolation'] && $moveResult['valid'] && empty($moveResult['invalidSQs']))
$moveResult['finished'] = true;
}
if ($moveResult['finished'] == true)
Expand Down
24 changes: 15 additions & 9 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -5910,7 +5910,12 @@ function _ValidateQuestion($questionSeq,$force=false)

$gRelInfo = $LEM->gRelInfo[$qInfo['gseq']];
$grel = $gRelInfo['result'];

//Allways set a $_SESSION
$allSQs = explode('|', $LEM->qid2code[$qid]);
foreach($allSQs as $answer){
if(!isset($_SESSION[$LEM->sessid][$answer]))
$_SESSION[$LEM->sessid][$answer]=null;
}
///////////////////////////
// IS QUESTION RELEVANT? //
///////////////////////////
Expand Down Expand Up @@ -5963,6 +5968,7 @@ function _ValidateQuestion($questionSeq,$force=false)
$prettyPrintSQRelEqn='';
$prettyPrintValidTip='';
$anyUnanswered = false;

if (!$qrel)
{
// All sub-questions are irrelevant
Expand Down Expand Up @@ -6217,7 +6223,7 @@ function _ValidateQuestion($questionSeq,$force=false)
//////////////////////////////////////////////
$qmandViolation = false; // assume there is no mandatory violation until discover otherwise
$mandatoryTip = '';
if (!$force && $qrel && !$qhidden && ($qInfo['mandatory'] == 'Y'))
if ($qrel && !$qhidden && ($qInfo['mandatory'] == 'Y'))
{
$mandatoryTip = "<strong><br /><span class='errormandatory'>".$LEM->gT('This question is mandatory').'. ';
switch ($qInfo['type'])
Expand Down Expand Up @@ -6361,6 +6367,7 @@ function _ValidateQuestion($questionSeq,$force=false)
break;
}
}

///////////////////////////////////////////////
// DETECT ANY VIOLATIONS OF VALIDATION RULES //
///////////////////////////////////////////////
Expand All @@ -6370,7 +6377,7 @@ function _ValidateQuestion($questionSeq,$force=false)
$validationEqn='';
$validationJS=''; // assume can't generate JavaScript to validate equation
$validTip=''; // default is none
if (!$force && isset($LEM->qid2validationEqn[$qid]))
if (isset($LEM->qid2validationEqn[$qid]))
{
$hasValidationEqn=true;
if (!$qhidden) // do this even is starts irrelevant, else will never show this information.
Expand Down Expand Up @@ -6415,11 +6422,11 @@ function _ValidateQuestion($questionSeq,$force=false)
}
}
}

if (!$qvalid)
{
$invalidSQs = $LEM->qid2code[$qid]; // TODO - currently invalidates all - should only invalidate those that truly fail validation rules.
}

/////////////////////////////////////////////////////////
// OPTIONALLY DISPLAY (DETAILED) DEBUGGING INFORMATION //
/////////////////////////////////////////////////////////
Expand Down Expand Up @@ -6579,19 +6586,19 @@ function _ValidateQuestion($questionSeq,$force=false)
'relEqn' => $prettyPrintRelEqn,
'sgqa' => $LEM->qid2code[$qid],
'unansweredSQs' => implode('|',$unansweredSQs),
'valid' => $qvalid,
'valid' => $force || $qvalid,
'validEqn' => $validationEqn,
'prettyValidEqn' => $prettyPrintValidEqn,
'validTip' => $validTip,
'prettyValidTip' => $prettyPrintValidTip,
'validJS' => $validationJS,
'invalidSQs' => (isset($invalidSQs) ? $invalidSQs : ''),
'invalidSQs' => (isset($invalidSQs) && !$force) ? $invalidSQs : '',
'relevantSQs' => implode('|',$relevantSQs),
'irrelevantSQs' => implode('|',$irrelevantSQs),
'subQrelEqn' => implode('<br />',$prettyPrintSQRelEqns),
'mandViolation' => $qmandViolation,
'mandViolation' => (!$force) ? $qmandViolation : false,
'anyUnanswered' => $anyUnanswered,
'mandTip' => $mandatoryTip,
'mandTip' => (!$force) ? $mandatoryTip : '',
'message' => $debug_qmessage,
'updatedValues' => $updatedValues,
'sumEqn' => (isset($sumEqn) ? $sumEqn : ''),
Expand Down Expand Up @@ -6623,7 +6630,6 @@ function _ValidateQuestion($questionSeq,$force=false)
'mandViolation' => $qmandViolation,
'valid' => $qvalid,
);

$_SESSION[$LEM->sessid]['relevanceStatus'][$qid] = $qrel;
return $qStatus;
}
Expand Down

0 comments on commit 3f5fbf7

Please sign in to comment.