if ($displayMode == '3') { // Show the current and next course progress steps // $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); $subTitle1 = get_lang('CurrentTopic'); $subTitle2 = get_lang('NextTopic'); $class1 = ' current'; } } } if (!empty($thematic_advance_info)) { $thematic_advance = get_lang('CourseThematicAdvance'); $thematicScore = $thematic->get_total_average_of_thematic_advances() . '%'; $thematicUrl = api_get_path(WEB_CODE_PATH) . 'course_progress/index.php?action=thematic_details&' . api_get_cidreq(); $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); $userInfo = api_get_user_info(); $courseInfo = api_get_course_info(); $titleThematic = $thematic_advance . ' : ' . $courseInfo['name'] . ' <b>( ' . $thematicScore . ' )</b>'; $infoUser = '******' . $userInfo['avatar'] . '" class="img-circle img-responsive"></div>'; $infoUser .= '<div class="progress"> <div class="progress-bar progress-bar-danger" role="progressbar" style="width: ' . $thematicScore . ';"> ' . $thematicScore . ' </div> </div>'; $thematicItemOne = ' <div class="col-md-6 items-progress">
} } ?> <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;
$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; $table_row[] = is_null($assignments_in_course) ? '-' : $assignments_in_course;
/** * This method is used for thematic control (update, insert or listing) * @param string Action * render to thematic.php */ public function thematic($action) { $thematic = new Thematic(); $data = array(); $error = false; $msg_add = false; $check = Security::check_token('request'); $thematic_id = isset($_REQUEST['thematic_id']) ? intval($_REQUEST['thematic_id']) : null; $displayHeader = !empty($_REQUEST['display']) && $_REQUEST['display'] === 'no_header' ? false : true; if ($check) { switch ($action) { case 'thematic_add': case 'thematic_edit': // insert or update a thematic if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { if (trim($_POST['title']) !== '') { if (api_is_allowed_to_edit(null, true)) { $id = isset($_POST['thematic_id']) ? $_POST['thematic_id'] : null; $title = trim($_POST['title']); $content = trim($_POST['content']); $session_id = api_get_session_id(); $thematic->set_thematic_attributes($id, $title, $content, $session_id); $last_id = $thematic->thematic_save(); if ($_POST['action'] == 'thematic_add') { $action = 'thematic_details'; $thematic_id = null; if ($last_id) { $data['last_id'] = $last_id; } } else { $action = 'thematic_details'; $thematic_id = null; } } } else { $error = true; $data['error'] = $error; $data['action'] = $_POST['action']; $data['thematic_id'] = $_POST['thematic_id']; // render to the view $this->view->set_data($data); $this->view->set_layout('layout'); $this->view->set_template('thematic'); $this->view->render(); } } break; case 'thematic_copy': //Copy a thematic to a session $thematic->copy($thematic_id); $thematic_id = null; $action = 'thematic_details'; break; case 'thematic_delete_select': //Delete many thematics if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { if (api_is_allowed_to_edit(null, true)) { $thematic_ids = $_POST['id']; $affected_rows = $thematic->thematic_destroy($thematic_ids); } $action = 'thematic_details'; } break; case 'thematic_delete': // Delete a thematic if (isset($thematic_id)) { if (api_is_allowed_to_edit(null, true)) { $thematic->thematic_destroy($thematic_id); } $thematic_id = null; $action = 'thematic_details'; } break; case 'thematic_import_select': break; case 'thematic_import': $csv_import_array = Import::csvToArray($_FILES['file']['tmp_name']); if (isset($_POST['replace']) && $_POST['replace']) { // Remove current thematic. $list = $thematic->get_thematic_list(); foreach ($list as $i) { $thematic->thematic_destroy($i); } } // Import the progress. $current_thematic = null; foreach ($csv_import_array as $item) { $key = $item['type']; switch ($key) { case 'title': $thematic->set_thematic_attributes(null, $item['data1'], $item['data2'], api_get_session_id()); $current_thematic = $thematic->thematic_save(); $description_type = 0; break; case 'plan': $thematic->set_thematic_plan_attributes($current_thematic, $item['data1'], $item['data2'], $description_type); $thematic->thematic_plan_save(); $description_type++; break; case 'progress': $thematic->set_thematic_advance_attributes(null, $current_thematic, 0, $item['data3'], $item['data1'], $item['data2']); $thematic->thematic_advance_save(); break; } } $action = 'thematic_details'; break; case 'thematic_export': $list = $thematic->get_thematic_list(); $csv = array(); $csv[] = array('type', 'data1', 'data2', 'data3'); foreach ($list as $theme) { $csv[] = array('title', $theme['title'], $theme['content']); $data = $thematic->get_thematic_plan_data($theme['id']); if (!empty($data)) { foreach ($data as $plan) { $csv[] = array('plan', $plan['title'], $plan['description']); } } $data = $thematic->get_thematic_advance_by_thematic_id($theme['id']); if (!empty($data)) { foreach ($data as $advance) { $csv[] = array('progress', $advance['start_date'], $advance['duration'], $advance['content']); } } } Export::arrayToCsv($csv); exit; // Don't continue building a normal page. return; case 'thematic_export_pdf': $list = $thematic->get_thematic_list(); $table = array(); $table[] = array(get_lang('Thematic'), get_lang('ThematicPlan'), get_lang('ThematicAdvance')); foreach ($list as $theme) { $data = $thematic->get_thematic_plan_data($theme['id']); $plan_html = null; if (!empty($data)) { foreach ($data as $plan) { $plan_html .= '<strong>' . $plan['title'] . '</strong><br /> ' . $plan['description'] . '<br />'; } } $data = $thematic->get_thematic_advance_by_thematic_id($theme['id']); $advance_html = null; if (!empty($data)) { foreach ($data as $advance) { $advance_html .= api_convert_and_format_date($advance['start_date'], DATE_FORMAT_LONG) . ' (' . $advance['duration'] . ' ' . get_lang('HourShort') . ')<br />' . $advance['content'] . '<br />'; } } $table[] = array($theme['title'], $plan_html, $advance_html); } $params = array('filename' => get_lang('Thematic') . '-' . api_get_local_time(), 'pdf_title' => get_lang('Thematic'), 'add_signatures' => true, 'format' => 'A4-L', 'orientation' => 'L'); Export::export_table_pdf($table, $params); break; case 'moveup': $thematic->move_thematic('up', $thematic_id); $action = 'thematic_details'; $thematic_id = null; break; case 'movedown': $thematic->move_thematic('down', $thematic_id); $action = 'thematic_details'; $thematic_id = null; break; } Security::clear_token(); } else { $action = 'thematic_details'; $thematic_id = null; } if (isset($thematic_id)) { $data['thematic_data'] = $thematic->get_thematic_list($thematic_id); $data['thematic_id'] = $thematic_id; } if ($action == 'thematic_details') { if (isset($thematic_id)) { $thematic_data_result = $thematic->get_thematic_list($thematic_id); if (!empty($thematic_data_result)) { $thematic_data[$thematic_id] = $thematic_data_result; } $data['total_average_of_advances'] = $thematic->get_average_of_advances_by_thematic($thematic_id); } else { $thematic_data = $thematic->get_thematic_list(null, api_get_course_id(), api_get_session_id()); $data['max_thematic_item'] = $thematic->get_max_thematic_item(); $data['last_done_thematic_advance'] = $thematic->get_last_done_thematic_advance(); $data['total_average_of_advances'] = $thematic->get_total_average_of_thematic_advances(); } // Second column $thematic_plan_data = $thematic->get_thematic_plan_data(); // Third column $thematic_advance_data = $thematic->get_thematic_advance_list(null, null, true); $data['thematic_plan_div'] = $thematic->get_thematic_plan_div($thematic_plan_data); $data['thematic_advance_div'] = $thematic->get_thematic_advance_div($thematic_advance_data); $data['thematic_plan_data'] = $thematic_plan_data; $data['thematic_advance_data'] = $thematic_advance_data; $data['thematic_data'] = $thematic_data; } $data['default_thematic_plan_title'] = $thematic->get_default_thematic_plan_title(); $data['action'] = $action; $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'); $this->view->render(); }
} ?> <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']); $courseInfo = api_get_course_info(); $total_average = 0; if (!empty($thematic_advance_id)) { $thematic = new Thematic($courseInfo); $affected_rows = $thematic->update_done_thematic_advances($thematic_advance_id); //if ($affected_rows) { $total_average = $thematic->get_total_average_of_thematic_advances(null, api_get_session_id()); //} } echo $total_average; break; default: echo ''; } exit;
/** * @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') . ' ' . $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; }*/ }
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; }