Skip to content

Commit

Permalink
Bug/19160 v5 subquestion save (#3546)
Browse files Browse the repository at this point in the history
* 'Fixed issue #19160 - subquestion save, code can be duplicate between scales

* dev: refactor QuestionAdministrationController::storeSubquestions

* Fixed issue #19160 - delete removed subquestions
  • Loading branch information
kevin-foster-uk committed Oct 17, 2023
1 parent 963a619 commit 132e6f6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions application/controllers/QuestionAdministrationController.php
Expand Up @@ -2832,6 +2832,7 @@ private function storeSubquestions($question, $subquestionsArray)
private function updateSubquestions($question, $subquestionsArray)
{
$questionOrder = 0;
$subquestionIds = [];
foreach ($subquestionsArray as $subquestionId => $subquestionArray) {
foreach ($subquestionArray as $scaleId => $data) {
$subquestion = Question::model()->findByAttributes(
Expand Down Expand Up @@ -2865,6 +2866,7 @@ private function updateSubquestions($question, $subquestionsArray)
->setDetailedErrorsFromModel($subquestion);
}
$subquestion->refresh();
$subquestionIds[] = $subquestion->qid;
foreach ($data['subquestionl10n'] as $lang => $questionText) {
$l10n = QuestionL10n::model()->findByAttributes(
[
Expand All @@ -2885,6 +2887,7 @@ private function updateSubquestions($question, $subquestionsArray)
}
}
}
$question->deleteAllSubquestions($subquestionIds);
}

/**
Expand Down

0 comments on commit 132e6f6

Please sign in to comment.