Skip to content

Commit

Permalink
Fixed issue #13235: Copying Array question results in error
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schmitz committed Jan 24, 2018
1 parent 823015e commit f029d3a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions application/controllers/admin/database.php
Expand Up @@ -1302,18 +1302,20 @@ private function actionInsertCopyQuestion($iSurveyID)
if (returnGlobal('copysubquestions') == 1 && isset($oOldQuestion)) {
$aSQIDMappings = [];
foreach ($oOldQuestion->subquestions as $qr1) {
$qr1->parent_qid = $this->iQuestionID;
$arQuestion=new Question();
$arQuestion->attributes=$qr1->attributes;
$arQuestion->parent_qid = $this->iQuestionID;
$oldqid = '';
if (isset($aSQIDMappings[$qr1->qid])) {
$qr1->qid = $aSQIDMappings[$qr1->qid];
$arQuestion->qid = $aSQIDMappings[$qr1->qid];
} else {
$oldqid = $qr1->qid;
$qr1->qid = null;
$arQuestion->qid = null;
}

$qr1->gid = $this->iQuestionGroupID;
if ($qr1->save()) {
$aSQIDMappings[$oldqid] = $qr1->gid;
$arQuestion->gid = $this->iQuestionGroupID;
if ($arQuestion->save()) {
$aSQIDMappings[$oldqid] = $arQuestion->gid;
}
}
}
Expand Down

0 comments on commit f029d3a

Please sign in to comment.