diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index d0b2528c7b..51d3d5a13f 100644 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -2591,19 +2591,18 @@ class learnpath { */ public function get_toc() { if ($this->debug > 0) { - error_log('New LP - In learnpath::get_toc()', 0); + error_log('learnpath::get_toc()', 0); } $toc = array(); //echo "
".print_r($this->items,true)."
"; foreach ($this->ordered_items as $item_id) { if ($this->debug > 2) { - error_log('New LP - learnpath::get_toc(): getting info for item ' . $item_id, 0); + error_log('learnpath::get_toc(): getting info for item ' . $item_id, 0); } // TODO: Change this link generation and use new function instead. $toc[] = array ( 'id' => $item_id, 'title' => $this->items[$item_id]->get_title(), - //'link' => get_addedresource_link_in_learnpath('document', $item_id, 1), 'status' => $this->items[$item_id]->get_status(), 'level' => $this->items[$item_id]->get_level(), 'type' => $this->items[$item_id]->get_type(), @@ -2617,7 +2616,6 @@ class learnpath { return $toc; } - /** * Generate and return the table of contents for this learnpath. The JS * table returned is used inside of scorm_api.php @@ -2720,12 +2718,12 @@ class learnpath { $is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false); if ($this->debug > 0) { - error_log('New LP - In learnpath::get_html_toc()', 0); + error_log('In learnpath::get_html_toc()', 0); } if (empty($toc_list)) { $toc_list = $this->get_toc(); } - $html = '
' . Security::remove_XSS($this->get_name()) . '
'; + $html = '
'.Security::remove_XSS($this->get_name()) . '
'; $hide_teacher_icons_lp = isset($_configuration['hide_teacher_icons_lp']) ? $_configuration['hide_teacher_icons_lp'] : true; @@ -2750,10 +2748,7 @@ class learnpath { $i = 0; foreach ($toc_list as $item) { - if ($this->debug > 2) { - //error_log('New LP - learnpath::get_html_toc(): using item ' . $item['id'], 0); - } - // TODO: Complete this. + // TODO: Complete this $icon_name = array ( 'not attempted' => '../img/notattempted.gif', 'incomplete' => '../img/incomplete.png', @@ -2773,7 +2768,6 @@ class learnpath { $style = 'scorm_item_highlight'; $scorm_color_background = 'scorm_item_highlight'; } else { - if ($color_counter % 2 == 0) { $scorm_color_background = 'scorm_item_1'; } else { @@ -2829,8 +2823,12 @@ class learnpath { $result = Database::query($sql); $count = Database :: num_rows($result);*/ if ($item['type'] == 'quiz') { + error_log("1-->>>>>>>>>>>>>>>>"); + error_log($item['status']); if ($item['status'] == 'completed') { - $html .= " " . substr($item["; + $html .= " " . substr($item["; + } else { + $html .= " " . substr("; } } else { if ($item['type'] != 'dokeos_chapter' && $item['type'] != 'dokeos_module' && $item['type'] != 'dir') { diff --git a/main/newscorm/lp_ajax_start_timer.php b/main/newscorm/lp_ajax_start_timer.php old mode 100755 new mode 100644 index 7e8c4d1ff7..2e21023d0a --- a/main/newscorm/lp_ajax_start_timer.php +++ b/main/newscorm/lp_ajax_start_timer.php @@ -2,9 +2,6 @@ /* For licensing terms, see /license.txt */ /** - * This script contains the server part of the xajax interaction process. The client part is located - * in lp_api.php or other api's. - * This is a first attempt at using xajax and AJAX in general, so the code might be a bit unsettling. * @package chamilo.learnpath * @author Yannick Warnier */ @@ -15,10 +12,7 @@ * @return string JavaScript time intializer */ function start_timer() { - //$objResponse = new xajaxResponse(); $time = time(); - //$objResponse->addScript("asset_timer='$time';asset_timer_total=0;"); - //return $objResponse; - return "olms.asset_timer='$time';olms.asset_timer_total=0;"; + return $time; //"olms.asset_timer='$time'; olms.asset_timer_total = 0;"; } -echo start_timer(); +echo start_timer(); \ No newline at end of file diff --git a/main/newscorm/lp_list.php b/main/newscorm/lp_list.php index be65365a7a..26c199e87d 100644 --- a/main/newscorm/lp_list.php +++ b/main/newscorm/lp_list.php @@ -211,7 +211,7 @@ if (!empty($flat_list)) { $url_start_lp = 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$id; $name = Security::remove_XSS($details['lp_name']); if ($is_allowed_to_edit) { - // '.$details['lp_proximity'].' + $url_start_lp .= '&isStudentView=true'; $dsp_desc = ''.$details['lp_maker'].' '.(learnpath::is_lp_visible_for_student($id, api_get_user_id())?'':' - ('.get_lang('LPNotVisibleToStudent').')'); $extra = '
'.$dsp_desc .'
'; } @@ -223,10 +223,11 @@ if (!empty($flat_list)) { if ($details['lp_visibility'] == 0 ) { $my_title = Display::tag('font', $name, array('style'=>'color:grey')); } + $dsp_line = ''. - ''.Display::return_icon('learnpath.png', get_lang('LPName'),'',ICON_SIZE_SMALL).'' . $my_title . '' . $session_img .$extra.""; + ''.Display::return_icon('learnpath.png', get_lang('LPName'),'',ICON_SIZE_SMALL).' + ' . $my_title . '' . $session_img .$extra.""; - //$dsp_desc=''.$details['lp_desc'].''."\n"; $dsp_desc = ''; $dsp_export = ''; $dsp_edit = ''; diff --git a/main/newscorm/scorm_api.php b/main/newscorm/scorm_api.php index fcad0d6ddd..9eb30e9fb1 100644 --- a/main/newscorm/scorm_api.php +++ b/main/newscorm/scorm_api.php @@ -202,12 +202,12 @@ addEvent(window, 'load', addListeners, false); // Initialize stuff when the page is loaded $(document).ready(function() { - logit_lms('document.ready'); + logit_lms('document.ready start'); olms.info_lms_item[0] = 'get_id();?>'; olms.info_lms_item[1] = 'get_id();?>'; - $("#content_id").load( function() { + $("#content_id").load(function() { logit_lms('#content_id on load executing: '); olms.info_lms_item[0] = olms.info_lms_item[1]; @@ -223,11 +223,11 @@ $(document).ready(function() { //oXAJAX = new XAJAXobject(); //oxajax = new XAJAXobject(); +// This code was moved inside LMSInitialize() if (olms.lms_lp_type == 1 || olms.lms_item_type == 'asset') { - xajax_start_timer(); + //xajax_start_timer(); } - /** * The following section represents a set of mandatory functions for SCORM */ @@ -249,7 +249,7 @@ function LMSInitialize() { olms.G_LastError = G_NoError ; olms.G_LastErrorMessage = 'No error'; - olms.lms_initialized=0; + olms.lms_initialized = 0; // if there are more parameters than "" if (arguments.length > 1) { olms.G_LastError = G_InvalidArgumentError; @@ -267,6 +267,7 @@ function LMSInitialize() { 'vid': olms.lms_view_id, 'iid': olms.lms_item_id }; + $.ajax({ type: "POST", url: "lp_ajax_initialize.php", @@ -274,8 +275,9 @@ function LMSInitialize() { dataType: 'script', async: false }); + // log a more complete object dump when initializing, so we know what data hasn't been cleaned - var log = '\nitem : '+ olms.lms_item_id + var log = '\nitem : '+ olms.lms_item_id + '\nitem_type : '+ olms.lms_item_type + '\nscore : '+ olms.score + '\nmax : '+ olms.max @@ -295,10 +297,9 @@ function LMSInitialize() { logit_scorm('LMSInitialize() with params: '+log); - //To keep the table updated - update_toc(olms.lesson_status, olms.lms_item_id); - - olms.lms_initialized = 1; + if (olms.lms_lp_type == 1 || olms.lms_item_type == 'asset') { + xajax_start_timer(); + } if (olms.lms_item_type == 'sco') { @@ -463,8 +464,7 @@ function LMSGetValue(param) { } else if(req_type == '_children'){ result = 'id,score,status'; } else if(req_type == 'score'){ - if(myres[3]==null) - { + if(myres[3]==null) { result = ''; olms.G_LastError = G_NotImplementedError; olms.G_LastErrorString = 'Not implemented yet'; @@ -486,50 +486,45 @@ function LMSGetValue(param) { } } else { //the object is not null - if(req_type == 'id') - { + if(req_type == 'id') { result = olms.item_objectives[obj_id][0]; - }else if(req_type == '_children'){ + } else if(req_type == '_children'){ result = 'id,score,status'; - }else if(req_type == 'score'){ - if(myres[3]==null) - { + } else if(req_type == 'score'){ + if(myres[3]==null) { result = ''; olms.G_LastError = G_NotImplementedError; olms.G_LastErrorString = 'Not implemented yet'; - }else if (myres[3] == '._children'){ + } else if (myres[3] == '._children'){ result = 'raw,min,max'; //non-standard, added for NetG - }else if (myres[3] == '.raw'){ + } else if (myres[3] == '.raw'){ if(olms.item_objectives[obj_id][2] != null) { result = olms.item_objectives[obj_id][2]; }else{ result = ''; } - }else if (myres[3] == '.max'){ - if(olms.item_objectives[obj_id][3] != null) - { + } else if (myres[3] == '.max'){ + if(olms.item_objectives[obj_id][3] != null) { result = olms.item_objectives[obj_id][3]; }else{ result = ''; } - }else if (myres[3] == '.min'){ - if(olms.item_objectives[obj_id][4] != null) - { + } else if (myres[3] == '.min') { + if(olms.item_objectives[obj_id][4] != null) { result = olms.item_objectives[obj_id][4]; - }else{ + } else { result = ''; } - }else{ + } else{ result = ''; olms.G_LastError = G_NotImplementedError; olms.G_LastErrorString = 'Not implemented yet'; } - }else if(req_type == 'status'){ - if(olms.item_objectives[obj_id][1] != null) - { + } else if(req_type == 'status'){ + if(olms.item_objectives[obj_id][1] != null) { result = olms.item_objectives[obj_id][1]; - }else{ + } else { result = 'not attempted'; } } @@ -650,7 +645,7 @@ function LMSSetValue(param, val) { } else if ( param == "cmi.student_data.time_limit_action" ) { olms.G_LastError = G_ElementIsReadOnly; } else if ( param == "cmi.student_data.mastery_score" ) { - olms.G_LastError = G_ElementIsReadOnly; + olms.G_LastError = G_ElementIsReadOnly; } else if ( param == "cmi.student_data.max_time_allowed" ) { olms.G_LastError = G_ElementIsReadOnly; } else if ( param == "cmi.student_preference._children" ) { @@ -662,8 +657,8 @@ function LMSSetValue(param, val) { if(myres = param.match(/cmi.interactions.(\d+).(id|time|type|correct_responses|weighting|student_response|result|latency)(.*)/)) { olms.updatable_vars_list['interactions']=true; elem_id = myres[1]; - if(elem_id > olms.interactions.length) //interactions setting should start at 0 - { + //interactions setting should start at 0 + if(elem_id > olms.interactions.length) { /* olms.G_LastError = G_InvalidArgumentError; olms.G_LastErrorString = 'Invalid argument (interactions)'; @@ -988,9 +983,9 @@ function Terminate() { * Defining the AJAX-object class to be made available from other frames */ function XAJAXobject() { - this.xajax_switch_item_details=xajax_switch_item_details; - this.switch_item=switch_item; - this.xajax_save_objectives=xajax_save_objectives; + this.xajax_switch_item_details = xajax_switch_item_details; + this.switch_item = switch_item; + this.xajax_save_objectives = xajax_save_objectives; this.xajax_save_item = xajax_save_item; } @@ -1005,7 +1000,7 @@ function addEvent(elm, evType, fn, useCapture){ if (elm.addEventListener){ elm.addEventListener(evType, fn, useCapture); return true; - } else if (elm.attachEvent){ + } else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); } else{ elm['on'+evType] = fn; @@ -1065,7 +1060,7 @@ function lms_save_asset() { if (olms.lms_lp_type == 1 || olms.lms_item_type == 'asset') { logit_lms('lms_save_asset'); logit_lms('execute_stats :'+ olms.execute_stats); - xajax_save_item(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, olms.lms_item_id, olms.score, olms.max, olms.min, olms.lesson_status, olms.session_time, olms.suspend_data, olms.lesson_location,olms.interactions, olms.lms_item_core_exit); + xajax_save_item(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, olms.lms_item_id, olms.score, olms.max, olms.min, olms.lesson_status, olms.session_time, olms.suspend_data, olms.lesson_location, olms.interactions, olms.lms_item_core_exit); if (olms.item_objectives.length>0) { xajax_save_objectives(olms.lms_lp_id,olms.lms_user_id,olms.lms_view_id,olms.lms_item_id,olms.item_objectives); } @@ -1082,7 +1077,10 @@ function lms_save_asset() { function chamilo_void_save_asset(myscore, mymax) { logit_lms('chamilo_void_save_asset',2); olms.score = myscore; - if((mymax == null) || (mymax == '')){mymax = 100;} //assume a default of 100, otherwise the score will not get saved (see lpi->set_score()) + if ((mymax == null) || (mymax == '')){ + mymax = 100; + } + //assume a default of 100, otherwise the score will not get saved (see lpi->set_score()) xajax_save_item(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, olms.lms_item_id, myscore, mymax); } @@ -1318,7 +1316,7 @@ function switch_item(current_item, next_item){ var orig_item_type = olms.lms_item_types['i'+current_item]; var next_item_type = olms.lms_item_types['i'+next_item]; - logit_lms('Called switch_item with params '+olms.lms_item_id+' and '+next_item+'',0); + logit_lms('switch_item() called with params '+olms.lms_item_id+' and '+next_item+'',0); /* There are four "cases" for switching items: @@ -1342,6 +1340,8 @@ function switch_item(current_item, next_item){ if (next_item_type != 'sco' ) { //case 1 logit_lms('Case 1'); + logit_lms('timer' + olms.asset_timer); + xajax_save_item(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, olms.lms_item_id, olms.score, olms.max, olms.min, olms.lesson_status, olms.asset_timer, olms.suspend_data, olms.lesson_location,olms.interactions, olms.lms_item_core_exit); xajax_switch_item_details(olms.lms_lp_id,olms.lms_user_id,olms.lms_view_id,olms.lms_item_id,next_item); } else { @@ -1427,17 +1427,18 @@ function switch_item(current_item, next_item){ switch (next_item){ case 'next': next_item = olms.lms_next_item; - olms.info_lms_item[0]=olms.info_lms_item[1]; - olms.info_lms_item[1]=olms.lms_next_item; + olms.info_lms_item[0] = olms.info_lms_item[1]; + olms.info_lms_item[1] = olms.lms_next_item; break; case 'previous': next_item = olms.lms_previous_item; - olms.info_lms_item[0]=olms.info_lms_item[1]; - olms.info_lms_item[1]=olms.lms_previous_item; + olms.info_lms_item[0] = olms.info_lms_item[1]; + olms.info_lms_item[1] = olms.lms_previous_item; break; default: break; } + var mysrc = 'lp_controller.php?action=content&lp_id='+olms.lms_lp_id+'&item_id='+next_item; var cont_f = $("#content_id"); @@ -1454,7 +1455,7 @@ function switch_item(current_item, next_item){ cont_f.attr("src",mysrc); - if (olms.lms_lp_type==1 || olms.lms_item_type=='asset'){ + if (olms.lms_lp_type==1 || olms.lms_item_type == 'asset'){ xajax_start_timer(); } @@ -1608,14 +1609,16 @@ function xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id) * @uses lp_ajax_start_timer.php */ function xajax_start_timer() { - logit_lms('xajax_start_timer'); + logit_lms('xajax_start_timer() called'); $.ajax({ type: "GET", url: "lp_ajax_start_timer.php", dataType: "script", async: false, - success: function(data) { - //logit_lms('xajax_start_timer result: ' + data); + success: function(time) { + olms.asset_timer = time; + olms.asset_timer_total = 0; + logit_lms('xajax_start_timer result:' + time); } }); } @@ -1673,6 +1676,7 @@ function xajax_switch_item_details(lms_lp_id,lms_user_id,lms_view_id,lms_item_id 'iid': lms_item_id, 'next': next_item }; + logit_lms('xajax_switch_item_details with params:' + params); $.ajax({ @@ -1694,7 +1698,7 @@ function xajax_switch_item_details(lms_lp_id,lms_user_id,lms_view_id,lms_item_id * @param int ID of the next item * @uses lp_ajax_switch_toc.php */ -function xajax_switch_item_toc(lms_lp_id,lms_user_id,lms_view_id,lms_item_id,next_item) { +function xajax_switch_item_toc(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, next_item) { var params = { 'lid': lms_lp_id, 'uid': lms_user_id, @@ -1702,7 +1706,7 @@ function xajax_switch_item_toc(lms_lp_id,lms_user_id,lms_view_id,lms_item_id,nex 'iid': lms_item_id, 'next': next_item }; - logit_lms('xajax_switch_item_toc with params:' + params); + logit_lms('xajax_switch_item_toc'); $.ajax({ type: "POST",