Skip to content

Commit

Permalink
Fixed issue #12249: This survey does not work with quota
Browse files Browse the repository at this point in the history
Dev: 2.63 release have issue with debug=2, else same fix than before + add warning log
  • Loading branch information
Shnoulle committed Apr 3, 2017
1 parent 3440f6f commit 3d1da4c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
4 changes: 3 additions & 1 deletion application/controllers/admin/quotas.php
Expand Up @@ -217,10 +217,12 @@ function index($iSurveyId, $quickreport = false)
foreach ($oQuota->quotaMembers as $oQuotaMember)
{
$aQuestionAnswers = self::getQuotaAnswers($oQuotaMember['qid'], $iSurveyId, $oQuota['id']);
$answerText=isset($aQuestionAnswers[$oQuotaMember['code']]) ? flattenText($aQuestionAnswers[$oQuotaMember['code']]['Display']) : null;
$aQuotaItems[$oQuota['id']][] = array(
'oQuestion' => Question::model()->findByPk(array('qid' => $oQuotaMember['qid'], 'language' => $oSurvey->language)),
'answer_title' => flattenText($aQuestionAnswers[$oQuotaMember['code']]['Display']),
'answer_title' => $answerText,
'oQuotaMember'=>$oQuotaMember,
'valid'=>isset($answerText),
);
}

Expand Down
24 changes: 18 additions & 6 deletions application/models/Quota.php
Expand Up @@ -159,16 +159,28 @@ public function getMainLanguagesetting(){
}

public function getCompleteCount(){
if(!tableExists("survey_{$this->sid}"))
return;

if (count($this->quotaMembers) > 0)
{
if(!tableExists("survey_{$this->sid}")) {
return;
}
/* Must control if column name exist (@todo : move this to QuotaMember::model(), even with deactivated survey*/
$aExistingColumnName=SurveyDynamic::model($this->sid)->getTableSchema()->getColumnNames();
if (count($this->quotaMembers) > 0) {
// Keep a list of fields for easy reference
$aQuotaColumns = array();
foreach ($this->quotaMembers as $member)
{
$aQuotaColumns[$member->memberInfo['fieldname']][] = $member->memberInfo['value'];
if(!in_array($member->memberInfo['fieldname'],$aExistingColumnName)) {
\Yii::log(
sprintf(
"Invalid quota member %s",
$member->memberInfo['fieldname']
),
'warning',
'application.model.Quota'
);
return;
}
$aQuotaColumns[$member->memberInfo['fieldname']][] = $member->memberInfo['value'];
}

$oCriteria = new CDbCriteria;
Expand Down
4 changes: 2 additions & 2 deletions application/models/QuotaMember.php
Expand Up @@ -72,8 +72,8 @@ public function primaryKey()

public function getMemberInfo()
{
$sFieldName = "0";
$sValue = "";
$sFieldName = null;
$sValue = null;

switch($this->question->type) {
case "L":
Expand Down
Expand Up @@ -8,7 +8,7 @@
/* @var Question $oQuestion */
$oQuestion = $data['oQuestion'];
?>
<tr>
<tr class="<?php echo !$data['valid'] ? "bg-warning text-danger":""; ?>"><!-- because lime-admin-colors.css force tr:nth-child(2n+1) td color, must add text-danger -->
<td data-toggle="tooltip" data-container="body" title="<?php echo viewHelper::flatEllipsizeText($oQuestion->question,true,60,'...',0.6); ?>">
<?php echo $oQuestion->title?>
</td>
Expand All @@ -24,4 +24,4 @@
));
?>
</td>
</div>
</tr>

0 comments on commit 3d1da4c

Please sign in to comment.