Skip to content

Commit

Permalink
Dev: reworking dual_scale
Browse files Browse the repository at this point in the history
Dev: readding column width
Dev: use return_display_style for filter : NOT TESTED
  • Loading branch information
Shnoulle committed Sep 21, 2016
1 parent dc651e9 commit 36a3788
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 74 deletions.
20 changes: 13 additions & 7 deletions application/helpers/qanda_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6000,7 +6000,7 @@ function do_array_dual($ia)
$aData['aSubQuestions'][$i]['myfid1'] = $myfid1;

$aData['aSubQuestions'][$i]['answertext'] = $ansrow['question'];

$aData['aSubQuestions'][$i]['zebra'] = 2 - ($i % 2);
/* Check the Sub Q mandatory violation */
if ($ia[6]=='Y' && (in_array($myfname0, $aMandatoryViolationSubQ) || in_array($myfname1, $aMandatoryViolationSubQ)))
{
Expand All @@ -6012,10 +6012,12 @@ function do_array_dual($ia)
}

// Get array_filter stuff
list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc answers-list radio-list");
$aData['aSubQuestions'][$i]['htmltbody2'] = $htmltbody2;
$aData['aSubQuestions'][$i]['hiddenfield'] = $hiddenfield;
//~ list($htmltbody2, $hiddenfield) = return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc answers-list radio-list");

//~ $aData['aSubQuestions'][$i]['htmltbody2'] = $htmltbody2;
//~ $aData['aSubQuestions'][$i]['hiddenfield'] = $hiddenfield;
// @todo return_display_style($ia, $aQuestionAttributes, $thissurvey, $ansrow);
$aData['aSubQuestions'][$i]['sDisplayStyle']=return_display_style($ia, $aQuestionAttributes, $thissurvey, $myfname);
array_push($inputnames, $myfname0);

if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname0]))
Expand Down Expand Up @@ -6199,13 +6201,17 @@ function do_array_dual($ia)
$aData['aSubQuestions'][$i]['myfid1'] = $myfid1;
$aData['aSubQuestions'][$i]['sActualAnswer0'] = $sActualAnswer0;
$aData['aSubQuestions'][$i]['sActualAnswer1'] = $sActualAnswer1;
$aData['aSubQuestions'][$i]['zebra'] = 2 - ($i % 2);

// Set mandatory alert
$aData['aSubQuestions'][$i]['alert'] = ($ia[6]=='Y' && (in_array($myfname0, $aMandatoryViolationSubQ) || in_array($myfname1, $aMandatoryViolationSubQ)));
$aData['aSubQuestions'][$i]['mandatoryviolation'] = ($ia[6]=='Y' && (in_array($myfname0, $aMandatoryViolationSubQ) || in_array($myfname1, $aMandatoryViolationSubQ)));
// Array filter : maybe leave EM do the trick
$aData['aSubQuestions'][$i]['sDisplayStyle']=return_display_style($ia, $aQuestionAttributes, $thissurvey, $myfname);

list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc subquestion-list questions-list dropdown-list");
$aData['aSubQuestions'][$i]['htmltbody2'] = $htmltbody2;
$aData['aSubQuestions'][$i]['hiddenfield'] = $hiddenfield;
//~ list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc subquestion-list questions-list dropdown-list");
//~ $aData['aSubQuestions'][$i]['htmltbody2'] = $htmltbody2;
//~ $aData['aSubQuestions'][$i]['hiddenfield'] = $hiddenfield;
$aData['labels0'] = $labels0;
$aData['labels1'] = $labels1;
$aData['aSubQuestions'][$i]['showNoAnswer0'] = ($sActualAnswer0 != '' && $ia[6] != 'Y' && SHOW_NO_ANSWER);
Expand Down
58 changes: 30 additions & 28 deletions application/views/survey/questions/arrays/dualscale/answer.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,22 @@
<?php endif; ?>

<!-- tr -->
<?php echo $ansrow['htmltbody2']; ?>
<th class="answertext">
<?php echo $ansrow['hiddenfield']; ?>

<?php if ($ansrow['showmandatoryviolation']): ?>
<div class="label label-danger">
<span class="fa fa-exclamation-circle" aria-hidden="true"></span>
<?php echo $ansrow['answertext']; ?>
</div>
<?php else: ?>
<?php echo $ansrow['answertext']; ?>
<?php endif; ?>


