From ea289111644d1cef3add93d826214e5c2c101bb8 Mon Sep 17 00:00:00 2001 From: LouisGac Date: Tue, 22 Mar 2016 18:38:54 +0100 Subject: [PATCH] Dev: array Yes/No/Uncertain views --- application/helpers/qanda_helper.php | 139 ++++++------------ .../arrays/yesnouncertain/close_table.php | 3 + .../questions/arrays/yesnouncertain/col.php | 10 ++ .../arrays/yesnouncertain/header.php | 12 ++ .../questions/arrays/yesnouncertain/thead.php | 26 ++++ .../questions/arrays/yesnouncertain/tr.php | 90 ++++++++++++ 6 files changed, 182 insertions(+), 98 deletions(-) create mode 100644 application/views/survey/questions/arrays/yesnouncertain/close_table.php create mode 100644 application/views/survey/questions/arrays/yesnouncertain/col.php create mode 100644 application/views/survey/questions/arrays/yesnouncertain/header.php create mode 100644 application/views/survey/questions/arrays/yesnouncertain/thead.php create mode 100644 application/views/survey/questions/arrays/yesnouncertain/tr.php diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php index 74a412cb743..40e527bafa9 100644 --- a/application/helpers/qanda_helper.php +++ b/application/helpers/qanda_helper.php @@ -4073,7 +4073,7 @@ function do_array_10point($ia) $anscount = count($aSubquestions); $fn = 1; - $answer = $answer = Yii::app()->getController()->renderPartial('/survey/questions/arrays/10point/header', $headerDatas, true); + $answer = Yii::app()->getController()->renderPartial('/survey/questions/arrays/10point/header', $headerDatas, true); $odd_even = ''; for ($xc=1; $xc<=10; $xc++) @@ -4206,7 +4206,8 @@ function do_array_yesnouncertain($ia) } $cellwidth = round((( 100 - $answerwidth ) / $cellwidth) , 1); // convert number of columns to percentage of table width - if ($aQuestionAttributes['random_order']==1) { + if ($aQuestionAttributes['random_order']==1) + { $ansquery = "SELECT * FROM {{questions}} WHERE parent_qid=$ia[0] AND language='".$_SESSION['survey_'.Yii::app()->getConfig('surveyID')]['s_lang']."' ORDER BY ".dbRandom(); } else @@ -4217,41 +4218,30 @@ function do_array_yesnouncertain($ia) $aSubquestions = $ansresult->readAll(); $anscount = count($aSubquestions); $fn = 1; - /*$answer = "\n\n" - . "\t\n" - . "\n\t\n";*/ - $answer = "\n
\n" - . "\t\n" - . "\n\t\n"; + + $answer = Yii::app()->getController()->renderPartial( + '/survey/questions/arrays/yesnouncertain/header', + array('answerwidth'=>$answerwidth, 'extraclass'=>$extraclass), true); + $odd_even = ''; for ($xc=1; $xc<=3; $xc++) { $odd_even = alternation($odd_even); - //$answer .= "\n"; - $answer .= "\n"; + $answer .= Yii::app()->getController()->renderPartial('/survey/questions/arrays/yesnouncertain/col', array('odd_even'=>$odd_even,'cellwidth'=>$cellwidth), true); } if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory { $odd_even = alternation($odd_even); - //$answer .= "\n"; - $answer .= "\n"; - } - $answer .= "\t\n\n" - . "\t\n\n" - . "\t\n" - . "\t\n" - . "\t\n" - . "\t\n"; - if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) //Question is not mandatory - { - $answer .= "\t\n"; + $answer .= Yii::app()->getController()->renderPartial('/survey/questions/arrays/yesnouncertain/col', array('odd_even'=>$odd_even,'cellwidth'=>$cellwidth, 'no_answer'=>true ), true); } - $answer .= "\n\t"; - $answer_t_content = ''; + + $no_answer = ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1)?true:false; + $answer .= Yii::app()->getController()->renderPartial('/survey/questions/arrays/yesnouncertain/thead', array('no_answer'=>$no_answer, 'anscount'=>$anscount), true); + + $answer_t_content = ''; if ($anscount==0) { $inputnames=array(); - $answer.="\t\n\n"; } else { @@ -4261,88 +4251,41 @@ function do_array_yesnouncertain($ia) $myfname = $ia[1].$ansrow['title']; $answertext = $ansrow['question']; /* Check the sub question mandatory violation */ - if ($ia[6]=='Y' && in_array($myfname, $aMandatoryViolationSubQ)) - { - //$answertext = "{$answertext}"; - $answertext =' - '; - - } + $error = ($ia[6]=='Y' && in_array($myfname, $aMandatoryViolationSubQ))?true:false; $trbc = alternation($trbc , 'row'); // Get array_filter stuff - list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc answers-list radio-list"); - - $answer_t_content .= $htmltbody2; + //list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, $trbc, $myfname,"tr","$trbc answers-list radio-list"); + $sDisplayStyle = return_display_style($ia, $aQuestionAttributes, $thissurvey, $myfname); - $answer_t_content .= "\t\n" - . "\t\n" - . "\t\n" - . "\t\n"; + $no_answer = ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1)?true:false; + $value = (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname])) ? $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] : ''; + $Ychecked = (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == 'Y')?'CHECKED':''; + $Uchecked = (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == 'U')?'CHECKED':''; + $Nchecked = (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]) && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == 'N')?'CHECKED':''; + $NAchecked = (!isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]) || $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] == '')?'CHECKED':''; + + + $answer_t_content .= Yii::app()->getController()->renderPartial('/survey/questions/arrays/yesnouncertain/tr', array( + 'myfname'=> $myfname, + 'sDisplayStyle'=> $sDisplayStyle, + 'answertext'=> $answertext, + 'Ychecked'=> $Ychecked, + 'Uchecked'=> $Uchecked, + 'Nchecked'=>$Nchecked, + 'NAchecked'=>$NAchecked, + 'value'=>$value, + 'checkconditionFunction'=>$checkconditionFunction, + 'error'=>$error, + 'no_answer'=>$no_answer, + ), true); - if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) - { - $answer_t_content .= "\t\n"; - // --> END NEW FEATURE - SAVE - } - $answer_t_content .= ""; $inputnames[]=$myfname; $fn++; } } - $answer .= $answer_t_content . "\t\n\n
 ".gT('Yes')."".gT('Uncertain')."".gT('No')."".gT('No answer')."
