Uploading newscorm folder from 1.9.x

skala
Julio Montoya 13 years ago
parent 19af5453fb
commit b808c9568f
  1. 35
      main/newscorm/aicc_api.php
  2. 480
      main/newscorm/learnpath.class.php
  3. 241
      main/newscorm/learnpathItem.class.php
  4. 3
      main/newscorm/lp_add.php
  5. 2
      main/newscorm/lp_add_item.php
  6. 187
      main/newscorm/lp_admin_view.php
  7. 64
      main/newscorm/lp_ajax_initialize.php
  8. 2
      main/newscorm/lp_ajax_last_update_status.php
  9. 154
      main/newscorm/lp_ajax_save_item.php
  10. 2
      main/newscorm/lp_ajax_save_objectives.php
  11. 4
      main/newscorm/lp_ajax_switch_item.php
  12. 4
      main/newscorm/lp_ajax_switch_item_toc.php
  13. 8
      main/newscorm/lp_comm.server.php
  14. 60
      main/newscorm/lp_controller.php
  15. 32
      main/newscorm/lp_edit.php
  16. 14
      main/newscorm/lp_edit_item.php
  17. 3
      main/newscorm/lp_list.php
  18. 13
      main/newscorm/lp_nav.php
  19. 94
      main/newscorm/lp_view.php
  20. 44
      main/newscorm/lp_view_item.php
  21. 27
      main/newscorm/scorm.class.php
  22. 714
      main/newscorm/scorm_api.php

