Skip to content

Commit

Permalink
Dev Fixed issue with importing subquestion translations.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Jul 3, 2015
1 parent b234943 commit 7cc4a78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion application/controllers/QuestionsController.php
Expand Up @@ -174,9 +174,13 @@ public function actionDelete($id)
* @return \Question
*/
protected function loadModel($id) {
return \Question::model()->findByAttributes([
$result = \Question::model()->findByAttributes([
'qid' => $id
]);
if (!isset($result)) {
throw new \CHttpException(404, gT("Question not found."));
}
return $result;
}
}

5 changes: 3 additions & 2 deletions application/helpers/import/BaseElementXmlImport.php
Expand Up @@ -75,7 +75,8 @@ protected function constructQuestion($question, $language, $data)
{

// Add translations.
foreach ($data['questions']['rows'] as $translatedQuestion) {
$questions = isset($data['subquestions']) ? array_merge($data['subquestions']['rows'], $data['questions']['rows']) : $data['questions']['rows'];
foreach ($questions as $translatedQuestion) {
if ($translatedQuestion['qid'] == $question['qid']
&& $translatedQuestion['language'] != $language
) {
Expand All @@ -85,7 +86,7 @@ protected function constructQuestion($question, $language, $data)

// Add subquestions
foreach (isset($data['subquestions']) ? $data['subquestions']['rows'] : [] as $subQuestion) {
if ($subQuestion['parent_qid'] == $question['qid']) {
if ($subQuestion['parent_qid'] == $question['qid'] && $subQuestion['language'] == $language) {
$question['subquestions'][] = $this->constructQuestion($subQuestion, $language, $data);
}
}
Expand Down

0 comments on commit 7cc4a78

Please sign in to comment.