user_id = $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->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(); if (api_is_platform_admin()) { $student_content_html = $this->get_students_content_html_for_platform_admin(); } else if (api_is_drh()) { $student_content_html = $this->get_students_content_html_for_drh(); } $html = '
  • Students Informations

    '.$student_content_html.'
  • '; $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 = ''; $content = '
    '; $content .= '

    '.get_lang('YourStudents').'

    '; if (count($students) > 0) { $students_table = ''; $students_table .= ' '; $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 .= ''; // courses information about the student if (!empty($courses_by_user)) { 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)); $students_table .= ''; } } else { $students_table .= ''; } $i++; } $students_table .= '
    '.get_lang('FirstName').' '.get_lang('LastName').' '.get_lang('CourseInformation').'
    '.get_lang('Courses').' '.get_lang('Time').'
    '.$student['firstname'].' '.$student['lastname'].'
    '.$course_title.' '.$time.'
    '.get_lang('Empty').'
    '; } else { $students_table .= get_lang('ThereAreNoInformationAboutStudents'); } $content .= $students_table; if (count($students) > 0) { $content .= '
    '.get_lang('SeeMore').'
    '; } $content .= '
    '; return $content; } public function get_students_content_html_for_drh() { $attendance = new Attendance(); $students = $this->students; $content = ''; $content = '
    '; $content .= '

    '.get_lang('YourStudents').'

    '; if (count($students) > 0) { $students_table = ''; $students_table .= ' '; $i = 1; foreach ($students as $student) { $student_id = $student['user_id']; $firstname = $student['firstname']; $lastname = $student['lastname']; $evaluations_avg = 0; // 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 = ''.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)'; } else { $attendances_faults_avg = '0%'; } if ($i%2 == 0) $class_tr = 'row_odd'; else $class_tr = 'row_even'; $students_table .= ''; $i++; } $students_table .= '
    '.get_lang('FirstName').' '.get_lang('LastName').' '.get_lang('AttendancesFaults').' '.get_lang('Evaluations').'
    '.$firstname.' '.$lastname.' '.$attendances_faults_avg.' '.$evaluations_avg.'%
    '; } else { $students_table .= get_lang('ThereAreNoInformationAboutStudents'); } $content .= $students_table; if (count($students) > 0) { $content .= '
    '.get_lang('SeeMore').'
    '; } $content .= '
    '; return $content; } /** * Get number of sessions * @return int */ function get_number_of_students() { return count($this->students); } } ?>