added plugins for blocks in dashboard - partial CT#570

skala
Cristian Fasanando 15 years ago
parent 809a960190
commit 7e6a38fb0e
  1. 187
      plugin/dashboard/block_course/block_course.class.php
  2. 6
      plugin/dashboard/block_course/block_course.info
  3. 83
      plugin/dashboard/block_course/css/default.css
  4. 170
      plugin/dashboard/block_session/block_session.class.php
  5. 6
      plugin/dashboard/block_session/block_session.info
  6. 83
      plugin/dashboard/block_session/css/default.css
  7. 152
      plugin/dashboard/block_student/block_student.class.php
  8. 6
      plugin/dashboard/block_student/block_student.info
  9. 83
      plugin/dashboard/block_student/css/default.css
  10. 150
      plugin/dashboard/block_teacher/block_teacher.class.php
  11. 6
      plugin/dashboard/block_teacher/block_teacher.info
  12. 83
      plugin/dashboard/block_teacher/css/default.css

@ -0,0 +1,187 @@
<?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
*/
/**
* required files for getting data
*/
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
/**
* 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;
/**
* Constructor
*/
public function __construct ($user_id) {
$this->user_id = $user_id;
$this->courses = CourseManager::get_assigned_courses_to_hr_manager($user_id);
$this->path = 'block_course';
}
/**
* 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 = array();
$content = '';
$data_table = '';
$content = $this->get_content_html();
$html = '
<li class="widget color-green" id="intro">
<div class="widget-head">
<h3>Courses Informations</h3>
<div class="widget-actions"><a onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">'.Display::return_icon('close.gif',get_lang('Close')).'</a></div>
</div>
<div class="widget-content">
'.$content.'
</div>
</li>
';
$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 = '';
if (!empty($course_data)) {
$data_table = '<table class="data_table" width:"95%">';
$data_table .= '<tr>
<th>'.get_lang('CourseTitle').'</th>
<th width="10%">'.get_lang('NbStudents').'</th>
<th width="10%">'.get_lang('AvgTimeSpentInTheCourse').'</th>
<th width="10%">'.get_lang('AvgStudentsProgress').'</th>
<th width="10%">'.get_lang('AvgCourseScore').'</th>
<th width="10%">'.get_lang('AvgExercisesScore').'</th>
<th width="10%">'.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.'">';
foreach ($course as $cell) {
$data_table .= '<td align="right">'.$cell.'</td>';
}
$data_table .= '</tr>';
$i++;
}
$data_table .= '</table>';
} else {
$data_table .= get_lang('ThereAreNoInformationsAboutYoursCourses');
}
$content .= '<div style="margin:15px;"><h3>'.get_lang('YourCourseList').'</h3>';
$content .= $data_table;
if (!empty($course_data)) {
$content .= '<div style="text-align:right;margin-top:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
return $content;
}
/**
* Get number of courses
* @return int
*/
function get_number_of_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;
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='5' AND course_rel_user.course_code='$course_code'";
$rs = Database::query($sql, __FILE__, __LINE__);
$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 = Tracking::get_time_spent_on_the_course($users, $course_code);
$avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code);
$avg_score_in_course = Tracking :: get_avg_student_score($users, $course_code);
$avg_score_in_exercise = Tracking::get_avg_student_exercise_score($users, $course_code);
$avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course);
$avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2);
$avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2);
$avg_score_in_exercise = round($avg_score_in_exercise / $nb_students_in_course, 2);
} else {
$avg_time_spent_in_course = null;
$avg_progress_in_course = null;
$avg_score_in_course = null;
$avg_score_in_exercise = null;
}
$tematic_advance_progress = 0;
$course_description = new CourseDescription();
$course_description->set_session_id(0);
$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
if (!empty($tematic_advance)) {
$tematic_advance_progress = $tematic_advance['progress'];
}
$table_row = array();
$table_row[] = $row_course['title'];
$table_row[] = $nb_students_in_course;
$table_row[] = $avg_time_spent_in_course;
$table_row[] = is_null($avg_progress_in_course) ? '' : $avg_progress_in_course.'%';
$table_row[] = is_null($avg_score_in_course) ? '' : $avg_score_in_course.'%';
$table_row[] = is_null($avg_score_in_exercise) ? '' : $avg_score_in_exercise.'%';
$table_row[] = $tematic_advance_progress.'%';
$course_data[] = $table_row;
}
return $course_data;
}
}
?>