".gT('Error: This question has no answers.')."
\n" - . $hiddenfield - . "\t\t\t\t$answertext\n" - . "\t\n" - . "\n" - . "\n" - . "\t
\n"; + //$answer .= $answer_t_content . "\t\n\n\n"; + $answer .= $answer_t_content . Yii::app()->getController()->renderPartial('/survey/questions/arrays/yesnouncertain/close_table', array(), true); return array($answer, $inputnames); } diff --git a/application/views/survey/questions/arrays/yesnouncertain/close_table.php b/application/views/survey/questions/arrays/yesnouncertain/close_table.php new file mode 100644 index 00000000000..7932872fd7a --- /dev/null +++ b/application/views/survey/questions/arrays/yesnouncertain/close_table.php @@ -0,0 +1,3 @@ + + + diff --git a/application/views/survey/questions/arrays/yesnouncertain/col.php b/application/views/survey/questions/arrays/yesnouncertain/col.php new file mode 100644 index 00000000000..6788ada1551 --- /dev/null +++ b/application/views/survey/questions/arrays/yesnouncertain/col.php @@ -0,0 +1,10 @@ + + +" style='width: %;' /> diff --git a/application/views/survey/questions/arrays/yesnouncertain/header.php b/application/views/survey/questions/arrays/yesnouncertain/header.php new file mode 100644 index 00000000000..019720ce8a2 --- /dev/null +++ b/application/views/survey/questions/arrays/yesnouncertain/header.php @@ -0,0 +1,12 @@ + + + + + diff --git a/application/views/survey/questions/arrays/yesnouncertain/thead.php b/application/views/survey/questions/arrays/yesnouncertain/thead.php new file mode 100644 index 00000000000..5fb9cb0d768 --- /dev/null +++ b/application/views/survey/questions/arrays/yesnouncertain/thead.php @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/application/views/survey/questions/arrays/yesnouncertain/tr.php b/application/views/survey/questions/arrays/yesnouncertain/tr.php new file mode 100644 index 00000000000..1bfbe812228 --- /dev/null +++ b/application/views/survey/questions/arrays/yesnouncertain/tr.php @@ -0,0 +1,90 @@ + + +> + + + + + + + + + + + + + + + + +
 
+ +
+ + + + + + + + + + + + +