Skip to content

Commit

Permalink
Fixed issue #6984
Browse files Browse the repository at this point in the history
  • Loading branch information
SamMousa committed Jun 16, 2015
1 parent 4b139bb commit 4978c6e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 30 deletions.
5 changes: 3 additions & 2 deletions application/controllers/GroupsController.php
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/globals.php
Expand Up @@ -8,7 +8,7 @@

/**
* Helper function to replace calls to Yii::app() and enable correct code completion.
* @return LSYii_Application
* @return WebApplication
*/
function App()
{
Expand Down
28 changes: 1 addition & 27 deletions application/models/QuestionGroup.php
Expand Up @@ -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')
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4978c6e

Please sign in to comment.