Skip to content

Commit

Permalink
Dev: multiple short texts question, views
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jan 26, 2016
1 parent edb5207 commit a4d338a
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 49 deletions.
95 changes: 46 additions & 49 deletions application/helpers/qanda_helper.php
Expand Up @@ -2819,8 +2819,7 @@ function do_multipleshorttext($ia)
$tiwidth=$aQuestionAttributes['text_input_width'];
$tiwidth=($aQuestionAttributes['text_input_width']<=12)?$aQuestionAttributes['text_input_width']:12;
$extraclass .=" inputwidth".trim($aQuestionAttributes['text_input_width']);
//$col = ($aQuestionAttributes['text_input_width']<=12)?$aQuestionAttributes['text_input_width']:12;
//$extraclass .=" col-sm-".trim($col);

}
else
{
Expand Down Expand Up @@ -2867,11 +2866,8 @@ function do_multipleshorttext($ia)
$ansresult = dbExecuteAssoc($ansquery); //Checked
$aSubquestions = $ansresult->readAll();
$anscount = count($aSubquestions)*2;
//$answer .= "\t<input type='hidden' name='MULTI$ia[1]' value='$anscount'>\n";
$fn = 1;

$answer_main = '';

$label_width = 0;

if ($anscount==0)
Expand All @@ -2889,7 +2885,7 @@ function do_multipleshorttext($ia)

// label
$nbColLabelLg = $oNbCols->nbColLabelLg;

$answer = Yii::app()->getController()->renderPartial('/survey/questions/multipleshorttext/header', array(), true);
if (trim($aQuestionAttributes['display_rows'])!='')
{
//question attribute "display_rows" is set -> we need a textarea to be able to show several rows
Expand All @@ -2903,36 +2899,38 @@ function do_multipleshorttext($ia)
$ansrow['question'] = "&nbsp;";
}

//NEW: textarea instead of input=text field
list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li","question-item answer-item text-item".$extraclass);

//$answer_main .= "\t$htmltbody2\n"
$answer_main .= '<div class="form-group-row row">';
$answer_main .= " <label class='control-label col-sm-$nbColLabelLg ' for=\"answer$myfname\">{$ansrow['question']}</label>\n";
$answer_main .= ' <div class="col-sm-'.$tiwidth.' ">';
//. "\t<span>\n".$prefix."\n".'
$answer_main .= $prefix."\n".'
<textarea class="form-control textarea '.$kpclass.'" name="'.$myfname.'" id="answer'.$myfname.'"
rows="'.$drows.'" '.$maxlength.' onkeyup="'.$checkconditionFunction.'(this.value, this.name, this.type);">';

if($label_width < strlen(trim(strip_tags($ansrow['question']))))
{
$label_width = strlen(trim(strip_tags($ansrow['question'])));
}
//list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li","question-item answer-item text-item".$extraclass);
/* Check for array_filter */
$sDisplayStyle = return_display_style($ia, $aQuestionAttributes, $thissurvey, $myfname);

//. "\t<span>\n".$prefix."\n".'
if (isset($_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname]))
{
$dispVal = $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname];
if ($aQuestionAttributes['numbers_only']==1)
{
$dispVal = str_replace('.',$sSeparator,$dispVal);
}
$answer_main .= htmlspecialchars($dispVal);
$dispVal .= htmlspecialchars($dispVal);
}

$answer_main .= "</textarea>\n".$suffix."\n\t</div>\n";
//. "\t</li>\n";
$answer_main .= '</div>'; // form group row;
$itemTextareaDatas = array(
'alert'=>false,
'maxlength'=>'',
'extraclass'=>$extraclass,
'sDisplayStyle'=>$sDisplayStyle,
'prefix'=>$prefix,
'myfname'=>$myfname,
'labelText'=>$ansrow['question'],
'prefix'=>$prefix,
'kpclass'=>$kpclass,
'rows'=>$drows.' '.$maxlength,
'checkconditionFunction'=>$checkconditionFunction.'(this.value, this.name, this.type)',
'dispVal'=>$dispVal,
'suffix'=>$suffix,
);
$answer = Yii::app()->getController()->renderPartial('/survey/questions/multipleshorttext/item_textarea', $itemTextareaDatas, true);

$fn++;
$inputnames[]=$myfname;
Expand All @@ -2947,23 +2945,13 @@ function do_multipleshorttext($ia)
if ($ansrow['question'] == "") {$ansrow['question'] = "&nbsp;";}

