/**
  * Build the Surveys
  * @param int $session_id Internal session ID
  * @param int $courseId Internal course ID
  * @param bool $with_base_content Whether to include content from the course without session or not
  * @param array $id_list If you want to restrict the structure to only the given IDs
  */
 public function build_thematic($session_id = 0, $courseId = 0, $with_base_content = false, $id_list = array())
 {
     $table_thematic = Database::get_course_table(TABLE_THEMATIC);
     $table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
     $table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN);
     $session_id = intval($session_id);
     if ($with_base_content) {
         $session_condition = api_get_session_condition($session_id, true, true);
     } else {
         $session_condition = api_get_session_condition($session_id, true);
     }
     $sql = "SELECT * FROM {$table_thematic}\n                WHERE c_id = {$courseId} {$session_condition} ";
     $db_result = Database::query($sql);
     while ($row = Database::fetch_array($db_result, 'ASSOC')) {
         $thematic = new Thematic($row);
         $sql = 'SELECT * FROM ' . $table_thematic_advance . '
                 WHERE c_id = ' . $courseId . ' AND thematic_id = ' . $row['id'];
         $result = Database::query($sql);
         while ($sub_row = Database::fetch_array($result, 'ASSOC')) {
             $thematic->add_thematic_advance($sub_row);
         }
         $items = api_get_item_property_by_tool('thematic_plan', api_get_course_id(), $session_id);
         $thematic_plan_id_list = array();
         if (!empty($items)) {
             foreach ($items as $item) {
                 $thematic_plan_id_list[] = $item['ref'];
                 //$thematic_plan_complete_list[$item['ref']] = $item;
             }
         }
         if (count($thematic_plan_id_list) > 0) {
             $sql = "SELECT tp.*\n                        FROM {$table_thematic_plan} tp\n                            INNER JOIN {$table_thematic} t ON (t.id=tp.thematic_id)\n                        WHERE\n                            t.c_id = {$courseId} AND\n                            tp.c_id = {$courseId} AND\n                            thematic_id = {$row['id']}  AND\n                            tp.id IN (" . implode(', ', $thematic_plan_id_list) . ") ";
             $result = Database::query($sql);
             while ($sub_row = Database::fetch_array($result, 'ASSOC')) {
                 $thematic->add_thematic_plan($sub_row);
             }
         }
         $this->course->add_resource($thematic);
     }
 }
        $intro_dispCommand = false;
    }
}
/* Executes the display */
// display thematic advance inside a postit
if ($intro_dispForm) {
    $default['intro_content'] = $intro_content;
    $form->setDefaults($default);
    $introduction_section .= '<div id="courseintro" style="width: 98%">';
    $introduction_section .= $form->return_form();
    $introduction_section .= '</div>';
}
$thematic_description_html = '';
if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
    // Only show this if we're on the course homepage and we're not currently editing
    $thematic = new Thematic();
    $displayMode = api_get_course_setting('display_info_advance_inside_homecourse');
    $class1 = '';
    if ($displayMode == '1') {
        // Show only the current course progress step
        // $information_title = get_lang('InfoAboutLastDoneAdvance');
        $last_done_advance = $thematic->get_last_done_thematic_advance();
        $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
        $subTitle1 = get_lang('CurrentTopic');
        $class1 = ' current';
    } else {
        if ($displayMode == '2') {
            // Show only the two next course progress steps
            // $information_title = get_lang('InfoAboutNextAdvanceNotDone');
            $last_done_advance = $thematic->get_next_thematic_advance_not_done();
            $next_advance_not_done = $thematic->get_next_thematic_advance_not_done(2);
Esempio n. 3
0
     $messages_in_course = Tracking::count_student_messages($users, $courseId, $id_session);
     $assignments_in_course = Tracking::count_student_assignments($users, $courseId, $id_session);
     $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);
     if (is_numeric($avg_score_in_course)) {
         $avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2) . '%';
     }
 } else {
     $avg_time_spent_in_course = null;
     $avg_progress_in_course = null;
     $avg_score_in_course = null;
     $messages_in_course = null;
     $assignments_in_course = null;
 }
 $tematic_advance_progress = 0;
 $thematic = new Thematic($course);
 $tematic_advance = $thematic->get_total_average_of_thematic_advances($course_code, $id_session);
 if (!empty($tematic_advance)) {
     $tematic_advance_csv = $tematic_advance_progress . '%';
     $tematic_advance_progress = '<a title="' . get_lang('GoToThematicAdvance') . '" href="' . api_get_path(WEB_CODE_PATH) . 'course_progress/index.php?cidReq=' . $course_code . '&id_session=' . $id_session . '">' . $tematic_advance . '%</a>';
 } else {
     $tematic_advance_progress = '-';
 }
 $table_row = array();
 $table_row[] = $course['title'];
 $table_row[] = $nb_students_in_course;
 $table_row[] = is_null($avg_time_spent_in_course) ? '-' : $avg_time_spent_in_course;
 $table_row[] = $tematic_advance_progress;
 $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($messages_in_course) ? '-' : $messages_in_course;
