- redesign * @author Denes Nagy, principal author * @author Isthvan Mandak, several new features * @author Roan Embrechts, code improvements and refactoring * @license GNU/GPL - See Dokeos license directory for details ============================================================================== */ /** * Script */ /* ============================================================================== INIT SECTION ============================================================================== */ $_SESSION['whereami'] = 'lp/view'; $this_section=SECTION_COURSES; if($lp_controller_touched!=1){ header('location: lp_controller.php?action=view&item_id='.$_REQUEST['item_id']); } /* ----------------------------------------------------------- Libraries ----------------------------------------------------------- */ require_once('back_compat.inc.php'); //require_once('../learnpath/learnpath_functions.inc.php'); require_once('scorm.lib.php'); require_once('learnpath.class.php'); require_once('learnpathItem.class.php'); //require_once('lp_comm.common.php'); //xajax functions if ($is_allowed_in_course == false) api_not_allowed(); /* ----------------------------------------------------------- Variables ----------------------------------------------------------- */ // we set the encoding of the lp if (!empty($_SESSION['oLP']->encoding)) { $charset = $_SESSION['oLP']->encoding; } else { $charset = api_get_system_encoding(); } $oLearnpath = false; $course_code = api_get_course_id(); $user_id = api_get_user_id(); $platform_theme = api_get_setting('stylesheets'); // plataform's css $my_style=$platform_theme; //escape external variables /* ----------------------------------------------------------- Header ----------------------------------------------------------- */ $htmlHeadXtra[] = ''; //jQuery if (api_get_setting('show_glossary_in_documents') == 'ismanual' || api_get_setting('show_glossary_in_documents') == 'isautomatic' ) { $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; } $htmlHeadXtra[] = ''; $htmlHeadXtra[] = ''; $_SESSION['oLP']->error = ''; $lp_type = $_SESSION['oLP']->get_type(); $lp_item_id = $_SESSION['oLP']->get_current_item_id(); //$lp_item_id = learnpath::escape_string($_GET['item_id']); //$_SESSION['oLP']->set_current_item($lp_item_id); // already done by lp_controller.php //Prepare variables for the test tool (just in case) - honestly, this should disappear later on $_SESSION['scorm_view_id'] = $_SESSION['oLP']->get_view_id(); $_SESSION['scorm_item_id'] = $lp_item_id; $_SESSION['lp_mode'] = $_SESSION['oLP']->mode; //reinit exercises variables to avoid spacename clashes (see exercise tool) if(isset($exerciseResult) or isset($_SESSION['exerciseResult'])) { api_session_unregister($exerciseResult); } unset($_SESSION['objExercise']); unset($_SESSION['questionList']); /** * Get a link to the corresponding document */ if (!isset($src)) { $src = ''; switch($lp_type) { case 1: $_SESSION['oLP']->stop_previous_item(); $htmlHeadXtra[] = ''; $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id); if($prereq_check === true){ $src = $_SESSION['oLP']->get_link('http',$lp_item_id); $_SESSION['oLP']->start_current_item(); //starts time counter manually if asset }else{ $src = 'blank.php?error=prerequisites'; } break; case 2: //save old if asset $_SESSION['oLP']->stop_previous_item(); //save status manually if asset $htmlHeadXtra[] = ''; $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id); if($prereq_check === true){ $src = $_SESSION['oLP']->get_link('http',$lp_item_id); $_SESSION['oLP']->start_current_item(); //starts time counter manually if asset }else{ $src = 'blank.php?error=prerequisites'; } break; case 3: //aicc $_SESSION['oLP']->stop_previous_item(); //save status manually if asset $htmlHeadXtra[] = ''; $prereq_check = $_SESSION['oLP']->prerequisites_match($lp_item_id); if($prereq_check === true){ $src = $_SESSION['oLP']->get_link('http',$lp_item_id); $_SESSION['oLP']->start_current_item(); //starts time counter manually if asset }else{ $src = 'blank.php'; } break; case 4: break; } } $list = $_SESSION['oLP']->get_toc(); $type_quiz = false; foreach($list as $toc) { if ($toc['id'] == $lp_item_id && ($toc['type']=='quiz') ) { $type_quiz = true; } } $autostart = 'true'; // update status,total_time from lp_item_view table when you finish the exercises in learning path if ($type_quiz && !empty($_REQUEST['exeId']) && isset($_GET['lp_id']) && isset($_GET['lp_item_id'])) { global $src; $_SESSION['oLP']->items[$_SESSION['oLP']->current]->write_to_db(); $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES); $TBL_LP_ITEM_VIEW = Database::get_course_table(TABLE_LP_ITEM_VIEW); $TBL_LP_VIEW = Database::get_course_table(TABLE_LP_VIEW); $TBL_LP_ITEM = Database::get_course_table(TABLE_LP_ITEM); $safe_item_id = Database::escape_string($_GET['lp_item_id']); $safe_id = Database::escape_string($_GET['lp_id']); $safe_exe_id = Database::escape_string($_REQUEST['exeId']); if ($safe_id == strval(intval($safe_id)) && $safe_item_id == strval(intval($safe_item_id))) { $sql = 'SELECT start_date,exe_date,exe_result,exe_weighting FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.(int)$safe_exe_id; $res = Database::query($sql,__FILE__,__LINE__); $row_dates = Database::fetch_array($res); $time_start_date = convert_mysql_date($row_dates['start_date']); $time_exe_date = convert_mysql_date($row_dates['exe_date']); $mytime = ((int)$time_exe_date-(int)$time_start_date); $score = (float)$row_dates['exe_result']; $max_score = (float)$row_dates['exe_weighting']; $sql_upd_status = "UPDATE $TBL_LP_ITEM_VIEW SET status = 'completed' WHERE lp_item_id = '".(int)$safe_item_id."' AND lp_view_id = (SELECT lp_view.id FROM $TBL_LP_VIEW lp_view WHERE user_id = '".(int)$_SESSION['oLP']->user_id."' AND lp_id='".(int)$safe_id."')"; Database::query($sql_upd_status,__FILE__,__LINE__); $sql_upd_max_score = "UPDATE $TBL_LP_ITEM SET max_score = '$max_score' WHERE id = '".(int)$safe_item_id."'"; Database::query($sql_upd_max_score,__FILE__,__LINE__); $sql_last_attempt = "SELECT id FROM $TBL_LP_ITEM_VIEW WHERE lp_item_id = '$safe_item_id' AND lp_view_id = '".$_SESSION['oLP']->lp_view_id."' order by id desc limit 1"; $res_last_attempt = Database::query($sql_last_attempt,__FILE__,__LINE__); $row_last_attempt = Database::fetch_row($res_last_attempt); if (Database::num_rows($res_last_attempt)>0) { $sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET score = $score,total_time = $mytime WHERE id='".$row_last_attempt[0]."'"; Database::query($sql_upd_score,__FILE__,__LINE__); } } if(intval($_GET['fb_type']) > 0) { $src = 'blank.php?msg=exerciseFinished'; } else { $src = api_get_path(WEB_CODE_PATH).'exercice/exercise_show.php?id='.Security::remove_XSS($_REQUEST['exeId']).'&origin=learnpath&learnpath_id='.Security::remove_XSS($_GET['lp_id']).'&learnpath_item_id='.Security::remove_XSS($_GET['lp_id']).'&fb_type='.Security::remove_XSS($_GET['fb_type']); } $autostart = 'false'; } $_SESSION['oLP']->set_previous_item($lp_item_id); $nameTools = Security :: remove_XSS(api_convert_encoding($_SESSION['oLP']->get_name(), $charset, api_get_system_encoding())); $save_setting = api_get_setting("show_navigation_menu"); global $_setting; $_setting['show_navigation_menu'] = 'false'; $scorm_css_header=true; $lp_theme_css=$_SESSION['oLP']->get_theme(); //sets the css theme of the LP this call is also use at the frames (toc, nav, message) if($_SESSION['oLP']->mode == 'fullscreen') { $htmlHeadXtra[] = ""; include_once('../inc/reduced_header.inc.php'); //set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php) $_SESSION['loaded_lp_view'] = true; ?>