/** * @param int $item_id * @param array course info * @return bool */ function deleteWorkItem($item_id, $courseInfo) { $work_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); $TSTDPUBASG = Database :: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); $currentCourseRepositorySys = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/'; $is_allowed_to_edit = api_is_allowed_to_edit(); $file_deleted = false; $item_id = intval($item_id); $is_author = user_is_author($item_id); $work_data = get_work_data_by_id($item_id); $locked = api_resource_is_locked_by_gradebook($work_data['parent_id'], LINK_STUDENTPUBLICATION); $course_id = $courseInfo['real_id']; if (($is_allowed_to_edit && $locked == false) || ( $locked == false && $is_author && api_get_course_setting('student_delete_own_publication') == 1 && $work_data['qualificator_id'] == 0 ) ) { // We found the current user is the author $sql = "SELECT url, contains_file FROM $work_table WHERE c_id = $course_id AND id = $item_id"; $result = Database::query($sql); $row = Database::fetch_array($result); if (Database::num_rows($result) > 0) { $sql = "UPDATE $work_table SET active = 2 WHERE c_id = $course_id AND id = $item_id"; Database::query($sql); $sql = "DELETE FROM $TSTDPUBASG WHERE c_id = $course_id AND publication_id = $item_id"; Database::query($sql); api_item_property_update( $courseInfo, 'work', $item_id, 'DocumentDeleted', api_get_user_id() ); $work = $row['url']; if ($row['contains_file'] == 1) { if (!empty($work)) { if (api_get_setting('permanently_remove_deleted_files') == 'true') { my_delete($currentCourseRepositorySys.'/'.$work); $file_deleted = true; } else { $extension = pathinfo($work, PATHINFO_EXTENSION); $new_dir = $work.'_DELETED_'.$item_id.'.'.$extension; if (file_exists($currentCourseRepositorySys.'/'.$work)) { rename($currentCourseRepositorySys.'/'.$work, $currentCourseRepositorySys.'/'.$new_dir); $file_deleted = true; } } } } else { $file_deleted = true; } } } return $file_deleted; }
require 'lp_add.php'; } break; case 'admin_view': if (!$is_allowed_to_edit) { api_not_allowed(true); } if ($debug > 0) error_log('New LP - admin_view action triggered', 0); if (!$lp_found) { error_log('New LP - No learnpath given for admin_view', 0); require 'lp_list.php'; } else { $_SESSION['refresh'] = 1; require 'lp_admin_view.php'; } break; case 'auto_launch': if (api_get_course_setting('enable_lp_auto_launch') == 1) { //Redirect to a specific LP if (!$is_allowed_to_edit) { api_not_allowed(true); } if ($debug > 0) error_log('New LP - auto_launch action triggered', 0); if (!$lp_found) { error_log('New LP - No learnpath given for set_autolunch', 0); require 'lp_list.php'; } else { $_SESSION['oLP']->set_autolunch($_GET['lp_id'], $_GET['status']); require 'lp_list.php'; exit; } } break; case 'build': if (!$is_allowed_to_edit) { api_not_allowed(true);
if (!$is_allowed_to_edit) { api_not_allowed(true); } if ($debug > 0) { error_log('New LP - admin_view action triggered', 0); } if (!$lp_found) { error_log('New LP - No learnpath given for admin_view', 0); require 'lp_list.php'; } else { $_SESSION['refresh'] = 1; require 'lp_admin_view.php'; } break; case 'auto_launch': if (api_get_course_setting('enable_lp_auto_launch') == 1) { //Redirect to a specific LP if (!$is_allowed_to_edit) { api_not_allowed(true); } if ($debug > 0) { error_log('New LP - auto_launch action triggered', 0); } if (!$lp_found) { error_log('New LP - No learnpath given for set_autolunch', 0); require 'lp_list.php'; } else { $_SESSION['oLP']->set_autolunch($_GET['lp_id'], $_GET['status']); require 'lp_list.php'; exit; }
$group_properties = GroupManager::get_group_properties($group_id); $interbreadcrumb[] = array("url" => api_get_path(WEB_CODE_PATH) . "group/group.php?" . api_get_cidreq(), "name" => get_lang('Groups')); $interbreadcrumb[] = array("url" => api_get_path(WEB_CODE_PATH) . "group/group_space.php?" . api_get_cidreq(), "name" => get_lang('GroupSpace') . ' ' . $group_properties['name']); } if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') { //we are not in the learning path Display::display_header($nameTools, get_lang('Announcements')); } // Tool introduction if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath') { Display::display_introduction_section(TOOL_ANNOUNCEMENT); } // Actions $show_actions = false; $actionsLeft = ''; if ((api_is_allowed_to_edit(false, true) || api_get_course_setting('announcement.allow_user_edit_announcement') && !api_is_anonymous()) && (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath')) { if (in_array($action, array('add', 'modify', 'view'))) { $actionsLeft .= "<a href='" . api_get_self() . "?" . api_get_cidreq() . "&origin=" . $origin . "'>" . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . "</a>"; } else { $actionsLeft .= "<a href='" . api_get_self() . "?" . api_get_cidreq() . "&action=add&origin=" . $origin . "'>" . Display::return_icon('new_announce.png', get_lang('AddAnnouncement'), '', ICON_SIZE_MEDIUM) . "</a>"; } $show_actions = true; } else { if (in_array($action, array('view'))) { $actionsLeft .= "<a href='" . api_get_self() . "?" . api_get_cidreq() . "&origin=" . $origin . "'>" . Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM) . "</a>"; echo '</div>'; } } if (api_is_allowed_to_edit() && $announcement_number > 1) { if (api_get_group_id() == 0) { if (!isset($_GET['action'])) {
/** * See this file in you BBB to set up default values * @param array $params Array of parameters that will be completed if not containing all expected variables /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties * More record information: http://code.google.com/p/bigbluebutton/wiki/RecordPlaybackSpecification # Default maximum number of users a meeting can have. # Doesn't get enforced yet but is the default value when the create # API doesn't pass a value. defaultMaxUsers=20 # Default duration of the meeting in minutes. # Current default is 0 (meeting doesn't end). defaultMeetingDuration=0 # Remove the meeting from memory when the end API is called. # This allows 3rd-party apps to recycle the meeting right-away # instead of waiting for the meeting to expire (see below). removeMeetingWhenEnded=false # The number of minutes before the system removes the meeting from memory. defaultMeetingExpireDuration=1 # The number of minutes the system waits when a meeting is created and when # a user joins. If after this period, a user hasn't joined, the meeting is # removed from memory. defaultMeetingCreateJoinDuration=5 * */ public function createMeeting($params) { $params['c_id'] = api_get_course_int_id(); $courseCode = api_get_course_id(); $params['session_id'] = api_get_session_id(); $params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : api_get_course_id(); $attendeePassword = $params['attendee_pw']; $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword(); $moderatorPassword = $params['moderator_pw']; $params['record'] = api_get_course_setting('big_blue_button_record_and_store', $courseCode) == 1 ? true : false; $max = api_get_course_setting('big_blue_button_max_students_allowed', $courseCode); $max = isset($max) ? $max : -1; $params['status'] = 1; // Generate a pseudo-global-unique-id to avoid clash of conferences on // the same BBB server with several Chamilo portals $params['remote_id'] = uniqid(true, true); // Each simultaneous conference room needs to have a different // voice_bridge composed of a 5 digits number, so generating a random one $params['voice_bridge'] = rand(10000, 99999); if ($this->debug) { error_log("enter create_meeting " . print_r($params, 1)); } $params['created_at'] = api_get_utc_datetime(); $id = Database::insert($this->table, $params); if ($id) { if ($this->debug) { error_log("create_meeting: {$id} "); } $meetingName = isset($params['meeting_name']) ? $params['meeting_name'] : api_get_course_id() . '-' . api_get_session_id(); $welcomeMessage = isset($params['welcome_msg']) ? $params['welcome_msg'] : null; $record = isset($params['record']) && $params['record'] ? 'true' : 'false'; $duration = isset($params['duration']) ? intval($params['duration']) : 0; // This setting currently limits the maximum conference duration, // to avoid lingering sessions on the video-conference server #6261 $duration = 300; $bbbParams = array('meetingId' => $params['remote_id'], 'meetingName' => $meetingName, 'attendeePw' => $attendeePassword, 'moderatorPw' => $moderatorPassword, 'welcomeMsg' => $welcomeMessage, 'dialNumber' => '', 'voiceBridge' => $params['voice_bridge'], 'webVoice' => '', 'logoutUrl' => $this->logout_url, 'maxParticipants' => $max, 'record' => $record, 'duration' => $duration); if ($this->debug) { error_log("create_meeting params: " . print_r($bbbParams, 1)); } $status = false; $meeting = null; while ($status == false) { $result = $this->api->createMeetingWithXmlResponseArray($bbbParams); if (isset($result) && strval($result['returncode']) == 'SUCCESS') { if ($this->debug) { error_log("create_meeting result: " . print_r($result, 1)); } $meeting = $this->joinMeeting($meetingName, true); return $meeting; } } return $this->logout; } }
if ($is_allowed_to_edit) { global $interbreadcrumb; $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list&isStudentView=false', 'name' => get_lang('LearningPaths')); $interbreadcrumb[] = array('url' => api_get_self() . "?action=add_item&type=step&lp_id={$learnPath->lp_id}&isStudentView=false", 'name' => $learnPath->get_name()); $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Preview')); $breadcrumb = Display::returnBreadcrumb($interbreadcrumb, null, null); } // Return to course home. if ($is_allowed_to_edit) { $buttonHomeUrl = 'lp_controller.php?' . api_get_cidreq() . '&' . http_build_query(['isStudentView' => 'false', 'action' => 'return_to_course_homepage']); } else { $buttonHomeUrl = 'lp_controller.php?' . api_get_cidreq() . '&' . http_build_query(['action' => 'return_to_course_homepage']); } $buttonHomeText = get_lang('CourseHomepageLink'); // Return to lp list if (api_get_course_setting('lp_return_link') == 1) { $buttonHomeUrl .= '&redirectTo=lp_list'; $buttonHomeText = get_lang('LearningPathList'); } $lpPreviewImagePath = api_get_path(WEB_IMG_PATH) . 'icons/64/unknown.png'; if ($learnPath->get_preview_image()) { $lpPreviewImagePath = $learnPath->get_preview_image_path(); } if ($learnPath->current == $learnPath->get_last()) { $categories = Category::load(null, null, $course_code, null, null, $sessionId); if (!empty($categories)) { $gradebookEvaluations = $categories[0]->get_evaluations(); $gradebookLinks = $categories[0]->get_links(); if (count($gradebookEvaluations) === 0 && count($gradebookLinks) === 1 && $gradebookLinks[0]->get_type() == LINK_LEARNPATH && $gradebookLinks[0]->get_ref_id() == $learnPath->lp_id) { $gradebookMinScore = $categories[0]->get_certificate_min_score(); $userScore = $gradebookLinks[0]->calc_score($user_id, 'best');
/** * @param string $courseCode * @return string 'visible' or 'invisible' string */ public static function getDocumentDefaultVisibility($courseCode) { $settings = api_get_setting('document.tool_visible_by_default_at_creation'); $defaultVisibility = 'visible'; if (isset($settings['documents'])) { $portalDefaultVisibility = 'invisible'; if ($settings['documents'] == 'true') { $portalDefaultVisibility = 'visible'; } $defaultVisibility = $portalDefaultVisibility; } if (api_get_setting('document.documents_default_visibility_defined_in_course') == 'true') { $courseVisibility = api_get_course_setting('documents_default_visibility', $courseCode); if (!empty($courseVisibility) && in_array($courseVisibility, array('visible', 'invisible'))) { $defaultVisibility = $courseVisibility; } } return $defaultVisibility; }
/** * Get the achieved certificates for a user in course sessions * @param int $userId The user id * @param type $includeNonPublicCertificates Whether include the non-plublic certificates * @return array */ public static function getUserCertificatesInSessions($userId, $includeNonPublicCertificates = true) { $userId = intval($userId); $sessionList = []; $sessions = SessionManager::get_sessions_by_user($userId); foreach ($sessions as $session) { if (empty($session['courses'])) { continue; } $sessionCourses = SessionManager::get_course_list_by_session_id($session['session_id']); foreach ($sessionCourses as $course) { if (!$includeNonPublicCertificates) { $allowPublicCertificates = api_get_course_setting('allow_public_certificates', $course['code']); if (empty($allowPublicCertificates)) { continue; } } $courseGradebookCategory = Category::load(null, null, $course['code'], null, null, $session['session_id']); if (empty($courseGradebookCategory)) { continue; } $courseGradebookId = $courseGradebookCategory[0]->get_id(); $certificateInfo = GradebookUtils::get_certificate_by_user_id($courseGradebookId, $userId); if (empty($certificateInfo)) { continue; } $sessionList[] = ['session' => $session['session_name'], 'course' => $course['title'], 'score' => $certificateInfo['score_certificate'], 'date' => api_format_date($certificateInfo['created_at'], DATE_FORMAT_SHORT), 'link' => api_get_path(WEB_PATH) . "certificates/index.php?id={$certificateInfo['id']}"]; } } return $sessionList; }
$link_id = $link_info['id']; if ($link_info !== false) { remove_resource_from_course_gradebook($link_id); } Display::display_confirmation_message(get_lang('DirDeleted') . ': ' . $work_to_delete['title']); } else { Display::display_warning_message(get_lang('ResourceLockedByGradebook')); } } /* DELETE WORK COMMAND */ if ($action == 'delete' && $item_id) { $file_deleted = false; $is_author = user_is_author($item_id); $work_data = get_work_data_by_id($item_id); $locked = api_resource_is_locked_by_gradebook($work_data['parent_id'], LINK_STUDENTPUBLICATION); if ($is_allowed_to_edit && $locked == false || ($locked == false and $is_author && api_get_course_setting('student_delete_own_publication') == 1 && $work_data['qualificator_id'] == 0)) { //we found the current user is the author $queryString1 = "SELECT url, contains_file FROM " . $work_table . " WHERE c_id = {$course_id} AND id = {$item_id}"; $result1 = Database::query($queryString1); $row = Database::fetch_array($result1); if (Database::num_rows($result1) > 0) { $queryString2 = "UPDATE " . $work_table . " SET active = 2 WHERE c_id = {$course_id} AND id = {$item_id}"; $queryString3 = "DELETE FROM " . $TSTDPUBASG . " WHERE c_id = {$course_id} AND publication_id = {$item_id}"; Database::query($queryString2); Database::query($queryString3); api_item_property_update($_course, 'work', $item_id, 'DocumentDeleted', $user_id); $work = $row['url']; if ($row['contains_file'] == 1) { if (!empty($work)) { if (api_get_setting('permanently_remove_deleted_files') == 'true') { my_delete($currentCourseRepositorySys . '/' . $work);
/** * Show a toolbar with shortcuts to the course tool */ public static function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL) { $navigation_items = self::get_navigation_items(false); $html = ''; if (!empty($navigation_items)) { if ($orientation == SHORTCUTS_HORIZONTAL) { $style_id = "toolshortcuts_horizontal"; } else { $style_id = "toolshortcuts_vertical"; } $html .= '<div id="' . $style_id . '">'; foreach ($navigation_items as $key => $navigation_item) { if (strpos($navigation_item['link'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) { $html .= '<a href="javascript: void(0);" onclick="javascript: window.open(\'' . $navigation_item['link'] . '\',\'window_chat' . $_SESSION['_cid'] . '\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $navigation_item['target'] . '"'; } else { $html .= '<a href="' . $navigation_item['link'] . '"'; } if (strpos(api_get_self(), $navigation_item['link']) !== false) { $html .= ' id="here"'; } $html .= ' target="_top" title="' . $navigation_item['name'] . '">'; $html .= '<img src="' . api_get_path(WEB_IMG_PATH) . $navigation_item['image'] . '" alt="' . $navigation_item['name'] . '"/>'; $html .= '</a> '; if ($orientation == SHORTCUTS_VERTICAL) { $html .= '<br />'; } } $html .= '</div>'; } return $html; }
$titleclass = 'forum_message_post_title'; $messageclass = 'forum_message_post_text'; $leftclass = 'forum_message_left'; } $indent = $post['indent_cnt'] * '20'; echo "<div style=\"margin-left: " . $indent . "px;\">"; echo "<table width=\"100%\" class=\"post\" cellspacing=\"5\" border=\"0\">"; echo "<tr>"; echo "<td rowspan=\"3\" class=\"{$leftclass}\">"; $username = sprintf(get_lang('LoginX'), $post['username']); if ($post['user_id'] == '0') { $name = $post['poster_name']; } else { $name = api_get_person_name($post['firstname'], $post['lastname']); } if (api_get_course_setting('allow_user_image_forum')) { echo '<br />' . display_user_image($post['user_id'], $name, $origin) . '<br />'; } echo display_user_link($post['user_id'], $name, $origin, $username) . "<br />"; echo api_convert_and_format_date($post['post_date']) . '<br /><br />'; // get attach id $attachment_list = get_attachment($post['post_id']); $id_attach = !empty($attachment_list) ? $attachment_list['id'] : ''; // The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum // The course admin him/herself can do this off course always if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) or $current_forum['allow_edit'] == 1 and $row['user_id'] == $_user['user_id'] or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) { if ($locked == false) { echo "<a href=\"editpost.php?" . api_get_cidreq() . "&forum=" . $clean_forum_id . "&thread=" . $clean_thread_id . "&post=" . $post['post_id'] . "&id_attach=" . $id_attach . "\">" . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . "</a>"; } } if (GroupManager::is_tutor_of_group(api_get_user_id(), $group_id) or api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && $current_forum['session_id'] != $_SESSION['id_session'])) {
$mylpid = empty($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id; $mylpitemid = empty($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id; $token = Security::get_token(); $i = 1; if ($is_allowedToEdit) { $headers = array(array('name' => get_lang('ExerciseName')), array('name' => get_lang('QuantityQuestions'), 'params' => array('width' => '100px')), array('name' => get_lang('Actions'), 'params' => array('width' => '180px'))); } else { $headers = array(array('name' => get_lang('ExerciseName')), array('name' => get_lang('Status'))); } $header_list = ''; foreach ($headers as $header) { $params = isset($header['params']) ? $header['params'] : null; $header_list .= Display::tag('th', $header['name'], $params); } echo Display::tag('tr', $header_list); $autolaunch_setting_on = api_get_course_setting('enable_exercise_auto_launch') == 1; $count = 0; if (!empty($exercise_list)) { foreach ($exercise_list as $row) { $my_exercise_id = $row['iid']; $exercise_obj = new Exercise(); $exercise_obj->read($my_exercise_id, false); $locked = $exercise_obj->is_gradebook_locked; //echo '<div id="tabs-'.$i.'">'; $i++; // Validation when belongs to a session $session_img = api_get_session_image($row['session_id'], $_user['status']); $time_limits = false; if ($row['start_time'] != '0000-00-00 00:00:00' || $row['end_time'] != '0000-00-00 00:00:00') { $time_limits = true; }
private function get_announcements($username, $course_code, $announcement_id = 0) { $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id); $announcement_id = $announcement_id == 0 ? "" : "AND announcement.id=" . $announcement_id; $user_id = UserManager::get_user_id_from_username($username); $course_info = CourseManager::get_course_information($course_code); $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); $maximum = '12'; $group_memberships = GroupManager::get_group_ids($course_info['real_id'], $user_id); if (api_get_group_id() == 0) { $cond_user_id = " AND (\n ip.to_user_id='" . $user_id . "' OR\n ip.to_group_id IN (0, " . implode(", ", $group_memberships) . ") OR\n ip.to_group_id IS NULL\n ) "; } else { $cond_user_id = " AND (\n ip.to_user_id='" . $user_id . "' OR\n ip.to_group_id IN (0, " . api_get_group_id() . ") OR\n ip.to_group_id IS NULL\n ) "; } // the user is member of several groups => display personal // announcements AND his group announcements AND the general announcements if (is_array($group_memberships) && count($group_memberships) > 0) { $sql = "SELECT\n announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id\n FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n WHERE\n announcement.id = ip.ref AND\n ip.tool='announcement' AND\n ip.visibility='1'\n {$announcement_id}\n {$cond_user_id}\n {$condition_session}\n GROUP BY ip.ref\n ORDER BY display_order DESC\n LIMIT 0,{$maximum}"; } else { // the user is not member of any group // this is an identified user => show the general announcements AND his personal announcements if ($user_id) { if (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) { $cond_user_id = " AND (\n ip.lastedit_user_id = '" . api_get_user_id() . "' OR\n ( ip.to_user_id='" . $user_id . "' OR ip.to_group_id='0' OR ip.to_group_id IS NULL)\n ) "; } else { $cond_user_id = " AND ( ip.to_user_id='" . $user_id . "' OR ip.to_group_id='0' OR ip.to_group_id IS NULL) "; } $sql = "SELECT\n announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id\n FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n WHERE\n announcement.id = ip.ref AND\n ip.tool='announcement' AND\n ip.visibility='1'\n {$announcement_id}\n {$cond_user_id}\n {$condition_session}\n GROUP BY ip.ref\n ORDER BY display_order DESC\n LIMIT 0,{$maximum}"; } else { if (api_get_course_setting('allow_user_edit_announcement')) { $cond_user_id = " AND (\n ip.lastedit_user_id = '" . api_get_user_id() . "' OR ip.to_group_id='0' OR ip.to_group_id IS NULL\n ) "; } else { $cond_user_id = " AND ip.to_group_id='0' "; } // the user is not identiefied => show only the general announcements $sql = "SELECT\n announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id\n FROM {$tbl_announcement} announcement, {$tbl_item_property} ip\n WHERE announcement.id = ip.ref\n AND ip.tool='announcement'\n AND ip.visibility='1'\n AND ip.to_group_id='0'\n {$announcement_id}\n {$condition_session}\n GROUP BY ip.ref\n ORDER BY display_order DESC\n LIMIT 0,{$maximum}"; } } $result = Database::query($sql); return $result; }
$show_autolaunch_lp_warning = true; } else { $session_key = 'lp_autolaunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id(); if (!isset($_SESSION[$session_key])) { //redirecting to the LP $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $lp_data['id']; $_SESSION[$session_key] = true; header("Location: {$url}"); exit; } } } } } } $forumAutoLaunch = api_get_course_setting('enable_forum_auto_launch'); if ($forumAutoLaunch == 1) { if (api_is_platform_admin() || api_is_allowed_to_edit()) { Display::addFlash(Display::return_message(get_lang('TheForumAutoLaunchSettingIsOnStudentsWillBeRedirectToTheForumTool'), 'warning')); } else { //$forumKey = 'forum_auto_launch_'.$session_id.'_'.api_get_course_int_id().'_'.api_get_user_id(); //if (!isset($_SESSION[$forumKey])) { //redirecting to the LP $url = api_get_path(WEB_CODE_PATH) . 'forum/index.php?' . api_get_cidreq() . '&id_session=' . $session_id; // $_SESSION[$forumKey] = true; header("Location: {$url}"); exit; //} } } $tool_table = Database::get_course_table(TABLE_TOOL_LIST);
/** * Subscribe the user to a given course * @param string Course code * @return string Message about results */ public function subscribe_user($course_code) { $user_id = api_get_user_id(); $all_course_information = CourseManager::get_course_information($course_code); if ($all_course_information['registration_code'] == '' || $_POST['course_registration_code'] == $all_course_information['registration_code']) { if (api_is_platform_admin()) { $status_user_in_new_course = COURSEMANAGER; } else { $status_user_in_new_course = null; } if (CourseManager::add_user_to_course($user_id, $course_code, $status_user_in_new_course)) { $send = api_get_course_setting('email_alert_to_teacher_on_new_user_in_course', $course_code); if ($send == 1) { CourseManager::email_to_tutor($user_id, $course_code, $send_to_tutor_also = false); } else { if ($send == 2) { CourseManager::email_to_tutor($user_id, $course_code, $send_to_tutor_also = true); } } $url = Display::url($all_course_information['title'], api_get_course_url($course_code)); $message = sprintf(get_lang('EnrollToCourseXSuccessful'), $url); } else { $message = get_lang('ErrorContactPlatformAdmin'); } return array('message' => $message); } else { if (isset($_POST['course_registration_code']) && $_POST['course_registration_code'] != $all_course_information['registration_code']) { return false; } $message = get_lang('CourseRequiresPassword') . '<br />'; $message .= $all_course_information['title'] . ' (' . $all_course_information['visual_code'] . ') '; $action = api_get_path(WEB_CODE_PATH) . "auth/courses.php?action=subscribe_user_with_password&sec_token=" . $_SESSION['sec_token']; $form = new FormValidator('subscribe_user_with_password', 'post', $action); $form->addElement('hidden', 'sec_token', $_SESSION['sec_token']); $form->addElement('hidden', 'subscribe_user_with_password', $all_course_information['code']); $form->addElement('text', 'course_registration_code'); $form->addButton(get_lang('SubmitRegistrationCode')); $content = $form->returnForm(); return array('message' => $message, 'content' => $content); } }
/** * Returns the name of the visual (CSS) theme to be applied on the current page. * The returned name depends on the platform, course or user -wide settings. * @return string The visual theme's name, it is the name of a folder inside .../chamilo/main/css/ */ function api_get_visual_theme() { static $visual_theme; if (!isset($visual_theme)) { $platform_theme = api_get_setting('stylesheets'); // Platform's theme. $visual_theme = $platform_theme; if (api_get_setting('profile.user_selected_theme') == 'true') { $user_info = api_get_user_info(); if (isset($user_info['theme'])) { $user_theme = $user_info['theme']; if (!empty($user_theme)) { $visual_theme = $user_theme; // User's theme. } } } $course_id = api_get_course_id(); if (!empty($course_id) && $course_id != -1) { if (api_get_setting('course.allow_course_theme') == 'true') { $course_theme = api_get_course_setting('course_theme'); if (!empty($course_theme) && $course_theme != -1) { if (!empty($course_theme)) { $visual_theme = $course_theme; // Course's theme. } } $allow_lp_theme = api_get_course_setting('allow_learning_path_theme'); if ($allow_lp_theme == 1) { global $lp_theme_css, $lp_theme_config; // These variables come from the file lp_controller.php. if (!$lp_theme_config) { if (!empty($lp_theme_css)) { $visual_theme = $lp_theme_css; // LP's theme. } } } } } if (empty($visual_theme)) { $visual_theme = 'chamilo'; } global $lp_theme_log; if ($lp_theme_log) { $visual_theme = $platform_theme; } } return $visual_theme; }
/** * @param int $filter * @param string $view * @return string */ public function displayActions($view, $filter = 0) { $courseInfo = api_get_course_info(); $actionsLeft = ''; $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_js.php?type={$this->type}'>" . Display::return_icon('calendar.png', get_lang('Calendar'), '', ICON_SIZE_MEDIUM) . "</a>"; $courseCondition = ''; if (!empty($courseInfo)) { $courseCondition = api_get_cidreq(); } $actionsLeft .= "<a href='" . api_get_path(WEB_CODE_PATH) . "calendar/agenda_list.php?type={$this->type}&" . $courseCondition . "'>" . Display::return_icon('week.png', get_lang('AgendaList'), '', ICON_SIZE_MEDIUM) . "</a>"; $form = ''; if (api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous() && api_is_allowed_to_session_edit(false, true) || GroupManager::user_has_access(api_get_user_id(), api_get_group_id(), GroupManager::GROUP_TOOL_CALENDAR) && GroupManager::is_tutor_of_group(api_get_user_id(), api_get_group_id())) { $actionsLeft .= Display::url(Display::return_icon('new_event.png', get_lang('AgendaAdd'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=add&type=" . $this->type); $actionsLeft .= Display::url(Display::return_icon('import_calendar.png', get_lang('ICalFileImport'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . "calendar/agenda.php?" . api_get_cidreq() . "&action=importical&type=" . $this->type); if ($this->type == 'course') { if (!isset($_GET['action'])) { $form = new FormValidator('form-search', 'post', '', '', array(), FormValidator::LAYOUT_INLINE); $attributes = array('multiple' => false, 'id' => 'select_form_id_search'); $selectedValues = $this->parseAgendaFilter($filter); $this->showToForm($form, $selectedValues, $attributes); $form = $form->returnForm(); } } } if (api_is_platform_admin() || api_is_teacher() || api_is_student_boss() || api_is_drh() || api_is_session_admin() || api_is_coach()) { if ($this->type == 'personal') { $form = null; if (!isset($_GET['action'])) { $form = new FormValidator('form-search', 'get', api_get_self() . '?type=personal&', '', array(), FormValidator::LAYOUT_INLINE); $sessions = SessionManager::get_sessions_by_user(api_get_user_id()); $form->addHidden('type', 'personal'); $sessions = array_column($sessions, 'session_name', 'session_id'); $sessions = ['0' => get_lang('SelectAnOption')] + $sessions; $form->addSelect('session_id', get_lang('Session'), $sessions, ['id' => 'session_id', 'onchange' => 'submit();']); //$form->addButtonFilter(get_lang('Filter')); //$renderer = $form->defaultRenderer(); //$renderer->setCustomElementTemplate('<div class="col-md-6">{element}</div>'); $form->addButtonReset(get_lang('Reset')); $form = $form->returnForm(); } } } $actionsRight = ''; if ($view == 'calendar') { $actionsRight .= $form; } $toolbar = Display::toolbarAction('toolbar-agenda', array(0 => $actionsLeft, 1 => $actionsRight), 2, false); return $toolbar; }
if (!empty($msg)) { $show_message .= Display::return_message(get_lang($msg['message']), 'info', false); } } } /* Is the user allowed here? */ api_protect_course_script(true); /* STATISTICS */ if (!isset($coursesAlreadyVisited[$course_code])) { Event::accessCourse(); $coursesAlreadyVisited[$course_code] = 1; Session::write('coursesAlreadyVisited', $coursesAlreadyVisited); } /*Auto launch code */ $show_autolaunch_lp_warning = false; $auto_launch = api_get_course_setting('enable_lp_auto_launch'); if (!empty($auto_launch)) { $session_id = api_get_session_id(); if ($auto_launch == 2) { //LP list if (api_is_platform_admin() || api_is_allowed_to_edit()) { $show_autolaunch_lp_warning = true; } else { $session_key = 'lp_autolaunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id(); if (!isset($_SESSION[$session_key])) { //redirecting to the LP $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&id_session=' . $session_id; $_SESSION[$session_key] = true; header("Location: {$url}"); exit; }
function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) { if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { return null; } // Email configuration settings $courseCode = api_get_course_id(); $course_info = api_get_course_info($courseCode); $url_email = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_show.php?' . api_get_cidreq() . '&id_session=' . api_get_session_id() . '&id=' . $exe_id . '&action=qualify'; $user_info = api_get_user_info(api_get_user_id()); $oral_question_list = null; foreach ($question_list_answers as $item) { $question = $item['question']; $answer = $item['answer']; $answer_type = $item['answer_type']; if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) { $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3">' . '<tr>' . '<td width="220" valign="top" bgcolor="#E5EDF8"> ' . get_lang('Question') . '</td>' . '<td width="473" valign="top" bgcolor="#F3F3F3">' . $question . '</td>' . '</tr>' . '<tr>' . '<td width="220" valign="top" bgcolor="#E5EDF8"> ' . get_lang('Answer') . '</td>' . '<td valign="top" bgcolor="#F3F3F3">' . $answer . '</td>' . '</tr></table>'; } } if (!empty($oral_question_list)) { $msg = get_lang('OralQuestionsAttempted') . '<br /><br /> ' . get_lang('AttemptDetails') . ' : <br /><br />' . '<table>' . '<tr>' . '<td><em>' . get_lang('CourseName') . '</em></td>' . '<td> <b>#course#</b></td>' . '</tr>' . '<tr>' . '<td>' . get_lang('TestAttempted') . '</td>' . '<td> #exercise#</td>' . '</tr>' . '<tr>' . '<td>' . get_lang('StudentName') . '</td>' . '<td> #firstName# #lastName#</td>' . '</tr>' . '<tr>' . '<td>' . get_lang('StudentEmail') . '</td>' . '<td> #mail#</td>' . '</tr>' . '</table>'; $msg .= '<br />' . sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list) . '<br />'; $msg1 = str_replace("#exercise#", $this->exercise, $msg); $msg = str_replace("#firstName#", $user_info['firstname'], $msg1); $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg); $msg = str_replace("#mail#", $user_info['email'], $msg1); $msg = str_replace("#course#", $course_info['name'], $msg1); if ($origin != 'learnpath') { $msg .= '<br /><a href="#url#">' . get_lang('ClickToCommentAndGiveFeedback') . '</a>'; } $msg1 = str_replace("#url#", $url_email, $msg); $mail_content = $msg1; $subject = get_lang('OralQuestionsAttempted'); if (api_get_session_id()) { $teachers = CourseManager::get_coach_list_from_course_code($courseCode, api_get_session_id()); } else { $teachers = CourseManager::getTeacherListFromCourse($course_info['real_id']); } if (!empty($teachers)) { foreach ($teachers as $user_id => $teacher_data) { MessageManager::send_message_simple($user_id, $subject, $mail_content); } } } }
/** * See this file in you BBB to set up default values * @param array $params Array of parameters that will be completed if not containing all expected variables /var/lib/tomcat6/webapps/bigbluebutton/WEB-INF/classes/bigbluebutton.properties * More record information: http://code.google.com/p/bigbluebutton/wiki/RecordPlaybackSpecification # Default maximum number of users a meeting can have. # Doesn't get enforced yet but is the default value when the create # API doesn't pass a value. defaultMaxUsers=20 # Default duration of the meeting in minutes. # Current default is 0 (meeting doesn't end). defaultMeetingDuration=0 # Remove the meeting from memory when the end API is called. # This allows 3rd-party apps to recycle the meeting right-away # instead of waiting for the meeting to expire (see below). removeMeetingWhenEnded=false # The number of minutes before the system removes the meeting from memory. defaultMeetingExpireDuration=1 # The number of minutes the system waits when a meeting is created and when # a user joins. If after this period, a user hasn't joined, the meeting is # removed from memory. defaultMeetingCreateJoinDuration=5 * */ public function createMeeting($params) { $params['c_id'] = api_get_course_int_id(); $courseCode = api_get_course_id(); $params['session_id'] = api_get_session_id(); $params['attendee_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : api_get_course_id(); $attendeePassword = $params['attendee_pw']; $params['moderator_pw'] = isset($params['moderator_pw']) ? $params['moderator_pw'] : $this->getModMeetingPassword(); $moderatorPassword = $params['moderator_pw']; $params['record'] = api_get_course_setting('big_blue_button_record_and_store', $courseCode) == 1 ? true : false; $max = api_get_course_setting('big_blue_button_max_students_allowed', $courseCode); $max = isset($max) ? $max : -1; $params['status'] = 1; // Generate a pseudo-global-unique-id to avoid clash of conferences on // the same BBB server with several Chamilo portals $params['remote_id'] = uniqid(true, true); if ($this->debug) { error_log("enter create_meeting ".print_r($params, 1)); } $params['created_at'] = api_get_utc_datetime(); $id = Database::insert($this->table, $params); if ($id) { if ($this->debug) { error_log("create_meeting: $id "); } $meetingName = isset($params['meeting_name']) ? $params['meeting_name'] : api_get_course_id().'-'.api_get_session_id(); $welcomeMessage = isset($params['welcome_msg']) ? $params['welcome_msg'] : null; $record = isset($params['record']) && $params['record'] ? 'true' : 'false'; $duration = isset($params['duration']) ? intval($params['duration']) : 0; // This setting currently limits the maximum conference duration, // to avoid lingering sessions on the video-conference server #6261 $duration = 300; $bbbParams = array( 'meetingId' => $params['remote_id'], // REQUIRED 'meetingName' => $meetingName, // REQUIRED 'attendeePw' => $attendeePassword, // Match this value in getJoinMeetingURL() to join as attendee. 'moderatorPw' => $moderatorPassword, // Match this value in getJoinMeetingURL() to join as moderator. 'welcomeMsg' => $welcomeMessage, // ''= use default. Change to customize. 'dialNumber' => '', // The main number to call into. Optional. 'voiceBridge' => '12345', // PIN to join voice. Required. 'webVoice' => '', // Alphanumeric to join voice. Optional. 'logoutUrl' => $this->logout_url, 'maxParticipants' => $max, // Optional. -1 = unlimitted. Not supported in BBB. [number] 'record' => $record, // New. 'true' will tell BBB to record the meeting. 'duration' => $duration, // Default = 0 which means no set duration in minutes. [number] //'meta_category' => '', // Use to pass additional info to BBB server. See API docs. ); if ($this->debug) { error_log("create_meeting params: ".print_r($bbbParams,1)); } $status = false; $meeting = null; while ($status == false) { $result = $this->api->createMeetingWithXmlResponseArray( $bbbParams ); if (isset($result) && strval($result['returncode']) == 'SUCCESS' ) { if ($this->debug) { error_log( "create_meeting result: " . print_r($result, 1) ); } $meeting = $this->joinMeeting($meetingName, true); return $meeting; } } return $this->logout; } }
$token = Security::get_token(); } $courseInfo = api_get_course_info(); $currentUrl = api_get_path(WEB_CODE_PATH) . 'work/work.php?' . api_get_cidreq(); $content = null; // For teachers switch ($action) { case 'settings': //if posts if ($is_allowed_to_edit && !empty($_POST['changeProperties'])) { updateSettings($course, $_POST['show_score'], $_POST['student_delete_own_publication']); Session::write('message', Display::return_message(get_lang('Saved'), 'success')); header('Location: ' . $currentUrl); exit; } $studentDeleteOwnPublication = api_get_course_setting('student_delete_own_publication') == 1 ? 1 : 0; /* Display of tool options */ $content = settingsForm(array('show_score' => $course_info['show_score'], 'student_delete_own_publication' => $studentDeleteOwnPublication)); break; case 'add': case 'create_dir': if (!$is_allowed_to_edit) { api_not_allowed(); } $form = new FormValidator('form1', 'post', api_get_path(WEB_CODE_PATH) . 'work/work.php?action=create_dir&' . api_get_cidreq()); $form->addElement('header', get_lang('CreateAssignment')); $form->addElement('hidden', 'action', 'add'); $defaults = isset($_POST) ? $_POST : array(); $form = getFormWork($form, $defaults); $form->addButtonCreate(get_lang('CreateDirectory')); if ($form->validate()) {
} else { $origin = $_SESSION['origin']; $target = $_SESSION['target']; $_SESSION['origin'] = Security::remove_XSS($_GET["origin"]); $_SESSION['target'] = Security::remove_XSS($_GET["target"]); } /* TRACKING */ event_access_tool(TOOL_CHAT); header('Content-Type: text/html; charset=' . api_get_system_encoding()); /* * Choose CSS style (platform's, user's, or course's) */ $my_style = api_get_visual_theme(); $mycourseid = api_get_course_id(); if (!empty($mycourseid) && $mycourseid != -1) { $open_chat_window = api_get_course_setting('allow_open_chat_window'); } $cidreq = Security::remove_XSS($_GET['cidReq']); $toolgroup = Security::remove_XSS($_GET['toolgroup']); //fix when change by vertical or horizontal menu from a chat group to chat course. if (empty($toolgroup) && empty($open_chat_window)) { unset($_SESSION['_gid']); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo api_get_language_isocode(); ?> " lang="<?php
/** * @return array */ private function autolaunch() { $showAutoLaunchExerciseWarning = false; // Exercise auto-launch $auto_launch = api_get_course_setting('enable_exercise_auto_launch'); if (!empty($auto_launch)) { $session_id = api_get_session_id(); //Exercise list if ($auto_launch == 2) { if (api_is_platform_admin() || api_is_allowed_to_edit()) { $showAutoLaunchExerciseWarning = true; } else { $session_key = 'exercise_autolunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id(); if (!isset($_SESSION[$session_key])) { //redirecting to the Exercise $url = api_get_path(WEB_CODE_PATH) . 'exercice/exercice.php?' . api_get_cidreq() . '&id_session=' . $session_id; $_SESSION[$session_key] = true; header("Location: {$url}"); exit; } } } else { $table = \Database::get_course_table(TABLE_QUIZ_TEST); $course_id = api_get_course_int_id(); $condition = ''; if (!empty($session_id)) { $condition = api_get_session_condition($session_id); $sql = "SELECT iid FROM {$table} WHERE c_id = {$course_id} AND autolaunch = 1 {$condition} LIMIT 1"; $result = \Database::query($sql); //If we found nothing in the session we just called the session_id = 0 autolaunch if (\Database::num_rows($result) == 0) { $condition = ''; } else { //great, there is an specific auto lunch for this session we leave the $condition } } $sql = "SELECT iid FROM {$table} WHERE c_id = {$course_id} AND autolaunch = 1 {$condition} LIMIT 1"; $result = \Database::query($sql); if (\Database::num_rows($result) > 0) { $data = \Database::fetch_array($result, 'ASSOC'); if (!empty($data['iid'])) { if (api_is_platform_admin() || api_is_allowed_to_edit()) { $showAutoLaunchExerciseWarning = true; } else { $session_key = 'exercise_autolunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id(); if (!isset($_SESSION[$session_key])) { //redirecting to the LP $url = api_get_path(WEB_CODE_PATH) . 'exercice/overview.php?' . api_get_cidreq() . '&exerciseId=' . $data['iid']; $_SESSION[$session_key] = true; header("Location: {$url}"); exit; } } } } } } /* Auto launch code */ $showAutoLaunchLpWarning = false; $auto_launch = api_get_course_setting('enable_lp_auto_launch'); if (!empty($auto_launch)) { $session_id = api_get_session_id(); //LP list if ($auto_launch == 2) { if (api_is_platform_admin() || api_is_allowed_to_edit()) { $showAutoLaunchLpWarning = true; } else { $session_key = 'lp_autolunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id(); if (!isset($_SESSION[$session_key])) { //redirecting to the LP $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&id_session=' . $session_id; $_SESSION[$session_key] = true; header("Location: {$url}"); exit; } } } else { $lp_table = \Database::get_course_table(TABLE_LP_MAIN); $course_id = api_get_course_int_id(); $condition = ''; if (!empty($session_id)) { $condition = api_get_session_condition($session_id); $sql = "SELECT id FROM {$lp_table} WHERE c_id = {$course_id} AND autolunch = 1 {$condition} LIMIT 1"; $result = \Database::query($sql); //If we found nothing in the session we just called the session_id = 0 autolunch if (\Database::num_rows($result) == 0) { $condition = ''; } else { //great, there is an specific auto lunch for this session we leave the $condition } } $sql = "SELECT id FROM {$lp_table} WHERE c_id = {$course_id} AND autolunch = 1 {$condition} LIMIT 1"; $result = \Database::query($sql); if (\Database::num_rows($result) > 0) { $lp_data = \Database::fetch_array($result, 'ASSOC'); if (!empty($lp_data['id'])) { if (api_is_platform_admin() || api_is_allowed_to_edit()) { $showAutoLaunchLpWarning = true; } else { $session_key = 'lp_autolunch_' . $session_id . '_' . api_get_course_int_id() . '_' . api_get_user_id(); if (!isset($_SESSION[$session_key])) { //redirecting to the LP $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $lp_data['id']; $_SESSION[$session_key] = true; header("Location: {$url}"); exit; } } } } } } return array('show_autolaunch_exercise_warning' => $showAutoLaunchExerciseWarning, 'show_autolaunch_lp_warning' => $showAutoLaunchLpWarning); }
/** * Pre-formats a PDF to the right size and, if not stated otherwise, with * header, footer and watermark (if any) * @param array $course_data General course information (to fill headers) * @param bool $complete Whether we want headers, footers and watermark or not */ public function format_pdf($course_data, $complete = true) { if ($complete === false) { error_log('Asked with no decoration'); } $course_code = null; if (!empty($course_data)) { $course_code = $course_data['code']; } /*$pdf->SetAuthor('Documents Chamilo'); $pdf->SetTitle('title'); $pdf->SetSubject('Exported from Chamilo Documents'); $pdf->SetKeywords('Chamilo Documents'); */ // TODO: To be read from the html document. $this->pdf->directionality = api_get_text_direction(); $this->pdf->useOnlyCoreFonts = true; // Use different Odd/Even headers and footers and mirror margins $this->pdf->mirrorMargins = 1; // Add decoration only if not stated otherwise if ($complete) { // Adding watermark if (api_get_setting('pdf_export_watermark_enable') == 'true') { $watermark_file = self::get_watermark($course_code); if ($watermark_file) { //http://mpdf1.com/manual/index.php?tid=269&searchstring=watermark $this->pdf->SetWatermarkImage($watermark_file); $this->pdf->showWatermarkImage = true; } else { $watermark_file = self::get_watermark(null); if ($watermark_file) { $this->pdf->SetWatermarkImage($watermark_file); $this->pdf->showWatermarkImage = true; } } if ($course_code) { $watermark_text = api_get_course_setting('pdf_export_watermark_text'); if (empty($watermark_text)) { $watermark_text = api_get_setting('pdf_export_watermark_text'); } } else { $watermark_text = api_get_setting('pdf_export_watermark_text'); } if (!empty($watermark_text)) { $this->pdf->SetWatermarkText(strcode2utf($watermark_text),0.1); $this->pdf->showWatermarkText = true; } } if (empty($this->custom_header)) { self::set_header($course_data); } else { $this->pdf->SetHTMLHeader($this->custom_header,'E'); $this->pdf->SetHTMLHeader($this->custom_header,'O'); } if (empty($this->custom_footer)) { self::set_footer(); } else { $this->pdf->SetHTMLFooter($this->custom_footer); } } }
* * - show users registered in courses; * * @author Roan Embrechts * @author Julio Montoya Armas, Several fixes * @package chamilo.user */ $use_anonymous = true; require_once '../inc/global.inc.php'; $current_course_tool = TOOL_USER; $this_section = SECTION_COURSES; // notice for unauthorized people. api_protect_course_script(true); if (!api_is_platform_admin(true)) { if (!api_is_course_admin() && !api_is_coach()) { if (api_get_course_setting('allow_user_view_user_list') == 0) { api_not_allowed(true); } } } /* Constants and variables */ $course_code = Database::escape_string(api_get_course_id()); $sessionId = api_get_session_id(); $is_western_name_order = api_is_western_name_order(); $sort_by_first_name = api_sort_by_first_name(); $course_info = api_get_course_info(); $user_id = api_get_user_id(); $courseCode = $course_info['code']; $courseId = $course_info['real_id']; //Can't auto unregister from a session if (!empty($sessionId)) {
} } /* 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); $thematic_advance_info = $thematic->get_thematic_advance_list($last_done_advance);
//setting the default year and month $select_year = ''; $select_month = ''; if (!empty($_GET['year'])) { $select_year = (int) $_GET['year']; } if (!empty($_GET['month'])) { $select_month = (int) $_GET['month']; } if (empty($select_year) && empty($select_month)) { $today = getdate(); $select_year = $today['year']; $select_month = $today['mon']; } echo '<div class="actions">'; if (api_is_allowed_to_edit(false, true) or api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) { display_student_links(); display_courseadmin_links(); } echo '</div><br /><br />'; echo '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>'; // THE LEFT PART if (empty($_GET['origin']) or $_GET['origin'] != 'learnpath') { echo '<td width="220" height="19" valign="top">'; // the small calendar $MonthName = $MonthsLong[$select_month - 1]; $agenda_items = get_calendar_items($select_month, $select_year); if (api_get_setting('display_mini_month_calendar') == 'true') { display_minimonthcalendar($agenda_items, $select_month, $select_year, $MonthName); } if (api_get_setting('display_upcoming_events') == 'true') {
/** * Display the exercise results * @param Exercise $objExercise * @param int $exe_id * @param bool $save_user_result save users results (true) or just show the results (false) */ public static function display_question_list_by_attempt($objExercise, $exe_id, $save_user_result = false) { global $origin; // Getting attempt info $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id); // Getting question list $question_list = array(); if (!empty($exercise_stat_info['data_tracking'])) { $question_list = explode(',', $exercise_stat_info['data_tracking']); } else { // Try getting the question list only if save result is off if ($save_user_result == false) { $question_list = $objExercise->get_validated_question_list(); } } $counter = 1; $total_score = $total_weight = 0; $exercise_content = null; // Hide results $show_results = false; $show_only_score = false; if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS) { $show_results = true; } if (in_array($objExercise->results_disabled, array(RESULT_DISABLE_SHOW_SCORE_ONLY, RESULT_DISABLE_SHOW_FINAL_SCORE_ONLY_WITH_CATEGORIES))) { $show_only_score = true; } // Not display expected answer, but score, and feedback $show_all_but_expected_answer = false; if ($objExercise->results_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY && $objExercise->feedback_type == EXERCISE_FEEDBACK_TYPE_END) { $show_all_but_expected_answer = true; $show_results = true; $show_only_score = false; } if ($show_results || $show_only_score) { $user_info = api_get_user_info($exercise_stat_info['exe_user_id']); //Shows exercise header echo $objExercise->show_exercise_result_header($user_info, api_convert_and_format_date($exercise_stat_info['start_date'], DATE_TIME_FORMAT_LONG), $exercise_stat_info['duration'], $exercise_stat_info['user_ip']); } // Display text when test is finished #4074 and for LP #4227 $end_of_message = $objExercise->selectTextWhenFinished(); if (!empty($end_of_message)) { Display::display_normal_message($end_of_message, false); echo "<div class='clear'> </div>"; } $question_list_answers = array(); $media_list = array(); $category_list = array(); // Loop over all question to show results for each of them, one by one if (!empty($question_list)) { foreach ($question_list as $questionId) { // creates a temporary Question object $objQuestionTmp = Question::read($questionId); // This variable came from exercise_submit_modal.php ob_start(); // We're inside *one* question. Go through each possible answer for this question $result = $objExercise->manage_answer($exercise_stat_info['exe_id'], $questionId, null, 'exercise_result', array(), $save_user_result, true, $show_results, $objExercise->selectPropagateNeg(), array()); if (empty($result)) { continue; } // In case of global score, make sure the calculated total score is integer /*if (!is_int($result['score'])) { $result['score'] = round($result['score']); }*/ $total_score += $result['score']; $total_weight += $result['weight']; $question_list_answers[] = array('question' => $result['open_question'], 'answer' => $result['open_answer'], 'answer_type' => $result['answer_type']); $my_total_score = $result['score']; $my_total_weight = $result['weight']; // Category report $category_was_added_for_this_test = false; if (isset($objQuestionTmp->category) && !empty($objQuestionTmp->category)) { if (!isset($category_list[$objQuestionTmp->category]['score'])) { $category_list[$objQuestionTmp->category]['score'] = 0; } if (!isset($category_list[$objQuestionTmp->category]['total'])) { $category_list[$objQuestionTmp->category]['total'] = 0; } $category_list[$objQuestionTmp->category]['score'] += $my_total_score; $category_list[$objQuestionTmp->category]['total'] += $my_total_weight; $category_was_added_for_this_test = true; } if (isset($objQuestionTmp->category_list) && !empty($objQuestionTmp->category_list)) { foreach ($objQuestionTmp->category_list as $category_id) { $category_list[$category_id]['score'] += $my_total_score; $category_list[$category_id]['total'] += $my_total_weight; $category_was_added_for_this_test = true; } } // No category for this question! if ($category_was_added_for_this_test == false) { if (!isset($category_list['none']['score'])) { $category_list['none']['score'] = 0; } if (!isset($category_list['none']['total'])) { $category_list['none']['total'] = 0; } $category_list['none']['score'] += $my_total_score; $category_list['none']['total'] += $my_total_weight; } if ($objExercise->selectPropagateNeg() == 0 && $my_total_score < 0) { $my_total_score = 0; } $comnt = null; if ($show_results) { $comnt = Event::get_comments($exe_id, $questionId); if (!empty($comnt)) { echo '<b>' . get_lang('Feedback') . '</b>'; echo '<div id="question_feedback">' . $comnt . '</div>'; } } if ($show_results) { $score = array('result' => get_lang('Score') . " : " . self::show_score($my_total_score, $my_total_weight, false, true), 'pass' => $my_total_score >= $my_total_weight ? true : false, 'score' => $my_total_score, 'weight' => $my_total_weight, 'comments' => $comnt); } else { $score = array(); } $contents = ob_get_clean(); $question_content = ''; if ($show_results) { $question_content = '<div class="question_row_answer">'; $show_media = false; /*if ($objQuestionTmp->parent_id != 0 && !in_array($objQuestionTmp->parent_id, $media_list)) { $show_media = true; $media_list[] = $objQuestionTmp->parent_id; }*/ //Shows question title an description $question_content .= $objQuestionTmp->return_header(null, $counter, $score); } $counter++; $question_content .= $contents; if ($show_results) { $question_content .= '</div>'; } $exercise_content .= $question_content; } // end foreach() block that loops over all questions } $total_score_text = null; if ($origin != 'learnpath') { if ($show_results || $show_only_score) { $total_score_text .= '<div class="question_row_score">'; $total_score_text .= self::get_question_ribbon($objExercise, $total_score, $total_weight, true); $total_score_text .= '</div>'; } } if (!empty($category_list) && ($show_results || $show_only_score)) { //Adding total $category_list['total'] = array('score' => $total_score, 'total' => $total_weight); echo TestCategory::get_stats_table_by_attempt($objExercise->id, $category_list); } if ($show_all_but_expected_answer) { $exercise_content .= "<div class='normal-message'>" . get_lang("ExerciseWithFeedbackWithoutCorrectionComment") . "</div>"; } // Remove audio auto play from questions on results page - refs BT#7939 $exercise_content = preg_replace(['/autoplay[\\=\\".+\\"]+/', '/autostart[\\=\\".+\\"]+/'], '', $exercise_content); echo $total_score_text; echo $exercise_content; if (!$show_only_score) { echo $total_score_text; } if ($save_user_result) { // Tracking of results $learnpath_id = $exercise_stat_info['orig_lp_id']; $learnpath_item_id = $exercise_stat_info['orig_lp_item_id']; $learnpath_item_view_id = $exercise_stat_info['orig_lp_item_view_id']; if (api_is_allowed_to_session_edit()) { Event::update_event_exercice($exercise_stat_info['exe_id'], $objExercise->selectId(), $total_score, $total_weight, api_get_session_id(), $learnpath_id, $learnpath_item_id, $learnpath_item_view_id, $exercise_stat_info['exe_duration'], $question_list, '', array()); } // Send notification .. if (!api_is_allowed_to_edit(null, true) && !api_is_excluded_user_type()) { if (api_get_course_setting('email_alert_manager_on_new_quiz') == 1) { $objExercise->send_mail_notification_for_exam($question_list_answers, $origin, $exe_id); } $objExercise->send_notification_for_open_questions($question_list_answers, $origin, $exe_id); $objExercise->send_notification_for_oral_questions($question_list_answers, $origin, $exe_id); } } }
$form = new FormValidator('form1', 'post', 'lp_controller.php'); // Form title $form->addElement('header', get_lang('EditLPSettings')); // Title $form->addElement('text', 'lp_name', api_ucfirst(get_lang('LearnpathTitle')), array('class' => 'span5')); $form->applyFilter('lp_name', 'html_filter'); $form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('hidden', 'lp_encoding'); $referer = isset($_REQUEST['referer']) ? Security::remove_XSS($_REQUEST['referer']) : null; $form->addElement('hidden', 'referer', $referer); $items = learnpath::get_category_from_course_into_select(api_get_course_int_id(), true); $form->addElement('select', 'category_id', get_lang('Category'), $items); //Hide toc frame $hide_toc_frame = $form->addElement('checkbox', 'hide_toc_frame', null, get_lang('HideTocFrame'), array('onclick' => '$("#lp_layout_column").toggle()')); if (api_get_setting('allow_course_theme') == 'true') { $mycourselptheme = api_get_course_setting('allow_learning_path_theme'); if (!empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) { //LP theme picker $theme_select = $form->addElement('select_theme', 'lp_theme', get_lang('Theme')); $form->applyFilter('lp_theme', 'trim'); $s_theme = $_SESSION['oLP']->get_theme(); $theme_select->setSelected($s_theme); //default } } // Author $form->addElement('html_editor', 'lp_author', get_lang('Author'), array('size' => 80), array('ToolbarSet' => 'LearningPathAuthor', 'Width' => '100%', 'Height' => '150px')); $form->applyFilter('lp_author', 'html_filter'); // LP image $form->add_progress_bar(); if (strlen($_SESSION['oLP']->get_preview_image()) > 0) {
$id_list = explode('_', $eventId); $eventId = $id_list[1]; $event_type = $id_list[0]; } if (!api_is_allowed_to_edit(null, true) && $event_type == 'course') { api_not_allowed(true); } if ($event_type == 'course') { $agendaUrl = api_get_path(WEB_CODE_PATH) . 'calendar/agenda_js.php?' . api_get_cidreq() . '&type=course'; } else { $agendaUrl = api_get_path(WEB_CODE_PATH) . 'calendar/agenda_js.php?&type=' . $event_type; } $course_info = api_get_course_info(); $agenda->type = $event_type; $content = null; if (api_is_allowed_to_edit(false, true) || api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous() && api_is_allowed_to_session_edit(false, true) || GroupManager::user_has_access(api_get_user_id(), $group_id, GroupManager::GROUP_TOOL_CALENDAR) && GroupManager::is_tutor_of_group(api_get_user_id(), $group_id)) { switch ($action) { case 'add': $actionName = get_lang('Add'); $form = $agenda->getForm(array('action' => 'add')); if ($form->validate()) { $values = $form->getSubmitValues(); $sendEmail = isset($values['add_announcement']) ? true : false; $allDay = isset($values['all_day']) ? 'true' : 'false'; $sendAttachment = isset($_FILES['user_upload']) ? true : false; $attachment = $sendAttachment ? $_FILES['user_upload'] : null; $attachmentComment = isset($values['file_comment']) ? $values['file_comment'] : null; $comment = isset($values['comment']) ? $values['comment'] : null; $startDate = $values['date_range_start']; $endDate = $values['date_range_end']; $eventId = $agenda->addEvent($startDate, $endDate, $allDay, $values['title'], $values['content'], $values['users_to_send'], $sendEmail, null, $attachment, $attachmentComment, $comment);