Updating newscorm folder from 1.9.4

skala
Julio Montoya 13 years ago
parent dcbbbcf7af
commit eec498b4b3
  1. 89
      main/newscorm/learnpath.class.php
  2. 49
      main/newscorm/learnpathItem.class.php
  3. 5
      main/newscorm/lp_ajax_initialize.php
  4. 30
      main/newscorm/lp_ajax_save_item.php
  5. 11
      main/newscorm/lp_ajax_switch_item_toc.php
  6. 4
      main/newscorm/lp_controller.php
  7. 2
      main/newscorm/lp_edit_item_prereq.php
  8. 50
      main/newscorm/lp_stats.php
  9. 2
      main/newscorm/lp_view.php
  10. 54
      main/newscorm/scorm_api.php

@ -12,6 +12,7 @@
* Defines the learnpath parent class
* @package chamilo.learnpath
*/
class learnpath {
public $attempt = 0; // The number for the current ID view.
@ -726,20 +727,22 @@ class learnpath {
* @param integer Optional ID of the item from which to look for parents
*/
public function autocomplete_parents($item) {
$course_id = api_get_course_int_id();
if ($this->debug > 0) {
$debug = $this->debug;
if ($debug) {
error_log('New LP - In learnpath::autocomplete_parents()', 0);
}
if (empty ($item)) {
if (empty($item)) {
$item = $this->current;
}
$parent_id = $this->items[$item]->get_parent();
if ($this->debug > 2) {
if ($debug) {
error_log('New LP - autocompleting parent of item ' . $item . ' (item ' . $parent_id . ')', 0);
}
if (is_object($this->items[$item]) and !empty ($parent_id)) {
if (is_object($this->items[$item]) and !empty($parent_id)) {
// if $item points to an object and there is a parent.
if ($this->debug > 2) {
if ($debug) {
error_log('New LP - ' . $item . ' is an item, proceed', 0);
}
$current_item = & $this->items[$item];
@ -749,18 +752,19 @@ class learnpath {
if ($current_item->is_done() || $current_status == 'browsed' || $current_status == 'failed') {
// If the current item is completed or passes or succeeded.
$completed = true;
if ($this->debug > 2) {
if ($debug) {
error_log('New LP - Status of current item is alright', 0);
}
foreach ($parent->get_children() as $child) {
// Check all his brothers (his parent's children) for completion status.
// Check all his brothers (parent's children) for completion status.
if ($child != $item) {
if ($this->debug > 2) {
if ($debug) {
error_log('New LP - Looking at brother with ID ' . $child . ', status is ' . $this->items[$child]->get_status(), 0);
}
//if($this->items[$child]->status_is(array('completed','passed','succeeded')))
// Trying completing parents of failed and browsed items as well.
if ($this->items[$child]->status_is(array (
if ($this->items[$child]->status_is(array(
'completed',
'passed',
'succeeded',
@ -776,11 +780,12 @@ class learnpath {
}
}
}
if ($completed) { // If all the children were completed:
$parent->set_status('completed');
$parent->save(false, $this->prerequisites_match($parent->get_id()));
$this->update_queue[$parent->get_id()] = $parent->get_status();
if ($this->debug > 2) {
if ($debug) {
error_log('New LP - Added parent to update queue ' . print_r($this->update_queue, true), 0);
}
$this->autocomplete_parents($parent->get_id()); // Recursive call.
@ -3530,7 +3535,7 @@ class learnpath {
error_log('New LP - In learnpath::next()', 0);
}
$this->last = $this->get_current_item_id();
$this->items[$this->last]->save(false, $this->prerequisites_match($this->last));
$this->items[$this->last]->save(false, $this->prerequisites_match($this->last));
$this->autocomplete_parents($this->last);
$new_index = $this->get_next_index();
if ($this->debug > 2) {
@ -3671,19 +3676,20 @@ class learnpath {
$tbl_tool = Database :: get_course_table(TABLE_TOOL_LIST);
$course_id = api_get_course_int_id();
$link = 'newscorm/lp_controller.php?action=view&lp_id=' . $lp_id.'&id_session='.$session_id;
$sql = "SELECT * FROM $tbl_tool WHERE c_id = ".$course_id." AND name='$name' and image='scormbuilder.gif' and link LIKE '$link%' $session_condition";
$sql = "SELECT * FROM $tbl_tool WHERE c_id = ".$course_id." AND link='$link' and image='scormbuilder.gif' and link LIKE '$link%' $session_condition";
$result = Database::query($sql);
$num = Database :: num_rows($result);
$row2 = Database :: fetch_array($result);
//if ($this->debug > 2) { error_log('New LP - '.$sql.' - '.$num, 0); }
if (($set_visibility == 'i') && ($num > 0)) {
$sql = "DELETE FROM $tbl_tool WHERE c_id = ".$course_id." AND (name='$name' and image='scormbuilder.gif' and link LIKE '$link%' $session_condition)";
$sql = "DELETE FROM $tbl_tool WHERE c_id = ".$course_id." AND (link='$link' and image='scormbuilder.gif' $session_condition)";
} elseif (($set_visibility == 'v') && ($num == 0)) {
$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id) VALUES
($course_id, '$name','$link','scormbuilder.gif','$v','0','pastillegris.gif',0, $session_id)";
} elseif (($set_visibility == 'v') && ($num > 0)) {
$sql = "UPDATE $tbl_tool SET c_id = $course_id, name = '$name', link = '$link', image = 'scormbuilder.gif', visibility = '$v', admin = '0', address = 'pastillegris.gif', added_tool = 0, session_id = $session_id
WHERE c_id = ".$course_id." AND (link='$link' and image='scormbuilder.gif' $session_condition)";
} else {
// Parameter and database incompatible, do nothing.
}
@ -3748,7 +3754,7 @@ class learnpath {
}
if (is_object($this->items[$this->current])) {
//$res = $this->items[$this->current]->save(false);
$res = $this->items[$this->current]->save(false, $this->prerequisites_match($this->current));
$res = $this->items[$this->current]->save(false, $this->prerequisites_match($this->current));
$this->autocomplete_parents($this->current);
$status = $this->items[$this->current]->get_status();
$this->append_message('new_item_status: ' . $status);
@ -3764,26 +3770,25 @@ class learnpath {
* @param boolean Save from url params (true) or from current attributes (false). Optional. Defaults to true
* @return boolean
*/
public function save_item($item_id = null, $from_outside = true) {
$course_id = api_get_course_int_id();
if ($this->debug > 0) {
public function save_item($item_id = null, $from_outside = true) {
$debug = $this->debug;
if ($debug) {
error_log('New LP - In learnpath::save_item(' . $item_id . ',' . $from_outside . ')', 0);
}
// TODO: Do a better check on the index pointing to the right item (it is supposed to be working
// on $ordered_items[] but not sure it's always safe to use with $items[]).
if (empty($item_id)) {
$item_id = Database::escape_string($_REQUEST['id']);
$item_id = intval($_REQUEST['id']);
}
if (empty($item_id)) {
$item_id = $this->get_current_item_id();
}
if ($this->debug > 2) {
if ($debug) {
error_log('New LP - save_current() saving item ' . $item_id, 0);
}
if (is_object($this->items[$item_id])) {
if ($this->debug) { error_log('object exists'); }
$res = $this->items[$item_id]->save($from_outside, $this->prerequisites_match($item_id));
//$res = $this->items[$item_id]->save($from_outside);
if ($debug) { error_log('object exists'); }
$res = $this->items[$item_id]->save($from_outside, $this->prerequisites_match($item_id));
$this->autocomplete_parents($item_id);
$status = $this->items[$item_id]->get_status();
$this->append_message('new_item_status: ' . $status);
@ -3966,7 +3971,7 @@ class learnpath {
if ($this->debug > 2) {
error_log('New LP - lp updated with new content_maker : ' . $this->maker, 0);
}
$res = Database::query($sql);
Database::query($sql);
return true;
}
@ -3975,13 +3980,13 @@ class learnpath {
* @param string Optional string giving the new name of this learnpath
* @return boolean True/False
*/
public function set_name($name = '') {
public function set_name($name = null) {
if ($this->debug > 0) {
error_log('New LP - In learnpath::set_name()', 0);
}
if (empty ($name))
if (empty($name)) {
return false;
}
$this->name = Database::escape_string($name);
$lp_table = Database :: get_course_table(TABLE_LP_MAIN);
$lp_id = $this->get_id();
@ -3993,11 +3998,13 @@ class learnpath {
$res = Database::query($sql);
// If the lp is visible on the homepage, change his name there.
if (Database::affected_rows()) {
$table = Database :: get_course_table(TABLE_TOOL_LIST);
$sql = 'UPDATE ' . $table . ' SET
name = "' . $this->name . '"
WHERE c_id = '.$course_id.' AND link = "newscorm/lp_controller.php?action=view&lp_id=' . $lp_id . '"';
Database::query($sql);
$session_id = api_get_session_id();
$session_condition = api_get_session_condition($session_id);
$tbl_tool = Database :: get_course_table(TABLE_TOOL_LIST);
$link = 'newscorm/lp_controller.php?action=view&lp_id=' . $lp_id.'&id_session='.$session_id;
$sql = "UPDATE $tbl_tool SET name = '$this->name'
WHERE c_id = ".$course_id." AND (link='$link' and image='scormbuilder.gif' $session_condition)";
$res = Database::query($sql);
}
return true;
}
@ -5123,7 +5130,7 @@ class learnpath {
$url = api_get_self() . '?cidReq='.Security::remove_XSS($_GET['cidReq']).'&view=build&id='.$arrLP[$i]['id'] .'&lp_id='.$this->lp_id;
if (!in_array($arrLP[$i]['item_type'], array('dokeos_chapter', 'dokeos_module', 'dir'))) {
$prerequisities_icon = Display::url(Display::return_icon('accept.png', get_lang('Prerequisites'), array(), ICON_SIZE_TINY), $url.'&action=edit_item_prereq');
$prerequisities_icon = Display::url(Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_TINY), $url.'&action=edit_item_prereq');
$move_item_icon = Display::url(Display::return_icon('move.png', get_lang('Move'), array(), ICON_SIZE_TINY), $url.'&action=move_item');
$audio_icon = Display::url(Display::return_icon('audio.png', get_lang('UplUpload'), array(), ICON_SIZE_TINY), $url.'&action=add_audio');
}
@ -5251,8 +5258,6 @@ class learnpath {
$return .= '<a href="lp_controller.php?cidReq=' . Security :: remove_XSS($_GET['cidReq']) . '&action=build&lp_id=' . $this->lp_id . '">' . Display :: return_icon('home.png', get_lang('Build'),'',ICON_SIZE_MEDIUM).'</a>';
if ($is_allowed_to_edit) {
}
//$return .= '<a href="' . api_get_self().'?'.api_get_cidreq().'&amp;gradebook=' . $gradebook . '&amp;action=admin_view&amp;lp_id=' . $_SESSION['oLP']->lp_id . '" title="' . get_lang('BasicOverview') . '">' . Display :: return_icon('move_learnpath.png', get_lang('BasicOverview'),'',ICON_SIZE_MEDIUM).'</a>';
$return .= '<a href="lp_controller.php?'.api_get_cidreq().'&amp;gradebook=' . $gradebook . '&action=view&lp_id=' . $_SESSION['oLP']->lp_id . '">' . Display :: return_icon('view_left_right.png', get_lang('Display'),'',ICON_SIZE_MEDIUM).'</a> ';
@ -5930,7 +5935,7 @@ class learnpath {
}
/*// Commented the prerequisites, only visible in edit (exercise).
$return .= '<tr>';
$return .= '<td class="label"><label for="idPrerequisites">'.get_lang('Prerequisites').'</label></td>';
$return .= '<td class="label"><label for="idPrerequisites">'.get_lang('LearnpathPrerequisites').'</label></td>';
$return .= '<td class="input"><select name="prerequisites" id="prerequisites" class="learnpath_item_form"><option value="0">'.get_lang('NoPrerequisites').'</option>';
foreach($arrHide as $key => $value){
@ -6514,7 +6519,7 @@ class learnpath {
}
$return .= '<tr>';
$return .= '<td class="label"><label for="idPrerequisites">' . get_lang('Prerequisites') . '</label></td>';
$return .= '<td class="label"><label for="idPrerequisites">' . get_lang('LearnpathPrerequisites') . '</label></td>';
$return .= '<td class="input"><select name="prerequisites" id="prerequisites"><option value="0">' . get_lang('NoPrerequisites') . '</option>';
foreach ($arrHide as $key => $value) {
@ -7442,7 +7447,7 @@ class learnpath {
// Commented the prerequisites, only visible in edit (work).
/*
$return .= '<tr>';
$return .= '<td class="label"><label for="idPrerequisites">'.get_lang('Prerequisites').'</label></td>';
$return .= '<td class="label"><label for="idPrerequisites">'.get_lang('LearnpathPrerequisites').'</label></td>';
$return .= '<td class="input"><select name="prerequisites" id="prerequisites" class="learnpath_item_form"><option value="0">'.get_lang('NoPrerequisites').'</option>';
foreach($arrHide as $key => $value) {
@ -7561,7 +7566,7 @@ class learnpath {
// Commented for now as prerequisites cannot be added to chapters.
if ($item_type != 'dokeos_chapter' && $item_type != 'chapter') {
$return .= Display::url(Display::return_icon('accept.png', get_lang('Prerequisites'), array(), ICON_SIZE_SMALL), $url.'&action=edit_item_prereq');
$return .= Display::url(Display::return_icon('accept.png', get_lang('LearnpathPrerequisites'), array(), ICON_SIZE_SMALL), $url.'&action=edit_item_prereq');
}
$return .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), $url.'&action=delete_item');
@ -7756,7 +7761,7 @@ class learnpath {
$return .= '<table class="data_table" style="width:650px">';
$return .= '<tr>';
$return .= '<th height="24">' . get_lang('Prerequisites') . '</th>';
$return .= '<th height="24">' . get_lang('LearnpathPrerequisites') . '</th>';
$return .= '<th width="70" height="24">' . get_lang('Minimum') . '</th>';
$return .= '<th width="70" height="24">' . get_lang('Maximum') . '</th>';
$return .= '</tr>';

@ -1969,7 +1969,8 @@ class learnpathItem {
*/
public function set_score($score) {
//$possible_status = array('not attempted','incomplete','completed','passed','failed','browsed');
if (self::debug > 0) { error_log('learnpathItem::set_score('.$score.')', 0); }
$debug = self::debug;
if ($debug > 0) { error_log('learnpathItem::set_score('.$score.')', 0); }
if (($this->max_score <= 0 || $score <= $this->max_score) && ($score >= $this->min_score)) {
$this->current_score = $score;
$master = $this->get_mastery_score();
@ -1979,7 +1980,8 @@ class learnpathItem {
if ($master == -1) {
$master = $this->max_score;
}
if (self::debug > 0) {
if ($debug > 0) {
error_log('get_mastery_score: '.$master);
error_log('current_status: '.$current_status);
error_log('current score : '.$this->current_score);
@ -1987,12 +1989,12 @@ class learnpathItem {
// If mastery_score is set AND the current score reaches the mastery score AND the current status is different from 'completed', then set it to 'passed'.
if ($master != -1 && $this->current_score >= $master && $current_status != $this->possible_status[2]) {
if (self::debug > 0) error_log('Status changed to: '.$this->possible_status[3]);
if ($debug > 0) error_log('Status changed to: '.$this->possible_status[3]);
$this->set_status($this->possible_status[3]); //passed
} elseif ($master != -1 && $this->current_score < $master) {
if (self::debug > 0) error_log('Status changed to: '.$this->possible_status[4]);
if ($debug > 0) error_log('Status changed to: '.$this->possible_status[4]);
$this->set_status($this->possible_status[4]); //failed
}
}
return true;
}
return false;
@ -2672,4 +2674,41 @@ class learnpathItem {
$sql = "UPDATE $tbl_lp_item SET audio = '' WHERE c_id = $course_id AND id IN (".$this->db_id.")";
Database::query($sql);
}
static function humanize_status($status, $decorate = true) {
$mylanglist = array(
'completed' => 'ScormCompstatus',
'incomplete' => 'ScormIncomplete',
'failed' => 'ScormFailed',
'passed' => 'ScormPassed',
'browsed' => 'ScormBrowsed',
'not attempted' => 'ScormNotAttempted'
);
$my_lesson_status = get_lang($mylanglist[$status]);
switch ($status) {
case 'completed':
case 'browsed':
$class_status = 'info';
break;
case 'incomplete':
$class_status = 'warning';
break;
case 'passed':
$class_status = 'success';
break;
case 'failed':
$class_status = 'important';
break;
default:
$class_status = 'default';
break;
}
if ($decorate) {
return Display::label($my_lesson_status, $class_status);
} else {
return $my_lesson_status;
}
}
}

@ -62,11 +62,6 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
$mylp->set_current_item($next_item);
if ($debug > 1) { error_log('In initialize_item() - new item is '.$next_item, 0); }
$mylp->start_current_item(true);
/*
if ($mylp->force_commit) {
$mylp->save_current();
}
*/
if (is_object($mylp->items[$next_item])) {
if ($debug > 1) { error_log('In initialize_item - recovering existing item object '.$next_item, 0); }

@ -47,7 +47,8 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
$debug = 0;
if ($debug > 0) {
error_log('lp_ajax_save_item.php : save_item params: ');
error_log('lp_ajax_save_item.php : save_item() params: ');
error_log("item_id: $item_id");
error_log("lp_id: $lp_id - user_id: - $user_id - view_id: $view_id - item_id: $item_id");
error_log("score: $score - max:$max - min: $min - status:$status - time:$time - suspend: $suspend - location: $location - core_exit: $core_exit");
}
@ -91,14 +92,15 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
//set_score function already saves the status
if (isset($score) && $score != -1) {
if ($debug > 1) { error_log('Calling set_score('.$score.')', 0); }
if ($debug > 1) { error_log('Calling set_score('.$score.')', 0); }
if ($debug > 1) { error_log('set_score changes the status to failed/passed if mastery score is provided', 0); }
$mylpi->set_score($score);
if ($debug > 1) { error_log('Done calling set_score '.$mylpi->get_score(), 0); }
} else {
if ($debug > 1) { error_log("Score not updated"); }
//Default behaviour
if (isset($status) && $status != '' && $status != 'undefined') {
if (isset($status) && $status != '' && $status != 'undefined') {
//Implements scorm 1.2 constraint
//If SCO_MasteryScore does not evaluate to a number, passed/failed status won't be set at all
//Score was not set
@ -112,7 +114,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
default:
if ($debug > 1) { error_log('Calling set_status('.$status.')', 0); }
$mylpi->set_status($status);
if ($debug > 1) { error_log('Done calling set_status: checking from memory:'.$mylpi->get_status(false), 0); }
if ($debug > 1) { error_log('Done calling set_status: checking from memory: '.$mylpi->get_status(false), 0); }
break;
}
} else {
@ -139,7 +141,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
}
}
if (isset($time) && $time!='' && $time!='undefined') {
if (isset($time) && $time != '' && $time != 'undefined') {
// If big integer, then it's a timestamp, otherwise it's normal scorm time.
if ($debug > 1) { error_log('Calling set_time('.$time.') ', 0); }
if ($time == intval(strval($time)) && $time > 1000000) {
@ -186,7 +188,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
}
$mystatus_in_db = $mylpi->get_status(true);
error_log("Status in DB: $mystatus_in_db");
if ($debug) error_log("Status in DB: $mystatus_in_db");
if ($mystatus_in_db != 'completed' && $mystatus_in_db != 'passed' && $mystatus_in_db != 'browsed' && $mystatus_in_db != 'failed') {
$mystatus_in_memory = $mylpi->get_status(false);
@ -199,16 +201,14 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
$mystatus = $mystatus_in_db;
}
$mytotal = $mylp->get_total_items_count_without_chapters();
$mycomplete = $mylp->get_complete_items_count();
$mytotal = $mylp->get_total_items_count_without_chapters();
$mycomplete = $mylp->get_complete_items_count();
$myprogress_mode = $mylp->get_progress_bar_mode();
$myprogress_mode = $myprogress_mode == '' ? '%' : $myprogress_mode;
if ($debug > 1) { error_log("mystatus: $mystatus", 0); }
if ($debug > 1) { error_log("myprogress_mode: $myprogress_mode", 0); }
if ($debug > 1) { error_log("mytotal: $mytotal", 0); }
if ($debug > 1) { error_log("mycomplete: $mycomplete", 0); }
if ($debug > 1) { error_log("myprogress_mode: $myprogress_mode", 0); }
if ($debug > 1) { error_log("progress: $mycomplete / $mytotal", 0); }
$_SESSION['lpobject'] = serialize($mylp);
if ($mylpi->get_type() != 'sco') {
@ -217,12 +217,14 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
}
$return .= "update_toc('".$mystatus."','".$item_id."');";
$update_list = $mylp->get_update_queue();
foreach ($update_list as $my_upd_id => $my_upd_status) {
if ($my_upd_id != $item_id) { // Only update the status from other items (i.e. parents and brothers), do not update current as we just did it already.
$return .= "update_toc('".$my_upd_status."','".$my_upd_id."');";
}
}
$return .= "update_progress_bar('$mycomplete','$mytotal','$myprogress_mode');";
}
$return .= "update_progress_bar('$mycomplete', '$mytotal', '$myprogress_mode');";
if ($debug > 0) {
$return .= "logit_lms('Saved data for item ".$item_id.", user ".$user_id." (status=".$mystatus.")',2);";

@ -45,7 +45,7 @@ function switch_item_toc($lp_id, $user_id, $view_id, $current_item, $next_item)
if ($debug > 2) { error_log('Building new lp', 0); }
unset($oLP);
$code = api_get_course_id();
$mylp = new learnpath($code,$lp_id,$user_id);
$mylp = new learnpath($code, $lp_id, $user_id);
} else {
if ($debug > 1) { error_log('Reusing session lp', 0); }
$mylp = & $oLP;
@ -87,8 +87,7 @@ function switch_item_toc($lp_id, $user_id, $view_id, $current_item, $next_item)
$mylp->start_current_item(true);
if ($mylp->force_commit) {
$mylp->save_current();
}
//$objResponse->addAlert(api_get_path(REL_CODE_PATH).'newscorm/learnpathItem.class.php');
}
if (is_object($mylp->items[$new_item_id])) {
$mylpi = & $mylp->items[$new_item_id];
} else {
@ -182,8 +181,6 @@ function switch_item_toc($lp_id, $user_id, $view_id, $current_item, $next_item)
if ($debug > 1) { error_log('Prereq_match() returned '.htmlentities($mylp->error), 0); }
$_SESSION['scorm_item_id'] = $new_item_id; // Save the new item ID for the exercise tool to use.
$_SESSION['lpobject'] = serialize($mylp);
return $return;
//return $objResponse;
return $return;
}
echo switch_item_toc($_POST['lid'], $_POST['uid'], $_POST['vid'], $_POST['iid'], $_POST['next']);
echo switch_item_toc($_POST['lid'], $_POST['uid'], $_POST['vid'], $_POST['iid'], $_POST['next']);

@ -819,9 +819,7 @@ switch ($action) {
require 'lp_save.php';
}
break;
case 'stats':
case 'stats':
if ($debug > 0) error_log('New LP - stats action triggered', 0);
if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; }
else {

@ -72,7 +72,7 @@ $interbreadcrumb[] = array('url' => api_get_self() . "?action=add_item&type=step
$show_learn_path = true;
$lp_theme_css = $_SESSION['oLP']->get_theme();
Display::display_header(get_lang('Prerequisites'), 'Path');
Display::display_header(get_lang('LearnpathPrerequisites'), 'Path');
$suredel = trim(get_lang('AreYouSureToDelete'));
?>

@ -335,22 +335,7 @@ if (is_array($list) && count($list) > 0) {
}
// Remove "NaN" if any (@todo: locate the source of these NaN)
$time = str_replace('NaN', '00' . $h . '00\'00"', $time);
if (($lesson_status == 'completed') || ($lesson_status == 'passed')) {
$class_status = 'success';
} else {
$class_status = 'default';
}
$mylanglist = array(
'completed' => 'ScormCompstatus',
'incomplete' => 'ScormIncomplete',
'failed' => 'ScormFailed',
'passed' => 'ScormPassed',
'browsed' => 'ScormBrowsed',
'not attempted' => 'ScormNotAttempted'
);
$my_lesson_status = get_lang($mylanglist[$lesson_status]);
$time = str_replace('NaN', '00' . $h . '00\'00"', $time);
if ($row['item_type'] != 'dokeos_chapter') {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@ -376,7 +361,7 @@ if (is_array($list) && count($list) > 0) {
<td></td>
<td>' . $extend_attempt_link . '</td>
<td colspan="3">' . get_lang('Attempt') . ' ' . $row['iv_view_count'] . '</td>
<td colspan="2">' . Display::label($my_lesson_status, $class_status) . '</td>
<td colspan="2">' . learnpathItem::humanize_status($lesson_status) . '</td>
<td colspan="2">' . $view_score . '</td>
<td colspan="2">' . $time . '</td>
<td></td>
@ -385,7 +370,7 @@ if (is_array($list) && count($list) > 0) {
if (!empty($export_csv)) {
$temp = array();
$temp[] = $title = Security::remove_XSS($title);
$temp[] = Security::remove_XSS($my_lesson_status);
$temp[] = Security::remove_XSS(learnpathItem::humanize_status($lesson_status, false));
if ($row['item_type'] == 'quiz') {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@ -518,13 +503,9 @@ if (is_array($list) && count($list) > 0) {
$score = $row['myscore'];
$subtotal_time = $row['mytime'];
//if ($row['mytime'] == 0) {
while ($tmp_row = Database :: fetch_array($result)) {
$subtotal_time += $tmp_row['mytime'];
}
//}
//$time_for_total = $subtotal_time;
//$time = learnpathItem :: get_scorm_time('js', $subtotal_time);
$scoIdentifier = $row['myid'];
$title = $row['mytitle'];
@ -620,23 +601,6 @@ if (is_array($list) && count($list) > 0) {
// Remove "NaN" if any (@todo: locate the source of these NaN)
//$time = str_replace('NaN', '00'.$h.'00\'00"', $time);
if (($lesson_status == 'completed') or ($lesson_status == 'passed')) {
$class_status = 'success';
} else {
$class_status = 'default';
}
$mylanglist = array(
'completed' => 'ScormCompstatus',
'incomplete' => 'ScormIncomplete',
'failed' => 'ScormFailed',
'passed' => 'ScormPassed',
'browsed' => 'ScormBrowsed',
'not attempted' => 'ScormNotAttempted'
);
$my_lesson_status = get_lang($mylanglist[$lesson_status]);
if ($row['item_type'] != 'dokeos_chapter') {
if ($row['item_type'] == 'quiz') {
$correct_test_link = '';
@ -711,7 +675,7 @@ if (is_array($list) && count($list) > 0) {
$output .= '<td>'.$extend_link.'</td>
<td colspan="4">' . $title . '</td>
<td colspan="2">' . Display::label($my_lesson_status, $class_status) .'</td>
<td colspan="2">' . learnpathitem::humanize_status($lesson_status) .'</td>
<td colspan="2">';
if ($row['item_type'] == 'quiz') {
if (!$is_allowed_to_edit && $result_disabled_ext_all) {
@ -837,16 +801,16 @@ if (is_array($list) && count($list) > 0) {
$my_lesson_status = $row_attempts['status'];
if ($my_lesson_status == '') {
$my_lesson_status = get_lang($mylanglist['completed']);
$my_lesson_status = learnpathitem::humanize_status('completed');
} elseif ($my_lesson_status == 'incomplete') {
$my_lesson_status = get_lang($mylanglist['incomplete']);
$my_lesson_status = learnpathitem::humanize_status('incomplete');
}
$output .= '<tr class="' . $oddclass . '" >
<td></td>
<td>' . $extend_attempt_link . '</td>
<td colspan="3">' . get_lang('Attempt') . ' ' . $n . '</td>
<td colspan="2">' . Display::label($my_lesson_status, $class_status) . '</td>
<td colspan="2">' . $my_lesson_status . '</td>
<td colspan="2">
' . $view_score . '
</td>

@ -380,7 +380,7 @@ if (Database::num_rows($res_media) > 0) {
<div id="learning_path_toc">
<?php echo $_SESSION['oLP']->get_html_toc($get_toc_list); ?>
<?php if (!empty($_SESSION['oLP']->scorm_debug)) { //only show log ?>
<?php if (!empty($_SESSION['oLP']->scorm_debug) && api_is_platform_admin()) { //only show log ?>
<!-- log message layout -->
<div id="lp_log_name" name="lp_log_name" class="lp_log" style="height:150px;overflow:auto;margin:4px">
<div id="log_content"></div>

@ -266,7 +266,7 @@ function LMSInitialize() {
async: false
});
// log a more complete object dump when initializing, so we know what data hasn't been cleaned
var log = '<br />item : '+ olms.lms_item_id
var log = '<br />item : '+ olms.lms_item_id
+ '<br />item_type : '+ olms.lms_item_type
+ '<br />score : '+ olms.score
+ '<br />max : '+ olms.max
@ -278,9 +278,10 @@ function LMSInitialize() {
+ '<br />total_time : '+ olms.total_time
+ '<br />mastery_score : '+ olms.mastery_score
+ '<br />max_time_allowed: '+ olms.max_time_allowed
+ '<br />lms_lp_id : '+olms.lms_lp_id
+ '<br />lms_user_id: '+olms.lms_user_id
+ '<br />lms_view_id: '+olms.lms_view_id
+ '<br />credit : '+ olms.lms_item_credit
+ '<br />lms_lp_id : '+ olms.lms_lp_id
+ '<br />lms_user_id : '+ olms.lms_user_id
+ '<br />lms_view_id : '+ olms.lms_view_id
;
logit_scorm('LMSInitialize()'+log,0);
@ -799,6 +800,8 @@ function SetValue(param, val) {
function savedata(origin) {
//origin can be 'commit', 'finish' or 'terminate' (depending on the calling function)
//Status is NOT modified here see the lp_ajax_save_item.php file
/* console.log('savedata');
console.log(olms.lesson_status);
console.log(olms.mastery_score);
@ -841,21 +844,23 @@ function savedata(origin) {
}
*/
}
//console.log(olms.lesson_status);
logit_lms('saving data (status='+olms.lesson_status+' - interactions: '+ olms.interactions.length +')',1);
old_item_id=olms.info_lms_item[0];
old_item_id = olms.info_lms_item[0];
xajax_save_item_scorm(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, old_item_id);
xajax_save_item_scorm(olms.lms_lp_id, olms.lms_user_id, olms.lms_view_id, old_item_id);
olms.info_lms_item[1]=olms.lms_item_id;
if (olms.item_objectives.length>0) {
xajax_save_objectives(olms.lms_lp_id,olms.lms_user_id,olms.lms_view_id,old_item_id,olms.item_objectives);
}
olms.execute_stats = false;
//clean array
olms.variable_to_send=new Array();
olms.variable_to_send = new Array();
}
/**
* Send the Commit signal to the LMS (save the data for this element without
* closing the current process)
@ -1256,7 +1261,7 @@ function update_stats_page() {
*/
function update_progress_bar(nbr_complete, nbr_total, mode) {
logit_lms('update_progress_bar('+nbr_complete+','+nbr_total+','+mode+')',2);
logit_lms('could update with data: '+olms.lms_lp_id+','+olms.lms_view_id+','+olms.lms_user_id,2);
logit_lms('Could update with data: '+olms.lms_lp_id+','+olms.lms_view_id+','+olms.lms_user_id,2);
if (mode == '') {
mode='%';
@ -1272,13 +1277,6 @@ function update_progress_bar(nbr_complete, nbr_total, mode) {
var pr_text = $("#progress_text");
var progress_bar = $("#progress_bar_value");
progress_bar.css('width', percentage + "%");
/*
var pr_full = $("#progress_img_full");
var pr_empty = $("#progress_img_empty");
pr_full.attr('width',percentage*1.2);
pr_empty.attr('width',(100-percentage)*1.2);
*/
var mytext = '';
switch(mode){
@ -1337,11 +1335,11 @@ function reinit_updatable_vars_list () {
function switch_item(current_item, next_item){
// backup these params
var orig_current_item = current_item;
var orig_next_item = next_item;
var orig_lesson_status = olms.lesson_status;
var orig_item_type = olms.lms_item_types['i'+current_item];
var next_item_type = olms.lms_item_types['i'+next_item];
var orig_current_item = current_item;
var orig_next_item = next_item;
var orig_lesson_status = olms.lesson_status;
var orig_item_type = olms.lms_item_types['i'+current_item];
var next_item_type = olms.lms_item_types['i'+next_item];
/*
There are four "cases" for switching items:
@ -1550,6 +1548,7 @@ function xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score
});
}
}
/**
* Save a SCORM item's variables, getting its SCORM values from
* updatable_vars_list. Takes interactions into account and considers whether
@ -1567,8 +1566,9 @@ function xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id)
var is_interactions='false';
var params='';
params += 'lid='+lms_lp_id+'&uid='+lms_user_id+'&vid='+lms_view_id+'&iid='+lms_item_id;
var my_scorm_values=new Array();
my_scorm_values=process_scorm_values();
var my_scorm_values = new Array();
my_scorm_values = process_scorm_values();
for (k=0;k<my_scorm_values.length;k++) {
if (my_scorm_values[k]=='cmi.core.session_time') {
@ -1603,9 +1603,10 @@ function xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id)
}
if (is_interactions=='true') {
if (is_interactions == 'true') {
interact_string = '';
temp = '';
temp = '';
for (i in olms.interactions) {
interact_string += '&interact['+i+']=';
interact_temp = '[';
@ -1621,7 +1622,6 @@ function xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id)
interact_temp = interact_temp.substr(0,(interact_temp.length-2)) + ']';
// interact_string += encodeURIComponent(interact_temp);
interact_string += interact_temp;
}
//interact_string = encodeURIComponent(interact_string.substr(0,(interact_string.length-1)));

Loading…
Cancel
Save