Moving pchart in the vendors folder

skala
Julio Montoya 12 years ago
parent d27d057077
commit 5588fc58c2
  1. 43
      main/gradebook/gradebook_flatview.php
  2. 82
      main/gradebook/lib/fe/flatviewtable.class.php
  3. 155
      main/gradebook/lib/scoredisplay.class.php
  4. 24
      main/mySpace/access_details.php
  5. 5
      main/mySpace/myspace.lib.php
  6. 253
      plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php
  7. 152
      plugin/dashboard/block_student_graph/block_student_graph.class.php
  8. 7
      plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php

@ -14,7 +14,7 @@ $current_course_tool = TOOL_GRADEBOOK;
api_protect_course_script();
require_once 'lib/be.inc.php';
require_once 'lib/be.inc.php';
require_once 'lib/fe/dataform.class.php';
require_once 'lib/fe/userform.class.php';
require_once 'lib/flatview_data_generator.class.php';
@ -84,10 +84,10 @@ if ($simple_search_form->validate() && (empty($keyword))) {
if (!empty($keyword)) {
$users = find_students($keyword);
} else {
if (isset($alleval) && isset($alllinks)) {
$users = get_all_users($alleval, $alllinks);
$users = get_all_users($alleval, $alllinks);
} else {
$users = null;
}
@ -95,38 +95,39 @@ if (!empty($keyword)) {
$offset = isset($_GET['offset']) ? $_GET['offset'] : '0';
$flatviewtable = new FlatViewTable($cat[0], $users, $alleval, $alllinks, true, $offset, $addparams);
//$flatviewtable = new FlatViewTable($cat[0], $users, $alleval, $alllinks, true, $offset, $addparams);
$flatviewtable = new FlatViewTable($cat[0], $users, $alleval, $alllinks, true, $offset);
$parameters=array('selectcat'=>intval($_GET['selectcat']));
$flatviewtable->set_additional_parameters($parameters);
if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') {
if (isset($_GET['export_pdf']) && $_GET['export_pdf'] == 'category') {
$params = array();
$params['only_total_category'] = true;
$params['join_firstname_lastname'] = true;
$params['show_official_code'] = true;
$params['export_pdf'] = true;
$params['export_pdf'] = true;
if ($cat[0]->is_locked() == true || api_is_platform_admin()) {
Display :: set_header(null, false, false);
export_pdf_flatview($cat, $users, $alleval, $alllinks, $params);
}
}
if (isset($_GET['exportpdf'])) {
$interbreadcrumb[] = array (
'url' => api_get_self().'?selectcat=' . Security::remove_XSS($_GET['selectcat']),
'name' => get_lang('FlatView')
);
$export_pdf_form = new DataForm(DataForm::TYPE_EXPORT_PDF, 'export_pdf_form', null, api_get_self().'?exportpdf=&offset='.intval($_GET['offset']).'&selectcat='.intval($_GET['selectcat']), '_blank', '');
if ($export_pdf_form->validate()) {
if ($export_pdf_form->validate()) {
$params = array();
$params = $export_pdf_form->exportValues();
Display :: set_header(null, false, false);
$params['join_firstname_lastname'] = true;
$params['join_firstname_lastname'] = true;
$params['show_official_code'] = true;
$params['export_pdf'] = true;
$params['export_pdf'] = true;
$params['only_total_category'] = false;
export_pdf_flatview($cat, $users, $alleval, $alllinks, $params);
} else {
@ -138,9 +139,9 @@ if (isset ($_GET['print'])) {
$printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks);
echo print_table($printable_data[1],$printable_data[0], get_lang('FlatView'), $cat[0]->get_name());
exit;
}
if (!empty($_GET['export_report']) && $_GET['export_report'] == 'export_report') {
}
if (!empty($_GET['export_report']) && $_GET['export_report'] == 'export_report') {
if (api_is_platform_admin() || api_is_course_admin() || api_is_course_coach()) {
$user_id = null;
@ -153,7 +154,7 @@ if (!empty($_GET['export_report']) && $_GET['export_report'] == 'export_report')
require_once 'gradebook_result.class.php';
$printable_data = get_printable_data($cat[0], $users, $alleval, $alllinks);
switch($_GET['export_format']) {
case 'xls':
$export = new GradeBookResult();
@ -184,8 +185,8 @@ if (isset($_GET['search'])) {
$this_section = SECTION_COURSES;
if (isset($_GET['exportpdf'])) {
$export_pdf_form->display();
if (isset($_GET['exportpdf'])) {
$export_pdf_form->display();
} else {
Display :: display_header(get_lang('FlatView'));
}
@ -195,16 +196,16 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false') {
$flatviewtable->display();
} elseif (isset($_GET['selectcat']) && ($_SESSION['studentview'] == 'teacherview')) {
DisplayGradebook :: display_header_reduce_flatview($cat[0], $showeval, $showlink, $simple_search_form);
// main graph
$flatviewtable->display();
$flatviewtable->display();
// @todo this needs a fix
//$image_file = $flatviewtable->display_graph();
//@todo load images with jquery
echo '<div id="contentArea" style="text-align: center;" >';
echo '<div id="contentArea" style="text-align: center;" >';
if (!empty($image_file)) {
echo '<img src="'.$image_file.'">';
}
}
$flatviewtable->display_graph_by_resource();
echo '</div>';
}

@ -31,14 +31,14 @@ class FlatViewTable extends SortableTable
function FlatViewTable ($selectcat, $users= array (), $evals= array (), $links= array (), $limit_enabled = false, $offset = 0, $addparams = null) {
parent :: __construct ('flatviewlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 1 : 0);
$this->datagen = new FlatViewDataGenerator($users, $evals, $links);
$this->selectcat = $selectcat;
$this->limit_enabled = $limit_enabled;
$this->offset = $offset;
if (isset ($addparams)) {
$this->set_additional_parameters($addparams);
}
// step 2: generate rows: students
$this->datagen->category = $this->selectcat;
}
@ -47,26 +47,23 @@ class FlatViewTable extends SortableTable
* Display the graph of the total results of all students
* */
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) {
@ -76,15 +73,15 @@ class FlatViewTable extends SortableTable
}
$i = 1;
$show_draw = false;
if ($total_users >0 ) {
if ($total_users >0 ) {
foreach($pre_result as $res) {
$total = $res / ($total_users);
$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();
@ -93,12 +90,12 @@ class FlatViewTable extends SortableTable
}
// Cache definition
$Cache = new pCache();
$Cache = new pCache(api_get_path(SYS_ARCHIVE_PATH));
// 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) {
@ -130,7 +127,7 @@ class FlatViewTable extends SortableTable
//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);
@ -163,9 +160,6 @@ class FlatViewTable extends SortableTable
}
function display_graph_by_resource() {
require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php';
require_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();
@ -176,13 +170,13 @@ class FlatViewTable extends SortableTable
array_shift($header_name);
//Removing last name
array_shift($header_name);
$displayscore = ScoreDisplay :: instance();
$customdisplays = $displayscore->get_custom_score_display_settings();
$customdisplays = $displayscore->get_custom_score_display_settings();
if (is_array($customdisplays) && count(($customdisplays))) {
$user_results = $this->datagen->get_data_to_graph2();
$user_results = $this->datagen->get_data_to_graph2();
$pre_result = $new_result = array();
$DataSet = new pData();
//filling the Dataset
@ -192,7 +186,7 @@ class FlatViewTable extends SortableTable
$pre_result[$i+3][]= $result[$i+1];
}
}
$i=0;
$show_draw = false;
$resource_list = array();
@ -202,11 +196,11 @@ class FlatViewTable extends SortableTable
rsort($res_array);
$pre_result2[] = $res_array;
}
//@todo when a display custom does not exist the order of the color does not match
//filling all the answer that are not responded with 0
rsort($customdisplays);
if ($total_users > 0) {
foreach($pre_result2 as $key=>$res_array) {
$key_list = array();
@ -214,22 +208,22 @@ class FlatViewTable extends SortableTable
$resource_list[$key][$user_result[1]] += 1;
$key_list[] = $user_result[1];
}
foreach ($customdisplays as $display) {
if (!in_array($display['display'], $key_list))
$resource_list[$key][$display['display']] = 0;
}
$i++;
}
}
//fixing $resource_list
$max = 0;
}
//fixing $resource_list
$max = 0;
$new_list = array();
foreach($resource_list as $key=>$value) {
$new_value = array();
foreach($customdisplays as $item) {
foreach($customdisplays as $item) {
if ($value[$item['display']] > $max) {
$max = $value[$item['display']];
}
@ -237,8 +231,8 @@ class FlatViewTable extends SortableTable
}
$new_list[] = $new_value;
}
$resource_list = $new_list;
$resource_list = $new_list;
$i = 1;
$j = 0;
@ -258,7 +252,7 @@ class FlatViewTable extends SortableTable
$DataSet->SetYAxisName(get_lang('Students'));
$show_draw = true;
// Cache definition
$Cache = new pCache();
$Cache = new pCache(api_get_path(SYS_ARCHIVE_PATH));
// the graph id
$gradebook_id = intval($_GET['selectcat']);
$graph_id = api_get_user_id().'ByResource'.$gradebook_id.api_get_course_id().api_get_session_id();
@ -290,12 +284,12 @@ class FlatViewTable extends SortableTable
//background color area & stripe or not
$Test->drawGraphArea(255,255,255,TRUE);
//Setting max height by default see #3296
if (!empty($max)) {
$Test->setFixedScale(0, $max);
$Test->setFixedScale(0, $max);
}
$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(), SCALE_ADDALLSTART0, 150,150,150, TRUE, 0, 0, FALSE);
//background grid
@ -433,7 +427,7 @@ class FlatViewTable extends SortableTable
.'?selectcat='.Security::remove_XSS($_GET['selectcat'])
.'&offset='.(($this->offset)-LIMIT)
.(isset($_GET['search'])?'&search='.Security::remove_XSS($_GET['search']):'').'">'
.Display::return_icon('action_prev.png', get_lang('PreviousPage'), array(), 32)
.Display::return_icon('action_prev.png', get_lang('PreviousPage'), array(), 32)
.'</a>';
} else {
$header .= Display::return_icon('action_prev_na.png', get_lang('PreviousPage'), array(), 32);
@ -442,7 +436,7 @@ class FlatViewTable extends SortableTable
// next X
$calcnext = (($this->offset+(2*LIMIT)) > $totalitems) ?
($totalitems-(LIMIT+$this->offset)) : LIMIT;
if ($calcnext > 0) {
$header .= '<a href="'.api_get_self()
.'?selectcat='.Security::remove_XSS($_GET['selectcat'])
@ -474,14 +468,14 @@ class FlatViewTable extends SortableTable
$header_names = $this->datagen->get_header_names($this->offset, $selectlimit);
$column = 0;
if ($is_western_name_order) {
$this->set_header($column++, $header_names[1]);
$this->set_header($column++, $header_names[0]);
} else {
$this->set_header($column++, $header_names[0]);
$this->set_header($column++, $header_names[1]);
}
}
while ($column < count($header_names)) {
$this->set_header($column, $header_names[$column], false);

@ -17,6 +17,7 @@ define('SCORE_DECIMAL', 5); // 0.50 (X/Y)
define('SCORE_BAR', 6); // Uses the Display::bar_progress function
define('SCORE_SIMPLE', 7); // X
//@todo where is number 6?
define('SCORE_IGNORE_SPLIT', 8); // ??
@ -30,6 +31,8 @@ define('SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS', 12); // X - Good!
define('SCORE_BOTH',1);
define('SCORE_ONLY_DEFAULT',2);
define('SCORE_ONLY_CUSTOM',3);
define('SCORE_ONLY_SCORE', 4);
/**
* Class to display scores according to the settings made by the platform admin.
@ -75,7 +78,7 @@ class ScoreDisplay
}
}
private $coloring_enabled;
private $color_split_value;
private $custom_enabled;
@ -90,29 +93,29 @@ class ScoreDisplay
if (!empty($category_id)) {
$this->category_id = $category_id;
}
//Loading portal settings + using standard functions
$value = api_get_setting('gradebook_score_display_coloring');
$value = $value['my_display_coloring'];
$value = $value['my_display_coloring'];
//Settting coloring
$this->coloring_enabled = $value == 'true' ? true : false;
if ($this->coloring_enabled) {
$value = api_get_setting('gradebook_score_display_colorsplit');
if (isset($value)) {
if (isset($value)) {
$this->color_split_value = $value;
}
}
//Setting custom enabled
$value = api_get_setting('gradebook_score_display_custom');
$value = $value['my_display_custom'];
$value = api_get_setting('gradebook_score_display_custom');
$value = $value['my_display_custom'];
$this->custom_enabled = $value == 'true' ? true : false;
if ($this->custom_enabled) {
if ($this->custom_enabled) {
$params = array('category = ? AND subkey = ?' => array('Gradebook', 'ranking'));
$displays = api_get_settings_params($params);
$portal_displays = array();
@ -122,48 +125,48 @@ class ScoreDisplay
$portal_displays[$data[0]] = array('score' => $data[0], 'display' =>$data[1]);
}
sort($portal_displays);
}
}
$this->custom_display = $portal_displays;
if (count($this->custom_display)>0) {
$value = api_get_setting('gradebook_score_display_upperlimit');
$value = $value['my_display_upperlimit'];
$this->upperlimit_included = $value == 'true' ? true : false;
$this->custom_display_conv = $this->convert_displays($this->custom_display);
$value = $value['my_display_upperlimit'];
$this->upperlimit_included = $value == 'true' ? true : false;
$this->custom_display_conv = $this->convert_displays($this->custom_display);
}
}
//If teachers can override the portal parameters
if (api_get_setting('teachers_can_change_score_settings') == 'true') {
//Load course settings
if ($this->custom_enabled) {
$this->custom_display = $this->get_custom_displays();
if (count($this->custom_display)> 0) {
$this->custom_display_conv = $this->convert_displays($this->custom_display);
}
$this->custom_display = $this->get_custom_displays();
if (count($this->custom_display)> 0) {
$this->custom_display_conv = $this->convert_displays($this->custom_display);
}
}
if ($this->coloring_enabled) {
$this->color_split_value = $this->get_score_color_percent();
}
}
}
/**
* Is coloring enabled ?
*/
public function is_coloring_enabled () {
return $this->coloring_enabled;
}
/**
* Is custom score display enabled ?
*/
public function is_custom() {
return $this->custom_enabled;
}
/**
* Is upperlimit included ?
*/
@ -245,15 +248,15 @@ class ScoreDisplay
}
$sql .= "(NULL, '".$display['score']."', '".Database::escape_string($display['display'])."', ".$category_id.", ".intval($scorecolpercent).")";
$count++;
}
}
Database::query($sql);
}
public function insert_defaults($category_id) {
if (empty($category_id)) {
return false;
}
//Get this from DB settings
$display = array(
50 => get_lang('GradebookFailed'),
@ -261,9 +264,9 @@ class ScoreDisplay
70 => get_lang('GradebookFair'),
80 => get_lang('GradebookGood'),
90 => get_lang('GradebookOutstanding'),
100 => get_lang('GradebookExcellent')
100 => get_lang('GradebookExcellent')
);
$tbl_display = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_SCORE_DISPLAY);
foreach($display as $value => $text) {
$params = array(
@ -272,26 +275,26 @@ class ScoreDisplay
'category_id' => $category_id,
'score_color_percent' => 0,
);
Database::insert($tbl_display, $params);
Database::insert($tbl_display, $params);
}
Database::query($sql);
Database::query($sql);
}
public function get_number_decimals() {
$number_decimals = api_get_setting('gradebook_number_decimals');
$number_decimals = api_get_setting('gradebook_number_decimals');
if (!isset($number_decimals)) {
$number_decimals = 0;
}
}
return $number_decimals;
}
/**
* Formats a number depending of the number of decimals
*
*
* @param float a score
* @return float the score formatted
*/
public function format_score($score) {
public function format_score($score) {
return floatval(number_format($score, $this->get_number_decimals()));
}
@ -303,38 +306,38 @@ class ScoreDisplay
* @param int $what one of the following constants: SCORE_BOTH, SCORE_ONLY_DEFAULT, SCORE_ONLY_CUSTOM (default: SCORE_BOTH)
* (only taken into account if custom score display is enabled and for course/platform admin)
*/
public function display_score($score, $type = SCORE_DIV_PERCENT, $what = SCORE_BOTH, $no_color = false) {
$my_score = $score == 0 ? 1 : $score;
public function display_score($score, $type = SCORE_DIV_PERCENT, $what = SCORE_BOTH, $no_color = false) {
$my_score = $score == 0 ? 1 : $score;
if ($type == SCORE_BAR) {
$percentage = $my_score[0]/$my_score[1]*100;
$percentage = $my_score[0]/$my_score[1]*100;
return Display::bar_progress($percentage, null, null, true);
}
if ($type == SCORE_SIMPLE) {
if ($type == SCORE_SIMPLE) {
$simple_score = $this->format_score($my_score[0]);
return $simple_score;
}
if ($this->custom_enabled && isset($this->custom_display_conv)) {
$display = $this->display_default($my_score, $type);
if ($this->custom_enabled && isset($this->custom_display_conv)) {
$display = $this->display_default($my_score, $type);
} else {
// if no custom display set, use default display
$display = $this->display_default($my_score, $type);
}
}
if ($this->coloring_enabled && $no_color == false) {
$my_score_denom = ($score[1]==0)?1:$score[1];
$my_score_denom = ($score[1]==0)?1:$score[1];
if (($score[0] / $my_score_denom) < ($this->color_split_value / 100)) {
$display = Display::tag('font', $display, array('color'=>'red'));
$display = Display::tag('font', $display, array('color'=>'red'));
//$display = Display::label($display, 'important');
}
}
}
return $display;
}
// Internal functions
private function display_default ($score, $type) {
private function display_default ($score, $type) {
switch ($type) {
case SCORE_DIV : // X / Y
return $this->display_as_div($score);
@ -345,7 +348,7 @@ class ScoreDisplay
case SCORE_AVERAGE : // XX %
return $this->display_as_percent($score);
case SCORE_DECIMAL : // 0.50 (X/Y)
return $this->display_as_decimal($score);
return $this->display_as_decimal($score);
case SCORE_DIV_PERCENT_WITH_CUSTOM : // X / Y (XX %) - Good!
$custom = $this->display_custom($score);
if (!empty($custom)) {
@ -357,7 +360,7 @@ class ScoreDisplay
if (!empty($custom)) {
$custom = ' - '.$custom;
}
return $this->display_simple_score($score).$custom;
return $this->display_simple_score($score).$custom;
break;
case SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS:
$custom = $this->display_custom($score);
@ -365,7 +368,7 @@ class ScoreDisplay
$custom = ' - '.$custom;
}
$score = $this->display_simple_score($score);
//needs sudo apt-get install php5-intl
if (class_exists(NumberFormatter)) {
$iso = api_get_language_isocode();
@ -374,21 +377,21 @@ class ScoreDisplay
$letters = api_strtoupper($letters);
$letters = " ($letters) ";
}
return $score.$letters.$custom;
return $score.$letters.$custom;
break;
case SCORE_CUSTOM: // Good!
return $this->display_custom($score);
}
}
private function display_simple_score($score) {
if (isset($score[0])) {
return $this->format_score($score[0]);
}
return '';
}
/**
* Returns "1" for array("100", "100");
*/
@ -396,20 +399,20 @@ class ScoreDisplay
$score_denom = ($score[1]==0) ? 1 : $score[1];
return $this->format_score($score[0]/$score_denom);
}
/**
* Returns "100 %" for array("100", "100");
*/
private function display_as_percent($score) {
$score_denom = ($score[1]==0) ? 1 : $score[1];
private function display_as_percent($score) {
$score_denom = ($score[1]==0) ? 1 : $score[1];
return $this->format_score($score[0]/$score_denom*100) . ' %';
}
/**
*
*
* Returns 10.00 / 10.00 for array("100", "100");
* @param array $score
*/
*/
private function display_as_div($score) {
if ($score == 1) {
return '0/0';
@ -419,12 +422,12 @@ class ScoreDisplay
return $score[0] . ' / ' . $score[1];
}
}
/**
*
* Depends in the user selections [0 50] Bad [50:100] Good
*
* Depends in the user selections [0 50] Bad [50:100] Good
* @param array $score
*/
*/
private function display_custom ($score) {
$my_score_denom= ($score[1]==0) ? 1 : $score[1];
$scaledscore = $score[0] / $my_score_denom;
@ -444,7 +447,7 @@ class ScoreDisplay
}
}
}
/**
* Get score color percent by category
@ -484,8 +487,8 @@ class ScoreDisplay
$sql = 'SELECT * FROM '.$tbl_display.' WHERE category_id = '.$category_id.' ORDER BY score';
$result = Database::query($sql);
return Database::store_result($result,'ASSOC');
}
}
/**
* Convert display settings to internally used values

@ -10,7 +10,7 @@
* @param string $course_code the course code
* @author Julio Montoya <gugli100@gmail.com>
* @author Jorge Frisancho Jibaja - select between dates
*
*
*/
/**
* Code
@ -21,10 +21,6 @@ $language_file = array ('registration', 'index', 'tracking');
require_once '../inc/global.inc.php';
// including additional libraries
require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php';
require_once 'myspace.lib.php';
// the section (for the tabs)
@ -57,7 +53,7 @@ $(function() {
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
if (foo){
var start_date = document.getElementById("date_from").value;
var end_date = document.getElementById("date_to").value;
@ -90,22 +86,22 @@ $(function() {
}
var foo_height = sliderGetHeight("#messages");
sliderSetHeight(".slider",foo_height);
controlSliderMenu(foo_height);
controlSliderMenu(foo_height);
// Hide confirmation message and enable stars for "Rate this" control, after 2 sec...
/*setTimeout(function(){
$("#messages").fadeOut(1000, function(){ui.enable()})
}, 2000);*/
}, "json");
$( "#cev_slider" ).empty();
// Create element to use for confirmation messages
$('.$quote_simple .'<div id="messages"/>'.$quote_simple .').appendTo("#cev_slider");
}
}
});
if (areBothFilled()){
runEffect();
runEffect();
}
});
@ -184,10 +180,10 @@ $form->display();
<div id="cev_cont_stats">
<?php
if ($result_to_print != "") {
$rst = get_stats($user_id, $course_code);
$rst = get_stats($user_id, $course_code);
$foo_stats = '<strong>'.get_lang('Total').': </strong>'.$rst['total'].'<br />';
$foo_stats .= '<strong>'.get_lang('Average').': </strong>'.$rst['avg'].'<br />';
$foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
$foo_stats .= '<strong>'.get_lang('Quantity').' : </strong>'.$rst['times'].'<br />';
echo $foo_stats;
} else {
echo Display::display_warning_message(get_lang('NoDataAvailable'));
@ -199,7 +195,7 @@ $form->display();
<div id="container-9">
<ul>
<li><a href="<?php echo api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail&type=day&course='.$course_code.'&student='.$user_id?>"><span> <?php echo api_ucfirst(get_lang('Day')); ?></span></a></li>
<li><a href="<?php echo api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail&type=month&course='.$course_code.'&student='.$user_id?>"><span> <?php echo api_ucfirst(get_lang('MinMonth')); ?></span></a></li>
<li><a href="<?php echo api_get_path(WEB_AJAX_PATH).'myspace.ajax.php?a=access_detail&type=month&course='.$course_code.'&student='.$user_id?>"><span> <?php echo api_ucfirst(get_lang('MinMonth')); ?></span></a></li>
</ul>
</div>
@ -212,7 +208,7 @@ $form->display();
echo $result_to_print;
} else {
Display::display_warning_message(get_lang('NoDataAvailable'));
}
}
?>
</div>
<?php