@ -0,0 +1,6 @@
name = "Block Course"
controller = "BlockCourse"
description = "Display information about courses inside platform"
package = Dashboard
version = 1.0
author = Christian Fasanando

@ -0,0 +1,83 @@
/* Colors */
.color-yellow {background:#f2bc00;}
.color-red {background:#dd0000;}
.color-blue {background:#148ea4;}
.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 */
//#columns #column1 .widget { margin: 30px 35px 0 25px; }
//#columns #column3 .widget { margin: 30px 25px 0 35px; }
.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 img {
float: right;
margin: 10px;
border: 1px solid #FFF;
}
.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;}

@ -0,0 +1,170 @@
<?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
*/
/**
* required files for getting data
*/
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'course_description.lib.php';
/**
* 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;
/**
* Constructor
*/
public function __construct ($user_id) {
$this->user_id = $user_id;
$this->sessions = SessionManager::get_assigned_sessions_to_hr_manager($user_id);
$this->path = 'block_session';
}
/**
* 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 = array();
$content = $this->get_content_html();
$content_html = '
<li class="widget color-red" id="intro">
<div class="widget-head">
<h3>'.get_lang('SessionsInformation').'</h3>
<div class="widget-actions"><a onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">'.Display::return_icon('close.gif',get_lang('Close')).'</a></div>
</div>
<div class="widget-content">
'.$content.'
</div>
</li>
';
$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 = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('YourTrainingsSessionList').'</font></h3>';
if (count($sessions) > 0) {
foreach ($sessions as $session) {
$session_id = intval($session['id']);
$content .= '<div style="margin-top:10px;"><strong>'.$session['name'].'</strong> - '.get_lang('From').' '.$session['date_start'].' '.get_lang('To').' '.$session['date_end'].'</div>';
$courses = Tracking ::get_courses_list_from_session($session_id);
$courses_table = '';
if (count($courses)) {
$courses_table = '<div style="margin:10px;margin-bottom:20px;"><table class="data_table" width:"95%">';
$courses_table .= '<tr>
<th>'.get_lang('Course').'</th>
<th width="10%">'.get_lang('Time').'</th>
<th width="10%">'.get_lang('Progress').'</th>
<th width="10%">'.get_lang('Score').'</th>
<th width="10%">'.get_lang('TematicAdvance').'</th>
</tr>';
$i = 1;
foreach ($courses as $course) {
$course_code = Database::escape_string($course['course_code']);
$course_info = CourseManager :: get_course_information($course_code);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
// students directly subscribed to the course
$sql = "SELECT id_user FROM $tbl_session_course_user srcu WHERE srcu. course_code='$course_code'";
$rs = Database::query($sql, __FILE__, __LINE__);
$users = array();
while ($row = Database::fetch_array($rs)) {
$users[] = $row['id_user'];
}
$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($users, $course_code));
$progress = Tracking :: get_avg_student_progress($users, $course_code);
$score = Tracking :: get_avg_student_score($users, $course_code);
$progress = empty($progress) ? '0%' : $progress.'%';
$score = empty($score) ? '0%' : $score.'%';
$tematic_advance_progress = 0;
$course_description = new CourseDescription();
$course_description->set_session_id($session_id);
$tematic_advance = $course_description->get_data_by_description_type(8, $course_code);
if (!empty($tematic_advance)) {
$tematic_advance_progress = $tematic_advance['progress'];
}
if ($i%2 == 0) $class_tr = 'row_odd';
else $class_tr = 'row_even';
$courses_table .= '<tr class="'.$class_tr.'">
<td align="right">'.$course_info['title'].'</td>
<td align="right">'.$time_spent_on_course.'</td>
<td align="right">'.$progress.'</td>
<td align="right">'.$score.'</td>
<td align="right">'.$tematic_advance_progress.'%</td>
</tr>';
$i++;
}
$courses_table .= '</table></div>';
} else {
$courses_table .= '<div style="margin:10px;">'.get_lang('ThereAreNoCoursesInformationsInsideThisSession').'</div>';
}
$content .= $courses_table;
}
} else {
$content .= '<div style="margin:20px;">'.get_lang('ThereAreNoInformationsAboutYoursSessions').'</div>';
}
if (count($sessions) > 0) {
$content .= '<div style="text-align:right;margin-top:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
return $content;
}
/**
* Get number of sessions
* @return int
*/
function get_number_of_sessions() {
return count($this->sessions);
}
}
?>

@ -0,0 +1,6 @@
name = "Block Session"
controller = "BlockSession"
description = "Display information about sessions inside platform"
package = Dashboard
version = 1.0
author = Christian Fasanando

@ -0,0 +1,83 @@
/* Colors */
.color-yellow {background:#f2bc00;}
.color-red {background:#dd0000;}
.color-blue {background:#148ea4;}
.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 */
//#columns #column1 .widget { margin: 30px 35px 0 25px; }
//#columns #column3 .widget { margin: 30px 25px 0 35px; }
.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 img {
float: right;
margin: 10px;
border: 1px solid #FFF;
}
.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;}

@ -0,0 +1,152 @@
<?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
*/
/**
* required files for getting data
*/
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
/**
* 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;
/**
* Constructor
*/
public function __construct ($user_id) {
$this->user_id = $user_id;
$this->students = UserManager::get_assigned_users_to_hr_manager($user_id, STUDENT);
$this->path = 'block_student';
}
/**
* 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 = array();
$student_content_html = $this->get_students_content_html();
$html = '
<li class="widget color-blue" id="intro">
<div class="widget-head">
<h3>Students Informations</h3>
<div class="widget-actions"><a onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">'.Display::return_icon('close.gif',get_lang('Close')).'</a></div>
</div>
<div class="widget-content">
'.$student_content_html.'
</div>
</li>
';
$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() {
$students = $this->students;
$content = '';
$content = '<div style="margin:20px;margin-right:30px;">';
$content .= '<h3><font color="#000">'.get_lang('StudentsOverview').'</font></h3>';
if (count($students) > 0) {
$students_table = '<div style="margin:10px;width:100%"><table class="data_table" width:"90%">';
$students_table .= '
<tr>
<th width="10%" rowspan="2">'.get_lang('FirtName').'</th>
<th width="10%" rowspan="2">'.get_lang('LastName').'</th>
<th width="30%" colspan="4">'.get_lang('TrainingInformations').'</th>
</tr>
<tr>
<th width="10%">'.get_lang('Training').'</th>
<th width="10%">'.get_lang('Time').'</th>
<th width="10%">'.get_lang('Progress').'</th>
<th width="10%">'.get_lang('Score').'</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);
if ($i%2 == 0) $style = ' style="background-color:#F2F2F2" ';
else $style = ' style="background-color:#FFF" ';
$students_table .= '<tr '.$style.'>
<td rowspan="'.($count_courses+1).'">'.$student['firstname'].'</td>
<td rowspan="'.($count_courses+1).'">'.$student['lastname'].'</td>
</tr>';
// courses information about the student
foreach ($courses_by_user as $course) {
$course_code = $course['code'];
$course_title = $course['title'];
$time = api_time_to_hms(Tracking :: get_time_spent_on_the_course($student['user_id'], $course_code));
$progress = round(Tracking :: get_avg_student_progress($student['user_id'], $course_code), 2);
$score = round(Tracking :: get_avg_student_score($student['user_id'], $course_code), 2);
$students_table .= '<tr '.$style.'>
<td>'.$course_title.'</td>
<td>'.$time.'</td>
<td>'.$progress.'</td>
<td>'.$score.'</td>
</tr>';
}
$i++;
}
$students_table .= '</table></div>';
} else {
$students_table .= '<div style="margin:20px">'.get_lang('ThereAreNoInformationAboutStudents').'</div>';
}
$content .= $students_table;
if (count($students) > 0) {
$content .= '<div style="text-align:right;margin:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
return $content;
}
/**
* Get number of sessions
* @return int
*/
function get_number_of_students() {
return count($this->students);
}
}
?>

@ -0,0 +1,6 @@
name = "Block Student"
controller = "BlockStudent"
description = "Display information about students inside platform"
package = Dashboard
version = 1.0
author = Christian Fasanando

@ -0,0 +1,83 @@
/* Colors */
.color-yellow {background:#f2bc00;}
.color-red {background:#dd0000;}
.color-blue {background:#148ea4;}
.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 */
//#columns #column1 .widget { margin: 30px 35px 0 25px; }
//#columns #column3 .widget { margin: 30px 25px 0 35px; }
.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 img {
float: right;
margin: 10px;
border: 1px solid #FFF;
}
.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;}

@ -0,0 +1,150 @@
<?php
/**
* 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
*/
/**
* required files for getting data
*/
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
/**
* 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;
/**
* Controller
*/
public function __construct ($user_id) {
$this->user_id = $user_id;
$this->teachers = UserManager::get_assigned_users_to_hr_manager($user_id, COURSEMANAGER);
$this->path = 'block_teacher';
}
/**
* 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 = array();
$teacher_content_html = $this->get_teachers_content_html();
$html = '
<li class="widget color-blue" id="intro">
<div class="widget-head">
<h3>Teachers Informations</h3>
<div class="widget-actions"><a onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;" href="index.php?action=disable_block&path='.$this->path.'">'.Display::return_icon('close.gif',get_lang('Close')).'</a></div>
</div>
<div class="widget-content">
'.$teacher_content_html.'
</div>
</li>
';
$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() {
$teachers = $this->teachers;
$content = '';
$content = '<div style="margin:10px;">';
$content .= '<h3><font color="#000">'.get_lang('TeachersOverview').'</font></h3>';
if (count($teachers) > 0) {
$teachers_table = '<div style="margin:10px;margin-bottom:20px;"><table class="data_table" width:"80%">';
$teachers_table .= '
<tr>
<th>'.get_lang('FirtName').'</th>
<th>'.get_lang('LastName').'</th>
<th>'.get_lang('TimeSpentOnThePlatform').'</th>
<th>'.get_lang('LastConnexion').'</th>
<th>'.get_lang('NbStudents').'</th>
<th>'.get_lang('CountCours').'</th>
<th>'.get_lang('NumberOfSessions').'</th>
</tr>
';
$i = 1;
foreach ($teachers as $teacher) {
$teacher_id = $teacher['user_id'];
$firtname = $teacher['firstname'];
$lastname = $teacher['lastname'];
$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);
$nb_students = count(Tracking :: get_student_followed_by_coach($teacher_id));
$nb_courses = count(Tracking :: get_courses_followed_by_coach($teacher_id));
$nb_sessions = count(Tracking :: get_sessions_coached_by_user($teacher_id));
if ($i%2 == 0) $class_tr = 'row_odd';
else $class_tr = 'row_even';
$teachers_table .= '
<tr class="'.$class_tr.'">
<td>'.$firtname.'</td>
<td>'.$lastname.'</td>
<td>'.$time_on_platform.'</td>
<td>'.$last_connection.'</td>
<td>'.$nb_students.'</td>
<td>'.$nb_courses.'</td>
<td>'.$nb_sessions.'</td>
</tr>
';
$i++;
}
$teachers_table .= '</table></div>';
} else {
$teachers_table .= '<div style="margin:20px">'.get_lang('ThereAreNoInformationAboutTeachers').'</div>';
}
$content .= $teachers_table;
if (count($teachers) > 0) {
$content .= '<div style="text-align:right;margin:10px;"><a href="#">'.get_lang('SeeMore').'</a></div>';
}
$content .= '</div>';
return $content;
}
/**
* Get number of sessions
* @return int
*/
function get_number_of_teachers() {
return count($this->teachers);
}
}
?>

@ -0,0 +1,6 @@
name = "Block Teacher"
controller = "BlockTeacher"
description = "Display information about teachers inside platform"
package = Dashboard
version = 1.0
author = Christian Fasanando

@ -0,0 +1,83 @@
/* Colors */
.color-yellow {background:#f2bc00;}
.color-red {background:#dd0000;}
.color-blue {background:#148ea4;}
.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 */
//#columns #column1 .widget { margin: 30px 35px 0 25px; }
//#columns #column3 .widget { margin: 30px 25px 0 35px; }
.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 img {
float: right;
margin: 10px;
border: 1px solid #FFF;
}
.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;}
Loading…
Cancel
Save