Skip to content

Commit

Permalink
Fixed issue #16521: After updating an answer option, the related cond…
Browse files Browse the repository at this point in the history
…ition doesn't get updated

Updated dependant conditions when an answer's code is updated.
  • Loading branch information
gabrieljenik authored and eddylackmann committed Jul 30, 2020
1 parent 4df49e4 commit cdc1ddf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions application/controllers/QuestionEditorController.php
Expand Up @@ -1255,6 +1255,7 @@ private function storeAnswerOptions(&$oQuestion, $dataSet, $isCopyProcess = fals
"Answer option code cannot be empty"
);
}
$sOldCode = $oAnswer->code;
$oAnswer->setAttributes($aAnswerOptionDataSet);
$answerSaved = $oAnswer->save();
if (!$answerSaved) {
Expand All @@ -1264,9 +1265,26 @@ private function storeAnswerOptions(&$oQuestion, $dataSet, $isCopyProcess = fals
. print_r($oAnswer->getErrors(), true)
);
}
// Updating code => update condition with the new code
if (isset($sOldCode) && $oAnswer->code !== $sOldCode) {
Condition::model()->updateAll(
array(
'value' => $oAnswer->code
),
'cqid=:cqid AND value=:value',
array(
':cqid' => $oAnswer->qid,
':value' => $sOldCode
)
);
}
$this->applyAnswerI10N($oAnswer, $oQuestion, $aAnswerOptionDataSet);
}
}

LimeExpressionManager::SetDirtyFlag();
LimeExpressionManager::UpgradeConditionsToRelevance($oQuestion->sid);

return true;
}

Expand Down

0 comments on commit cdc1ddf

Please sign in to comment.