diff --git a/main/inc/lib/fckeditor/myconfig.js b/main/inc/lib/fckeditor/myconfig.js
index abcad2f4e3..02de6a6b24 100644
--- a/main/inc/lib/fckeditor/myconfig.js
+++ b/main/inc/lib/fckeditor/myconfig.js
@@ -116,11 +116,3 @@ FCKConfig.VideoUploadDeniedExtensions = '' ;
FCKConfig.MediaUploadAllowedExtensions = '.(flv|mp4)$' ;
FCKConfig.MediaUploadDeniedExtensions = '' ;
// Note: These lists get combined with the platform's white and black lists.
-
-
-/*
- * Other settings.
- */
-
-// TODO: This setting seems obsolete. To be checked for removal.
-FCKConfig.UserStatus = 'teacher' ;
diff --git a/main/inc/lib/legal.lib.php b/main/inc/lib/legal.lib.php
index 103edc73ec..b1ed987807 100644
--- a/main/inc/lib/legal.lib.php
+++ b/main/inc/lib/legal.lib.php
@@ -2,12 +2,11 @@
/*
==============================================================================
*/
-class LegalManager
-{
- private function __construct() {
+class LegalManager {
+ private function __construct () {
//void
}
- function add($language, $content, $type, $changes) {
+ public function add ($language, $content, $type, $changes) {
$legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$last = self::get_last_condition($language);
$language = Database::escape_string($language);
@@ -43,7 +42,7 @@ class LegalManager
}
}
- function delete($id) {
+ public function delete ($id) {
/*
$legal_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$id = intval($id);
@@ -51,7 +50,7 @@ class LegalManager
*/
}
- function get_last_condition_version($language){
+ public function get_last_condition_version ($language) {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language= Database::escape_string($language);
$sql = "SELECT version FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY legal_id DESC LIMIT 1 ";
@@ -64,7 +63,7 @@ class LegalManager
}
}
- function get_last_condition($language) {
+ public function get_last_condition ($language) {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language= Database::escape_string($language);
$sql = "SELECT * FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY version DESC LIMIT 1 ";
@@ -72,8 +71,7 @@ class LegalManager
return Database::fetch_array($result);
}
- function show_last_condition($term_preview)
- {
+ public function show_last_condition ($term_preview) {
$preview = '';
switch ($term_preview['type']) {
/*// scroll box
@@ -103,7 +101,7 @@ class LegalManager
// html
case 0:
$preview = '
'.$term_preview['content'].'
';
- $preview .= '
'.get_lang('ByClickingAccept');
+ $preview .= '
'.get_lang('ByClickingRegisterYouAgreeTermsAndConditions');
break;
// page link
case 1:
@@ -124,7 +122,7 @@ class LegalManager
}
return $preview;
}
- function get_last_version($language){
+ public function get_last_version ($language) {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$language= Database::escape_string($language);
$sql = "SELECT version FROM $legal_conditions_table WHERE language_id = '".$language."' ORDER BY version DESC LIMIT 1 ";
@@ -138,7 +136,7 @@ class LegalManager
}
}
- function get_legal_data($from, $number_of_items, $column) {
+ public function get_legal_data ($from, $number_of_items, $column) {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
$from = intval($from);
@@ -169,7 +167,7 @@ class LegalManager
return $legals;
}
- function count() {
+ public function count() {
$legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
$sql = "SELECT count(*) as count_result FROM $legal_conditions_table ORDER BY legal_id DESC ";
$result = Database::query($sql, __FILE__, __LINE__);
@@ -177,4 +175,18 @@ class LegalManager
$result = $url['count_result'];
return $result;
}
+ /**
+ * Get type of terms and conditions
+ * @param int The legal id
+ * @param int The language id
+ * @return int The current type of terms and conditions
+ */
+ public function get_type_of_terms_and_conditions ($legal_id,$language_id) {
+ $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL);
+ $legal_id=Database::escape_string($legal_id);
+ $language_id=Database::escape_string($language_id);
+ $sql='SELECT type FROM '.$legal_conditions_table.' WHERE legal_id="'.$legal_id.'" AND language_id="'.$language_id.'"';
+ $rs=Database::query($sql,__FILE__,__LINE__);
+ return Database::result($rs,0,'type');
+ }
}
\ No newline at end of file
diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php
index dbe9700c06..39c5797997 100644
--- a/main/inc/lib/main_api.lib.php
+++ b/main/inc/lib/main_api.lib.php
@@ -183,7 +183,6 @@ define('LOG_USER_DELETE', 'user_deleted');
define('LOG_USER_CREATE', 'user_created');
define('LOG_SESSION_CREATE', 'session_created');
define('LOG_SESSION_DELETE', 'session_deleted');
-define('LOG_SESSION_DELETE', 'session_deleted');
define('LOG_CONFIGURATION_SETTINGS_CHANGE', 'settings_changed');
define('LOG_SUBSCRIBE_USER_TO_COURSE', 'user_subscribed');
define('LOG_UNSUBSCRIBE_USER_FROM_COURSE', 'user_unsubscribed');
@@ -462,11 +461,6 @@ function api_get_path($path_type) {
return api_get_path(WEB_CODE_PATH).'img/';
break;
- case GARBAGE_PATH :
- // example: /var/www/dokeos/main/garbage/
- return $GLOBALS['garbageRepositorySys'];
- break;
-
case SYS_PLUGIN_PATH :
// example: /var/www/dokeos/plugin/
return api_get_path(SYS_PATH).'plugin/';
@@ -477,6 +471,7 @@ function api_get_path($path_type) {
return api_get_path(WEB_PATH).'plugin/';
break;
+ case GARBAGE_PATH : //now set to be same as archive
case SYS_ARCHIVE_PATH :
// example: /var/www/dokeos/archive/
return api_get_path(SYS_PATH).'archive/';
diff --git a/main/inc/lib/pclzip/pclzip.lib.php b/main/inc/lib/pclzip/pclzip.lib.php
index c12d0a1691..c76b1fa3ef 100644
--- a/main/inc/lib/pclzip/pclzip.lib.php
+++ b/main/inc/lib/pclzip/pclzip.lib.php
@@ -22,7 +22,7 @@
// The use of this software is at the risk of the user.
//
// --------------------------------------------------------------------------------
-// $Id: pclzip.lib.php 21315 2009-06-09 13:50:25Z ndieschburg $
+// $Id: pclzip.lib.php 22578 2009-08-03 04:32:32Z yannoo $
// --------------------------------------------------------------------------------
// ----- Constants
@@ -63,7 +63,7 @@
// define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
// define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
if (!defined('PCLZIP_TEMPORARY_DIR')) {
- define( 'PCLZIP_TEMPORARY_DIR', $garbageRepositorySys );
+ define( 'PCLZIP_TEMPORARY_DIR', api_get_path(SYS_ARCHIVE_PATH) );
}
// --------------------------------------------------------------------------------
diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php
index 306328fb45..f53acf814b 100644
--- a/main/inc/lib/sessionmanager.lib.php
+++ b/main/inc/lib/sessionmanager.lib.php
@@ -1,4 +1,4 @@
-,from existing code
diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php
index 435a922cc7..3ac50e9433 100644
--- a/main/inc/lib/tracking.lib.php
+++ b/main/inc/lib/tracking.lib.php
@@ -211,7 +211,7 @@ class Tracking {
//If the last connection is > than 7 days, the text is red
//345600 = 7 days in seconds
if ($currentTimestamp - $timestamp > 604800) {
- return '
' . format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_login_date)) . ' ';
+ return '
' . format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_login_date)) . (api_is_allowed_to_edit()?' ':'').'';
} else {
return format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_login_date));
}
@@ -369,15 +369,14 @@ class Tracking {
* @param Array limit average to listed lp ids
* @return string value (number %) Which represents a round integer explain in got in 3.
*/
- function get_avg_student_score($student_id, $course_code, $lp_ids=array()) {
-
+ function get_avg_student_score($student_id, $course_code, $lp_ids=array()) {
$course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$course_user_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$table_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_stats_exercices = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$tbl_stats_attempts= Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
- $course = CourseManager :: get_course_information($course_code);
+ $course = CourseManager :: get_course_information($course_code);
if (!empty($course['db_name'])) {
$tbl_quiz_questions= Database :: get_course_table(TABLE_QUIZ_QUESTION,$course['db_name']);
@@ -387,67 +386,108 @@ class Tracking {
$lp_item_view_table = Database :: get_course_table(TABLE_LP_ITEM_VIEW,$course['db_name']);
$sql_course_lp = 'SELECT id FROM '.$lp_table;
- if(count($lp_ids)!=0)
- {
+ if(count($lp_ids)!=0) {
$sql_course_lp.=' WHERE id IN ('.implode(',',$lp_ids).')';
}
+
$sql_result_lp = api_sql_query($sql_course_lp, __FILE__, __LINE__);
-
$lp_scorm_score_total = 0;
$lp_scorm_weighting_total = 0;
$lp_scorm_result_score_total = 0;
$lp_scorm_loop=0;
+ $lp_count = 0;
+ $progress = 0;
+
if(Database::num_rows($sql_result_lp)>0){
- //Scorm test
- while($a_learnpath = Database::fetch_array($sql_result_lp)){
+ //Scorm test
+ while($a_learnpath = Database::fetch_array($sql_result_lp)) {
- //We get the last view id of this LP
- $sql='SELECT max(id) as id FROM '.$lp_view_table.' WHERE lp_id='.$a_learnpath['id'].' AND user_id="'.intval($student_id).'"';
+ //We get the last view id of this LP (with the higher id)
+ $sql='SELECT max(id) as id FROM '.$lp_view_table.'
+ WHERE lp_id='.$a_learnpath['id'].' AND user_id="'.intval($student_id).'"';
$rs_last_lp_view_id = api_sql_query($sql, __FILE__, __LINE__);
- $lp_view_id = Database::result($rs_last_lp_view_id,0,'id');
+ $lp_view_id = Database::result($rs_last_lp_view_id,0,'id'); // THE view
- $sql_max_score='SELECT lp_iv.score as score,lp_i.max_score
- FROM '.$lp_item_view_table.' as lp_iv
- INNER JOIN '.$lp_item_table.' as lp_i
- ON lp_i.id = lp_iv.lp_item_id
- AND lp_i.item_type="sco"
- WHERE lp_view_id="'.$lp_view_id.'"';
-
- //$rs = api_sql_query($sql, __FILE__, __LINE__);
- //$sql_max_score='SELECT max_score FROM '.$lp_item_view_table.' WHERE lp_view_id="'.$lp_view_id.'" ';
- $res_max_score=Database::query($sql_max_score,__FILE__,__LINE__);
- $count_total_loop=0;
- $num_rows_max_score=Database::num_rows($res_max_score);
- if ($num_rows_max_score==1) {
- while ($row_max_score=Database::fetch_array($res_max_score)) {
- if ($row_max_score['max_score']==0) {
- //when there's no max score, we assume 100 as the max score, as the SCORM 1.2 says that the value should always be between 0 and 100.
- $lp_scorm_result_score_total+=($row_max_score['score']/100);
- } else {
- $lp_scorm_result_score_total+=($row_max_score['score']/$row_max_score['max_score']);
- }
- $count_total_loop++;
- }
- } elseif ($num_rows_max_score>1) {
- while ($row_max_score=Database::fetch_array($res_max_score)) {
- if ($row_max_score['max_score']==0) {
- $lp_scorm_result_score_total+=($row_max_score['score']/100);
- } else {
- $lp_scorm_result_score_total+=($row_max_score['score']/$row_max_score['max_score']);
- }
- $count_total_loop++;
- }
- }
- if ($count_total_loop==0) {
- $count_total_loop=1;
- }
- $score_of_scorm_calculate=round((($lp_scorm_result_score_total/$count_total_loop)*100),2);
+ if ($lp_view_id != '') {
+ // we get the progress
+ $sql='SELECT progress FROM '.$lp_view_table.' WHERE id="'.$lp_view_id.'"';
+ $rs = api_sql_query($sql, __FILE__, __LINE__);
+ $progress = Database::result($rs,0,'progress');
+
+ // item's list of an scorm
+ $sql_max_score='SELECT lp_iv.score as score,lp_i.max_score
+ FROM '.$lp_item_view_table.' as lp_iv
+ INNER JOIN '.$lp_item_table.' as lp_i
+ ON lp_i.id = lp_iv.lp_item_id
+ AND lp_i.item_type="sco"
+ WHERE lp_view_id="'.$lp_view_id.'"';
+
+ //$rs = api_sql_query($sql, __FILE__, __LINE__);
+ //$sql_max_score='SELECT max_score FROM '.$lp_item_view_table.' WHERE lp_view_id="'.$lp_view_id.'" ';
+ $res_max_score=Database::query($sql_max_score,__FILE__,__LINE__);
+ $count_total_loop=0;
+ $num_rows_max_score=Database::num_rows($res_max_score);
+
+ if ($num_rows_max_score==1) {
+ while ($row_max_score=Database::fetch_array($res_max_score)) {
+ echo $row_max_score['score'].' - '.$row_max_score['max_score'];
+ if ($row_max_score['max_score']==0) {
+ //when there's no max score, we assume 100 as the max score, as the SCORM 1.2 says that the value should always be between 0 and 100.
+ $lp_scorm_result_score_total+=($row_max_score['score']/100);
+ $current_value = $row_max_score['score']/100;
+
+ } else {
+ $lp_scorm_result_score_total+=($row_max_score['score']/$row_max_score['max_score']);
+ $current_value = $row_max_score['score']/$row_max_score['max_score'];
+ }
+ $count_total_loop++;
+ }
+ } elseif ($num_rows_max_score > 1) {
+ //echo ' ----
';
+ while ($row_max_score=Database::fetch_array($res_max_score)) {
+ //echo $row_max_score['score'].' - '.$row_max_score['max_score'];
+ //echo '
';
+ if ($row_max_score['max_score']==0) {
+ $lp_scorm_result_score_total+=($row_max_score['score']/100);
+ $current_value = $row_max_score['score']/100;
+ } else {
+ //when there's no max score, we assume 100 as the max score, as the SCORM 1.2 says that the value should always be between 0 and 100.
+ $lp_scorm_result_score_total+=($row_max_score['score']/$row_max_score['max_score']);
+ $current_value = $row_max_score['score']/$row_max_score['max_score'];
+ }
+ $count_total_loop++;
+ }
+ }
+
+ if ($num_rows_max_score > 0 && ($progress > 0 || $current_value > 0 )) {
+ $lp_count++;
+ }
+
+ if ($count_total_loop==0) {
+ $count_total_loop=1;
+ }
+ $score_of_scorm_calculate=round((($lp_scorm_result_score_total/$count_total_loop)*100),2);
+
+ } else {
+ $score_of_scorm_calculate = 0;
+ }
}
+
//The next call to a MySQL fetch function, such as mysql_fetch_assoc(), would return that row.
mysql_data_seek($sql_result_lp,0);
-
+
+ if ($lp_count==0) {
+ $lp_count=1;
+ }
+
+ if(count($lp_ids)==0 ) {
+ $score_of_scorm_calculate=round((($score_of_scorm_calculate/$lp_count)),2);
+ }
+
+ $lp_scorm_score_total = $score_of_scorm_calculate;
+
//Quizz in a LP
- while($a_learnpath = Database::fetch_array($sql_result_lp)){
+ while($a_learnpath = Database::fetch_array($sql_result_lp)) {
//we got the maxscore this is wrong
/*
echo $sql = 'SELECT id as item_id, max_score
@@ -528,8 +568,8 @@ class Tracking {
$total_weighting += $maxscore;
if($total_weighting>0 && $maxscore>0) {
//echo $total_score.' - '.$maxscore; echo '
';
- //echo $lp_scorm_score_total += ($total_score/$total_weighting)*100;
- $lp_scorm_score_total += ($total_score/$maxscore)*100;
+ //echo $lp_scorm_score_total += ($total_score/$total_weighting)*100;
+ $lp_scorm_score_total += ($total_score/$maxscore)*100;
$lp_scorm_weighting_total+=100;
}
}
@@ -538,14 +578,14 @@ class Tracking {
}
}
- $totalScore = $lp_scorm_score_total;
-
+ $totalScore = $lp_scorm_score_total;
$pourcentageScore = 0;
if($lp_scorm_weighting_total>0) {
//i.e 10.52
$pourcentageScore = round( (($totalScore * 100) / $lp_scorm_weighting_total),2);
return $pourcentageScore;
} elseif ($score_of_scorm_calculate>0) {
+ //echo '
'.$score_of_scorm_calculate;
return $score_of_scorm_calculate;
} else {
return null;
@@ -1308,4 +1348,4 @@ class Tracking {
return $avg_student_score;
}
}
-?>
+?>
\ No newline at end of file
diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php
index e680b1cd9b..f32814667b 100644
--- a/main/inc/local.inc.php
+++ b/main/inc/local.inc.php
@@ -10,7 +10,8 @@
Copyright (c) Roan Embrechts (Vrije Universiteit Brussel)
Copyright (c) Patrick Cool
Copyright (c) Julio Montoya Armas
-
+ Copyright (c) Isaac flores paz
+
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
@@ -159,6 +160,7 @@ The course id is stored in $_cid session variable.
// verified if exists the username and password in session current
if (isset($_SESSION['info_current_user'][1]) && isset($_SESSION['info_current_user'][2])) {
require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
+ require_once (api_get_path(LIBRARY_PATH).'legal.lib.php');
}
// parameters passed via GET
$logout = isset($_GET["logout"]) ? $_GET["logout"] : '';
@@ -210,11 +212,23 @@ if (get_setting('allow_terms_conditions')=='true') {
$user_id=$_SESSION['update_term_and_condition'][1]; // user id
// update the terms & conditions
- if ((isset($_POST['legal_accept']) && $_POST['legal_accept']=='1') || !isset($_POST['legal_accept'])) {
+
+ //verify type of terms and conditions
+ $info_legal = explode(':',$_POST['legal_info']);
+ $legal_type=LegalManager::get_type_of_terms_and_conditions($info_legal[0],$info_legal[1]);
+
+ //is necessary verify check
+ if ($legal_type==1) {
+ if ((isset($_POST['legal_accept']) && $_POST['legal_accept']=='1')) {
+ $legal_option=true;
+ } else {
+ $legal_option=false;
+
+ }
+ }
+ //no is check option
+ if ($legal_type==0) {
$legal_option=true;
- } else {
- $legal_option=false;
-
}
if (isset($_POST['legal_accept_type']) && $legal_option===true) {
diff --git a/main/install/compare_db.php b/main/install/compare_db.php
index 82f9130200..ca2b46df25 100644
--- a/main/install/compare_db.php
+++ b/main/install/compare_db.php
@@ -1,27 +1,5 @@
-
- Copyright (c) 2004 Dokeos S.A.
- Copyright (c) 2003 Ghent University (UGent)
- Copyright (c) 2001 Universite catholique de Louvain (UCL)
-
- For a full list of contributors, see "credits.txt".
- The full license can be read in "license.txt".
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- See the GNU General Public License for more details.
-
- Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
- Mail: info@dokeos.com
-==============================================================================
-*/
+type == 'sco') ||(($this->type == 'sco') && ($credit == 'no-credit' OR $mode == 'review' OR $mode == 'browse')))
+ if (($save===false && $this->type == 'sco') ||(($this->type == 'sco') && ($credit == 'no-credit' OR $mode == 'review' OR $mode == 'browse')))
{
//this info shouldn't be saved as the credit or lesson mode info prevent it
if($this->debug>1){error_log('New LP - In learnpathItem::write_to_db() - credit('.$credit.') or lesson_mode('.$mode.') prevent recording!',0);}
- }else{
+ } else {
//check the row exists
$inserted = false;
- // this a special case for multiple attepmts and Dokeos exercises
- if ($this->type == 'quiz' && $this->get_prevent_reinit()==0 && $this->get_status()=='completed') {
+ // this a special case for multiple attempts and Dokeos exercises
+ if ($this->type == 'quiz' && $this->get_prevent_reinit()==0 && $this->get_status()=='completed') {
// we force the item to be restarted
$this->restart();
-
+
$sql = "INSERT INTO $item_view_table " .
"(total_time, " .
"start_time, " .
@@ -2281,10 +2281,10 @@ function get_terms()
if($this->debug>2){error_log('New LP - In learnpathItem::write_to_db() - Inserting into item_view: '.$sql,0);}
$res = api_sql_query($sql,__FILE__,__LINE__);
$this->db_item_view_id = Database::get_last_insert_id();
- }else{
+ } else {
$sql = '';
- if($this->type=='hotpotatoes')
- { //make an exception for HotPotatoes, don't update the score
+ if($this->type=='hotpotatoes') {
+ //make an exception for HotPotatoes, don't update the score
//because it has been saved outside of this tool
$sql = "UPDATE $item_view_table " .
"SET total_time = ".$this->get_total_time().", " .
@@ -2297,43 +2297,39 @@ function get_terms()
"WHERE lp_item_id = ".$this->db_id." " .
"AND lp_view_id = ".$this->view_id." " .
"AND view_count = ".$this->attempt_id;
- }
- else
- { //for all other content types...
+ } else {
+ //for all other content types...
if ($this->type=='quiz') {
$my_status = ' ';
$total_time = ' ';
if (!empty($_REQUEST['exeId'])) {
- $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
-
- $safe_exe_id = Database::escape_string($_REQUEST['exeId']);
- $sql = 'SELECT start_date,exe_date FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.(int)$safe_exe_id;
- $res = api_sql_query($sql,__FILE__,__LINE__);
- $row_dates = Database::fetch_array($res);
-
- $time_start_date = convert_mysql_date($row_dates['start_date']);
- $time_exe_date = convert_mysql_date($row_dates['exe_date']);
- $mytime = ((int)$time_exe_date-(int)$time_start_date);
- $total_time =" total_time = ".$mytime.", ";
- }
-
-
- }else {
+ $TBL_TRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
+
+ $safe_exe_id = Database::escape_string($_REQUEST['exeId']);
+ $sql = 'SELECT start_date,exe_date FROM ' . $TBL_TRACK_EXERCICES . ' WHERE exe_id = '.(int)$safe_exe_id;
+ $res = api_sql_query($sql,__FILE__,__LINE__);
+ $row_dates = Database::fetch_array($res);
+
+ $time_start_date = convert_mysql_date($row_dates['start_date']);
+ $time_exe_date = convert_mysql_date($row_dates['exe_date']);
+ $mytime = ((int)$time_exe_date-(int)$time_start_date);
+ $total_time =" total_time = ".$mytime.", ";
+ }
+ } else {
$my_type_lp=learnpath::get_type_static($this->lp_id);
// this is a array containing values finished
$case_completed=array('completed','passed','browsed');
//is not multiple attempts
- if ($this->get_prevent_reinit()==1) {
- // process of status verified into data base
-
- $sql_verified='SELECT status FROM '.$item_view_table.' WHERE lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
- $rs_verified=api_sql_query($sql_verified,__FILE__,__LINE__);
- $row_verified=Database::fetch_array($rs_verified);
-
- //get type lp i.e 2=scorm and 1=lp dokeos
- // if not is completed or passed or browsed and learnig path is scorm
+ if ($this->get_prevent_reinit()==1) {
+ // process of status verified into data base
+ $sql_verified='SELECT status FROM '.$item_view_table.' WHERE lp_item_id="'.$this->db_id.'" AND lp_view_id="'.$this->view_id.'" AND view_count="'.$this->attempt_id.'" ;';
+ $rs_verified=api_sql_query($sql_verified,__FILE__,__LINE__);
+ $row_verified=Database::fetch_array($rs_verified);
+
+ //get type lp: 1=lp dokeos and 2=scorm
+ // if not is completed or passed or browsed and learning path is scorm
if(!in_array($this->get_status(false),$case_completed) && $my_type_lp==2 ) {//&& $this->type!='dir'
$total_time =" total_time = total_time +".$this->get_total_time().", ";
$my_status = " status = '".$this->get_status(false)."' ,";
@@ -2346,31 +2342,28 @@ function get_terms()
$total_time =" total_time = total_time +".$this->get_total_time().", ";
$my_status = " status = '".$this->get_status(false)."' ,";
}else {
- //&& !in_array($row_verified['status'],$case_completed)
-
+ //&& !in_array($row_verified['status'],$case_completed)
//is lp dokeos
if ($my_type_lp==1 && $this->type!='chapter') {
$total_time =" total_time = total_time + ".$this->get_total_time().", ";
$my_status = " status = '".$this->get_status(false)."' ,";
}
- }
-
+ }
}
} else {
- // is multipe attempts
+ // is multiple attempts
if (in_array($this->get_status(false),$case_completed) && $my_type_lp==2) {
- //reset zero new attempt ?
+ //reset zero new attempt ?
+ $my_status = " status = '".$this->get_status(false)."' ,";
} elseif (!in_array($this->get_status(false),$case_completed) && $my_type_lp==2){
$total_time =" total_time = ".$this->get_total_time().", ";
- $my_status = " status = '".$this->get_status(false)."' ,";
+ $my_status = " status = '".$this->get_status(false)."' ,";
} else {
- //is lp dokeos
+ //is dokeos LP
$total_time =" total_time = total_time +".$this->get_total_time().", ";
$my_status = " status = '".$this->get_status(false)."' ,";
- }
-
- }
-
+ }
+ }
/*if ($my_type_lp==1 && !in_array($row_verified['status'],$case_completed)) {
$total_time =" total_time = total_time + ".$this->get_total_time().", ";
}*/
@@ -2442,7 +2435,7 @@ function get_terms()
"latency = '".Database::escape_string($interaction[7])."'" .
"WHERE id = $iva_id";
$ivau_res = api_sql_query($ivau_sql,__FILE__,__LINE__);
- }else{
+ } else {
//insert new one
$ivai_sql = "INSERT INTO $iva_table " .
"(order_id, lp_iv_id, interaction_id, interaction_type, " .
diff --git a/main/newscorm/lp_ajax_save_item.php b/main/newscorm/lp_ajax_save_item.php
index 1b4f3ca30e..82e4fc4671 100644
--- a/main/newscorm/lp_ajax_save_item.php
+++ b/main/newscorm/lp_ajax_save_item.php
@@ -109,7 +109,10 @@ function save_item($lp_id,$user_id,$view_id,$item_id,$score=-1,$max=-1,$min=-1,$
//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){
foreach($interactions as $index=>$interaction){
- $mylpi->add_interaction($index,$interactions[$index]);
+ //$mylpi->add_interaction($index,$interactions[$index]);
+ //fix DT#4444
+ $clean_interaction = str_replace('@@',',',$interactions[$index]);
+ $mylpi->add_interaction($index,$clean_interaction);
}
}
$mylpi->set_core_exit($core_exit);
diff --git a/main/newscorm/scorm_api.php b/main/newscorm/scorm_api.php
old mode 100644
new mode 100755
index 51cd758af7..f98b27d455
--- a/main/newscorm/scorm_api.php
+++ b/main/newscorm/scorm_api.php
@@ -7,7 +7,7 @@
Copyright (c) Denes Nagy (darkden@freemail.hu)
For a full list of contributors, see "credits.txt".
- The full license can be read in "license.txt".
+ The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -616,7 +616,7 @@ function LMSSetValue(param, val) {
return_value='true';
break;
case "student_response":
- interactions[elem_id][5] = val;
+ interactions[elem_id][5] = ''+val;
logit_scorm("Interaction "+elem_id+"'s student_response updated",2);
return_value='true';
break;
@@ -740,7 +740,6 @@ function reinit_update_table_list () {
}
function savedata(origin) {
-
//origin can be 'commit', 'finish' or 'terminate'
if ((lesson_status != 'completed') && (lesson_status != 'passed') && (mastery_score >=0) && (score >= mastery_score)) {
lesson_status = 'passed';
@@ -781,6 +780,7 @@ function savedata(origin) {
logit_lms('saving data (status='+lesson_status+' - interactions: '+ interactions.length +')',1);
old_item_id=info_lms_item[0];
+ // xajax_save_item is replaced to xajax_save_item_scorm for scorm LP's
//xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, session_time, suspend_data, lesson_location, interactions, lms_item_core_exit);
xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, old_item_id,my_get_value_scorm);
@@ -1231,7 +1231,13 @@ function switch_item(current_item, next_item) {
//(1) save the current item
logit_lms('Called switch_item with params '+lms_item_id+' and '+next_item+'',0);
if (lms_lp_type==1 || lms_item_type=='asset' || session_time == '0' || session_time == '0:00:00'){
- xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, asset_timer, suspend_data, lesson_location,interactions, lms_item_core_exit);
+ if (lms_lp_type==1) {
+ xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, asset_timer, suspend_data, lesson_location,interactions, lms_item_core_exit);
+ } else {
+ my_get_value_scorm=new Array();
+ my_get_value_scorm=ProcessValueScorm();
+ xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id,my_get_value_scorm);
+ }
if(item_objectives.length>0) {
xajax_save_objectives(lms_lp_id,lms_user_id,lms_view_id,lms_item_id,item_objectives);
}
@@ -1262,6 +1268,7 @@ function switch_item(current_item, next_item) {
//savedata('finish');
//}
// xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score, max, min, lesson_status, session_time, suspend_data, lesson_location,interactions, lms_item_core_exit);
+
}
execute_stats=false;
//(2) Refresh all the values inside this SCORM API object - use AJAX
@@ -1410,8 +1417,6 @@ function xajax_save_item(lms_lp_id, lms_user_id, lms_view_id, lms_item_id, score
}
);
}
-
-
}
function xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id,info_get_lms) {
@@ -1454,21 +1459,32 @@ function xajax_save_item_scorm(lms_lp_id, lms_user_id, lms_view_id, lms_item_id,
is_interactions='false';
}
}
-
+
+
if (is_interactions=='true') {
- interact_string = '';
+ interact_string = '';
+ temp = '';
for (i in interactions){
+
interact_string += '&interact['+i+']=';
interact_temp = '[';
- for (j in interactions[i]) {
- interact_temp += interactions[i][j]+',';
+ for (j in interactions[i]) {
+ temp = interactions[i][j];
+ temp = ''+temp; // if temp == 1 there are problems with indexOf and an integer number
+ //this fix when an interaction have ',' i.e: {a,b,c,d} is replace to {a@@b@@c@@d} see DT#4444
+ while(temp.indexOf(',') >= 0){
+ temp = temp.replace(',','@@');
+ };
+ interact_temp +=temp+',';
}
interact_temp = interact_temp.substr(0,(interact_temp.length-2)) + ']';
- interact_string += encodeURIComponent(interact_temp);
+ // interact_string += encodeURIComponent(interact_temp);
+
+
+ interact_string += interact_temp;
}
- //interact_string = encodeURIComponent(interact_string.substr(0,(interact_string.length-1)));
-
- params += interact_string;
+ //interact_string = encodeURIComponent(interact_string.substr(0,(interact_string.length-1)));
+ params += interact_string;
is_interactions='false';
}
diff --git a/main/social/data_personal.inc.php b/main/social/data_personal.inc.php
index 80b2ba9c92..f0f81068e6 100755
--- a/main/social/data_personal.inc.php
+++ b/main/social/data_personal.inc.php
@@ -5,6 +5,7 @@ $language_file = array('registration','messages','userInfo','admin','forum','blo
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php';
+require_once api_get_path(LIBRARY_PATH).'course.lib.php';
// @todo here we must show the user information as read only
//User picture size is calculated from SYSTEM path
@@ -21,8 +22,8 @@ if (isset($_POST['load_ajax'])) {
$course_db = $_POST['course_code'];
// @todo goto the course link
//echo '
'.get_lang('GotoCourse').'';
- $my_course_info_db=explode('_',$course_db);
- $course_id=$my_course_info_db[1];
+ $course_id=CourseManager::get_course_id_by_database_name($course_db);
+
if (api_is_user_of_course($course_id,api_get_user_id())) {
$table_forums = Database :: get_course_table(TABLE_FORUM,$course_db);
@@ -31,7 +32,8 @@ if (isset($_POST['load_ajax'])) {
$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY,$course_db);
$table_users = Database :: get_main_table(TABLE_MAIN_USER);
- //------Forum messages
+ //------Forum messages
+
$forum_result = get_all_post_from_user($user_id, $course_db);
$all_result_data = 0;
if ($forum_result !='') {
@@ -47,7 +49,7 @@ if (isset($_POST['load_ajax'])) {
$result = get_blog_post_from_user($course_db, $user_id);
if (!empty($result)) {
echo '
';
- api_display_tool_title(get_lang('BlogPosts'));
+ api_display_tool_title(api_xml_http_response_encode(get_lang('BlogPosts')));
echo '
';
echo api_xml_http_response_encode($result);
echo '
';
@@ -58,7 +60,7 @@ if (isset($_POST['load_ajax'])) {
//------Blog comments
$result = get_blog_comment_from_user($course_db, $user_id);
if (!empty($result)) {
- api_display_tool_title(get_lang('BlogComments'));
+ api_display_tool_title(api_xml_http_response_encode(get_lang('BlogComments')));
echo '
';
echo api_xml_http_response_encode($result);
echo '
';
@@ -71,9 +73,9 @@ if (isset($_POST['load_ajax'])) {
} else {
echo '
';
- api_display_tool_title(get_lang('Details'));
+ api_display_tool_title(api_xml_http_response_encode(get_lang('Details')));
echo '
';
- echo get_lang('UserNonRegisteredAtTheCourse');
+ echo api_xml_http_response_encode(get_lang('UserNonRegisteredAtTheCourse'));
echo '
';
echo '
';
echo '
';
diff --git a/main/social/profile.php b/main/social/profile.php
index ad26077eba..31e54ba3f9 100644
--- a/main/social/profile.php
+++ b/main/social/profile.php
@@ -551,7 +551,7 @@ echo '
';
$friend_html.= '
';
$friend_html.= '
'; // close div friend-header
}
$friend_html.= '
';
@@ -568,7 +568,7 @@ echo '
';
echo '
';
if ($count_pending_invitations > 0) {
echo '
';
- echo get_lang('PendingInvitations');
+ echo api_convert_encoding(get_lang('PendingInvitations'),$charset,'UTF-8');
echo '
';
for ($i=0;$i<$count_pending_invitations;$i++) {
//var_dump($invitations);
@@ -577,7 +577,7 @@ echo '
';
echo '
';
echo '
';
echo '
';
- echo ' '.substr($pending_invitations[$i]['content'],0,50);
+ echo ' '.api_convert_encoding(substr($pending_invitations[$i]['content'],0,50),$charset,'UTF-8');
echo '
';
echo '
'.get_lang('SocialAddToFriends').'';
echo '
';
@@ -701,17 +701,49 @@ echo '
';
}*/
if ($show_full_profile) {
- //-- Extra Data
+ //-- Extra Data
+ $t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD);
+ $t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
$extra_user_data = UserManager::get_extra_user_data($user_id);
if (is_array($extra_user_data) && count($extra_user_data)>0 ) {
echo '
';
echo get_lang('ExtraInformation');
echo '
';
echo '
';
- foreach($extra_user_data as $key=>$data) {
- echo ucfirst($key).': '.$data;
- echo '
';
+
+ foreach($extra_user_data as $key=>$data) {
+
+ // get display text, visibility and type from user_field table
+ $field_variable = str_replace('extra_','',$key);
+ $sql = "SELECT field_display_text,field_visible,field_type FROM $t_uf WHERE field_variable ='$field_variable'";
+ $res_field = Database::query($sql,__FILE__,__LINE__);
+ $row_field = Database::fetch_row($res_field);
+ $field_display_text = $row_field[0];
+ $field_visible = $row_field[1];
+ $field_type = $row_field[2];
+
+ if ($field_visible == 1) {
+ if (is_array($data)) {
+ echo ''.ucfirst($field_display_text).': '.implode(',',$data).'
';
+ } else {
+ if ($field_type == 8) {
+ $id_options = explode(';',$data);
+ $value_options = array();
+ // get option display text from user_field_options table
+ foreach ($id_options as $id_option) {
+ $sql = "SELECT option_display_text FROM $t_ufo WHERE id = '$id_option'";
+ $res_options = Database::query($sql,__FILE__,__LINE__);
+ $row_options = Database::fetch_row($res_options);
+ $value_options[] = $row_options[0];
+ }
+ echo ''.ucfirst($field_display_text).': '.implode(' ',$value_options).'
';
+ }
+ else {
+ echo ''.ucfirst($field_display_text).': '.$data.'
';
+ }
+ }
}
+ }
echo '
';
echo '
';
}
diff --git a/main/survey/survey.php b/main/survey/survey.php
index c3a8db1f4d..6047b9a66c 100644
--- a/main/survey/survey.php
+++ b/main/survey/survey.php
@@ -1,29 +1,10 @@
-, Ghent University: cleanup, refactoring and rewriting large parts of the code
-* @version $Id: survey.php 21734 2009-07-02 17:12:41Z cvargas1 $
+* @version $Id: survey.php 22573 2009-08-03 03:38:13Z yannoo $
*
* @todo use quickforms for the forms
*/
@@ -58,6 +39,7 @@ $table_survey_question_group = Database :: get_course_table(TABLE_SURVEY_QUES
$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$table_user = Database :: get_main_table(TABLE_MAIN_USER);
$user_info = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER);
+$survey_id = intval($_GET['survey_id']);
// breadcrumbs
$interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('SurveyList'));
@@ -66,7 +48,7 @@ $interbreadcrumb[] = array ("url" => "survey_list.php", "name" => get_lang('Surv
if (isset($_GET['survey_id'])) {
$course_code = api_get_course_id();
if ($course_code!=-1) {
- $survey_data = survey_manager::get_survey($_GET['survey_id']);
+ $survey_data = survey_manager::get_survey($survey_id);
} else {
Display :: display_header(get_lang('Survey'));
Display :: display_error_message(get_lang('NotAllowed'), false);
@@ -99,7 +81,7 @@ if($is_survey_type_1 && ($_GET['action']=='addgroup')||($_GET['action']=='delete
}
elseif(!empty($_POST['name']))
{
- api_sql_query('INSERT INTO '.$table_survey_question_group.' (name,description,survey_id) values (\''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($_GET['survey_id']).'\') ');
+ api_sql_query('INSERT INTO '.$table_survey_question_group.' (name,description,survey_id) values (\''.Database::escape_string($_POST['name']).'\',\''.Database::escape_string($_POST['description']).'\',\''.Database::escape_string($survey_id).'\') ');
$sendmsg = 'GroupCreatedSuccessfully';
} else {
$sendmsg = 'GroupNeedName';
@@ -107,11 +89,11 @@ if($is_survey_type_1 && ($_GET['action']=='addgroup')||($_GET['action']=='delete
}
if($_GET['action']=='deletegroup'){
- api_sql_query('DELETE FROM '.$table_survey_question_group.' WHERE id = '.Database::escape_string($_GET['gid']).' and survey_id = '.Database::escape_string($_GET['survey_id']));
+ api_sql_query('DELETE FROM '.$table_survey_question_group.' WHERE id = '.Database::escape_string($_GET['gid']).' and survey_id = '.Database::escape_string($survey_id));
$sendmsg = 'GroupDeletedSuccessfully';
}
- header('Location:survey.php?survey_id='.(int)$_GET['survey_id'].'&sendmsg='.$sendmsg);
+ header('Location:survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg);
exit;
}
@@ -151,30 +133,30 @@ if(!empty($survey_data['survey_version'])) echo '
'.get_lang('Version').': '.$
SurveyUtil::check_first_last_question($_GET['survey_id']);
// Action links
-$survey_actions = ''.Display::return_icon('edit.gif', get_lang('Edit')).' '.get_lang('EditSurvey').'';
-$survey_actions .= ''.Display::return_icon('delete.gif', get_lang('Delete')).' '.get_lang('DeleteSurvey').'';
-//$survey_actions .= ''.Display::return_icon('copy.gif', get_lang('Copy')).'';
-$survey_actions .= ''.Display::return_icon('preview.gif', get_lang('Preview')).' '.get_lang('Preview').'';
-$survey_actions .= ''.Display::return_icon('survey_publish.gif', get_lang('Publish')).' '.get_lang('Publish').'';
-$survey_actions .= ''.Display::return_icon('statistics.gif', get_lang('Reporting')).' '.get_lang('Reporting').'';
+$survey_actions = ''.Display::return_icon('edit.gif', get_lang('Edit')).' '.get_lang('EditSurvey').'';
+$survey_actions .= ''.Display::return_icon('delete.gif', get_lang('Delete')).' '.get_lang('DeleteSurvey').'';
+//$survey_actions .= ''.Display::return_icon('copy.gif', get_lang('Copy')).'';
+$survey_actions .= ''.Display::return_icon('preview.gif', get_lang('Preview')).' '.get_lang('Preview').'';
+$survey_actions .= ''.Display::return_icon('survey_publish.gif', get_lang('Publish')).' '.get_lang('Publish').'';
+$survey_actions .= ''.Display::return_icon('statistics.gif', get_lang('Reporting')).' '.get_lang('Reporting').'';
echo ''.$survey_actions.'
';
if ($survey_data['survey_type']==0) {
echo '';
} else {
echo '';
- echo ''.get_lang('PersonalityQuestion').'';
+ //echo '
'.get_lang('Add groups').'';
+ echo '
'.get_lang('PersonalityQuestion').'';
echo '
';
}
@@ -193,7 +175,7 @@ if($is_survey_type_1) {
echo ' ';
// Displaying the table contents with all the questions
$question_counter = 1;
-$sql = "SELECT * FROM $table_survey_question_group WHERE survey_id = '".Database::escape_string($_GET['survey_id'])."' ORDER BY id";
+$sql = "SELECT * FROM $table_survey_question_group WHERE survey_id = '".Database::escape_string($survey_id)."' ORDER BY id";
$result = api_sql_query($sql, __FILE__, __LINE__);
$groups = array();
while($row = Database::fetch_array($result)) {
@@ -203,7 +185,7 @@ $sql = "SELECT survey_question.*, count(survey_question_option.question_option_i
FROM $table_survey_question survey_question
LEFT JOIN $table_survey_question_option survey_question_option
ON survey_question.question_id = survey_question_option.question_id
- WHERE survey_question.survey_id = '".Database::escape_string($_GET['survey_id'])."'
+ WHERE survey_question.survey_id = '".Database::escape_string($survey_id)."'
GROUP BY survey_question.question_id
ORDER BY survey_question.sort ASC";
$result = api_sql_query($sql, __FILE__, __LINE__);
@@ -231,17 +213,17 @@ while ($row = Database::fetch_array($result,'ASSOC')) {
echo '
'.$tool_name.' | ';
echo '
'.$row['number_of_options'].' | ';
echo '
';
- echo ' '.Display::return_icon('edit.gif', get_lang('Edit')).'';
- echo ' '.Display::return_icon('delete.gif', get_lang('Delete')).'';
+ echo ' '.Display::return_icon('edit.gif', get_lang('Edit')).'';
+ echo ' '.Display::return_icon('delete.gif', get_lang('Delete')).'';
if ($question_counter > 1)
{
- echo ' '.Display::return_icon('up.gif', get_lang('MoveUp')).'';
+ echo ' '.Display::return_icon('up.gif', get_lang('MoveUp')).'';
} else {
Display::display_icon('up_na.gif');
}
if ($question_counter < $question_counter_max)
{
- echo ' '.Display::return_icon('down.gif', get_lang('MoveDown')).'';
+ echo ' '.Display::return_icon('down.gif', get_lang('MoveDown')).'';
} else {
Display::display_icon('down_na.gif');
}
@@ -271,16 +253,16 @@ if($is_survey_type_1)
echo ''.get_lang('Name').' | '.get_lang('Description').' | ';
- echo ' |