function unset_session_resources() { $_SESSION['addedresource'] = ''; $_SESSION['addedresourceid'] = ''; Session::erase(addedresource); Session::erase(addedresourceid); }
/** * @param Application $app * @param string $type courses|sessions|mycoursecategories * @param string $filter for the userportal courses page. Only works when setting 'history' * @param int $page * * @return Response|void */ public function indexAction(Application $app, $type = 'courses', $filter = 'current', $page = 1) { // @todo Use filters like "after/before|finish" to manage user access api_block_anonymous_users(); // Abort request because the user is not allowed here - @todo use filters if ($app['allowed'] == false) { return $app->abort(403, 'Not allowed'); } // Main courses and session list $items = null; $type = str_replace('/', '', $type); /** @var \PageController $pageController */ $pageController = $app['page_controller']; switch ($type) { case 'sessions': $items = $pageController->returnSessions(api_get_user_id(), $filter, $page); break; case 'sessioncategories': $items = $pageController->returnSessionsCategories(api_get_user_id(), $filter, $page); break; case 'courses': $items = $pageController->returnCourses(api_get_user_id(), $filter, $page); break; case 'mycoursecategories': $items = $pageController->returnMyCourseCategories(api_get_user_id(), $filter, $page); break; case 'specialcourses': $items = $pageController->returnSpecialCourses(api_get_user_id(), $filter, $page); break; } //Show the chamilo mascot if (empty($items) && empty($filter)) { $pageController->return_welcome_to_course_block($app['template']); } /* $app['my_main_menu'] = function($app) { $menu = $app['knp_menu.factory']->createItem('root'); $menu->addChild('Home', array('route' => api_get_path(WEB_CODE_PATH))); return $menu; }; $app['knp_menu.menus'] = array('main' => 'my_main_menu');*/ $app['template']->assign('content', $items); $pageController->setCourseSessionMenu(); $pageController->setProfileBlock(); $pageController->setUserImageBlock(); $pageController->setCourseBlock($filter); $pageController->setSessionBlock(); $pageController->return_reservation_block(); $pageController->returnNavigationLinks($app['template']->getNavigationLinks()); $app['template']->assign('search_block', $pageController->return_search_block()); $app['template']->assign('classes_block', $pageController->return_classes_block()); $pageController->returnSkillsLinks(); // Deleting the session_id. Session::erase('session_id'); $response = $app['template']->render_template('userportal/index.tpl'); return new Response($response, 200, array()); }
/** * * @global int $_cid * @global array $_course * @global int $_gid * * @param int $group_id * @param bool $reset */ static function init_group($group_id, $reset) { global $_cid; global $_course; global $_gid; if ($reset) { // session data refresh requested if ($group_id && $_cid && !empty($_course['real_id'])) { // have keys to search data $group_table = Database::get_course_table(TABLE_GROUP); $sql = "SELECT * FROM {$group_table} WHERE c_id = " . $_course['real_id'] . " AND id = '{$group_id}'"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { // This group has recorded status related to this course $gpData = Database::fetch_array($result); $_gid = $gpData['id']; Session::write('_gid', $_gid); } else { Session::erase('_gid'); } } elseif (isset($_SESSION['_gid']) or isset($_gid)) { // Keys missing => not anymore in the group - course relation Session::erase('_gid'); } } elseif (isset($_SESSION['_gid'])) { // continue with the previous values $_gid = $_SESSION['_gid']; } else { //if no previous value, assign caracteristic undefined value $_gid = -1; } //set variable according to student_view_enabled choices if (api_get_setting('course.student_view_enabled') == "true") { if (isset($_GET['isStudentView'])) { if ($_GET['isStudentView'] == 'true') { if (isset($_SESSION['studentview'])) { if (!empty($_SESSION['studentview'])) { // switching to studentview $_SESSION['studentview'] = 'studentview'; } } } elseif ($_GET['isStudentView'] == 'false') { if (isset($_SESSION['studentview'])) { if (!empty($_SESSION['studentview'])) { // switching to teacherview $_SESSION['studentview'] = 'teacherview'; } } } } elseif (!empty($_SESSION['studentview'])) { //all is fine, no change to that, obviously } elseif (empty($_SESSION['studentview'])) { // We are in teacherview here $_SESSION['studentview'] = 'teacherview'; } } }
$template = new Template(get_lang('GradebookListOfStudentsCertificates')); if (Session::has('reportErrorMessage')) { $template->assign('errorMessage', Session::read('reportErrorMessage')); } $searchBySessionCourseDateForm = new FormValidator('certificate_report_form', 'post', api_get_path(WEB_CODE_PATH) . 'gradebook/certificate_report.php'); $searchBySessionCourseDateForm->addSelect('session', get_lang('Sessions'), $sessions, ['id' => 'session']); $searchBySessionCourseDateForm->addSelect('course', get_lang('Courses'), $courses, ['id' => 'course']); $searchBySessionCourseDateForm->addGroup([$searchBySessionCourseDateForm->createElement('select', 'month', null, $months, ['id' => 'month']), $searchBySessionCourseDateForm->createElement('text', 'year', null, ['id' => 'year', 'placeholder' => get_lang('Year')])], null, get_lang('Date')); $searchBySessionCourseDateForm->addButtonSearch(); $searchBySessionCourseDateForm->setDefaults(['session' => $selectedSession, 'course' => $selectedCourse, 'month' => $selectedMonth, 'year' => $selectedYear]); if (api_is_student_boss()) { foreach ($userList as $studentId) { $students[$studentId] = api_get_user_info($studentId)['complete_name_with_username']; } $searchByStudentForm = new FormValidator('certificate_report_form', 'post', api_get_path(WEB_CODE_PATH) . 'gradebook/certificate_report.php'); $searchByStudentForm->addSelect('student', get_lang('Students'), $students, ['id' => 'student']); $searchByStudentForm->addButtonSearch(); $searchByStudentForm->setDefaults(['student' => $selectedStudent]); $template->assign('searchByStudentForm', $searchByStudentForm->returnForm()); } $template->assign('searchBySessionCourseDateForm', $searchBySessionCourseDateForm->returnForm()); $template->assign('sessions', $sessions); $template->assign('courses', $courses); $template->assign('months', $months); $template->assign('exportAllLink', $exportAllLink); $template->assign('certificateStudents', $certificateStudents); $content = $template->fetch("default/gradebook/certificate_report.tpl"); $template->assign('content', $content); $template->display_one_col_template(); Session::erase('reportErrorMessage');
} } $form_data = CourseManager::redirectToCourse($form_data); $form_register = new FormValidator('form_register', 'post', $form_data['action']); if (!empty($form_data['message'])) { $form_register->addElement('html', $form_data['message'] . '<br /><br />'); } if ($usersCanCreateCourse) { $form_register->addElement('html', $form_data['button']); } else { $form_register->addElement('html', $form_data['go_button']); } $text_after_registration .= $form_register->returnForm(); // Just in case Session::erase('course_redirect'); Session::erase('exercise_redirect'); if (CustomPages::enabled()) { CustomPages::display(CustomPages::REGISTRATION_FEEDBACK, array('info' => $text_after_registration)); } else { //$tpl = new Template($tool_name); echo Container::getTemplating()->render('@template_style/auth/inscription.html.twig', ['inscription_content' => $content, 'text_after_registration' => $text_after_registration, 'hide_header' => $hideHeaders]); } } else { // Custom pages if (CustomPages::enabled()) { CustomPages::display(CustomPages::REGISTRATION, array('form' => $form)); } else { if (!api_is_anonymous()) { // Saving user to course if it was set. if (!empty($course_code_redirect)) { $course_info = api_get_course_info($course_code_redirect);
* * @package chamilo.exercise * @author Julio Montoya <*****@*****.**> */ /** * Code */ use ChamiloSession as Session; $language_file = 'exercice'; require_once 'exercise.class.php'; //require_once '../inc/global.inc.php'; $current_course_tool = TOOL_QUIZ; // Clear the exercise session just in case $objExercise = Session::read('objExercise'); if (isset($objExercise)) { Session::erase('objExercise'); } $this_section = SECTION_COURSES; // Notice for unauthorized people. api_protect_course_script(true); $exercise_id = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : 0; $objExercise = new Exercise(); $result = $objExercise->read($exercise_id); if (!$result) { api_not_allowed(true); } $gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : null; $learnpath_id = isset($_REQUEST['learnpath_id']) ? intval($_REQUEST['learnpath_id']) : null; $learnpath_item_id = isset($_REQUEST['learnpath_item_id']) ? intval($_REQUEST['learnpath_item_id']) : null; $origin = isset($_REQUEST['origin']) ? Security::remove_XSS($_REQUEST['origin']) : null; $interbreadcrumb[] = array("url" => "exercice.php?gradebook={$gradebook}", "name" => get_lang('Exercices'));
$this_section = SECTION_COURSES; $current_course_tool = TOOL_COURSE_MAINTENANCE; api_protect_course_script(true); $_course = api_get_course_info(); $current_course_code = $_course['official_code']; $current_course_name = $_course['name']; if (!api_is_allowed_to_edit()) { api_not_allowed(true); } $tool_name = get_lang('DelCourse'); if (isset($_GET['delete']) && $_GET['delete'] == 'yes') { CourseManager::delete_course($_course['sysCode']); $obj_cat = new Category(); $obj_cat->update_category_delete($_course['sysCode']); // DELETE CONFIRMATION MESSAGE Session::erase('_cid'); Session::erase('_real_cid'); $noPHP_SELF = true; $message = '<h2>' . get_lang('Course') . ' : ' . $current_course_name . ' (' . $current_course_code . ') </h2>'; $message .= get_lang('HasDel'); $message .= '<br /><br /><a href="../../index.php">' . get_lang('BackHome') . ' ' . api_get_setting('platform.site_name') . '</a>'; } else { $message = '<h3>' . get_lang('Course') . ' : ' . $current_course_name . ' (' . $current_course_code . ') </h3>'; $message .= '<p>' . get_lang('ByDel') . '</p>'; $message .= '<p><a class="btn btn-primary" href="' . api_get_path(WEB_CODE_PATH) . 'course_info/maintenance.php?' . api_get_cidreq() . '">' . get_lang('No') . '</a> <a class="btn" href="' . api_get_self() . '?delete=yes&' . api_get_cidreq() . '">' . get_lang('Yes') . '</a></p>'; $interbreadcrumb[] = array('url' => 'maintenance.php', 'name' => get_lang('Maintenance')); } Display::display_header($tool_name, 'Settings'); echo Display::page_header($tool_name); Display::display_warning_message($message, false); Display::display_footer();
//Impress js if ($learnPath->mode == 'impress') { $lp_id = $learnPath->get_id(); $url = api_get_path(WEB_CODE_PATH) . "newscorm/lp_impress.php?lp_id={$lp_id}&" . api_get_cidreq(); header("Location: {$url}"); exit; } // Prepare variables for the test tool (just in case) - honestly, this should disappear later on. Session::write('scorm_view_id', $learnPath->get_view_id()); Session::write('scorm_item_id', $lp_item_id); $exerciseFromSession = Session::read('exerciseResult'); // Reinit exercises variables to avoid spacename clashes (see exercise tool) if (isset($exerciseResult) || isset($exerciseFromSession)) { Session::erase('exerciseResult'); Session::erase('objExercise'); Session::erase('questionList'); } // additional APIs $htmlHeadXtra[] = '<script> chamilo_courseCode = "' . $course_code . '"; </script>'; // Document API //$htmlHeadXtra[] = '<script src="js/documentapi.js" type="text/javascript" language="javascript"></script>'; // Storage API $htmlHeadXtra[] = '<script> var sv_user = \'' . api_get_user_id() . '\'; var sv_course = chamilo_courseCode; var sv_sco = \'' . intval($_REQUEST['lp_id']) . '\'; </script>'; // FIXME fetch sco and userid from a more reliable source directly in sotrageapi.js //$htmlHeadXtra[] = '<script type="text/javascript" src="js/storageapi.js"></script>';
$content = '<p><div><strong>' . get_lang('Description') . ':</strong><p>' . Security::remove_XSS($my_folder_data['description'], STUDENT) . '</p></div></p>'; } if (api_is_allowed_to_edit() || api_is_coach()) { // Work list $content .= '<div class="toolbar-works"><a id="open-view-list" class="btn btn-primary" href="#"><i class="fa fa-users"></i> Ver Estudiantes</a></div>'; $content .= '<div class="row">'; $content .= '<div class="col-md-12">'; $content .= '<div id="work-list" class="table-responsive">'; $content .= showTeacherWorkGrid(); $content .= '</div>'; $content .= '</div>'; $content .= '<div id="student-list-work" style="display: none" class="table-responsive">'; $content .= '<div class="toolbar"><a id="closed-view-list" href="#"><i class="fa fa-times-circle"></i> ' . get_lang('Close') . '</a></div>'; $content .= showStudentList($work_id); $content .= '</div>'; } else { $content .= showStudentWorkGrid(); } break; } Display::display_header(null); Display::display_introduction_section(TOOL_STUDENTPUBLICATION); if ($origin == 'learnpath') { echo '<div style="height:15px"> </div>'; } display_action_links($work_id, $curdirpath, $action); $message = Session::read('message'); echo $message; Session::erase('message'); echo $content; Display::display_footer();
/** * @param string $username */ function api_clean_account_captcha($username) { $userInfo = api_get_user_info_from_username($username); if (empty($userInfo)) { return false; } Session::erase('loginFailedCount'); UserManager::update_extra_field_value($userInfo['user_id'], 'captcha_blocked_until_date', null); }
/** * This function stores which users have to be notified of which forums or threads * * @param string $content does the user want to be notified about a forum or about a thread * @param integer $id the id of the forum or thread * @return string language variable * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version May 2008, dokeos 1.8.5 * @since May 2008, dokeos 1.8.5 */ function set_notification($content, $id, $add_only = false) { $_user = api_get_user_info(); // Database table definition $table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION); $course_id = api_get_course_int_id(); // Which database field do we have to store the id in? if ($content == 'forum') { $database_field = 'forum_id'; } else { $database_field = 'thread_id'; } // First we check if the notification is already set for this. $sql = "SELECT * FROM {$table_notification}\n WHERE\n c_id = {$course_id} AND\n {$database_field} = '" . Database::escape_string($id) . "' AND\n user_id = '" . intval($_user['user_id']) . "'"; $result = Database::query($sql); $total = Database::num_rows($result); // If the user did not indicate that (s)he wanted to be notified already // then we store the notification request (to prevent double notification requests). if ($total <= 0) { $sql = "INSERT INTO {$table_notification} (c_id, {$database_field}, user_id)\n VALUES (" . $course_id . ", '" . Database::escape_string($id) . "','" . intval($_user['user_id']) . "')"; Database::query($sql); Session::erase('forum_notification'); get_notifications_of_user(0, true); return get_lang('YouWillBeNotifiedOfNewPosts'); } else { if (!$add_only) { $sql = "DELETE FROM {$table_notification}\n WHERE\n c_id = {$course_id} AND\n {$database_field} = '" . Database::escape_string($id) . "' AND\n user_id = '" . intval($_user['user_id']) . "'"; Database::query($sql); Session::erase('forum_notification'); get_notifications_of_user(0, true); return get_lang('YouWillNoLongerBeNotifiedOfNewPosts'); } } }
/** * Destroys the message session */ public static function cleanFlashMessages() { Session::erase('flash_messages'); }
} //check for flash and message $sniff_notification = ''; $some_activex = isset($_SESSION['sniff_check_some_activex']) ? $_SESSION['sniff_check_some_activex'] : null; $some_plugins = isset($_SESSION['sniff_check_some_plugins']) ? $_SESSION['sniff_check_some_plugins'] : null; if(!empty($some_activex) || !empty($some_plugins)){ if (! preg_match("/flash_yes/", $some_activex) && ! preg_match("/flash_yes/", $some_plugins)) { $sniff_notification = Display::return_message(get_lang('NoFlash'), 'warning', true); //js verification - To annoying of redirecting every time the page $controller->tpl->assign('sniff_notification', $sniff_notification); } } $controller->tpl->assign('profile_block', $controller->return_profile_block()); $controller->tpl->assign('user_image_block', $controller->return_user_image_block()); $controller->tpl->assign('course_block', $controller->return_course_block()); $controller->tpl->assign('navigation_course_links', $controller->return_navigation_links()); $controller->tpl->assign('reservation_block', $controller->return_reservation_block()); $controller->tpl->assign('search_block', $controller->return_search_block()); $controller->tpl->assign('classes_block', $controller->return_classes_block()); //if (api_is_platform_admin() || api_is_drh()) { $controller->tpl->assign('skills_block', $controller->return_skills_links()); //} $controller->tpl->display_two_col_template(); // Deleting the session_id. Session::erase('session_id');
/** * This function exports the given Chamilo test * @param integer Test ID * @return string The test itself as an HTML string */ function export_exercise($item_id) { global $expdir, $_course, $_configuration, $_SESSION, $_SERVER, $language_interface, $langExerciseNotFound, $langQuestion, $langOk, $origin, $questionNum; $exerciseId = $item_id; require_once '../exercice/exercise.class.php'; require_once '../exercice/question.class.php'; require_once '../exercice/answer.class.php'; $TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST); /* Clears the exercise session */ if (isset($_SESSION['objExercise'])) { Session::erase('objExercise'); } if (isset($_SESSION['objQuestion'])) { Session::erase('objQuestion'); } if (isset($_SESSION['objAnswer'])) { Session::erase('objAnswer'); } if (isset($_SESSION['questionList'])) { Session::erase('questionList'); } if (isset($_SESSION['exerciseResult'])) { Session::erase('exerciseResult'); } // If the object is not in the session: if (!isset($_SESSION['objExercise'])) { // Construction of Exercise. $objExercise = new Exercise(); $sql = "SELECT title,description,sound,type,random,active FROM {$TBL_EXERCISES} WHERE iid='{$exerciseId}'"; // If the specified exercise doesn't exist or is disabled: if (!$objExercise->read($exerciseId) || !$objExercise->selectStatus() && !api_is_allowed_to_edit() && $origin != 'learnpath') { die($langExerciseNotFound); } // Saves the object into the session. Session::write('objExercise', $objExercise); } $exerciseTitle = $objExercise->selectTitle(); $exerciseDescription = $objExercise->selectDescription(); $exerciseSound = $objExercise->selectSound(); $randomQuestions = $objExercise->isRandom(); $exerciseType = $objExercise->selectType(); if (!isset($_SESSION['questionList'])) { // Selects the list of question ID. $questionList = $randomQuestions ? $objExercise->selectRandomList() : $objExercise->selectQuestionList(); // Saves the question list into the session. Session::write('questionList', $questionList); } $nbrQuestions = sizeof($questionList); // If questionNum comes from POST and not from GET: if (!$questionNum || $_POST['questionNum']) { // Only used for sequential exercises (see $exerciseType). if (!$questionNum) { $questionNum = 1; } else { $questionNum++; } } $test .= "<h3>" . $exerciseTitle . "</h3>"; if (!empty($exerciseSound)) { $test .= "<a href=\"../document/download.php?doc_url=%2Faudio%2F" . $exerciseSound . "\"&SQMSESSID=36812c2dea7d8d6e708d5e6a2f09b0b9 target=\"_blank\"><img src=\"../img/sound.gif\" border=\"0\" align=\"absmiddle\" alt=" . get_lang("Sound") . "\" /></a>"; } // Writing the .js file with to check the correct answers begin. $scriptfilename = "Exercice" . $item_id . ".js"; $s = "<script type=\"text/javascript\" src='../js/" . $scriptfilename . "'></script>"; $test .= $s; $content = "function evaluate() {\n alert('Test evaluated.');\n }\n "; if (!($handle = fopen($expdir . '/js/' . $scriptfilename, 'w'))) { echo "Cannot open file ({$scriptfilename})"; } if (fwrite($handle, $content) === false) { echo "Cannot write to file ({$filename})"; exit; } fclose($handle); // Writing the .js file with to check the correct answers end. $s = "\n <p>{$exerciseDescription}</p>\n <table width='100%' border='0' cellpadding='1' cellspacing='0'>\n <form method='post' action=''><input type=\"hidden\" name=\"SQMSESSID\" value=\"36812c2dea7d8d6e708d5e6a2f09b0b9\" />\n <input type='hidden' name='formSent' value='1' />\n <input type='hidden' name='exerciseType' value='" . $exerciseType . "' />\n <input type='hidden' name='questionNum' value='" . $questionNum . "' />\n <input type='hidden' name='nbrQuestions' value='" . $nbrQuestions . "' />\n <tr>\n <td>\n <table width='100%' cellpadding='4' cellspacing='2' border='0'>"; $exerciseType = 1; // So to list all questions in one page. $test .= $s; $i = 0; foreach ($questionList as $questionId) { $i++; // For sequential exercises. if ($exerciseType == 2) { // If it is not the right question, goes to the next loop iteration. if ($questionNum != $i) { continue; } else { // if the user has already answered this question: if (isset($exerciseResult[$questionId])) { // Construction of the Question object. $objQuestionTmp = new Question(); // Reads question informations. $objQuestionTmp->read($questionId); $questionName = $objQuestionTmp->selectTitle(); // Destruction of the Question object. unset($objQuestionTmp); $test .= '<tr><td>' . get_lang('AlreadyAnswered') . ' "' . $questionName . '"</td></tr>'; break; } } } echo $s = "<tr bgcolor='#e6e6e6'><td valign='top' colspan='2'>" . get_lang('Question') . " "; // Call the showQuestion(). This basically displays the question in a table. $question_obj = Question::read($questionId); $test .= $objExercise->showQuestion($question_obj, false, 'export', $i); } // end foreach() $s = "</table></td></tr><tr><td><br/><input type='button' value='" . $langOk . "' onclick=\"javascript: evaluate(); alert('Evaluated.');\">"; $s .= "</td></tr></form></table>"; $s .= "<script type='text/javascript'> loadPage(); </script>"; $b = 2; $test .= $s; return $test; }
$nbrActiveTests = $nbrActiveTests + 1; $item .= Display::tag('td', '<a href="showinframes.php?' . api_get_cidreq() . '&file=' . $path . '&cid=' . api_get_course_id() . '&uid=' . api_get_user_id() . '"' . (!$active ? 'class="invisible"' : '') . '">' . $title . '</a>'); //$item .= Display::tag('td', ''); $actions = '<a href="hotpotatoes_exercise_report.php?' . api_get_cidreq() . '&path=' . $path . '&filter_by_user='******'">' . Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_SMALL) . '</a>'; $item .= Display::tag('td', $actions); echo Display::tag('tr', $item, array('class' => $class)); } } $count++; } } echo '</table>'; if (empty($exercise_list) && $hotpotatoes_exist == false) { if ($is_allowedToEdit && $origin != 'learnpath') { echo '<div id="no-data-view">'; echo '<h2>' . get_lang('Quiz') . '</h2>'; echo Display::return_icon('quiz.png', '', array(), 64); echo '<div class="controls">'; echo Display::url(get_lang('NewEx'), 'exercise_admin.php?' . api_get_cidreq(), array('class' => 'btn')); echo '</div>'; echo '</div>'; } } if ($origin != 'learnpath') { //so we are not in learnpath tool Display::display_footer(); } Session::erase('objExercise'); Session::erase('objQuestion'); Session::erase('objAnswer');
/** * Create a new SortableTable * @param string $table_name A name for the table (default = 'table') * @param string $get_total_number_function A user defined function to get * the total number of items in the table * @param string $get_data_function A function to get the data to display on * the current page * @param int $default_column The default column on which the data should be * sorted * @param int $default_items_per_page The default number of items to show * on one page * @param string $default_order_direction The default order direction; * either the constant 'ASC' or 'DESC' * @param string $table_id */ public function __construct($table_name = 'table', $get_total_number_function = null, $get_data_function = null, $default_column = 1, $default_items_per_page = 20, $default_order_direction = 'ASC', $table_id = null) { if (empty($table_id)) { $table_id = $table_name . uniqid(); } $this->table_id = $table_id; parent::__construct(array('class' => 'data_table', 'id' => $table_id)); $this->table_name = $table_name; $this->additional_parameters = array(); $this->param_prefix = $table_name . '_'; $this->page_nr = Session::read($this->param_prefix . 'page_nr', 1); $this->page_nr = isset($_GET[$this->param_prefix . 'page_nr']) ? intval($_GET[$this->param_prefix . 'page_nr']) : $this->page_nr; $this->column = Session::read($this->param_prefix . 'column', $default_column); $this->column = isset($_GET[$this->param_prefix . 'column']) ? intval($_GET[$this->param_prefix . 'column']) : $this->column; // Default direction. if (in_array(strtoupper($default_order_direction), array('ASC', 'DESC'))) { $this->direction = $default_order_direction; } $directionFromSession = Session::read($this->param_prefix . 'direction'); if (isset($directionFromSession)) { $my_session_direction = $directionFromSession; if (!in_array($my_session_direction, array('ASC', 'DESC'))) { $this->direction = 'ASC'; } else { if ($my_session_direction == 'ASC') { $this->direction = 'ASC'; } elseif ($my_session_direction == 'DESC') { $this->direction = 'DESC'; } } } if (isset($_GET[$this->param_prefix . 'direction'])) { $my_get_direction = $_GET[$this->param_prefix . 'direction']; if (!in_array($my_get_direction, array('ASC', 'DESC'))) { $this->direction = 'ASC'; } else { if ($my_get_direction == 'ASC') { $this->direction = 'ASC'; } elseif ($my_get_direction == 'DESC') { $this->direction = 'DESC'; } } } // Allow to change paginate in multiples tabs Session::erase($this->param_prefix . 'per_page'); $this->per_page = Session::read($this->param_prefix . 'per_page', $default_items_per_page); $this->per_page = isset($_GET[$this->param_prefix . 'per_page']) ? intval($_GET[$this->param_prefix . 'per_page']) : $this->per_page; Session::write($this->param_prefix . 'per_page', $this->per_page); Session::write($this->param_prefix . 'direction', $this->direction); Session::write($this->param_prefix . 'page_nr', $this->page_nr); Session::write($this->param_prefix . 'column', $this->column); $this->pager = null; $this->default_items_per_page = $default_items_per_page; $this->total_number_of_items = -1; $this->get_total_number_function = $get_total_number_function; $this->get_data_function = $get_data_function; $this->column_filters = array(); $this->form_actions = array(); $this->checkbox_name = null; $this->td_attributes = array(); $this->th_attributes = array(); $this->other_tables = array(); }
echo '<div class="actions">'; echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq().'&origin='.$origin.'">'.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'</a>'; if (api_is_allowed_to_session_edit(false, true) && !empty($workId)) { echo '<a href="'.api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId.'&origin='.$origin.'">'; echo Display::return_icon('upload_file.png', get_lang('UploadADocument'), '', ICON_SIZE_MEDIUM).'</a>'; } echo '</div>'; if (!empty($my_folder_data['title'])) { echo Display::page_subheader($my_folder_data['title']); } $error_message = Session::read('error_message'); if (!empty($error_message)) { echo $error_message; Session::erase('error_message'); } if (!empty($my_folder_data['description'])) { echo '<p><div><strong>'.get_lang('Description').':</strong><p>'.Security::remove_XSS($my_folder_data['description']).'</p></div></p>'; } $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null; switch ($action) { case 'delete': $fileDeleted = deleteWorkItem($item_id, $courseInfo); if (!$fileDeleted) { Display::display_error_message(get_lang('YouAreNotAllowedToDeleteThisDocument'));
?> " > <?php echo get_lang('Finish'); ?> </button> <?php } } if ($origin != 'learnpath') { //we are not in learnpath tool Display::display_footer(); } else { if (!isset($_GET['fb_type'])) { $lp_mode = Session::read('lp_mode'); $url = '../newscorm/lp_controller.php?' . api_get_cidreq() . '&action=view&lp_id=' . $learnpath_id . '&lp_item_id=' . $learnpath_item_id . '&exeId=' . $exeId . '&fb_type=' . $feedback_type; $href = $lp_mode == 'fullscreen' ? ' window.opener.location.href="' . $url . '" ' : ' top.location.href="' . $url . '" '; echo '<script type="text/javascript">' . $href . '</script>'; // Record the results in the learning path, using the SCORM interface (API) echo "<script>window.parent.API.void_save_asset('{$totalScore}', '{$totalWeighting}', 0, 'completed'); </script>"; echo '</body></html>'; } else { Display::display_normal_message(get_lang('ExerciseFinished') . ' ' . get_lang('ToContinueUseMenu')); echo '<br />'; } } // Destroying the session Session::erase('questionList'); unset($questionList); Session::erase('exerciseResult'); unset($exerciseResult);
$files[$files_in_invisible_folder['path']] = $files_in_invisible_folder; } } // Compare the array with visible files and the array with files in invisible folders // and keep the difference (= all visible files that are not in an invisible folder) $files_for_zipfile = diff((array) $all_visible_files_path, (array) $files_in_invisible_folder_path); } else { // No invisible folders found, so all visible files can be added to the zipfile $files_for_zipfile = $all_visible_files_path; } Session::write('doc_files_to_download', $files); // Add all files in our final array to the zipfile for ($i = 0; $i < count($files_for_zipfile); $i++) { $zip->add($sysCoursePath . $courseInfo['path'] . '/document' . $files_for_zipfile[$i], PCLZIP_OPT_REMOVE_PATH, $sysCoursePath . $courseInfo['path'] . '/document' . $remove_dir, PCLZIP_CB_PRE_ADD, 'fixDocumentNameCallback'); } Session::erase('doc_files_to_download'); } // Launch event Event::event_download($path == '/' ? 'documents.zip (folder)' : basename($path) . '.zip (folder)'); // Start download of created file $name = $path == '/' ? 'documents.zip' : $documentInfo['title'] . '.zip'; if (Security::check_abs_path($tempZipFile, api_get_path(SYS_ARCHIVE_PATH))) { $result = DocumentManager::file_send_for_download($tempZipFile, true, $name); @unlink($tempZipFile); exit; } else { api_not_allowed(true); } /** * Returns the difference between two arrays, as an array of those key/values * Use this as array_diff doesn't give the
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); $sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks = 0, position = 0 WHERE exe_id = $exe_id "; Database::query($sql_fraud); }*/ // Unset session for clock time. ExerciseLib::exercise_time_control_delete($objExercise->id, $learnpath_id, $learnpath_item_id); ExerciseLib::delete_chat_exercise_session($exe_id); if ($origin != 'learnpath') { echo '<hr>'; echo $objExercise->returnEndButtonHTML(); if (api_is_allowed_to_session_edit()) { Session::erase('objExercise'); Session::erase('exe_id'); Session::erase('categoryList'); Session::erase('question_list_flatten'); } Display::display_footer(); } else { $lp_mode = $_SESSION['lp_mode']; $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?cidReq=' . api_get_course_id() . '&action=view&lp_id=' . $learnpath_id . '&lp_item_id=' . $learnpath_item_id . '&exeId=' . $exercise_stat_info['exe_id'] . '&fb_type=' . $objExercise->feedback_type; $href = $lp_mode == 'fullscreen' ? ' window.opener.location.href="' . $url . '" ' : ' top.location.href="' . $url . '"'; if (api_is_allowed_to_session_edit()) { Session::erase('objExercise'); Session::erase('exe_id'); Session::erase('categoryList'); } // Record the results in the learning path, using the SCORM interface (API) echo "<script>window.parent.API.void_save_asset('{$total_score}', '{$total_weight}', 0, 'completed');</script>"; echo '<script type="text/javascript">' . $href . '</script>'; echo '</body></html>'; }
/** * Erase temp nanogong audio. */ public static function removeGeneratedAudioTempFile() { $tempAudio = Session::read('temp_audio_nanogong'); if (isset($tempAudio) && !empty($tempAudio) && is_file($tempAudio)) { unlink($tempAudio); Session::erase('temp_audio_nanogong'); } }
/* LOGIN */ /** * Registers in the track_e_default table (view in important activities in admin * interface) a possible attempted break in, sending auth data through get. * @todo This piece of code should probably move to local.inc.php where the actual login / logout procedure is handled. The real use of this code block should be seriously considered as well. This form should just use a security token and get done with it. */ if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) { $i = api_get_anonymous_id(); Event::addEvent(LOG_ATTEMPTED_FORCED_LOGIN, 'tried_hacking_get', $_SERVER['REMOTE_ADDR'] . (empty($_POST['login']) ? '' : '/' . $_POST['login']), null, $i); echo 'Attempted breakin - sysadmins notified.'; session_destroy(); die; } // Delete session neccesary for legal terms if (api_get_setting('allow_terms_conditions') == 'true') { Session::erase('term_and_condition'); } //If we are not logged in and customapages activated if (!api_get_user_id() && CustomPages::enabled()) { if (Request::get('loggedout')) { CustomPages::display(CustomPages::LOGGED_OUT); } else { CustomPages::display(CustomPages::INDEX_UNLOGGED); } } /** * @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled. * @todo Check if this code is used. I think this code is never executed because after clicking the submit button * the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending * on api_get_setting('page_after_login'). */
stop: function() { stop = true; } }); }); </script> <?php //we filter the type of questions we can add Question::display_type_menu($objExercise); // Re sets the question list $objExercise->setQuestionList(); echo '<div style="clear:both;"></div>'; echo '<div id="message"></div>'; $token = Security::get_token(); //deletes a session when using don't know question type (ugly fix) Session::erase('less_answer'); // If we are in a test $inATest = isset($exerciseId) && $exerciseId > 0; if (!$inATest) { echo "<div class='alert alert-warning'>" . get_lang("ChoiceQuestionType") . "</div>"; } else { // Title line echo "<div class='table-responsive'>"; echo "<table class='table table-condensed'>"; echo "<tr>"; echo "<th style=\"width: 50%;\">" . get_lang('Questions') . "</th>"; echo "<th style=\"width: 6%;\">" . get_lang('Type') . "</th>"; echo "<th style=\"width: 22%; text-align:center;\">" . get_lang('Category') . "</th>"; echo "<th style=\"width: 6%;\">" . get_lang('Difficulty') . "</th>"; echo "<th style=\"width: 16%; float:left;\">" . get_lang('Score') . "</th>"; echo "</tr>";
$emailDest = api_get_setting('emailAdministrator'); $emailTitle = get_lang('SubscribeToSessionRequest'); $emailText = $objTemplate->fetch($mailTemplate); break; default: $emailDest = Security::remove_XSS($_REQUEST['dest']); $emailTitle = Security::remove_XSS($_REQUEST['email_title']); $emailText = Security::remove_XSS($_REQUEST['email_text']); } $defaults = array('dest' => $emailDest, 'email_address' => $emailDest, 'email_title' => $emailTitle, 'email_text' => $emailText); $form->setDefaults($defaults); if ($form->validate()) { $text = Security::remove_XSS($_POST['email_text']) . "\n\n---\n" . get_lang('EmailSentFromDokeos') . " " . api_get_path(WEB_PATH); $email_administrator = Security::remove_XSS($_POST['dest']); $user_id = api_get_user_id(); $title = Security::remove_XSS($_POST['email_title']); $content = Security::remove_XSS($_POST['email_text']); if (!empty($_user['mail'])) { api_mail_html('', $email_administrator, $title, $text, api_get_person_name($_user['firstname'], $_user['lastname']), $_user['mail']); UserManager::send_message_in_outbox($email_administrator, $user_id, $title, $content); } else { api_mail_html('', $email_administrator, $title, $text, get_lang('Anonymous')); } $orig = $_SESSION['origin_url']; Session::erase('origin_url'); header('location:' . $orig); exit; } Display::display_header(get_lang('SendEmail')); $form->display(); Display::display_footer();
case 'delete': if (!$is_allowed_to_edit) { api_not_allowed(true); } if ($debug > 0) { error_log('New LP - delete action triggered', 0); } if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; } else { $_SESSION['refresh'] = 1; // Remove lp from homepage if it is there. //$_SESSION['oLP']->toggle_visibility((int)$_GET['lp_id'],'i'); $_SESSION['oLP']->delete(null, (int) $_GET['lp_id'], 'remove'); Session::erase('oLP'); require 'lp_list.php'; } break; case 'toggle_visible': // Change lp visibility (inside lp tool). if (!$is_allowed_to_edit) { api_not_allowed(true); } if ($debug > 0) { error_log('New LP - visibility action triggered', 0); } if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; } else {
require_once dirname(__FILE__) . '/functions.inc.php'; //MAIN CODE //$uData variable is set in local.inc.php $user = api_get_user_info($uData['user_id']); $new_user = external_get_user_info($login); $user['firstname'] = $new_user['firstname']; $user['lastname'] = $new_user['lastname']; $user['status'] = $new_user['status']; $user['admin'] = $new_user['admin']; $user['email'] = $new_user['email']; $user['username'] = $new_user['username']; $user['profile_link'] = $new_user['profile_link']; $user['worldwide_bu'] = $new_user['worldwide_bu']; $user['manager'] = $new_user['manager']; $user['country_bu'] = $new_user['country_bu']; $user['extra'] = $new_user['extra']; if ($new_user !== false) { //User can login external_update_user($user); $loginFailed = false; $_user['user_id'] = $user['user_id']; $_user['uidReset'] = true; $uidReset = true; Session::write('_user', $_user); } else { //User cannot login $loginFailed = true; Session::erase('_uid'); header('Location: ' . api_get_path(WEB_PATH) . 'index.php?loginFailed=1&error=user_password_incorrect'); exit; }
if (!empty($exercise_stat_info)) { $total_score = $exercise_stat_info['exe_result']; } $max_score = $objExercise->get_max_score(); Display::display_normal_message(get_lang('Saved') . '<br />', false); // Display and save questions ExerciseLib::display_question_list_by_attempt($objExercise, $exe_id, true); //Unset session for clock time ExerciseLib::exercise_time_control_delete($objExercise->id, $learnpath_id, $learnpath_item_id); ExerciseLib::delete_chat_exercise_session($exe_id); if ($origin != 'learnpath') { echo '<hr>'; echo Display::url(get_lang('ReturnToCourseHomepage'), api_get_course_url(), array('class' => 'btn btn-primary')); if (api_is_allowed_to_session_edit()) { Session::erase('objExercise'); Session::erase('exe_id'); } Display::display_footer(); } else { $lp_mode = Session::read('lp_mode'); $url = '../newscorm/lp_controller.php?cidReq=' . api_get_course_id() . '&action=view&lp_id=' . $learnpath_id . '&lp_item_id=' . $learnpath_item_id . '&exeId=' . $exercise_stat_info['exe_id'] . '&fb_type=' . $objExercise->feedback_type; $href = $lp_mode == 'fullscreen' ? ' window.opener.location.href="' . $url . '" ' : ' top.location.href="' . $url . '"'; if (api_is_allowed_to_session_edit()) { Session::erase('objExercise'); Session::erase('exe_id'); } // Record the results in the learning path, using the SCORM interface (API) echo "<script>window.parent.API.void_save_asset('{$total_score}', '{$max_score}', 0, 'completed');</script>"; echo '<script type="text/javascript">' . $href . '</script>'; echo '</body></html>'; }
$tool_table = Database::get_course_table(TABLE_TOOL_LIST); $temps = time(); $reqdate = "&reqdate={$temps}"; /* SWITCH TO A DIFFERENT HOMEPAGE VIEW the setting homepage_view is adjustable through the platform administration section */ if ($show_autolaunch_lp_warning) { $show_message .= Display::return_message(get_lang('TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP'), 'warning'); } if (api_get_setting('course.homepage_view') == 'activity' || api_get_setting('course.homepage_view') == 'activity_big') { require 'activity.php'; } elseif (api_get_setting('course.homepage_view') == '2column') { require '2column.php'; } elseif (api_get_setting('course.homepage_view') == '3column') { require '3column.php'; } elseif (api_get_setting('course.homepage_view') == 'vertical_activity') { require 'vertical_activity.php'; } $content = '<div id="course_tools">' . $content . '</div>'; $tpl = new Template(null); $tpl->assign('message', $show_message); $tpl->assign('content', $content); // Direct login to course $tpl->assign('course_code', $course_code); $tpl->display_one_col_template(); // Deleting the objects Session::erase('_gid'); Session::erase('oLP'); Session::erase('lpobject'); api_remove_in_gradebook(); DocumentManager::removeGeneratedAudioTempFile();
/** * Handles a given Excel spreadsheets as in the template provided */ function lp_upload_quiz_action_handling() { global $debug; $_course = api_get_course_info(); $courseId = $_course['real_id']; if (!isset($_POST['submit_upload_quiz'])) { return; } // Get the extension of the document. $path_info = pathinfo($_FILES['user_upload_quiz']['name']); // Check if the document is an Excel document if ($path_info['extension'] != 'xls') { return; } // Read the Excel document $data = new Spreadsheet_Excel_Reader(); // Set output Encoding. $data->setOutputEncoding(api_get_system_encoding()); // Reading the xls document. $data->read($_FILES['user_upload_quiz']['tmp_name']); $correctScore = isset($_POST['correct_score']) ? $_POST['correct_score'] : null; $incorrectScore = isset($_POST['incorrect_score']) ? $_POST['incorrect_score'] : null; $useCustomScore = isset($_POST['user_custom_score']) ? true : false; $propagateNegative = 0; if ($useCustomScore && !empty($incorrectScore)) { if ($incorrectScore < 0) { $propagateNegative = 1; } } // Variables $quiz_index = 0; $question_title_index = array(); $question_name_index_init = array(); $question_name_index_end = array(); $score_index = array(); $feedback_true_index = array(); $feedback_false_index = array(); $number_questions = 0; $question_description_index = array(); // Reading all the first column items sequentially to create breakpoints for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) { if ($data->sheets[0]['cells'][$i][1] == 'Quiz' && $i == 1) { $quiz_index = $i; // Quiz title position, only occurs once } elseif ($data->sheets[0]['cells'][$i][1] == 'Question') { $question_title_index[] = $i; // Question title position line $question_name_index_init[] = $i + 1; // Questions name 1st position line $number_questions++; } elseif ($data->sheets[0]['cells'][$i][1] == 'Score') { $question_name_index_end[] = $i - 1; // Question name position $score_index[] = $i; // Question score position } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackTrue') { $feedback_true_index[] = $i; // FeedbackTrue position (line) } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackFalse') { $feedback_false_index[] = $i; // FeedbackFalse position (line) } elseif ($data->sheets[0]['cells'][$i][1] == 'EnrichQuestion') { $question_description_index[] = $i; } } // Variables $quiz = array(); $question = array(); $new_answer = array(); $score_list = array(); $feedback_true_list = array(); $feedback_false_list = array(); $question_description = array(); // Getting questions. $k = $z = $q = $l = $m = 0; for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) { if (is_array($data->sheets[0]['cells'][$i])) { $column_data = $data->sheets[0]['cells'][$i]; // Fill all column with data to have a full array for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) { if (empty($column_data[$x])) { $data->sheets[0]['cells'][$i][$x] = ''; } } // Array filled with data $column_data = $data->sheets[0]['cells'][$i]; } else { $column_data = ''; } // Fill quiz data if ($quiz_index == $i) { // The title always in the first position $quiz = $column_data; } elseif (in_array($i, $question_title_index)) { //a complete line where 1st column is 'Question' $question[$k] = $column_data; $k++; } elseif (in_array($i, $score_index)) { //a complete line where 1st column is 'Score' $score_list[$z] = $column_data; $z++; } elseif (in_array($i, $feedback_true_index)) { //a complete line where 1st column is 'FeedbackTrue' $feedback_true_list[$q] = $column_data; $q++; } elseif (in_array($i, $feedback_false_index)) { //a complete line where 1st column is 'FeedbackFalse' for wrong answers $feedback_false_list[$l] = $column_data; $l++; } elseif (in_array($i, $question_description_index)) { //a complete line where 1st column is 'EnrichQuestion' $question_description[$m] = $column_data; $m++; } } // Get answers for ($i = 0; $i < count($question_name_index_init); $i++) { for ($j = $question_name_index_init[$i]; $j <= $question_name_index_end[$i]; $j++) { if (is_array($data->sheets[0]['cells'][$j])) { $column_data = $data->sheets[0]['cells'][$j]; // Fill all column with data for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) { if (empty($column_data[$x])) { $data->sheets[0]['cells'][$j][$x] = ''; } } $column_data = $data->sheets[0]['cells'][$j]; // Array filled of data if (is_array($data->sheets[0]['cells'][$j]) && count($data->sheets[0]['cells'][$j]) > 0) { $new_answer[$i][$j] = $data->sheets[0]['cells'][$j]; } } } } // Quiz title. $quiz_title = $quiz[2]; if ($quiz_title != '') { // Variables $type = 2; $random = $active = $results = $max_attempt = $expired_time = 0; // Make sure feedback is enabled (3 to disable), otherwise the fields // added to the XLS are not shown, which is confusing $feedback = 0; // Quiz object $exercise = new Exercise(); // $quiz_id = $exercise->createExercise($quiz_title, $expired_time, $type, $random, $active, $results, $max_attempt, $feedback, $propagateNegative); if ($quiz_id) { // insert into the item_property table api_item_property_update($_course, TOOL_QUIZ, $quiz_id, 'QuizAdded', api_get_user_id()); // Import questions. for ($i = 0; $i < $number_questions; $i++) { // Question name $question_title = $question[$i][2]; $question_description_text = "<p></p>"; if (isset($question_description[$i][2])) { // Question description. $question_description_text = "<p>" . $question_description[$i][2] . "</p>"; } // Unique answers are the only question types available for now // through xls-format import $question_id = null; $detectQuestionType = detectQuestionType($new_answer[$i], $score_list); /** @var Question $answer */ switch ($detectQuestionType) { case FREE_ANSWER: $answer = new FreeAnswer(); break; case GLOBAL_MULTIPLE_ANSWER: $answer = new GlobalMultipleAnswer(); break; case MULTIPLE_ANSWER: $answer = new MultipleAnswer(); break; case UNIQUE_ANSWER: default: $answer = new UniqueAnswer(); break; } if ($question_title != '') { $question_id = $answer->create_question($quiz_id, $question_title, $question_description_text, 0, $answer->type); } $total = 0; if (is_array($new_answer[$i]) && !empty($question_id)) { $id = 1; $answers_data = $new_answer[$i]; $globalScore = null; $objAnswer = new Answer($question_id, $courseId); $globalScore = $score_list[$i][3]; // Calculate the number of correct answers to divide the // score between them when importing from CSV $numberRightAnswers = 0; foreach ($answers_data as $answer_data) { if (strtolower($answer_data[3]) == 'x') { $numberRightAnswers++; } } foreach ($answers_data as $answer_data) { $answerValue = $answer_data[2]; $correct = 0; $score = 0; if (strtolower($answer_data[3]) == 'x') { $correct = 1; $score = $score_list[$i][3]; $comment = $feedback_true_list[$i][2]; } else { $comment = $feedback_false_list[$i][2]; $floatVal = (double) $answer_data[3]; if (is_numeric($floatVal)) { $score = $answer_data[3]; } } if ($useCustomScore) { if ($correct) { $score = $correctScore; } else { $score = $incorrectScore; } } // Fixing scores: switch ($detectQuestionType) { case GLOBAL_MULTIPLE_ANSWER: $score /= $numberRightAnswers; break; case UNIQUE_ANSWER: break; case MULTIPLE_ANSWER: if (!$correct) { //$total = $total - $score; } break; } $objAnswer->createAnswer($answerValue, $correct, $comment, $score, $id); $total += $score; $id++; } $objAnswer->save(); $questionObj = Question::read($question_id, $courseId); switch ($detectQuestionType) { case GLOBAL_MULTIPLE_ANSWER: $questionObj->updateWeighting($globalScore); break; case UNIQUE_ANSWER: case MULTIPLE_ANSWER: default: $questionObj->updateWeighting($total); break; } $questionObj->save(); } else { if ($detectQuestionType === FREE_ANSWER) { $questionObj = Question::read($question_id, $courseId); $globalScore = $score_list[$i][3]; $questionObj->updateWeighting($globalScore); $questionObj->save(); } } } } if (isset($_SESSION['lpobject'])) { if ($debug > 0) { error_log('New LP - SESSION[lpobject] is defined', 0); } $oLP = unserialize($_SESSION['lpobject']); if (is_object($oLP)) { if ($debug > 0) { error_log('New LP - oLP is object', 0); } if (empty($oLP->cc) or $oLP->cc != api_get_course_id()) { if ($debug > 0) { error_log('New LP - Course has changed, discard lp object', 0); } $oLP = null; Session::erase('oLP'); Session::erase('lpobject'); } else { $_SESSION['oLP'] = $oLP; } } } if (isset($_SESSION['oLP']) && isset($_GET['lp_id'])) { $previous = $_SESSION['oLP']->select_previous_item_id(); $parent = 0; // Add a Quiz as Lp Item $_SESSION['oLP']->add_item($parent, $previous, TOOL_QUIZ, $quiz_id, $quiz_title, ''); // Redirect to home page for add more content header('location: ../newscorm/lp_controller.php?' . api_get_cidreq() . '&action=add_item&type=step&lp_id=' . Security::remove_XSS($_GET['lp_id'])); exit; } else { // header('location: exercise.php?' . api_get_cidreq()); echo '<script>window.location.href = "' . api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidReq() . '&exerciseId=' . $quiz_id . '&session_id=' . api_get_session_id() . '"</script>'; } } }
/** * Make sure this function is protected because it does NOT check password! * * This function defines globals. * @param int $userId * * @return bool False on failure, redirection on success * @author Evie Embrechts * @author Yannick Warnier <*****@*****.**> */ function loginUser($userId) { $userId = intval($userId); $userInfo = api_get_user_info($userId); // Check if the user is allowed to 'login_as' $canLoginAs = api_can_login_as($userId); if (!$canLoginAs || empty($userInfo)) { return false; } $firstname = $userInfo['firstname']; $lastname = $userInfo['lastname']; if (api_is_western_name_order()) { $message = sprintf(get_lang('AttemptingToLoginAs'), $firstname, $lastname, $userId); } else { $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); } if ($userId) { // Logout the current user LoginDelete(api_get_user_id()); Session::erase('_user'); Session::erase('is_platformAdmin'); Session::erase('is_allowedCreateCourse'); Session::erase('_uid'); // Cleaning session variables $_user['firstName'] = $userInfo['firstname']; $_user['lastName'] = $userInfo['lastname']; $_user['mail'] = $userInfo['email']; //$_user['lastLogin'] = $user_data['login_date']; $_user['official_code'] = $userInfo['official_code']; $_user['picture_uri'] = $userInfo['picture_uri']; $_user['user_id'] = $userId; $_user['id'] = $userId; $_user['status'] = $userInfo['status']; // Filling session variables with new data Session::write('_uid', $userId); Session::write('_user', $userInfo); Session::write('is_platformAdmin', (bool) UserManager::is_admin($userId)); Session::write('is_allowedCreateCourse', (bool) ($userInfo['status'] == 1)); // will be useful later to know if the user is actually an admin or not (example reporting) Session::write('login_as', true); $target_url = api_get_path(WEB_PATH) . "user_portal.php"; $message .= '<br />' . sprintf(get_lang('LoginSuccessfulGoToX'), '<a href="' . $target_url . '">' . $target_url . '</a>'); Display::display_header(get_lang('UserList')); Display::display_normal_message($message, false); Display::display_footer(); exit; } }