|
@@ -2897,7 +2897,6 @@ class SurveyUtil
|
|
|
* @todo the pagebreak and comment question types should not be shown => removed from $survey_data before
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
|
|
|
* @version February 2007 - Updated March 2008
|
|
|
- * @CSS Alex Aragon <alex.aragon@beeznest.com> - update January 2015
|
|
|
*/
|
|
|
public static function display_question_report($survey_data)
|
|
|
{
|
|
@@ -2909,11 +2908,13 @@ class SurveyUtil
|
|
|
|
|
|
// Determining the offset of the sql statement (the n-th question of the survey)
|
|
|
$offset = !isset($_GET['question']) ? 0 : intval($_GET['question']);
|
|
|
- $currentQuestion = isset($_GET['question']) ? $_GET['question'] : 0;
|
|
|
+ $currentQuestion = isset($_GET['question']) ? intval($_GET['question']) : 0;
|
|
|
$question = array();
|
|
|
+ $surveyId = intval($_GET['survey_id']);
|
|
|
+ $action = Security::remove_XSS($_GET['action']);
|
|
|
|
|
|
echo '<div class="actions">';
|
|
|
- echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.
|
|
|
+ echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.$surveyId.'">'.
|
|
|
Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ReportingOverview'),'',ICON_SIZE_MEDIUM).'</a>';
|
|
|
echo '</div>';
|
|
|
|
|
@@ -2922,12 +2923,12 @@ class SurveyUtil
|
|
|
/* echo '<ul><li class="disabled"><a href="#">'.get_lang('Question').'</a></li>'; */
|
|
|
|
|
|
if ($currentQuestion != 0 ) {
|
|
|
- echo '<li><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.Security::remove_XSS($_GET['action']).'&'.api_get_cidreq().'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&question='.Security::remove_XSS($offset-1).'">'.get_lang('PreviousQuestion').'</a></li>';
|
|
|
+ echo '<li><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.$action.'&'.api_get_cidreq().'&survey_id='.$surveyId.'&question='.($offset-1).'">'.get_lang('PreviousQuestion').'</a></li>';
|
|
|
}
|
|
|
|
|
|
for ($i = 1; $i <= $survey_data['number_of_questions']; $i++) {
|
|
|
if ($offset != $i - 1) {
|
|
|
- echo '<li><a href="' . api_get_path(WEB_CODE_PATH) . 'survey/reporting.php?action=' . Security::remove_XSS($_GET['action']) . '&' . api_get_cidreq() . '&survey_id=' . Security::remove_XSS($_GET['survey_id']) . '&question=' . ($i - 1) . '">' . $i . '</a></li>';
|
|
|
+ echo '<li><a href="' . api_get_path(WEB_CODE_PATH) . 'survey/reporting.php?action=' . $action . '&' . api_get_cidreq() . '&survey_id=' . $surveyId . '&question=' . ($i - 1) . '">' . $i . '</a></li>';
|
|
|
} else {
|
|
|
echo '<li class="disabled"s><a href="#">' . $i . '</a></li>';
|
|
|
}
|
|
@@ -2936,7 +2937,7 @@ class SurveyUtil
|
|
|
}*/
|
|
|
}
|
|
|
if ($currentQuestion < ($survey_data['number_of_questions'] - 1)) {
|
|
|
- echo '<li><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.Security::remove_XSS($_GET['action']).'&'.api_get_cidreq().'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&question='.Security::remove_XSS($offset+1).'">'.get_lang('NextQuestion').'</li></a>';
|
|
|
+ echo '<li><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.$action.'&'.api_get_cidreq().'&survey_id='.$surveyId.'&question='.($offset+1).'">'.get_lang('NextQuestion').'</li></a>';
|
|
|
}
|
|
|
echo '</ul>';
|
|
|
echo '</div>';
|
|
@@ -3019,7 +3020,9 @@ class SurveyUtil
|
|
|
}
|
|
|
array_push($chartData, array('option' => $optionText, 'votes' => $votes));
|
|
|
}
|
|
|
- self::drawChart($chartData);
|
|
|
+ echo '<div id="chartContainer" class="span12">';
|
|
|
+ echo self::drawChart($chartData);
|
|
|
+ echo '</div>';
|
|
|
|
|
|
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/tag/jquery.fcbkcomplete.js" type="text/javascript" language="javascript"></script>';
|
|
|
|
|
@@ -3052,7 +3055,7 @@ class SurveyUtil
|
|
|
echo ' <td class="center">'.$value['option_text'].'</td>';
|
|
|
echo ' <td class="center">';
|
|
|
if ($absolute_number!=0){
|
|
|
- echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.Security::remove_XSS($_GET['action']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&question='.Security::remove_XSS($offset).'&viewoption='.$value['question_option_id'].'">'.$absolute_number.'</a>';
|
|
|
+ echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.$action.'&survey_id='.$surveyId.'&question='.$offset.'&viewoption='.$value['question_option_id'].'">'.$absolute_number.'</a>';
|
|
|
}else{
|
|
|
echo '0';
|
|
|
}
|
|
@@ -3064,7 +3067,7 @@ class SurveyUtil
|
|
|
if ($size > 0) {
|
|
|
echo '<div style="border:1px solid #264269; background-color:#aecaf4; height:10px; width:'.$size.'px"> </div>';
|
|
|
}else{
|
|
|
- echo '<div style="text-align: left;">'.get_lang("NoDataRegistered").'</div>';
|
|
|
+ echo '<div style="text-align: left;">'.get_lang("NoDataAvailable").'</div>';
|
|
|
}
|
|
|
echo ' </td>';
|
|
|
echo ' </tr>';
|
|
@@ -3096,7 +3099,7 @@ class SurveyUtil
|
|
|
echo '<ul>';
|
|
|
while ($row = Database::fetch_array($result)) {
|
|
|
$user_info = api_get_user_info($row['user']);
|
|
|
- echo '<li><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&survey_id='.Security::remove_XSS($_GET['survey_id']).'&user='.$row['user'].'">'.$user_info['complete_name'].'</a></li>';
|
|
|
+ echo '<li><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action=userreport&survey_id='.$surveyId.'&user='.$row['user'].'">'.$user_info['complete_name'].'</a></li>';
|
|
|
}
|
|
|
echo '</ul>';
|
|
|
echo '</div>';
|
|
@@ -3163,7 +3166,9 @@ class SurveyUtil
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
- self::drawChart($chartData, true);
|
|
|
+ echo '<div id="chartContainer" class="span12">';
|
|
|
+ echo self::drawChart($chartData, true);
|
|
|
+ echo '</div>';
|
|
|
|
|
|
// Displaying the table: headers
|
|
|
echo '<table class="data_table">';
|
|
@@ -3181,7 +3186,7 @@ class SurveyUtil
|
|
|
echo ' <tr>';
|
|
|
echo ' <td>'.$value['option_text'].'</td>';
|
|
|
echo ' <td>'.$i.'</td>';
|
|
|
- echo ' <td><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.Security::remove_XSS($_GET['action']).'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&question='.Security::remove_XSS($offset).'&viewoption='.$value['question_option_id'].'&value='.$i.'">'.$absolute_number.'</a></td>';
|
|
|
+ echo ' <td><a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?action='.$action.'&survey_id='.Security::remove_XSS($_GET['survey_id']).'&question='.Security::remove_XSS($offset).'&viewoption='.$value['question_option_id'].'&value='.$i.'">'.$absolute_number.'</a></td>';
|
|
|
echo ' <td>'.round($absolute_number/$number_of_answers*100, 2).' %</td>';
|
|
|
echo ' <td>';
|
|
|
$size = ($absolute_number/$number_of_answers*100*2);
|
|
@@ -4100,7 +4105,9 @@ class SurveyUtil
|
|
|
}
|
|
|
}
|
|
|
$tableHtml .= '</table>';
|
|
|
- self::drawChart($chartData, true);
|
|
|
+ echo '<div id="chartContainer" class="span12">';
|
|
|
+ echo self::drawChart($chartData, true);
|
|
|
+ echo '</div>';
|
|
|
echo $tableHtml;
|
|
|
}
|
|
|
}
|
|
@@ -5330,55 +5337,59 @@ class SurveyUtil
|
|
|
* @param boolean Tells if the chart has a serie. False by default
|
|
|
* @return void (direct output)
|
|
|
*/
|
|
|
- static function drawChart($chartData, $hasSerie = false)
|
|
|
+ public static function drawChart($chartData, $hasSerie = false)
|
|
|
{
|
|
|
- $htmlChart = '<div id="chartContainer" class="span12">'.
|
|
|
- api_get_js("d3/d3.v3.4.8.js").'
|
|
|
- <script src="http://dimplejs.org/dist/dimple.v2.1.0.min.js"></script>
|
|
|
+ $htmlChart = '';
|
|
|
+ if (api_browser_support("svg")) {
|
|
|
+ $htmlChart .= api_get_js("d3/d3.v3.4.8.js");
|
|
|
+ $htmlChart .= api_get_js("dimple.v2.1.2.min.js") . '
|
|
|
<script type="text/javascript">
|
|
|
var svg = dimple.newSvg("#chartContainer", "100%", 400);
|
|
|
var data = [';
|
|
|
- $serie = array();
|
|
|
- $order = array();
|
|
|
- foreach ($chartData as $chartDataElement) {
|
|
|
- $htmlChart .= '{"';
|
|
|
+ $serie = array();
|
|
|
+ $order = array();
|
|
|
+ foreach ($chartData as $chartDataElement) {
|
|
|
+ $htmlChart .= '{"';
|
|
|
+ if (!$hasSerie) {
|
|
|
+ $htmlChart .= get_lang("Option") . '":"' . $chartDataElement['option'] . '", "';
|
|
|
+ array_push($order, $chartDataElement['option']);
|
|
|
+ } else {
|
|
|
+ if (!is_array($chartDataElement['serie'])) {
|
|
|
+ $htmlChart .= get_lang("Option") . '":"' . $chartDataElement['serie'] . '", "' .
|
|
|
+ get_lang("Score") . '":"' . $chartDataElement['option'] . '", "';
|
|
|
+ array_push($serie, $chartDataElement['serie']);
|
|
|
+ } else {
|
|
|
+ $htmlChart .= get_lang("Serie") . '":"' . $chartDataElement['serie'][0] . '", "' .
|
|
|
+ get_lang("Option") . '":"' . $chartDataElement['serie'][1] . '", "' .
|
|
|
+ get_lang("Score") . '":"' . $chartDataElement['option'] . '", "';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $htmlChart .= get_lang("Votes") . '":"' . $chartDataElement['votes'] .
|
|
|
+ '"},';
|
|
|
+ }
|
|
|
+ rtrim($htmlChart, ",");
|
|
|
+ $htmlChart .= '];
|
|
|
+ var myChart = new dimple.chart(svg, data);
|
|
|
+ myChart.addMeasureAxis("y", "' . get_lang("Votes") . '");';
|
|
|
if (!$hasSerie) {
|
|
|
- $htmlChart .= get_lang("Option") . '":"' . $chartDataElement['option'] . '", "';
|
|
|
- array_push($order, $chartDataElement['option']);
|
|
|
- } else if (!is_array($chartDataElement['serie'])) {
|
|
|
- $htmlChart .= get_lang("Option") . '":"' . $chartDataElement['serie'] . '", "' .
|
|
|
- get_lang("Score") . '":"' . $chartDataElement['option'] . '", "';
|
|
|
- array_push($serie, $chartDataElement['serie']);
|
|
|
+ $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", "' . get_lang("Option") . '");
|
|
|
+ xAxisCategory.addOrderRule(' . json_encode($order) . ');
|
|
|
+ myChart.addSeries("' . get_lang("Option") . '", dimple.plot.bar);';
|
|
|
} else {
|
|
|
- $htmlChart .= get_lang("Serie") . '":"' . $chartDataElement['serie'][0] . '", "' .
|
|
|
- get_lang("Option") . '":"' . $chartDataElement['serie'][1] . '", "' .
|
|
|
- get_lang("Score") . '":"' . $chartDataElement['option'] . '", "';
|
|
|
+ if (!is_array($chartDataElement['serie'])) {
|
|
|
+ $serie = array_values(array_unique($serie));
|
|
|
+ $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", ["' . get_lang("Option") . '","' . get_lang("Score") . '"]);
|
|
|
+ xAxisCategory.addOrderRule(' . json_encode($serie) . ');
|
|
|
+ xAxisCategory.addGroupOrderRule("' . get_lang("Score") . '");
|
|
|
+ myChart.addSeries("' . get_lang("Option") . '", dimple.plot.bar);';
|
|
|
+ } else {
|
|
|
+ $htmlChart .= 'myChart.addCategoryAxis("x", ["' . get_lang("Option") . '","' . get_lang("Score") . '"]);
|
|
|
+ myChart.addSeries("' . get_lang("Serie") . '", dimple.plot.bar);';
|
|
|
+ }
|
|
|
}
|
|
|
- $htmlChart .= get_lang("Votes") . '":"' . $chartDataElement['votes'] .
|
|
|
- '"},';
|
|
|
- }
|
|
|
- rtrim($htmlChart, ",");
|
|
|
- $htmlChart .= '];
|
|
|
- var myChart = new dimple.chart(svg, data);
|
|
|
- myChart.addMeasureAxis("y", "'.get_lang("Votes").'");';
|
|
|
- if (!$hasSerie) {
|
|
|
- $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", "'.get_lang("Option").'");';
|
|
|
- $htmlChart .= 'xAxisCategory.addOrderRule('.json_encode($order).');';
|
|
|
- $htmlChart .= 'myChart.addSeries("'.get_lang("Option").'", dimple.plot.bar);';
|
|
|
-
|
|
|
- } else if (!is_array($chartDataElement['serie'])) {
|
|
|
- $serie = array_values(array_unique($serie));
|
|
|
- $htmlChart .= 'var xAxisCategory = myChart.addCategoryAxis("x", ["'.get_lang("Option").'","'.get_lang("Score").'"]);';
|
|
|
- $htmlChart .= 'xAxisCategory.addOrderRule('.json_encode($serie).');';
|
|
|
- $htmlChart .= 'xAxisCategory.addGroupOrderRule("'.get_lang("Score").'");';
|
|
|
- $htmlChart .= 'myChart.addSeries("'.get_lang("Option").'", dimple.plot.bar);';
|
|
|
- } else {
|
|
|
- $htmlChart .= 'myChart.addCategoryAxis("x", ["'.get_lang("Option").'","'.get_lang("Score").'"]);';
|
|
|
- $htmlChart .= 'myChart.addSeries("'.get_lang("Serie").'", dimple.plot.bar);';
|
|
|
+ $htmlChart .= 'myChart.draw();
|
|
|
+ </script>';
|
|
|
}
|
|
|
- $htmlChart .= 'myChart.draw();
|
|
|
- </script>
|
|
|
- </div>';
|
|
|
- echo $htmlChart;
|
|
|
+ return $htmlChart;
|
|
|
}
|
|
|
}
|