skala
Julio Montoya 13 years ago
commit 51328a986d
  1. 44
      main/exercice/hotpotatoes_exercise_result.class.php
  2. 24
      main/inc/lib/document.lib.php
  3. 6
      main/newscorm/learnpath.class.php
  4. 4
      main/newscorm/learnpathItem.class.php
  5. 21
      main/newscorm/lp_ajax_save_item.php
  6. 84
      main/newscorm/scorm_api.php

@ -83,27 +83,27 @@ class HotpotatoesExerciseResult
}
if (empty($user_id)) {
$sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
email,
tth.exe_name,
tth.exe_result,
tth.exe_weighting,
tth.exe_date
FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
WHERE tu.user_id=tth.exe_user_id AND
tth.exe_cours_id = '" . Database :: escape_string($cid) . "' AND
tth.exe_name = '$hotpotato_name'
ORDER BY tth.exe_cours_id ASC, tth.exe_date DESC";
$sql="SELECT firstname as userpart1, lastname as userpart2 ,
email,
tth.exe_name,
tth.exe_result,
tth.exe_weighting,
tth.exe_date
FROM $TBL_TRACK_HOTPOTATOES tth, $TBL_USER tu
WHERE tu.user_id=tth.exe_user_id AND
tth.exe_cours_id = '" . Database :: escape_string($cid) . "' AND
tth.exe_name = '$hotpotato_name'
ORDER BY tth.exe_cours_id ASC, tth.exe_date ASC";
} else {
$user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
// get only this user's results
$sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date
FROM $TBL_TRACK_HOTPOTATOES
WHERE exe_user_id = '" . $user_id . "' AND
exe_cours_id = '" . Database :: escape_string($cid) . "' AND
tth.exe_name = '$hotpotato_name'
ORDER BY exe_cours_id ASC, exe_date DESC";
$user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
// get only this user's results
$sql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date
FROM $TBL_TRACK_HOTPOTATOES
WHERE exe_user_id = '" . $user_id . "' AND
exe_cours_id = '" . Database :: escape_string($cid) . "' AND
tth.exe_name = '$hotpotato_name'
ORDER BY exe_cours_id ASC, exe_date ASC";
}
$results = array();
@ -203,8 +203,6 @@ class HotpotatoesExerciseResult
$data .= get_lang('Total').';';
$data .= "\n";
error_log("HUBC |||".serialize($this->results)."|||");
//results
foreach($this->results as $row) {
if (api_is_western_name_order()) {
@ -249,6 +247,8 @@ class HotpotatoesExerciseResult
}
header('Content-Description: '.$filename);
header('Content-transfer-encoding: binary');
// @todo add this utf-8 header for all csv files
echo "\xEF\xBB\xBF"; // force utf-8 header of csv file
echo $data;
return true;
}

