Skip to content

Commit

Permalink
Dev: cleaning, create subview & helper function for statistics view
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Dec 17, 2015
1 parent ac73d50 commit d4de2c0
Show file tree
Hide file tree
Showing 13 changed files with 1,398 additions and 1,349 deletions.
21 changes: 20 additions & 1 deletion application/controllers/admin/statistics.php
Expand Up @@ -447,6 +447,7 @@ public function run($surveyid = 0, $subaction = null)
// ----------------------------------- END FILTER FORM ---------------------------------------

Yii::app()->loadHelper('admin/statistics');
$helper = new statistics_helper();
$showtextinline=isset($_POST['showtextinline']) ? 1 : 0;
$aData['showtextinline'] = $showtextinline;

Expand All @@ -457,7 +458,7 @@ public function run($surveyid = 0, $subaction = null)
$aData['usegraph'] = $usegraph;
$outputType = $_POST['outputtype'];

$helper = new statistics_helper();

switch($outputType){
case 'html':
$statisticsoutput .= $helper->generate_statistics($surveyid,$summary,$summary,$usegraph,$outputType,'DD',$statlang);
Expand All @@ -476,10 +477,28 @@ public function run($surveyid = 0, $subaction = null)

} //end if -> show summary results

$usegraph=isset($_POST['usegraph']) ? 1 : 0;
$aData['usegraph'] = $usegraph;

$aData['sStatisticsLanguage']=$statlang;
$aData['output'] = $statisticsoutput;
$aData['summary'] = $summary;


$error = '';
if (!function_exists("gd_info"))
{
$error .= '<br />'.gT('You do not have the GD Library installed. Showing charts requires the GD library to function properly.');
$error .= '<br />'.gT('visit http://us2.php.net/manual/en/ref.image.php for more information').'<br />';
}
else if (!function_exists("imageftbbox")) {
$error .= '<br />'.gT('You do not have the Freetype Library installed. Showing charts requires the Freetype library to function properly.');
$error .= '<br />'.gT('visit http://us2.php.net/manual/en/ref.image.php for more information').'<br />';
}

$aData['error'] = $error;
$aData['oStatisticsHelper'] = $helper;

$this->_renderWrappedTemplate('export', 'statistics_view', $aData);

}
Expand Down
35 changes: 35 additions & 0 deletions application/helpers/admin/statistics_helper.php
Expand Up @@ -3654,5 +3654,40 @@ function _listcolumn($surveyid, $column, $sortby="", $sortmethod="", $sorttype="
return $output;
}

/* This function builds the text description of eqch question in the filter section
*
* @param string $hinttext The question text
*
* */
public static function _showSpeaker($hinttext)
{
global $maxchars; //Where does this come from? can it be replaced? passed with function call?
if(!isset($maxchars))
{
$maxchars = 100;
}
$htmlhinttext=str_replace("'",'&#039;',$hinttext); //the string is already HTML except for single quotes so we just replace these only
$jshinttext=javascriptEscape($hinttext,true,true); //Build a javascript safe version of the string

if(strlen($hinttext) > ($maxchars))
{
$shortstring = flattenText($hinttext);

$shortstring = htmlspecialchars(mb_strcut(html_entity_decode($shortstring,ENT_QUOTES,'UTF-8'), 0, $maxchars, 'UTF-8'));

//output with hoover effect
$reshtml= "<span style='cursor: pointer' title='".$htmlhinttext."' "
." onclick=\"alert('".gT("Question","js").": $jshinttext')\">"
." \"$shortstring...\" </span>"
."<span class='icon-assessments' style='cursor: pointer' ></span>"
." onclick=\"alert('".gT("Question","js").": $jshinttext')\" />";
}
else
{
$reshtml= "<span style='cursor: pointer' title='".$htmlhinttext."'> \"$htmlhinttext\"</span>";
}
return $reshtml;
}

}
@@ -0,0 +1,51 @@
<fieldset style='clear:both;'>
<legend><?php eT("Data selection"); ?></legend>

<div class="form-group">
<label for='completionstate' class="col-sm-5 control-label"><?php eT("Include:"); ?> </label>

<div class="col-sm-5">
<select name='completionstate' id='completionstate' class='form-control'>
<option value='all' <?php echo $selectshow; ?>><?php eT("All responses"); ?></option>
<option value='complete' <?php echo $selecthide; ?> > <?php eT("Completed responses only"); ?></option>
<option value='incomplete' <?php echo $selectinc; ?> > <?php eT("Incomplete responses only"); ?></option>
</select>
</div>
</div>

<div class='form-group'>
<label class="col-sm-5 control-label" for='viewsummaryall'><?php eT("View summary of all available fields"); ?></label>
<div class='col-sm-7'>
<input type='checkbox' id='viewsummaryall' name='viewsummaryall' <?php if (isset($_POST['viewsummaryall'])) { echo "checked='checked'";} ?> />
</div>
</div>

