Skip to content

Commit

Permalink
DEV: Survey TODO remove (#768)
Browse files Browse the repository at this point in the history
Fixed issue #12394: Adding question to quota shoult order questions in display order
Dev: add quoteColumnName for order
Dev: Put the grouping criteria in separate method (reusable)
Dev: Survey TODO remove survey $full_answers_count (UNUSED)
Dev: Survey TODO remove survey $partial_answers_count (UNUSED)
Dev: Survey TODO remove $pac & $fac, use countFullAnswers & countPartialAnswers
Dev: use QueryBuilder for query
Dev: fix fixSurveyAttribute param
Dev: fix missing $upload_file
Dev: fix tablenames
  • Loading branch information
TonisOrmisson authored and LouisGac committed Jul 11, 2017
1 parent 101beb5 commit 70a62c1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 50 deletions.
1 change: 1 addition & 0 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -130,6 +130,7 @@ public function run($surveyid,$args)
//Iterate through the questions about to be displayed:
$inputnames = array();
$vpopup = $fpopup = false;
$upload_file = null;

foreach ($_SESSION[$this->LEMsessid]['grouplist'] as $gl){
$gid = $gl['gid'];
Expand Down
78 changes: 28 additions & 50 deletions application/models/Survey.php
Expand Up @@ -88,9 +88,9 @@
*
* @property array $fullAnswers
* @property array $partialAnswers
* @property integer $countFullAnswers
* @property integer $countPartialAnswers
* @property integer $countTotalAnswers
* @property integer $countFullAnswers Full-answers count
* @property integer $countPartialAnswers Full-answers count
* @property integer $countTotalAnswers Total-answers count
* @property integer $groupsCount Number of groups in a survey (in base language)
* @property array $surveyinfo
* @property SurveyLanguageSetting $currentLanguageSettings Survey languagesettings in currently active language
Expand Down Expand Up @@ -142,19 +142,8 @@ class Survey extends LSActiveRecord



// TODO unused??
/** @var null $full_answers_account */
public $full_answers_account=null;

// TODO unused??
public $partial_answers_account=null;
/** @var string $searched_value */
public $searched_value;

/** @var integer $fac Full-answers count*/
private $fac;
/** @var integer $pac Partial-answers count*/
private $pac;

private $sSurveyUrl;

Expand Down Expand Up @@ -338,11 +327,10 @@ public function rules()


/**
* fixSurveyAttribute to fix and/or add some survey attribute
* - Fix template name to be sure template exist
* //FIXME $event input parameter is overridden always remove from implementations
*/
public function fixSurveyAttribute($event)
* fixSurveyAttribute to fix and/or add some survey attribute
* - Fix template name to be sure template exist
*/
public function fixSurveyAttribute()
{
$event = new PluginEvent('afterFindSurvey');
$event->set('surveyid',$this->sid);
Expand Down Expand Up @@ -1151,20 +1139,17 @@ public function getFullAnswers()
*/
public function getCountFullAnswers()
{
if($this->fac!==null) {
return $this->fac;
$sResponseTable = $this->responsesTableName;
Yii::app()->cache->flush();
if ($this->active!='Y') {
return 0;
} else {
$sResponseTable = $this->responsesTableName;
Yii::app()->cache->flush();
if ($this->active!='Y') {
$this->fac = 0;
// TODO Why string?
return '0';
} else {
$answers = Yii::app()->db->createCommand('select count(*) from '.$sResponseTable.' where submitdate IS NOT NULL')->queryScalar();
$this->fac = $answers;
return $answers;
}
$answers = Yii::app()->db->createCommand()
->select('count(*)')
->from($sResponseTable)
->where('submitdate IS NOT NULL')
->queryScalar();
return $answers;
}
}

Expand All @@ -1173,19 +1158,17 @@ public function getCountFullAnswers()
*/
public function getCountPartialAnswers()
{
if($this->pac!==null) {
return $this->pac;
$table = $this->responsesTableName;
Yii::app()->cache->flush();
if ($this->active!='Y') {
return 0;
} else {
$table = $this->responsesTableName;
Yii::app()->cache->flush();
if ($this->active!='Y') {
$this->pac = 0;
return 0;
} else {
$answers = Yii::app()->db->createCommand('select count(*) from '.$table.' where submitdate IS NULL')->queryScalar();
$this->pac = $answers;
return $answers;
}
$answers = Yii::app()->db->createCommand()
->select('count(*)')
->from($table)
->where('submitdate IS NULL')
->queryScalar();
return $answers;
}
}

Expand All @@ -1194,12 +1177,7 @@ public function getCountPartialAnswers()
*/
public function getCountTotalAnswers()
{
// TODO why we have pac & fac & then countFullAnswers etc? same thing!
if ($this->pac!==null && $this->fac!==null) {
return ($this->pac + $this->fac);
} else {
return ($this->countFullAnswers + $this->countPartialAnswers);
}
return ($this->countFullAnswers + $this->countPartialAnswers);
}

/**
Expand Down

0 comments on commit 70a62c1

Please sign in to comment.