Skip to content

Commit

Permalink
Dev: list with comment, list views
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jan 25, 2016
1 parent 2a33bf9 commit d418c40
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 29 deletions.
64 changes: 35 additions & 29 deletions application/helpers/qanda_helper.php
Expand Up @@ -1843,7 +1843,7 @@ function do_listwithcomment($ia)
// General variables
global $dropdownthreshold;
global $thissurvey;
$dropdownthreshold = Yii::app()->getConfig("dropdownthreshold");
$dropdownthreshold = Yii::app()->getConfig("dropdownthreshold");
$kpclass = testKeypad($thissurvey['nokeyboard']); // Virtual keyboard (probably obsolete today)
$checkconditionFunction = "checkconditions";
$iSurveyId = Yii::app()->getConfig('surveyID'); // survey id
Expand All @@ -1865,22 +1865,23 @@ function do_listwithcomment($ia)
$hint_comment = gT('Please enter your comment here');
if ($aQuestionAttributes['use_dropdown']!=1 && $anscount <= $dropdownthreshold)
{
$answer .= '<div class="list">
<ul class="list-unstyled answers-list radio-list">
';

$answer .= Yii::app()->getController()->renderPartial('/survey/questions/list_with_comment/list/header', array(), true);
foreach ($ansresult as $ansrow)
{
$check_ans = '';
if ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] == $ansrow['code'])
{
$check_ans = CHECKED;
}
$answer .= ' <li class="answer-item radio-item">
<input type="radio" name="'.$ia[1].'" id="answer'.$ia[1].$ansrow['code'].'" value="'.$ansrow['code'].'" class="radio" '.$check_ans.' onclick="'.$checkconditionFunction.'(this.value, this.name, this.type)" />
<label for="answer'.$ia[1].$ansrow['code'].'" class="answertext">'.$ansrow['answer'].'</label>
</li>
';
$itemData = array(
'name'=>$ia[1],
'id'=>'answer'.$ia[1].$ansrow['code'],
'value'=>$ansrow['code'],
'check_ans'=>$check_ans,
'checkconditionFunction'=>$checkconditionFunction.'(this.value, this.name, this.type);',
'labeltext'=>$ansrow['answer'],
);
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/list_with_comment/list/item', $itemData, true);
}

if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1)
Expand All @@ -1893,11 +1894,17 @@ function do_listwithcomment($ia)
{
$check_ans = '';
}
$answer .= ' <li class="answer-item radio-item noanswer-item">
<input class="radio" type="radio" name="'.$ia[1].'" id="answer'.$ia[1].'" value=" " onclick="'.$checkconditionFunction.'(this.value, this.name, this.type)"'.$check_ans.' />
<label for="answer'.$ia[1].'" class="answertext">'.gT('No answer').'</label>
</li>
';

$itemData = array(
'li_classes'=>' noanswer-item',
'name'=>$ia[1],
'id'=>'answer'.$ia[1],
'value'=>'',
'check_ans'=>$check_ans,
'checkconditionFunction'=>$checkconditionFunction.'(this.value, this.name, this.type)',
'labeltext'=>gT('No answer'),
);
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/list_with_comment/list/item', $itemData, true);
}

$fname2 = $ia[1].'comment';
Expand All @@ -1907,23 +1914,22 @@ function do_listwithcomment($ia)
// $answer .= "\t<td valign='top'>\n"
// . "<textarea class='textarea' name='$ia[1]comment' id='answer$ia[1]comment' rows='$tarows' cols='30'>";
// --> END ORIGINAL
$answer .= ' </ul>
</div>

<p class="comment answer-item text-item">
<label for="answer'.$ia[1].'comment">'.$hint_comment.':</label>
$footerData = array(
'id'=>'answer'.$ia[1].'comment',
'hint_comment'=>$hint_comment,
'kpclass'=>$kpclass,
'name'=>$ia[1].'comment',
'tarows'=>floor($tarows),
'has_comment_saved'=>isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$fname2]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$fname2],
'comment_saved'=>htmlspecialchars($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$fname2]),
'java_name'=>'java'.$ia[1],
'java_id'=>'java'.$ia[1],
'java_value'=>$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]]
);

<textarea class="textarea form-control'.$kpclass.'" name="'.$ia[1].'comment" id="answer'.$ia[1].'comment" rows="'.floor($tarows).'" cols="30" >';
// --> END NEW FEATURE - SAVE
if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$fname2]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$fname2])
{
$answer .= htmlspecialchars($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$fname2]);
}
$answer .= '</textarea>
</p>
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/list_with_comment/list/footer', $footerData, true);

<input class="radio" type="hidden" name="java'.$ia[1].'" id="java'.$ia[1].'" value="'.$_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]].'" />
';
$inputnames[]=$ia[1];
$inputnames[]=$ia[1].'comment';
}
Expand Down
@@ -0,0 +1,43 @@
<?php
/**
* List with comment footer Html
* @var $id answer'.$ia[1].'comment
* @var $hint_comment
* @var $kpclass
* @var $name $ia[1].'comment
* @var $tarows floor($tarows)
* @var $has_comment_saved isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$fname2]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$fname2]
* @var $comment_saved htmlspecialchars($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$fname2])
* @var $java_name java'.$ia[1].'
* @var $java_id java'.$ia[1].'
* @var $java_value $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]].'"
*/
?>
</ul>
</div>

<p class="comment answer-item text-item">
<label for="<?php echo $id; ?>">
<?php echo $hint_comment;?>:
</label>

<textarea
class="textarea form-control <?php echo $kpclass; ?>"
name="<?php echo $name; ?>"
id="<?php echo $id; ?>"
rows="<?php echo $tarows;?>"
cols="30"
>
<?php if($has_comment_saved):?>
<?php echo $comment_saved;?>
<?php endif;?>
</textarea>
</p>

<input
class="radio"
type="hidden"
name="<?php echo $java_name;?>"
id="<?php echo $java_id;?>"
value="<?php echo $java_value;?>"
/>
@@ -0,0 +1,8 @@
<?php
/**
* List with comment header Html
*/
?>

<div class="list">
<ul class="list-unstyled answers-list radio-list">
27 changes: 27 additions & 0 deletions application/views/survey/questions/list_with_comment/list/item.php
@@ -0,0 +1,27 @@
<?php
/**
* List with comment item Html
*
* @var $name $ia[1]
* @var $id answer'.$ia[1].$ansrow['code'].'
* @var $value $ansrow['code']
* @var $check_ans
* @var $checkconditionFunction $checkconditionFunction.'(this.value, this.name, this.type)
* @var $labeltext $ansrow['answer']
* @var $li_classes
*/
?>
<li class="answer-item radio-item <?php if(isset($li_classes)){echo $li_classes;}?>">
<input
type="radio"
name="<?php echo $name; ?>"
id="<?php echo $id; ?>"
value="<?php echo $value; ?>"
class="radio"
<?php $check_ans; ?>
onclick="<?php echo $checkconditionFunction; ?>"
/>
<label for="<?php echo $id; ?>" class="answertext">
<?php echo $labeltext;?>
</label>
</li>

0 comments on commit d418c40

Please sign in to comment.