@ -36,7 +36,6 @@ require_once 'learnpathItem.class.php';
require_once 'aicc.class.php';
// Is this needed? This is probabaly done in the header file.
// $_user = $_SESSION['_user'];
$file = $_SESSION['file'];
$oLP = unserialize($_SESSION['lpobject']);
$oItem = $oLP->items[$oLP->current];
@ -444,19 +443,41 @@ function chamilo_save_asset(){
* @param string Message to log
* @param integer Priority (0 for top priority, 3 for lowest)
*/
function logit_scorm(message,priority){
if(frames["lp_log_name"] && scorm_logs>priority){
function logit_scorm(message,priority) {
if (scorm_logs) {
log_in_log("SCORM: " + message);
}
return false;
/*if(frames["lp_log_name"] && scorm_logs>priority){
frames["lp_log_name"].document.getElementById("log_content").innerHTML += "AICC: " + message + "<br/>";
}*/
}
function log_in_log(message) {
var ua = $.browser;
if (ua.mozilla) {
console.log(message);
} else {
if (window.console) {
window.console.log(message);
}
}
}
/**
* Logs information about LMS activity into the log frame
* @param string Message to log
* @param integer Priority (0 for top priority, 3 for lowest)
*/
function logit_lms(message,priority){
function logit_lms(message,priority) {
/*
if(frames["lp_log_name"] && lms_logs>priority){
frames["lp_log_name"].document.getElementById("log_content").innerHTML += "LMS: " + message + "<br/>";
}*/
if (scorm_logs) {
log_in_log("LMS: " + message);
}
}
@ -541,10 +562,10 @@ function update_progress_bar(nbr_complete, nbr_total, mode)
if(nbr_total == 0){nbr_total=1;}
var percentage = (nbr_complete/nbr_total)*100;
percentage = Math.round(percentage);
var progress_bar = $("#progress_bar_value");
progress_bar.css('width', percentage +"%");
/*
var pr_text = myframe.document.getElementById('progress_text');
var pr_full = myframe.document.getElementById('progress_img_full');
@ -553,7 +574,7 @@ function update_progress_bar(nbr_complete, nbr_total, mode)
pr_full.width = percentage;
pr_empty.width = 100-percentage;
*/
var mytext = '';
switch(mode){
case 'abs':

File diff suppressed because it is too large Load Diff

@ -59,7 +59,7 @@ class learnpathItem {
public $type; // This attribute can contain chapter|link|student_publication|module|quiz|document|forum|thread
public $view_id;
//var used if absolute session time mode is used
private $last_scorm_session_time =0;
private $last_scorm_session_time = 0;
const debug = 0; // Logging parameter.
@ -78,7 +78,7 @@ class learnpathItem {
if (!isset($user_id)) { $user_id = api_get_user_id(); }
if (self::debug > 0) { error_log("learnpathItem constructor: id: $id user_id: $user_id course_id: $course_id item_content: $item_content", 0); }
$id = intval($id);
if (empty($item_content)) {
$items_table = Database::get_course_table(TABLE_LP_ITEM);
if (empty($course_id)) {
@ -90,14 +90,14 @@ class learnpathItem {
//error_log('New LP - Creating item object from DB: '.$sql, 0);
$res = Database::query($sql);
if (Database::num_rows($res) < 1) {
$this->error = 'Could not find given learnpath item in learnpath_item table';
$this->error = 'Could not find given learnpath item in learnpath_item table';
return false;
}
$row = Database::fetch_array($res);
} else {
$row = $item_content;
}
$this->lp_id = $row['lp_id'];
$this->max_score = $row['max_score'];
$this->min_score = $row['min_score'];
@ -123,7 +123,7 @@ class learnpathItem {
$this->seriousgame_mode = 0;
// Get search_did.
if (api_get_setting('search_enabled') == 'true') {
if (api_get_setting('search_enabled') == 'true') {
$tbl_se_ref = Database::get_main_table(TABLE_MAIN_SEARCH_ENGINE_REF);
$sql = 'SELECT * FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level=%d LIMIT 1';
// TODO: Verify if it's possible to assume the actual course instead of getting it from db.
@ -231,11 +231,11 @@ class learnpathItem {
$sql_sel = "SELECT * FROM $lp_item WHERE c_id = $course_id AND id = ".$this->db_id;
$res_sel = Database::query($sql_sel);
if (Database::num_rows($res_sel) < 1) {
return false;
if (Database::num_rows($res_sel) < 1) {
return false;
}
$sql_del_item = "DELETE FROM $lp_item WHERE c_id = $course_id AND id = ".$this->db_id;
$sql_del_item = "DELETE FROM $lp_item WHERE c_id = $course_id AND id = ".$this->db_id;
Database::query($sql_del_item);
if (self::debug > 0) { error_log('Deleting from lp_item: '.$sql_del_view); }
@ -668,7 +668,7 @@ class learnpathItem {
* @author ndiechburg <noel@cblue.be>
**/
public function get_seriousgame_mode() {
if(self::debug>2){error_log('learnpathItem::get_seriousgame_mode()',0);}
if(self::debug>2){error_log('learnpathItem::get_seriousgame_mode()',0);}
$course_id = api_get_course_int_id();
if (!isset($this->seriousgame_mode)) {
if (!empty($this->lp_id)) {
@ -731,7 +731,7 @@ class learnpathItem {
//error_log(str_repeat(' ',$recursivity).'Analyse file '.$abs_path, 0);
$files_list = array();
$type = $this->get_type();
switch ($type) {
case TOOL_DOCUMENT :
case TOOL_QUIZ:
@ -741,9 +741,9 @@ class learnpathItem {
if (is_file($abs_path)) {
// for now, read the whole file in one go (that's gonna be a problem when the file is too big).
$info = pathinfo($abs_path);
$ext = $info['extension'];
switch (strtolower($ext)) {
case 'html':
case 'htm':
@ -754,13 +754,13 @@ class learnpathItem {
$file_content = file_get_contents($abs_path);
// Get an array of attributes from the HTML source.
$attributes = DocumentManager::parse_HTML_attributes($file_content, $wanted_attributes);
// Look at 'src' attributes in this file
// Look at 'src' attributes in this file
foreach ($wanted_attributes as $attr) {
if (isset($attributes[$attr])) {
// Find which kind of path these are (local or remote).
$sources = $attributes[$attr];
foreach ($sources as $source) {
// Skip what is obviously not a resource.
if (strpos($source, "+this.")) continue; // javascript code - will still work unaltered.
@ -769,7 +769,7 @@ class learnpathItem {
if (strpos($source, ';') && !strpos($source, '&amp;')) continue; // Avoid code - that should help.
if ($attr == 'value') {
if (strpos($source , 'mp3file')) {
if (strpos($source , 'mp3file')) {
$files_list[] = array(substr($source, 0, strpos($source , '.swf') + 4), 'local', 'abs');
$mp3file = substr($source , strpos($source , 'mp3file=') + 8);
if (substr($mp3file, 0, 1) == '/')
@ -777,7 +777,7 @@ class learnpathItem {
else
$files_list[] = array($mp3file, 'local', 'rel');
} elseif (strpos($source, 'flv=') === 0) {
$source = substr($source, 4);
if (strpos($source, '&') > 0) {
$source = substr($source, 0, strpos($source, '&'));
@ -796,7 +796,7 @@ class learnpathItem {
continue; // Skipping anything else to avoid two entries (while the others can have sub-files in their url, flv's can't).
}
}
if (strpos($source, '://') > 0) {
// Cut at '?' in a URL with params.
@ -898,7 +898,7 @@ class learnpathItem {
}
}
}
// Found some protocol there.
if (strpos($source, api_get_path(WEB_PATH)) !== false) {
// We found the current portal url.
@ -913,7 +913,7 @@ class learnpathItem {
}
} else {
// No protocol found, make link local.
if (substr($source, 0, 1) === '/') {
if (substr($source, 0, 1) === '/') {
// Link starts with a /, making it absolute (relative to DocumentRoot).
$files_list[] = array($source, 'local', 'abs');
$in_files_list[] = learnpathItem::get_resources_from_source(TOOL_DOCUMENT, $source, $recursivity + 1);
@ -930,15 +930,15 @@ class learnpathItem {
$files_list = array_merge($files_list, $in_files_list);
}
} else {
// No starting '/', making it relative to current document's path.
if (strpos($source, 'width=') || strpos($source, 'autostart=')) {
continue;
}
if (substr($source, 0, 2) == './') {
$source = substr($source, 2);
}
}
$files_list[] = array($source, 'local', 'rel');
$dir = dirname($abs_path);
$new_abs_path = realpath($dir.'/'.$source);
@ -975,7 +975,7 @@ class learnpathItem {
$checked_array_list[] = $files_list[$idx];
}
}
}
}
return $checked_array_list;
}
@ -1004,19 +1004,21 @@ class learnpathItem {
if (self::debug > 0) { error_log('learnpathItem::get_status() on item '.$this->db_id, 0); }
if ($check_db) {
if (self::debug > 2) { error_log('learnpathItem::get_status(): checking db', 0); }
$table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = "SELECT status FROM $table WHERE c_id = $course_id AND id = '".$this->db_item_view_id."' AND view_count = '".$this->get_attempt_id()."'";
if (self::debug > 2) { error_log('learnpathItem::get_status() - Checking DB: '.$sql, 0); }
if (!empty($this->db_item_view_id)) {
$table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql = "SELECT status FROM $table WHERE c_id = $course_id AND id = '".$this->db_item_view_id."' AND view_count = '".$this->get_attempt_id()."'";
if (self::debug > 2) { error_log('learnpathItem::get_status() - Checking DB: '.$sql, 0); }
$res = Database::query($sql);
if (Database::num_rows($res) == 1) {
$row = Database::fetch_array($res);
if ($update_local) {
$this->set_status($row['status']);
}
if (self::debug > 2) { error_log('learnpathItem::get_status() - Returning db value '.$row['status'], 0); }
return $row['status'];
}
$res = Database::query($sql);
if (Database::num_rows($res) == 1) {
$row = Database::fetch_array($res);
if ($update_local) {
$this->set_status($row['status']);
}
if (self::debug > 2) { error_log('learnpathItem::get_status() - Returning db value '.$row['status'], 0); }
return $row['status'];
}
}
} else {
if (self::debug > 2) { error_log('learnpathItem::get_status() - in get_status: using attrib', 0); }
if (!empty($this->status)) {
@ -1061,7 +1063,7 @@ class learnpathItem {
} else {
$start = $this->current_start_time;
$stop = $this->current_stop_time;
}
}
if (!empty($start)) {
if (!empty($stop)) {
$time = $stop - $start;
@ -1140,8 +1142,8 @@ class learnpathItem {
* @return string The item type (can be doc, dir, sco, asset)
*/
public function get_type() {
$res = 'asset';
if (!empty($this->type)) {
$res = 'asset';
if (!empty($this->type)) {
$res = $this->type;
}
if (self::debug > 2) { error_log('learnpathItem::get_type() - Returning '.$res.' for item '.$this->db_id, 0); }
@ -1533,7 +1535,7 @@ class learnpathItem {
} else {
if (self::debug > 1) { error_log('New LP - Prerequisite '.$prereqs_string.' complete', 0); }
}
//$returnstatus = true;
if ($returnstatus && $this->prevent_reinit == 1) {
// I would prefer check in the database.
@ -1562,38 +1564,6 @@ class learnpathItem {
if (self::debug > 1) { error_log('New LP - Prerequisite '.$prereqs_string.' complete', 0); }
}
}
//error_log('results :'.$items[$refs_list[$prereqs_string]]->path. ':'.$user_id);
/*$rs_quiz = Database::query($sql);
if ($quiz = Database :: fetch_array($rs_quiz)) {
if ($quiz['exe_result'] >= $items[$refs_list[$prereqs_string]]->get_mastery_score()) {
$returnstatus = true;
} else {
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
$returnstatus = false;
}
} else {
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
$returnstatus = false;
}*/
/*
$status = $items[$refs_list[$prereqs_string]]->get_status(true);
//error_log(print_r($items, 1));
//error_log($refs_list[$prereqs_string]);
$returnstatus = (($status == $this->possible_status[2]) OR ($status == $this->possible_status[3]));
if (!$returnstatus && empty($this->prereq_alert)) {
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
}
if(!$returnstatus){
if (self::debug > 1) { error_log('New LP - Prerequisite '.$prereqs_string.' not complete', 0); }
}else{
if (self::debug > 1) { error_log('New LP - Prerequisite '.$prereqs_string.' complete', 0); }
}
*/
//$returnstatus =false;
return $returnstatus;
}
} else {
@ -1701,7 +1671,7 @@ class learnpathItem {
* @return boolean True on success, false on failure
*/
public function save($from_outside = true, $prereqs_complete = false) {
if (self::debug > 0) { error_log('learnpathItem::save()', 0); }
if (self::debug > 0) { error_log('learnpathItem::save()', 0); }
// First check if parameters passed via GET can be saved here
// in case it's a SCORM, we should get:
if ($this->type == 'sco' || $this->type== 'au') {
@ -1888,10 +1858,10 @@ class learnpathItem {
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
// Get the lp_item_view with the highest view_count.
$sql = "SELECT * FROM $item_view_table
WHERE c_id = $course_id AND
$sql = "SELECT * FROM $item_view_table
WHERE c_id = $course_id AND
lp_item_id = ".$this->get_id()." AND
lp_view_id = ".$lp_view_id."
lp_view_id = ".$lp_view_id."
ORDER BY view_count DESC";
if (self::debug > 2) { error_log('learnpathItem::set_lp_view() - Querying lp_item_view: '.$sql, 0); }
@ -1902,9 +1872,9 @@ class learnpathItem {
$this->attempt_id = $row['view_count'];
$this->current_score = $row['score'];
$this->current_data = $row['suspend_data'];
$this->view_max_score = $row['max_score'];
$this->status = $row['status'];
$this->current_start_time = $row['start_time'];
$this->view_max_score = $row['max_score'];
$this->status = $row['status'];
$this->current_start_time = $row['start_time'];
$this->current_stop_time = $this->current_start_time + $row['total_time'];
$this->lesson_location = $row['lesson_location'];
$this->core_exit = $row['core_exit'];
@ -1966,7 +1936,7 @@ class learnpathItem {
* it, then set the status to 'passed'.
* @param float Score
* @return boolean True on success, false otherwise
*/
*/
public function set_score($score) {
//$possible_status = array('not attempted','incomplete','completed','passed','failed','browsed');
$debug = self::debug;
@ -1975,26 +1945,27 @@ class learnpathItem {
$this->current_score = $score;
$master = $this->get_mastery_score();
$current_status = $this->get_status(false);
//Fixes bug when SCORM doesn't send a mastery score even if they sent a score!
if ($master == -1) {
$master = $this->max_score;
}
if ($debug > 0) {
error_log('get_mastery_score: '.$master);
error_log('current_status: '.$current_status);
error_log('current score : '.$this->current_score);
}
// 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 ($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 ($debug > 0) error_log('Status changed to: '.$this->possible_status[4]);
$this->set_status($this->possible_status[4]); //failed
}
}*/
return true;
}
return false;
@ -2082,7 +2053,7 @@ class learnpathItem {
* @param string Time as given by SCORM
* @return void
*/
public function set_time($scorm_time, $format = 'scorm') {
public function set_time($scorm_time, $format = 'scorm') {
if (self::debug > 0) { error_log('learnpathItem::set_time('.$scorm_time.')', 0); }
if ($scorm_time == 0 and ($this->type != 'sco') and $this->current_start_time != 0) {
$my_time = time() - $this->current_start_time;
@ -2092,7 +2063,7 @@ class learnpathItem {
}
} else {
switch ($format) {
case 'scorm':
case 'scorm':
$res = array();
if (preg_match('/^(\d{1,4}):(\d{2}):(\d{2})(\.\d{1,4})?/', $scorm_time, $res)) {
$time = time();
@ -2200,16 +2171,16 @@ class learnpathItem {
public function scorm_update_time($total_sec = 0) {
if (self::debug > 0) error_log('Funcion called: scorm_update_time');
if (self::debug > 0) error_log("total_sec: $total_sec");
//Step 1 : get actual total time stored in db
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$course_id = api_get_course_int_id();
$get_view_sql = 'SELECT total_time, status FROM '.$item_view_table.'
WHERE c_id = '.$course_id.' AND lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
$result=Database::query($get_view_sql);
$row=Database::fetch_array($result);
if (!isset($row['total_time'])) {
$total_time = 0;
} else {
@ -2235,7 +2206,7 @@ class learnpathItem {
$result=Database::query($update_view_sql);
}
}
/**
* Set the total_time to 0 into db
**/
@ -2243,10 +2214,10 @@ class learnpathItem {
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$course_id = api_get_course_int_id();
$update_view_sql='UPDATE '.$item_view_table.' SET total_time = 0, start_time='.time().'
WHERE c_id = '.$course_id.' AND lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
WHERE c_id = '.$course_id.' AND lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
Database::query($update_view_sql);
}
/**
* Write objectives to DB. This method is separate from write_to_db() because otherwise
* objectives are lost as a side effect to AJAX and session concurrent access
@ -2312,37 +2283,37 @@ class learnpathItem {
*/
public function write_to_db() {
if (self::debug > 0) { error_log('learnpathItem::write_to_db()', 0); }
// Check the session visibility.
if (!api_is_allowed_to_session_edit()) {
if (self::debug > 0) { error_log('return false api_is_allowed_to_session_edit'); }
if (self::debug > 0) { error_log('return false api_is_allowed_to_session_edit'); }
return false;
}
$course_id = api_get_course_int_id();
$mode = $this->get_lesson_mode();
$credit = $this->get_credit();
//$my_verified_status=$this->get_status(false);
$item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$sql_verified = 'SELECT status FROM '.$item_view_table.'
WHERE c_id = '.$course_id.' AND lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
WHERE c_id = '.$course_id.' AND lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->get_attempt_id().'" ;';
$rs_verified = Database::query($sql_verified);
$row_verified = Database::fetch_array($rs_verified);
$my_case_completed = array('completed', 'passed', 'browsed', 'failed'); // Added by Isaac Flores.
$save = true;
if (isset($sql_verified['status'])) {
if (in_array($sql_verified['status'], $my_case_completed)) {
if (isset($row_verified) && isset($row_verified['status'])) {
if (in_array($row_verified['status'], $my_case_completed)) {
$save = false;
}
}
if ((($save === false && $this->type == 'sco') ||
if ((($save === false && $this->type == 'sco') ||
($this->type == 'sco' && ($credit == 'no-credit' OR $mode == 'review' OR $mode == 'browse'))
) && ($this->seriousgame_mode != 1 && $this->type == 'sco')
){
if (self::debug>1) {
){
if (self::debug>1) {
error_log("This info shouldn't be saved as the credit or lesson mode info prevent it");
error_log('learnpathItem::write_to_db() - credit('.$credit.') or lesson_mode('.$mode.') prevent recording!',0);
}
@ -2395,7 +2366,7 @@ class learnpathItem {
// Depending on what we want (really), we'll update or insert a new row
// now save into DB.
$res = 0;
if (!$inserted && Database::num_rows($check_res) < 1) {
if (!$inserted && Database::num_rows($check_res) < 1) {
$sql = "INSERT INTO $item_view_table " .
"(c_id, total_time, " .
"start_time, " .
@ -2520,7 +2491,7 @@ class learnpathItem {
$total_time = " total_time = total_time +".$this->get_total_time().", ";
}
}
}
}
}
if ($this->type == 'sco') { //IF scorm scorm_update_time has already updated total_tim in db
@ -2535,7 +2506,7 @@ class learnpathItem {
"WHERE c_id = $course_id AND lp_item_id = ".$this->db_id." " .
"AND lp_view_id = ".$this->view_id." " .
"AND view_count = ".$this->get_attempt_id();
} else {
} else {
$sql = "UPDATE $item_view_table " .
"SET " .$total_time.
" start_time = ".$this->get_current_start_time().", " .
@ -2554,7 +2525,7 @@ class learnpathItem {
if (self::debug > 2) { error_log('learnpathItem::write_to_db() - Updating item_view: '.$sql, 0); }
$res = Database::query($sql);
}
if (is_array($this->interactions) && count($this->interactions) > 0) {
// Save interactions.
$tbl = Database::get_course_table(TABLE_LP_ITEM_VIEW);
@ -2618,63 +2589,63 @@ class learnpathItem {
if (self::debug > 2) { error_log('End of learnpathItem::write_to_db()', 0); }
return true;
}
function add_audio() {
$course_info = api_get_course_info();
$filepath = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/';
if (!is_dir($filepath.'audio')) {
mkdir($filepath.'audio', api_get_permissions_for_new_directories());
$audio_id = add_document($course_info, '/audio', 'folder', 0, 'audio');
api_item_property_update($course_info, TOOL_DOCUMENT, $audio_id, 'FolderCreated', api_get_user_id(), null, null, null, null, api_get_session_id());
api_item_property_update($course_info, TOOL_DOCUMENT, $audio_id, 'invisible', api_get_user_id(), null, null, null, null, api_get_session_id());
api_item_property_update($course_info, TOOL_DOCUMENT, $audio_id, 'invisible', api_get_user_id(), null, null, null, null, api_get_session_id());
}
$key = 'file';
if (!isset($_FILES[$key]['name']) || !isset($_FILES[$key]['tmp_name'])) {
return false;
}
$result = DocumentManager::upload_document($_FILES, '/audio', null, null, 0, 'rename', false, false);
}
$result = DocumentManager::upload_document($_FILES, '/audio', null, null, 0, 'rename', false, false);
$file_path = null;
if ($result) {
$file_path = basename($result['path']);
$file_path = basename($result['path']);
// Store the mp3 file in the lp_item table.
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql_insert_audio = "UPDATE $tbl_lp_item SET audio = '".Database::escape_string($file_path)."'
$sql_insert_audio = "UPDATE $tbl_lp_item SET audio = '".Database::escape_string($file_path)."'
WHERE c_id = {$course_info['real_id']} AND id = '".Database::escape_string($this->db_id)."'";
Database::query($sql_insert_audio);
}
return $file_path;
return $file_path;
}
function add_audio_from_documents($doc_id) {
$course_info = api_get_course_info();
$course_info = api_get_course_info();
$document_data = DocumentManager::get_document_data_by_id($doc_id, $course_info['code']);
if (!empty($document_data)) {
$file_path = basename($document_data['path']);
if (!empty($document_data)) {
$file_path = basename($document_data['path']);
// Store the mp3 file in the lp_item table.
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql_insert_audio = "UPDATE $tbl_lp_item SET audio = '".Database::escape_string($file_path)."'
$sql_insert_audio = "UPDATE $tbl_lp_item SET audio = '".Database::escape_string($file_path)."'
WHERE c_id = {$course_info['real_id']} AND id = '".Database::escape_string($this->db_id)."'";
Database::query($sql_insert_audio);
}
return $file_path;
return $file_path;
}
function remove_audio() {
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$course_id = api_get_course_int_id();
$course_id = api_get_course_int_id();
if (empty($this->db_id)) {
return false;
}
$sql = "UPDATE $tbl_lp_item SET audio = '' WHERE c_id = $course_id AND id IN (".$this->db_id.")";
$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',
@ -2684,9 +2655,9 @@ class learnpathItem {
'browsed' => 'ScormBrowsed',
'not attempted' => 'ScormNotAttempted'
);
$my_lesson_status = get_lang($mylanglist[$status]);
switch ($status) {
case 'completed':
case 'browsed':
@ -2703,9 +2674,9 @@ class learnpathItem {
break;
default:
$class_status = 'default';
break;
break;
}
if ($decorate) {
if ($decorate) {
return Display::label($my_lesson_status, $class_status);
} else {
return $my_lesson_status;

@ -19,9 +19,6 @@ api_protect_course_script();
/* Libraries */
// The main_api.lib.php, database.lib.php and display.lib.php
// libraries are included by default.
require 'learnpath_functions.inc.php';
//include '../resourcelinker/resourcelinker.inc.php';
require 'resourcelinker.inc.php';

@ -285,7 +285,7 @@ if (isset($new_item_id) && is_numeric($new_item_id)) {
break;
case TOOL_DOCUMENT:
Display::display_confirmation_message(get_lang('NewDocumentCreated'));
echo $_SESSION['oLP']->display_item($new_item_id, true);
echo $_SESSION['oLP']->display_item($new_item_id);
break;
case TOOL_FORUM:
echo $_SESSION['oLP']->display_manipulate($new_item_id, $type);

@ -21,9 +21,6 @@ api_protect_course_script();
/* Libraries */
// The main_api.lib.php, database.lib.php and display.lib.php
// libraries are included by default.
include 'learnpath_functions.inc.php';
//include '../resourcelinker/resourcelinker.inc.php';
include 'resourcelinker.inc.php';
@ -36,7 +33,6 @@ $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
$isStudentView = (int) $_REQUEST['isStudentView'];
$learnpath_id = (int) $_REQUEST['lp_id'];
@ -46,7 +42,7 @@ $submit = $_POST['submit_button'];
// Using the resource linker as a tool for adding resources to the learning path.
if ($action == 'add' and $type == 'learnpathitem') {
$htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
$htmlHeadXtra[] = "<script> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
}
if ((!$is_allowed_to_edit) || ($isStudentView)) {
error_log('New LP - User not authorized in lp_admin_view.php');
@ -60,12 +56,6 @@ $sql_query = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_
$result = Database::query($sql_query);
$therow = Database::fetch_array($result);
//$admin_output = '';
/*
Course admin section
- all the functions not available for students - always available in this case (page only shown to admin)
*/
/* SHOWING THE ADMIN TOOLS */
if (isset($_SESSION['gradebook'])) {
@ -93,7 +83,92 @@ if (isset($_REQUEST['updateaudio'])) {
$show_learn_path = true;
$lp_theme_css = $_SESSION['oLP']->get_theme();
/* DISPLAY SECTION */
// POST action handling (uploading mp3, deleting mp3)
if (isset($_POST['save_audio'])) {
//Updating the lp.modified_on
$_SESSION['oLP']->set_modified_on();
// Deleting the audio fragments.
foreach ($_POST as $key => $value) {
if (substr($key, 0, 9) == 'removemp3') {
$lp_items_to_remove_audio[] = str_ireplace('removemp3', '', $key);
// Removing the audio from the learning path item.
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$in = implode(',', $lp_items_to_remove_audio);
}
}
if (count($lp_items_to_remove_audio)>0) {
$sql = "UPDATE $tbl_lp_item SET audio = '' WHERE c_id = $course_id AND id IN (".$in.")";
$result = Database::query($sql);
}
// Uploading the audio files.
foreach ($_FILES as $key => $value) {
if (substr($key, 0, 7) == 'mp3file' AND !empty($_FILES[$key]['tmp_name'])) {
// The id of the learning path item.
$lp_item_id = str_ireplace('mp3file', '', $key);
// Create the audio folder if it does not exist yet.
global $_course;
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
if (!is_dir($filepath.'audio')) {
mkdir($filepath.'audio', api_get_permissions_for_new_directories());
$audio_id = add_document($_course, '/audio', 'folder', 0, 'audio');
api_item_property_update($_course, TOOL_DOCUMENT, $audio_id, 'FolderCreated', api_get_user_id(), null, null, null, null, api_get_session_id());
}
// Check if file already exits into document/audio/
$file_name = $_FILES[$key]['name'];
$file_name = stripslashes($file_name);
// Add extension to files without one (if possible).
$file_name = add_ext_on_mime($file_name, $_FILES[$key]['type']);
$clean_name = replace_dangerous_char($file_name);
// No "dangerous" files.
$clean_name = disable_dangerous_file($clean_name);
$check_file_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/audio/'.$clean_name;
// If the file exists we generate a new name.
if (file_exists($check_file_path)) {
$filename_components = explode('.', $clean_name);
// Gettting the extension of the file.
$file_extension = $filename_components[count($filename_components) - 1];
// Adding something random to prevent overwriting.
$filename_components[count($filename_components) - 1] = time();
// Reconstructing the new filename.
$clean_name = implode($filename_components) .'.'.$file_extension;
// Using the new name in the $_FILES superglobal.
$_FILES[$key]['name'] = $clean_name;
}
// Upload the file in the documents tool.
include_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
$file_path = handle_uploaded_document($_course, $_FILES[$key], api_get_path(SYS_COURSE_PATH).$_course['path'].'/document','/audio', api_get_user_id(), '', '', '', '', false);
// Getting the filename only.
$file_components = explode('/', $file_path);
$file = $file_components[count($file_components) - 1];
// Store the mp3 file in the lp_item table.
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql_insert_audio = "UPDATE $tbl_lp_item SET audio = '".Database::escape_string($file)."'
WHERE c_id = $course_id AND id = '".Database::escape_string($lp_item_id)."'";
Database::query($sql_insert_audio);
}
}
//Display::display_confirmation_message(get_lang('ItemUpdated'));
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
header('Location: '.$url);
exit;
}
Display::display_header(null, 'Path');
$suredel = trim(get_lang('AreYouSureToDelete'));
?>
@ -206,8 +281,14 @@ function confirmation(name) {
</script>
<?php
/* DISPLAY SECTION */
echo $_SESSION['oLP']->build_action_menu();
echo '<div class="row-fluid">';
echo '<div class="span3">';
echo $_SESSION['oLP']->return_new_tree(null, true);
echo '</div>';
echo '<div class="span9">';
switch ($_GET['action']) {
case 'edit_item':
if (isset($is_success) && $is_success === true) {
@ -223,86 +304,8 @@ switch ($_GET['action']) {
break;
}
// POST action handling (uploading mp3, deleting mp3)
if (isset($_POST['save_audio'])) {
//Updating the lp.modified_on
$_SESSION['oLP']->set_modified_on();
// Deleting the audio fragments.
foreach ($_POST as $key => $value) {
if (substr($key, 0, 9) == 'removemp3') {
$lp_items_to_remove_audio[] = str_ireplace('removemp3', '', $key);
// Removing the audio from the learning path item.
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$in = implode(',', $lp_items_to_remove_audio);
}
}
if (count($lp_items_to_remove_audio)>0) {
$sql = "UPDATE $tbl_lp_item SET audio = '' WHERE c_id = $course_id AND id IN (".$in.")";
$result = Database::query($sql);
}
// Uploading the audio files.
foreach ($_FILES as $key => $value) {
if (substr($key, 0, 7) == 'mp3file' AND !empty($_FILES[$key]['tmp_name'])) {
// The id of the learning path item.
$lp_item_id = str_ireplace('mp3file', '', $key);
// Create the audio folder if it does not exist yet.
global $_course;
$filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/';
if (!is_dir($filepath.'audio')) {
mkdir($filepath.'audio', api_get_permissions_for_new_directories());
$audio_id = add_document($_course, '/audio', 'folder', 0, 'audio');
api_item_property_update($_course, TOOL_DOCUMENT, $audio_id, 'FolderCreated', api_get_user_id(), null, null, null, null, api_get_session_id());
}
// Check if file already exits into document/audio/
$file_name = $_FILES[$key]['name'];
$file_name = stripslashes($file_name);
// Add extension to files without one (if possible).
$file_name = add_ext_on_mime($file_name, $_FILES[$key]['type']);
$clean_name = replace_dangerous_char($file_name);
// No "dangerous" files.
$clean_name = disable_dangerous_file($clean_name);
$check_file_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/audio/'.$clean_name;
// If the file exists we generate a new name.
if (file_exists($check_file_path)) {
$filename_components = explode('.', $clean_name);
// Gettting the extension of the file.
$file_extension = $filename_components[count($filename_components) - 1];
// Adding something random to prevent overwriting.
$filename_components[count($filename_components) - 1] = time();
// Reconstructing the new filename.
$clean_name = implode($filename_components) .'.'.$file_extension;
// Using the new name in the $_FILES superglobal.
$_FILES[$key]['name'] = $clean_name;
}
// Upload the file in the documents tool.
include_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
$file_path = handle_uploaded_document($_course, $_FILES[$key], api_get_path(SYS_COURSE_PATH).$_course['path'].'/document','/audio', api_get_user_id(), '', '', '', '', false);
// Getting the filename only.
$file_components = explode('/', $file_path);
$file = $file_components[count($file_components) - 1];
// Store the mp3 file in the lp_item table.
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql_insert_audio = "UPDATE $tbl_lp_item SET audio = '".Database::escape_string($file)."'
WHERE c_id = $course_id AND id = '".Database::escape_string($lp_item_id)."'";
Database::query($sql_insert_audio);
}
}
Display::display_confirmation_message(get_lang('ItemUpdated'));
}
echo $_SESSION['oLP']->build_action_menu();
echo $_SESSION['oLP']->overview();
echo '</div>';
echo '</div>';
/* FOOTER */
Display::display_footer();

@ -12,12 +12,20 @@
/**
* Code
*/
// Flag to allow for anonymous user - needs to be set before global.inc.php.
// Flag to allow for anonymous user - needs to be set before global.inc.php
use \ChamiloSession as Session;
$use_anonymous = true;
// Name of the language file that needs to be included.
$language_file[] = 'learnpath';
require_once 'back_compat.inc.php';
require_once 'learnpath.class.php';
require_once 'scorm.class.php';
require_once 'aicc.class.php';
require_once 'learnpathItem.class.php';
require_once 'scormItem.class.php';
require_once 'aiccItem.class.php';
/**
* Get one item's details
@ -28,7 +36,7 @@ require_once 'back_compat.inc.php';
* @param integer New item ID
*/
function initialize_item($lp_id, $user_id, $view_id, $next_item) {
$debug = 0;
$debug = 10;
$return = '';
if ($debug > 0) { error_log('In initialize_item('.$lp_id.','.$user_id.','.$view_id.','.$next_item.')', 0); }
/*$item_id may be one of:
@ -38,39 +46,43 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
* -'last'
* - a real item ID
*/
require_once 'learnpath.class.php';
require_once 'scorm.class.php';
require_once 'aicc.class.php';
require_once 'learnpathItem.class.php';
require_once 'scormItem.class.php';
require_once 'aiccItem.class.php';
$mylp = '';
if (isset($_SESSION['lpobject'])) {
if ($debug > 1) { error_log('$_SESSION[lpobject] is set', 0); }
$oLP = unserialize($_SESSION['lpobject']);
$lpobject = Session::read('lpobject');
if (isset($lpobject)) {
$oLP = unserialize($lpobject);
if ($debug) error_log("lpobject was set");
if (!is_object($oLP)) {
if ($debug > 1) { error_log(print_r($oLP,true), 0); }
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);
if ($debug) error_log("Creating learnpath");
} else {
if ($debug > 1) { error_log('Reusing session LP', 0); }
$mylp = $oLP;
if ($debug) error_log("Loading learnpath from unserialize");
}
} else {
if ($debug) {
error_log("lpobject was not set");
}
}
$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 (is_object($mylp->items[$next_item])) {
if ($debug > 1) { error_log('In initialize_item - recovering existing item object '.$next_item, 0); }
$mylpi = $mylp->items[$next_item];
} else {
if ($debug > 1) { error_log('In initialize_item - generating new item object '.$next_item, 0); }
$mylpi = new learnpathItem($next_item, $user_id);
}
if ($mylpi) {
$mylpi->set_lp_view($view_id);
}
/*
* now get what's needed by the SCORM API:
* -score
@ -84,8 +96,8 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
$mymax = $mylpi->get_max();
if ($mymax === '') { $mymax = "''"; }
$mymin = $mylpi->get_min();
$mylesson_status = $mylpi->get_status();
$mylesson_status = $mylpi->get_status();
$mytotal_time = $mylpi->get_scorm_time('js', null, true);
$mymastery_score = $mylpi->get_mastery_score();
$mymax_time_allowed = $mylpi->get_max_time_allowed();
@ -102,24 +114,25 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
$myistring = substr($myistring, 1);
}
// Obtention des donnees d'objectifs
$mycoursedb = Database::get_course_table(TABLE_LP_IV_OBJECTIVE);
$course_id = api_get_course_int_id();
$mylp_iv_id = $mylpi->db_item_view_id;
$phpobjectives = array();
if (!empty($mylp_iv_id)) {
$sql = "SELECT objective_id, status, score_raw, score_max, score_min
FROM ".$mycoursedb."
WHERE lp_iv_id = ".$mylp_iv_id." AND c_id = $course_id
FROM $mycoursedb
WHERE lp_iv_id = $mylp_iv_id AND c_id = $course_id
ORDER BY id ASC;";
$res = Database::query($sql);
while ($row = Database::fetch_row($res)) {
$phpobjectives[] = $row;
$phpobjectives[] = $row;
}
}
$myobjectives = json_encode($phpobjectives);
$return .=
"olms.score=".$myscore.";" .
"olms.max=".$mymax.";" .
@ -183,7 +196,8 @@ function initialize_item($lp_id, $user_id, $view_id, $next_item) {
$mylp->set_error_msg('');
$mylp->prerequisites_match(); // Check the prerequisites are all complete.
if ($debug > 1) { error_log('Prereq_match() returned '.htmlentities($mylp->error), 0); }
if ($debug > 1) { error_log('Prereq_match() returned '.htmlentities($mylp->error), 0); }
if ($debug > 1) { error_log("return = $return "); }
return $return;
}
echo initialize_item($_POST['lid'], $_POST['uid'], $_POST['vid'], $_POST['iid']);

@ -61,7 +61,7 @@ function last_update_status($lp_id, $user_id, $view_id, $item_id) {
$mylp = new learnpath($code,$lp_id,$user_id);
} else {
if ($debug > 2) { error_log('Reusing session lp', 0); }
$mylp = & $oLP;
$mylp = $oLP;
}
}
error_log(__LINE__);

@ -11,6 +11,9 @@
/**
* Code
*/
use \ChamiloSession as Session;
// Flag to allow for anonymous user - needs to be set before global.inc.php.
$use_anonymous = true;
@ -42,54 +45,71 @@ require_once 'aiccItem.class.php';
* @param string Core exit SCORM string
*/
function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1, $min = -1, $status = '', $time = 0, $suspend = '', $location = '', $interactions = array(), $core_exit = 'none') {
global $_configuration;
$return = '';
$debug = 0;
if ($debug > 0) {
$return = null;
$debug = 10;
if ($debug > 0) {
error_log('lp_ajax_save_item.php : save_item() params: ');
error_log("item_id: $item_id");
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");
}
}
$mylp = null;
if (isset($_SESSION['lpobject'])) {
$oLP = unserialize($_SESSION['lpobject']);
if (!is_object($oLP)) {
$lpobject = Session::read('lpobject');
if (isset($lpobject)) {
$oLP = unserialize($lpobject);
if ($debug) error_log("lpobject was set");
if (!is_object($oLP)) {
unset($oLP);
$code = api_get_course_id();
$mylp = new learnpath($code, $lp_id, $user_id);
if ($debug) error_log("Creating learnpath");
} else {
$mylp = & $oLP;
$mylp = $oLP;
if ($debug) error_log("Loading learnpath from unserialize");
}
} else {
if ($debug) {
error_log("lpobject was not set");
}
}
if (!is_a($mylp, 'learnpath')) {
if ($debug) {
error_log("mylp variable is not an learnpath object");
}
}
if (!is_a($mylp, 'learnpath')) {
return '';
return null;
}
$prereq_check = $mylp->prerequisites_match($item_id);
$mylpi = $mylp->items[$item_id];
$mylpi = $mylp->items[$item_id];
if (empty($mylpi)) {
if ($debug > 0) {
error_log("item #$item_id not found in the items array: ".print_r($mylp->items, 1));
}
return false;
}
//This functions sets the $this->db_item_view_id variable needed in get_status() see BT#5069
$mylpi->set_lp_view($view_id);
if ($prereq_check === true) {
if ($debug > 1) { error_log('Prereq are check'); }
// Launch the prerequisites check and set error if needed
// Launch the prerequisites check and set error if needed
if (isset($max) && $max != -1) {
$mylpi->max_score = $max;
$mylpi->set_max_score($max);
if ($debug > 1) { error_log("Setting max_score: $max"); }
}
if (isset($min) && $min != -1 && $min != 'undefined') {
$mylpi->min_score = $min;
if ($debug > 1) { error_log("Setting min_score: $min"); }
}
//set_score function already saves the status
if (isset($score) && $score != -1) {
if ($debug > 1) { error_log('Calling set_score('.$score.')', 0); }
@ -98,33 +118,20 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
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') {
//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
//@todo remove the switch
switch ($status) {
case 'failed':
case 'passed':
$mylpi->set_status($status);
//if ($debug > 1) { error_log("Cant't set status to these values only if a score was set"); }
break;
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); }
break;
}
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); }
} else {
if ($debug > 1) { error_log("Status not updated"); }
}
}
// Hack to set status to completed for hotpotatoes if score > 80%.
$my_type = $mylpi->get_type();
if ($my_type == 'hotpotatoes') {
if ((empty($status) || $status == 'undefined' || $status == 'not attempted') && $max > 0) {
if (($score/$max) > 0.8) {
@ -140,13 +147,13 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
if ($debug > 1) { error_log('Done calling set_status for hotpotatoes - now '.$mylpi->get_status(false), 0); }
}
}
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) {
if ($debug > 1) { error_log("Time is INT"); }
$real_time = time() - $time;
$real_time = time() - $time;
if ($debug > 1) { error_log('Calling $real_time '.$real_time.' ', 0); }
$mylpi->set_time($real_time, 'int');
} else {
@ -158,15 +165,15 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
} else {
$time = $mylpi->get_total_time();
}
if (isset($suspend) && $suspend != '' && $suspend != 'undefined') {
$mylpi->current_data = $suspend; //escapetxt($suspend);
}
if (isset($location) && $location != '' && $location!='undefined') {
$mylpi->set_lesson_location($location);
}
// Deal with interactions provided in arrays in the following format:
// id(0), type(1), time(2), weighting(3), correct_responses(4), student_response(5), result(6), latency(7)
if (is_array($interactions) && count($interactions) > 0) {
@ -177,19 +184,21 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
$mylpi->add_interaction($index, $clean_interaction);
}
}
if ($core_exit != 'undefined') {
$mylpi->set_core_exit($core_exit);
}
$mylp->save_item($item_id, false);
} else {
} else {
if ($debug) {
error_log("prereq_check: ".intval($prereq_check));
}
return $return;
}
$mystatus_in_db = $mylpi->get_status(true);
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);
if ($mystatus_in_memory != $mystatus_in_db) {
@ -200,35 +209,34 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
} else {
$mystatus = $mystatus_in_db;
}
$mytotal = $mylp->get_total_items_count_without_chapters();
$mycomplete = $mylp->get_complete_items_count();
$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("progress: $mycomplete / $mytotal", 0); }
$_SESSION['lpobject'] = serialize($mylp);
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') {
// If this object's JS status has not been updated by the SCORM API, update now.
// If this object's JS status has not been updated by the SCORM API, update now.
$return .= "olms.lesson_status='".$mystatus."';";
}
}
$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.
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');";
if ($debug > 0) {
if ($debug > 0) {
$return .= "logit_lms('Saved data for item ".$item_id.", user ".$user_id." (status=".$mystatus.")',2);";
if ($debug > 1) { error_log('End of save_item()', 0); }
}
if (!isset($_SESSION['login_as'])) {
@ -236,8 +244,8 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql_last_connection = "SELECT login_id, login_date
FROM $tbl_track_login
WHERE login_user_id='".api_get_user_id()."'
FROM $tbl_track_login
WHERE login_user_id='".api_get_user_id()."'
ORDER BY login_date DESC LIMIT 0,1";
$q_last_connection = Database::query($sql_last_connection);
@ -253,11 +261,13 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
if ($mylp->get_type() == 2) {
$return .= "update_stats();";
}
//To be sure progress is updated
$mylp->save_last();
if ($debug > 0) { error_log('lp_ajax_save_item.php : save_item end ----- '); }
return $return;
Session::write('lpobject', serialize($mylp));
if ($debug > 0) { error_log('---------------- lp_ajax_save_item.php : save_item end ----- '); }
return $return;
}
$interactions = array();
@ -285,4 +295,4 @@ echo save_item(
(!empty($_REQUEST['suspend'])?$_REQUEST['suspend']:null),
(!empty($_REQUEST['loc'])?$_REQUEST['loc']:null),
$interactions,
(!empty($_REQUEST['core_exit'])?$_REQUEST['core_exit']:''));
(!empty($_REQUEST['core_exit'])?$_REQUEST['core_exit']:''));

@ -50,7 +50,7 @@ function save_objectives($lp_id, $user_id, $view_id, $item_id, $objectives = arr
$mylp = new learnpath($code, $lp_id, $user_id);
}else{
if ($debug > 2) { error_log('Reusing session lp', 0); }
$mylp = & $oLP;
$mylp = $oLP;
}
}
$mylpi =& $mylp->items[$item_id];

@ -57,7 +57,7 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
$mylp = new learnpath($code,$lp_id,$user_id);
} else {
if ($debug > 1) { error_log('Reusing session lp', 0); }
$mylp = & $oLP;
$mylp = $oLP;
}
}
$new_item_id = 0;
@ -99,7 +99,7 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
}
//$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];
$mylpi = $mylp->items[$new_item_id];
} else {
if ($debug > 1) { error_log('In switch_item_details - generating new item object', 0); }
$mylpi = new learnpathItem($new_item_id, $user_id);

@ -48,7 +48,7 @@ function switch_item_toc($lp_id, $user_id, $view_id, $current_item, $next_item)
$mylp = new learnpath($code, $lp_id, $user_id);
} else {
if ($debug > 1) { error_log('Reusing session lp', 0); }
$mylp = & $oLP;
$mylp = $oLP;
}
}
$new_item_id = 0;
@ -89,7 +89,7 @@ function switch_item_toc($lp_id, $user_id, $view_id, $current_item, $next_item)
$mylp->save_current();
}
if (is_object($mylp->items[$new_item_id])) {
$mylpi = & $mylp->items[$new_item_id];
$mylpi = $mylp->items[$new_item_id];
} else {
if ($debug > 1) { error_log('In switch_item_details - generating new item object', 0); }
$mylpi = new learnpathItem($new_item_id, $user_id);

@ -85,7 +85,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
$mylp = new learnpath($code, $lp_id, $user_id);
} else {
if ($debug > 2) { error_log('Reusing session lp', 0); }
$mylp = & $oLP;
$mylp = $oLP;
}
}
//$objResponse->addAlert(api_get_path(REL_CODE_PATH).'newscorm/learnpathItem.class.php');
@ -217,7 +217,7 @@ function save_objectives($lp_id, $user_id, $view_id, $item_id, $objectives = arr
$mylp = new learnpath($code,$lp_id,$user_id);
} else {
if ($debug > 2) { error_log('Reusing session lp', 0); }
$mylp = & $oLP;
$mylp = $oLP;
}
}
$mylpi =& $mylp->items[$item_id];
@ -271,7 +271,7 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
$mylp = new learnpath($code,$lp_id,$user_id);
} else {
if ($debug > 1) { error_log('Reusing session lp', 0); }
$mylp = & $oLP;
$mylp = $oLP;
}
}
$new_item_id = 0;
@ -313,7 +313,7 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it
}
//$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];
$mylpi = $mylp->items[$new_item_id];
} else {
if ($debug > 1) { error_log('In switch_item_details - generating new item object', 0); }
$mylpi = new learnpathItem($new_item_id, $user_id);

@ -197,6 +197,9 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $
}
if ($debug > 0) error_log('New LP - Passed oLP creation check', 0);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
/**
* Actions switching
*/
@ -213,9 +216,15 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
$_REQUEST['action'] = 'list';
}
}
} else {
if ($is_allowed_to_edit) {
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'view') {
$_REQUEST['action'] = 'build';
}
}
}
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$action = (!empty($_REQUEST['action']) ? $_REQUEST['action'] : '');
@ -254,9 +263,10 @@ switch ($action) {
} else {
// For all other item types than documents, load the item using the item type and path rather than its ID.
$new_item_id = $_SESSION['oLP']->add_item($_POST['parent'], $_POST['previous'], $_POST['type'], $_POST['path'], $_POST['title'], $_POST['description'], $_POST['prerequisites'], $_POST['maxTimeAllowed']);
}
// Display.
require 'lp_add_item.php';
}
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
header('Location: '.$url);
exit;
}
} else {
require 'lp_add_item.php';
@ -337,7 +347,10 @@ switch ($action) {
if (is_numeric($new_lp_id)) {
// TODO: Maybe create a first module directly to avoid bugging the user with useless queries
$_SESSION['oLP'] = new learnpath(api_get_course_id(),$new_lp_id,api_get_user_id());
require 'lp_build.php';
//require 'lp_build.php';
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id);
header('Location: '.$url);
exit;
}
}
} else {
@ -380,7 +393,10 @@ switch ($action) {
if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; }
else {
$_SESSION['refresh'] = 1;
require 'lp_build.php';
//require 'lp_build.php';
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
header('Location: '.$url);
exit;
}
break;
case 'edit_item':
@ -397,18 +413,21 @@ switch ($action) {
//Updating the lp.modified_on
$_SESSION['oLP']->set_modified_on();
//$_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description'], $_POST['prerequisites']);
// TODO: mp3 edit
$audio = array();
if (isset($_FILES['mp3'])) $audio = $_FILES['mp3'];
$_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description'], $_POST['prerequisites'], $audio, $_POST['maxTimeAllowed']);
if (isset($_FILES['mp3'])) {
$audio = $_FILES['mp3'];
}
$_SESSION['oLP']->edit_item($_REQUEST['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description'], $_POST['prerequisites'], $audio, $_POST['maxTimeAllowed']);
if (isset($_POST['content_lp'])) {
$_SESSION['oLP']->edit_document($_course);
}
$is_success = true;
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
header('Location: '.$url);
exit;
}
if (isset($_GET['view']) && $_GET['view'] == 'build') {
require 'lp_edit_item.php';
@ -423,7 +442,6 @@ switch ($action) {
api_not_allowed(true);
}
if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0);
if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; }
else {
if (isset($_POST['submit_button'])) {
@ -435,7 +453,10 @@ switch ($action) {
$is_success = true;
}
}
require 'lp_edit_item_prereq.php';
//require 'lp_edit_item_prereq.php';
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
header('Location: '.$url);
exit;
}
break;
@ -453,7 +474,9 @@ switch ($action) {
$_SESSION['oLP']->set_modified_on();
$_SESSION['oLP']->edit_item($_GET['id'], $_POST['parent'], $_POST['previous'], $_POST['title'], $_POST['description']);
$is_success = true;
$is_success = true;
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
header('Location: '.$url);
}
if (isset($_GET['view']) && $_GET['view'] == 'build') {
require 'lp_move_item.php';
@ -609,7 +632,6 @@ switch ($action) {
require 'lp_edit.php';
}
break;
case 'update_lp':
if (!$is_allowed_to_edit) {
api_not_allowed(true);
@ -644,7 +666,6 @@ switch ($action) {
$_SESSION['oLP']->set_prerequisite($_REQUEST['prerequisites']);
$_SESSION['oLP']->set_use_max_score($_REQUEST['use_max_score']);
if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) {
$publicated_on = $_REQUEST['publicated_on'];
$publicated_on = $publicated_on['Y'].'-'.$publicated_on['F'].'-'.$publicated_on['d'].' '.$publicated_on['H'].':'.$publicated_on['i'].':00';
@ -687,11 +708,12 @@ switch ($action) {
}
}
}
}
require 'lp_build.php';
}
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id);
header('Location: '.$url);
exit;
}
break;
case 'add_sub_item': // Add an item inside a chapter.
if (!$is_allowed_to_edit) {
api_not_allowed(true);

@ -16,7 +16,6 @@ $this_section = SECTION_COURSES;
event_access_tool(TOOL_LEARNPATH);
api_protect_course_script();
//if (! $is_allowed_in_course) api_not_allowed();
if (isset($_SESSION['gradebook'])) {
$gradebook = $_SESSION['gradebook'];
@ -32,7 +31,7 @@ $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => g
$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=".$_SESSION['oLP']->get_id(), 'name' => $_SESSION['oLP']->get_name());
//$interbreadcrumb[] = array('url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id", 'name' => get_lang('NewStep'));
$htmlHeadXtra[] = '<script type="text/javascript">
$htmlHeadXtra[] = '<script>
function activate_start_date() {
if(document.getElementById(\'start_date_div\').style.display == \'none\') {
document.getElementById(\'start_date_div\').style.display = \'block\';
@ -56,26 +55,7 @@ Display::display_header(get_lang('CourseSettings'), 'Path');
echo $_SESSION['oLP']->build_action_menu();
// Action links
//echo '<div class="actions">';
$gradebook = isset($_GET['gradebook']) ? Security::remove_XSS($_GET['gradebook']) : null;
//echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=build&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '" title="'.get_lang('Build').'">'.Display::return_icon('build_learnpath.png', get_lang('Build'),'',ICON_SIZE_MEDIUM).'</a>';
//echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=admin_view&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '" title="'.get_lang('BasicOverview').'">'.Display::return_icon('move_learnpath.png', get_lang('BasicOverview'),'',ICON_SIZE_MEDIUM).'</a>';
//echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=view&lp_id='.Security::remove_XSS($_GET['lp_id']).'">'.Display::return_icon('view_remove.png', get_lang('Display'),'',ICON_SIZE_MEDIUM).'</a>';
//echo ' '.Display::return_icon('i.gif');
/*echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=add_item&amp;type=step&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '" title="'.get_lang('NewStep').'">
'.Display::return_icon('add.png', get_lang('NewStep'),'',ICON_SIZE_MEDIUM).'</a>';*/
/*echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=add_item&amp;type=chapter&amp;lp_id=' . Security::remove_XSS($_GET['lp_id']) . '" title="'.get_lang('NewChapter').'">
'.Display::return_icon('add_learnpath_section.png', get_lang('NewChapter'),'',ICON_SIZE_MEDIUM).'</a>';*/
//echo '<a href="lp_controller.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;gradebook='.$gradebook.'&amp;action=admin_view&amp;lp_id='.Security::remove_XSS($_GET['lp_id']).'&amp;updateaudio=true">'.Display::return_icon('upload_audio.png', get_lang('UpdateAllAudioFragments'),'',ICON_SIZE_MEDIUM).'</a>';
//echo Display::url(Display::return_icon('settings_na.png', get_lang('CourseSettings'),'',ICON_SIZE_MEDIUM), '#');
//echo '<a href="../newscorm/lp_controller.php?cidReq='.$_course['sysCode'].'">'.Display::return_icon('scorms_na.png',get_lang('ReturnToLearningPaths'),'',ICON_SIZE_MEDIUM).'</a>';
//echo '</div>';
$defaults=array();
$form = new FormValidator('form1', 'post', 'lp_controller.php');
@ -95,7 +75,7 @@ $form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required');
// Encoding
/* // Chamilo 1.8.8: Deprecated code.
$encoding_select = &$form->addElement('select', 'lp_encoding', get_lang('Charset'));
$encoding_select = $form->addElement('select', 'lp_encoding', get_lang('Charset'));
$encodings = array('UTF-8','ISO-8859-1','ISO-8859-15','cp1251','cp1252','KOI8-R','BIG5','GB2312','Shift_JIS','EUC-JP');
foreach ($encodings as $encoding) {
if (api_equal_encodings($encoding, $_SESSION['oLP']->encoding)) {
@ -108,7 +88,7 @@ $form->addElement('hidden', 'lp_encoding');
// Origin
/*
$origin_select = &$form->addElement('select', 'lp_maker', get_lang('Origin'));
$origin_select = $form->addElement('select', 'lp_maker', get_lang('Origin'));
$lp_orig = $_SESSION['oLP']->get_maker();
include 'content_makers.inc.php';
@ -120,7 +100,7 @@ foreach ($content_origins as $origin) {
}
// Content proximity
$content_proximity_select = &$form->addElement('select', 'lp_proximity', get_lang('ContentProximity'));
$content_proximity_select = $form->addElement('select', 'lp_proximity', get_lang('ContentProximity'));
$lp_prox = $_SESSION['oLP']->get_proximity();
if ($lp_prox != 'local') {
$s_selected_proximity = 'remote';
@ -131,12 +111,12 @@ $content_proximity_select->addOption(get_lang('Local'), 'local');
$content_proximity_select->addOption(get_lang('Remote'), 'remote');
*/
//Hide toc frame
$hide_toc_frame = &$form->addElement('checkbox', 'hide_toc_frame', null, get_lang('HideTocFrame'),array('onclick' => '$("#lp_layout_column").toggle()' ));
$hide_toc_frame = $form->addElement('checkbox', 'hide_toc_frame', null, get_lang('HideTocFrame'),array('onclick' => '$("#lp_layout_column").toggle()' ));
if (api_get_setting('allow_course_theme') == 'true') {
$mycourselptheme = api_get_course_setting('allow_learning_path_theme');
if (!empty($mycourselptheme) && $mycourselptheme!=-1 && $mycourselptheme== 1) {
//LP theme picker
$theme_select = &$form->addElement('select_theme', 'lp_theme', get_lang('Theme'));
$theme_select = $form->addElement('select_theme', 'lp_theme', get_lang('Theme'));
$form->applyFilter('lp_theme', 'trim');
$s_theme = $_SESSION['oLP']->get_theme();

@ -21,9 +21,6 @@ api_protect_course_script();
/* Libraries */
// The main_api.lib.php, database.lib.php and display.lib.php
// libraries are included by default.
include 'learnpath_functions.inc.php';
//include '../resourcelinker/resourcelinker.inc.php';
include 'resourcelinker.inc.php';
@ -34,7 +31,7 @@ $language_file = 'learnpath';
/* Header and action code */
$htmlHeadXtra[] = '
<script type="text/javascript">
<script>
function FCKeditor_OnComplete( editorInstance ) {
document.getElementById(\'frmModel\').innerHTML = "<iframe height=890px; width=230px; frameborder=0 src=\''.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/fckdialogframe.html \'>";
@ -48,7 +45,9 @@ function InnerDialogLoaded() {
var B=new window.frames[0].FCKToolbarButton(\'Templates\',window.frames[0].FCKLang.Templates);
}
return B.ClickFrame();
$};'.$_SESSION['oLP']->get_js_dropdown_array().'</script>';
$};'.$_SESSION['oLP']->get_js_dropdown_array().'
</script>';
/* Constants and variables */
@ -92,7 +91,7 @@ if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array (
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook')
);
);
}
$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}"));
@ -106,7 +105,7 @@ Display::display_header(get_lang('Edit'),'Path');
$suredel = trim(get_lang('AreYouSureToDelete'));
?>
<script type='text/javascript'>
<script>
/* <![CDATA[ */
function stripslashes(str) {
str=str.replace(/\\'/g,'\'');
@ -131,7 +130,6 @@ function confirmation(name) {
echo $_SESSION['oLP']->build_action_menu();
echo '<div class="row-fluid">';
echo '<div class="span3">';

@ -286,7 +286,6 @@ if (!empty($flat_list)) {
//"</a>";
}*/
// EDIT LP
if ($current_session == $details['lp_session']) {
$dsp_edit_lp = '<a href="lp_controller.php?'.api_get_cidreq().'&action=edit&lp_id='.$id.'">'.Display::return_icon('settings.png', get_lang('CourseSettings'),'',ICON_SIZE_SMALL).'</a>';
@ -297,7 +296,7 @@ if (!empty($flat_list)) {
// BUILD
if ($current_session == $details['lp_session']) {
if ($details['lp_type'] == 1 || $details['lp_type'] == 2) {
$dsp_build = '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=build&amp;lp_id='.$id.'">'.Display::return_icon('edit.png', get_lang('LearnpathEditLearnpath'),'',ICON_SIZE_SMALL).'</a>';
$dsp_build = '<a href="lp_controller.php?'.api_get_cidreq().'&amp;action=add_item&amp;type=step&amp;lp_id='.$id.'">'.Display::return_icon('edit.png', get_lang('LearnpathEditLearnpath'),'',ICON_SIZE_SMALL).'</a>';
} else {
$dsp_build = Display::return_icon('edit_na.png', get_lang('LearnpathEditLearnpath'),'',ICON_SIZE_SMALL);
}

@ -22,9 +22,9 @@ require_once 'learnpath.class.php';
require_once 'scorm.class.php';
require_once 'aicc.class.php';
$htmlHeadXtra[] = '<script type="text/javascript">
$htmlHeadXtra[] = '<script>
var chamilo_xajax_handler = window.parent.oxajax;
</script>';
</script>';
$progress_bar = '';
$navigation_bar = '';
@ -43,12 +43,11 @@ if (isset($_SESSION['lpobject'])) {
$display_mode = $_SESSION['oLP']->mode;
$scorm_css_header = true;
$lp_theme_css = $_SESSION['oLP']->get_theme();
$my_style = api_get_visual_theme();
//Setting up the CSS theme if exists
$mycourselptheme = null;
if (api_get_setting('allow_course_theme') == 'true') {
$mycourselptheme = api_get_course_setting('allow_learning_path_theme');
@ -59,7 +58,7 @@ if (isset($_SESSION['lpobject'])) {
} else {
$lp_theme_css = $my_style;
}
$progress_bar = $_SESSION['oLP']->get_progress_bar('', -1, '', true);
$navigation_bar = $_SESSION['oLP']->get_navigation_bar();
$mediaplayer = $_SESSION['oLP']->get_mediaplayer($autostart);

@ -90,10 +90,10 @@ var chamilo_xajax_handler = window.oxajax;
</script>';
if ($_SESSION['oLP']->mode == 'embedframe' || $_SESSION['oLP']->get_hide_toc_frame()==1 ) {
$htmlHeadXtra[] = '<script>
$htmlHeadXtra[] = '<script>
$(document).ready(function(){
toogle_minipanel();
});
});
</script>';
}
@ -127,9 +127,9 @@ $htmlHeadXtra[] = '<script type="text/javascript" src="js/storageapi.js"></scrip
* Get a link to the corresponding document.
*/
if ($debug) {
if ($debug) {
error_log(" src: $src ");
error_log(" lp_type: $lp_type ");
error_log(" lp_type: $lp_type ");
}
$get_toc_list = $_SESSION['oLP']->get_toc();
@ -154,7 +154,7 @@ if (!isset($src)) {
//Prevents FF 3.6 + Adobe Reader 9 bug see BT#794 when calling a pdf file in a LP.
$file_info = parse_url($src);
$file_info = pathinfo($file_info['path']);
if (api_strtolower(substr($file_info['extension'], 0, 3) == 'pdf')) {
if (api_strtolower(substr($file_info['extension'], 0, 3) == 'pdf')) {
$src = api_get_path(WEB_CODE_PATH).'newscorm/lp_view_item.php?lp_item_id='.$lp_item_id;
}
$_SESSION['oLP']->start_current_item(); // starts time counter manually if asset
@ -240,7 +240,7 @@ if ($type_quiz && !empty($_REQUEST['exeId']) && isset($lp_id) && isset($_GET['lp
$lp_item_view_id = $row_last_attempt[0];
$sql_upd_score = "UPDATE $TBL_LP_ITEM_VIEW SET status = 'completed' , score = $score, total_time = $mytime
WHERE id='".$lp_item_view_id."' AND c_id = $course_id ";
if ($debug) error_log($sql_upd_score);
Database::query($sql_upd_score);
@ -315,26 +315,54 @@ if (Database::num_rows($res_media) > 0) {
if (!empty($row_media['audio'])) {$show_audioplayer = true; break;}
}
}
?>
<div id="learning_path_main" style="width:100%;height:100%;">
<div id="learning_path_left_zone" style="<?php echo $display_none;?>">
<!-- header -->
<div id="header">
/*
*
* <?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>
<div id="log_content_cleaner" style="cursor: pointer; color:blue;"><?php echo get_lang('Clean'); ?></div>
</div>
<!-- end log message layout -->
<?php } ?>
*/
echo '<div id="learning_path_main" style="width:100%;height:100%;">';
$is_allowed_to_edit = api_is_allowed_to_edit(null, true, false, false);
if ($is_allowed_to_edit) {
echo '<div id="learning_path_breadcrumb_zone">';
global $interbreadcrumb;
$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list&isStudentView=false', 'name' => get_lang('LearningPaths'));
$interbreadcrumb[] = array('url' => api_get_self()."?action=add_item&type=step&lp_id=".$_SESSION['oLP']->lp_id."&isStudentView=false", 'name' => $_SESSION['oLP']->get_name());
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Preview'));
//$interbreadcrumb[] = array('type' => 'right', 'url' => api_get_self()."?action=add_item&type=step&lp_id=".$_SESSION['oLP']->lp_id."&isStudentView=false", 'name' => get_lang('Edit'), 'class' => 'btn btn-mini btn-warning');
echo return_breadcrumb($interbreadcrumb, null, null);
echo '</div>';
}
echo '<div id="learning_path_left_zone" style="'.$display_none.'"> ';
echo '<div id="header">
<table>
<tr>
<td>
<a href="lp_controller.php?action=return_to_course_homepage&<?php echo api_get_cidreq(); ?>" target="_self" onclick="javascript: window.parent.API.save_asset();">
<td>';
echo '<a href="lp_controller.php?action=return_to_course_homepage&'.api_get_cidreq().'" target="_self" onclick="javascript: window.parent.API.save_asset();">
<img src="../img/lp_arrow.gif" />
</a>
</td>
<td>
<a class="link" href="lp_controller.php?action=return_to_course_homepage&<?php echo api_get_cidreq(); ?>" target="_self" onclick="javascript: window.parent.API.save_asset();">
<?php echo get_lang('CourseHomepageLink'); ?></a>
<td>';
if ($is_allowed_to_edit) {
echo '<a class="link" href="lp_controller.php?isStudentView=false&action=return_to_course_homepage&'.api_get_cidreq().'" target="_self" onclick="javascript: window.parent.API.save_asset();">';
} else {
echo '<a class="link" href="lp_controller.php?action=return_to_course_homepage&'.api_get_cidreq().'" target="_self" onclick="javascript: window.parent.API.save_asset();">';
}
echo get_lang('CourseHomepageLink').'
</a>
</td>
</tr>
</table>
</div>
</div>';
?>
<!-- end header -->
<!-- Author image preview -->
@ -366,36 +394,26 @@ if (Database::num_rows($res_media) > 0) {
</div>
<!-- media player layout -->
<?php
<?php
if ($show_audioplayer) {
echo '<div id="lp_media_file">';
echo '<div id="lp_media_file">';
echo $mediaplayer;
echo '</div>';
}
?>
}
?>
<!-- end media player layout -->
<!-- TOC layout -->
<div id="toc_id" name="toc_name" style="overflow: auto; padding:0;margin-top:0px;width:100%;float:left">
<div id="learning_path_toc">
<?php echo $_SESSION['oLP']->get_html_toc($get_toc_list); ?>
<?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>
<div id="log_content_cleaner" style="cursor: pointer; color:blue;"><?php echo get_lang('Clean'); ?></div>
</div>
<!-- end log message layout -->
<?php } ?>
</div>
</div>
<!-- end TOC layout -->
</div>
<!-- end left Zone -->
<!-- end left zone -->
<!-- right Zone -->
<!-- right zone -->
<div id="learning_path_right_zone" style="margin-left:<?php echo $margin_left;?>;height:100%">
<?php
// hub 26-05-2010 Fullscreen or not fullscreen
@ -418,12 +436,12 @@ if (Database::num_rows($res_media) > 0) {
var hauteurHeader = document.getElementById('header').offsetHeight;
var hauteurAuthorImg = document.getElementById('author_image').offsetHeight;
var hauteurAuthorName = document.getElementById('author_name').offsetHeight;
var hauteurMedia = 0;
if ($("#lp_media_file").length != 0) {
hauteurMedia = document.getElementById('lp_media_file').offsetHeight;
}
var hauteurTitre = document.getElementById('scorm_title').offsetHeight;
var hauteurAction = 0;
if (document.getElementById('actions_lp')) hauteurAction = document.getElementById('actions_lp').offsetHeight;
@ -450,7 +468,7 @@ if (Database::num_rows($res_media) > 0) {
{type:"script", id:"_fr4", src:"<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.min.js"},
{type:"stylesheet", id:"_fr5", src:"<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.css"},
{type:"script", id:"_fr2", src:"<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery.highlight.js"}
] }
);
<?php
@ -462,9 +480,9 @@ if (Database::num_rows($res_media) > 0) {
{ load: [
{type:"script", id:"_fr1", src:"<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery.min.js"},
{type:"script", id:"_fr4", src:"<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.min.js"},
{type:"stylesheet", id:"_fr5", src:"<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.css"},
{type:"stylesheet", id:"_fr5", src:"<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery-ui/smoothness/jquery-ui-1.8.21.custom.css"},
{type:"script", id:"_fr2", src:"<?php echo api_get_path(WEB_LIBRARY_PATH); ?>javascript/jquery.highlight.js"}
] }
);
<?php

@ -53,6 +53,8 @@ if (isset($_GET['lp_item_id'])) {
}
}
$mode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'fullpage';
/* INIT SECTION */
$_SESSION['whereami'] = 'lp/build';
@ -61,9 +63,6 @@ if (isset($_SESSION['oLP']) && isset($_GET['id'])) {
}
$this_section = SECTION_COURSES;
/* Libraries */
$language_file = "learnpath";
/* Header and action code */
@ -79,7 +78,7 @@ $learnpath_id = (int) $_REQUEST['lp_id'];
// Using the resource linker as a tool for adding resources to the learning path.
if ($action == 'add' && $type == 'learnpathitem') {
$htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
$htmlHeadXtra[] = "<script> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
}
if ((!$is_allowed_to_edit) || ($isStudentView)) {
error_log('New LP - User not authorized in lp_view_item.php');
@ -116,12 +115,13 @@ if (isset($_SESSION['oLP']) && is_object($_SESSION['oLP'])) {
$lp_theme_css = $_SESSION['oLP']->get_theme();
}
Display::display_header(get_lang('Item'),'Path');
//api_display_tool_title($therow['name']);
if ($mode == 'fullpage') {
Display::display_header(get_lang('Item'),'Path');
}
$suredel = trim(get_lang('AreYouSureToDelete'));
?>
<script type='text/javascript'>
<script>
/* <![CDATA[ */
function stripslashes(str) {
@ -141,15 +141,25 @@ function confirmation(name) {
}
</script>
<?php
$id = (isset($new_item_id)) ? $new_item_id : $_GET['id'];
if (is_object($_SESSION['oLP'])) {
echo $_SESSION['oLP']->build_action_menu();
echo '<div class="row-fluid">';
echo '<div class="span3">';
echo $_SESSION['oLP']->return_new_tree();
echo '</div>';
echo '<div class="span9">';
echo $_SESSION['oLP']->display_item((isset($new_item_id)) ? $new_item_id : $_GET['id']);
echo '</div>';
echo '</div>';
switch ($mode) {
case 'fullpage':
echo $_SESSION['oLP']->build_action_menu();
echo '<div class="row-fluid">';
echo '<div class="span3">';
echo $_SESSION['oLP']->return_new_tree();
echo '</div>';
echo '<div class="span9">';
echo $_SESSION['oLP']->display_item($id);
echo '</div>';
echo '</div>';
Display::display_footer();
break;
case 'preview_document':
echo $_SESSION['oLP']->display_item($id, null, false);
break;
}
}
Display::display_footer();

@ -271,7 +271,7 @@ class scorm extends learnpath {
$new_lp = Database::get_course_table(TABLE_LP_MAIN);
$new_lp_item = Database::get_course_table(TABLE_LP_ITEM);
$use_max_score = intval($use_max_score);
foreach ($this->organizations as $id => $dummy) {
$is_session = api_get_session_id();
$is_session != 0 ? $session_id = $is_session : $session_id = 0;
@ -298,7 +298,7 @@ class scorm extends learnpath {
$res = Database::query($sql);
$lp_id = Database::insert_id();
$this->lp_id = $lp_id;
// Insert into item_property.
api_item_property_update(api_get_course_info($course_code), TOOL_LEARNPATH, $this->lp_id, 'LearnpathAdded', api_get_user_id());
api_item_property_update(api_get_course_info($course_code), TOOL_LEARNPATH, $this->lp_id, 'visible', api_get_user_id());
@ -310,7 +310,7 @@ class scorm extends learnpath {
$parent = 0;
$previous = 0;
$level = 0;
foreach ($list as $item) {
if ($item['level'] > $level) {
// Push something into the parents array.
@ -366,7 +366,7 @@ class scorm extends learnpath {
$identifier = Database::escape_string($item['identifier']);
$prereq = Database::escape_string($item['prerequisites']);
$sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,launch_data, parameters) VALUES " .
"($course_id, $lp_id, '$type','".$identifier."','".$title."'," .
"'$path',0,$max_score, $value_add" .
@ -465,7 +465,7 @@ class scorm extends learnpath {
$zip_file_path = $zip_file_info['tmp_name'];
$zip_file_name = $zip_file_info['name'];
if ($this->debug > 1) { error_log('New LP - import_package() - zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name, 0); }
$course_rel_dir = api_get_course_path().'/scorm'; // scorm dir web path starting from /courses
$course_sys_dir = api_get_path(SYS_COURSE_PATH).$course_rel_dir; // Absolute system path for this course.
@ -498,8 +498,8 @@ class scorm extends learnpath {
$manifest_list = array();
// The following loop should be stopped as soon as we found the right imsmanifest.xml (how to recognize it?).
foreach ($zipContentArray as $thisContent) {
$thisContent['filename'];
foreach ($zipContentArray as $thisContent) {
$thisContent['filename'];
//error_log('Looking at '.$thisContent['filename'], 0);
if (preg_match('~.(php.*|phtml)$~i', $thisContent['filename'])) {
$this->set_error_msg("File $file contains a PHP script");
@ -520,7 +520,7 @@ class scorm extends learnpath {
}
$realFileSize += $thisContent['size'];
}
// Now get the shortest path (basically, the imsmanifest that is the closest to the root).
$shortest_path = $manifest_list[0];
$slash_count = substr_count($shortest_path, '/');
@ -572,7 +572,7 @@ class scorm extends learnpath {
$saved_dir = getcwd();
chdir($course_sys_dir.$new_dir);
$unzippingState = $zipFile->extract();
for ($j = 0; $j < count($unzippingState); $j++) {
$state = $unzippingState[$j];
@ -604,11 +604,11 @@ class scorm extends learnpath {
if ($this->debug >= 1) { error_log('Comparing: '.$safe_file, 0); }
if ($this->debug >= 1) { error_log('and: '.$file, 0); }
if ($safe_file != $file) {
//@rename($course_sys_dir.$new_dir, $course_sys_dir.'/'.$safe_file);
$mydir = dirname($course_sys_dir.$new_dir.$safe_file);
if (!is_dir($mydir)) {
$mysubdirs = split('/', $mydir);
$mybasedir = '/';
@ -755,7 +755,7 @@ class scorm extends learnpath {
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once 'learnpath_functions.inc.php';
$course_id = api_get_course_int_id();
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@ -862,7 +862,7 @@ class scorm extends learnpath {
if ($this->debug > 0) { error_log('In scorm::reimport_manifest() method', 0); }
global $_course;
// RECOVERING PATH FROM DB
$main_table = Database::get_main_table(TABLE_MAIN_COURSE);
$main_table = Database::get_main_table(TABLE_MAIN_COURSE);
$course = Datbase::escape_string($course);
$sql = "SELECT * FROM $main_table WHERE code = '$course'";
if ($this->debug > 2) { error_log('New LP - scorm::reimport_manifest() '.__LINE__.' - Querying course: '.$sql, 0); }
@ -882,7 +882,6 @@ class scorm extends learnpath {
$lp_id = intval($lp_id);
$sql = "SELECT * FROM $lp_table WHERE c_id = ".$course_id." AND id = '$lp_id'";
if ($this->debug > 2) { error_log('New LP - scorm::reimport_manifest() '.__LINE__.' - Querying lp: '.$sql, 0); }
//$res = Database::query($sql);
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$this->lp_id = $lp_id;

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save