@ -1172,10 +1172,26 @@ class DocumentManager {
$condition = "AND id_session IN ('$session_id', '0') ";
// The " d.filetype='file' " let the user see a file even if the folder is hidden see #2198
//When using hotpotatoes files, new files are generated in the hotpotatoe folder, if user_id=1 does the exam a new html file will be generated: hotpotatoe.html.(user_id).t.html
//so we remove that string in order to find correctly the origin file
if (strpos($doc_path, 'HotPotatoes_files')) {
// $doc_path = substr($doc_path, 0, strlen($doc_path) - 8);
/*
When using hotpotatoes files, a new html files are generated in the hotpotatoes folder
to display the test.
The genuine html file is copied to math4.htm(user_id).t.html
Images files are not copied, and keep same name.
To check the html file visibility, we don't have to check file math4.htm(user_id).t.html but file math4.htm
In this case, we have to remove (user_id).t.html to check the visibility of the file
For images, we just check the path of the image file.
Exemple of hotpotatoes folder :
A.jpg
maths4-consigne.jpg
maths4.htm
maths4.htm1.t.html
maths4.htm52.t.html
maths4.htm654.t.html
omega.jpg
theta.jpg
*/
if (strpos($doc_path, 'HotPotatoes_files') && preg_match("/\.t\.html$/", $doc_path)) {
$doc_path = substr($doc_path, 0, strlen($doc_path) - 7 - strlen(api_get_user_id()));
}

@ -1451,7 +1451,7 @@ class learnpath {
$i = 0;
foreach ($this->items as $id => $dummy) {
// Trying failed and browsed considered "progressed" as well.
if ($this->items[$id]->status_is(array (
if ($this->items[$id]->status_is(array(
'completed',
'passed',
'succeeded',
@ -1515,12 +1515,12 @@ class learnpath {
}
$total = 0;
foreach ($this->items as $temp2) {
if (!in_array($temp2->get_type(), array (
if (!in_array($temp2->get_type(), array(
'dokeos_chapter',
'chapter',
'dir'
)))
$total++;
$total++;
}
return $total;
}

@ -1003,7 +1003,7 @@ class learnpathItem {
if ($check_db) {
if (self::debug > 2) { error_log('New LP - In 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()."'";
$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('New LP - In learnpathItem::get_status() - Checking DB: '.$sql, 0); }
$res = Database::query($sql);
@ -1012,7 +1012,7 @@ class learnpathItem {
if ($update_local) {
$this->set_status($row['status']);
}
if (self::debug > 2) { error_log('New LP - In learnpathItem::get_status() - Returning db value '.$row['status'], 0); }
if (self::debug > 2) { error_log('New LP - In learnpathItem::get_status() - Returning db value '.$row['status'], 0); }
return $row['status'];
}
} else {

@ -37,16 +37,17 @@ require_once 'back_compat.inc.php';
*/
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;
$debug = 0;
$debug = 5;
$return = '';
if ($debug > 0) { error_log('In save_item('.$lp_id.','.$user_id.','.$view_id.','.$item_id.','.$score.','.$max.','.$min.',"'.$status.'",'.$time.',"'.$suspend.'","'.$location.'","'.(count($interactions) > 0 ? $interactions[0] : '').'","'.$core_exit.'")', 0); }
//$objResponse = new xajaxResponse();
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); }
@ -66,9 +67,15 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
if (!is_a($mylp, 'learnpath')) { return ''; }
$prereq_check = $mylp->prerequisites_match($item_id);
if ($prereq_check === true) { // Launch the prerequisites check and set error if needed.
$mylpi = $mylp->items[$item_id];
//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) {
// Launch the prerequisites check and set error if needed
$mylpi =& $mylp->items[$item_id];
//$mylpi =& $mylp->items[$item_id];
//$mylpi->set_lp_view($view_id);
if (isset($max) && $max != -1) {
$mylpi->max_score = $max;
@ -142,6 +149,7 @@ function save_item($lp_id, $user_id, $view_id, $item_id, $score = -1, $max = -1,
//return $objResponse;
return $return;
}
$mystatus_in_db = $mylpi->get_status(true);
if ($mystatus_in_db != 'completed' && $mystatus_in_db != 'passed' && $mystatus_in_db != 'browsed' && $mystatus_in_db != 'failed') {
$mystatus_in_memory = $mylpi->get_status(false);
@ -154,9 +162,12 @@ 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();
$mycomplete = $mylp->get_complete_items_count();
$myprogress_mode = $mylp->get_progress_bar_mode();
$myprogress_mode = ($myprogress_mode == '' ? '%' : $myprogress_mode);
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); }
//$mylpi->write_to_db();
$_SESSION['lpobject'] = serialize($mylp);
if ($mylpi->get_type() != 'sco') {

@ -1092,32 +1092,35 @@ function chamilo_void_save_asset(myscore,mymax)
* @param integer Priority (0 for top priority, 3 for lowest)
*/
function logit_scorm(message,priority) {
if(scorm_logs == 0) {return false;}
if(scorm_logs>priority){ /* fixed see http://support.chamilo.org/issues/370 */
if($("#lp_log_name") && $("#log_content")){
//scorm_logs = 10000;
if (scorm_logs == 0) { return false; }
if (scorm_logs > priority) {
/* fixed see http://support.chamilo.org/issues/370 */
if ($("#lp_log_name") && $("#log_content")){
$("#log_content").append("SCORM: " + message + "<br/>");
}
params = {
msg: "SCORM: " + message,
debug: scorm_logs
};
$.ajax({
type: "POST",
data: params,
url: "lp_ajax_log.php",
dataType: "script",
async: true
});
params = {
msg: "SCORM: " + message,
debug: scorm_logs
};
$.ajax({
type: "POST",
data: params,
url: "lp_ajax_log.php",
dataType: "script",
async: true
});
//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){
if(lms_logs>=priority){
function logit_lms(message, priority){
if (lms_logs >= priority) {
if ($("#lp_log_name") && $("#log_content")) {
$("#log_content").append("LMS: " + message + "<br />");
}
@ -1131,9 +1134,11 @@ function logit_lms(message,priority){
url: "lp_ajax_log.php",
dataType: "script",
async: true
});
});
}
//console.log(message);
}
/**
* Update the Table Of Contents frame, by changing CSS styles, mostly
* @param string Action to be taken
@ -1255,39 +1260,42 @@ 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);
if (mode == ''){mode='%';}
if (nbr_total == 0){nbr_total=1;}
if (mode == '') {
mode='%';
}
if (nbr_total == 0) {
nbr_total=1;
}
var percentage = (nbr_complete/nbr_total)*100;
percentage = Math.round(percentage);
var pr_text = $("#progress_text");
var progress_bar = $("#progress_bar_value");
progress_bar.css('width', percentage + "%");
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);
pr_empty.attr('width',(100-percentage)*1.2);
*/
var mytext = '';
switch(mode){
case 'abs':
mytext = nbr_complete + '/' + nbr_total;
break;
case '%':
default:
mytext = percentage + '%';
break;
}
var mytext = '';
switch(mode){
case 'abs':
mytext = nbr_complete + '/' + nbr_total;
break;
case '%':
default:
mytext = percentage + '%';
break;
}
pr_text.html(mytext);
return true;
}
/**
* Analyses the variables that have been modified through this SCO's life and
* put them into an array for later shipping to lp_ajax_save_item.php

Loading…
Cancel
Save