Esempio n. 4
0
    $action = 'thematic_details';
}
if ($action == 'thematic_details' || $action == 'thematic_list') {
    $_SESSION['thematic_control'] = $action;
}
// get thematic id
if (isset($_GET['thematic_id'])) {
    $thematic_id = intval($_GET['thematic_id']);
}
// get thematic plan description type
if (isset($_GET['description_type'])) {
    $description_type = intval($_GET['description_type']);
}
$courseInfo = api_get_course_info();
// instance thematic object for using like library here
$thematic = new Thematic($courseInfo);
// thematic controller object
$thematic_controller = new ThematicController();
if (!empty($thematic_id)) {
    // thematic data by id
    $thematic_data = $thematic->get_thematic_list($thematic_id);
}
// get default thematic plan title
$default_thematic_plan_title = $thematic->get_default_thematic_plan_title();
// Only when I see the 3 columns. Avoids double or triple click binding for onclick event
$htmlHeadXtra[] = '<script type="text/javascript">

$(document).ready(function() {

	//Second col
     /*
Esempio n. 5
0
            }
        }
        ?>
		<div class="control-group">
			<label class="control-label"><?php 
        echo $label;
        ?>
</label>
			<div class="controls"><?php 
        echo $input_select;
        ?>
</div>
		</div>
		<?php 
        break;
    case 'update_done_thematic_advance':
        $thematic_advance_id = intval($_GET['thematic_advance_id']);
        $total_average = 0;
        if (!empty($thematic_advance_id)) {
            $thematic = new Thematic();
            $affected_rows = $thematic->update_done_thematic_advances($thematic_advance_id);
            //if ($affected_rows) {
            $total_average = $thematic->get_total_average_of_thematic_advances(api_get_course_id(), api_get_session_id());
            //}
        }
        echo $total_average;
        break;
    default:
        echo '';
}
exit;
Esempio n. 6
0
 /**
  * @param int $thematic_id
  */
 public function copy($thematic_id)
 {
     $thematic = self::get_thematic_list($thematic_id, api_get_course_id(), 0);
     $thematic_copy = new Thematic();
     $thematic_copy->set_thematic_attributes('', $thematic['title'] . ' - ' . get_lang('Copy'), $thematic['content'], api_get_session_id());
     $new_thematic_id = $thematic_copy->thematic_save();
     if (!empty($new_thematic_id)) {
         $thematic_advanced = self::get_thematic_advance_by_thematic_id($thematic_id);
         if (!empty($thematic_advanced)) {
             foreach ($thematic_advanced as $item) {
                 $thematic = new Thematic();
                 $thematic->set_thematic_advance_attributes(0, $new_thematic_id, 0, $item['content'], $item['start_date'], $item['duration']);
                 $thematic->thematic_advance_save();
             }
         }
         $thematic_plan = self::get_thematic_plan_data($thematic_id);
         if (!empty($thematic_plan)) {
             foreach ($thematic_plan as $item) {
                 $thematic = new Thematic();
                 $thematic->set_thematic_plan_attributes($new_thematic_id, $item['title'], $item['description'], $item['description_type']);
                 $thematic->thematic_plan_save();
             }
         }
     }
 }
Esempio n. 7
0
 /**
  * This method is used for thematic advance control (update, insert or listing)
  * render to thematic_advance.php
  * @param 	string	$action
  *
  */
 public function thematic_advance($action)
 {
     $thematic = new Thematic();
     $attendance = new Attendance();
     $data = array();
     $displayHeader = !empty($_REQUEST['display']) && $_REQUEST['display'] === 'no_header' ? false : true;
     // get data for attendance input select
     $attendance_list = $attendance->get_attendances_list();
     $attendance_select = array();
     $attendance_select[0] = get_lang('SelectAnAttendance');
     foreach ($attendance_list as $attendance_id => $attendance_data) {
         $attendance_select[$attendance_id] = $attendance_data['name'];
     }
     $thematic_id = intval($_REQUEST['thematic_id']);
     $thematic_advance_id = isset($_REQUEST['thematic_advance_id']) ? intval($_REQUEST['thematic_advance_id']) : null;
     $thematic_advance_data = array();
     switch ($action) {
         case 'thematic_advance_delete':
             if (!empty($thematic_advance_id)) {
                 if (api_is_allowed_to_edit(null, true)) {
                     $thematic->thematic_advance_destroy($thematic_advance_id);
                 }
                 header('Location: index.php');
                 exit;
             }
             break;
         case 'thematic_advance_list':
             if (!api_is_allowed_to_edit(null, true)) {
                 echo '';
                 exit;
             }
             if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance']) || !empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) {
                 if ($_REQUEST['start_date_type'] == 1 && empty($_REQUEST['start_date_by_attendance'])) {
                     $start_date_error = true;
                     $data['start_date_error'] = $start_date_error;
                 }
                 if (!empty($_REQUEST['duration_in_hours']) && !is_numeric($_REQUEST['duration_in_hours'])) {
                     $duration_error = true;
                     $data['duration_error'] = $duration_error;
                 }
                 $data['action'] = $_REQUEST['action'];
                 $data['thematic_id'] = $_REQUEST['thematic_id'];
                 $data['attendance_select'] = $attendance_select;
                 if (isset($_REQUEST['thematic_advance_id'])) {
                     $data['thematic_advance_id'] = $_REQUEST['thematic_advance_id'];
                     $thematic_advance_data = $thematic->get_thematic_advance_list($_REQUEST['thematic_advance_id']);
                     $data['thematic_advance_data'] = $thematic_advance_data;
                 }
             } else {
                 if (api_is_allowed_to_edit(null, true)) {
                     $thematic_advance_id = isset($_REQUEST['thematic_advance_id']) ? $_REQUEST['thematic_advance_id'] : null;
                     $thematic_id = $_REQUEST['thematic_id'];
                     $content = isset($_REQUEST['content']) ? $_REQUEST['content'] : null;
                     $duration = isset($_REQUEST['duration_in_hours']) ? $_REQUEST['duration_in_hours'] : null;
                     if (isset($_REQUEST['start_date_type']) && $_REQUEST['start_date_type'] == 2) {
                         $start_date = $_REQUEST['custom_start_date'];
                         $attendance_id = 0;
                     } else {
                         $start_date = isset($_REQUEST['start_date_by_attendance']) ? $_REQUEST['start_date_by_attendance'] : null;
                         $attendance_id = isset($_REQUEST['attendance_select']) ? $_REQUEST['attendance_select'] : null;
                     }
                     $thematic->set_thematic_advance_attributes($thematic_advance_id, $thematic_id, $attendance_id, $content, $start_date, $duration);
                     $affected_rows = $thematic->thematic_advance_save();
                     if ($affected_rows) {
                         // get last done thematic advance before move thematic list
                         $last_done_thematic_advance = $thematic->get_last_done_thematic_advance();
                         // update done advances with de current thematic list
                         if (!empty($last_done_thematic_advance)) {
                             $thematic->update_done_thematic_advances($last_done_thematic_advance);
                         }
                     }
                 }
             }
             break;
         default:
             $thematic_advance_data = $thematic->get_thematic_advance_list($thematic_advance_id);
             break;
     }
     // get calendar select by attendance id
     $calendar_select = array();
     if (!empty($thematic_advance_data)) {
         if (!empty($thematic_advance_data['attendance_id'])) {
             $attendance_calendar = $attendance->get_attendance_calendar($thematic_advance_data['attendance_id']);
             if (!empty($attendance_calendar)) {
                 foreach ($attendance_calendar as $calendar) {
                     $calendar_select[$calendar['date_time']] = $calendar['date_time'];
                 }
             }
         }
     }
     $data['action'] = $action;
     $data['thematic_id'] = $thematic_id;
     $data['thematic_advance_id'] = $thematic_advance_id;
     $data['attendance_select'] = $attendance_select;
     $data['thematic_advance_data'] = $thematic_advance_data;
     $data['calendar_select'] = $calendar_select;
     $layoutName = $displayHeader ? 'layout' : 'layout_no_header';
     // render to the view
     $this->view->set_data($data);
     $this->view->set_layout($layoutName);
     $this->view->set_template('thematic_advance');
     $this->view->render();
 }
 static function create_thematic($data)
 {
     //error_log('create_thematic');
     $session_id = $data['session_id'];
     if (!empty($session_id)) {
         $course_list = SessionManager::get_course_list_by_session_id($session_id);
         if (!empty($course_list)) {
             $course_data = current($course_list);
             $course_info = api_get_course_info($course_data['code']);
             if (!empty($course_data)) {
                 $thematic = new Thematic($course_info);
                 $thematic->set_course_int_id($course_info['real_id']);
                 $thematic->set_session_id($session_id);
                 $thematic_info = $thematic->get_thematic_by_title($data['thematic']);
                 if (empty($thematic_info)) {
                     $thematic->set_thematic_attributes(null, $data['thematic'], null, $session_id);
                     $thematic_id = $thematic->thematic_save();
                     error_log("Thematic added to course code: {$course_info['code']} - session_id: {$session_id}");
                 } else {
                     $thematic_id = isset($thematic_info['id']) ? $thematic_info['id'] : null;
                     error_log("Thematic id #{$thematic_id} found in course: {$course_info['code']} - session_id: {$session_id}");
                 }
                 if ($thematic_id) {
                     $thematic->set_thematic_plan_attributes($thematic_id, $data['thematic_plan'], null, 6);
                     $thematic->thematic_plan_save();
                     error_log("Saving plan attributes: {$data['thematic_plan']}");
                 }
                 error_log("Adding thematic id : {$thematic_id} to session: {$session_id} to course: {$course_info['code']} real_id: {$course_info['real_id']}");
                 if ($thematic_id) {
                     error_log("Thematic saved: {$thematic_id}");
                 } else {
                     error_log("Thematic NOT saved");
                 }
             }
             //if ($course_info['code'] != 'B05') {
             //exit;
             //}
         } else {
             error_log("No courses in session {$session_id} ");
         }
     }
 }
Esempio n. 9
0
 /**
  * @param string $tool
  * @param array $toolList
  *
  * @return null
  */
 public static function return_introduction_section($tool, $toolList = array())
 {
     $urlGenerator = Container::getRouter();
     $is_allowed_to_edit = api_is_allowed_to_edit();
     $courseInfo = api_get_course_info();
     $introduction_section = null;
     if (api_get_setting('course.enable_tool_introduction') == 'true' || $tool == TOOL_COURSE_HOMEPAGE) {
         $introduction_section = null;
         $TBL_INTRODUCTION = Database::get_course_table(TABLE_TOOL_INTRO);
         $session_id = api_get_session_id();
         $course_id = api_get_course_int_id();
         /* Retrieves the module introduction text, if exist */
         $sql = "SELECT iid, intro_text FROM {$TBL_INTRODUCTION}\n                    WHERE\n                        c_id = {$course_id} AND\n                        tool ='" . Database::escape_string($tool) . "' AND\n                        session_id = '" . intval($session_id) . "'";
         $intro_dbQuery = Database::query($sql);
         $introContent = null;
         $toolId = null;
         if (Database::num_rows($intro_dbQuery) > 0) {
             $row = Database::fetch_array($intro_dbQuery);
             $introContent = $row['intro_text'];
             $toolId = $row['iid'];
         }
         $introContent = CourseHome::replaceTextWithToolUrls($introContent, $toolList);
         /* Determines the correct display */
         $displayIntro = false;
         if ($is_allowed_to_edit) {
             $displayIntro = true;
         }
         $thematicDescription = '';
         if ($tool == TOOL_COURSE_HOMEPAGE) {
             $thematic = new Thematic($courseInfo);
             $thematic->set_course_int_id(api_get_course_int_id());
             if (api_get_course_setting('display_info_advance_inside_homecourse') == '1') {
                 $information_title = get_lang('InfoAboutLastDoneAdvance');
                 $last_done_advance = $thematic->get_last_done_thematic_advance();
                 $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
             } else {
                 if (api_get_course_setting('display_info_advance_inside_homecourse') == '2') {
                     $information_title = get_lang('InfoAboutNextAdvanceNotDone');
                     $next_advance_not_done = $thematic->get_next_thematic_advance_not_done();
                     $thematic_advance_info = $thematic->get_thematic_advance_list($next_advance_not_done);
                 } else {
                     if (api_get_course_setting('display_info_advance_inside_homecourse') == '3') {
                         $information_title = get_lang('InfoAboutLastDoneAdvanceAndNextAdvanceNotDone');
                         $last_done_advance = $thematic->get_last_done_thematic_advance();
                         $next_advance_not_done = $thematic->get_next_thematic_advance_not_done();
                         $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
                         $thematic_advance_info2 = $thematic->get_thematic_advance_list($next_advance_not_done);
                     }
                 }
             }
             if (!empty($thematic_advance_info)) {
                 $thematic_advance = get_lang('CourseThematicAdvance') . '&nbsp;' . $thematic->get_total_average_of_thematic_advances() . '%';
                 $thematic_info = $thematic->get_thematic_list($thematic_advance_info['thematic_id']);
                 $thematic_advance_info['start_date'] = api_get_local_time($thematic_advance_info['start_date']);
                 $thematic_advance_info['start_date'] = api_format_date($thematic_advance_info['start_date'], DATE_TIME_FORMAT_LONG);
                 $thematicDescription = '<div class="thematic-postit">
                                               <div class="thematic-postit-top"><h3><a class="thematic-postit-head" style="" href="#"> ' . $thematic_advance . '</h3></a></div>
                                               <div class="thematic-postit-center" style="display:none">';
                 $thematicDescription .= '<div><strong>' . $thematic_info['title'] . '</strong></div>';
                 $thematicDescription .= '<div style="font-size:8pt;"><strong>' . $thematic_advance_info['start_date'] . '</strong></div>';
                 $thematicDescription .= '<div>' . $thematic_advance_info['content'] . '</div>';
                 $thematicDescription .= '<div>' . get_lang('DurationInHours') . ' : ' . $thematic_advance_info['duration'] . '</div>';
                 if (!empty($thematic_advance_info2)) {
                     $thematic_info2 = $thematic->get_thematic_list($thematic_advance_info2['thematic_id']);
                     $thematic_advance_info2['start_date'] = api_get_local_time($thematic_advance_info2['start_date']);
                     $thematic_advance_info2['start_date'] = api_format_date($thematic_advance_info2['start_date'], DATE_TIME_FORMAT_LONG);
                     $thematicDescription .= '<div><strong>' . $thematic_info2['title'] . '</strong></div>';
                     $thematicDescription .= '<div style="font-size:8pt;"><strong>' . $thematic_advance_info2['start_date'] . '</strong></div>';
                     $thematicDescription .= '<div>' . $thematic_advance_info2['content'] . '</div>';
                     $thematicDescription .= '<div>' . get_lang('DurationInHours') . ' : ' . $thematic_advance_info2['duration'] . '</div>';
                     $thematicDescription .= '<br />';
                 }
                 $thematicDescription .= '</div>
                                           <div class="thematic-postit-bottom"></div>
                                           </div>';
             }
         }
         $introduction_section .= '<div id="introduction_block" class="row"><div class="col-md-12">';
         $introduction_section .= $thematicDescription;
         if (!empty($introContent)) {
             $introduction_section .= $introContent;
         }
         $introduction_section .= '</div>';
         if ($displayIntro) {
             if (empty($introContent)) {
                 // Displays "Add intro" commands
                 $introduction_section .= '<div id="introduction_block_action" class="col-md-2 col-md-offset-10">';
                 $em = Database::getManager();
                 $criteria = ['tool' => $tool, 'cId' => api_get_course_int_id()];
                 $toolIntro = $em->getRepository('ChamiloCourseBundle:CToolIntro')->findOneBy($criteria);
                 if ($toolIntro) {
                     $url = $urlGenerator->generate('chamilo_course_ctoolintro_update', array('tool' => $toolIntro->getTool(), 'course' => api_get_course_id(), 'iid' => $toolIntro->getId()));
                 } else {
                     $url = $urlGenerator->generate('chamilo_course_ctoolintro_create', array('tool' => $tool, 'course' => api_get_course_id()));
                 }
                 $introduction_section .= "<a href=\"" . $url . "?" . api_get_cidreq() . "\">";
                 $introduction_section .= Display::return_icon('introduction_add.gif', get_lang('AddIntro')) . ' ';
                 $introduction_section .= "</a>";
                 $introduction_section .= "</div>";
             } else {
                 // Displays "edit intro && delete intro" commands
                 $introduction_section .= '<div id="introduction_block_action" class="col-md-2 col-md-offset-10">';
                 $url = $urlGenerator->generate('chamilo_course_ctoolintro_update', array('tool' => $tool, 'iid' => $toolId, 'course' => api_get_course_id()));
                 $introduction_section .= "<a href=\"" . $url . "?" . api_get_cidreq() . "\">";
                 $introduction_section .= Display::return_icon('edit.png', get_lang('Modify')) . ' ';
                 $introduction_section .= "</a>";
                 $url = $urlGenerator->generate('chamilo_course_ctoolintro_delete', array('iid' => $toolId, 'course' => api_get_course_id()));
                 $introduction_section .= "<a onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'))) . "')) return false;\" href=\"" . $url . "?" . api_get_cidreq() . "\">";
                 $introduction_section .= Display::return_icon('delete.png', get_lang('AddIntro')) . ' ';
                 $introduction_section .= "</a>";
                 $introduction_section .= "</div>";
             }
         }
         $introduction_section .= '</div>';
     }
     return $introduction_section;
     /*$moduleId = $tool;
       if (api_get_setting('course.enable_tool_introduction') == 'true' ||
           $tool == TOOL_COURSE_HOMEPAGE
       ) {
           $introduction_section = null;
           require api_get_path(INCLUDE_PATH).'introductionSection.inc.php';
           return $introduction_section;
       }*/
 }
Esempio n. 10
0
function get_courses($from, $limit, $column, $direction)
{
    $userId = api_get_user_id();
    $sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
    $keyword = isset($_GET['keyword']) ? $_GET['keyword'] : null;
    $follow = isset($_GET['follow']) ? true : false;
    $drhLoaded = false;
    if (api_is_drh()) {
        if (api_drh_can_access_all_session_content()) {
            $courses = SessionManager::getAllCoursesFollowedByUser($userId, $sessionId, $from, $limit, $column, $direction, false, $keyword);
            $drhLoaded = true;
        }
    }
    if ($drhLoaded == false) {
        $courses = CourseManager::getCoursesFollowedByUser($userId, COURSEMANAGER, $from, $limit, $column, $direction, false, $keyword, $sessionId, $follow);
    }
    $courseList = array();
    if (!empty($courses)) {
        foreach ($courses as $data) {
            $courseCode = $data['code'];
            $courseInfo = api_get_course_info($courseCode);
            $userList = CourseManager::get_user_list_from_course_code($data['code'], $sessionId);
            $userIdList = array();
            if (!empty($userList)) {
                foreach ($userList as $user) {
                    $userIdList[] = $user['user_id'];
                }
            }
            $messagesInCourse = 0;
            $assignmentsInCourse = 0;
            $avgTimeSpentInCourse = 0;
            $avgProgressInCourse = 0;
            if (count($userIdList) > 0) {
                $countStudents = count($userIdList);
                // tracking data
                $avgProgressInCourse = Tracking::get_avg_student_progress($userIdList, $courseCode, array(), $sessionId);
                $avgScoreInCourse = Tracking::get_avg_student_score($userIdList, $courseCode, array(), $sessionId);
                $avgTimeSpentInCourse = Tracking::get_time_spent_on_the_course($userIdList, $courseInfo['real_id'], $sessionId);
                $messagesInCourse = Tracking::count_student_messages($userIdList, $courseCode, $sessionId);
                $assignmentsInCourse = Tracking::count_student_assignments($userIdList, $courseCode, $sessionId);
                $avgTimeSpentInCourse = api_time_to_hms($avgTimeSpentInCourse / $countStudents);
                $avgProgressInCourse = round($avgProgressInCourse / $countStudents, 2);
                if (is_numeric($avgScoreInCourse)) {
                    $avgScoreInCourse = round($avgScoreInCourse / $countStudents, 2) . '%';
                }
            }
            $thematic = new Thematic();
            $tematic_advance = $thematic->get_total_average_of_thematic_advances($courseCode, $sessionId);
            $tematicAdvanceProgress = '-';
            if (!empty($tematic_advance)) {
                $tematicAdvanceProgress = '<a title="' . get_lang('GoToThematicAdvance') . '" href="' . api_get_path(WEB_CODE_PATH) . 'course_progress/index.php?cidReq=' . $courseCode . '&id_session=' . $sessionId . '">' . $tematic_advance . '%</a>';
            }
            $courseIcon = '<a href="' . api_get_path(WEB_CODE_PATH) . 'tracking/courseLog.php?cidReq=' . $courseCode . '&id_session=' . $sessionId . '">
                        ' . Display::return_icon('2rightarrow.png', get_lang('Details')) . '
                      </a>';
            $title = Display::url($data['title'], $courseInfo['course_public_url'] . '?id_session=' . $sessionId);
            $attendanceLink = Display::url(Display::return_icon('attendance_list.png', get_lang('Attendance'), array(), ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'attendance/index.php?cidReq=' . $courseCode . '&id_session=' . $sessionId . '&action=calendar_logins');
            $courseList[] = array($title, $countStudents, is_null($avgTimeSpentInCourse) ? '-' : $avgTimeSpentInCourse, $tematicAdvanceProgress, is_null($avgProgressInCourse) ? '-' : $avgProgressInCourse . '%', is_null($avgScoreInCourse) ? '-' : $avgScoreInCourse, is_null($messagesInCourse) ? '-' : $messagesInCourse, is_null($assignmentsInCourse) ? '-' : $assignmentsInCourse, $attendanceLink, $courseIcon);
        }
    }
    return $courseList;
}
    /**
     * 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;
    }