From 20dd6bc42e7996970cb1a30e45e5f83ba95e2d41 Mon Sep 17 00:00:00 2001
From: LouisGac
Date: Mon, 21 Mar 2016 12:15:54 +0100
Subject: [PATCH 1/4] Dev: added view for list_dropdown other option.
---
application/helpers/qanda_helper.php | 103 ++----------------
.../questions/list_dropdown/othertext.php | 39 +++++++
2 files changed, 50 insertions(+), 92 deletions(-)
create mode 100644 application/views/survey/questions/list_dropdown/othertext.php
diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php
index fd87650d8e1..64335421318 100644
--- a/application/helpers/qanda_helper.php
+++ b/application/helpers/qanda_helper.php
@@ -178,7 +178,8 @@ function retrieveAnswers($ia)
case 'R': //RANKING STYLE
$values=do_ranking($ia);
break;
- case 'M': //Multiple choice checkbox
+
+ case 'M': //Multiple choice checkbox
$values=do_multiplechoice($ia);
if (count($values[1]) > 1 && $aQuestionAttributes['hide_tip']==0)
{
@@ -455,7 +456,6 @@ function file_validation_message($ia)
// TMSW Validation -> EM
function mandatory_popup($ia, $notanswered=null)
{
-
//This sets the mandatory popup message to show if required
//Called from question.php, group.php or survey.php
if ($notanswered === null) {unset($notanswered);}
@@ -484,7 +484,6 @@ function mandatory_popup($ia, $notanswered=null)
// TMSW Validation -> EM
function validation_popup($ia, $notvalidated=null)
{
-
//This sets the validation popup message to show if required
//Called from question.php, group.php or survey.php
if ($notvalidated === null) {unset($notvalidated);}
@@ -655,54 +654,6 @@ function return_timer_script($aQuestionAttributes, $ia, $disable=null)
return $output;
}
-/**
- * This function returns the default nb-col for bootstrap, based on the length of labels
- */
-function return_object_nb_cols($ansresult, $minLabelSize = 11, $minInputSize=1)
-{
- // We first check that $minLabelSize and $minInputSize are coherent with a 12 column grid
- // We give the priority to defined label size
- if (($minLabelSize + $minInputSize) > 12)
- $minInputSize = 12 - $minLabelSize;
-
- $nbColLabelLgLog=0;
-
- // We define the same col-lg and col-xs for all labels/inputs, on the base of the bigger one.
- foreach ($ansresult as $ansrow)
- {
- // We calculate the needed row to fully display the label
- $nbCol = round(strlen($ansrow['question'])/10)+1;
- $nbColLabelLg = ($nbCol > $minLabelSize)?$minLabelSize:$nbCol;
-
- // If it's the largest one until now, we log it.
- if ($nbColLabelLg > $nbColLabelLgLog)
- $nbColLabelLgLog = $nbColLabelLg;
-
- }
-
- // We define the XS label size on the base of the LG width
- $nbColLabelXs = $nbColLabelLgLog + 5;
- $nbColLabelXs = ($nbColLabelXs > 11)?11:$nbColLabelXs;
-
- // The input width is defined on the base of the label width
- $nbColInputLg = 12 - $nbColLabelLgLog;
- $nbColInputLg = ($nbColInputLg < 1)?12:$nbColInputLg;
-
- $nbColInputXs = 12 - $nbColLabelXs;
- $nbColInputXs = ($nbColInputXs < 1)?12:$nbColInputXs;
-
- // We store the datas in an object before returning them
- $oNbCols = new stdClass();
- $oNbCols->nbColLabelXs = $nbColLabelXs;
- $oNbCols->nbColLabelLg = $nbColLabelLgLog;
- $oNbCols->nbColInputXs = $nbColInputXs;
-
- $oNbCols->nbColInputLg = $nbColInputLg;
-
-
- return $oNbCols;
-}
-
function return_display_style($ia, $aQuestionAttributes, $thissurvey, $rowname)
{
$htmltbody2 = '';
@@ -1461,51 +1412,19 @@ function do_list_dropdown($ia)
if (isset($other) && $other=='Y')
{
- $answer .= "\n\n";
- $answer .= ' ';
- $answer .= ' getConfig('surveyID')][$thisfieldname])) { $answer .= ' value="'.htmlspecialchars($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$thisfieldname],ENT_QUOTES).'" ';}
- // // --> END BUG FIX
-
- // --> START NEW FEATURE - SAVE
- $answer .= " alt='".gT('Other answer')."' onchange='$checkconditionFunction(this.value, this.name, this.type);'";
+ $aData = array();
+ $aData['name']= $ia[1];
+ $aData['checkconditionFunction']=$checkconditionFunction;
+ $aData['display'] = ($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$ia[1]] != '-oth-')?'display: none;':'';
$thisfieldname="$ia[1]other";
- if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$thisfieldname])) { $answer .= " value='".htmlspecialchars($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$thisfieldname],ENT_QUOTES)."' ";}
- $answer .= ' />';
- $answer .= "
";
- // --> END NEW FEATURE - SAVE
- $inputnames[]=$ia[1]."other";
- }
+ $aData['value'] = (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$thisfieldname]))?htmlspecialchars($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$thisfieldname],ENT_QUOTES):'';
+ $answer .= Yii::app()->getController()->renderPartial('/survey/questions/list_dropdown/othertext', $aData, true);
+ $inputnames[]=$ia[1].'other';
+ // TODO: check if needed : $answer .= "";
+ }
$inputnames[]=$ia[1];
diff --git a/application/views/survey/questions/list_dropdown/othertext.php b/application/views/survey/questions/list_dropdown/othertext.php
new file mode 100644
index 00000000000..7c3b8c28287
--- /dev/null
+++ b/application/views/survey/questions/list_dropdown/othertext.php
@@ -0,0 +1,39 @@
+
+
+
+'
+ onchange='(this.value, this.name, this.type);'
+/>
From 9f9ceac23427e94e0a296139150b61080239497b Mon Sep 17 00:00:00 2001
From: LouisGac
Date: Mon, 21 Mar 2016 12:22:44 +0100
Subject: [PATCH 2/4] Dev: input type "columns" for question attribute
"display_columns"
---
application/helpers/common_helper.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php
index 3782ff288c5..8f28c0218f9 100644
--- a/application/helpers/common_helper.php
+++ b/application/helpers/common_helper.php
@@ -2781,7 +2781,8 @@ function questionAttributes($returnByName=false)
"types"=>"LM",
'category'=>gT('Display'),
'sortorder'=>100,
- 'inputtype'=>'integer',
+ //'inputtype'=>'integer',
+ 'inputtype'=>'columns',
'default'=>'1',
'min'=>'1',
'max'=>'100',
From 178fb70459f81c61db3ed2063e82fe0fa8f4f5f2 Mon Sep 17 00:00:00 2001
From: LouisGac
Date: Tue, 22 Mar 2016 12:29:56 +0100
Subject: [PATCH 3/4] Dev: quanda cleaning, and views for array 5point question
type
---
application/helpers/common_helper.php | 14 +-
application/helpers/qanda_helper.php | 256 +++++++-----------
.../survey/questions/arrays/5point/close_row | 0
.../questions/arrays/5point/close_row.php | 1 +
.../questions/arrays/5point/close_table.php | 3 +
.../arrays/5point/close_table_head.php | 3 +
.../survey/questions/arrays/5point/col.php | 9 +
.../survey/questions/arrays/5point/header.php | 12 +
.../arrays/5point/open_table_head.php | 9 +
.../questions/arrays/5point/table_headers | 4 +
.../questions/arrays/5point/table_headers.php | 11 +
.../questions/arrays/5point/td_answertext.php | 9 +
.../questions/arrays/5point/td_input.php | 22 ++
.../questions/arrays/5point/tr_open.php | 19 ++
.../views/survey/questions/arrays/header.php | 14 -
.../survey/questions/listradio/item_row.php | 4 -
.../multiplechoice/item_other_row.php | 4 -
.../questions/multiplechoice/item_row.php | 4 -
.../views/survey/questions/ranking/script.php | 25 ++
templates/default/css/template.css | 13 +-
20 files changed, 245 insertions(+), 191 deletions(-)
create mode 100644 application/views/survey/questions/arrays/5point/close_row
create mode 100644 application/views/survey/questions/arrays/5point/close_row.php
create mode 100644 application/views/survey/questions/arrays/5point/close_table.php
create mode 100644 application/views/survey/questions/arrays/5point/close_table_head.php
create mode 100644 application/views/survey/questions/arrays/5point/col.php
create mode 100644 application/views/survey/questions/arrays/5point/header.php
create mode 100644 application/views/survey/questions/arrays/5point/open_table_head.php
create mode 100644 application/views/survey/questions/arrays/5point/table_headers
create mode 100644 application/views/survey/questions/arrays/5point/table_headers.php
create mode 100644 application/views/survey/questions/arrays/5point/td_answertext.php
create mode 100644 application/views/survey/questions/arrays/5point/td_input.php
create mode 100644 application/views/survey/questions/arrays/5point/tr_open.php
delete mode 100644 application/views/survey/questions/arrays/header.php
create mode 100644 application/views/survey/questions/ranking/script.php
diff --git a/application/helpers/common_helper.php b/application/helpers/common_helper.php
index 8f28c0218f9..6a158054fac 100644
--- a/application/helpers/common_helper.php
+++ b/application/helpers/common_helper.php
@@ -2783,9 +2783,9 @@ function questionAttributes($returnByName=false)
'sortorder'=>100,
//'inputtype'=>'integer',
'inputtype'=>'columns',
- 'default'=>'1',
+ 'default'=>'6',
'min'=>'1',
- 'max'=>'100',
+ 'max'=>'12',
"help"=>gT('The answer options will be distributed across the number of columns set here'),
"caption"=>gT('Display columns'));
@@ -3583,9 +3583,13 @@ function questionAttributes($returnByName=false)
"types"=>"KNSTUQ;",
'category'=>gT('Display'),
'sortorder'=>100,
- 'inputtype'=>'text',
- "help"=>gT('Width of text input box'),
- "caption"=>gT('Input box width'));
+ //'inputtype'=>'text',
+ 'inputtype'=>'columns',
+ 'default'=>'6',
+ 'min'=>'1',
+ 'max'=>'12',
+ "help"=>gT('Number of Bootstrap columns for the input box'),
+ "caption"=>gT('Input box columns'));
$qattributes["text_input_columns"]=array(
"types"=>"Q",
diff --git a/application/helpers/qanda_helper.php b/application/helpers/qanda_helper.php
index 64335421318..0a394204353 100644
--- a/application/helpers/qanda_helper.php
+++ b/application/helpers/qanda_helper.php
@@ -1471,21 +1471,9 @@ function do_list_radio($ia)
$anscount = ($other == 'Y') ? $anscount+1 : $anscount; //COUNT OTHER AS AN ANSWER FOR MANDATORY CHECKING!
$anscount = ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) ? $anscount+1 : $anscount; //Count up if "No answer" is showing
- //// Label and input width
- // TODO : use a question attribute var
-
- // label
- $nbColLabelXs = 10;
- $nbColLabelLg = 10;
-
- // Inputs
- $nbColInputXs = 1;
- $nbColInputLg = 1;
-
//// Columns containing answer rows, set by user in question attribute
/// TODO : move to a dedicated function
-
// setting variables
$iMaxRowsByColumn = 0; // How many answer rows by column
$iRowCount = 0;
@@ -1502,7 +1490,6 @@ function do_list_radio($ia)
// Then, we calculate how many answer rows in each column
$iMaxRowsByColumn = ceil($anscount / $iNbCols);
$first = true; // The very first item will open a bootstrap row containing the columns
-
}
$answer = Yii::app()->getController()->renderPartial('/survey/questions/listradio/listradio_header', array(), true);
@@ -1554,10 +1541,6 @@ function do_list_radio($ia)
'sDisplayStyle' => $sDisplayStyle,
'ia'=>$ia,
'ansrow'=>$ansrow,
- 'nbColLabelXs'=>$nbColLabelXs,
- 'nbColLabelLg'=>$nbColLabelLg,
- 'nbColInputLg'=>$nbColInputLg,
- 'nbColInputXs'=>$nbColInputXs,
'checkedState'=>$checkedState,
'myfname'=>$myfname,
);
@@ -1621,8 +1604,6 @@ function do_list_radio($ia)
$answer_other = ' value=""';
}
- //list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, array("code"=>"other"), $thisfieldname, $trbc, $myfname, "div", "form-group answer-item radio-item other-item other");
-
////
// Open Column
// The column is opened if user set more than one column in question attribute
@@ -1632,7 +1613,6 @@ function do_list_radio($ia)
{
$answer .= Yii::app()->getController()->renderPartial('/survey/questions/listradio/item_column_header', array('iColumnWidth' => $iColumnWidth, 'first'=>false), true);
}
-
$sDisplayStyle = return_display_style($ia, $aQuestionAttributes, $thissurvey, $myfname);
////
@@ -1643,11 +1623,7 @@ function do_list_radio($ia)
'answer_other'=>$answer_other,
'myfname'=>$myfname,
'sDisplayStyle' => $sDisplayStyle,
- 'nbColLabelXs'=>$nbColLabelXs,
- 'nbColLabelLg'=>$nbColLabelLg,
'othertext'=>$othertext,
- 'nbColInputLg'=>$nbColInputLg,
- 'nbColInputXs'=>$nbColInputXs,
'checkedState'=>$checkedState,
'kpclass'=>$kpclass,
'oth_checkconditionFunction'=>$oth_checkconditionFunction.'(this.value, this.name, this.type)',
@@ -1803,12 +1779,7 @@ function do_listwithcomment($ia)
}
$fname2 = $ia[1].'comment';
- if ($anscount > 8) {$tarows = $anscount/1.2;} else {$tarows = 4;}
- // --> START NEW FEATURE - SAVE
- // --> START ORIGINAL
- // $answer .= "\t