|
|
|
|
@ -1,14 +1,18 @@ |
|
|
|
|
<?php |
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* This file is part of student graph block plugin for dashboard, |
|
|
|
|
* it should be required inside dashboard controller for showing it into dashboard interface from plattform |
|
|
|
|
* @package chamilo.dashboard |
|
|
|
|
* @author Christian Fasanando |
|
|
|
|
* @author Julio Montoya <gugli100@gmail.com> |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* required files for getting data |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'course.lib.php'; |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php'; |
|
|
|
|
@ -78,8 +82,7 @@ class BlockStudentGraph extends Block { |
|
|
|
|
$data = array(); |
|
|
|
|
$students_attendance_graph = $this->get_students_attendance_graph(); |
|
|
|
|
|
|
|
|
|
$html = ' |
|
|
|
|
<li class="widget color-orange" id="intro"> |
|
|
|
|
$html = '<li class="widget color-orange" id="intro"> |
|
|
|
|
<div class="widget-head"> |
|
|
|
|
<h3>'.get_lang('StudentsInformationsGraph').'</h3> |
|
|
|
|
<div class="widget-actions"><a onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">'.Display::return_icon('close.gif',get_lang('Close')).'</a></div> |
|
|
|
|
@ -88,14 +91,10 @@ class BlockStudentGraph extends Block { |
|
|
|
|
<div style="padding:10px;"><strong>'.get_lang('AttendancesFaults').'</strong></div> |
|
|
|
|
'.$students_attendance_graph.' |
|
|
|
|
</div> |
|
|
|
|
</li> |
|
|
|
|
'; |
|
|
|
|
|
|
|
|
|
</li>'; |
|
|
|
|
$data['column'] = $column; |
|
|
|
|
$data['content_html'] = $html; |
|
|
|
|
|
|
|
|
|
return $data; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -104,22 +103,24 @@ class BlockStudentGraph extends Block { |
|
|
|
|
*/ |
|
|
|
|
public function get_students_attendance_graph() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$students = $this->students; |
|
|
|
|
$attendance = new Attendance(); |
|
|
|
|
|
|
|
|
|
// get data |
|
|
|
|
$attendances_faults_avg = array(); |
|
|
|
|
if (is_array($students) && count($students) > 0) { |
|
|
|
|
|
|
|
|
|
foreach ($students as $student) { |
|
|
|
|
$student_id = $student['user_id']; |
|
|
|
|
$student_info = api_get_user_info($student_id); |
|
|
|
|
//$student_info = api_get_user_info($student_id); |
|
|
|
|
// get average of faults in attendances by student |
|
|
|
|
$results_faults_avg = $attendance->get_faults_average_inside_courses($student_id); |
|
|
|
|
|
|
|
|
|
if (!empty($results_faults_avg)) { |
|
|
|
|
$attendances_faults_avg[$student_info['username']] = $results_faults_avg['porcent']; |
|
|
|
|
$attendances_faults_avg[$student['username']] = $results_faults_avg['porcent']; |
|
|
|
|
} else { |
|
|
|
|
$attendances_faults_avg[$student_info['username']] = 0; |
|
|
|
|
$attendances_faults_avg[$student['username']] = 0; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -138,6 +139,7 @@ class BlockStudentGraph extends Block { |
|
|
|
|
|
|
|
|
|
// Defining data |
|
|
|
|
$data_set = new pData; |
|
|
|
|
|
|
|
|
|
$data_set->AddPoint($faults,"Promedio"); |
|
|
|
|
$data_set->AddPoint($usernames,"Usuario"); |
|
|
|
|
$data_set->AddAllSeries(); |
|
|
|
|
@ -150,6 +152,7 @@ class BlockStudentGraph extends Block { |
|
|
|
|
$data = $data_set->GetData(); // return $this->DataDescription |
|
|
|
|
|
|
|
|
|
if ($cache->IsInCache($graph_id, $data_set->GetData())) { |
|
|
|
|
//if (0) { |
|
|
|
|
//if we already created the img |
|
|
|
|
$img_file = $cache->GetHash($graph_id, $data_set->GetData()); // image file with hash |
|
|
|
|
} else { |
|
|
|
|
@ -163,17 +166,20 @@ class BlockStudentGraph extends Block { |
|
|
|
|
// Initialise the graph |
|
|
|
|
$test = new MyHorBar(400,($height+30)); |
|
|
|
|
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 8); |
|
|
|
|
$test->setGraphArea(65,30,350,$height); |
|
|
|
|
$test->setGraphArea(100,30,370,$height); |
|
|
|
|
|
|
|
|
|
$test->drawFilledRoundedRectangle(7,7,393,$height,5,240,240,240); |
|
|
|
|
$test->drawRoundedRectangle(5,5,395,$height,5,230,230,230); |
|
|
|
|
$test->drawGraphArea(255,255,255,TRUE); |
|
|
|
|
$test->setFixedScale(0,100,5); |
|
|
|
|
|
|
|
|
|
//X axis |
|
|
|
|
$test->setFixedScale(0,100,10); |
|
|
|
|
//var_dump($data_set->GetDataDescription()); |
|
|
|
|
$test->drawHorScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2,TRUE); |
|
|
|
|
$test->setColorPalette(0,255,0,0); |
|
|
|
|
$test->drawHorGrid(10,TRUE,230,230,230,50); |
|
|
|
|
|
|
|
|
|
// Draw the 0 line |
|
|
|
|
//$Test->setFontProperties("Fonts/tahoma.ttf",6); |
|
|
|
|
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 6); |
|
|
|
|
$test->drawTreshold(0,143,55,72,TRUE,TRUE); |
|
|
|
|
|
|
|
|
|
@ -181,9 +187,11 @@ class BlockStudentGraph extends Block { |
|
|
|
|
$test->drawHorBarGraph($data_set->GetData(),$data_set->GetDataDescription(),FALSE); |
|
|
|
|
|
|
|
|
|
$cache->WriteToCache($graph_id, $data_set->GetData(), $test); |
|
|
|
|
|
|
|
|
|
ob_start(); |
|
|
|
|
$test->Stroke(); |
|
|
|
|
ob_end_clean(); |
|
|
|
|
|
|
|
|
|
$img_file = $cache->GetHash($graph_id, $data_set->GetData()); |
|
|
|
|
} |
|
|
|
|
if (!empty($img_file)) { |
|
|
|
|
@ -202,7 +210,5 @@ class BlockStudentGraph extends Block { |
|
|
|
|
function get_number_of_students() { |
|
|
|
|
return count($this->students); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
?> |