Skip to content

Commit

Permalink
Fixed issue: Subquestions and attributes were not properly copied whe…
Browse files Browse the repository at this point in the history
…n copying question
  • Loading branch information
c-schmitz committed Jul 26, 2012
1 parent be5fced commit e31ce9a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
22 changes: 10 additions & 12 deletions application/controllers/admin/database.php
Expand Up @@ -475,7 +475,7 @@ function index($sa = null)
if (returnGlobal('copysubquestions') == "Y")
{
$aSQIDMappings = array();
$r1 = Questions::getSubQuestions(returnGlobal('oldqid'));
$r1 = Questions::model()->getSubQuestions(returnGlobal('oldqid'));

while ($qr1 = $r1->read())
{
Expand All @@ -488,19 +488,19 @@ function index($sa = null)
unset($qr1['qid']);
}
$qr1['gid'] = $postgid;
$ir1 = Questions::insertRecords($qr1);
$iInsertID = Questions::model()->insertRecords($qr1);
if (!isset($qr1['qid']))
{
$aSQIDMappings[$oldqid] = Yii::app()->db->getLastInsertID('qid');
$aSQIDMappings[$oldqid] = $iInsertID;
}
}
}
if (returnGlobal('copyanswers') == "Y")
{
$r1 = Answers::getAnswers(returnGlobal('oldqid'));
$r1 = Answers::model()->getAnswers(returnGlobal('oldqid'));
while ($qr1 = $r1->read())
{
Answers::insertRecords(array(
Answers::model()->insertRecords(array(
'qid' => $qid,
'code' => $qr1['code'],
'answer' => $qr1['answer'],
Expand All @@ -512,14 +512,12 @@ function index($sa = null)
}
if (returnGlobal('copyattributes') == "Y")
{
$r1 = Question_attributes::getQuestionAttributes(returnGlobal('oldqid'));
$r1 = Question_attributes::model()->getQuestionAttributes(returnGlobal('oldqid'));
while($qr1 = $r1->read())
{
Question_attributes::insertRecords(array(
'qid' => $qid,
'attribute' => $qr1['attribute'],
'value' => $qr1['value']
));
$qr1['qid']=$qid;
unset($qr1['qaid']);
Question_attributes::model()->insertRecords($qr1);
}
}
} else {
Expand All @@ -535,7 +533,7 @@ function index($sa = null)
'attribute' => $validAttribute['name']
);

Question_attributes::insertRecords($data);
Question_attributes::model()->insertRecords($data);

}
}
Expand Down
4 changes: 2 additions & 2 deletions application/models/Question_attributes.php
Expand Up @@ -55,7 +55,7 @@ function getQuestionAttributes($qid)
{
return Yii::app()->db->createCommand()
->select()
->from(self::tableName())
->from($this->tableName())
->where(array('and', 'qid=:qid'))->bindParam(":qid", $qid, PDO::PARAM_STR)
->order('qaid asc')
->query();
Expand All @@ -73,7 +73,7 @@ public function getQuestionsForStatistics($fields, $condition, $orderby=FALSE)
{
$command = Yii::app()->db->createCommand()
->select($fields)
->from(self::tableName())
->from($this->tableName())
->where($condition);
if ($orderby != FALSE)
{
Expand Down
4 changes: 2 additions & 2 deletions application/models/Questions.php
Expand Up @@ -189,8 +189,8 @@ function getSubQuestions($parent_qid)
return Yii::app()->db->createCommand()
->select()
->from(self::tableName())
->where(array('and', 'parent_qid=:parent_qid'))
->bindParam(":parent_qid", $qid, PDO::PARAM_INT)
->where('parent_qid=:parent_qid')
->bindParam(":parent_qid", $parent_qid, PDO::PARAM_INT)
->order('question_order asc')
->query();
}
Expand Down

0 comments on commit e31ce9a

Please sign in to comment.