Skip to content

Commit

Permalink
Dev: Re-fix issue #09828 : adding subquestion multiple times update m…
Browse files Browse the repository at this point in the history
…ax_subquestions

Dev: Adding attribute only if not exist
Dev: related d09e6d4#diff-4c8b6e0396ccd2f7fad4f57489b63b06L156 and #507
  • Loading branch information
Shnoulle committed Aug 23, 2017
1 parent c7553b4 commit 9cbb9ba
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions application/controllers/admin/database.php
Expand Up @@ -152,17 +152,18 @@ function index($sa = null)
/* @todo : add it to upgrage DB system, and see for the lsa */
if($sQuestionType=="R" && Survey::model()->findByPk($iSurveyID)->active=="Y")
{
QuestionAttribute::model()->find(
$oQuestionAttributeMaxSubQuestions = QuestionAttribute::model()->find(
"qid = :qid AND attribute = 'max_subquestions'",
array(':qid' => $iQuestionID)
);

$answerCount=Answer::model()->countByAttributes(array('qid' => $iQuestionID,'language'=>Survey::model()->findByPk($iSurveyID)->language));
$oQuestionAttribute = new QuestionAttribute();
$oQuestionAttribute->qid = $iQuestionID;
$oQuestionAttribute->attribute = 'max_subquestions';
$oQuestionAttribute->value = $answerCount;
$oQuestionAttribute->save();
if(!$oQuestionAttributeMaxSubQuestions) {
$answerCount=Answer::model()->countByAttributes(array('qid' => $iQuestionID,'language'=>Survey::model()->findByPk($iSurveyID)->language));
$oQuestionAttributeMaxSubQuestions = new QuestionAttribute();
$oQuestionAttributeMaxSubQuestions->qid = $iQuestionID;
$oQuestionAttributeMaxSubQuestions->attribute = 'max_subquestions';
$oQuestionAttributeMaxSubQuestions->value = $answerCount;
$oQuestionAttributeMaxSubQuestions->save();
}

}

Expand Down

0 comments on commit 9cbb9ba

Please sign in to comment.