<?php
$errorClass= (($ansrow['showmandatoryviolation']) ? " has-error" : "");
echo CHtml::tag(
"tr",
array(
'id'=> "javatbd{$ansrow['myfname']}",
'class'=>"answers-list radio-list array{$ansrow['zebra']} {$errorClass} " ,
'role'=>"radiogroup",
'aria-labelledby'=>"answertext{$ansrow['myfname']}"
),
"",
false
);
?>
<th class="answertext control-label">
<?php echo $ansrow['answertext']; ?>
<input type="hidden" disabled="disabled" name="java<?php echo $ansrow['myfid0']; ?>"
id="java<?php echo $ansrow['myfid0']; ?>" value=""
<?php echo $ansrow['sessionfname0']; ?>
Expand All @@ -121,18 +123,18 @@
<!-- First label set -->
<?php foreach ($labelcode0 as $j => $ld): ?>
<?php if ($j === 0 && $leftheader != ''): ?>
<td class='visible-xs'><em><?php echo $leftheader; ?></em></td>
<td class='visible-xs leftheader'><?php echo $leftheader; ?></td>
<?php endif; ?>
<td class="answer_cell_1_<?php echo $ld; ?> answer-item <?php echo $answertypeclass; ?>-item text-center">
<td class="answer_cell_1_<?php echo $ld; ?> answer-item <?php echo $answertypeclass; ?>-item">
<input
type="radio"
name="<?php echo $ansrow['myfname0']; ?>"
value="<?php echo $ld; ?>"
id="answer<?php echo $ansrow['myfid0']; ?>-<?php echo $ld; ?>"
<?php echo $labelcode0_checked[$ansrow['title']][$ld]; ?>
/>
<label for="answer<?php echo $ansrow['myfid0']; ?>-<?php echo $ld; ?>">
<span class="visible-xs-block label-text"><?php echo $labelans0[$j];?></span>
<label for="answer<?php echo $ansrow['myfid0']; ?>-<?php echo $ld; ?>" class="sr-only">
<?php echo $labelans0[$j];?>
</label>
</td>
<?php endforeach; ?>
Expand All @@ -142,7 +144,7 @@
<?php if ($shownoanswer): // No answer for accessibility and no javascript (but visible-xs-block visible-xs-block even with no js: need reworking) ?>
<label for='answer<?php echo $ansrow['myfid0']; ?>-'>
<input
class='jshide read'
class='visible-xs-block'
type='radio'
name='<?php echo $ansrow['myfname0']; ?>'
value=''
Expand All @@ -156,18 +158,18 @@ class='jshide read'
<!-- Second label set -->
<?php foreach ($labelcode1 as $k => $ld): ?>
<?php if ($k === 0 && $rightheader != ''): ?>
<td class='visible-xs'><em><?php echo $rightheader; ?></em></td>
<td class='visible-xs rightheader'><?php echo $rightheader; ?></td>
<?php endif; ?>
<td class="answer_cell_2_<?php echo $ld; ?> answer-item radio-item text-center">
<td class="answer_cell_2_<?php echo $ld; ?> answer-item radio-item">
<input
type="radio"
name="<?php echo $ansrow['myfname1']; ?>"
value="<?php echo $ld; ?>"
id="answer<?php echo $ansrow['myfid1']; ?>-<?php echo $ld; ?>"
<?php echo $labelcode1_checked[$ansrow['title']][$ld]; ?>
/>
<label for="answer<?php echo $ansrow['myfid1']; ?>-<?php echo $ld; ?>">
<span class="visible-xs-block label-text"><?php echo $labelans1[$k];?></span>
<label for="answer<?php echo $ansrow['myfid1']; ?>-<?php echo $ld; ?>" class="sr-only">
<?php echo $labelans1[$k];?>
</label>
</td>
<?php endforeach; ?>
Expand All @@ -182,7 +184,7 @@ class='jshide read'

<!-- No answer column -->
<?php if ($shownoanswer): ?>
<td class="dual_scale_no_answer answer-item radio-item noanswer-item text-center">
<td class="dual_scale_no_answer answer-item radio-item noanswer-item">
<?php if (count($labelans1) > 0): ?>
<input
type='radio'
Expand All @@ -191,8 +193,8 @@ class='jshide read'
id='answer<?php echo $ansrow['myfid1']; ?>-'
<?php echo $myfname1_notset; ?>
/>
<label for='answer<?php echo $ansrow['myfid1']; ?>-'>
<span class="visible-xs-block label-text"><?php eT("No answer"); ?></span>
<label for='answer<?php echo $ansrow['myfid1']; ?>-' class="sr-only">
<?php eT("No answer"); ?>
</label>
<?php else: ?>
<input
Expand All @@ -202,8 +204,8 @@ class='jshide read'
id='answer<?php echo $ansrow['myfid0']; ?>-'
<?php echo $myfname0_notset; ?>
/>
<label for='answer<?php echo $ansrow['myfid0']; ?>-'>
<span class="visible-xs-block label-text"><?php eT("No answer"); ?></span>
<label for='answer<?php echo $ansrow['myfid0']; ?>-' class="sr-only">
<?php eT("No answer"); ?>
</label>
<?php endif; ?>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<div class="no-more-tables no-more-tables-array-dual-dropdown-layout">
<table class="table table-in-qanda-10 question subquestion-list questions-list dropdown-list">

<?php /*
<!-- Column groups -->
<col class="answertext" style='width: <?php echo $answerwidth; ?>%;' />

Expand Down Expand Up @@ -55,16 +54,14 @@
<?php if ($ddprefix != '' || $ddsuffix != ''): ?>
</colgroup>
<?php endif; ?>
*/ ?>

<!-- Header -->

