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..b0fdc9a652 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
@@ -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 '
';
} 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
-==============================================================================
-*/
+'.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 '
';
@@ -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 '
';
@@ -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 '
';
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 '';
}
}
}
diff --git a/main/wiki/wiki.inc.php b/main/wiki/wiki.inc.php
index 34675e77e8..a9d6d92e7b 100644
--- a/main/wiki/wiki.inc.php
+++ b/main/wiki/wiki.inc.php
@@ -314,16 +314,46 @@ function save_wiki() {
}
//cleaning config variables
-
- $_clean['feedback1']=Database::escape_string(Security::remove_XSS($_POST['feedback1']));
- $_clean['feedback2']=Database::escape_string(Security::remove_XSS($_POST['feedback2']));
- $_clean['feedback3']=Database::escape_string(Security::remove_XSS($_POST['feedback3']));
- $_clean['max_text']=Database::escape_string(Security::remove_XSS($_POST['max_text']));
- $_clean['max_version']=Database::escape_string(Security::remove_XSS($_POST['max_version']));
- $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS($_POST['startdate_assig']));
- $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS($_POST['enddate_assig']));
- $_clean['delayedsubmit']=Database::escape_string(Security::remove_XSS($_POST['delayedsubmit']));
+
+ if(!empty($_POST['task']))
+ {
+ $_clean['task']=Database::escape_string(Security::remove_XSS($_POST['task']));
+ }
+ if(!empty($_POST['feedback1']) || !empty($_POST['feedback2']) || !empty($_POST['feedback3']))
+ {
+ $_clean['feedback1']=Database::escape_string(Security::remove_XSS($_POST['feedback1']));
+ $_clean['feedback2']=Database::escape_string(Security::remove_XSS($_POST['feedback2']));
+ $_clean['feedback3']=Database::escape_string(Security::remove_XSS($_POST['feedback3']));
+ $_clean['fprogress1']=Database::escape_string(Security::remove_XSS($_POST['fprogress1']));
+ $_clean['fprogress2']=Database::escape_string(Security::remove_XSS($_POST['fprogress2']));
+ $_clean['fprogress3']=Database::escape_string(Security::remove_XSS($_POST['fprogress3']));
+ }
+
+ if(Security::remove_XSS($_POST['initstartdate']==1))
+ {
+ $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('startdate_assig')));
+ }
+ else
+ {
+ $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS($_POST['startdate_assig']));
+ }
+
+ if(Security::remove_XSS($_POST['initenddate']==1))
+ {
+ $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('enddate_assig')));
+ }
+ else
+ {
+ $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS($_POST['enddate_assig']));
+ }
+
+ $_clean['delayedsubmit']=Database::escape_string(Security::remove_XSS($_POST['delayedsubmit']));
+ if(!empty($_POST['max_text']) || !empty($_POST['max_version']))
+ {
+ $_clean['max_text']=Database::escape_string(Security::remove_XSS($_POST['max_text']));
+ $_clean['max_version']=Database::escape_string(Security::remove_XSS($_POST['max_version']));
+ }
$sql="INSERT INTO ".$tbl_wiki." (page_id, reflink, title, content, user_id, group_id, dtime, assignment, comment, progress, version, linksto, user_ip) VALUES ('".$_clean['page_id']."','".$_clean['reflink']."','".$_clean['title']."','".$_clean['content']."','".$_clean['user_id']."','".$_clean['group_id']."','".$dtime."','".$_clean['assignment']."','".$_clean['comment']."','".$_clean['progress']."','".$_clean['version']."','".$_clean['linksto']."','".Database::escape_string($_SERVER['REMOTE_ADDR'])."')";
@@ -332,12 +362,20 @@ function save_wiki() {
if ($_clean['page_id'] ==0)
{
- $sql='UPDATE '.$tbl_wiki.' SET page_id="'.$Id.'" WHERE id="'.$Id.'"';
+ $sql='UPDATE '.$tbl_wiki.' SET page_id="'.$Id.'" WHERE id="'.$Id.'"';
api_sql_query($sql,__FILE__,__LINE__);
}
//update wiki config
- $sql='UPDATE'.$tbl_wiki.' SET page_id="'.$Id.'", feedback1="'.$_clean['feedback1'].'", feedback2="'.$_clean['feedback2'].'", feedback3="'.$_clean['feedback3'].'", max_text="'.$_clean['max_text'].'", max_version="'.$_clean['max_version'].'", startdate_assig="'.$_clean['startdate_assig'].'", enddate_assig="'.$_clean['enddate_assig'].'", delayedsubmit="'.$_clean['delayedsubmit'].'" WHERE id="'.$Id.'"';
+
+ if ($_clean['reflink']=='index' && $_clean['version']==1)
+ {
+ $sql="INSERT INTO ".$tbl_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3, max_text, max_version, startdate_assig, enddate_assig, delayedsubmit) VALUES ('".$Id."','".$_clean['task']."','".$_clean['feedback1']."','".$_clean['feedback2']."','".$_clean['feedback3']."','".$_clean['fprogress1']."','".$_clean['fprogress2']."','".$_clean['fprogress3']."','".$_clean['max_text']."','".$_clean['max_version']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."')";
+ }
+ else
+ {
+ $sql='UPDATE'.$tbl_wiki_conf.' SET task="'.$_clean['task'].'", feedback1="'.$_clean['feedback1'].'", feedback2="'.$_clean['feedback2'].'", feedback3="'.$_clean['feedback3'].'", fprogress1="'.$_clean['fprogress1'].'", fprogress2="'.$_clean['fprogress2'].'", fprogress3="'.$_clean['fprogress3'].'", max_text="'.$_clean['max_text'].'", max_version="'.$_clean['max_version'].'", startdate_assig="'.$_clean['startdate_assig'].'", enddate_assig="'.$_clean['enddate_assig'].'", delayedsubmit="'.$_clean['delayedsubmit'].'" WHERE page_id="'.$_clean['page_id'].'"';
+ }
api_sql_query($sql,__FILE__,__LINE__);
api_item_property_update($_course, 'wiki', $Id, 'WikiAdded', api_get_user_id(), $_clean['group_id']);
@@ -454,19 +492,37 @@ function save_new_wiki() {
$_clean['linksto'] = links_to($_clean['content']); //check wikilinks
- //cleaning config variables
+ //cleaning config variables
+ $_clean['task']=Database::escape_string(Security::remove_XSS($_POST['task']));
$_clean['feedback1']=Database::escape_string(Security::remove_XSS($_POST['feedback1']));
$_clean['feedback2']=Database::escape_string(Security::remove_XSS($_POST['feedback2']));
$_clean['feedback3']=Database::escape_string(Security::remove_XSS($_POST['feedback3']));
$_clean['fprogress1']=Database::escape_string(Security::remove_XSS($_POST['fprogress1']));
$_clean['fprogress2']=Database::escape_string(Security::remove_XSS($_POST['fprogress2']));
$_clean['fprogress3']=Database::escape_string(Security::remove_XSS($_POST['fprogress3']));
- $_clean['max_text']=Database::escape_string(Security::remove_XSS($_POST['max_text']));
- $_clean['max_version']=Database::escape_string(Security::remove_XSS($_POST['max_version']));
- $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('startdate_assig')));
- $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('enddate_assig')));
- $_clean['delayedsubmit']=Database::escape_string(Security::remove_XSS($_POST['delayedsubmit']));
+
+ if(Security::remove_XSS($_POST['initstartdate']==1))
+ {
+ $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('startdate_assig')));
+ }
+ else
+ {
+ $_clean['startdate_assig']=Database::escape_string(Security::remove_XSS($_POST['startdate_assig']));
+ }
+
+ if(Security::remove_XSS($_POST['initenddate']==1))
+ {
+ $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS(get_date_from_select('enddate_assig')));
+ }
+ else
+ {
+ $_clean['enddate_assig']=Database::escape_string(Security::remove_XSS($_POST['enddate_assig']));
+ }
+ $_clean['delayedsubmit']=Database::escape_string(Security::remove_XSS($_POST['delayedsubmit']));
+ $_clean['max_text']=Database::escape_string(Security::remove_XSS($_POST['max_text']));
+ $_clean['max_version']=Database::escape_string(Security::remove_XSS($_POST['max_version']));
+
//filter no _uass
if (api_eregi('_uass', $_POST['title']) || (api_strtoupper(trim($_POST['title'])) == 'INDEX' || api_strtoupper(trim(api_htmlentities($_POST['title'], ENT_QUOTES, $charset))) == api_strtoupper(api_htmlentities(get_lang('DefaultTitle'), ENT_QUOTES, $charset)))) {
$message= get_lang('GoAndEditMainPage');
@@ -488,7 +544,7 @@ function save_new_wiki() {
api_sql_query($sql,__FILE__,__LINE__);
//insert wiki config
- $sql="INSERT INTO ".$tbl_wiki_conf." (page_id, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3, max_text, max_version, startdate_assig, enddate_assig, delayedsubmit) VALUES ('".$Id."','".$_clean['feedback1']."','".$_clean['feedback2']."','".$_clean['feedback3']."','".$_clean['fprogress1']."','".$_clean['fprogress2']."','".$_clean['fprogress3']."','".$_clean['max_text']."','".$_clean['max_version']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."')";
+ $sql="INSERT INTO ".$tbl_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3, max_text, max_version, startdate_assig, enddate_assig, delayedsubmit) VALUES ('".$Id."','".$_clean['task']."','".$_clean['feedback1']."','".$_clean['feedback2']."','".$_clean['feedback3']."','".$_clean['fprogress1']."','".$_clean['fprogress2']."','".$_clean['fprogress3']."','".$_clean['max_text']."','".$_clean['max_version']."','".$_clean['startdate_assig']."','".$_clean['enddate_assig']."','".$_clean['delayedsubmit']."')";
api_sql_query($sql,__LINE__,__FILE__);
api_item_property_update($_course, 'wiki', $Id, 'WikiAdded', api_get_user_id(), $_clean['group_id']);
@@ -522,7 +578,7 @@ return true;
}
';
echo '';
echo '
* '.get_lang(Title).':
';
@@ -531,25 +587,31 @@ return true;
{
$_clean['group_id']=(int)$_SESSION['_gid']; // TODO: check if delete ?
-
- // echo'
'.Display::return_icon('div_show.gif',get_lang('Show')).' '.get_lang('AdvancedParameters').' '; // TODO: under develop, uncoment and activate later
+
+ echo'
'.Display::return_icon('div_show.gif',get_lang('Show')).' '.get_lang('AdvancedParameters').' ';
echo '
';
- //time limit
- echo '
'.get_lang('PutATimeLimit').'';
- echo '
';
- echo '
';
- echo '
'.get_lang('StartDate').' :'.draw_date_picker('startdate_assig').'
';
- echo '
'.get_lang('EndDate').' :'.draw_date_picker('enddate_assig').'
';
- echo get_lang('AllowLaterSends').'
';
- echo '
';
+ //task
+ echo '
'.get_lang('DescriptionOfTheTask').'';
+ echo '
';
+ echo '
';
+
+ echo '
';
+ echo '';
+ echo ''.get_lang('DescriptionOfTheTask').' ';
+ echo ' ';
+ echo '';
+ echo ''.stripslashes($row['task']).' ';
+ echo ' ';
+ echo '
';
+ echo '
';
//feedback
- echo '
'.get_lang('AddAutomaticFeedbacks').'';
- echo '
';
- echo '
';
+ echo '
'.get_lang('AddFeedback').'';
+ echo '
';
+ echo '
';
- echo '
';
+ echo '';
echo '';
echo ''.get_lang('Feedback1').' ';
echo ''.get_lang('Feedback2').' ';
@@ -562,7 +624,7 @@ return true;
echo ' ';
echo '';
echo ''.get_lang('FProgress').': ';
- echo '
+ echo '
0
10
20
@@ -576,7 +638,7 @@ return true;
100
% ';
echo ''.get_lang('FProgress').': ';
- echo '
+ echo '
0
10
20
@@ -607,20 +669,42 @@ return true;
echo '
';
echo '';
- //other max limit
- echo ' '.get_lang('SettingOtherLimitations').'';
+ //time limit
+ echo '
'.get_lang('PutATimeLimit').'';
+ echo ' ';
+ echo '';
+
+ //other limit
+ echo '
'.get_lang('OtherSettings').'';
echo ' ';
- echo ' ';
- echo get_lang('Max_text').' '.get_lang('Max_version').' ';
- echo '
';
-
+ echo '';
+
//to define as an individual assignment
- echo ' '.get_lang('DefineAssignmentPage').'
'; // 1= teacher 2 =student
-
+ echo ''; // 1= teacher 2 =student
+ //
echo'';
- echo '
';
-
}
echo '';
echo '';
@@ -661,6 +745,7 @@ function display_wiki_entry()
{
global $charset;
global $tbl_wiki;
+ global $tbl_wiki_conf;
global $groupfilter;
global $page;
@@ -669,7 +754,8 @@ function display_wiki_entry()
if ($_GET['view'])
{
$_clean['view']=(int)Database::escape_string($_GET['view']);
- $filter=" AND id='".$_clean['view']."'";
+
+ $filter=' AND '.$tbl_wiki.'.id="'.$_clean['view'].'"';
}
//first, check page visibility in the first page version
@@ -679,9 +765,9 @@ function display_wiki_entry()
$KeyVisibility=$row['visibility'];
// second, show the last version
- $sql="SELECT * FROM ".$tbl_wiki."WHERE reflink='".html_entity_decode(Database::escape_string(stripslashes(urldecode($page))))."' AND $groupfilter $filter ORDER BY id DESC";
- $result=api_sql_query($sql,__LINE__,__FILE__);
- $row=Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version
+ $sql='SELECT * FROM '.$tbl_wiki.', '.$tbl_wiki_conf.' WHERE '.$tbl_wiki_conf.'.page_id='.$tbl_wiki.'.page_id AND '.$tbl_wiki.'.reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$tbl_wiki.'.'.$groupfilter.' '.$filter.' ORDER BY id DESC';
+ $result=api_sql_query($sql,__LINE__,__FILE__);
+ $row=Database::fetch_array($result); // we do not need a while loop since we are always displaying the last version
//update visits
@@ -712,7 +798,7 @@ function display_wiki_entry()
}
- //assignment mode: for identify page type
+ //assignment mode: identify page type
if(stripslashes($row['assignment'])==1)
{
$icon_assignment='
';
@@ -721,8 +807,13 @@ function display_wiki_entry()
{
$icon_assignment='
';
}
-
-
+
+ //task mode
+
+ if (!empty($row['task']))
+ {
+ $icon_task='
';
+ }
//Show page. Show page to all users if isn't hide page. Mode assignments: if student is the author, can view
if($KeyVisibility=="1" || api_is_allowed_to_edit() || api_is_platform_admin() || ($row['assignment']==2 && $KeyVisibility=="0" && (api_get_user_id()==$row['user_id'])))
@@ -833,7 +924,7 @@ function display_wiki_entry()
if (wiki_exist($title))
{
- echo $icon_assignment.' '.stripslashes($title);
+ echo $icon_assignment.' '.$icon_task.' '.stripslashes($title);
}
else
{
@@ -1723,17 +1814,6 @@ function double_post($wpost_id)
}
}
-/**
- * Function convert date to number
- * 2008-10-12 00:00:00 ---to--> 12345672218 (timestamp)
- */
-function convert_date_to_number($default)
-{
- $parts = split(' ',$default);
- list($d_year,$d_month,$d_day) = split('-',$parts[0]);
- list($d_hour,$d_minute,$d_second) = split(':',$parts[1]);
- return mktime($d_hour, $d_minute, $d_second, $d_month, $d_day, $d_year);
-}
/**
* Function wizard individual assignment
@@ -1980,7 +2060,7 @@ function display_wiki_search_results($search_term, $search_content=0)
*
*/
function draw_date_picker($prefix,$default='') {
- //$default = 2008-10-01 10:00:00
+
if(empty($default)) {
$default = date('Y-m-d H:i:s');
}
@@ -2007,7 +2087,7 @@ function draw_date_picker($prefix,$default='') {
array_unshift($minute,'00','01','02','03','04','05','06','07','08','09');
$date_form = make_select($prefix.'_day', array_combine(range(1,31),range(1,31)), $d_day);
$date_form .= make_select($prefix.'_month', $month_list, $d_month);
- $date_form .= make_select($prefix.'_year', array( $d_year=> $d_year, $d_year+1=>$d_year+1), $d_year).' ';
+ $date_form .= make_select($prefix.'_year', array($d_year-2=>$d_year-2, $d_year-1=>$d_year-1, $d_year=> $d_year, $d_year+1=>$d_year+1, $d_year+2=>$d_year+2), $d_year).' ';
$date_form .= make_select($prefix.'_hour', array_combine(range(0,23),range(0,23)), $d_hour).' : ';
$date_form .= make_select($prefix.'_minute', $minute, $d_minute);
return $date_form;
@@ -2026,14 +2106,6 @@ function make_select($name,$values,$checked='') {
return $output;
}
-/**
- * Enter description here...
- *
- */
-function make_checkbox($name,$checked='') {
- return '' .
- '
';
-}
/**
* Enter description here...
@@ -2051,4 +2123,5 @@ function two_digits($number)
$number = (int)$number;
return ($number < 10) ? '0'.$number : $number;
}
+
?>
\ No newline at end of file
diff --git a/tests/all.test2.php b/tests/all.test2.php
new file mode 100644
index 0000000000..87ec7c2982
--- /dev/null
+++ b/tests/all.test2.php
@@ -0,0 +1,25 @@
+TestSuite('All tests2');
+ //$this->addTestFile(dirname(__FILE__).'/main/admin/calendar.lib.test.php');
+ $this->addTestFile(dirname(__FILE__).'/main/admin/statistics/statistics.lib.test.php');
+ }
+}
+$test = &new AllTests2();
+//$test-> run( new HtmlReporter());
+
+?>
diff --git a/tests/main/admin/calendar.lib.test.php b/tests/main/admin/calendar.lib.test.php
new file mode 100644
index 0000000000..9ffcb99103
--- /dev/null
+++ b/tests/main/admin/calendar.lib.test.php
@@ -0,0 +1,688 @@
+UnitTestCase('testing the file about calendar/agenda');
+
+ }
+
+ public function testDisplayMinimonthcalendar(){
+ ob_start();
+ global $DaysShort;
+ $agendaitems=array('abc','cde');
+ $month=11;
+ $year=2008;
+ $monthName='';
+ $res = display_minimonthcalendar($agendaitems, $month, $year, $monthName);
+ ob_end_clean();
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ public function testToJavascript(){
+ $res = to_javascript();
+ $this->assertTrue($res);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ public function testUserGroupFilterJavascript(){
+ $res = user_group_filter_javascript();
+ $this->assertTrue($res);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ public function testDisplayMonthcalendar(){
+ ob_start();
+ global $MonthsLong;
+ global $DaysShort;
+ global $origin;
+ $month=05;
+ $year=2010;
+ $res = display_monthcalendar($month, $year);
+ ob_end_clean();
+ $this->assertTrue(is_null($res));
+ $this->assertNull($res);
+ //var_dump($res);
+ }
+
+ public function testStoreNewAgendaItem(){
+ global $_user;
+ $res = store_new_agenda_item();
+ $this->assertFalse($res);
+ $this->assertTrue(is_null($res));
+ $this->assertNull($res);
+ //var_dump($res);
+ }
+
+ public function testDisplayCourseadminLinks(){
+ ob_start();
+ $res = display_courseadmin_links();
+ ob_end_clean();
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ public function testDisplayStudentLinks(){
+ ob_start();
+ global $show;
+ $res = display_student_links();
+ ob_end_clean();
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ public function testGetAgendaItem(){
+ $realgrouplist= new MockDatabase();
+ $id=1;
+ $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ $sql= "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'";
+ $sql_result = api_sql_query($sql,__FILE__,__LINE__);
+ $result= Database::fetch_array($result);
+ $real_list[] = $result;
+ $res = get_agenda_item($id);
+ if(is_array($real_list))
+ $this->assertTrue(is_array($real_list));
+ else{
+ $this->assertTrue(is_null($real_list));
+ $this->assertTrue($real_list === true || $real_list === false);
+ }
+ $realgrouplist->expectOnce($real_list);
+ $this->assertTrue(is_array($res));
+ //var_dump($real_list);
+ //var_dump($res);
+ }
+
+ public function testStoreEditedAgendaItem(){
+ ob_start();
+ $instans = new MockDisplay();
+ $id=1;
+ $title='';
+ $content='';
+ $start_date= 21;
+ $end_date=25;
+ $res = store_edited_agenda_item();
+ $instans = Display::display_normal_message(get_lang("EditSuccess"));
+ $edit_result=save_edit_agenda_item($id,$title,$content,$start_date,$end_date);
+ ob_end_clean();
+ $this->assertTrue(is_null($instans));
+ $this->assertTrue($edit_result);
+ //var_dump($instans);
+ //var_dump($edit_result);
+ }
+
+ public function testSaveEditAgendaItem(){
+ $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ $id=Database::escape_string($id);
+ $title=Database::escape_string($title);
+ $content=Database::escape_string($content);
+ $start_date=Database::escape_string($start_date);
+ $end_date=Database::escape_string($end_date);
+ $res = save_edit_agenda_item($id,$title,$content,$start_date,$end_date);
+ $this->assertTrue($res);
+ $this->assertTrue($TABLEAGENDA);
+ $this->assertTrue(is_bool($res));
+ //var_dump($res);
+ //var_dump($TABLEAGENDA);
+ }
+
+ public function testDeleteAgendaItem(){
+ $realagenda= new MockDatabase();
+ $realagenda1 = new MockDisplay();
+ global $_course;
+ $id=Database::escape_string($id);
+ $res = delete_agenda_item($id);
+ $sql = "SELECT * FROM $t_agenda WHERE id = $id";
+ $sql_result = Database::query($sql,__FILE__,__LINE__);
+ $result = Database::fetch_array($sql_result);
+ $real_agenda[] = $result;
+ $res= delete_agenda_item($id);
+ $realagenda->expectOnce($real_agenda);
+ $this->assertTrue($real_agenda);
+ $this->assertTrue(is_null($res));
+ $this->assertTrue(is_array($real_agenda));
+ //var_dump($res);
+ //var_dump($real_agenda);
+ }
+
+ public function testShowhideAgendaItem(){
+ ob_start();
+ $instans = new MockDisplay();
+ $id=1;
+ global $nameTools;
+ $res = showhide_agenda_item($id);
+ $real_show = Display::display_normal_message(get_lang("VisibilityChanged"));
+ $instans_real[] = $real_show;
+ $instans->expectOnce($instans_real);
+ ob_end_clean();
+ $this->assertTrue(is_object($instans));
+ $this->assertTrue(is_array($instans_real));
+ //var_dump($instans);
+ //var_dump($res);
+ //var_dump($instans_real);
+ }
+ /**
+ * Para poder ejecutar la funcion display_agenda_items(), es
+ * necesario comentar el die de la linea 718, porque sino, no se
+ * podria realizar la prueba.
+ */
+ public function testDisplayAgendaItems(){
+ ob_start();
+ $realdisplay = new MockDatabase();
+ $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ global $select_month, $select_year;
+ global $DaysShort, $DaysLong, $MonthsLong;
+ global $is_courseAdmin;
+ global $dateFormatLong, $timeNoSecFormat,$charset, $_user, $_course;
+ $sql = "SELECT * FROM ".$TABLEAGENDA.' ORDER BY start_date '.$_SESSION['sort'];
+ $result=api_sql_query($sql,__FILE__,__LINE__);
+ $real_display[] = $result;
+ $res = display_agenda_items();
+ ob_end_clean();
+ $realdisplay->expectOnce($real_display);
+ $this->assertTrue(is_null($res));
+ $this->assertTrue(is_array($real_display));
+ $realdisplay->expectOnce($real_display);
+ //var_dump($res);
+ //var_dump($real_display);
+ //var_dump($realdisplay);
+ }
+ /**
+ * Para poder ejecutar esta prueba es necesario comentar el
+ * die de la linea 984.
+ */
+ public function testDisplayOneAgendaItem(){
+ ob_start();
+ $realdisplayone = new MockDatabase();
+ $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ global $TABLE_ITEM_PROPERTY;
+ global $select_month, $select_year;
+ global $DaysShort, $DaysLong, $MonthsLong;
+ global $is_courseAdmin;
+ global $dateFormatLong, $timeNoSecFormat, $charset;
+ global $_user;
+ $agenda_id=2;
+ $agenda_id=Database::escape_string($agenda_id);
+ $sql = "SELECT * FROM ".$TABLEAGENDA;
+ $sql_result=api_sql_query($sql,__FILE__,__LINE__);
+ $myrow=Database::fetch_array($sql_result);
+ $real_display_one[]= $$myrow;
+ //$res = display_one_agenda_item($agenda_id);
+ ob_end_clean();
+ $realdisplayone->expectOnce($real_display_one);
+ $this->assertTrue(is_array($real_display_one));
+ //var_dump($res);
+ //var_dump($realdisplayone);
+ //var_dump($real_display_one);
+ }
+
+ /*public function testShowGroupFilterForm(){
+ $group_list=get_course_groups();
+ $res = show_group_filter_form();
+ $this->assertTrue($res);
+ //var_dump($res);
+ }
+
+ public function testShowUserFilterForm(){
+
+ $res = show_user_filter_form();
+ $this->assertTrue($res);
+ //var_dump($res);
+ }
+ */
+ public function testShowAddForm(){
+ ob_start();
+ global $MonthsLong;
+ $id='';
+ $res= show_add_form($id);
+ ob_end_clean();
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ public function testGetAgendaitems(){
+ $realgetagenda = new MockDatabase();
+ $$TABLEAGENDA = Database :: get_course_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ $month=06;
+ $year=2010;
+ global $MonthsLong;
+ $month=Database::escape_string($month);
+ $year=Database::escape_string($year);
+ $sqlquery = "SELECT
+ DISTINCT *
+ FROM ".$TABLEAGENDA."
+ WHERE
+ MONTH(start_date)='".$month."'
+ AND YEAR(start_date)='".$year."'
+ GROUP BY id
+ ORDER BY start_date ";
+ $sql_result = api_sql_query($sqlquery, __FILE__, __LINE__);
+ $result = Database::fetch_array($sql_result);
+ $real_get_agenda[] = $result;
+ $res = get_agendaitems($month, $year);
+ $this->assertTrue(is_array($res));
+ $realgetagenda->expectOnce($real_get_agenda);
+ $this->assertTrue(is_array($real_get_agenda));
+ //var_dump($res);
+ //var_dump($real_get_agenda);
+ //var_dump($realgetagenda);
+ }
+
+ public function testDisplayUpcomingEvents(){
+ ob_start();
+ $realdisplay = new MockDatabase();
+ $TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ $sqlquery = "SELECT
+ DISTINCT *
+ FROM ".$TABLEAGENDA."
+ ORDER BY start_date ";
+ $result = api_sql_query($sqlquery, __FILE__, __LINE__);
+ $resultado = Database::fetch_array($result,'ASSOC');
+ $real_display[] = $resultado;
+ $res = display_upcoming_events();
+ $realdisplay->expectOnce($real_display);
+ ob_end_clean();
+ $this->assertTrue(is_array($real_display));
+ $this->assertTrue(is_null($res));
+ //var_dump($real_display);
+ //var_dump($realdisplay);
+ //var_dump($res);
+ }
+
+ public function testCalculateStartEndOfWeek(){
+ $week_number=4;
+ $year=2011;
+ $res = calculate_start_end_of_week($week_number, $year);
+ $this->assertTrue(is_array($res));
+ $this->assertTrue($res);
+ //var_dump($res);
+ }
+
+ public function testDisplayDaycalendar(){
+ ob_start();
+ $agendaitems='';
+ $day='';
+ $month='';
+ $year='';
+ $weekdaynames='';
+ $monthName='';
+ $res = display_daycalendar($agendaitems, $day, $month, $year, $weekdaynames, $monthName);
+ ob_end_clean();
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ public function testDisplayWeekcalendar(){
+ ob_start();
+ $agendaitems='';
+ $month=10;
+ $year=2011;
+ $weekdaynames='';
+ $monthName='';
+ $res = display_weekcalendar($agendaitems, $month, $year, $weekdaynames, $monthName);
+ ob_end_clean();
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ public function testGetDayAgendaitems(){
+ $realgetday = new MockDatabase();
+ $TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ global $_user;
+ global $_configuration;
+ global $setting_agenda_link;
+ $courses_dbs='';
+ $month=11;
+ $year=2009;
+ $day='';
+ $sqlquery = "SELECT DISTINCT *
+ FROM ".$TABLEAGENDA."
+ WHERE
+ DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
+ GROUP BY agenda.id
+ ORDER BY start_date ";
+ $result = api_sql_query($sqlquery, __FILE__, __LINE__);
+ $item = Database::fetch_array($result);
+ $real_get_day[] = $item;
+ $res = get_day_agendaitems($courses_dbs, $month, $year, $day);
+ $realgetday->expectOnce($real_get_day);
+ $this->assertTrue(is_array($real_get_day));
+ $this->assertTrue(is_array($res));
+ //var_dump($res);
+ //var_dump($real_get_day);
+ //var_dump($$realgetday);
+ }
+
+ public function testGetWeekAgendaitems(){
+ $realgetweek = new MockDatabase();
+ $TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ global $_user;
+ global $_configuration;
+ global $setting_agenda_link;$month='';
+ $courses_dbs='';
+ $year='';
+ $week = '';
+ $sqlquery = "SELECT DISTINCT * FROM ".$TABLEAGENDA." ORDER BY start_date";
+ $result = api_sql_query($sqlquery, __FILE__, __LINE__);
+ $item = Database::fetch_array($result);
+ $real_get_week[]= $item;
+ $res = get_week_agendaitems($courses_dbs, $month, $year, $week);
+ $realgetweek->expectOnce($real_get_week);
+ $this->assertTrue(is_array($real_get_week));
+ $this->assertTrue($realgetweek);
+ $this->assertTrue(is_array($res));
+ //var_dump($res);
+ //var_dump($real_get_week);
+ //var_dump($realgetweek);
+ }
+
+ public function testGetRepeatedEventsDayView(){
+ $realgetrepeat = new MockDatabase();
+ $course_info='';
+ $start=0;
+ $end=0;
+ $params='';
+ $t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']);
+ $t_ip = Database::get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']);
+ $sql = "SELECT c.id, c.title, c.content, " .
+ " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " .
+ " cr.cal_type, cr.cal_end " .
+ " FROM $t_cal c, $t_cal_repeat cr, $t_ip as item_property " .
+ " WHERE cr.cal_end >= $start " .
+ " AND cr.cal_id = c.id " .
+ " AND item_property.ref = c.id ".
+ " AND item_property.tool = '".TOOL_CALENDAR_EVENT."' ".
+ " AND c.start_date <= '$db_start' "
+ .(!empty($params['conditions'])?$params['conditions']:'')
+ .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
+ .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
+ $res = api_sql_query($sql,__FILE__,__LINE__);
+ $row = Database::fetch_array($res);
+ $real_get_repeat[] = $row;
+ $resul = get_repeated_events_day_view($course_info,$start,$end,$params);
+ $realgetrepeat->expectOnce($real_get_repeat);
+ $this->assertTrue(is_array($real_get_repeat));
+ $this->assertTrue(is_array($resul));
+ //var_dump($resul);
+ //var_dump($realgetrepeat);
+ //var_dump($real_get_repeat);
+ }
+
+ public function testget_repeated_events_week_view(){
+ $realgetrepeated = new MockDatabase();
+ $course_info='';
+ $start=0;
+ $end=0;
+ $params='';
+ $t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ $sql = "SELECT c.id, c.title, c.content " .
+ " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " .
+ " FROM". $t_cal ."
+ WHERE c.start_date <= '$db_start' "
+ .(!empty($params['conditions'])?$params['conditions']:'')
+ .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
+ .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
+ $res = api_sql_query($sql,__FILE__,__LINE__);
+ $row = Database::fetch_array($res);
+ $real_get_repeated[] = $row;
+ $resul = get_repeated_events_week_view($course_info,$start,$end,$params);
+ $realgetrepeated->expectOnce($real_get_repeated);
+ $this->assertTrue(is_array($resul));
+ $this->assertTrue($real_get_repeated);
+ //var_dump($resul);
+ //var_dump($real_get_repeated);
+ //var_dump($realgetrepeated);
+ }
+
+ public function testGetRepeatedEventsMonthView(){
+ $realgetrepeated= new MockDatabase();
+ $course_info='';
+ $start='';
+ $end='';
+ $params='';
+ $t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ $sql = "SELECT c.id, c.title, c.content, " .
+ " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " .
+ " cr.cal_type, cr.cal_end " .
+ " FROM $t_cal c, $t_cal_repeat cr, $t_ip as item_property " .
+ " WHERE cr.cal_end >= $start " .
+ " AND cr.cal_id = c.id " .
+ " AND item_property.ref = c.id ".
+ " AND item_property.tool = '".TOOL_CALENDAR_EVENT."' ".
+ " AND c.start_date <= '$db_start' "
+ .(!empty($params['conditions'])?$params['conditions']:'')
+ .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
+ .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
+ $res = api_sql_query($sql,__FILE__,__LINE__);
+ $row = Database::fetch_array($res);
+ $real_get_repeated[] = $row;
+ $resul= get_repeated_events_month_view($course_info,$start,$end,$params);
+ $realgetrepeated->expectOnce($real_get_repeated);
+ $this->assertTrue(is_array($resul));
+ $this->assertTrue(is_bool($res));
+ $this->assertTrue($res === false || $res === true);
+ $this->assertTrue($real_get_repeated);
+ //var_dump($resul);
+ //var_dump($real_get_repeated);
+ //var_dump($realgetrepeated);
+ }
+
+ public function testGetRepeatedEventsListView(){
+ $realgetrepeatedevents = new MockDatabase();
+ $course_info='';
+ $start=0;
+ $end=0;
+ $params='';
+ $t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']);
+ $sql = "SELECT c.id, c.title, c.content, " .
+ " UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " .
+ " cr.cal_type, cr.cal_end " .
+ " FROM $t_cal c, $t_cal_repeat cr, $t_ip as item_property " .
+ " WHERE cr.cal_end >= $start " .
+ " AND cr.cal_id = c.id " .
+ " AND item_property.ref = c.id ".
+ " AND item_property.tool = '".TOOL_CALENDAR_EVENT."' ".
+ " AND c.start_date <= '$db_start' "
+ .(!empty($params['conditions'])?$params['conditions']:'')
+ .(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'')
+ .(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:'');
+ $res = api_sql_query($sql,__FILE__,__LINE__);
+ $row = Database::fetch_array($res);
+ $real_get_repeated_events[] = $row;
+ $resul = get_repeated_events_list_view($course_info,$start,$end,$params);
+ $realgetrepeatedevents->expectOnce($real_get_repeated_events);
+ $this->assertTrue(is_array($real_get_repeated_events));
+ $this->assertTrue(is_array($resul));
+ $realgetrepeatedevents->expectCallCount($real_get_repeated_events);
+ //var_dump($resul);
+ //var_dump($real_get_repeated_events);
+ //var_dump($realgetrepeatedevents);
+ }
+
+ public function testIsRepeatedEvent() {
+ $realrepetead = new MockDatabase();
+ $id=1;
+ $course=null;
+ $sql = "SELECT * FROM $t_agenda_repeat WHERE cal_id = $id";
+ $res = Database::query($sql,__FILE__,__LINE__);
+ $result = Database::num_rows($res)>0;
+ $real_repetead[] = $result;
+ $resu = is_repeated_event($id,$course);
+ $realrepetead->expectOnce($real_repetead);
+ $this->assertTrue(is_bool($resu));
+ $this->assertTrue($resu === true || $resu === false);
+ $this->assertTrue($real_repetead);
+ $this->assertTrue($realrepetead);
+ //var_dump($resu);
+ //var_dump($real_repetead);
+ //var_dump($realrepetead);
+ }
+
+ public function testAddWeek(){
+ $timestamp=12;
+ $num=1;
+ $res = add_week($timestamp,$num);
+ $this->assertTrue(is_numeric($res));
+ //var_dump($res);
+ }
+
+ public function testAddMonth(){
+ $timestamp=5;
+ $num=1;
+ $res = add_month($timestamp,$num);
+ $this->assertTrue(is_numeric($res));
+ //var_dump($res);
+ }
+
+ public function testAddYear(){
+ $timestamp=9999;
+ $num=1;
+ $res = add_year($timestamp,$num);
+ $this->assertTrue(is_numeric($res));
+ //var_dump($res);
+ }
+ /**
+ * para poder realizar esta prueba, se tuvo que comentar el "die" ubicado en la
+ * linea 2877 para que la prueba pudiera ejecutarse de manera exitosa.
+ */
+ public function testAgendaAddItem(){
+
+ $realagenda = new MockDatabase();
+ global $_course;
+ $course_info='null';
+ $title='test';
+ $content='test function';
+ $db_start_date='07/11/2009';
+ $db_end_date='07/20/2009';
+ $to=array();
+ $parent_id=null;
+ $t_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ $title = Database::escape_string($title);
+ $content = Database::escape_string($content);
+ $start_date = Database::escape_string($db_start_date);
+ $end_date = Database::escape_string($db_end_date);
+ $sql = "SELECT * FROM $t_agenda WHERE title='$title' AND content = '$content' AND start_date = '$start_date'
+ AND end_date = '$end_date' ".(!empty($parent_id)? "AND parent_event_id = '$parent_id'":"");
+ $result = api_sql_query($sql,__FILE__,__LINE__);
+ $sql1 = "INSERT INTO ".$t_agenda."(title,content, start_date, end_date)VALUES
+ ('".$title."','".$content."', '".$start_date."','".$end_date."')";
+ $result1 = api_sql_query($sql1,__FILE__,__LINE__);
+ $real_agenda[]= $result;
+ $real_agenda1[]= $result1;
+ //$res = agenda_add_item($course_info, $title, $content, $db_start_date, $db_end_date, $to, $parent_id);
+ $realagenda->expectOnce($real_agenda);
+ $realagenda->expectOnce($real_agenda1);
+ //$this->assertTrue(is_numeric($res));
+ $this->assertTrue(is_array($real_agenda));
+ $this->assertTrue(is_array($real_agenda1));
+ //var_dump($res);
+ //var_dump($real_agenda);
+ //var_dump($real_agenda1);
+ }
+
+ public function testGetCalendarItems(){
+ $realgetcalendar = new MockDatabase();
+ global $_user, $_course;
+ global $is_allowed_to_edit;
+ $month='march';
+ $year='2009';
+ $TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
+ $sql="SELECT
+ DISTINCT *
+ FROM ".$TABLEAGENDA." agenda
+ WHERE MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."'
+ GROUP BY id ".
+ "ORDER BY start_date ";
+ $result=api_sql_query($sql,__FILE__,__LINE__);
+ $row=Database::fetch_array($result);
+ $res = get_calendar_items($month, $year);
+ $real_get_calendar[]= $row;
+ $realgetcalendar->expectOnce($real_get_calendar);
+ $realgetcalendar->expectCallCount($real_get_calendar);
+ $this->assertTrue(is_bool($row));
+ $this->assertTrue(is_array($real_get_calendar));
+ $this->assertTrue(is_array($res));
+ //var_dump($real_get_calendar);
+ //var_dump($row);
+ //var_dump($res);
+ }
+
+ public function testAgendaAddRepeatItem(){
+ $realagenda = new MockDatabase();
+ $course_info='course of test';
+ $orig_id=001;
+ $type='daily';
+ $end=10;
+ $orig_dest='monday';
+ $t_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']);
+ $sql = "SELECT title, content, start_date as sd, end_date as ed FROM $t_agenda WHERE id = $orig_id";
+ $res = Database::query($sql,__FILE__,__LINE__);
+ $row = Database::fetch_array($res);
+ $sql1 = "INSERT INTO $t_agenda_r (cal_id, cal_type, cal_end)" .
+ " VALUES ($orig_id,'$type',$end)";
+ $res1 = Database::query($sql1,__FILE__,__LINE__);
+ $resu= agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest);
+ $real_agenda[] = $row;
+ $realagenda->expectOnce($real_agenda);
+ $realagenda->expectCallCount($real_agenda);
+ $realagenda->expectOnce($t_agenda);
+ $realagenda->expectOnce($res1);
+ if(is_bool($resu)){
+ $this->assertTrue(is_bool($resu));
+ $this->assertTrue($resu === true || $resu===false);
+ }else
+ $this->assertTrue(is_null($resu));
+ $this->assertTrue(is_array($real_agenda));
+ $this->assertTrue($row);
+ //var_dump($resu);
+ //var_dump($res);
+ //var_dump($res1);
+ //var_dump($real_agenda);
+ }
+
+ public function testAgendaImportIcal(){
+ $course_info='course_test';
+ $file='';
+ $res = agenda_import_ical($course_info,$file);
+ if(is_bool($res)){
+ $this->assertTrue(is_bool($res));
+ $this->assertTrue($res===false || $res === true);
+ }else{
+ $this->assertTrue($res);
+ }
+ //var_dump($res);
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
+?>
diff --git a/tests/main/admin/statistics/statistics.lib.test.php b/tests/main/admin/statistics/statistics.lib.test.php
new file mode 100644
index 0000000000..2915a3863f
--- /dev/null
+++ b/tests/main/admin/statistics/statistics.lib.test.php
@@ -0,0 +1,316 @@
+UnitTestCase('this File test the provides some function for statistics ');
+ }
+
+ public function setUp(){
+ $this-> statisc = new Statistics();
+ }
+
+ public function tearDown(){
+ $this->statisc = null;
+ }
+
+ public function testMakeSizeString(){
+ $size=20960000;
+ $res = Statistics::make_size_string($size);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ public function testCountCourse(){
+ $instans = new MockDatabase();
+
+ $course_code = 'ABC';
+ $course_code2 = 'ABCD';
+ $category_code = NULL;
+ $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach');
+ $res = Statistics::count_courses($category_code);
+ $this->assertTrue(is_numeric($res));
+ $this->assertTrue(count($res) !== 0);
+ //var_dump($res);
+ }
+
+ public function testCountCourse2(){
+ $instans = new MockDatabase();
+ $user_id=1;
+ $course_code = 'ABC';
+ $course_code2 = 'ABCD';
+ $category_code = NULL;
+ $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach');
+ SessionManager::add_courses_to_session($session_id,array($course_code));
+ SessionManager::suscribe_users_to_session($session_id,array($user_id));
+ $res = Statistics::count_courses($category_code);
+ $this->assertTrue(count($res ==0));
+ $this->assertTrue(is_numeric($res));
+ CourseManager::delete_course($course_code);
+ //var_dump($res);
+ }
+
+ public function testCountCourse3(){
+ $user_id=1;
+ $course_code = 'ABC';
+ $course_code2 = 'ABCD';
+ $category_code = NULL;
+ $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach');
+ SessionManager::suscribe_users_to_session($session_id,array($user_id+3));
+ $res = Statistics::count_courses($category_code);
+ $this->assertTrue(is_numeric($res));
+ $this->assertTrue(count($res)!==0);
+ //var_dump($res);
+ }
+
+ public function testCountCourse4(){
+ $user_id=1;
+ $course_code = 'ABC';
+ $course_code2 = 'ABCD';
+ $category_code = NULL;
+ //ob_start();
+ $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach');
+ SessionManager::suscribe_users_to_session($session_id,array($user_id+3));
+ SessionManager::add_courses_to_session($session_id,array());
+ $res = Statistics::count_courses($category_code);
+ $this->assertTrue(is_numeric($res));
+ $this->assertTrue(count($res)!==0);
+ SessionManager::delete_session($session_id);
+ CourseManager::delete_course($course_code2);
+ CourseManager::delete_course($course_code);
+ //ob_end_clean();
+ //var_dump($res);
+ }
+
+ public function testCountUsers(){
+ $user_id =001;
+ $category_code = NULL;
+ $course_code='ABC';
+ $firstName='adam'; $lastName='ivan'; $status='01'; $email='ricardo.rodriguez@dokeos.com'; $loginName='adam'; $password='1234';
+ $count_invisible_courses = true;
+ $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach');
+ SessionManager::suscribe_users_to_session($session_id,array($user_id+3));
+ $res = Statistics::count_users($status, $category_code, $count_invisible_courses);
+ $this->assertTrue(is_numeric($res));
+ $this->assertTrue(count($res)===0 || count($res)!==0);
+ SessionManager::delete_session($session_id);
+ //var_dump($res);
+ }
+
+ public function testGetNumberOfActivities(){
+ $activitis = new MockDatabase();
+ $sql = "SELECT count(default_id) AS total_number_of_items FROM $track_e_default ";
+ $res = api_sql_query($sql, __FILE__, __LINE__);
+ $obj = Database::fetch_object($res);
+ $resu = Statistics::get_number_of_activities();
+ $this->assertTrue(is_numeric($resu));
+ $this->assertTrue(count($resu)==0 || count($resu)!==0);
+ //var_dump($resu);
+ //var_dump($res);
+ }
+
+ public function testGetActivitiesData(){
+ $instans = new MockDatabase();
+ global $dateTimeFormatLong;
+ $from='';
+ $number_of_items=10;
+ $column='';
+ $direction='';
+ $track_e_default = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
+ $table_user = Database::get_main_table(TABLE_MAIN_USER);
+ $sql = "SELECT
+ default_event_type as col0,
+ default_value_type as col1,
+ default_value as col2,
+ user.username as col3,
+ default_date as col4
+ FROM $track_e_default track_default, $table_user user
+ WHERE track_default.default_user_id = user.user_id ";
+ $res = api_sql_query($sql, __FILE__, __LINE__);
+ $row = Database::fetch_row($res);
+ $resu = Statistics::get_activities_data($from, $number_of_items, $column, $direction);
+ $this->assertTrue(is_array($resu));
+ $this->assertTrue($row);
+ //var_dump($resu);
+ //var_dump($row);
+ //var_dump($res);
+ }
+
+ public function testGetCourseCategories(){
+ $user_id =002;
+ $category_code = NULL;
+ $course_code='ABCDE';
+ $real_course_code='00001';
+ $course_title='test1';
+ $wanted_course_code='test2';
+ $course_language='es';
+ $course_category='primary';
+ $code='00001';
+ $session_id = SessionManager::create_session($course_code,2009,07,20,2010,07,20,0,0,1,'coach');
+ CourseManager::create_virtual_course ($real_course_code, $course_title, $wanted_course_code, $course_language, $course_category);
+ $res = Statistics::get_course_categories();
+ $this->assertTrue($res);
+ CourseManager::delete_course($code);
+ //var_dump($res);
+ }
+
+ public function testRescale(){
+ $data=array('aas','aaa'.'aab');
+ $max = 500;
+ $res = Statistics::rescale($data, $max);
+ $this->assertTrue($res);
+ $this->assertTrue(is_array($res));
+ //var_dump($res);
+ }
+
+ public function testPrintStats(){
+ ob_start();
+ $title='testing';
+ $stats=array('aa','bb','cc');
+ $show_total = true;
+ $is_file_size = false;
+ $res = Statistics::print_stats($title, $stats, $show_total = true, $is_file_size = false);
+ ob_end_clean();
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ public function testPrintLoginStats(){
+ ob_start();
+ $instans = new MockDatabase();
+ $type='january';
+ $table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
+ if($type === 'month'){
+ $sql = "SELECT DATE_FORMAT( login_date, '%Y %b' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY login_date ";
+ }if($type === 'hour'){
+ $sql = "SELECT DATE_FORMAT( login_date, '%H' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY stat_date ";
+ }else{
+ $sql = "SELECT DATE_FORMAT( login_date, '%a' ) AS stat_date , count( login_id ) AS number_of_logins FROM ".$table." GROUP BY stat_date ORDER BY DATE_FORMAT( login_date, '%w' ) ";
+ }
+ $res = api_sql_query($sql,__FILE__,__LINE__);
+ $obj = Database::fetch_object($res);
+ $result[$obj->stat_date] = $obj->number_of_logins;
+ $login_stats[] = $result;
+ $resu = Statistics::print_login_stats($type);
+ ob_end_clean();
+ $instans->expectOnce($login_stats);
+ $this->assertTrue(is_null($resu));
+ $this->assertTrue($result);
+ //var_dump($resu);
+ //var_dump($result);
+ }
+
+ public function testPrintRecenLoginStats(){
+ ob_start();
+ $instans = new MockDatabase();
+ $total_logins = array();
+ $table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
+ $query[get_lang('Total')] = "SELECT count(login_user_id) AS number FROM $table";
+ $res = api_sql_query($query,__FILE__,__LINE__);
+ $obj = Database::fetch_object($res);
+ $total_logins[] = $obj->number;
+ $res = Statistics::print_recent_login_stats();
+ ob_end_clean();
+ $instans->expectCallCount($total_logins);
+ $this->assertTrue(is_null($res));
+ $this->assertTrue(count($total_logins));
+ //var_dump($res);
+ //var_dump($total_logins);
+ }
+
+ public function testPrintToolStats(){
+ ob_start();
+ $instans = new MockDatabase();
+ $table = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
+ $tools = array('announcement','assignment','calendar_event','chat','conference','course_description','document','dropbox','group','learnpath','link','quiz','student_publication','user','bb_forum');
+ $sql = "SELECT access_tool, count( access_id ) AS number_of_logins FROM $table WHERE access_tool IN ('".implode("','",$tools)."') GROUP BY access_tool ";
+ $res = api_sql_query($sql,__FILE__,__LINE__);
+ $result = array();
+ $obj = Database::fetch_object($res);
+ $result[$obj->access_tool] = $obj->number_of_logins;
+ $resu = Statistics::print_tool_stats();
+ ob_end_clean();
+ $instans->expectCallCount($result);
+ $this->assertTrue(is_null($resu));
+ //var_dump($resu);
+ //var_dump($result);
+ }
+
+ public function testPrintCourseByLanguageStats(){
+ ob_start();
+ $instans = new MockDatabase();
+ $table = Database::get_main_table(TABLE_MAIN_COURSE);
+ $sql = "SELECT course_language, count( code ) AS number_of_courses FROM $table GROUP BY course_language ";
+ $res = api_sql_query($sql,__FILE__,__LINE__);
+ $result = array();
+ $obj = Database::fetch_object($res);
+ $result[$obj->course_language] = $obj->number_of_courses;
+ $instans->expectOnce($result);
+ $resu = Statistics::print_course_by_language_stats();
+ ob_end_clean();
+ $this->assertTrue(is_null($resu));
+ $this->assertTrue(is_array($result));
+ //var_dump($resu);
+ //var_dump($result);
+ }
+
+ public function testPrintUserPicturesStats(){
+ ob_start();
+ $instans = new MockDatabase();
+ $user_table = Database :: get_main_table(TABLE_MAIN_USER);
+ $sql = "SELECT COUNT(*) AS n FROM $user_table";
+ $res = api_sql_query($sql,__FILE__,__LINE__);
+ $count1 = Database::fetch_object($res);
+ $instans_print[]= $count1;
+ $instans->expectOnce($instans_print);
+ $instans->expectCallCount($instans_print);
+ $resu = Statistics::print_user_pictures_stats();
+ ob_end_clean();
+ $this->assertTrue(is_null($resu));
+ $this->assertTrue($instans_print);
+ //var_dump($resu);
+ //var_dump($instans_print);
+ }
+
+ public function testPrintActivitiesStats(){
+ ob_start();
+ $res = Statistics::print_activities_stats();
+ ob_end_clean();
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ public function testPrintCourseLastVisit(){
+ ob_start();
+ $instans = new MockDatabase();
+ $instans1 = new MockDisplay();
+ $table_header[] = array ("Coursecode", true);
+ $course = array ();
+ $courses[] = $course;
+ $column='';
+ $direction='';
+ $parameters['action'] = 'courselastvisit';
+ $instans->expectCallCount('Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS)');
+ $instans1->expectOnce(Display :: display_sortable_table($table_header, $courses, array('column'=>$column,'direction'=>$direction), array (), $parameters));
+ $res = Statistics::print_course_last_visit();
+ ob_end_clean();
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+
+
+
+
+
+
+}
+?>
diff --git a/tests/main/auth/lost_password.lib.test.php b/tests/main/auth/lost_password.lib.test.php
new file mode 100644
index 0000000000..54756b875f
--- /dev/null
+++ b/tests/main/auth/lost_password.lib.test.php
@@ -0,0 +1,78 @@
+assertTrue($res);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function testget_secret_word(){
+ global $_configuration;
+ $add='';
+ $res = get_secret_word($add);
+ $this->assertTrue($res);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function testget_user_account_list(){
+ global $_configuration;
+ $user='';
+ $thisUser=array();
+ $secretword = get_secret_word($thisUser["email"]);
+ $reset_link = get_lang('Pass')." : $thisUser[password]";
+ $userAccountList[] = get_lang('YourRegistrationData')." : \n".get_lang('UserName').' : '.$thisUser["loginName"]."\n".get_lang('ResetLink').' : '.$reset_link.'';
+ $res = get_user_account_list($user, $reset = false);
+ $this->assertTrue($userAccountList);
+ $this->assertTrue(is_array($userAccountList));
+ //var_dump($userAccountList);
+ }
+
+ function testhandle_encrypted_password() {
+ require_once api_get_path (LIBRARY_PATH).'mail.lib.inc.php';
+ global $charset;
+ global $_configuration;
+ ob_start();
+ $user=array('abc');
+ $emailHeaders = get_email_headers(); // Email Headers
+ $emailSubject = "[".get_setting('siteName')."] ".get_lang('LoginRequest'); // SUBJECT
+ $userAccountList = get_user_account_list($user, true); // BODY
+ $emailTo = $user[0]["email"];
+ $secretword = get_secret_word($emailTo);
+ $emailBody = get_lang('DearUser')." :\n".get_lang("password_request")."\n\n";
+ $emailBody .= "-----------------------------------------------\n".$userAccountList."\n-----------------------------------------------\n\n";
+ $emailBody .=get_lang('PasswordEncryptedForSecurity');
+ $emailBody .="\n\n".get_lang('Formula').",\n".get_lang('PlataformAdmin');
+ $sender_name = get_setting('administratorName').' '.get_setting('administratorSurname');
+ $email_admin = get_setting('emailAdministrator');
+ $res=handle_encrypted_password($user);
+ if(!is_array($res))$this->assertTrue(is_null($res));
+ ob_end_clean();
+ //var_dump($res);
+ }
+
+ function testreset_password(){
+ $secret='1234567891011';
+ $id=5;
+ $res=reset_password($secret, $id);
+ $this->assertTrue($res);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function testsend_password_to_user() {
+ $user=array();
+ ob_start();
+ $res=send_password_to_user($user);
+ if(!is_null($res))$this->assertTrue(is_array($res));
+ ob_end_clean();
+ //var_dump($res);
+ }
+}
+?>
diff --git a/tests/main/auth/openid/openid.lib.test.php b/tests/main/auth/openid/openid.lib.test.php
new file mode 100644
index 0000000000..15164e2c4c
--- /dev/null
+++ b/tests/main/auth/openid/openid.lib.test.php
@@ -0,0 +1,222 @@
+assertTrue(is_string($res));
+ $this->assertTrue(is_string($serialized));
+ //var_dump($serialized);
+ }
+
+ function test_openid_dh_base64_to_long() {
+ $str='';
+ $b64 = base64_decode($str);
+ $res=_openid_dh_base64_to_long($str);
+ $this->assertTrue(is_numeric($res));
+ $this->assertTrue(is_string($b64));
+ //var_dump($res);
+ }
+
+ function test_openid_dh_binary_to_long() {
+ $str='';
+ $bytes = array_merge(unpack('C*', $str));
+ $res=_openid_dh_binary_to_long($str);
+ $this->assertTrue(is_numeric($res));
+ $this->assertTrue(is_array($bytes));
+ //var_dump($bytes);
+ }
+
+ function test_openid_dh_long_to_base64() {
+ $str='';
+ $res=_openid_dh_long_to_base64($str);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function test_openid_dh_long_to_binary() {
+ $long='';
+ $res=_openid_dh_long_to_binary($long);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function test_openid_dh_rand() {
+ $stop='';
+ $rbytes = _openid_dh_long_to_binary($stop);
+ $nbytes = strlen($rbytes);
+ $mxrand = bcpow(256, $nbytes);
+ $duplicate = bcmod($mxrand, $stop);
+ $duplicate_cache = array();
+ $duplicate_cache[$rbytes] = array($duplicate, $nbytes);
+ $res=_openid_dh_rand($stop);
+ if(!is_array($res))$this->assertTrue(is_null($res));
+ $this->assertTrue(is_array($duplicate_cache));
+ //var_dump($res);
+ //var_dump($duplicate_cache);
+ }
+
+ function test_openid_dh_xorsecret() {
+ $shared='';
+ $secret='';
+ $res=_openid_dh_xorsecret($shared, $secret);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function test_openid_encode_message() {
+ $message='';
+ $res=_openid_encode_message($message);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function test_openid_fix_post() {
+ $post='';
+ $res=_openid_fix_post($post);
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ function test_openid_get_bytes() {
+ static $f = null;
+ $num_bytes='';
+ $res=_openid_get_bytes($num_bytes);
+ $this->assertTrue(is_bool($res));
+ //var_dump($res);
+ }
+
+ function test_openid_hmac() {
+ $key='';
+ $text='';
+ $res=_openid_hmac($key, $text);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function test_openid_is_xri() {
+ $identifier='';
+ $res=_openid_is_xri($identifier);
+ $this->assertTrue(is_bool($res));
+ //var_dump($res);
+ }
+
+ function test_openid_link_href() {
+ $rel='';
+ $html='';
+ $res=_openid_link_href($rel, $html);
+ $this->assertTrue(is_bool($res));
+ //var_dump($res);
+ }
+
+ function test_openid_meta_httpequiv() {
+ $equiv='';
+ $html='';
+ $res=_openid_meta_httpequiv($equiv, $html);
+ $this->assertTrue(is_bool($res));
+ //var_dump($res);
+ }
+
+ function test_openid_nonce() {
+ $res=_openid_nonce();
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function test_openid_normalize() {
+ $identifier='';
+ $res=_openid_normalize($identifier);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function test_openid_normalize_url() {
+ $url='';
+ $res=_openid_normalize_url($url);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function test_openid_normalize_xri() {
+ $xri='';
+ $res=_openid_normalize_xri($xri);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function test_openid_parse_message() {
+ $message='';
+ $parsed_message = array();
+ $res=_openid_parse_message($message);
+ $this->assertTrue(is_array($res));
+ //var_dump($res);
+ }
+
+ function test_openid_sha1() {
+ $text='';
+ $res=_openid_sha1($text);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function test_openid_signature() {
+ $association='';
+ $message_array='';
+ $keys_to_sign='';
+ $res=_openid_signature($association, $message_array, $keys_to_sign);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+
+ function testbcpowmod() {
+ $base='';
+ $exp='';
+ $mod='';
+ $res=bcpowmod($base, $exp, $mod);
+ $this->assertTrue(is_bool($res));
+ //var_dump($res);
+ }
+
+ function testopenid_redirect() {
+ $url='http://localhost/dokeossvn186/tests/all.test2.php';
+ $message='';
+ ob_start();
+ $res=openid_redirect($url, $message);
+ $this->assertTrue(is_null($res));
+ ob_end_clean();
+ //var_dump($res);
+ }
+
+ function testopenid_redirect_http() {
+ $url='http://localhost/dokeossvn186/tests/all.test2.php';
+ $message='';
+ ob_start();
+ $res=openid_redirect_http($url, $message);
+ $this->assertTrue(is_null($res));
+ ob_end_clean();
+ //var_dump($res);
+ }
+}
+?>
diff --git a/tests/main/auth/openid/xrds.lib.test.php b/tests/main/auth/openid/xrds.lib.test.php
new file mode 100644
index 0000000000..96e7902b8e
--- /dev/null
+++ b/tests/main/auth/openid/xrds.lib.test.php
@@ -0,0 +1,46 @@
+assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ function test_xrds_element_end() {
+ global $xrds_open_elements, $xrds_services, $xrds_current_service;
+ $parser='';
+ $name='';
+ $xrds_current_service['version'] = 2;
+ $xrds_current_service['version'] = 1;
+ $xrds_services[] = $xrds_current_service;
+ $xrds_current_service= array();
+ $res=_xrds_element_end($parser, $name);
+ $this->assertTrue(is_null($res));
+ //var_dump($xrds_current_service);
+ }
+
+ function test_xrds_element_start() {
+ global $xrds_open_elements;
+ $parser='';
+ $name='';
+ $attribs='';
+ $xrds_open_elements[] = _xrds_strip_namespace($name);
+ $res=_xrds_element_start($parser, $name);
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ function test_xrds_strip_namespace() {
+ $name='';
+ $res=_xrds_strip_namespace($name);
+ $this->assertTrue(is_string($res));
+ //var_dump($res);
+ }
+}
+?>
diff --git a/tests/main/chat/chat_functions.lib.test.php b/tests/main/chat/chat_functions.lib.test.php
new file mode 100644
index 0000000000..60cfe7c3f4
--- /dev/null
+++ b/tests/main/chat/chat_functions.lib.test.php
@@ -0,0 +1,38 @@
+assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ function testexit_of_chat () {
+ $docu = new MockCourseManager();
+ $user_id=1;
+ $res = exit_of_chat();
+ $docu->expectOnce(CourseManager::get_courses_list_by_user_id($user_id),'admin');
+ $this->assertTrue(is_object($docu));
+ $this->assertTrue(is_null($res));
+ //var_dump($res);
+ }
+
+ function testuser_connected_in_chat () {
+ $user_id=1;
+ $database_name='';
+ $res = user_connected_in_chat($user_id,$database_name);
+ $this->assertTrue(is_bool($res));
+ //var_dump($res);
+ }
+
+ function testusers_list_in_chat () {
+ $res = users_list_in_chat();
+ $this->assertTrue(is_array($res));
+ //var_dump($res);
+ }
+}
+?>
diff --git a/tests/main/conference/get_translation.lib.test.php b/tests/main/conference/get_translation.lib.test.php
new file mode 100644
index 0000000000..9be7ad4123
--- /dev/null
+++ b/tests/main/conference/get_translation.lib.test.php
@@ -0,0 +1,12 @@
+assertTrue(($res));
+ //var_dump($res);
+ }
+}
+?>