Skip to content

Commit

Permalink
Dev: revert broken fix for 13684
Browse files Browse the repository at this point in the history
Fixed issue #16203: Multiple choice questions with "other" with "exclusive" unable to submit
Fixed issue #16226: Invalid count on multi with exclude : broke logic and php vs js diff
Dev: revert 30a85bb
Dev: previous system have more issue than fix : order dependent
Dev: set sub-question with relevance to  `0` to relevant (and to `N` value)
Dev: didn't set previous data to same data
  • Loading branch information
Shnoulle committed May 7, 2020
1 parent daefb50 commit fd0dcf5
Showing 1 changed file with 4 additions and 55 deletions.
59 changes: 4 additions & 55 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -6507,55 +6507,15 @@ function ($sqRankAnwsers) {
$_SESSION[$LEM->sessid]['relevanceStatus'][$sq['rowdivid']]=false;
}
}
case Question::QT_M_MULTIPLE_CHOICE: //Multiple choice checkbox
case Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS: //Multiple choice with comments checkbox + text
if ($sgqa == $sq['rowdivid'] || $sgqa == ($sq['rowdivid'] . 'comment')) // to catch case 'P'
{
$foundSQrelevance = true;
if (isset($LEM->ParseResultCache[$sq['eqn']])) {
$sqrel = $LEM->ParseResultCache[$sq['eqn']]['result'];
if (($LEM->debugLevel & LEM_PRETTY_PRINT_ALL_SYNTAX) == LEM_PRETTY_PRINT_ALL_SYNTAX) {
$prettyPrintSQRelEqns[$sq['rowdivid']] = $LEM->ParseResultCache[$sq['eqn']]['prettyprint'];
}
} else {
// check if the exclusive option is checked and set relevance to true
if (isset($_SESSION[$this->sessid][$qInfo['rowdivid']]) && $_SESSION[$this->sessid][$qInfo['rowdivid']] == "Y") {
$sqrel = true;
} else {
$stringToParse = htmlspecialchars_decode($sq['eqn'], ENT_QUOTES); // TODO is this needed?
$sqrel = $LEM->em->ProcessBooleanExpression($stringToParse, $qInfo['gseq'], $qInfo['qseq']);
}

$hasErrors = $LEM->em->HasErrors();
// make sure subquestions with errors in relevance equations are always shown and answers recorded #7703
if ($hasErrors) {
$sqrel = true;
}
if (($LEM->debugLevel & LEM_PRETTY_PRINT_ALL_SYNTAX) == LEM_PRETTY_PRINT_ALL_SYNTAX) {
$prettyPrintSQRelEqn = $LEM->em->GetPrettyPrintString();
$prettyPrintSQRelEqns[$sq['rowdivid']] = $prettyPrintSQRelEqn;
}
$LEM->ParseResultCache[$sq['eqn']] = array(
'result' => $sqrel,
'prettyprint' => $prettyPrintSQRelEqn,
'hasErrors' => $hasErrors,
);
}
if ($sqrel) {
$relevantSQs[] = $sgqa;
$_SESSION[$LEM->sessid]['relevanceStatus'][$sq['rowdivid']] = true;
} else {
$irrelevantSQs[] = $sgqa;
$_SESSION[$LEM->sessid]['relevanceStatus'][$sq['rowdivid']] = false;
}
}
break;
// Note, for M and P, Mandatory should mean that at least one answer was picked - not that all were checked
// No break : next part is for array text and array number too
case Question::QT_A_ARRAY_5_CHOICE_QUESTIONS: //ARRAY (5 POINT CHOICE) radio-buttons
case Question::QT_B_ARRAY_10_CHOICE_QUESTIONS: //ARRAY (10 POINT CHOICE) radio-buttons
case Question::QT_C_ARRAY_YES_UNCERTAIN_NO: //ARRAY (YES/UNCERTAIN/NO) radio-buttons
case Question::QT_E_ARRAY_OF_INC_SAME_DEC_QUESTIONS: //ARRAY (Increase/Same/Decrease) radio-buttons
case Question::QT_F_ARRAY_FLEXIBLE_ROW: //ARRAY (Flexible) - Row Format
case Question::QT_M_MULTIPLE_CHOICE: //Multiple choice checkbox
case Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS: //Multiple choice with comments checkbox + text
// Note, for M and P, Mandatory should mean that at least one answer was picked - not that all were checked
case Question::QT_K_MULTIPLE_NUMERICAL_QUESTION: //MULTIPLE NUMERICAL QUESTION
case Question::QT_Q_MULTIPLE_SHORT_TEXT: //MULTIPLE SHORT TEXT
if ($sgqa == $sq['rowdivid'] || $sgqa == ($sq['rowdivid'] . 'comment')) // to catch case 'P'
Expand Down Expand Up @@ -9105,7 +9065,6 @@ public static function ProcessCurrentResponses()
{
$value = (isset($_POST[$sq]) ? $_POST[$sq] : '');
}

// Check for and adjust ',' and '.' in numbers
$isOnlyNum = isset($LEM->knownVars[$sq]['onlynum']) && $LEM->knownVars[$sq]['onlynum']=='1';
if ($radixchange && $isOnlyNum) {
Expand Down Expand Up @@ -9205,16 +9164,6 @@ public static function ProcessCurrentResponses()
'type'=>$type,
'value'=>NULL,
);
// set irrelevant value for Question M and P to 'N', will be validated in _validateQuestion
if ($type == Question::QT_M_MULTIPLE_CHOICE || $type == Question::QT_P_MULTIPLE_CHOICE_WITH_COMMENTS) {
$value = 'N';
// Add the string in $_SESSION to be shown and see if we need to reset value
if (!self::checkValidityAnswer($type, $value, $sq, $qinfo['info'])) {
$value = NULL;
}
$_SESSION[$LEM->sessid][$sq] = $value;
$_update['value'] = $value;
}
$updatedValues[$sq] = $_update;
$LEM->updatedValues[$sq] = $_update;
}
Expand Down

0 comments on commit fd0dcf5

Please sign in to comment.