Skip to content

Commit

Permalink
Merge pull request #63 from trougakoss/Yii
Browse files Browse the repository at this point in the history
Fixed issue #7000: Fixed sorting of questions in export_statistics in re...
  • Loading branch information
trougakoss committed Dec 27, 2012
2 parents 70478fa + 5685893 commit c64dd94
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions application/controllers/admin/remotecontrol.php
Expand Up @@ -603,6 +603,7 @@ public function activate_survey($sSessionKey, $iSurveyID)
public function export_statistics($sSessionKey, $iSurveyID, $docType='pdf', $sLanguage=null, $graph='0', $groupIDs=null)
{
Yii::app()->loadHelper('admin/statistics');

$tempdir = Yii::app()->getConfig("tempdir");
if (!$this->_checkSessionKey($sSessionKey)) return array('status' => 'Invalid session key');

Expand All @@ -617,6 +618,10 @@ public function export_statistics($sSessionKey, $iSurveyID, $docType='pdf', $sL
if (is_null($sLanguage)|| !in_array($sLanguage,$aAdditionalLanguages))
$sLanguage = $oSurvey->language;

$oAllQuestions =Questions::model()->getQuestionList($iSurveyID, $sLanguage);
if (!isset($oAllQuestions))
return array('status' => 'No available data');

if($groupIDs!=null)
{
if(is_int($groupIDs))
Expand All @@ -634,24 +639,22 @@ public function export_statistics($sSessionKey, $iSurveyID, $docType='pdf', $sL

if (empty($groupIDs))
return array('status' => 'Error: Invalid group ID');

//and then get all the questions for these groups
$criteria = new CDbCriteria;
$criteria->addInCondition('gid', $groupIDs);
$criteria->addCondition('sid = '.$iSurveyID);
$criteria->addCondition('parent_qid = 0');
$criteria->addCondition('language = :lang');
$criteria->params[':lang'] = $sLanguage;
$oAllQuestions = Questions::model()->findAll($criteria);

foreach($oAllQuestions as $key => $aQuestion)
{
if(!in_array($aQuestion['gid'],$groupIDs))
unset($oAllQuestions[$key]);
}
}
else
return array('status' => 'Error: Invalid group ID');

}
else
$oAllQuestions = Questions::model()->findAllByAttributes(array('sid' => $iSurveyID, 'parent_qid'=>'0','language'=>$sLanguage));

usort($oAllQuestions, 'groupOrderThenQuestionOrder');
}

if (!isset($oAllQuestions))
return array('status' => 'No available data');

usort($oAllQuestions, 'groupOrderThenQuestionOrder');

$aSummary = createCompleteSGQA($iSurveyID,$oAllQuestions,$sLanguage);

$helper = new statistics_helper();
Expand Down

0 comments on commit c64dd94

Please sign in to comment.