// color code missing mandatory questions red
if ($ia[6]=='Y' && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] === '') {
//$ansrow['question'] = "<span class='errormandatory'>{$ansrow['question']}</span>";
$ansrow['question'] = '
<div class="alert alert-danger" role="alert">'.
$ansrow['question']
.'
</div>';
if ($ia[6]=='Y' && $_SESSION['survey_'.Yii::app()->getConfig('surveyID')][$myfname] === '')
{
$alert = true;
}

list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li","question-item answer-item text-item".$extraclass);

//$answer_main .= "\t$htmltbody2\n"
$answer_main .= '<div class="form-group-row row">';
$answer_main .= "<label class='control-label col-sm-$nbColLabelLg' for=\"col-sm-$nbColLabelLg answer$myfname\">{$ansrow['question']}</label>\n";
$answer_main .= ' <div class="col-sm-'.$tiwidth.' ">';
$answer_main .= $prefix."\n"
.'<input class="text '.$kpclass.' form-control" type="text" size="'.$tiwidth.'" name="'.$myfname.'" id="answer'.$myfname.'" value="';
$sDisplayStyle = return_display_style($ia, $aQuestionAttributes, $thissurvey, $myfname);
//list($htmltbody2, $hiddenfield)=return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $ansrow, $myfname, '', $myfname, "li","question-item answer-item text-item".$extraclass);

if($label_width < strlen(trim(strip_tags($ansrow['question']))))
{
Expand All @@ -2977,23 +2965,32 @@ function do_multipleshorttext($ia)
{
$dispVal = str_replace('.',$sSeparator,$dispVal);
}
$answer_main .= htmlspecialchars($dispVal,ENT_QUOTES,'UTF-8');
$dispVal = htmlspecialchars($dispVal,ENT_QUOTES,'UTF-8');
}

// --> START NEW FEATURE - SAVE
$answer_main .= '" onkeyup="'.$checkconditionFunction.'(this.value, this.name, this.type);" '.$maxlength.' />'."\n".$suffix."\n\t</div>\n"
. "\t</div>\n";
// --> END NEW FEATURE - SAVE

$itemInputextDatas = array(
'alert'=>$alert,
'maxlength'=>$maxlength,
'tiwidth'=>$tiwidth,
'extraclass'=>$extraclass,
'sDisplayStyle'=>$sDisplayStyle,
'prefix'=>$prefix,
'myfname'=>$myfname,
'labelText'=>$ansrow['question'],
'prefix'=>$prefix,
'kpclass'=>$kpclass,
'checkconditionFunction'=>$checkconditionFunction.'(this.value, this.name, this.type)',
'dispVal'=>$dispVal,
'suffix'=>$suffix,
);
$answer = Yii::app()->getController()->renderPartial('/survey/questions/multipleshorttext/item_inputext', $itemInputextDatas, true);
$fn++;
$inputnames[]=$myfname;
}

}
}

$answer = "<ul class=\"list-unstyled subquestions-list questions-list text-list\">\n".$answer_main."</ul>\n";

$answer .= Yii::app()->getController()->renderPartial('/survey/questions/multipleshorttext/footer', array(), true);
return array($answer, $inputnames);
}

Expand Down
@@ -0,0 +1,7 @@
<?php
/**
* Multiple short texts question, footer Html
*/
?>

</ul>
@@ -0,0 +1,6 @@
<?php
/**
* Multiple short texts question, header Html
*/
?>
<ul class="list-unstyled subquestions-list questions-list text-list">
@@ -0,0 +1,47 @@
<?php
/**
* Multiple short texts question, item input text Html
* @var $alert;
* @var $maxlength;
* @var $tiwidth
* @var $extraclass
* @var $sDisplayStyle
* @var $prefix
* @var $myfname
* @var $labelText $ansrow['question']
* @var $prefix
* @var $kpclass
* @var $rows $drows.' '.$maxlength
* @var $checkconditionFunction $checkconditionFunction.'(this.value, this.name, this.type)'
* @var $dispVal
* @var $suffix
*/
?>
<!-- question attribute "display_rows" is set -> we need a textarea to be able to show several rows -->
<li class="question-item answer-item text-item <?php echo $extraclass;?>" <?php echo $sDisplayStyle;?>>
<?php if($alert):?>
<div class="alert alert-danger errormandatory" role="alert">'.
<?php echo $labelText;?>
</div>

<?php endif;?>
<div class="form-group-row row">
<label class='control-label col-xs-12' for="answer<?php echo $myfname; ?>">
<?php echo $labelText;?>
</label>
<div class="col-xs-12">
<?php echo $prefix;?>
<input
class="text form-control <?php echo $kpclass;?>"
type="text"
size="<?php echo $tiwidth;?>"
name="<?php echo $myfname;?>"
id="answer<?php echo $myfname; ?>"
value="<?php echo $dispVal;?>"
onkeyup="<?php echo $checkconditionFunction; ?>"
<?php echo $maxlength; ?>
/>
<?php echo $suffix;?>
</div>
</div>
</li>
@@ -0,0 +1,37 @@
<?php
/**
* Multiple short texts question, item text area Html
* @var $extraclass
* @var $sDisplayStyle
* @var $prefix
* @var $myfname
* @var $labelText $ansrow['question']
* @var $prefix
* @var $kpclass
* @var $rows $drows.' '.$maxlength
* @var $checkconditionFunction $checkconditionFunction.'(this.value, this.name, this.type)'
* @var $dispVal
* @var $suffix
*/
?>
<!-- question attribute "display_rows" is set -> we need a textarea to be able to show several rows -->
<li class="question-item answer-item text-item <?php echo $extraclass;?>" <?php echo $sDisplayStyle;?>>
<div class="form-group-row row">
<label class='control-label col-xs-12' for="answer<?php echo $myfname; ?>">
<?php echo $labelText;?>
</label>
<div class="col-xs-12">
<?php echo $prefix;?>

<textarea
class="form-control textarea <?php echo $kpclass;?>"
name="<?php echo $myfname;?>"
id="answer<?php echo $myfname;?>"
rows="<?php echo $rows;?>"
onkeyup="<?php echo $checkconditionFunction; ?>"
>
<?php echo $dispVal;?>
</textarea>
<?php echo $suffix;?>
</div>
</li>

0 comments on commit a4d338a

Please sign in to comment.