@ -1947,9 +1947,6 @@ function convert_to_string($sql_result){
* @return string
*/
function grapher($sql_result, $start_date, $end_date, $type = "") {
require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php';
if (empty($start_date)) { $start_date =""; }
if (empty($end_date)) { $end_date =""; }
@ -2008,7 +2005,7 @@ function grapher($sql_result, $start_date, $end_date, $type = "") {
$graph_id = api_get_user_id().'AccessDetails'.api_get_course_id().$start_date.$end_date.$type;
$data_set->AddAllSeries();
$cache = new pCache();
$cache = new pCache(api_get_path(SYS_ARCHIVE_PATH));
// the graph id
$data = $data_set->GetData();

@ -11,9 +11,6 @@
/**
* required files for getting data
*/
require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php';
@ -38,40 +35,40 @@ class BlockEvaluationGraph extends Block {
/**
* Constructor
*/
public function __construct ($user_id) {
public function __construct ($user_id) {
$this->path = 'block_evaluation_graph';
$this->user_id = $user_id;
$this->bg_width = 450;
$this->bg_height = 350;
if ($this->is_block_visible_for_user($user_id)) {
//$this->courses = CourseManager::get_real_course_list();
if ($this->is_block_visible_for_user($user_id)) {
//$this->courses = CourseManager::get_real_course_list();
/*if (api_is_platform_admin()) {
$this->courses = CourseManager::get_real_course_list();
$this->sessions = SessionManager::get_sessions_list();
} else {*/
} else {*/
if (!api_is_session_admin()) {
$this->courses = CourseManager::get_courses_followed_by_drh($user_id);
}
$this->courses = CourseManager::get_courses_followed_by_drh($user_id);
}
$this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
//}
//}
}
}
/**
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
public function is_block_visible_for_user($user_id) {
*/
public function is_block_visible_for_user($user_id) {
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
}
return $is_block_visible_for_user;
}
/**
@ -80,25 +77,25 @@ class BlockEvaluationGraph extends Block {
* @return array column and content html
*/
public function get_block() {
global $charset;
$column = 1;
$data = array();
$evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph();
$evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph();
$html = '<li class="widget color-orange" id="intro">
<div class="widget-head">
<h3>'.get_lang('EvaluationsGraph').'</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>
</div>
<div class="widget-content" align="center">';
</div>
<div class="widget-content" align="center">';
if (empty($evaluations_base_courses_graph) && empty($evaluations_courses_in_sessions_graph)) {
$html .= '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'</p>';
} else {
} else {
// display evaluations base courses graph
if (!empty($evaluations_base_courses_graph)) {
foreach ($evaluations_base_courses_graph as $course_code => $img_html) {
@ -110,39 +107,39 @@ class BlockEvaluationGraph extends Block {
if (!empty($evaluations_courses_in_sessions_graph)) {
foreach ($evaluations_courses_in_sessions_graph as $session_id => $courses) {
$session_name = api_get_session_name($session_id);
$html .= '<div><strong>'.$session_name.':'.get_lang('Evaluations').'</strong></div>';
$html .= '<div><strong>'.$session_name.':'.get_lang('Evaluations').'</strong></div>';
foreach ($courses as $course_code => $img_html) {
$html .= '<div><strong>'.$course_code.'</strong></div>';
$html .= $img_html;
}
$html .= $img_html;
}
}
}
}
}
$html .= '</div>
</li>';
</li>';
$data['column'] = $column;
$data['content_html'] = $html;
return $data;
return $data;
}
/**
* This method return a graph containing informations about evaluations inside base courses, it's used inside get_block method for showing it inside dashboard interface
* @return string img html
*/
public function get_evaluations_base_courses_graph() {
$graphs = array();
public function get_evaluations_base_courses_graph() {
$graphs = array();
if (!empty($this->courses)) {
$courses_code = array_keys($this->courses);
foreach ($courses_code as $course_code) {
$cats = Category::load(null, null, $course_code, null, null, null, false);
$courses_code = array_keys($this->courses);
foreach ($courses_code as $course_code) {
$cats = Category::load(null, null, $course_code, null, null, null, false);
if (isset($cats) && isset($cats[0])) {
$alleval = $cats[0]->get_evaluations(null, true, $course_code);
$alllinks = $cats[0]->get_links(null, true);
$users = get_all_users($alleval, $alllinks);
$datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks);
$evaluation_sumary = $datagen->get_evaluation_sumary_results();
$users = get_all_users($alleval, $alllinks);
$datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks);
$evaluation_sumary = $datagen->get_evaluation_sumary_results();
if (!empty($evaluation_sumary)) {
$items = array_keys($evaluation_sumary);
$max = $min = $avg = array();
@ -150,74 +147,74 @@ class BlockEvaluationGraph extends Block {
$max[] = $evaluation['max'];
$min[] = $evaluation['min'];
$avg[] = $evaluation['avg'];
}
// Dataset definition
$data_set = new pData;
$data_set->AddPoint($max, "Max");
}
// Dataset definition
$data_set = new pData;
$data_set->AddPoint($max, "Max");
$data_set->AddPoint($avg, "Avg");
$data_set->AddPoint($min, "Min");
$data_set->AddPoint($items, "Items");
$data_set->AddPoint($min, "Min");
$data_set->AddPoint($items, "Items");
$data_set->SetXAxisName(get_lang('EvaluationName'));
$data_set->SetYAxisName(get_lang('Percentage'));
$data_set->AddAllSeries();
$data_set->RemoveSerie("Items");
$data_set->SetAbsciseLabelSerie("Items");
$graph_id = $this->user_id.'StudentEvaluationGraph';
$cache = new pCache();
$data_set->SetYAxisName(get_lang('Percentage'));
$data_set->AddAllSeries();
$data_set->RemoveSerie("Items");
$data_set->SetAbsciseLabelSerie("Items");
$graph_id = $this->user_id.'StudentEvaluationGraph';
$cache = new pCache(api_get_path(SYS_ARCHIVE_PATH));
// the graph id
$data = $data_set->GetData();
if ($cache->IsInCache($graph_id, $data)) {
$data = $data_set->GetData();
if ($cache->IsInCache($graph_id, $data)) {
//if we already created the img
$img_file = $cache->GetHash($graph_id, $data);
} else {
// Initialise the graph
$test = new pChart($this->bg_width,$this->bg_height);
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$test->setGraphArea(50,30,$this->bg_width-75,$this->bg_height-75);
$test->drawFilledRoundedRectangle(7,7,$this->bg_width-20,$this->bg_height-20,5,240,240,240);
$test->drawRoundedRectangle(5,5,$this->bg_width-18,$this->bg_height-18,5,230,230,230);
$test->drawGraphArea(255,255,255,TRUE);
$test->setFixedScale(0,100,5);
$test->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,0,2,TRUE);
// Initialise the graph
$test = new pChart($this->bg_width,$this->bg_height);
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$test->setGraphArea(50,30,$this->bg_width-75,$this->bg_height-75);
$test->drawFilledRoundedRectangle(7,7,$this->bg_width-20,$this->bg_height-20,5,240,240,240);
$test->drawRoundedRectangle(5,5,$this->bg_width-18,$this->bg_height-18,5,230,230,230);
$test->drawGraphArea(255,255,255,TRUE);
$test->setFixedScale(0,100,5);
$test->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,0,2,TRUE);
$test->setColorPalette(0,105,221,34);
$test->setColorPalette(1,255,135,30);
$test->setColorPalette(2,255,0,0);
$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->drawOverlayBarGraph($data_set->GetData(),$data_set->GetDataDescription(), 90);
// Finish the graph
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$test->drawLegend($this->bg_width-80,20,$data_set->GetDataDescription(),255,255,255);
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10);
//$test->drawTitle(50,22,$course_code,50,50,50,185);
$test->setColorPalette(2,255,0,0);
$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->drawOverlayBarGraph($data_set->GetData(),$data_set->GetDataDescription(), 90);
// Finish the graph
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$test->drawLegend($this->bg_width-80,20,$data_set->GetDataDescription(),255,255,255);
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10);
//$test->drawTitle(50,22,$course_code,50,50,50,185);
$test->setColorPalette(0,50,50,50);
$test->setColorPalette(1,50,50,50);
$test->setColorPalette(2,50,50,50);
$test->writeValues($data_set->GetData(),$data_set->GetDataDescription(),array("Min", "Max", "Avg"));
$test->setColorPalette(2,50,50,50);
$test->writeValues($data_set->GetData(),$data_set->GetDataDescription(),array("Min", "Max", "Avg"));
$cache->WriteToCache($graph_id, $data_set->GetData(), $test);
ob_start();
$test->Stroke();
ob_end_clean();
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
}
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
}
if (!empty($img_file)) {
$graphs[$course_code] = '<img src="'.api_get_path(WEB_ARCHIVE_PATH).$img_file.'">';
}
}
}
}
}
} // end for
}
return $graphs;
return $graphs;
}
/**
* This method return a graph containing informations about evaluations inside courses in sessions, it's used inside get_block method for showing it inside dashboard interface
* @return string img html
*/
public function get_evaluations_courses_in_sessions_graph() {
public function get_evaluations_courses_in_sessions_graph() {
$graphs = array();
if (!empty($this->sessions)) {
$session_ids = array_keys($this->sessions);
@ -227,7 +224,7 @@ class BlockEvaluationGraph extends Block {
foreach ($courses_code as $course_code) {
$cats = Category::load(null, null, $course_code, null, null, $session_id);
if (isset($cats) && isset($cats[0])) {
$alleval = $cats[0]->get_evaluations(null, true, $course_code);
$alleval = $cats[0]->get_evaluations(null, true, $course_code);
$alllinks = $cats[0]->get_links(null, true);
$users = get_all_users($alleval, $alllinks);
$datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks);
@ -239,69 +236,69 @@ class BlockEvaluationGraph extends Block {
$max[] = $evaluation['max'];
$min[] = $evaluation['min'];
$avg[] = $evaluation['avg'];
}
// Dataset definition
$data_set = new pData;
$data_set->AddPoint($max, "Max");
}
// Dataset definition
$data_set = new pData;
$data_set->AddPoint($max, "Max");
$data_set->AddPoint($avg, "Avg");
$data_set->AddPoint($min, "Min");
$data_set->AddPoint($items, "Items");
$data_set->AddPoint($min, "Min");
$data_set->AddPoint($items, "Items");
$data_set->SetXAxisName(get_lang('EvaluationName'));
$data_set->SetYAxisName(get_lang('Percentage'));
$data_set->AddAllSeries();
$data_set->RemoveSerie("Items");
$data_set->SetAbsciseLabelSerie("Items");
$graph_id = $this->user_id.'StudentEvaluationGraph';
$cache = new pCache();
$data_set->SetYAxisName(get_lang('Percentage'));
$data_set->AddAllSeries();
$data_set->RemoveSerie("Items");
$data_set->SetAbsciseLabelSerie("Items");
$graph_id = $this->user_id.'StudentEvaluationGraph';
$cache = new pCache(api_get_path(SYS_ARCHIVE_PATH));
// the graph id
$data = $data_set->GetData();
if ($cache->IsInCache($graph_id, $data)) {
$data = $data_set->GetData();
if ($cache->IsInCache($graph_id, $data)) {
//if we already created the img
$img_file = $cache->GetHash($graph_id, $data);
} else {
// Initialise the graph
$test = new pChart($this->bg_width,$this->bg_height);
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$test->setGraphArea(50,30,$this->bg_width-75,$this->bg_height-75);
$test->drawFilledRoundedRectangle(7,7,$this->bg_width-20,$this->bg_height-20,5,240,240,240);
$test->drawRoundedRectangle(5,5,$this->bg_width-18,$this->bg_height-18,5,230,230,230);
$test->drawGraphArea(255,255,255,TRUE);
$test->setFixedScale(0,100,5);
$test->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,0,2,TRUE);
// Initialise the graph
$test = new pChart($this->bg_width,$this->bg_height);
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$test->setGraphArea(50,30,$this->bg_width-75,$this->bg_height-75);
$test->drawFilledRoundedRectangle(7,7,$this->bg_width-20,$this->bg_height-20,5,240,240,240);
$test->drawRoundedRectangle(5,5,$this->bg_width-18,$this->bg_height-18,5,230,230,230);
$test->drawGraphArea(255,255,255,TRUE);
$test->setFixedScale(0,100,5);
$test->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,0,2,TRUE);
$test->setColorPalette(0,105,221,34);
$test->setColorPalette(1,255,135,30);
$test->setColorPalette(2,255,0,0);
$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->drawOverlayBarGraph($data_set->GetData(),$data_set->GetDataDescription(), 100);
// Finish the graph
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$test->drawLegend($this->bg_width-80,20,$data_set->GetDataDescription(),255,255,255);
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10);
$test->setColorPalette(2,255,0,0);
$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->drawOverlayBarGraph($data_set->GetData(),$data_set->GetDataDescription(), 100);
// Finish the graph
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$test->drawLegend($this->bg_width-80,20,$data_set->GetDataDescription(),255,255,255);
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10);
$test->setColorPalette(0,50,50,50);
$test->setColorPalette(1,50,50,50);
$test->setColorPalette(2,50,50,50);
$test->writeValues($data_set->GetData(),$data_set->GetDataDescription(),array("Min", "Max", "Avg"));
$test->setColorPalette(2,50,50,50);
$test->writeValues($data_set->GetData(),$data_set->GetDataDescription(),array("Min", "Max", "Avg"));
$cache->WriteToCache($graph_id, $data_set->GetData(), $test);
ob_start();
$test->Stroke();
ob_end_clean();
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
}
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
}
if (!empty($img_file)) {
$courses_graph[$course_code] = '<img src="'.api_get_path(WEB_ARCHIVE_PATH).$img_file.'">';
}
}
}
}
}
}
}
if (!empty($courses_graph)) {
$graphs[$session_id] = $courses_graph;
}
}
}
$graphs[$session_id] = $courses_graph;
}
}
}
return $graphs;
}
}

