Moving start time inside LPInitialize + adding more scorm logs

skala
Julio Montoya 13 years ago
parent d8e2f47c24
commit 0fb30a3cd1
  1. 18
      main/newscorm/learnpath.class.php
  2. 8
      main/newscorm/lp_ajax_start_timer.php
  3. 7
      main/newscorm/lp_list.php
  4. 58
      main/newscorm/scorm_api.php

@ -2591,19 +2591,18 @@ class learnpath {
*/ */
public function get_toc() { public function get_toc() {
if ($this->debug > 0) { if ($this->debug > 0) {
error_log('New LP - In learnpath::get_toc()', 0); error_log('learnpath::get_toc()', 0);
} }
$toc = array(); $toc = array();
//echo "<pre>".print_r($this->items,true)."</pre>"; //echo "<pre>".print_r($this->items,true)."</pre>";
foreach ($this->ordered_items as $item_id) { foreach ($this->ordered_items as $item_id) {
if ($this->debug > 2) { 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. // TODO: Change this link generation and use new function instead.
$toc[] = array ( $toc[] = array (
'id' => $item_id, 'id' => $item_id,
'title' => $this->items[$item_id]->get_title(), 'title' => $this->items[$item_id]->get_title(),
//'link' => get_addedresource_link_in_learnpath('document', $item_id, 1),
'status' => $this->items[$item_id]->get_status(), 'status' => $this->items[$item_id]->get_status(),
'level' => $this->items[$item_id]->get_level(), 'level' => $this->items[$item_id]->get_level(),
'type' => $this->items[$item_id]->get_type(), 'type' => $this->items[$item_id]->get_type(),
@ -2617,7 +2616,6 @@ class learnpath {
return $toc; return $toc;
} }
/** /**
* Generate and return the table of contents for this learnpath. The JS * Generate and return the table of contents for this learnpath. The JS
* table returned is used inside of scorm_api.php * table returned is used inside of scorm_api.php
@ -2720,7 +2718,7 @@ class learnpath {
$is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false); $is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);
if ($this->debug > 0) { 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)) { if (empty($toc_list)) {
$toc_list = $this->get_toc(); $toc_list = $this->get_toc();
@ -2750,10 +2748,7 @@ class learnpath {
$i = 0; $i = 0;
foreach ($toc_list as $item) { foreach ($toc_list as $item) {
if ($this->debug > 2) { // TODO: Complete this
//error_log('New LP - learnpath::get_html_toc(): using item ' . $item['id'], 0);
}
// TODO: Complete this.
$icon_name = array ( $icon_name = array (
'not attempted' => '../img/notattempted.gif', 'not attempted' => '../img/notattempted.gif',
'incomplete' => '../img/incomplete.png', 'incomplete' => '../img/incomplete.png',
@ -2773,7 +2768,6 @@ class learnpath {
$style = 'scorm_item_highlight'; $style = 'scorm_item_highlight';
$scorm_color_background = 'scorm_item_highlight'; $scorm_color_background = 'scorm_item_highlight';
} else { } else {
if ($color_counter % 2 == 0) { if ($color_counter % 2 == 0) {
$scorm_color_background = 'scorm_item_1'; $scorm_color_background = 'scorm_item_1';
} else { } else {
@ -2829,8 +2823,12 @@ class learnpath {
$result = Database::query($sql); $result = Database::query($sql);
$count = Database :: num_rows($result);*/ $count = Database :: num_rows($result);*/
if ($item['type'] == 'quiz') { if ($item['type'] == 'quiz') {
error_log("1-->>>>>>>>>>>>>>>>");
error_log($item['status']);
if ($item['status'] == 'completed') { if ($item['status'] == 'completed') {
$html .= "&nbsp;<img id='toc_img_" . $item['id'] . "' src='" . $icon_name[$item['status']] . "' alt='" . substr($item['status'], 0, 1) . "' width='14' />"; $html .= "&nbsp;<img id='toc_img_" . $item['id'] . "' src='" . $icon_name[$item['status']] . "' alt='" . substr($item['status'], 0, 1) . "' width='14' />";
} else {
$html .= "&nbsp;<img id='toc_img_" . $item['id'] . "' src='" . $icon_name['not attempted'] . "' alt='" . substr('not attempted', 0, 1) . "' width='14' />";
} }
} else { } else {
if ($item['type'] != 'dokeos_chapter' && $item['type'] != 'dokeos_module' && $item['type'] != 'dir') { if ($item['type'] != 'dokeos_chapter' && $item['type'] != 'dokeos_module' && $item['type'] != 'dir') {

@ -2,9 +2,6 @@
/* For licensing terms, see /license.txt */ /* 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 * @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org> * @author Yannick Warnier <ywarnier@beeznest.org>
*/ */
@ -15,10 +12,7 @@
* @return string JavaScript time intializer * @return string JavaScript time intializer
*/ */
function start_timer() { function start_timer() {
//$objResponse = new xajaxResponse();
$time = time(); $time = time();
//$objResponse->addScript("asset_timer='$time';asset_timer_total=0;"); return $time; //"olms.asset_timer='$time'; olms.asset_timer_total = 0;";
//return $objResponse;
return "olms.asset_timer='$time';olms.asset_timer_total=0;";
} }
echo start_timer(); echo start_timer();

@ -211,7 +211,7 @@ if (!empty($flat_list)) {
$url_start_lp = 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$id; $url_start_lp = 'lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$id;
$name = Security::remove_XSS($details['lp_name']); $name = Security::remove_XSS($details['lp_name']);
if ($is_allowed_to_edit) { if ($is_allowed_to_edit) {
//&nbsp;'.$details['lp_proximity'].' $url_start_lp .= '&isStudentView=true';
$dsp_desc = '<em>'.$details['lp_maker'].'</em> '.(learnpath::is_lp_visible_for_student($id, api_get_user_id())?'':' - ('.get_lang('LPNotVisibleToStudent').')'); $dsp_desc = '<em>'.$details['lp_maker'].'</em> '.(learnpath::is_lp_visible_for_student($id, api_get_user_id())?'':' - ('.get_lang('LPNotVisibleToStudent').')');
$extra = '<div class ="lp_content_type_label">'.$dsp_desc .'</div>'; $extra = '<div class ="lp_content_type_label">'.$dsp_desc .'</div>';
} }
@ -223,10 +223,11 @@ if (!empty($flat_list)) {
if ($details['lp_visibility'] == 0 ) { if ($details['lp_visibility'] == 0 ) {
$my_title = Display::tag('font', $name, array('style'=>'color:grey')); $my_title = Display::tag('font', $name, array('style'=>'color:grey'));
} }
$dsp_line = '<tr align="center" class="'.$oddclass.'">'. $dsp_line = '<tr align="center" class="'.$oddclass.'">'.
'<td align="left" valign="top">'.Display::return_icon('learnpath.png', get_lang('LPName'),'',ICON_SIZE_SMALL).'<a href="'.$url_start_lp.'">' . $my_title . '</a>' . $session_img .$extra."</td>"; '<td align="left" valign="top">'.Display::return_icon('learnpath.png', get_lang('LPName'),'',ICON_SIZE_SMALL).'
<a href="'.$url_start_lp.'">' . $my_title . '</a>' . $session_img .$extra."</td>";
//$dsp_desc='<td>'.$details['lp_desc'].'</td>'."\n";
$dsp_desc = ''; $dsp_desc = '';
$dsp_export = ''; $dsp_export = '';
$dsp_edit = ''; $dsp_edit = '';

@ -202,7 +202,7 @@ addEvent(window, 'load', addListeners, false);
// Initialize stuff when the page is loaded // Initialize stuff when the page is loaded
$(document).ready(function() { $(document).ready(function() {
logit_lms('document.ready'); logit_lms('document.ready start');
olms.info_lms_item[0] = '<?php echo $oItem->get_id();?>'; olms.info_lms_item[0] = '<?php echo $oItem->get_id();?>';
olms.info_lms_item[1] = '<?php echo $oItem->get_id();?>'; olms.info_lms_item[1] = '<?php echo $oItem->get_id();?>';
@ -223,11 +223,11 @@ $(document).ready(function() {
//oXAJAX = new XAJAXobject(); //oXAJAX = new XAJAXobject();
//oxajax = new XAJAXobject(); //oxajax = new XAJAXobject();
// This code was moved inside LMSInitialize()
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(); //xajax_start_timer();
} }
/** /**
* The following section represents a set of mandatory functions for SCORM * The following section represents a set of mandatory functions for SCORM
*/ */
@ -267,6 +267,7 @@ function LMSInitialize() {
'vid': olms.lms_view_id, 'vid': olms.lms_view_id,
'iid': olms.lms_item_id 'iid': olms.lms_item_id
}; };
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "lp_ajax_initialize.php", url: "lp_ajax_initialize.php",
@ -274,6 +275,7 @@ function LMSInitialize() {
dataType: 'script', dataType: 'script',
async: false async: false
}); });
// log a more complete object dump when initializing, so we know what data hasn't been cleaned // 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 + '\nitem_type : '+ olms.lms_item_type
@ -295,10 +297,9 @@ function LMSInitialize() {
logit_scorm('LMSInitialize() with params: '+log); logit_scorm('LMSInitialize() with params: '+log);
//To keep the table updated if (olms.lms_lp_type == 1 || olms.lms_item_type == 'asset') {
update_toc(olms.lesson_status, olms.lms_item_id); xajax_start_timer();
}
olms.lms_initialized = 1;
<?php if (api_get_setting('show_glossary_in_documents') == 'ismanual') { ?> <?php if (api_get_setting('show_glossary_in_documents') == 'ismanual') { ?>
if (olms.lms_item_type == 'sco') { if (olms.lms_item_type == 'sco') {
@ -463,8 +464,7 @@ function LMSGetValue(param) {
} else if(req_type == '_children'){ } else if(req_type == '_children'){
result = 'id,score,status'; result = 'id,score,status';
} else if(req_type == 'score'){ } else if(req_type == 'score'){
if(myres[3]==null) if(myres[3]==null) {
{
result = ''; result = '';
olms.G_LastError = G_NotImplementedError; olms.G_LastError = G_NotImplementedError;
olms.G_LastErrorString = 'Not implemented yet'; olms.G_LastErrorString = 'Not implemented yet';
@ -486,14 +486,12 @@ function LMSGetValue(param) {
} }
} else { } else {
//the object is not null //the object is not null
if(req_type == 'id') if(req_type == 'id') {
{
result = olms.item_objectives[obj_id][0]; result = olms.item_objectives[obj_id][0];
} else if(req_type == '_children'){ } else if(req_type == '_children'){
result = 'id,score,status'; result = 'id,score,status';
} else if(req_type == 'score'){ } else if(req_type == 'score'){
if(myres[3]==null) if(myres[3]==null) {
{
result = ''; result = '';
olms.G_LastError = G_NotImplementedError; olms.G_LastError = G_NotImplementedError;
olms.G_LastErrorString = 'Not implemented yet'; olms.G_LastErrorString = 'Not implemented yet';
@ -507,15 +505,13 @@ function LMSGetValue(param) {
result = ''; result = '';
} }
} else if (myres[3] == '.max'){ } else if (myres[3] == '.max'){
if(olms.item_objectives[obj_id][3] != null) if(olms.item_objectives[obj_id][3] != null) {
{
result = olms.item_objectives[obj_id][3]; result = olms.item_objectives[obj_id][3];
}else{ }else{
result = ''; result = '';
} }
} else if (myres[3] == '.min') { } else if (myres[3] == '.min') {
if(olms.item_objectives[obj_id][4] != null) if(olms.item_objectives[obj_id][4] != null) {
{
result = olms.item_objectives[obj_id][4]; result = olms.item_objectives[obj_id][4];
} else { } else {
result = ''; result = '';
@ -526,8 +522,7 @@ function LMSGetValue(param) {
olms.G_LastErrorString = 'Not implemented yet'; olms.G_LastErrorString = 'Not implemented yet';
} }
} else if(req_type == 'status'){ } else if(req_type == 'status'){
if(olms.item_objectives[obj_id][1] != null) if(olms.item_objectives[obj_id][1] != null) {
{
result = olms.item_objectives[obj_id][1]; result = olms.item_objectives[obj_id][1];
} else { } else {
result = 'not attempted'; result = 'not attempted';
@ -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)(.*)/)) { if(myres = param.match(/cmi.interactions.(\d+).(id|time|type|correct_responses|weighting|student_response|result|latency)(.*)/)) {
olms.updatable_vars_list['interactions']=true; olms.updatable_vars_list['interactions']=true;
elem_id = myres[1]; 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_LastError = G_InvalidArgumentError;
olms.G_LastErrorString = 'Invalid argument (interactions)'; olms.G_LastErrorString = 'Invalid argument (interactions)';
@ -1082,7 +1077,10 @@ function lms_save_asset() {
function chamilo_void_save_asset(myscore, mymax) { function chamilo_void_save_asset(myscore, mymax) {
logit_lms('chamilo_void_save_asset',2); logit_lms('chamilo_void_save_asset',2);
olms.score = myscore; 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); 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 orig_item_type = olms.lms_item_types['i'+current_item];
var next_item_type = olms.lms_item_types['i'+next_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: There are four "cases" for switching items:
@ -1342,6 +1340,8 @@ function switch_item(current_item, next_item){
if (next_item_type != 'sco' ) { if (next_item_type != 'sco' ) {
//case 1 //case 1
logit_lms('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_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); xajax_switch_item_details(olms.lms_lp_id,olms.lms_user_id,olms.lms_view_id,olms.lms_item_id,next_item);
} else { } else {
@ -1438,6 +1438,7 @@ function switch_item(current_item, next_item){
default: default:
break; break;
} }
var mysrc = 'lp_controller.php?action=content&lp_id='+olms.lms_lp_id+'&item_id='+next_item; var mysrc = 'lp_controller.php?action=content&lp_id='+olms.lms_lp_id+'&item_id='+next_item;
var cont_f = $("#content_id"); var cont_f = $("#content_id");
@ -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 * @uses lp_ajax_start_timer.php
*/ */
function xajax_start_timer() { function xajax_start_timer() {
logit_lms('xajax_start_timer'); logit_lms('xajax_start_timer() called');
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "lp_ajax_start_timer.php", url: "lp_ajax_start_timer.php",
dataType: "script", dataType: "script",
async: false, async: false,
success: function(data) { success: function(time) {
//logit_lms('xajax_start_timer result: ' + data); 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, 'iid': lms_item_id,
'next': next_item 'next': next_item
}; };
logit_lms('xajax_switch_item_details with params:' + params); logit_lms('xajax_switch_item_details with params:' + params);
$.ajax({ $.ajax({
@ -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, 'iid': lms_item_id,
'next': next_item 'next': next_item
}; };
logit_lms('xajax_switch_item_toc with params:' + params); logit_lms('xajax_switch_item_toc');
$.ajax({ $.ajax({
type: "POST", type: "POST",

Loading…
Cancel
Save