Skip to content

Commit

Permalink
Fixed issue #09753: Lack of sub question for array text and arry numb…
Browse files Browse the repository at this point in the history
…er aren't show in Question view

Dev: Test number of answers scales and subquestions scales
Dev: No view for question in ls3
Dev: Survey logic file need complete reworking : @todo for ls3 (or 3.1)
  • Loading branch information
Shnoulle committed Jul 7, 2015
1 parent f6550f5 commit efac566
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 24 deletions.
53 changes: 44 additions & 9 deletions application/core/Survey_Common_Action.php
Expand Up @@ -362,17 +362,11 @@ function _questionbar($iSurveyID, $gid, $qid, $action = null)
$baselang = Survey::model()->findByPk($iSurveyID)->language;

//Show Question Details
//Count answer-options for this question
$qrr = Answer::model()->findAllByAttributes(array('qid' => $qid, 'language' => $baselang));

$aData['qct'] = $qct = count($qrr);
$qrrow = Question::model()->findByAttributes(array('qid' => $qid, 'gid' => $gid, 'sid' => $iSurveyID, 'language' => $baselang));
if (is_null($qrrow))
return; // Throw 404 ....

//Count sub-questions for this question
$sqrq = Question::model()->findAllByAttributes(array('parent_qid' => $qid, 'language' => $baselang));
$aData['sqct'] = $sqct = count($sqrq);

$qrrow = Question::model()->findByAttributes(array('qid' => $qid, 'gid' => $gid, 'sid' => $iSurveyID, 'language' => $baselang));
if (is_null($qrrow)) return;
$questionsummary = "<div class='menubar'>\n";

// Check if other questions in the Survey are dependent upon this question
Expand All @@ -392,6 +386,47 @@ function _questionbar($iSurveyID, $gid, $qid, $action = null)
$qrrow = $qrrow->attributes;
$aData['languagelist'] = Survey::model()->findByPk($iSurveyID)->getAllLanguages();
$aData['qtypes'] = $qtypes = getQuestionTypeList('', 'array');

// Warning of lack of sub-questions or answers
$aWarnings=array();
if($qtypes[$qrrow['type']]['answerscales'] > 0 && !Answer::model()->count("qid=:qid AND language=:language and scale_id=0",array(':qid' => $qid, ':language' => $baselang)))
{
$aWarnings[]=array(
'url'=>App()->createUrl("admin/questions",array("sa"=>"answeroptions","surveyid"=>$iSurveyID,"gid"=>$gid,"qid"=>$qid)),
'img'=>'answers_20.png',
'text'=>gt("You need to add answer options to this question.",'unescaped'),
'help'=>gt("Edit answer options for this question.",'unescaped'),
);
}
elseif($qtypes[$qrrow['type']]['answerscales'] > 1 && !Answer::model()->count("qid=:qid AND language=:language and scale_id=1",array(':qid' => $qid, ':language' => $baselang)))
{
$aWarnings[]=array(
'url'=>App()->createUrl("admin/questions",array("sa"=>"answeroptions","surveyid"=>$iSurveyID,"gid"=>$gid,"qid"=>$qid)),
'img'=>'answers_20.png',
'text'=>gt("You need to add answer options to this question.",'unescaped'),
'help'=>gt("Edit answer options for this question.",'unescaped'),
);
}
if($qtypes[$qrrow['type']]['subquestions'] > 0 && !Question::model()->count("parent_qid=:qid AND language=:language and scale_id=0",array(':qid' => $qid, ':language' => $baselang)))
{
$aWarnings[]=array(
'url'=>App()->createUrl("admin/questions",array("sa"=>"subquestions","surveyid"=>$iSurveyID,"gid"=>$gid,"qid"=>$qid)),
'img'=>$qtypes[$qrrow['type']]['subquestions']>1 ? "subquestions2d_20.png" : "subquestions_20.png",
'text'=>gt("You need to add subquestions options to this question.",'unescaped'),
'help'=>gt("Edit subquestions options for this question.",'unescaped'),
);
}
elseif($qtypes[$qrrow['type']]['subquestions'] > 1 && !Question::model()->count("parent_qid=:qid AND language=:language and scale_id=1",array(':qid' => $qid, ':language' => $baselang)))
{
$aWarnings[]=array(
'url'=>App()->createUrl("admin/questions",array("sa"=>"subquestions","surveyid"=>$iSurveyID,"gid"=>$gid,"qid"=>$qid)),
'img'=>'subquestions2d_20.png',
'text'=>gt("You need to add subquestions to this question.",'unescaped'),
'help'=>gt("Edit subquestions for this question.",'unescaped'),
);
}
$aData['aWarnings'] = $aWarnings;

if ($action == 'editansweroptions' || $action == "editsubquestions" || $action == "editquestion" || $action == "editdefaultvalues" || $action =="editdefaultvalues" || $action == "copyquestion")
{
$qshowstyle = "style='display: none'";
Expand Down
24 changes: 9 additions & 15 deletions application/views/admin/survey/Question/questionbar_view.php
Expand Up @@ -184,24 +184,18 @@
<tr><td><strong>
<?php eT("Type:"); ?></strong></td><td><?php echo $qtypes[$qrrow['type']]['description']; ?>
</td></tr>
<?php if ($qct == 0 && $qtypes[$qrrow['type']]['answerscales'] >0)
{ ?>
<tr ><td></td><td>
<span class='statusentryhighlight'>
<?php eT("Warning"); ?>: <a href='<?php echo $this->createUrl("admin/questions/sa/answeroptions/surveyid/$surveyid/gid/$gid/qid/$qid"); ?>'><?php eT("You need to add answer options to this question"); ?>
<img src='<?php echo $sImageURL; ?>answers_20.png' title='<?php eT("Edit answer options for this question"); ?>' /></a></span></td></tr>
<?php }


if($sqct == 0 && $qtypes[$qrrow['type']]['subquestions'] >0)
<?php foreach($aWarnings as $aWarning)
{ ?>
<tr ><td></td><td>
<span class='statusentryhighlight'>
<?php eT("Warning"); ?>: <a href='<?php echo $this->createUrl("admin/questions/sa/subquestions/surveyid/$surveyid/gid/$gid/qid/$qid"); ?>'><?php eT("You need to add subquestions to this question"); ?>
<img src='<?php echo $sImageURL; ?><?php if ($qtypes[$qrrow['type']]['subquestions']==1){?>subquestions_20<?php } else {?>subquestions2d_20<?php } ?>.png' title='<?php eT("Edit subquestions for this question"); ?>' /></a></span></td></tr>
<?php }
<tr>
<td class='text-error'><?php eT("Warning:"); ?></td>
<td>
<?php echo CHtml::link($aWarning['text'].CHtml::image($sImageURL.$aWarning['img']),$aWarning['url'],array("title"=>$aWarning['help'])) ?>
</td>
</tr>
<?php } ?>

if ($qrrow['type'] == "M" or $qrrow['type'] == "P")
<?php if ($qrrow['type'] == "M" or $qrrow['type'] == "P")
{ ?>
<tr>
<td><strong>
Expand Down

0 comments on commit efac566

Please sign in to comment.