@ -2,22 +2,18 @@
/* For licensing terms, see /license.txt */
/**
* This file is part of student graph block plugin for dashboard,
* 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>
* @author Julio Montoya <gugli100@gmail.com>
*/
/**
* required files for getting data
*/
require_once api_get_path(LIBRARY_PATH).'attendance.lib.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/MyHorBar.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/gradebookitem.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/evaluation.class.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/result.class.php';
@ -25,7 +21,7 @@ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/linkfactory.class.php
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
/**
* This class is used like controller for student graph block plugin,
* This class is used like controller for student graph block plugin,
* the class name must be registered inside path.info file (e.g: controller = "BlockStudentGraph"), so dashboard controller will be instantiate it
* @package chamilo.dashboard
*/
@ -38,172 +34,172 @@ class BlockStudentGraph extends Block {
/**
* Constructor
*/
public function __construct ($user_id) {
*/
public function __construct ($user_id) {
$this->user_id = $user_id;
$this->path = 'block_student_graph';
$this->path = 'block_student_graph';
if ($this->is_block_visible_for_user($user_id)) {
/*if (api_is_platform_admin()) {
$this->students = UserManager::get_user_list(array('status' => STUDENT));
} else if (api_is_drh()) {*/
$this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT);
//}
}
//}
}
}
/**
* This method check if a user is allowed to see the block inside dashboard interface
* @param int User id
* @return bool Is block visible for user
*/
public function is_block_visible_for_user($user_id) {
*/
public function is_block_visible_for_user($user_id) {
$user_info = api_get_user_info($user_id);
$user_status = $user_info['status'];
$is_block_visible_for_user = false;
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {
$is_block_visible_for_user = true;
}
return $is_block_visible_for_user;
}
return $is_block_visible_for_user;
}
/**
* This method return content html containing information about students and its position for showing it inside dashboard interface
* it's important to use the name 'get_block' for beeing used from dashboard controller
* it's important to use the name 'get_block' for beeing used from dashboard controller
* @return array column and content html
*/
public function get_block() {
global $charset;
$column = 1;
$data = array();
$data = array();
$students_attendance_graph = $this->get_students_attendance_graph();
$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>
</div>
<div class="widget-content" align="center">
<div style="padding:10px;"><strong>'.get_lang('AttendancesFaults').'</strong></div>
</div>
<div class="widget-content" align="center">
<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;
$data['content_html'] = $html;
return $data;
}
/**
* This method return a graph containing informations about students evaluation, it's used inside get_block method for showing it inside dashboard interface
* @return string img html
*/
public function get_students_attendance_graph() {
public function get_students_attendance_graph() {
$students = $this->students;
$attendance = new Attendance();
// get data
// get data
$attendances_faults_avg = array();
if (is_array($students) && count($students) > 0) {
foreach ($students as $student) {
if (is_array($students) && count($students) > 0) {
foreach ($students as $student) {
$student_id = $student['user_id'];
//$student_info = api_get_user_info($student_id);
// get average of faults in attendances by student
//$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['lastname']] = $results_faults_avg['porcent'];
$attendances_faults_avg[$student['lastname']] = $results_faults_avg['porcent'];
} else {
$attendances_faults_avg[$student['lastname']] = 0;
}
}
}
}
arsort($attendances_faults_avg);
$usernames = array_keys($attendances_faults_avg);
$faults = array();
arsort($attendances_faults_avg);
$usernames = array_keys($attendances_faults_avg);
$faults = array();
foreach ($usernames as $username) {
$faults[] = $attendances_faults_avg[$username];
}
$graph = '';
$img_file = '';
if (is_array($usernames) && count($usernames) > 0) {
// Defining data
$data_set = new pData;
$data_set->AddPoint($faults,"Promedio");
$data_set->AddPoint($usernames,"Usuario");
$data_set->AddAllSeries();
$data_set->AddPoint($faults,"Promedio");
$data_set->AddPoint($usernames,"Usuario");
$data_set->AddAllSeries();
$data_set->SetAbsciseLabelSerie("Usuario");
// prepare cache for saving image
$graph_id = $this->user_id.'StudentEvaluationGraph'; // the graph id
$cache = new pCache();
$graph_id = $this->user_id.'StudentEvaluationGraph'; // the graph id
$cache = new pCache(api_get_path(SYS_ARCHIVE_PATH));
$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 {
if (count($usernames) < 5) {
$height = 200;
} else {
$height = (count($usernames)*40);
} else {
if (count($usernames) < 5) {
$height = 200;
} else {
$height = (count($usernames)*40);
}
// Initialise the graph
$test = new MyHorBar(400,($height+30));
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 8);
$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);
//X axis
$test->setFixedScale(0,100,10);
//var_dump($data_set->GetDataDescription());
$test->drawHorScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,0,0,TRUE);
$test->setColorPalette(0,255,0,0);
$test->drawHorScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,0,0,TRUE);
$test->setColorPalette(0,255,0,0);
$test->drawHorGrid(10,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->drawHorBarGraph($data_set->GetData(),$data_set->GetDataDescription(),TRUE,50);
$cache->WriteToCache($graph_id, $data_set->GetData(), $test);
ob_start();
$test->Stroke();
ob_end_clean();
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
}
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
}
if (!empty($img_file)) {
$graph = '<img src="'.api_get_path(WEB_ARCHIVE_PATH).$img_file.'">';
}
}
} else {
$graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'</p>';
}
}
return $graph;
}
/**
* Get number of students
* @return int
*/
function get_number_of_students() {
return count($this->students);
}
}
}

@ -9,9 +9,6 @@
/**
* required files for getting data
*/
require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php';
/**
* This class is used like controller for teacher graph block plugin,
@ -93,7 +90,7 @@ class BlockTeacherGraph extends Block {
public function get_teachers_information_graph() {
$teachers = $this->teachers;
$graph = '';
$user_ids = array_keys($teachers);
$user_ids = array_keys($teachers);
$a_last_week = get_last_week();
if (is_array($user_ids) && count($user_ids) > 0) {
@ -127,7 +124,7 @@ class BlockTeacherGraph extends Block {
$data_set->SetAbsciseLabelSerie("Days");
$graph_id = $this->user_id.'TeacherConnectionsGraph';
$cache = new pCache();
$cache = new pCache(api_get_path(SYS_ARCHIVE_PATH));
// the graph id
$data = $data_set->GetData();

Loading…
Cancel
Save