<div class='form-group'>
<label class="col-sm-5 control-label" id='noncompletedlbl' for='noncompleted' title='<?php eT("Count stats for each question based only on the total number of responses for which the question was displayed"); ?>'><?php eT("Subtotals based on displayed questions"); ?></label>
<div class='col-sm-7'>
<input type='checkbox' id='noncompleted' name='noncompleted' <?php if (isset($_POST['noncompleted'])) {echo "checked='checked'"; } ?> />
</div>
</div>

<?php
$language_options="";
foreach ($survlangs as $survlang)
{
$language_options .= "\t<option value=\"{$survlang}\"";
if ($sStatisticsLanguage == $survlang)
{
$language_options .= " selected=\"selected\" " ;
}
$temp = getLanguageNameFromCode($survlang,true);
$language_options .= ">".$temp[1]."</option>\n";
}

?>

<div class='form-group'>
<label for='statlang' class="col-sm-5 control-label" ><?php eT("Statistics report language"); ?></label>
<div class='col-sm-5'>
<select name="statlang" id="statlang" class="form-control"><?php echo $language_options; ?></select>
</div>
</div>
</fieldset>
11 changes: 11 additions & 0 deletions application/views/admin/export/statistics_subviews/_header.php
@@ -0,0 +1,11 @@
<div class='header statistics col-lg-12 box text-left'>
<div style='float:right;'>
<span id='showgfilter' alt='<?php eT("Maximize"); ?>' class="icon-maximize" ></span>
<span id='hidegfilter' alt='<?php eT("Minimize"); ?>' class="icon-minimize" ></span>
</div>

<div style='float:left;'>
<?php eT("General filters"); ?>
</div>

</div>
@@ -0,0 +1,21 @@
<fieldset>
<legend><?php eT("Select output format"); ?>:</legend>
<div class="form-group col-sm-12">
<label class="col-sm-5 control-label" for='outputtypehtml'>HTML</label>
<div class='col-sm-5'>
<input type='radio' id="outputtypehtml" name='outputtype' value='html' checked='checked' />
</div>
</div>
<div class="form-group col-sm-12">
<label class="col-sm-5 control-label" for='outputtypepdf'>PDF</label>
<div class='col-sm-5'>
<input type='radio' id="outputtypepdf" name='outputtype' value='pdf' />
</div>
</div>
<div class="form-group col-sm-12">
<label class="col-sm-5 control-label" for='outputtypexls'>Excel</label>
<div class='col-sm-5'>
<input type='radio' id="outputtypexls" onclick='nographs();' name='outputtype' value='xls' />
</div>
</div>
</fieldset>
@@ -0,0 +1,44 @@
<fieldset>
<legend><?php eT("Output options"); ?></legend>
<div class='form-group'>
<label for='showtextinline' class="col-sm-5 control-label" ><?php eT("Show text responses inline:") ?></label>
<div class='col-sm-5'>
<input type='checkbox' id='showtextinline' name='showtextinline'<?php if(isset($showtextinline) && $showtextinline == 1) {echo "checked='checked'"; } ?> />
</div>
</div>

<div class='form-group'>
<label for='usegraph' class="col-sm-5 control-label" ><?php eT("Show graphs"); ?></label>
<div class='col-sm-5'>
<input type='checkbox' id='usegraph' name='usegraph' <?php if (isset($usegraph) && $usegraph == 1) { echo "checked='checked'"; } ?> />
</div>
<?php if($error != '') { echo "<div id='grapherror' style='display:none'>$error<hr /></div>"; } ?>
</div>

<div class="form-group col-sm-12">
<div class="col-sm-offset-1 alert alert-info alert-dismissible" role="alert">
<button type="button" class="close limebutton" data-dismiss="alert" aria-label="Close"><span>×</span></button>
<?php eT("Each question has its own graph type defined in its advanced settings.");?>
<br/>
<?php eT("With chart type selector, you can force the use of graph type for all selected questions)");?>
</div>
</div>

<div class="form-group col-sm-12">
<label for='charttype' class="col-sm-5 control-label">
<?php eT('Chart type:');?>
</label>

<div class='col-sm-5'>
<select name="charttype" id='charttype' class="form-control">
<option value="default" selected="selected"><?php eT('as defined in questions\'s advanced setting');?></option>
<option value="0" ><?php eT('bar chart');?></option>
<option value="1"><?php eT('pie chart');?></option>
<option value="2"><?php eT('radar chart');?></option>
<option value="3"><?php eT('line chart');?></option>
<option value="4"><?php eT('polar chart');?></option>
<option value="5"><?php eT('doughnut chart');?></option>
</select>
</div>
</div>
</fieldset>

0 comments on commit d4de2c0

Please sign in to comment.