Minor - format code.

1.9.x
Julio Montoya 12 years ago
parent 7676bbac14
commit b6df93a346
  1. 338
      plugin/dashboard/block_course/block_course.class.php
  2. 358
      plugin/dashboard/block_daily/block_daily.class.php
  3. 103
      plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php
  4. 27
      plugin/dashboard/block_session/block_session.class.php
  5. 24
      plugin/dashboard/block_student/block_student.class.php
  6. 27
      plugin/dashboard/block_student_graph/block_student_graph.class.php
  7. 65
      plugin/dashboard/block_teacher/block_teacher.class.php
  8. 59
      plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php

@ -9,191 +9,215 @@
/** /**
* required files for getting data * required files for getting data
*/ */
require_once api_get_path(LIBRARY_PATH).'thematic.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'thematic.lib.php';
/** /**
* This class is used like controller for this course block plugin, * 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 * the class name must be registered inside path.info file (e.g: controller = "BlockCourse"), so dashboard controller will be instantiate it
* @package chamilo.dashboard * @package chamilo.dashboard
*/ */
class BlockCourse extends Block { class BlockCourse extends Block
{
private $user_id;
private $courses; private $user_id;
private $path; private $courses;
private $permission = array(DRH); private $path;
private $permission = array(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)) {
/*if (api_is_platform_admin()) {
$this->courses = CourseManager::get_real_course_list();
} else {*/
$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 * Constructor
* @param int User id */
* @return bool Is block visible for user public function __construct($user_id)
*/ {
public function is_block_visible_for_user($user_id) { $this->user_id = $user_id;
$user_info = api_get_user_info($user_id); $this->path = 'block_course';
$user_status = $user_info['status']; if ($this->is_block_visible_for_user($user_id)) {
$is_block_visible_for_user = false; /*if (api_is_platform_admin()) {
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { $this->courses = CourseManager::get_real_course_list();
$is_block_visible_for_user = true; } else {*/
} $this->courses = CourseManager::get_courses_followed_by_drh(
return $is_block_visible_for_user; $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 * 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 * it's important to use the name 'get_block' for beeing used from dashboard controller
* @return array column and content html * @return array column and content html
*/ */
public function get_block() { public function get_block()
{
global $charset; global $charset;
$column = 2;
$column = 2; $data = array();
$data = array(); $content = '';
$content = ''; $data_table = '';
$data_table = ''; $content = $this->get_content_html();
$content = $this->get_content_html(); $html = '
$html = '
<li class="widget color-green" id="intro"> <li class="widget color-green" id="intro">
<div class="widget-head"> <div class="widget-head">
<h3>'.get_lang('CoursesInformation').'</h3> <h3>' . get_lang('CoursesInformation') . '</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 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>
<div class="widget-content"> <div class="widget-content">
'.$content.' ' . $content . '
</div> </div>
</li> </li>
'; ';
$data['column'] = $column; $data['column'] = $column;
$data['content_html'] = $html; $data['content_html'] = $html;
return $data; return $data;
} }
/** /**
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html * @return string content html
*/ */
public function get_content_html() { public function get_content_html()
{
$course_data = $this->get_course_information_data();
$content = '<div style="margin:10px;">'; $course_data = $this->get_course_information_data();
$content .= '<h3><font color="#000">'.get_lang('YourCourseList').'</font></h3>'; $content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">' . get_lang(
'YourCourseList'
) . '</font></h3>';
$data_table = null; $data_table = null;
if (!empty($course_data)) { if (!empty($course_data)) {
$data_table .= '<table class="data_table" width:"95%">'; $data_table .= '<table class="data_table" width:"95%">';
$data_table .= '<tr> $data_table .= '<tr>
<th>'.get_lang('CourseTitle').'</th> <th>' . get_lang('CourseTitle') . '</th>
<th width="20%">'.get_lang('NbStudents').'</th> <th width="20%">' . get_lang('NbStudents') . '</th>
<th width="20%">'.get_lang('AvgTimeSpentInTheCourse').'</th> <th width="20%">' . get_lang(
<th width="20%">'.get_lang('ThematicAdvance').'</th> 'AvgTimeSpentInTheCourse'
) . '</th>
<th width="20%">' . get_lang(
'ThematicAdvance'
) . '</th>
</tr>'; </tr>';
$i = 1; $i = 1;
foreach ($course_data as $course) { foreach ($course_data as $course) {
if ($i%2 == 0) { if ($i % 2 == 0) {
$class_tr = 'row_odd'; $class_tr = 'row_odd';
} else { } else {
$class_tr = 'row_even'; $class_tr = 'row_even';
} }
$data_table .= '<tr class="'.$class_tr.'">'; $data_table .= '<tr class="' . $class_tr . '">';
if (!isset($course[2])) { if (!isset($course[2])) {
$course[2] = '0:00:00'; $course[2] = '0:00:00';
} }
foreach ($course as $cell) { foreach ($course as $cell) {
$data_table .= '<td align="right">'.$cell.'</td>'; $data_table .= '<td align="right">' . $cell . '</td>';
} }
$data_table .= '</tr>'; $data_table .= '</tr>';
$i++; $i++;
} }
$data_table .= '</table>'; $data_table .= '</table>';
} else { } else {
$data_table .= get_lang('ThereIsNoInformationAboutYourCourses'); $data_table .= get_lang('ThereIsNoInformationAboutYourCourses');
} }
$content .= $data_table; $content .= $data_table;
if (!empty($course_data)) { 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 style="text-align:right;margin-top:10px;"><a href="' . api_get_path(
} WEB_CODE_PATH
$content .= '</div>'; ) . 'mySpace/course.php">' . get_lang('SeeMore') . '</a></div>';
}
return $content; $content .= '</div>';
}
return $content;
}
/** /**
* Get number of courses * Get number of courses
* @return int * @return int
*/ */
function get_number_of_courses() { function get_number_of_courses()
return count($this->courses); {
} return count($this->courses);
}
/**
* Get course information data
* @return array
*/
function get_course_information_data() {
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$a_course_students = array();
$course_data = array();
$courses = $this->courses;
$thematic = new Thematic();
foreach ($courses as $row_course) {
$course_code = $row_course['code'];
$avg_assignments_in_course = $avg_messages_in_course = $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.course_code='$course_code'";
$rs = Database::query($sql);
$users = array();
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, $course_code)/$nb_students_in_course);
} else {
$avg_time_spent_in_course = null;
}
$tematic_advance_progress = 0;
$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 = array();
$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;
}
/**
* Get course information data
* @return array
*/
function get_course_information_data()
{
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$course_data = array();
$courses = $this->courses;
$thematic = new Thematic();
foreach ($courses as $row_course) {
$course_code = $row_course['code'];
$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.course_code='$course_code'";
$rs = Database::query($sql);
$users = array();
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, $course_code ) / $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 = array();
$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;
}
} }
?>

