diff --git a/application/controllers/GroupsController.php b/application/controllers/GroupsController.php index 68182302499..9b86e5eea18 100644 --- a/application/controllers/GroupsController.php +++ b/application/controllers/GroupsController.php @@ -49,12 +49,13 @@ public function actionCreate($surveyId) { $group->sid = $survey->primaryKey; if (App()->request->isPostRequest) { $group->setAttributes(App()->request->getPost('QuestionGroup')); + if ($group->save()) { - $this->redirect(['groups/update', 'id' => $group->primaryKey]); + return $this->redirect(['groups/update', 'id' => $group->primaryKey]); } } else { - $lastTitle = ([] != $values = array_values($group->survey->groups)) ? $values[count($group->survey->groups) - 1]->group_name : "q0"; + $lastTitle = ([] != $values = array_values($group->survey->groups)) ? $values[count($group->survey->groups) - 1]->group_name : "g0"; if (isset($lastTitle) && preg_match('/^(.*?)(\d+)$/', $lastTitle, $matches)) { $group->group_name = $matches[1] . ($matches[2] + 1); } diff --git a/application/helpers/globals.php b/application/helpers/globals.php index e6f668f2f6c..5a57c2d82df 100644 --- a/application/helpers/globals.php +++ b/application/helpers/globals.php @@ -8,7 +8,7 @@ /** * Helper function to replace calls to Yii::app() and enable correct code completion. - * @return LSYii_Application + * @return WebApplication */ function App() { diff --git a/application/models/QuestionGroup.php b/application/models/QuestionGroup.php index 927d829bc2b..712d32927c9 100644 --- a/application/models/QuestionGroup.php +++ b/application/models/QuestionGroup.php @@ -75,23 +75,6 @@ public function getQuestionCount() { return Question::model()->countByAttributes(['gid' => $this->id, 'parent_qid' => 0]); } - function getAllRecords($condition=FALSE, $order=FALSE, $return_query = TRUE) - { - $query = Yii::app()->db->createCommand()->select('*')->from('{{groups}}'); - - if ($condition != FALSE) - { - $query->where($condition); - } - - if($order != FALSE) - { - $query->order($order); - } - - return ( $return_query ) ? $query->queryAll() : $query; - } - function updateGroupOrder($sid,$lang,$position=0) { $data=Yii::app()->db->createCommand()->select('gid') @@ -159,16 +142,7 @@ private static function getQuestionIdsInGroup($groupId) { return $questionIds; } - function getAllGroups($condition, $order=false) - { - $command = Yii::app()->db->createCommand()->where($condition)->select('*')->from($this->tableName()); - if ($order != FALSE) - { - $command->order($order); - } - return $command->query(); - } - + /** * This function is here to support proper naming of entity attributes. * Since surveys have a title, I have decided all non-person entities have a title not a name.