|
@@ -80,128 +80,6 @@ class FlatViewTable extends SortableTable
|
|
|
return $this->mainCourseCategory;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Display the graph of the total results of all students
|
|
|
- * */
|
|
|
- public function display_graph()
|
|
|
- {
|
|
|
- include_once api_get_path(LIBRARY_PATH) . 'pchart/pData.class.php';
|
|
|
- include_once api_get_path(LIBRARY_PATH) . 'pchart/pChart.class.php';
|
|
|
- include_once api_get_path(LIBRARY_PATH) . 'pchart/pCache.class.php';
|
|
|
-
|
|
|
- $header_name = $this->datagen->get_header_names();
|
|
|
- $total_users = $this->datagen->get_total_users_count();
|
|
|
-
|
|
|
- $img_file = '';
|
|
|
-
|
|
|
- if ($this->datagen->get_total_items_count() > 0 && $total_users > 0) {
|
|
|
- // Removing user names and total
|
|
|
- array_shift($header_name);
|
|
|
- array_shift($header_name);
|
|
|
- array_pop($header_name);
|
|
|
-
|
|
|
- $user_results = $this->datagen->get_data_to_graph();
|
|
|
-
|
|
|
- $pre_result = $new_result = array();
|
|
|
- $DataSet = new pData();
|
|
|
-
|
|
|
- //$pre_result total score of students
|
|
|
- //filling the Dataset
|
|
|
- foreach ($user_results as $result) {
|
|
|
- for ($i = 0; $i < count($header_name); $i++) {
|
|
|
- $pre_result[$i + 3]+= $result[$i + 1];
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- $i = 1;
|
|
|
- $show_draw = false;
|
|
|
- if ($total_users > 0) {
|
|
|
- foreach ($pre_result as $res) {
|
|
|
- $total = $res / ($total_users);
|
|
|
- if ($total != 0) {
|
|
|
- $show_draw = true;
|
|
|
- }
|
|
|
- $DataSet->AddPoint($total, "Serie" . $i);
|
|
|
- $DataSet->SetSerieName(strip_tags($header_name[$i - 1]), "Serie" . $i);
|
|
|
-
|
|
|
- // Dataset definition
|
|
|
- $DataSet->AddAllSeries();
|
|
|
- $DataSet->SetAbsciseLabelSerie();
|
|
|
- $i++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // Cache definition
|
|
|
- $Cache = new pCache();
|
|
|
- // the graph id
|
|
|
- $gradebook_id = intval($_GET['selectcat']);
|
|
|
- $graph_id = api_get_user_id() . 'AverageResultsVsResource' . $gradebook_id . api_get_course_id();
|
|
|
- $data = $DataSet->GetData();
|
|
|
-
|
|
|
- if ($show_draw) {
|
|
|
- if ($Cache->IsInCache($graph_id, $DataSet->GetData())) {
|
|
|
- //if (0) {
|
|
|
- //if we already created the img
|
|
|
- //echo 'in cache';
|
|
|
- $img_file = $Cache->GetHash($graph_id, $DataSet->GetData());
|
|
|
- } else {
|
|
|
- // if the image does not exist in the archive/ folder
|
|
|
- // Initialise the graph
|
|
|
- $angle = -30;
|
|
|
- $Test = new pChart(760, 360);
|
|
|
-
|
|
|
- // set font of the axes
|
|
|
- $Test->setFontProperties(api_get_path(LIBRARY_PATH) . "pchart/fonts/tahoma.ttf", 8);
|
|
|
-
|
|
|
- $Test = $Test->fixHeightByRotation($DataSet->GetData(), $DataSet->GetDataDescription(), $angle);
|
|
|
-
|
|
|
- //which schema of color will be used
|
|
|
- $quant_resources = count($data[0]) - 1;
|
|
|
- // Adding the color schemma
|
|
|
- if ($quant_resources < 8) {
|
|
|
- $Test->loadColorPalette(api_get_path(LIBRARY_PATH) . "pchart/palette/reduced.txt");
|
|
|
- } else {
|
|
|
- $Test->loadColorPalette(api_get_path(LIBRARY_PATH) . "pchart/palette/default.txt");
|
|
|
- }
|
|
|
-
|
|
|
- $Test->setGraphArea(50, 30, 610, 300);
|
|
|
-
|
|
|
- $Test->drawFilledRoundedRectangle(7, 7, $Test->XSize + 20, $Test->YSize - 30, 5, 240, 240, 240);
|
|
|
- //$Test->drawRoundedRectangle(5,5,790,330,5,230,230,230);
|
|
|
- //background color area & stripe or not
|
|
|
- $Test->drawGraphArea(255, 255, 255, TRUE);
|
|
|
- $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, 0, 1, FALSE);
|
|
|
-
|
|
|
- //background grid
|
|
|
- $Test->drawGrid(4, TRUE, 230, 230, 230, 50);
|
|
|
-
|
|
|
- // Draw the 0 line
|
|
|
- //$Test->setFontProperties(api_get_path(LIBRARY_PATH)."pchart/fonts/tahoma.ttf",6);
|
|
|
- //$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
|
|
|
- // Draw the bar graph
|
|
|
- $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
|
|
|
-
|
|
|
- //Set legend properties: width, height and text color and font
|
|
|
- $Test->setFontProperties(api_get_path(LIBRARY_PATH) . "pchart/fonts/tahoma.ttf", 9);
|
|
|
- $Test->drawLegend(620, 70, $DataSet->GetDataDescription(), 255, 255, 255);
|
|
|
-
|
|
|
- //Set title properties
|
|
|
- $Test->setFontProperties(api_get_path(LIBRARY_PATH) . "pchart/fonts/tahoma.ttf", 10);
|
|
|
- $Test->drawTitle(50, 22, get_lang('AverageResultsVsResource'), 50, 50, 80, 620);
|
|
|
-
|
|
|
- //------------------
|
|
|
- //echo 'not in cache';
|
|
|
- $Cache->WriteToCache($graph_id, $DataSet->GetData(), $Test);
|
|
|
- ob_start();
|
|
|
- $Test->Stroke();
|
|
|
- ob_end_clean();
|
|
|
- $img_file = $Cache->GetHash($graph_id, $DataSet->GetData());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return api_get_path(WEB_ARCHIVE_PATH) . $img_file;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
*
|
|
|
*/
|