@ -5,158 +5,178 @@
* @package chamilo.dashboard * @package chamilo.dashboard
* @author Marco Sousa original code * @author Marco Sousa original code
* @author Julio Montoya class named was changed of name, and some minor changes * @author Julio Montoya class named was changed of name, and some minor changes
*/ */
/** /**
* required files for getting data * required files for getting data
*/ */
require_once api_get_path(LIBRARY_PATH).'thematic.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'thematic.lib.php';
require_once api_get_path(LIBRARY_PATH).'attendance.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'attendance.lib.php';
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be.inc.php'; require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be.inc.php';
/** /**
* This class is used like controller for this course block plugin, * 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 * the class name must be registered inside path.info file (e.g: controller = "BlockDiario"), so dashboard controller will be instantiate it
* @package chamilo.dashboard * @package chamilo.dashboard
*/ */
class BlockDaily extends Block { class BlockDaily extends Block
{
private $user_id;
private $courses; private $user_id;
private $path; private $courses;
private $permission = array(DRH); private $path;
private $permission = array(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)) {
/*if (api_is_platform_admin()) {
$this->courses = CourseManager::get_real_course_list();
} else {*/
$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 * Constructor
* @param int User id */
* @return bool Is block visible for user public function __construct($user_id)
*/ {
public function is_block_visible_for_user($user_id) { $this->user_id = $user_id;
$user_info = api_get_user_info($user_id); $this->path = 'block_daily';
$user_status = $user_info['status']; if ($this->is_block_visible_for_user($user_id)) {
$is_block_visible_for_user = false; /*if (api_is_platform_admin()) {
if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { $this->courses = CourseManager::get_real_course_list();
$is_block_visible_for_user = true; } else {*/
} $this->courses = CourseManager::get_courses_followed_by_drh(
return $is_block_visible_for_user; $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 * 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 * it's important to use the name 'get_block' for beeing used from dashboard controller
* @return array column and content html * @return array column and content html
*/ */
public function get_block() { public function get_block()
{
global $charset; global $charset;
$column = 2; $column = 2;
$data = array(); $data = array();
$content = ''; $content = '';
$data_table = ''; $data_table = '';
$content = $this->get_content_html(); $content = $this->get_content_html();
$html = '<li class="widget color-green" id="intro"> $html = '<li class="widget color-green" id="intro">
<div class="widget-head"> <div class="widget-head">
<h3>'.get_lang('GradebookAndAttendances').'</h3> <h3>' . get_lang('GradebookAndAttendances') . '</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 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>
<div class="widget-content"> <div class="widget-content">
'.$content.' ' . $content . '
</div> </div>
</li> </li>
'; ';
$data['column'] = $column; $data['column'] = $column;
$data['content_html'] = $html; $data['content_html'] = $html;
return $data; return $data;
} }
/** /**
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html * @return string content html
*/ */
public function get_content_html() { public function get_content_html()
{
$course_data = $this->get_course_information_data(); $course_data = $this->get_course_information_data();
$content = '<div style="margin:10px;">'; $content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourCourseList').'</font></h3>'; $content .= '<h3><font color="#000">' . get_lang(
'YourCourseList'
) . '</font></h3>';
$data_table = null; $data_table = null;
if (!empty($course_data)) { if (!empty($course_data)) {
$data_table .= '<table class="data_table" width:"95%">'; $data_table .= '<table class="data_table" width:"95%">';
$data_table .= '<tr> $data_table .= '<tr>
<th>'.get_lang('CourseTitle').'</th> <th>' . get_lang('CourseTitle') . '</th>
<th width="20%">'.get_lang('NbStudents').'</th> <th width="20%">' . get_lang('NbStudents') . '</th>
<th width="20%">'.get_lang('Evaluation').'</th> <th width="20%">' . get_lang('Evaluation') . '</th>
<th width="20%">'.get_lang('ToolAttendance').'</th> <th width="20%">' . get_lang('ToolAttendance') . '</th>
</tr>'; </tr>';
$i = 1; $i = 1;
foreach ($course_data as $course) { foreach ($course_data as $course) {
if ($i%2 == 0) { if ($i % 2 == 0) {
$class_tr = 'row_odd'; $class_tr = 'row_odd';
} else { } else {
$class_tr = 'row_even'; $class_tr = 'row_even';
} }
$data_table .= '<tr class="'.$class_tr.'">'; $data_table .= '<tr class="' . $class_tr . '">';
if (!isset($course[3])) { if (!isset($course[3])) {
$course[3] = get_lang('NotAvailable'); $course[3] = get_lang('NotAvailable');
} }
foreach ($course as $cell) { foreach ($course as $cell) {
$data_table .= '<td align="right">'.$cell.'</td>'; $data_table .= '<td align="right">' . $cell . '</td>';
} }
$data_table .= '</tr>'; $data_table .= '</tr>';
$i++; $i++;
} }
$data_table .= '</table>'; $data_table .= '</table>';
} else { } else {
$data_table .= get_lang('ThereIsNoInformationAboutYourCourses'); $data_table .= get_lang('ThereIsNoInformationAboutYourCourses');
} }
$content .= $data_table; $content .= $data_table;
if (!empty($course_data)) { 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 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; $content .= '</div>';
} return $content;
}
/**
* Get number of courses
* @return int
*/
function get_number_of_courses()
{
return count($this->courses);
}
/** /**
* Get number of courses * Get course information data
* @return int * @return array
*/ */
function get_number_of_courses() { function get_course_information_data()
return count($this->courses); {
} $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$course_data = array();
/** $courses = $this->courses;
* Get course information data
* @return array foreach ($courses as $row_course) {
*/
function get_course_information_data() {
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$a_course_students = array();
$course_data = array();
$courses = $this->courses;
foreach ($courses as $row_course) {
$score = null; $score = null;
$course_code = $row_course['code']; $course_code = $row_course['code'];
$course_info = api_get_course_info($course_code); $course_info = api_get_course_info($course_code);
@ -167,63 +187,73 @@ class BlockDaily extends Block {
// Attendance table // Attendance table
$table_course = Database::get_course_table(TABLE_ATTENDANCE); $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"; $sql = "SELECT id, name, attendance_qualify_max FROM $table_course
$rs = Database::query($sql); WHERE c_id = " . $course_info['real_id'] . " AND active = 1 AND session_id = 0";
$attendance = array(); $rs = Database::query($sql);
$attendance = array();
$attendances = array(); $attendances = array();
$param_gradebook = ''; $param_gradebook = '';
if (isset($_SESSION['gradebook'])) { if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.$_SESSION['gradebook']; $param_gradebook = '&gradebook=' . $_SESSION['gradebook'];
} }
while ($row = Database::fetch_array($rs,'ASSOC')) { while ($row = Database::fetch_array($rs, 'ASSOC')) {
$attendance['done'] = $row['attendance_qualify_max']; $attendance['done'] = $row['attendance_qualify_max'];
$attendance['id'] = $row['id']; $attendance['id'] = $row['id'];
//$attendance['name'] = $row['name']; //$attendance['name'] = $row['name'];
$attendance['course_code'] = $course_code; $attendance['course_code'] = $course_code;
if ($attendance['done'] != '0') 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'].$param_gradebook.'">'.Display::return_icon('printmgr.gif',get_lang('Print')).'</a>'; $attendances[] = '<a href="' . api_get_path(WEB_PATH).'main/attendance/index.php?cidReq=' . $attendance['course_code'] . '&action=attendance_sheet_print&attendance_id=' . $attendance['id'] . $param_gradebook . '">' . Display::return_icon('printmgr.gif', get_lang('Print')).'</a>';
else } else {
$attendances[] = get_lang("NotAvailable"); $attendances[] = get_lang("NotAvailable");
} }
}
// quantidade de alunos
// quantidade de alunos
$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user WHERE course_rel_user.status=".STUDENT." AND course_rel_user.course_code='$course_code'";
$rs = Database::query($sql); $sql = "SELECT user_id FROM $tbl_course_user as course_rel_user
$users = array(); WHERE course_rel_user.status=" . STUDENT . " AND course_rel_user.course_code='$course_code'";
while ($row = Database::fetch_array($rs)) { $rs = Database::query($sql);
$users[] = $row['user_id']; $users = array();
} while ($row = Database::fetch_array($rs)) {
if (count($users) > 0) { $users[] = $row['user_id'];
$nb_students_in_course = count($users); }
} 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 { if (!empty($tematic_advance)) {
$tematic_advance_progress = '0%'; $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 // Score
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY); $tbl_grade_categories = Database :: get_main_table(
$sql = "SELECT id from " . $tbl_grade_categories ." WHERE course_code ='".$course_code."'"; TABLE_MAIN_GRADEBOOK_CATEGORY
$rs = Database::query($sql); );
$category = null; $sql = "SELECT id from " . $tbl_grade_categories . "
while ($row = Database::fetch_array($rs)) { WHERE course_code ='" . $course_code . "'";
$category = $row['id']; $rs = Database::query($sql);
} $category = null;
while ($row = Database::fetch_array($rs)) {
if (!empty($category)) { $category = $row['id'];
}
if (!empty($category)) {
$cat = Category::load($category); $cat = Category::load($category);
$eval = $cat[0]->get_evaluations(); $eval = $cat[0]->get_evaluations();
if (count($eval) > 0){ if (count($eval) > 0) {
$i = 0; $i = 0;
foreach ($eval as $item) { 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().$param_gradebook.'">'.$item->get_name().'</a>'; $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().$param_gradebook . '">' . $item->get_name() . '</a>';
if (count($eval)-1 != $i) { if (count($eval) - 1 != $i) {
$score .= ', '; $score .= ', ';
} }
$i++; $i++;
@ -231,17 +261,17 @@ class BlockDaily extends Block {
} else { } else {
$score = get_lang("NotAvailable"); $score = get_lang("NotAvailable");
} }
} else { } else {
$score = get_lang("NotAvailable"); $score = get_lang("NotAvailable");
} }
$table_row = array(); $table_row = array();
$table_row[] = $row_course['title']; $table_row[] = $row_course['title'];
$table_row[] = $nb_students_in_course; $table_row[] = $nb_students_in_course;
$table_row[] = $score; $table_row[] = $score;
$table_row[] = $attendances[0]; $table_row[] = $attendances[0];
$course_data[] = $table_row; $course_data[] = $table_row;
} }
return $course_data; return $course_data;
} }
} }

@ -27,8 +27,8 @@ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
* the class name must be registered inside path.info file (e.g: controller = "BlockEvaluationGraph"), so dashboard controller will be instantiate it * the class name must be registered inside path.info file (e.g: controller = "BlockEvaluationGraph"), so dashboard controller will be instantiate it
* @package chamilo.dashboard * @package chamilo.dashboard
*/ */
class BlockEvaluationGraph extends Block { class BlockEvaluationGraph extends Block
{
private $user_id; private $user_id;
private $courses; private $courses;
private $sessions; private $sessions;
@ -38,25 +38,18 @@ class BlockEvaluationGraph extends Block {
/** /**
* Constructor * Constructor
*/ */
public function __construct ($user_id) { public function __construct($user_id)
{
$this->path = 'block_evaluation_graph'; $this->path = 'block_evaluation_graph';
$this->user_id = $user_id; $this->user_id = $user_id;
$this->bg_width = 450; $this->bg_width = 450;
$this->bg_height = 350; $this->bg_height = 350;
if ($this->is_block_visible_for_user($user_id)) { if ($this->is_block_visible_for_user($user_id)) {
//$this->courses = CourseManager::get_real_course_list(); if (!api_is_session_admin()) {
/*if (api_is_platform_admin()) { $this->courses = CourseManager::get_courses_followed_by_drh($user_id);
$this->courses = CourseManager::get_real_course_list(); }
$this->sessions = SessionManager::get_sessions_list(); $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
} else {*/
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);
//}
} }
} }
/** /**
@ -64,7 +57,8 @@ class BlockEvaluationGraph extends Block {
* @param int User id * @param int User id
* @return bool Is block visible for user * @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_info = api_get_user_info($user_id);
$user_status = $user_info['status']; $user_status = $user_info['status'];
$is_block_visible_for_user = false; $is_block_visible_for_user = false;
@ -79,47 +73,46 @@ class BlockEvaluationGraph extends Block {
* 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 * @return array column and content html
*/ */
public function get_block() { public function get_block()
{
global $charset; global $charset;
$column = 1; $column = 1;
$data = array(); $data = array();
$evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph(); $evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph();
$evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph(); $evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph();
$html = '<li class="widget color-orange" id="intro"> $html = '<li class="widget color-orange" id="intro">
<div class="widget-head"> <div class="widget-head">
<h3>'.get_lang('EvaluationsGraph').'</h3> <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 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>
<div class="widget-content" align="center">'; <div class="widget-content" align="center">';
if (empty($evaluations_base_courses_graph) && empty($evaluations_courses_in_sessions_graph)) { if (empty($evaluations_base_courses_graph) && empty($evaluations_courses_in_sessions_graph)) {
$html .= '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'</p>'; $html .= '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'</p>';
} else { } else {
// display evaluations base courses graph // display evaluations base courses graph
if (!empty($evaluations_base_courses_graph)) { if (!empty($evaluations_base_courses_graph)) {
foreach ($evaluations_base_courses_graph as $course_code => $img_html) { foreach ($evaluations_base_courses_graph as $course_code => $img_html) {
$html .= '<div><strong>'.$course_code.'</strong></div>'; $html .= '<div><strong>'.$course_code.'</strong></div>';
$html .= $img_html; $html .= $img_html;
} }
} }
// display evaluations base courses graph // display evaluations base courses graph
if (!empty($evaluations_courses_in_sessions_graph)) { if (!empty($evaluations_courses_in_sessions_graph)) {
foreach ($evaluations_courses_in_sessions_graph as $session_id => $courses) { foreach ($evaluations_courses_in_sessions_graph as $session_id => $courses) {
$session_name = api_get_session_name($session_id); $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) { foreach ($courses as $course_code => $img_html) {
$html .= '<div><strong>'.$course_code.'</strong></div>'; $html .= '<div><strong>'.$course_code.'</strong></div>';
$html .= $img_html; $html .= $img_html;
} }
} }
} }
} }
$html .= '</div> $html .= '</div>
</li>'; </li>';
$data['column'] = $column; $data['column'] = $column;
$data['content_html'] = $html; $data['content_html'] = $html;
@ -127,10 +120,13 @@ class BlockEvaluationGraph extends Block {
} }
/** /**
* 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 * 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 * @return string img html
*/ */
public function get_evaluations_base_courses_graph() { public function get_evaluations_base_courses_graph()
{
$graphs = array(); $graphs = array();
if (!empty($this->courses)) { if (!empty($this->courses)) {
$courses_code = array_keys($this->courses); $courses_code = array_keys($this->courses);
@ -214,10 +210,13 @@ class BlockEvaluationGraph extends Block {
} }
/** /**
* 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 * 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 * @return string img html
*/ */
public function get_evaluations_courses_in_sessions_graph() { public function get_evaluations_courses_in_sessions_graph()
{
$graphs = array(); $graphs = array();
if (!empty($this->sessions)) { if (!empty($this->sessions)) {
$session_ids = array_keys($this->sessions); $session_ids = array_keys($this->sessions);

@ -13,10 +13,12 @@ require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
/** /**
* This class is used like controller for this session block plugin, * 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 * the class name must be registered inside path.info file
* (e.g: controller = "BlockSession"), so dashboard controller will be instantiate it
* @package chamilo.dashboard * @package chamilo.dashboard
*/ */
class BlockSession extends Block { class BlockSession extends Block
{
private $user_id; private $user_id;
private $sessions; private $sessions;
@ -26,15 +28,12 @@ class BlockSession extends Block {
/** /**
* Constructor * Constructor
*/ */
public function __construct ($user_id) { public function __construct ($user_id)
{
$this->user_id = $user_id; $this->user_id = $user_id;
$this->path = 'block_session'; $this->path = 'block_session';
if ($this->is_block_visible_for_user($user_id)) { if ($this->is_block_visible_for_user($user_id)) {
/*if (api_is_platform_admin()) { $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
$this->sessions = SessionManager::get_sessions_list();
} else {*/
$this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);
//}
} }
} }
@ -43,7 +42,8 @@ class BlockSession extends Block {
* @param int User id * @param int User id
* @return bool Is block visible for user * @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_info = api_get_user_info($user_id);
$user_status = $user_info['status']; $user_status = $user_info['status'];
$is_block_visible_for_user = false; $is_block_visible_for_user = false;
@ -58,7 +58,8 @@ class BlockSession extends Block {
* 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 * @return array column and content html
*/ */
public function get_block() { public function get_block()
{
global $charset; global $charset;
@ -89,7 +90,8 @@ class BlockSession extends Block {
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html * @return string content html
*/ */
public function get_content_html() { public function get_content_html()
{
$content = ''; $content = '';
$sessions = $this->sessions; $sessions = $this->sessions;
@ -147,7 +149,8 @@ class BlockSession extends Block {
* Get number of sessions * Get number of sessions
* @return int * @return int
*/ */
function get_number_of_sessions() { function get_number_of_sessions()
{
return count($this->sessions); return count($this->sessions);
} }

@ -21,7 +21,8 @@ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
* the class name must be registered inside path.info file (e.g: controller = "BlockStudent"), so dashboard controller will be instantiate it * the class name must be registered inside path.info file (e.g: controller = "BlockStudent"), so dashboard controller will be instantiate it
* @package chamilo.dashboard * @package chamilo.dashboard
*/ */
class BlockStudent extends Block { class BlockStudent extends Block
{
private $user_id; private $user_id;
private $students; private $students;
@ -31,16 +32,12 @@ class BlockStudent extends Block {
/** /**
* Constructor * Constructor
*/ */
public function __construct ($user_id) { public function __construct ($user_id)
{
$this->user_id = $user_id; $this->user_id = $user_id;
$this->path = 'block_student'; $this->path = 'block_student';
if ($this->is_block_visible_for_user($user_id)) { if ($this->is_block_visible_for_user($user_id)) {
/*if (api_is_platform_admin()) {
$this->students = UserManager::get_user_list(array('status' => STUDENT));
} else {*/
$this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT); $this->students = UserManager::get_users_followed_by_drh($user_id, STUDENT);
//}
} }
} }
@ -49,7 +46,8 @@ class BlockStudent extends Block {
* @param int User id * @param int User id
* @return bool Is block visible for user * @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_info = api_get_user_info($user_id);
$user_status = $user_info['status']; $user_status = $user_info['status'];
$is_block_visible_for_user = false; $is_block_visible_for_user = false;
@ -64,7 +62,8 @@ class BlockStudent extends Block {
* 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 * @return array column and content html
*/ */
public function get_block() { public function get_block()
{
global $charset; global $charset;
$column = 1; $column = 1;
$data = array(); $data = array();
@ -90,7 +89,8 @@ class BlockStudent extends Block {
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html * @return string content html
*/ */
public function get_students_content_html_for_platform_admin() { public function get_students_content_html_for_platform_admin()
{
$students = $this->students; $students = $this->students;
$content = '<div style="margin:10px;">'; $content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourStudents').'</font></h3>'; $content .= '<h3><font color="#000">'.get_lang('YourStudents').'</font></h3>';
@ -235,6 +235,7 @@ class BlockStudent extends Block {
</div>'; </div>';
} }
$content .= '</div>'; $content .= '</div>';
return $content; return $content;
} }
@ -242,7 +243,8 @@ class BlockStudent extends Block {
* Get number of students * Get number of students
* @return int * @return int
*/ */
function get_number_of_students() { function get_number_of_students()
{
return count($this->students); return count($this->students);
} }
} }

@ -29,7 +29,8 @@ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/be/category.class.php';
* the class name must be registered inside path.info file (e.g: controller = "BlockStudentGraph"), so dashboard controller will be instantiate it * the class name must be registered inside path.info file (e.g: controller = "BlockStudentGraph"), so dashboard controller will be instantiate it
* @package chamilo.dashboard * @package chamilo.dashboard
*/ */
class BlockStudentGraph extends Block { class BlockStudentGraph extends Block
{
private $user_id; private $user_id;
private $students; private $students;
@ -39,7 +40,8 @@ class BlockStudentGraph extends Block {
/** /**
* Constructor * Constructor
*/ */
public function __construct ($user_id) { public function __construct ($user_id)
{
$this->user_id = $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 ($this->is_block_visible_for_user($user_id)) {
@ -56,7 +58,8 @@ class BlockStudentGraph extends Block {
* @param int User id * @param int User id
* @return bool Is block visible for user * @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_info = api_get_user_info($user_id);
$user_status = $user_info['status']; $user_status = $user_info['status'];
$is_block_visible_for_user = false; $is_block_visible_for_user = false;
@ -67,14 +70,15 @@ class BlockStudentGraph extends Block {
} }
/** /**
* This method return content html containing information about students and its position for showing it inside dashboard interface * This method return content html containing information about students
* it's important to use the name 'get_block' for beeing used from dashboard controller * 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 * @return array column and content html
*/ */
public function get_block() { public function get_block()
{
global $charset; global $charset;
$column = 1; $column = 1;
$data = array(); $data = array();
$students_attendance_graph = $this->get_students_attendance_graph(); $students_attendance_graph = $this->get_students_attendance_graph();
@ -95,10 +99,12 @@ class BlockStudentGraph extends Block {
} }
/** /**
* This method return a graph containing informations about students evaluation, it's used inside get_block method for showing it inside dashboard interface * 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 * @return string img html
*/ */
public function get_students_attendance_graph() { public function get_students_attendance_graph()
{
$students = $this->students; $students = $this->students;
$attendance = new Attendance(); $attendance = new Attendance();
@ -203,7 +209,8 @@ class BlockStudentGraph extends Block {
* Get number of students * Get number of students
* @return int * @return int
*/ */
function get_number_of_students() { function get_number_of_students()
{
return count($this->students); return count($this->students);
} }
} }

@ -12,10 +12,12 @@
/** /**
* This class is used like controller for teacher block plugin, * 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 * the class name must be registered inside path.info file
* (e.g: controller = "BlockTeacher"), so dashboard controller will be instantiate it
* @package chamilo.dashboard * @package chamilo.dashboard
*/ */
class BlockTeacher extends Block { class BlockTeacher extends Block
{
private $user_id; private $user_id;
private $teachers; private $teachers;
@ -25,15 +27,12 @@ class BlockTeacher extends Block {
/** /**
* Controller * Controller
*/ */
public function __construct ($user_id) { public function __construct ($user_id)
{
$this->user_id = $user_id; $this->user_id = $user_id;
$this->path = 'block_teacher'; $this->path = 'block_teacher';
if ($this->is_block_visible_for_user($user_id)) { if ($this->is_block_visible_for_user($user_id)) {
/*if (api_is_platform_admin()) { $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
$this->teachers = UserManager::get_user_list(array('status' => COURSEMANAGER));
} else {*/
$this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
//}
} }
} }
@ -42,7 +41,8 @@ class BlockTeacher extends Block {
* @param int User id * @param int User id
* @return bool Is block visible for user * @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_info = api_get_user_info($user_id);
$user_status = $user_info['status']; $user_status = $user_info['status'];
$is_block_visible_for_user = false; $is_block_visible_for_user = false;
@ -57,29 +57,24 @@ class BlockTeacher extends Block {
* 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 * @return array column and content html
*/ */
public function get_block() { public function get_block()
{
global $charset; global $charset;
$column = 1; $column = 1;
$data = array(); $data = array();
$teacher_content_html = $this->get_teachers_content_html_for_drh();
/*if (api_is_platform_admin()) {
$teacher_content_html = $this->get_teachers_content_html_for_platform_admin();
} else if (api_is_drh()) {*/
$teacher_content_html = $this->get_teachers_content_html_for_drh();
//}
$html = ' $html = '
<li class="widget color-blue" id="intro"> <li class="widget color-blue" id="intro">
<div class="widget-head"> <div class="widget-head">
<h3>'.get_lang('TeachersInformationsList').'</h3> <h3>'.get_lang('TeachersInformationsList').'</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 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>
<div class="widget-content"> <div class="widget-content">
'.$teacher_content_html.' '.$teacher_content_html.'
</div> </div>
</li> </li>
'; ';
$data['column'] = $column; $data['column'] = $column;
@ -93,8 +88,8 @@ class BlockTeacher extends Block {
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html * @return string content html
*/ */
public function get_teachers_content_html_for_platform_admin() { public function get_teachers_content_html_for_platform_admin()
{
$teachers = $this->teachers; $teachers = $this->teachers;
$content = '<div style="margin:10px;">'; $content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourTeachers').'</font></h3>'; $content .= '<h3><font color="#000">'.get_lang('YourTeachers').'</font></h3>';
@ -141,16 +136,17 @@ class BlockTeacher extends Block {
$content .= $teachers_table; $content .= $teachers_table;
if (count($teachers) > 0) { 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>'; $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>';
} }
$content .= '</div>'; $content .= '</div>';
return $content; return $content;
} }
public function get_teachers_content_html_for_drh() { public function get_teachers_content_html_for_drh()
{
$teachers = $this->teachers; $teachers = $this->teachers;
$content = '<div style="margin:10px;">'; $content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourTeachers').'</font></h3>'; $content .= '<h3><font color="#000">'.get_lang('YourTeachers').'</font></h3>';
@ -198,15 +194,14 @@ class BlockTeacher extends Block {
$content .= '</div>'; $content .= '</div>';
return $content; return $content;
} }
/** /**
* Get number of teachers * Get number of teachers
* @return int * @return int
*/ */
function get_number_of_teachers() { function get_number_of_teachers()
{
return count($this->teachers); return count($this->teachers);
} }
} }

@ -16,14 +16,13 @@ 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/pChart.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php'; require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php';
/** /**
* This class is used like controller for teacher graph block plugin, * 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 * the class name must be registered inside path.info file (e.g: controller = "BlockTeacherGraph"), so dashboard controller will be instantiate it
* @package chamilo.dashboard * @package chamilo.dashboard
*/ */
class BlockTeacherGraph extends Block { class BlockTeacherGraph extends Block
{
private $user_id; private $user_id;
private $teachers; private $teachers;
@ -33,15 +32,12 @@ class BlockTeacherGraph extends Block {
/** /**
* Controller * Controller
*/ */
public function __construct ($user_id) { public function __construct ($user_id)
{
$this->user_id = $user_id; $this->user_id = $user_id;
$this->path = 'block_teacher_graph'; $this->path = 'block_teacher_graph';
if ($this->is_block_visible_for_user($user_id)) { if ($this->is_block_visible_for_user($user_id)) {
/*if (api_is_platform_admin()) { $this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
$this->teachers = UserManager::get_user_list(array('status' => COURSEMANAGER));
} else {*/
$this->teachers = UserManager::get_users_followed_by_drh($user_id, COURSEMANAGER);
//}
} }
} }
@ -50,7 +46,8 @@ class BlockTeacherGraph extends Block {
* @param int User id * @param int User id
* @return bool Is block visible for user * @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_info = api_get_user_info($user_id);
$user_status = $user_info['status']; $user_status = $user_info['status'];
$is_block_visible_for_user = false; $is_block_visible_for_user = false;
@ -65,30 +62,24 @@ class BlockTeacherGraph extends Block {
* 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 * @return array column and content html
*/ */
public function get_block() { public function get_block()
{
global $charset; global $charset;
$column = 1; $column = 1;
$data = array(); $data = array();
$teacher_information_graph = $this->get_teachers_information_graph();
/*if (api_is_platform_admin()) {
$teacher_content_html = $this->get_teachers_content_html_for_platform_admin();
} else if (api_is_drh()) {*/
$teacher_information_graph = $this->get_teachers_information_graph();
//}
$html = ' $html = '
<li class="widget color-blue" id="intro"> <li class="widget color-blue" id="intro">
<div class="widget-head"> <div class="widget-head">
<h3>'.get_lang('TeachersInformationsGraph').'</h3> <h3>'.get_lang('TeachersInformationsGraph').'</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 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>
<div class="widget-content" align="center"> <div class="widget-content" align="center">
<div style="padding:10px;"><strong>'.get_lang('TimeSpentOnThePlatformLastWeekByDay').'</strong></div> <div style="padding:10px;"><strong>'.get_lang('TimeSpentOnThePlatformLastWeekByDay').'</strong></div>
'.$teacher_information_graph.' '.$teacher_information_graph.'
</div> </div>
</li> </li>
'; ';
$data['column'] = $column; $data['column'] = $column;
@ -102,8 +93,8 @@ class BlockTeacherGraph extends Block {
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface * This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html * @return string content html
*/ */
public function get_teachers_information_graph() { public function get_teachers_information_graph()
{
$teachers = $this->teachers; $teachers = $this->teachers;
$graph = ''; $graph = '';
@ -188,16 +179,16 @@ class BlockTeacherGraph extends Block {
} else { } else {
$graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'</p>'; $graph = '<p>'.api_convert_encoding(get_lang('GraphicNotAvailable'),'UTF-8').'</p>';
} }
return $graph;
return $graph;
} }
/** /**
* Get number of teachers * Get number of teachers
* @return int * @return int
*/ */
function get_number_of_teachers() { function get_number_of_teachers()
{
return count($this->teachers); return count($this->teachers);
} }

Loading…
Cancel
Save