Actualización
This commit is contained in:
209
plugin/dashboard/block_course/block_course.class.php
Normal file
209
plugin/dashboard/block_course/block_course.class.php
Normal file
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of course 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
|
||||
*/
|
||||
/**
|
||||
* This class is used like controller for this course block plugin,
|
||||
* the class name must be registered inside path.info file
|
||||
* (e.g: controller = "BlockCourse"), so dashboard controller will be instantiate it.
|
||||
*
|
||||
* @package chamilo.dashboard
|
||||
*/
|
||||
class BlockCourse extends Block
|
||||
{
|
||||
private $user_id;
|
||||
private $courses;
|
||||
private $path;
|
||||
private $permission = [DRH];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct($user_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->path = 'block_course';
|
||||
if ($this->is_block_visible_for_user($user_id)) {
|
||||
$this->courses = CourseManager::get_courses_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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return content html containing information
|
||||
* about courses and its position for showing it inside dashboard interface
|
||||
* 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 = 2;
|
||||
$data = [];
|
||||
$content = $this->get_content_html();
|
||||
$html = '
|
||||
<div class="panel panel-default" id="intro">
|
||||
<div class="panel-heading">'.get_lang('CoursesInformation').'
|
||||
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(
|
||||
api_htmlentities(
|
||||
get_lang('ConfirmYourChoice'),
|
||||
ENT_QUOTES,
|
||||
$charset
|
||||
)
|
||||
).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
|
||||
<em class="fa fa-times"></em>
|
||||
</a></div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
'.$content.'
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
$data['column'] = $column;
|
||||
$data['content_html'] = $html;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface.
|
||||
*
|
||||
* @return string content html
|
||||
*/
|
||||
public function get_content_html()
|
||||
{
|
||||
$course_data = $this->get_course_information_data();
|
||||
$content = '<h4>'.get_lang('YourCourseList').'</h4>';
|
||||
$data_table = null;
|
||||
if (!empty($course_data)) {
|
||||
$data_table .= '<table class="table table-hover table-striped data_table" width:"95%">';
|
||||
$data_table .= '<tr>
|
||||
<th>'.get_lang('CourseTitle').'</th>
|
||||
<th width="20%">'.get_lang('NbStudents').'</th>
|
||||
<th width="20%">'.get_lang('AvgTimeSpentInTheCourse').'</th>
|
||||
<th width="20%">'.get_lang('ThematicAdvance').'</th>
|
||||
</tr>';
|
||||
$i = 1;
|
||||
foreach ($course_data as $course) {
|
||||
if ($i % 2 == 0) {
|
||||
$class_tr = 'row_odd';
|
||||
} else {
|
||||
$class_tr = 'row_even';
|
||||
}
|
||||
$data_table .= '<tr class="'.$class_tr.'">';
|
||||
if (!isset($course[2])) {
|
||||
$course[2] = '0:00:00';
|
||||
}
|
||||
foreach ($course as $cell) {
|
||||
$data_table .= '<td align="right">'.$cell.'</td>';
|
||||
}
|
||||
$data_table .= '</tr>';
|
||||
$i++;
|
||||
}
|
||||
$data_table .= '</table>';
|
||||
} else {
|
||||
$data_table .= get_lang('ThereIsNoInformationAboutYourCourses');
|
||||
}
|
||||
$content .= $data_table;
|
||||
if (!empty($course_data)) {
|
||||
$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/course.php?follow">'.get_lang('SeeMore').'</a></div>';
|
||||
}
|
||||
//$content .= '</div>';
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of courses.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_number_of_courses()
|
||||
{
|
||||
return count($this->courses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get course information data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_course_information_data()
|
||||
{
|
||||
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
|
||||
$course_data = [];
|
||||
$courses = $this->courses;
|
||||
$thematic = new Thematic();
|
||||
|
||||
foreach ($courses as $row_course) {
|
||||
$course_code = $row_course['code'];
|
||||
$courseInfo = api_get_course_info($course_code);
|
||||
$courseId = $courseInfo['real_id'];
|
||||
$nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0;
|
||||
|
||||
// students directly subscribed to the course
|
||||
$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user
|
||||
WHERE course_rel_user.status=".STUDENT." AND course_rel_user.c_id='$courseId'";
|
||||
$rs = Database::query($sql);
|
||||
$users = [];
|
||||
while ($row = Database::fetch_array($rs)) {
|
||||
$users[] = $row['user_id'];
|
||||
}
|
||||
if (count($users) > 0) {
|
||||
$nb_students_in_course = count($users);
|
||||
$avg_time_spent_in_course = api_time_to_hms(
|
||||
Tracking::get_time_spent_on_the_course($users, $courseId) / $nb_students_in_course
|
||||
);
|
||||
} else {
|
||||
$avg_time_spent_in_course = null;
|
||||
}
|
||||
$tematic_advance = $thematic->get_total_average_of_thematic_advances(
|
||||
$course_code,
|
||||
0
|
||||
);
|
||||
|
||||
if (!empty($tematic_advance)) {
|
||||
$tematic_advance_progress = '<a title="'.get_lang('GoToThematicAdvance').'" href="'.api_get_path(WEB_CODE_PATH).'course_progress/index.php?cidReq='.$course_code.'&action=thematic_details">'.$tematic_advance.'%</a>';
|
||||
} else {
|
||||
$tematic_advance_progress = '0%';
|
||||
}
|
||||
|
||||
$table_row = [];
|
||||
$table_row[] = $row_course['title'];
|
||||
$table_row[] = $nb_students_in_course;
|
||||
$table_row[] = $avg_time_spent_in_course;
|
||||
$table_row[] = $tematic_advance_progress;
|
||||
$course_data[] = $table_row;
|
||||
}
|
||||
|
||||
return $course_data;
|
||||
}
|
||||
}
|
||||
6
plugin/dashboard/block_course/block_course.info
Normal file
6
plugin/dashboard/block_course/block_course.info
Normal file
@@ -0,0 +1,6 @@
|
||||
name = "Course Block"
|
||||
controller = "BlockCourse"
|
||||
description = "Display information about courses inside platform"
|
||||
package = Dashboard
|
||||
version = 1.0
|
||||
author = Christian Fasanando
|
||||
8
plugin/dashboard/block_course/index.html
Normal file
8
plugin/dashboard/block_course/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
269
plugin/dashboard/block_daily/block_daily.class.php
Normal file
269
plugin/dashboard/block_daily/block_daily.class.php
Normal file
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of course block plugin for dashboard,
|
||||
* it should be required inside dashboard controller for showing it into dashboard interface from plattform.
|
||||
*
|
||||
* @package chamilo.dashboard
|
||||
*
|
||||
* @author Marco Sousa original code
|
||||
* @author Julio Montoya class named was changed of name, and some minor changes
|
||||
*/
|
||||
|
||||
/**
|
||||
* required files for getting data.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used like controller for this course block plugin,
|
||||
* the class name must be registered inside path.info file
|
||||
* (e.g: controller = "BlockDiario"), so dashboard controller will be instantiate it.
|
||||
*
|
||||
* @package chamilo.dashboard
|
||||
*/
|
||||
class BlockDaily extends Block
|
||||
{
|
||||
private $user_id;
|
||||
private $courses;
|
||||
private $path;
|
||||
private $permission = [DRH];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct($user_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->path = 'block_daily';
|
||||
if ($this->is_block_visible_for_user($user_id)) {
|
||||
$this->courses = CourseManager::get_courses_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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return content html containing information about courses and its position for showing it inside dashboard interface
|
||||
* 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 = 2;
|
||||
$data = [];
|
||||
$content = $this->get_content_html();
|
||||
$html = '<div class="panel panel-default" id="intro">
|
||||
<div class="panel-heading">'.get_lang('GradebookAndAttendances').'
|
||||
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(
|
||||
api_htmlentities(
|
||||
get_lang('ConfirmYourChoice'),
|
||||
ENT_QUOTES,
|
||||
$charset
|
||||
)
|
||||
).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
|
||||
<em class="fa fa-times"></em>
|
||||
</a></div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
'.$content.'
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
$data['column'] = $column;
|
||||
$data['content_html'] = $html;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface.
|
||||
*
|
||||
* @return string content html
|
||||
*/
|
||||
public function get_content_html()
|
||||
{
|
||||
$course_data = $this->get_course_information_data();
|
||||
$content = '<h4>'.get_lang('YourCourseList').'</h4>';
|
||||
$data_table = null;
|
||||
if (!empty($course_data)) {
|
||||
$data_table .= '<table class="table table-hover table-striped data_table" width:"95%">';
|
||||
$data_table .= '<tr>
|
||||
<th>'.get_lang('CourseTitle').'</th>
|
||||
<th width="20%">'.get_lang('NbStudents').'</th>
|
||||
<th width="20%">'.get_lang('Evaluation').'</th>
|
||||
<th width="20%">'.get_lang('ToolAttendance').'</th>
|
||||
</tr>';
|
||||
$i = 1;
|
||||
foreach ($course_data as $course) {
|
||||
if ($i % 2 == 0) {
|
||||
$class_tr = 'row_odd';
|
||||
} else {
|
||||
$class_tr = 'row_even';
|
||||
}
|
||||
$data_table .= '<tr class="'.$class_tr.'">';
|
||||
if (!isset($course[3])) {
|
||||
$course[3] = get_lang('NotAvailable');
|
||||
}
|
||||
foreach ($course as $cell) {
|
||||
$data_table .= '<td align="right">'.$cell.'</td>';
|
||||
}
|
||||
$data_table .= '</tr>';
|
||||
$i++;
|
||||
}
|
||||
$data_table .= '</table>';
|
||||
} else {
|
||||
$data_table .= get_lang('ThereIsNoInformationAboutYourCourses');
|
||||
}
|
||||
$content .= $data_table;
|
||||
if (!empty($course_data)) {
|
||||
$content .= '<div style="text-align:right;margin-top:10px;">
|
||||
<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/course.php">'.get_lang('SeeMore').'</a></div>';
|
||||
}
|
||||
//$content .= '</div>';
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of courses.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_number_of_courses()
|
||||
{
|
||||
return count($this->courses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get course information data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_course_information_data()
|
||||
{
|
||||
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
|
||||
$course_data = [];
|
||||
$courses = $this->courses;
|
||||
|
||||
foreach ($courses as $row_course) {
|
||||
$score = null;
|
||||
$courseId = $row_course['c_id'];
|
||||
$course_info = api_get_course_info_by_id($courseId);
|
||||
$course_code = $course_info['code'];
|
||||
if (empty($course_info)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Attendance table
|
||||
$table_course = Database::get_course_table(TABLE_ATTENDANCE);
|
||||
|
||||
$sql = "SELECT id, name, attendance_qualify_max FROM $table_course
|
||||
WHERE c_id = ".$course_info['real_id']." AND active = 1 AND session_id = 0";
|
||||
$rs = Database::query($sql);
|
||||
$attendance = [];
|
||||
$attendances = [];
|
||||
|
||||
while ($row = Database::fetch_array($rs, 'ASSOC')) {
|
||||
$attendance['done'] = $row['attendance_qualify_max'];
|
||||
$attendance['id'] = $row['id'];
|
||||
//$attendance['name'] = $row['name'];
|
||||
$attendance['course_code'] = $course_info['code'];
|
||||
|
||||
if ($attendance['done'] != '0') {
|
||||
$attendances[] = '<a href="'.api_get_path(WEB_PATH).'main/attendance/index.php?cidReq='.$attendance['course_code'].'&action=attendance_sheet_print&attendance_id='.$attendance['id'].'">'.Display::return_icon('printmgr.gif', get_lang('Print')).'</a>';
|
||||
} else {
|
||||
$attendances[] = get_lang("NotAvailable");
|
||||
}
|
||||
}
|
||||
if (count($attendances) == 0) {
|
||||
$attendances[] = get_lang("NotAvailable");
|
||||
}
|
||||
|
||||
// Number of students
|
||||
|
||||
$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user
|
||||
WHERE course_rel_user.status=".STUDENT." AND course_rel_user.c_id=$courseId";
|
||||
$rs = Database::query($sql);
|
||||
$users = [];
|
||||
while ($row = Database::fetch_array($rs)) {
|
||||
$users[] = $row['user_id'];
|
||||
}
|
||||
if (count($users) > 0) {
|
||||
$nb_students_in_course = count($users);
|
||||
}
|
||||
|
||||
if (!empty($tematic_advance)) {
|
||||
$tematic_advance_progress = '<a title="'.get_lang(
|
||||
'GoToThematicAdvance'
|
||||
).'" href="'.api_get_path(
|
||||
WEB_CODE_PATH
|
||||
).'attendance/index.php?cidReq='.$course_code.'&action=attendance_sheet_print&attendance_id=">'.$tematic_advance.'%</a>';
|
||||
} else {
|
||||
$tematic_advance_progress = '0%';
|
||||
}
|
||||
|
||||
// Score
|
||||
$tbl_grade_categories = Database::get_main_table(
|
||||
TABLE_MAIN_GRADEBOOK_CATEGORY
|
||||
);
|
||||
$sql = "SELECT id from ".$tbl_grade_categories."
|
||||
WHERE course_code ='".$course_code."'";
|
||||
$rs = Database::query($sql);
|
||||
$category = null;
|
||||
while ($row = Database::fetch_array($rs)) {
|
||||
$category = $row['id'];
|
||||
}
|
||||
|
||||
if (!empty($category)) {
|
||||
$cat = Category::load($category);
|
||||
$eval = $cat[0]->get_evaluations();
|
||||
if (count($eval) > 0) {
|
||||
$i = 0;
|
||||
foreach ($eval as $item) {
|
||||
$score .= '<a href="'.api_get_path(WEB_PATH).'main/gradebook/gradebook_view_result.php?export=pdf&cat_code='.$cat[0]->get_id().'&official_code='.$cat[0]->get_course_code().'&selecteval='.$item->get_id().'">'.$item->get_name().'</a>';
|
||||
if (count($eval) - 1 != $i) {
|
||||
$score .= ', ';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
$score = get_lang("NotAvailable");
|
||||
}
|
||||
} else {
|
||||
$score = get_lang("NotAvailable");
|
||||
}
|
||||
|
||||
$table_row = [];
|
||||
$table_row[] = $row_course['title'];
|
||||
$table_row[] = $nb_students_in_course;
|
||||
$table_row[] = $score;
|
||||
$table_row[] = $attendances[0];
|
||||
$course_data[] = $table_row;
|
||||
}
|
||||
|
||||
return $course_data;
|
||||
}
|
||||
}
|
||||
6
plugin/dashboard/block_daily/block_daily.info
Normal file
6
plugin/dashboard/block_daily/block_daily.info
Normal file
@@ -0,0 +1,6 @@
|
||||
name = "Gradebook & Attendances"
|
||||
controller = "BlockDaily"
|
||||
description = "Access to attendances in a Gradebook"
|
||||
package = Dashboard
|
||||
version = 1.0
|
||||
author = Marco Antonio Firmino de Sousa
|
||||
8
plugin/dashboard/block_daily/index.html
Normal file
8
plugin/dashboard/block_daily/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,489 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
use CpChart\Cache as pCache;
|
||||
use CpChart\Data as pData;
|
||||
use CpChart\Image as pImage;
|
||||
|
||||
/**
|
||||
* Class BlockEvaluationGraph
|
||||
* This class is used like controller for this evaluations graph block plugin,
|
||||
* the class name must be registered inside path.info file
|
||||
* (e.g: controller = "BlockEvaluationGraph"),
|
||||
* so dashboard controller will be instantiate it.
|
||||
*
|
||||
* This file is part of evaluation graph block plugin for dashboard,
|
||||
* it should be required inside dashboard controller for showing it
|
||||
* into dashboard interface from platform
|
||||
*
|
||||
* @package chamilo.dashboard
|
||||
*
|
||||
* @author Christian Fasanando
|
||||
*/
|
||||
class BlockEvaluationGraph extends Block
|
||||
{
|
||||
private $user_id;
|
||||
private $courses;
|
||||
private $sessions;
|
||||
private $path;
|
||||
private $permission = [DRH, SESSIONADMIN];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
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)) {
|
||||
if (!api_is_session_admin()) {
|
||||
$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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return content html containing
|
||||
* information about sessions and its position for showing it inside dashboard interface
|
||||
* 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 = [];
|
||||
$evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph();
|
||||
$evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph();
|
||||
|
||||
$html = '<div class="panel panel-default" id="intro">
|
||||
<div class="panel-heading">
|
||||
'.get_lang('EvaluationsGraph').'
|
||||
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
|
||||
<em class="fa fa-times"></em>
|
||||
</a></div>
|
||||
</div>
|
||||
<div class="panel-body">';
|
||||
if (empty($evaluations_base_courses_graph) && empty($evaluations_courses_in_sessions_graph)) {
|
||||
$html .= '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8').'</p>';
|
||||
} else {
|
||||
// display evaluations base courses graph
|
||||
if (!empty($evaluations_base_courses_graph)) {
|
||||
foreach ($evaluations_base_courses_graph as $course_code => $img_html) {
|
||||
$html .= '<div><strong>'.$course_code.'</strong></div>';
|
||||
$html .= $img_html;
|
||||
}
|
||||
}
|
||||
// display evaluations base courses graph
|
||||
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>';
|
||||
foreach ($courses as $course_code => $img_html) {
|
||||
$html .= '<div><strong>'.$course_code.'</strong></div>';
|
||||
$html .= $img_html;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$html .= '</div>
|
||||
</div>';
|
||||
|
||||
$data['column'] = $column;
|
||||
$data['content_html'] = $html;
|
||||
|
||||
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 = [];
|
||||
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
|
||||
);
|
||||
|
||||
if (isset($cats) && isset($cats[0])) {
|
||||
$alleval = $cats[0]->get_evaluations(null, true, $course_code);
|
||||
$alllinks = $cats[0]->get_links(null, true);
|
||||
$users = GradebookUtils::get_all_users($alleval, $alllinks);
|
||||
$datagen = new FlatViewDataGenerator($users, $alleval, $alllinks);
|
||||
$evaluation_sumary = $datagen->getEvaluationSummaryResults();
|
||||
if (!empty($evaluation_sumary)) {
|
||||
$items = array_keys($evaluation_sumary);
|
||||
$max = $min = $avg = [];
|
||||
foreach ($evaluation_sumary as $evaluation) {
|
||||
$max[] = $evaluation['max'];
|
||||
$min[] = !empty($evaluation['min']) ? $evaluation['min'] : 0;
|
||||
$avg[] = $evaluation['avg'];
|
||||
}
|
||||
// Dataset definition
|
||||
$dataSet = new pData();
|
||||
$dataSet->addPoints($min, 'Serie3');
|
||||
$dataSet->addPoints($avg, 'Serie2');
|
||||
$dataSet->addPoints($max, 'Serie1');
|
||||
$dataSet->addPoints($items, 'Labels');
|
||||
|
||||
$dataSet->setSerieDescription('Serie1', get_lang('Max'));
|
||||
$dataSet->setSerieDescription('Serie2', get_lang('Avg'));
|
||||
$dataSet->setSerieDescription('Serie3', get_lang('Min'));
|
||||
$dataSet->setAbscissa('Labels');
|
||||
|
||||
$dataSet->setAbscissaName(get_lang('EvaluationName'));
|
||||
|
||||
$dataSet->normalize(100, '%');
|
||||
|
||||
$dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
|
||||
|
||||
// Cache definition
|
||||
$cachePath = api_get_path(SYS_ARCHIVE_PATH);
|
||||
$myCache = new pCache(['CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)]);
|
||||
$chartHash = $myCache->getHash($dataSet);
|
||||
if ($myCache->isInCache($chartHash)) {
|
||||
$imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
|
||||
$myCache->saveFromCache($chartHash, $imgPath);
|
||||
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
|
||||
} else {
|
||||
/* Create the pChart object */
|
||||
$widthSize = $this->bg_width;
|
||||
$heightSize = $this->bg_height;
|
||||
$fontSize = 8;
|
||||
$angle = 50;
|
||||
|
||||
$myPicture = new pImage($widthSize, $heightSize, $dataSet);
|
||||
|
||||
/* Turn of Antialiasing */
|
||||
$myPicture->Antialias = false;
|
||||
|
||||
/* Add a border to the picture */
|
||||
$myPicture->drawRectangle(
|
||||
0,
|
||||
0,
|
||||
$widthSize - 1,
|
||||
$heightSize - 1,
|
||||
[
|
||||
'R' => 0,
|
||||
'G' => 0,
|
||||
'B' => 0,
|
||||
]
|
||||
);
|
||||
|
||||
/* Set the default font */
|
||||
$myPicture->setFontProperties(
|
||||
[
|
||||
'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
|
||||
'FontSize' => 10,
|
||||
]
|
||||
);
|
||||
|
||||
/* Do NOT Write the chart title */
|
||||
|
||||
/* Define the chart area */
|
||||
$myPicture->setGraphArea(
|
||||
50,
|
||||
30,
|
||||
$widthSize - 20,
|
||||
$heightSize - 100
|
||||
);
|
||||
|
||||
/* Draw the scale */
|
||||
$scaleSettings = [
|
||||
'GridR' => 200,
|
||||
'GridG' => 200,
|
||||
'GridB' => 200,
|
||||
'DrawSubTicks' => true,
|
||||
'CycleBackground' => true,
|
||||
'Mode' => SCALE_MODE_MANUAL,
|
||||
'ManualScale' => [
|
||||
'0' => [
|
||||
'Min' => 0,
|
||||
'Max' => 100,
|
||||
],
|
||||
],
|
||||
'LabelRotation' => $angle,
|
||||
];
|
||||
$myPicture->drawScale($scaleSettings);
|
||||
|
||||
/* Turn on shadow computing */
|
||||
$myPicture->setShadow(
|
||||
true,
|
||||
[
|
||||
'X' => 1,
|
||||
'Y' => 1,
|
||||
'R' => 0,
|
||||
'G' => 0,
|
||||
'B' => 0,
|
||||
'Alpha' => 10,
|
||||
]
|
||||
);
|
||||
|
||||
/* Draw the chart */
|
||||
$myPicture->setShadow(
|
||||
true,
|
||||
[
|
||||
'X' => 1,
|
||||
'Y' => 1,
|
||||
'R' => 0,
|
||||
'G' => 0,
|
||||
'B' => 0,
|
||||
'Alpha' => 10,
|
||||
]
|
||||
);
|
||||
$settings = [
|
||||
'DisplayValues' => true,
|
||||
'DisplaySize' => $fontSize,
|
||||
'DisplayR' => 0,
|
||||
'DisplayG' => 0,
|
||||
'DisplayB' => 0,
|
||||
'DisplayOrientation' => ORIENTATION_HORIZONTAL,
|
||||
'Gradient' => false,
|
||||
'Surrounding' => 30,
|
||||
'InnerSurrounding' => 25,
|
||||
];
|
||||
$myPicture->drawStackedBarChart($settings);
|
||||
|
||||
$legendSettings = [
|
||||
'Mode' => LEGEND_HORIZONTAL,
|
||||
'Style' => LEGEND_NOBORDER,
|
||||
];
|
||||
$myPicture->drawLegend($widthSize / 2, 15, $legendSettings);
|
||||
|
||||
/* Write and save into cache */
|
||||
|
||||
$myCache->writeToCache($chartHash, $myPicture);
|
||||
$imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
|
||||
$myCache->saveFromCache($chartHash, $imgPath);
|
||||
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
|
||||
}
|
||||
if (!empty($imgPath)) {
|
||||
$courses_graph[$course_code] = '<img src="'.$imgPath.'">';
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end for
|
||||
}
|
||||
|
||||
return $graphs;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a graph containing information 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()
|
||||
{
|
||||
$graphs = [];
|
||||
if (!empty($this->sessions)) {
|
||||
$session_ids = array_keys($this->sessions);
|
||||
foreach ($session_ids as $session_id) {
|
||||
$courses_code = array_keys(Tracking::get_courses_list_from_session($session_id));
|
||||
$courses_graph = [];
|
||||
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);
|
||||
$alllinks = $cats[0]->get_links(null, true);
|
||||
$users = GradebookUtils::get_all_users($alleval, $alllinks);
|
||||
$datagen = new FlatViewDataGenerator($users, $alleval, $alllinks);
|
||||
$evaluation_sumary = $datagen->getEvaluationSummaryResults();
|
||||
if (!empty($evaluation_sumary)) {
|
||||
$items = array_keys($evaluation_sumary);
|
||||
$max = $min = $avg = [];
|
||||
foreach ($evaluation_sumary as $evaluation) {
|
||||
$max[] = $evaluation['max'];
|
||||
$min[] = $evaluation['min'];
|
||||
$avg[] = $evaluation['avg'];
|
||||
}
|
||||
// Dataset definition
|
||||
$dataSet = new pData();
|
||||
$dataSet->addPoints($min, 'Serie3');
|
||||
$dataSet->addPoints($avg, 'Serie2');
|
||||
$dataSet->addPoints($max, 'Serie1');
|
||||
$dataSet->addPoints($items, 'Labels');
|
||||
|
||||
$dataSet->setSerieDescription('Serie1', get_lang('Max'));
|
||||
$dataSet->setSerieDescription('Serie2', get_lang('Avg'));
|
||||
$dataSet->setSerieDescription('Serie3', get_lang('Min'));
|
||||
$dataSet->setAbscissa('Labels');
|
||||
$dataSet->setAbscissaName(get_lang('EvaluationName'));
|
||||
$dataSet->normalize(100, '%');
|
||||
$dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
|
||||
|
||||
// Cache definition
|
||||
$cachePath = api_get_path(SYS_ARCHIVE_PATH);
|
||||
$myCache = new pCache(
|
||||
[
|
||||
'CacheFolder' => substr(
|
||||
$cachePath,
|
||||
0,
|
||||
strlen($cachePath) - 1
|
||||
),
|
||||
]
|
||||
);
|
||||
$chartHash = $myCache->getHash($dataSet);
|
||||
if ($myCache->isInCache($chartHash)) {
|
||||
$imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
|
||||
$myCache->saveFromCache($chartHash, $imgPath);
|
||||
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
|
||||
} else {
|
||||
/* Create the pChart object */
|
||||
$widthSize = $this->bg_width;
|
||||
$heightSize = $this->bg_height;
|
||||
$fontSize = 8;
|
||||
$angle = 50;
|
||||
|
||||
$myPicture = new pImage($widthSize, $heightSize, $dataSet);
|
||||
|
||||
/* Turn of Antialiasing */
|
||||
$myPicture->Antialias = false;
|
||||
|
||||
/* Add a border to the picture */
|
||||
$myPicture->drawRectangle(
|
||||
0,
|
||||
0,
|
||||
$widthSize - 1,
|
||||
$heightSize - 1,
|
||||
[
|
||||
'R' => 0,
|
||||
'G' => 0,
|
||||
'B' => 0,
|
||||
]
|
||||
);
|
||||
|
||||
/* Set the default font */
|
||||
$myPicture->setFontProperties(
|
||||
[
|
||||
'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
|
||||
'FontSize' => 10,
|
||||
]
|
||||
);
|
||||
|
||||
/* Do NOT Write the chart title */
|
||||
|
||||
/* Define the chart area */
|
||||
$myPicture->setGraphArea(50, 30, $widthSize - 20, $heightSize - 100);
|
||||
|
||||
/* Draw the scale */
|
||||
$scaleSettings = [
|
||||
'GridR' => 200,
|
||||
'GridG' => 200,
|
||||
'GridB' => 200,
|
||||
'DrawSubTicks' => true,
|
||||
'CycleBackground' => true,
|
||||
'Mode' => SCALE_MODE_MANUAL,
|
||||
'ManualScale' => [
|
||||
'0' => [
|
||||
'Min' => 0,
|
||||
'Max' => 100,
|
||||
],
|
||||
],
|
||||
'LabelRotation' => $angle,
|
||||
];
|
||||
$myPicture->drawScale($scaleSettings);
|
||||
|
||||
/* Turn on shadow computing */
|
||||
$myPicture->setShadow(
|
||||
true,
|
||||
[
|
||||
'X' => 1,
|
||||
'Y' => 1,
|
||||
'R' => 0,
|
||||
'G' => 0,
|
||||
'B' => 0,
|
||||
'Alpha' => 10,
|
||||
]
|
||||
);
|
||||
|
||||
/* Draw the chart */
|
||||
$myPicture->setShadow(
|
||||
true,
|
||||
[
|
||||
'X' => 1,
|
||||
'Y' => 1,
|
||||
'R' => 0,
|
||||
'G' => 0,
|
||||
'B' => 0,
|
||||
'Alpha' => 10,
|
||||
]
|
||||
);
|
||||
$settings = [
|
||||
'DisplayValues' => true,
|
||||
'DisplaySize' => $fontSize,
|
||||
'DisplayR' => 0,
|
||||
'DisplayG' => 0,
|
||||
'DisplayB' => 0,
|
||||
'DisplayOrientation' => ORIENTATION_HORIZONTAL,
|
||||
'Gradient' => false,
|
||||
'Surrounding' => 30,
|
||||
'InnerSurrounding' => 25,
|
||||
];
|
||||
$myPicture->drawStackedBarChart($settings);
|
||||
|
||||
$legendSettings = [
|
||||
'Mode' => LEGEND_HORIZONTAL,
|
||||
'Style' => LEGEND_NOBORDER,
|
||||
];
|
||||
$myPicture->drawLegend($widthSize / 2, 15, $legendSettings);
|
||||
|
||||
/* Write and save into cache */
|
||||
$myCache->writeToCache($chartHash, $myPicture);
|
||||
$imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
|
||||
$myCache->saveFromCache($chartHash, $imgPath);
|
||||
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
|
||||
}
|
||||
if (!empty($imgPath)) {
|
||||
$courses_graph[$course_code] = '<img src="'.$imgPath.'">';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($courses_graph)) {
|
||||
$graphs[$session_id] = $courses_graph;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $graphs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
name = "Evaluation Graph Block"
|
||||
controller = "BlockEvaluationGraph"
|
||||
description = "Display maximum, minimum and average evaluations about links inside assessments tool"
|
||||
package = Dashboard
|
||||
version = 1.0
|
||||
author = Christian Fasanando
|
||||
152
plugin/dashboard/block_global_info/block_global_info.class.php
Normal file
152
plugin/dashboard/block_global_info/block_global_info.class.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/* See license terms in /license.txt */
|
||||
|
||||
/**
|
||||
* This file is part of global info block plugin for dashboard,
|
||||
* it should be required inside the dashboard controller for
|
||||
* showing it into the dashboard interface.
|
||||
*
|
||||
* @package chamilo.dashboard
|
||||
*
|
||||
* @author Yannick Warnier
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used like controller for this global info block plugin
|
||||
* the class name must be registered inside path.info file
|
||||
* (e.g: controller = "BlockGlobalInfo"), so dashboard controller can
|
||||
* instantiate it.
|
||||
*
|
||||
* @package chamilo.dashboard
|
||||
*/
|
||||
class BlockGlobalInfo extends Block
|
||||
{
|
||||
private $user_id;
|
||||
private $courses;
|
||||
private $path;
|
||||
private $permission = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param int $user_id
|
||||
*/
|
||||
public function __construct($user_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->path = 'block_global_info';
|
||||
if ($this->is_block_visible_for_user($user_id)) {
|
||||
//$this->courses = CourseManager::get_courses_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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return content html containing information
|
||||
* about courses and its position for showing it inside dashboard interface
|
||||
* 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 = 2;
|
||||
$data = [];
|
||||
$content = $this->get_content_html();
|
||||
$html = '<div class="panel panel-default" id="intro">
|
||||
<div class="panel-heading">'.get_lang('GlobalPlatformInformation').'
|
||||
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
|
||||
<em class="fa fa-times"></em>
|
||||
</a></div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
'.$content.'
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
$data['column'] = $column;
|
||||
$data['content_html'] = $html;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface.
|
||||
*
|
||||
* @return string content html
|
||||
*/
|
||||
public function get_content_html()
|
||||
{
|
||||
$global_data = $this->get_global_information_data();
|
||||
$content = '<h4>'.get_lang('GlobalPlatformInformation').'</h4>';
|
||||
$data_table = null;
|
||||
if (!empty($global_data)) {
|
||||
$data_table = '<table class="table table-hover table-striped table-bordered">';
|
||||
$i = 1;
|
||||
foreach ($global_data as $data) {
|
||||
if ($i % 2 == 0) {
|
||||
$class_tr = 'row_odd';
|
||||
} else {
|
||||
$class_tr = 'row_even';
|
||||
}
|
||||
$data_table .= '<tr class="'.$class_tr.'">';
|
||||
foreach ($data as $cell) {
|
||||
$data_table .= '<td align="right">'.$cell.'</td>';
|
||||
}
|
||||
$data_table .= '</tr>';
|
||||
$i++;
|
||||
}
|
||||
$data_table .= '</table>';
|
||||
} else {
|
||||
$data_table .= get_lang('ThereIsNoInformationAboutThePlatform');
|
||||
}
|
||||
$content .= $data_table;
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get global information data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_global_information_data()
|
||||
{
|
||||
// Two-dimensional array with data about the system
|
||||
$path = api_get_path(WEB_CODE_PATH);
|
||||
// Check total number of users
|
||||
$global_info = [
|
||||
[get_lang('CountUsers'), '<a href="'.$path.'admin/user_list.php">'.Statistics::countUsers().'</a>'],
|
||||
// Check only active users
|
||||
[get_lang('NumberOfUsersActive'), '<a href="'.$path.'admin/user_list.php?keyword_firstname=&keyword_lastname=&keyword_username=&keyword_email=&keyword_officialcode=&keyword_status=%25&keyword_active=1&submit=&_qf__advanced_search=">'.Statistics::countUsers(null, null, null, true).'</a>'],
|
||||
// Check number of courses
|
||||
[get_lang('NumberOfCoursesTotal'), '<a href="'.$path.'admin/course_list.php">'.Statistics::countCourses().'</a>'],
|
||||
[get_lang('NumberOfCoursesPublic'), '<a href="'.$path.'admin/course_list.php?keyword_code=&keyword_title=&keyword_language=%25&keyword_category=&keyword_visibility='.COURSE_VISIBILITY_OPEN_WORLD.'&keyword_subscribe=%25&keyword_unsubscribe=%25&submit=&_qf__advanced_course_search=">'.Statistics::countCoursesByVisibility([COURSE_VISIBILITY_OPEN_WORLD]).'</a>'],
|
||||
[get_lang('NumberOfCoursesOpen'), '<a href="'.$path.'admin/course_list.php?keyword_code=&keyword_title=&keyword_language=%25&keyword_category=&keyword_visibility='.COURSE_VISIBILITY_OPEN_PLATFORM.'&keyword_subscribe=%25&keyword_unsubscribe=%25&submit=&_qf__advanced_course_search=">'.Statistics::countCoursesByVisibility([COURSE_VISIBILITY_OPEN_PLATFORM]).'</a>'],
|
||||
[get_lang('NumberOfCoursesPrivate'), '<a href="'.$path.'admin/course_list.php?keyword_code=&keyword_title=&keyword_language=%25&keyword_category=&keyword_visibility='.COURSE_VISIBILITY_REGISTERED.'&keyword_subscribe=%25&keyword_unsubscribe=%25&submit=&_qf__advanced_course_search=">'.Statistics::countCoursesByVisibility([COURSE_VISIBILITY_REGISTERED]).'</a>'],
|
||||
[get_lang('NumberOfCoursesClosed'), '<a href="'.$path.'admin/course_list.php?keyword_code=&keyword_title=&keyword_language=%25&keyword_category=&keyword_visibility='.COURSE_VISIBILITY_CLOSED.'&keyword_subscribe=%25&keyword_unsubscribe=%25&submit=&_qf__advanced_course_search=">'.Statistics::countCoursesByVisibility([COURSE_VISIBILITY_CLOSED]).'</a>'],
|
||||
[get_lang('NumberOfCoursesHidden'), '<a href="'.$path.'admin/course_list.php?keyword_code=&keyword_title=&keyword_language=%25&keyword_category=&keyword_visibility='.COURSE_VISIBILITY_HIDDEN.'&keyword_subscribe=%25&keyword_unsubscribe=%25&submit=&_qf__advanced_course_search=">'.Statistics::countCoursesByVisibility([COURSE_VISIBILITY_HIDDEN]).'</a>'],
|
||||
];
|
||||
|
||||
return $global_info;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
name = "Global info Block"
|
||||
controller = "BlockGlobalInfo"
|
||||
description = "Display global platform information"
|
||||
package = Dashboard
|
||||
version = 1.0
|
||||
author = Yannick Warnier <ywarnier@beeznest.org>
|
||||
8
plugin/dashboard/block_global_info/index.html
Normal file
8
plugin/dashboard/block_global_info/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
164
plugin/dashboard/block_session/block_session.class.php
Normal file
164
plugin/dashboard/block_session/block_session.class.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of session 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used like controller for this session block plugin,
|
||||
* the class name must be registered inside path.info file
|
||||
* (e.g: controller = "BlockSession"), so dashboard controller will be instantiate it.
|
||||
*
|
||||
* @package chamilo.dashboard
|
||||
*/
|
||||
class BlockSession extends Block
|
||||
{
|
||||
private $user_id;
|
||||
private $sessions;
|
||||
private $path;
|
||||
private $permission = [DRH, SESSIONADMIN];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct($user_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->path = 'block_session';
|
||||
if ($this->is_block_visible_for_user($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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return content html containing
|
||||
* information about sessions and its position for showing it inside dashboard interface
|
||||
* 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 = 2;
|
||||
$data = [];
|
||||
$content = $this->get_content_html();
|
||||
$content_html = '<div class="panel panel-default" id="intro">
|
||||
<div class="panel-heading">
|
||||
'.get_lang('SessionsInformation').'
|
||||
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
|
||||
<em class="fa fa-times"></em>
|
||||
</a></div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
'.$content.'
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
$data['column'] = $column;
|
||||
$data['content_html'] = $content_html;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface.
|
||||
*
|
||||
* @return string content html
|
||||
*/
|
||||
public function get_content_html()
|
||||
{
|
||||
$content = '';
|
||||
$sessions = $this->sessions;
|
||||
$content .= '<h4>'.get_lang('YourSessionsList').'</h4>';
|
||||
if (count($sessions) > 0) {
|
||||
$sessions_table = '<table class="table table-hover table-striped data_table" width:"95%">';
|
||||
$sessions_table .= '<tr>
|
||||
<th >'.get_lang('Title').'</th>
|
||||
<th >'.get_lang('Date').'</th>
|
||||
<th width="100px">'.get_lang('NbCoursesPerSession').'</th>
|
||||
</tr>';
|
||||
$i = 1;
|
||||
foreach ($sessions as $session) {
|
||||
$session_id = intval($session['id']);
|
||||
$title = $session['name'];
|
||||
|
||||
if (!empty($session['access_start_date'])) {
|
||||
$dateFrom = api_convert_and_format_date(
|
||||
$session['access_start_date'],
|
||||
DATE_FORMAT_SHORT,
|
||||
date_default_timezone_get()
|
||||
);
|
||||
$dateUntil = api_convert_and_format_date(
|
||||
$session['access_end_date'],
|
||||
DATE_FORMAT_SHORT,
|
||||
date_default_timezone_get()
|
||||
);
|
||||
|
||||
$date = vsprintf(get_lang('FromDateXToDateY'), [$dateFrom, $dateUntil]);
|
||||
} else {
|
||||
$date = ' - ';
|
||||
}
|
||||
|
||||
$count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id));
|
||||
|
||||
if ($i % 2 == 0) {
|
||||
$class_tr = 'row_odd';
|
||||
} else {
|
||||
$class_tr = 'row_even';
|
||||
}
|
||||
|
||||
$sessions_table .= '<tr class="'.$class_tr.'">
|
||||
<td>'.$title.'</td>
|
||||
<td align="center">'.$date.'</td>
|
||||
<td align="center">'.$count_courses_in_session.'</td>
|
||||
</tr>';
|
||||
$i++;
|
||||
}
|
||||
$sessions_table .= '</table>';
|
||||
$content .= $sessions_table;
|
||||
} else {
|
||||
$content .= get_lang('ThereIsNoInformationAboutYourSessions');
|
||||
}
|
||||
|
||||
if (count($sessions) > 0) {
|
||||
$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/session.php">'.get_lang('SeeMore').'</a></div>';
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of sessions.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_number_of_sessions()
|
||||
{
|
||||
return count($this->sessions);
|
||||
}
|
||||
}
|
||||
6
plugin/dashboard/block_session/block_session.info
Normal file
6
plugin/dashboard/block_session/block_session.info
Normal file
@@ -0,0 +1,6 @@
|
||||
name = "Session Block"
|
||||
controller = "BlockSession"
|
||||
description = "Display information about sessions inside platform"
|
||||
package = Dashboard
|
||||
version = 1.0
|
||||
author = Christian Fasanando
|
||||
8
plugin/dashboard/block_session/index.html
Normal file
8
plugin/dashboard/block_session/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
259
plugin/dashboard/block_student/block_student.class.php
Normal file
259
plugin/dashboard/block_student/block_student.class.php
Normal file
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of student 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used like controller for student block plugin,
|
||||
* the class name must be registered inside path.info file
|
||||
* (e.g: controller = "BlockStudent"), so dashboard controller will be instantiate it.
|
||||
*
|
||||
* @package chamilo.dashboard
|
||||
*/
|
||||
class BlockStudent extends Block
|
||||
{
|
||||
private $user_id;
|
||||
private $students;
|
||||
private $path;
|
||||
private $permission = [DRH];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct($user_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->path = 'block_student';
|
||||
if ($this->is_block_visible_for_user($user_id)) {
|
||||
$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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return array column and content html
|
||||
*/
|
||||
public function get_block()
|
||||
{
|
||||
global $charset;
|
||||
$column = 1;
|
||||
$data = [];
|
||||
$student_content_html = $this->get_students_content_html_for_drh();
|
||||
$html = '<div class="panel panel-default" id="intro">
|
||||
<div class="panel-heading">
|
||||
'.get_lang('StudentsInformationsList').'
|
||||
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
|
||||
<em class="fa fa-times"></em>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
'.$student_content_html.'
|
||||
</div>
|
||||
</div>';
|
||||
$data['column'] = $column;
|
||||
$data['content_html'] = $html;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface.
|
||||
*
|
||||
* @return string content html
|
||||
*/
|
||||
public function get_students_content_html_for_platform_admin()
|
||||
{
|
||||
$students = $this->students;
|
||||
$content = '<h4>'.get_lang('YourStudents').'</h4>';
|
||||
$students_table = null;
|
||||
if (count($students) > 0) {
|
||||
$students_table .= '<table class="table table-hover table-striped data_table">';
|
||||
$students_table .= '<tr>
|
||||
<th width="10%" rowspan="2">'.get_lang('FirstName').'</th>
|
||||
<th width="10%" rowspan="2">'.get_lang('LastName').'</th>
|
||||
<th width="30%" colspan="2">'.get_lang('CourseInformation').'</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th width="10%">'.get_lang('Courses').'</th>
|
||||
<th width="10%">'.get_lang('Time').'</th>
|
||||
</tr>';
|
||||
|
||||
$i = 1;
|
||||
foreach ($students as $student) {
|
||||
$courses_by_user = CourseManager::get_courses_list_by_user_id($student['user_id'], true);
|
||||
$count_courses = count($courses_by_user);
|
||||
$rowspan = $count_courses ? $count_courses + 1 : 2;
|
||||
|
||||
if ($i % 2 == 0) {
|
||||
$style = ' style="background-color:#F2F2F2" ';
|
||||
} else {
|
||||
$style = ' style="background-color:#FFF" ';
|
||||
}
|
||||
|
||||
$students_table .= '<tr '.$style.'>
|
||||
<td rowspan="'.$rowspan.'">'.$student['firstname'].'</td>
|
||||
<td rowspan="'.$rowspan.'">'.$student['lastname'].'</td>
|
||||
</tr>';
|
||||
|
||||
// courses information about the student
|
||||
if (!empty($courses_by_user)) {
|
||||
foreach ($courses_by_user as $course) {
|
||||
$course_code = $course['code'];
|
||||
$courseInfo = api_get_course_info($course_code);
|
||||
$courseId = $courseInfo['real_id'];
|
||||
$course_title = $course['title'];
|
||||
$time = api_time_to_hms(Tracking::get_time_spent_on_the_course($student['user_id'], $courseId));
|
||||
$students_table .= '<tr '.$style.'>
|
||||
<td align="right">'.$course_title.'</td>
|
||||
<td align="right">'.$time.'</td>
|
||||
</tr>';
|
||||
}
|
||||
} else {
|
||||
$students_table .= '<tr '.$style.'>
|
||||
<td align="center" colspan="2"><i>'.get_lang('Empty').'</i></td>
|
||||
</tr>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$students_table .= '</table>';
|
||||
} else {
|
||||
$students_table .= get_lang('ThereIsNoInformationAboutYourStudents');
|
||||
}
|
||||
|
||||
$content .= $students_table;
|
||||
|
||||
if (count($students) > 0) {
|
||||
$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin&display=useroverview">'.get_lang('SeeMore').'</a></div>';
|
||||
}
|
||||
//$content .= '</div>';
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function get_students_content_html_for_drh()
|
||||
{
|
||||
$attendance = new Attendance();
|
||||
$students = $this->students;
|
||||
$content = '<h4>'.get_lang('YourStudents').'</h4>';
|
||||
$students_table = null;
|
||||
if (count($students) > 0) {
|
||||
$students_table .= '<table class="table table-hover table-striped data_table">';
|
||||
$students_table .= '<tr>
|
||||
<th>'.get_lang('User').'</th>
|
||||
<th>'.get_lang('AttendancesFaults').'</th>
|
||||
<th>'.get_lang('Evaluations').'</th>
|
||||
</tr>';
|
||||
$i = 1;
|
||||
foreach ($students as $student) {
|
||||
$student_id = $student['user_id'];
|
||||
$firstname = $student['firstname'];
|
||||
$lastname = $student['lastname'];
|
||||
$username = $student['username'];
|
||||
// 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 = '<a title="'.get_lang('GoToStudentDetails').'" href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
|
||||
} else {
|
||||
$attendances_faults_avg = '0%';
|
||||
}
|
||||
|
||||
$courses_by_user = CourseManager::get_courses_list_by_user_id($student_id, true);
|
||||
$evaluations_avg = 0;
|
||||
$score = $weight = 0;
|
||||
foreach ($courses_by_user as $course) {
|
||||
$course_code = $course['code'];
|
||||
$cats = Category::load(
|
||||
null,
|
||||
null,
|
||||
$course_code,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false
|
||||
);
|
||||
$scoretotal = [];
|
||||
if (isset($cats) && isset($cats[0])) {
|
||||
$scoretotal = $cats[0]->calc_score($student_id, null, $course_code);
|
||||
}
|
||||
|
||||
if (!empty($scoretotal)) {
|
||||
$score += $scoretotal[0];
|
||||
$weight += $scoretotal[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($weight)) {
|
||||
$evaluations_avg = '<a title="'.get_lang('GoToStudentDetails').'" href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.$student_id.'">'.round($score, 2).'/'.round($weight, 2).'('.round(($score / $weight) * 100, 2).' %)</a>';
|
||||
}
|
||||
|
||||
if ($i % 2 == 0) {
|
||||
$class_tr = 'row_odd';
|
||||
} else {
|
||||
$class_tr = 'row_even';
|
||||
}
|
||||
$students_table .= '<tr class="'.$class_tr.'">
|
||||
<td>'.api_get_person_name($firstname, $lastname).' ('.$username.')</td>
|
||||
<td>'.$attendances_faults_avg.'</td>
|
||||
<td>'.$evaluations_avg.'</td>
|
||||
</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
$students_table .= '</table>';
|
||||
} else {
|
||||
$students_table .= get_lang('ThereIsNoInformationAboutYourStudents');
|
||||
}
|
||||
|
||||
$content .= $students_table;
|
||||
|
||||
if (count($students) > 0) {
|
||||
$content .= '<div style="text-align:right;margin-top:10px;">
|
||||
<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin&display=yourstudents">'.get_lang('SeeMore').'</a>
|
||||
</div>';
|
||||
}
|
||||
//$content .= '</div>';
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of students.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_number_of_students()
|
||||
{
|
||||
return count($this->students);
|
||||
}
|
||||
}
|
||||
6
plugin/dashboard/block_student/block_student.info
Normal file
6
plugin/dashboard/block_student/block_student.info
Normal file
@@ -0,0 +1,6 @@
|
||||
name = "Student Block"
|
||||
controller = "BlockStudent"
|
||||
description = "Display information about students inside platform"
|
||||
package = Dashboard
|
||||
version = 1.0
|
||||
author = Christian Fasanando
|
||||
8
plugin/dashboard/block_student/index.html
Normal file
8
plugin/dashboard/block_student/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,263 @@
|
||||
<?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>
|
||||
*/
|
||||
use CpChart\Cache as pCache;
|
||||
use CpChart\Data as pData;
|
||||
use CpChart\Image as pImage;
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
class BlockStudentGraph extends Block
|
||||
{
|
||||
private $user_id;
|
||||
private $students;
|
||||
private $path;
|
||||
private $permission = [DRH];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct($user_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 being used from dashboard controller.
|
||||
*
|
||||
* @return array column and content html
|
||||
*/
|
||||
public function get_block()
|
||||
{
|
||||
global $charset;
|
||||
$column = 1;
|
||||
$data = [];
|
||||
$students_attendance_graph = $this->get_students_attendance_graph();
|
||||
|
||||
$html = '<div class="panel panel-default" id="intro">
|
||||
<div class="panel-heading">
|
||||
'.get_lang('StudentsInformationsGraph').'
|
||||
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
|
||||
<em class="fa fa-times"></em>
|
||||
</a></div>
|
||||
</div>
|
||||
<div class="panel-body" align="center">
|
||||
<div style="padding:10px;"><strong>'.get_lang('AttendancesFaults').'</strong></div>
|
||||
'.$students_attendance_graph.'
|
||||
</div>
|
||||
</div>';
|
||||
$data['column'] = $column;
|
||||
$data['content_html'] = $html;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a graph containing information 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()
|
||||
{
|
||||
$students = $this->students;
|
||||
$attendance = new Attendance();
|
||||
|
||||
// get data
|
||||
$attendances_faults_avg = [];
|
||||
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
|
||||
$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'];
|
||||
} else {
|
||||
$attendances_faults_avg[$student['lastname']] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
arsort($attendances_faults_avg);
|
||||
$usernames = array_keys($attendances_faults_avg);
|
||||
|
||||
$faults = [];
|
||||
foreach ($usernames as $username) {
|
||||
$faults[] = $attendances_faults_avg[$username];
|
||||
}
|
||||
|
||||
$graph = '';
|
||||
$img_file = '';
|
||||
if (is_array($usernames) && count($usernames) > 0) {
|
||||
// Defining data
|
||||
$dataSet = new pData();
|
||||
$dataSet->addPoints($faults, 'Serie1');
|
||||
$dataSet->addPoints($usernames, 'Labels');
|
||||
$dataSet->setSerieDescription('Series1', get_lang('Average'));
|
||||
$dataSet->setSerieDescription('Labels', get_lang('User'));
|
||||
$dataSet->setAbscissa('Labels');
|
||||
$dataSet->setAbscissaName(get_lang('User'));
|
||||
$dataSet->setAxisName(0, get_lang('Attendance'));
|
||||
$palette = [
|
||||
'0' => ['R' => 186, 'G' => 206, 'B' => 151, 'Alpha' => 100],
|
||||
'1' => ['R' => 210, 'G' => 148, 'B' => 147, 'Alpha' => 100],
|
||||
'2' => ['R' => 148, 'G' => 170, 'B' => 208, 'Alpha' => 100],
|
||||
'3' => ['R' => 221, 'G' => 133, 'B' => 61, 'Alpha' => 100],
|
||||
'4' => ['R' => 65, 'G' => 153, 'B' => 176, 'Alpha' => 100],
|
||||
'5' => ['R' => 114, 'G' => 88, 'B' => 144, 'Alpha' => 100],
|
||||
'6' => ['R' => 138, 'G' => 166, 'B' => 78, 'Alpha' => 100],
|
||||
'7' => ['R' => 171, 'G' => 70, 'B' => 67, 'Alpha' => 100],
|
||||
'8' => ['R' => 69, 'G' => 115, 'B' => 168, 'Alpha' => 100],
|
||||
];
|
||||
// Cache definition
|
||||
$cachePath = api_get_path(SYS_ARCHIVE_PATH);
|
||||
$myCache = new pCache(
|
||||
[
|
||||
'CacheFolder' => substr(
|
||||
$cachePath,
|
||||
0,
|
||||
strlen($cachePath) - 1
|
||||
),
|
||||
]
|
||||
);
|
||||
$chartHash = $myCache->getHash($dataSet);
|
||||
if ($myCache->isInCache($chartHash)) {
|
||||
$imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
|
||||
$myCache->saveFromCache($chartHash, $imgPath);
|
||||
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
|
||||
} else {
|
||||
$maxCounts = max(count($usernames), count($faults));
|
||||
if ($maxCounts < 5) {
|
||||
$heightSize = 200;
|
||||
} else {
|
||||
$heightSize = $maxCounts * 40;
|
||||
}
|
||||
|
||||
/* Create the pChart object */
|
||||
$widthSize = 480;
|
||||
$angle = 40;
|
||||
|
||||
$myPicture = new pImage($widthSize, $heightSize, $dataSet);
|
||||
|
||||
/* Turn of Antialiasing */
|
||||
$myPicture->Antialias = false;
|
||||
|
||||
/* Add a border to the picture */
|
||||
$myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, ['R' => 0, 'G' => 0, 'B' => 0]);
|
||||
|
||||
/* Set the default font */
|
||||
$myPicture->setFontProperties(
|
||||
[
|
||||
'FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
|
||||
'FontSize' => 10,
|
||||
]
|
||||
);
|
||||
|
||||
/* Do NOT Write the chart title */
|
||||
|
||||
/* Define the chart area */
|
||||
$myPicture->setGraphArea(80, 40, $widthSize - 20, $heightSize - 40);
|
||||
|
||||
/* Draw the scale */
|
||||
$scaleSettings = [
|
||||
'GridR' => 200,
|
||||
'GridG' => 200,
|
||||
'GridB' => 200,
|
||||
'DrawSubTicks' => true,
|
||||
'CycleBackground' => true,
|
||||
'Mode' => SCALE_MODE_ADDALL_START0,
|
||||
'Pos' => SCALE_POS_TOPBOTTOM,
|
||||
'DrawXLines' => false,
|
||||
'LabelRotation' => $angle,
|
||||
];
|
||||
|
||||
$myPicture->drawScale($scaleSettings);
|
||||
|
||||
/* Turn on shadow computing */
|
||||
$myPicture->setShadow(true, ['X' => 1, 'Y' => 1, 'R' => 0, 'G' => 0, 'B' => 0, 'Alpha' => 10]);
|
||||
|
||||
/* Draw the chart */
|
||||
$myPicture->setShadow(true, ['X' => 1, 'Y' => 1, 'R' => 0, 'G' => 0, 'B' => 0, 'Alpha' => 10]);
|
||||
$settings = [
|
||||
'OverrideColors' => $palette,
|
||||
'Gradient' => false,
|
||||
'GradientMode' => GRADIENT_SIMPLE,
|
||||
'DisplayPos' => LABEL_POS_TOP,
|
||||
'DisplayValues' => true,
|
||||
'DisplayR' => 0,
|
||||
'DisplayG' => 0,
|
||||
'DisplayB' => 0,
|
||||
'DisplayShadow' => true,
|
||||
'Surrounding' => 10,
|
||||
];
|
||||
$myPicture->drawBarChart($settings);
|
||||
|
||||
/* Write and save into cache */
|
||||
$myCache->writeToCache($chartHash, $myPicture);
|
||||
$imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
|
||||
$myCache->saveFromCache($chartHash, $imgPath);
|
||||
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
|
||||
}
|
||||
$graph = '<img src="'.$imgPath.'" >';
|
||||
} else {
|
||||
$graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8').'</p>';
|
||||
}
|
||||
|
||||
return $graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of students.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_number_of_students()
|
||||
{
|
||||
return count($this->students);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
name = "Student Graph Block"
|
||||
controller = "BlockStudentGraph"
|
||||
description = "Display information about students inside platform with graph"
|
||||
package = Dashboard
|
||||
version = 1.0
|
||||
author = Christian Fasanando
|
||||
212
plugin/dashboard/block_teacher/block_teacher.class.php
Normal file
212
plugin/dashboard/block_teacher/block_teacher.class.php
Normal file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
/* For licensing terms, see /license.txt */
|
||||
|
||||
/**
|
||||
* This file is part of teacher 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used like controller for teacher block plugin,
|
||||
* the class name must be registered inside path.info file
|
||||
* (e.g: controller = "BlockTeacher"), so dashboard controller will be instantiate it.
|
||||
*
|
||||
* @package chamilo.dashboard
|
||||
*/
|
||||
class BlockTeacher extends Block
|
||||
{
|
||||
private $user_id;
|
||||
private $teachers;
|
||||
private $path;
|
||||
private $permission = [DRH];
|
||||
|
||||
/**
|
||||
* Controller.
|
||||
*/
|
||||
public function __construct($user_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->path = 'block_teacher';
|
||||
if ($this->is_block_visible_for_user($user_id)) {
|
||||
$this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return content html containing information about
|
||||
* teachers and its position for showing it inside dashboard interface
|
||||
* 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 = [];
|
||||
$teacher_content_html = $this->get_teachers_content_html_for_drh();
|
||||
$html = '
|
||||
<div class="panel panel-default" id="intro">
|
||||
<div class="panel-heading">
|
||||
'.get_lang('TeachersInformationsList').'
|
||||
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
|
||||
<em class="fa fa-times"></em>
|
||||
</a></div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
'.$teacher_content_html.'
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
$data['column'] = $column;
|
||||
$data['content_html'] = $html;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a content html, it's used inside get_block method
|
||||
* for showing it inside dashboard interface.
|
||||
*
|
||||
* @return string content html
|
||||
*/
|
||||
public function get_teachers_content_html_for_platform_admin()
|
||||
{
|
||||
$teachers = $this->teachers;
|
||||
$content = '<h4>'.get_lang('YourTeachers').'</h4>';
|
||||
|
||||
$teachers_table = null;
|
||||
if (count($teachers) > 0) {
|
||||
$teachers_table .= '<table class="table table-hover table-striped data_table" width:"95%">';
|
||||
$teachers_table .= '
|
||||
<tr>
|
||||
<th>'.get_lang('User').'</th>
|
||||
<th>'.get_lang('TimeSpentOnThePlatform').'</th>
|
||||
<th>'.get_lang('LastConnexion').'</th>
|
||||
</tr>
|
||||
';
|
||||
$i = 1;
|
||||
foreach ($teachers as $teacher) {
|
||||
$teacher_id = $teacher['user_id'];
|
||||
$firstname = $teacher['firstname'];
|
||||
$lastname = $teacher['lastname'];
|
||||
$username = $teacher['username'];
|
||||
|
||||
$time_on_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($teacher_id));
|
||||
$last_connection = Tracking::get_last_connection_date($teacher_id);
|
||||
|
||||
if ($i % 2 == 0) {
|
||||
$class_tr = 'row_odd';
|
||||
} else {
|
||||
$class_tr = 'row_even';
|
||||
}
|
||||
$teachers_table .= '
|
||||
<tr class="'.$class_tr.'">
|
||||
<td>'.api_get_person_name($firstname, $lastname).' ('.$username.')</td>
|
||||
<td align="right">'.$time_on_platform.'</td>
|
||||
<td align="right">'.$last_connection.'</td>
|
||||
</tr>
|
||||
';
|
||||
$i++;
|
||||
}
|
||||
$teachers_table .= '</table>';
|
||||
} else {
|
||||
$teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers');
|
||||
}
|
||||
|
||||
$content .= $teachers_table;
|
||||
|
||||
if (count($teachers) > 0) {
|
||||
$content .= '<div style="text-align:right;margin-top:10px;">
|
||||
<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/index.php?view=admin">'.get_lang('SeeMore').'</a></div>';
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function get_teachers_content_html_for_drh()
|
||||
{
|
||||
$teachers = $this->teachers;
|
||||
$content = '<h4>'.get_lang('YourTeachers').'</h4>';
|
||||
$teachers_table = null;
|
||||
if (count($teachers) > 0) {
|
||||
$a_last_week = get_last_week();
|
||||
$last_week = date('Y-m-d', $a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]);
|
||||
|
||||
$teachers_table .= '<table class="table table-hover table-striped data_table" width:"95%">';
|
||||
$teachers_table .= '
|
||||
<tr>
|
||||
<th>'.get_lang('User').'</th>
|
||||
<th>'.get_lang('TimeSpentLastWeek').'<br />'.$last_week.'</th>
|
||||
</tr>
|
||||
';
|
||||
|
||||
$i = 1;
|
||||
foreach ($teachers as $teacher) {
|
||||
$teacher_id = $teacher['user_id'];
|
||||
$firstname = $teacher['firstname'];
|
||||
$lastname = $teacher['lastname'];
|
||||
$username = $teacher['username'];
|
||||
$time_on_platform = api_time_to_hms(
|
||||
Tracking::get_time_spent_on_the_platform($teacher_id, true)
|
||||
);
|
||||
|
||||
if ($i % 2 == 0) {
|
||||
$class_tr = 'row_odd';
|
||||
} else {
|
||||
$class_tr = 'row_even';
|
||||
}
|
||||
$teachers_table .= '<tr class="'.$class_tr.'">
|
||||
<td>'.api_get_person_name($firstname, $lastname).' ('.$username.')</td>
|
||||
<td align="right">'.$time_on_platform.'</td>
|
||||
</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
$teachers_table .= '</table>';
|
||||
} else {
|
||||
$teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers');
|
||||
}
|
||||
$content .= $teachers_table;
|
||||
if (count($teachers) > 0) {
|
||||
$content .= '<div style="text-align:right;margin-top:10px;"><a href="'.api_get_path(WEB_CODE_PATH).'mySpace/teachers.php">'.get_lang('SeeMore').'</a></div>';
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of teachers.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_number_of_teachers()
|
||||
{
|
||||
return count($this->teachers);
|
||||
}
|
||||
}
|
||||
6
plugin/dashboard/block_teacher/block_teacher.info
Normal file
6
plugin/dashboard/block_teacher/block_teacher.info
Normal file
@@ -0,0 +1,6 @@
|
||||
name = "Teacher Block"
|
||||
controller = "BlockTeacher"
|
||||
description = "Display information about teachers inside platform"
|
||||
package = Dashboard
|
||||
version = 1.0
|
||||
author = Christian Fasanando
|
||||
8
plugin/dashboard/block_teacher/index.html
Normal file
8
plugin/dashboard/block_teacher/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of teacher 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
|
||||
*/
|
||||
|
||||
/**
|
||||
* required files for getting data.
|
||||
*/
|
||||
use CpChart\Cache as pCache;
|
||||
use CpChart\Data as pData;
|
||||
use CpChart\Image as pImage;
|
||||
|
||||
/**
|
||||
* This class is used like controller for teacher graph block plugin,
|
||||
* the class name must be registered inside path.info file (e.g: controller = "BlockTeacherGraph"), so dashboard controller will be instantiate it.
|
||||
*
|
||||
* @package chamilo.dashboard
|
||||
*/
|
||||
class BlockTeacherGraph extends Block
|
||||
{
|
||||
private $user_id;
|
||||
private $teachers;
|
||||
private $path;
|
||||
private $permission = [DRH];
|
||||
|
||||
/**
|
||||
* Controller.
|
||||
*/
|
||||
public function __construct($user_id)
|
||||
{
|
||||
$this->user_id = $user_id;
|
||||
$this->path = 'block_teacher_graph';
|
||||
if ($this->is_block_visible_for_user($user_id)) {
|
||||
$this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return content html containing information about teachers and its position for showing it inside dashboard interface
|
||||
* 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 = [];
|
||||
$teacher_information_graph = $this->get_teachers_information_graph();
|
||||
$html = '
|
||||
<div class="panel panel-default" id="intro">
|
||||
<div class="panel-heading">'.get_lang('TeachersInformationsGraph').'
|
||||
<div class="pull-right"><a class="btn btn-danger btn-xs" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">
|
||||
<em class="fa fa-times"></em>
|
||||
</a></div>
|
||||
</div>
|
||||
<div class="panel-body" align="center">
|
||||
<div style="padding:10px;"><strong>'.get_lang('TimeSpentOnThePlatformLastWeekByDay').'</strong></div>
|
||||
'.$teacher_information_graph.'
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
$data['column'] = $column;
|
||||
$data['content_html'] = $html;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface.
|
||||
*
|
||||
* @return string content html
|
||||
*/
|
||||
public function get_teachers_information_graph()
|
||||
{
|
||||
$teachers = $this->teachers;
|
||||
$graph = '';
|
||||
$user_ids = array_keys($teachers);
|
||||
$a_last_week = get_last_week();
|
||||
|
||||
if (is_array($user_ids) && count($user_ids) > 0) {
|
||||
$dataSet = new pData();
|
||||
foreach ($user_ids as $user_id) {
|
||||
$teacher_info = api_get_user_info($user_id);
|
||||
$username = $teacher_info['username'];
|
||||
$time_by_days = [];
|
||||
foreach ($a_last_week as $day) {
|
||||
// day is received as y-m-d 12:00:00
|
||||
$start_date = api_get_utc_datetime($day);
|
||||
$end_date = api_get_utc_datetime($day + (3600 * 24 - 1));
|
||||
|
||||
$time_on_platform_by_day = Tracking::get_time_spent_on_the_platform(
|
||||
$user_id,
|
||||
'custom',
|
||||
$start_date,
|
||||
$end_date
|
||||
);
|
||||
$hours = floor($time_on_platform_by_day / 3600);
|
||||
$min = floor(($time_on_platform_by_day - ($hours * 3600)) / 60);
|
||||
$time_by_days[] = $min;
|
||||
}
|
||||
$dataSet->addPoints($time_by_days, $username);
|
||||
}
|
||||
|
||||
$last_week = date('Y-m-d', $a_last_week[0]).' '.get_lang('To').' '.date('Y-m-d', $a_last_week[6]);
|
||||
$days_on_week = [];
|
||||
foreach ($a_last_week as $weekday) {
|
||||
$days_on_week[] = date('d/m', $weekday);
|
||||
}
|
||||
|
||||
$dataSet->addPoints($days_on_week, 'Days');
|
||||
$dataSet->setAbscissaName($last_week);
|
||||
$dataSet->setAxisName(0, get_lang('Minutes'));
|
||||
$dataSet->setAbscissa('Days');
|
||||
$dataSet->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
|
||||
|
||||
// Cache definition
|
||||
$cachePath = api_get_path(SYS_ARCHIVE_PATH);
|
||||
$myCache = new pCache(['CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)]);
|
||||
$chartHash = $myCache->getHash($dataSet);
|
||||
if ($myCache->isInCache($chartHash)) {
|
||||
$imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
|
||||
$myCache->saveFromCache($chartHash, $imgPath);
|
||||
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
|
||||
} else {
|
||||
/* Create the pChart object */
|
||||
$widthSize = 440;
|
||||
$heightSize = 350;
|
||||
$angle = 50;
|
||||
$myPicture = new pImage($widthSize, $heightSize, $dataSet);
|
||||
|
||||
/* Turn of Antialiasing */
|
||||
$myPicture->Antialias = false;
|
||||
|
||||
/* Add a border to the picture */
|
||||
$myPicture->drawRectangle(0, 0, $widthSize - 1, $heightSize - 1, ['R' => 0, 'G' => 0, 'B' => 0]);
|
||||
|
||||
/* Set the default font */
|
||||
$myPicture->setFontProperties(['FontName' => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', 'FontSize' => 10]);
|
||||
|
||||
/* Do NOT Write the chart title */
|
||||
|
||||
/* Define the chart area */
|
||||
$myPicture->setGraphArea(40, 40, $widthSize - 20, $heightSize - 80);
|
||||
|
||||
/* Draw the scale */
|
||||
$scaleSettings = [
|
||||
'GridR' => 200,
|
||||
'GridG' => 200,
|
||||
'GridB' => 200,
|
||||
'DrawSubTicks' => true,
|
||||
'CycleBackground' => true,
|
||||
'Mode' => SCALE_MODE_ADDALL_START0,
|
||||
'LabelRotation' => $angle,
|
||||
];
|
||||
|
||||
$myPicture->drawScale($scaleSettings);
|
||||
|
||||
/* Turn on shadow computing */
|
||||
$myPicture->setShadow(true, ['X' => 1, 'Y' => 1, 'R' => 0, 'G' => 0, 'B' => 0, 'Alpha' => 10]);
|
||||
|
||||
/* Draw the chart */
|
||||
$myPicture->setShadow(true, ['X' => 1, 'Y' => 1, 'R' => 0, 'G' => 0, 'B' => 0, 'Alpha' => 10]);
|
||||
$settings = [
|
||||
'DisplayValues' => true,
|
||||
'DisplayR' => 0,
|
||||
'DisplayG' => 0,
|
||||
'DisplayB' => 0,
|
||||
];
|
||||
$myPicture->drawFilledSplineChart($settings);
|
||||
$myPicture->drawLegend(40, 20, ['Mode' => LEGEND_HORIZONTAL]);
|
||||
|
||||
/* Write and save into cache */
|
||||
$myCache->writeToCache($chartHash, $myPicture);
|
||||
$imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
|
||||
$myCache->saveFromCache($chartHash, $imgPath);
|
||||
$imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
|
||||
}
|
||||
$graph = '<img src="'.$imgPath.'" >';
|
||||
} else {
|
||||
$graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8').'</p>';
|
||||
}
|
||||
|
||||
return $graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of teachers.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_number_of_teachers()
|
||||
{
|
||||
return count($this->teachers);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
name = "Teacher Graph Block"
|
||||
controller = "BlockTeacherGraph"
|
||||
description = "Display information about teachers inside platform with graph"
|
||||
package = Dashboard
|
||||
version = 1.0
|
||||
author = Christian Fasanando
|
||||
80
plugin/dashboard/css/default.css
Normal file
80
plugin/dashboard/css/default.css
Normal file
@@ -0,0 +1,80 @@
|
||||
/* Colors */
|
||||
.color-yellow {background:#f2bc00;}
|
||||
.color-red {background:#dd0000;}
|
||||
.color-blue {background:#00A9E0;}
|
||||
.color-white {background:#dfdfdf;}
|
||||
.color-orange {background:#f66e00;}
|
||||
.color-green {background:#8dc100;}
|
||||
.color-yellow h3,
|
||||
.color-white h3,
|
||||
.color-green h3
|
||||
{color:#000;}
|
||||
.color-red h3,
|
||||
.color-blue h3,
|
||||
.color-orange h3 {
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
/* End Colors */
|
||||
|
||||
.widget {
|
||||
margin: 30px 20px 0 20px;
|
||||
padding: 2px;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-radius: 4px;
|
||||
}
|
||||
.widget .widget-head {
|
||||
color: #000;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
}
|
||||
.widget .widget-head h3 {
|
||||
padding: 0 5px;
|
||||
float: left;
|
||||
}
|
||||
.widget .widget-content {
|
||||
background: #FFF url(img/widget-content-bg.png) repeat-x;
|
||||
padding: 0 5px;
|
||||
color: #000;
|
||||
-moz-border-radius-bottomleft: 2px;
|
||||
-moz-border-radius-bottomright: 2px;
|
||||
-webkit-border-bottom-left-radius: 2px;
|
||||
-webkit-border-bottom-right-radius: 2px;
|
||||
line-height: 1.2em;
|
||||
overflow: hidden;
|
||||
}
|
||||
.widget .widget-content p {
|
||||
padding: 0.8em 0;
|
||||
border-bottom: 1px solid #666;
|
||||
}
|
||||
.widget .widget-content pre {
|
||||
padding: 0.5em 5px;
|
||||
color: #EEE;
|
||||
font-size: 12px;
|
||||
}
|
||||
.widget .widget-content ul {
|
||||
padding: 5px 0 5px 20px;
|
||||
list-style: disc;
|
||||
}
|
||||
.widget .widget-content ul li {padding: 3px 0;}
|
||||
.widget .widget-content ul.images {
|
||||
padding: 7px 0 0 0;
|
||||
list-style: none;
|
||||
height: 1%;
|
||||
}
|
||||
.widget .widget-content ul.images li {
|
||||
display: inline;
|
||||
float: left;
|
||||
}
|
||||
.widget .widget-content ul.images img {
|
||||
display: inline;
|
||||
float: left;
|
||||
margin: 0 0 7px 7px;
|
||||
}
|
||||
|
||||
.widget-actions {text-align:right;margin-right:5px;margin-top:5px;}
|
||||
.widget-actions img {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
8
plugin/dashboard/index.html
Normal file
8
plugin/dashboard/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<br />
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user