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 = '
';
$content .= '
'.get_lang('YourTrainingsSessionList').'
';
if (count($sessions) > 0) {
foreach ($sessions as $session) {
$session_id = intval($session['id']);
$content .= '
'.$session['name'].' - '.get_lang('From').' '.$session['date_start'].' '.get_lang('To').' '.$session['date_end'].'
';
$courses = Tracking ::get_courses_list_from_session($session_id);
$courses_table = '';
if (count($courses)) {
$courses_table = '
';
$courses_table .= '
'.get_lang('Course').' |
'.get_lang('Time').' |
'.get_lang('Progress').' |
'.get_lang('Score').' |
'.get_lang('TematicAdvance').' |
';
$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);
$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 .= '
'.$course_info['title'].' |
'.$time_spent_on_course.' |
'.$progress.' |
'.$score.' |
'.$tematic_advance_progress.'% |
';
$i++;
}
$courses_table .= '
';
} else {
$courses_table .= '
'.get_lang('ThereAreNoCoursesInformationsInsideThisSession').'
';
}
$content .= $courses_table;
}
} else {
$content .= '
'.get_lang('ThereAreNoInformationsAboutYoursSessions').'
';
}
if (count($sessions) > 0) {
$content .= '
';
}
$content .= '
';
return $content;
}
/**
* Get number of sessions
* @return int
*/
function get_number_of_sessions() {
return count($this->sessions);
}
}
?>