Skip to content

Commit

Permalink
Dev: 5 point choice question, human readable views
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Apr 4, 2016
1 parent a6fd42d commit 62628e8
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 106 deletions.
44 changes: 27 additions & 17 deletions application/helpers/qanda_helper.php
Expand Up @@ -806,8 +806,7 @@ function do_5pointchoice($ia)
$aQuestionAttributes = QuestionAttribute::model()->getQuestionAttributes($ia[0]);
$id = 'slider'.time().rand(0,100);

$answer = Yii::app()->getController()->renderPartial('/survey/questions/5pointchoice/5pointchoice_header', array('id'=>$id), true);

$sRows = "";
for ($fp=1; $fp<=5; $fp++)
{
$checkedState = '';
Expand All @@ -817,14 +816,17 @@ function do_5pointchoice($ia)
$checkedState = ' CHECKED ';
}

$aData = array(
'ia' => $ia,
'fp' => $fp,
'checkedState' => $checkedState,
$sRows .= Yii::app()->getController()->renderPartial('/survey/questions/5pointchoice/rows/item_row', array(
'name' => $ia[1],
'value' => $fp,
'id' => $ia[1].$fp,
'labelText' => $fp,
'itemExtraClass' => 'col-md-1',
'checkedState' => $checkedState,
'checkconditionFunction' => $checkconditionFunction,
);
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/5pointchoice/item_row', $aData, true);
), true);
}

if ($ia[6] != "Y" && SHOW_NO_ANSWER == 1) // Add "No Answer" option if question is not mandatory
{
$checkedState = '';
Expand All @@ -833,14 +835,18 @@ function do_5pointchoice($ia)
$checkedState = ' CHECKED ';
}
$aData = array(
'ia' => $ia,
'checkedState' => $checkedState,
'name' => $ia[1],
'value' => $fp,
'id' => $ia[1].'NANS',
'labelText' => gT('No answer'),
'itemExtraClass' => 'noanswer-item',
'checkedState' => $checkedState,
'checkconditionFunction' => $checkconditionFunction,
);
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/5pointchoice/item_noanswer_row', $aData, true);
$sRows .= Yii::app()->getController()->renderPartial('/survey/questions/5pointchoice/rows/item_row', $aData, true);

}
$sJavaValue = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]];
$sessionValue = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]];

$inputnames[]=$ia[1];

Expand All @@ -858,12 +864,16 @@ function do_5pointchoice($ia)
Yii::app()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts')."slider-rating.js");
}

$aData = array(
'ia' => $ia,
'sJavaValue' => $sJavaValue,

// ==> answer
$answer = Yii::app()->getController()->renderPartial('/survey/questions/5pointchoice/answer', array(
'id' => $id,
'sliderId' => $ia[0],
'name' => $ia[1],
'sessionValue' => $sessionValue,
'sRows' => $sRows,
'slider_rating' => $slider_rating,
);
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/5pointchoice/5pointchoice_footer', $aData, true);
), true);

return array($answer, $inputnames);
}
Expand Down

This file was deleted.

This file was deleted.

47 changes: 47 additions & 0 deletions application/views/survey/questions/5pointchoice/answer.php
@@ -0,0 +1,47 @@
<?php
/**
* 5 point choice Html
*
* @var $sRows : the rows, generated with the view item_row.php
* @var $slider_rating : slider rating display in question attribute
*
* @var $id
* @var $sliderId $ia[0];
* @var $name' => $ia[1],
* @var $sessionValue
*/
?>

<!-- 5 point choice -->

<!-- answer -->
<div id="<?php echo $id; ?>" class="answers-list five-point-choice radio-list">

<?php
// item_row.php
echo $sRows;
?>

<!-- 5 point choice footer -->
<input
type="hidden"
name="java<?php echo $name;?>"
id="java<?php echo $name;?>"
value="<?php echo $sessionValue;?>"
/>

<?php if($slider_rating==1):?>
<script type='text/javascript'>
<!--
doRatingStar( <?php echo $sliderId;?> );
-->
</script>
<?php elseif($slider_rating==2):?>
<script type='text/javascript'>
<!--
doRatingSlider( <?php echo $sliderId; ?> );
-->
</script>
<?php endif;?>
</div>
<!-- end of answer -->

This file was deleted.

25 changes: 0 additions & 25 deletions application/views/survey/questions/5pointchoice/item_row.php

This file was deleted.

30 changes: 30 additions & 0 deletions application/views/survey/questions/5pointchoice/rows/item_row.php
@@ -0,0 +1,30 @@
<?php
/**
* 5 point choice Html : item row
*
* @var $name
* @var $value
* @var $id
* @var $labelText
* @var $itemExtraClass
* @var $checkedState
* @var $checkconditionFunction
*/
?>

<!-- item_row -->
<div class="col-xs-12 col-sm-2 answer-item radio-item <?php echo $itemExtraClass; ?>">
<input
class="radio"
type="radio"
name="<?php echo $name; ?>"
id="answer<?php echo $id; ?>"
value="<?php echo $value;?>"
<?php echo $checkedState; ?>
onclick="<?php echo $checkconditionFunction; ?>(this.value, this.name, this.type)"
/>
<label for="answer<?php echo $id; ?>" class="answertext radio-label">
<?php echo $labelText; ?>
</label>
</div>
<!-- end of item_row -->

0 comments on commit 62628e8

Please sign in to comment.