<thead>
<tr>
<th>&nbsp;</th>
<th class='th-14 text-center' <?php echo $colspan; ?>><?php echo $leftheader; ?></th>
<th class='th-14' <?php echo $colspan; ?>><?php echo $leftheader; ?></th>
<th>&nbsp;</th>
<th class='th-15 text-center' <?php echo $colspan; ?>><?php echo $rightheader; ?></th>
<th class='th-15' <?php echo $colspan; ?>><?php echo $rightheader; ?></th>
</tr>
</thead>

Expand All @@ -75,43 +72,44 @@

<?php foreach ($aSubQuestions as $ansrow): ?>
<!-- <tr> -->
<?php echo $ansrow['htmltbody2']; ?>

<?php
echo CHtml::tag(
"tr",
array(
'id'=> "javatbd{$ansrow['myfname']}",
'class'=>"answers-list radio-list array{$ansrow['zebra']}".(($ansrow['mandatoryviolation']) ? " has-error error-mandatory" : "") ,
'role'=>"radiogroup",
),
"",
false
);
?>
<!-- Answer text (actual question) -->

<th class="answertext">
<label for="answer<?php echo $ansrow['myfid0']; ?>">

<?php if ($ansrow['alert']): ?>
<div class="label label-danger" role="alert">
<?php echo $ansrow['question']; ?>
</div>
<?php else: ?>
<?php echo $ansrow['question']; ?>
<?php endif; ?>

<input
type="hidden"
disabled="disabled"
name="java<?php echo $ansrow['myfid0']; ?>"
id="java<?php echo $ansrow['myfid0']; ?>"
value="<?php echo $ansrow['sActualAnswer0']; ?>"
/>
<input
type="hidden"
disabled="disabled"
name="java<?php echo $ansrow['myfid1']; ?>"
id="java<?php echo $ansrow['myfid1']; ?>"
value="<?php echo $ansrow['sActualAnswer1']; ?>"
/>

<th class="answertext control-label">
<label for="answer<?php echo $ansrow['myfid0']; ?>" id="answertext<?php echo $ansrow['myfname']; ?>">
<?php echo $ansrow['question']; ?>
</label>
<input
type="hidden"
disabled="disabled"
name="java<?php echo $ansrow['myfid0']; ?>"
id="java<?php echo $ansrow['myfid0']; ?>"
value="<?php echo $ansrow['sActualAnswer0']; ?>"
/>
<input
type="hidden"
disabled="disabled"
name="java<?php echo $ansrow['myfid1']; ?>"
id="java<?php echo $ansrow['myfid1']; ?>"
value="<?php echo $ansrow['sActualAnswer1']; ?>"
/>
</th>

<!-- Prefix -->

<?php if ($ddprefix != ''): ?>
<td class="ddprefix information-item text-right">
<td class="ddprefix information-item">
<?php echo $ddprefix; ?>
</td>
<?php endif; ?>
Expand All @@ -123,6 +121,7 @@
class='form-control'
name="<?php echo $ansrow['myfname0']; ?>"
id="answer<?php echo $ansrow['myfid0']; ?>"
aria-labelledby="answertext<?php echo $ansrow['myfname']; ?>"
>

<!-- Please choose... -->
Expand All @@ -145,7 +144,7 @@ class='form-control'
<?php endforeach; ?>

<!-- No answer -->
<?php if ($ansrow['showNoAnswer0']): ?>
<?php if ($ansrow['showNoAnswer0'] && $ansrow['sActualAnswer0'] != ''): ?>
<option value=""><?php eT('No answer'); ?></option>
<?php endif; ?>

Expand Down Expand Up @@ -174,12 +173,11 @@ class='form-control'
<!-- Second dropdown -->

<td class="answer-item dropdown-item">
<label class="visible-xs-block read" for="answer<?php echo $ansrow['myfid1']; ?>">
<label class="visible-xs-block" for="answer<?php echo $ansrow['myfid1']; ?>">
<?php echo $ansrow['question']; ?>
</label>

<select class='form-control' name="<?php echo $ansrow['myfname1']; ?>" id="answer<?php echo $ansrow['myfid1']; ?>">

<!-- Please choose... -->
<?php if ($ansrow['sActualAnswer1'] == ''): ?>
<option value="" <?php echo SELECTED; ?> ><?php eT('Please choose...'); ?></option>
Expand All @@ -191,14 +189,13 @@ class='form-control'
value="<?php echo $lrow['code']; ?>"
<?php if ($ansrow['sActualAnswer1'] == $lrow['code']): echo SELECTED; endif; ?>
>

<?php echo flattenText($lrow['title']); ?>

</option>
<?php endforeach; ?>

<!-- No answer -->
<?php if ($ansrow['showNoAnswer1']): ?>
<?php if ($ansrow['showNoAnswer1'] && $ansrow['sActualAnswer1'] != ''): ?>
<option value=""><?php eT('No answer'); ?></option>
<?php endif; ?>

Expand Down

0 comments on commit 36a3788

Please sign in to comment.