skala
Julio Montoya 15 years ago
commit 8b54edf958
  1. 9
      main/admin/calendar.lib.php
  2. 4
      main/admin/statistics/statistics.lib.php
  3. 4
      main/admin/system_announcements.php
  4. 1
      main/calendar/agenda.inc.php
  5. 4
      main/calendar/myagenda.inc.php
  6. 509
      main/forum/forumfunction.inc.php
  7. 5
      main/inc/lib/attendance.lib.php
  8. 7
      main/inc/lib/main_api.lib.php
  9. 8
      main/inc/lib/notebook.lib.php
  10. 31
      main/inc/lib/tracking.lib.php
  11. 43
      main/wiki/index.php
  12. 6
      main/work/work.lib.php
  13. 184
      tests/main/newscorm/scorm.class.test.php
  14. 197
      tests/setup.inc.php
  15. 165
      tests/teardown.inc.php
  16. 165
      tests/test_suite.php

@ -738,6 +738,7 @@ function display_agenda_items()
while($myrow=Database::fetch_array($result))
{
$is_repeated = !empty($myrow['parent_event_id']);
$myrow["start_date"] = api_get_local_time($myrow["start_date"], null, null, date_default_timezone_get());
echo '<table class="data_table">',"\n";
/*--------------------------------------------------
display: the month bar
@ -822,6 +823,7 @@ function display_agenda_items()
echo "\t\t<td>";
if ($myrow["end_date"]<>"0000-00-00 00:00:00")
{
$myrow["end_date"] = api_get_local_time($myrow["end_date"], null, null, date_default_timezone_get());
echo get_lang("EndTimeWindow").": ";
echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;";
echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"])))."";
@ -1009,6 +1011,7 @@ function display_one_agenda_item($agenda_id)
echo "\t<tr>\n";
// highlight: if a date in the small calendar is clicked we highlight the relevant items
$myrow["start_date"] = api_get_local_time($myrow["start_date"], null, null, date_default_timezone_get());
$db_date=(int)date("d",strtotime($myrow["start_date"])).date("n",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"]));
if ($_GET["day"].$_GET["month"].$_GET["year"] <>$db_date)
{
@ -1065,6 +1068,7 @@ function display_one_agenda_item($agenda_id)
echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["start_date"])))."";
echo "</td>\n";
echo "\t\t<td>".get_lang("EndTime").": ";
$myrow["end_date"] = api_get_local_time($myrow["end_date"], null, null, date_default_timezone_get());
echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;";
echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"])))."";
echo "</td>\n";
@ -1674,6 +1678,7 @@ function get_agendaitems($month, $year)
$result = Database::query($sqlquery);
while ($item = Database::fetch_array($result))
{
$item['start_date'] = api_get_local_time($item['start_date'], null, null, date_default_timezone_get());
$agendaday = date('j',strtotime($item['start_date']));
$time= date('H:i',strtotime($item['start_date']));
$URL = $portal_url.'main/admin/agenda.php?day='.$agendaday."&amp;month=".$month."&amp;year=".$year; // RH //Patrick Cool: to highlight the relevant agenda item
@ -1996,6 +2001,7 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
{
// in the display_daycalendar function we use $i (ranging from 0 to 47) for each halfhour
// we want to know for each agenda item for this day to wich halfhour it must be assigned
$item['start_date'] = api_get_local_time($item['start_date'], null, null, date_default_timezone_get());
list ($datepart, $timepart) = split(" ", $item['start_date']);
list ($year, $month, $day) = explode("-", $datepart);
list ($hours, $minutes, $seconds) = explode(":", $timepart);
@ -2105,6 +2111,7 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '')
while ($item = Database::fetch_array($result))
{
$item['start_date'] = api_get_local_time($item['start_date'], null, null, date_default_timezone_get());
$agendaday = date("j",strtotime($item['start_date']));
$time= date("H:i",strtotime($item['start_date']));
@ -2191,7 +2198,7 @@ function get_repeated_events_day_view($course_info,$start=0,$end=0,$params)
while($row = Database::fetch_array($res))
{
$orig_start = $row['orig_start'];
$orig_end = $row['orig_end'];
$orig_end = $row['orig_start'];
$repeat_type = $row['cal_type'];
switch($repeat_type)
{

@ -116,7 +116,7 @@ class Statistics
$res = Database::query($sql);
$activities = array ();
while ($row = Database::fetch_row($res)) {
$row[4] = api_format_date(DATE_TIME_FORMAT_LONG, strtotime($row[4]));
$row[4] = api_get_local_time($row[4], DATE_TIME_FORMAT_LONG, null, date_default_timezone_get());
$activities[] = $row;
}
return $activities;
@ -419,7 +419,7 @@ class Statistics
{
$course = array ();
$course[]= '<a href="'.api_get_path(WEB_PATH).'courses/'.$obj->access_cours_code.'">'.$obj->access_cours_code.' <a>';
$course[] = $obj->access_date;
$course[] = api_get_local_time($obj->access_date, null, null, date_default_timezone_get());
$courses[] = $course;
}
$parameters['action'] = 'courselastvisit';

@ -284,8 +284,8 @@ if ($show_announcement_list)
$row = array ();
$row[] = $announcement->id;
$row[] = Display::return_icon(($announcement->visible ? 'accept.png' : 'exclamation.png'), ($announcement->visible ? get_lang('AnnouncementAvailable') : get_lang('AnnouncementNotAvailable')));
$row[] = $announcement->date_start;
$row[] = $announcement->date_end;
$row[] = api_get_local_time($announcement->date_start, null, null, date_default_timezone_get());
$row[] = api_get_local_time($announcement->date_end, null, null, date_default_timezone_get());
$row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_TEACHER."&amp;action=". ($announcement->visible_teacher ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_teacher ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>";
$row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_STUDENT."&amp;action=". ($announcement->visible_student ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_student ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>";
$row[] = "<a href=\"?id=".$announcement->id."&amp;person=".VISIBLE_GUEST."&amp;action=". ($announcement->visible_guest ? 'make_invisible' : 'make_visible')."\">".Display::return_icon(($announcement->visible_guest ? 'visible.gif' : 'invisible.gif'), get_lang('show_hide'))."</a>";

@ -3477,6 +3477,7 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
{
// in the display_daycalendar function we use $i (ranging from 0 to 47) for each halfhour
// we want to know for each agenda item for this day to wich halfhour it must be assigned
$item['start_date'] = api_get_local_time($item['start_date'], null, null, date_default_timezone_get());
list ($datepart, $timepart) = split(" ", $item['start_date']);
list ($year, $month, $day) = explode("-", $datepart);
list ($hours, $minutes, $seconds) = explode(":", $timepart);

@ -117,8 +117,8 @@ function get_myagendaitems($courses_dbs, $month, $year)
$agendaday = date("j",strtotime($item['start_date']));
if(!isset($items[$agendaday])){$items[$agendaday]=array();}
$time= date("H:i",strtotime($item['start_date']));
$end_time= date("H:i",strtotime($item['end_date']));
$time = api_get_local_time($item['start_date'], "H:i", null, date_default_timezone_get());
$end_time = api_get_local_time($item['end_date'], "H:i", null, date_default_timezone_get());
$URL = api_get_path(WEB_PATH)."main/calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&amp;day=$agendaday&amp;month=$month&amp;year=$year#$agendaday"; // RH //Patrick Cool: to highlight the relevant agenda item
if ($setting_agenda_link == 'coursecode') {
$title=$array_course_info['title'];

File diff suppressed because it is too large Load Diff

@ -600,7 +600,8 @@ class Attendance
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
while ($row = Database::fetch_array($res)) {
$row['date_time'] = api_format_date($dateTimeFormatLong, strtotime($row['date_time']));
$row['date_time'] = api_get_local_time($row['date_time'], $dateTimeFormatLong, null, date_default_timezone_get());
//$row['date_time'] = api_format_date($dateTimeFormatLong, strtotime($row['date_time']));
$data[$user_id][] = $row;
}
}
@ -660,6 +661,7 @@ class Attendance
$data = array();
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs)) {
$row['date_time'] = api_get_local_time($row['date_time'], null, null, date_default_timezone_get());
$data = $row;
}
}
@ -680,6 +682,7 @@ class Attendance
$data = array();
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs)) {
$row['date_time'] = api_get_local_time($row['date_time'], null, null, date_default_timezone_get());
$row['date'] = api_format_date($dateFormatShort, strtotime($row['date_time']));
$row['time'] = api_format_date($timeNoSecFormat, strtotime($row['date_time']));
$data[] = $row;

@ -224,6 +224,7 @@ define('LIBRARY_PATH', 'LIBRARY_PATH');
define('CONFIGURATION_PATH', 'CONFIGURATION_PATH');
define('WEB_LIBRARY_PATH', 'WEB_LIBRARY_PATH');
define('WEB_AJAX_PATH', 'WEB_AJAX_PATH');
define('SYS_TEST_PATH', 'SYS_TEST_PATH');
// Constants for requesting path conversion.
define('TO_WEB', 'TO_WEB');
@ -313,6 +314,7 @@ require_once dirname(__FILE__).'/internationalization.lib.php';
* api_get_path(WEB_LIBRARY_PATH) http://www.mychamilo.org/chamilo/main/inc/lib/
* api_get_path(LIBRARY_PATH) /var/www/chamilo/main/inc/lib/
* api_get_path(CONFIGURATION_PATH) /var/www/chamilo/main/inc/conf/
* api_get_path(SYS_TEST_PATH) /var/www/chamilo/tests/
*
* This is how we retrieve paths of "registerd" resource files (scripts, players, etc.):
* api_get_path(TO_WEB, FLASH_PLAYER_AUDIO) http://www.mychamilo.org/chamilo/main/inc/lib/mediaplayer/player.swf
@ -355,7 +357,8 @@ function api_get_path($path_type, $path = null) {
LIBRARY_PATH => 'inc/lib/',
CONFIGURATION_PATH => 'inc/conf/',
WEB_LIBRARY_PATH => 'inc/lib/',
WEB_AJAX_PATH => 'inc/ajax/'
WEB_AJAX_PATH => 'inc/ajax/',
SYS_TEST_PATH => 'tests/'
);
static $resource_paths = array(
@ -472,6 +475,7 @@ function api_get_path($path_type, $path = null) {
$paths[WEB_PLUGIN_PATH] = $paths[WEB_PATH].$paths[WEB_PLUGIN_PATH];
$paths[SYS_ARCHIVE_PATH] = $paths[SYS_PATH].$paths[SYS_ARCHIVE_PATH];
$paths[WEB_ARCHIVE_PATH] = $paths[WEB_PATH].$paths[WEB_ARCHIVE_PATH];
$paths[SYS_TEST_PATH] = $paths[SYS_PATH].$paths[SYS_TEST_PATH];
// A change as of Chamilo 1.8.6.2
// Calculation in the previous way does not rely on configuration settings and in some cases gives unexpected results.
//$paths[INCLUDE_PATH] = $include_path_sys; // Old behaviour, Dokeos 1.8.6.1.
@ -4518,6 +4522,7 @@ function api_get_local_time($time, $format=null, $to_timezone=null, $from_timezo
$use_users_timezone = api_get_setting('use_users_timezone', 'timezones');
if ($use_users_timezone == 'true') {
// Get the timezone based on user preference, if it exists
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
$timezone_user = UserManager::get_extra_user_data_by_field($_user['user_id'],'timezone');
if ($timezone_user['timezone'] != null) {
$to_timezone = $timezone_user['timezone'];

@ -197,10 +197,12 @@ class NotebookManager
while ($row = Database::fetch_array($result)) {
//validacion when belongs to a session
$session_img = api_get_session_image($row['session_id'], $_user['status']);
$creation_date = api_get_local_time($row['creation_date'], null, null, date_default_timezone_get());
$update_date = api_get_local_time($row['update_date'], null, null, date_default_timezone_get());
echo '<div class="sectiontitle">';
echo '<span style="float: right;"> ('.get_lang('CreationDate').': '.date_to_str_ago($row['creation_date']).'&nbsp;&nbsp;<span class="dropbox_date">'.$row['creation_date'].'</span>';
echo '<span style="float: right;"> ('.get_lang('CreationDate').': '.date_to_str_ago($creation_date).'&nbsp;&nbsp;<span class="dropbox_date">'.$creation_date.'</span>';
if ($row['update_date'] <> $row['creation_date']) {
echo ', '.get_lang('UpdateDate').': '.date_to_str_ago($row['update_date']).'&nbsp;&nbsp;<span class="dropbox_date">'.$row['update_date'].'</span>';
echo ', '.get_lang('UpdateDate').': '.date_to_str_ago($update_date).'&nbsp;&nbsp;<span class="dropbox_date">'.$update_date.'</span>';
}
echo ')</span>';
echo $row['title'] . $session_img;
@ -214,4 +216,4 @@ class NotebookManager
//return $return;
}
}
?>
?>

@ -103,7 +103,8 @@ class Tracking {
if(Database::num_rows($rs)>0)
{
if ($first_login_date = Database::result($rs, 0, 0)) {
return format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($first_login_date));
$first_login_date_local = api_get_local_time($first_login_date, null, null, date_default_timezone_get());
return format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($first_login_date_local));
}
}
return false;
@ -120,6 +121,7 @@ class Tracking {
{
if ($last_login_date = Database::result($rs, 0, 0))
{
$last_login_date = api_get_local_time($last_login_date, null, null, date_default_timezone_get());
if ($return_timestamp)
{
return strtotime($last_login_date);
@ -163,6 +165,7 @@ class Tracking {
if(Database::num_rows($rs)>0)
{
if ($first_login_date = Database::result($rs, 0, 0)) {
$first_login_date = api_get_local_time($first_login_date, null, null, date_default_timezone_get());
return format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($first_login_date));
}
}
@ -180,6 +183,7 @@ class Tracking {
if(Database::num_rows($rs)>0)
{
if ($last_login_date = Database::result($rs, 0, 0)) {
$last_login_date = api_get_local_time($last_login_date, null, null, date_default_timezone_get());
$timestamp = strtotime($last_login_date);
$currentTimestamp = mktime();
//If the last connection is > than 7 days, the text is red
@ -1048,7 +1052,7 @@ class Tracking {
$rs = Database::query($sql);
$row = Database::fetch_array($rs);
$last_connection = $row['access_date'];
$last_connection = api_get_local_time($row['access_date'], null, null, date_default_timezone_get());
if (!empty($last_connection)) {
$date_format_long = format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_connection));
$time = explode(' ',$last_connection);
@ -1343,7 +1347,7 @@ class TrackingCourseLog {
$row[1] = get_lang($row[1]);
$row[5] = api_ucfirst(format_locale_date($dateTimeFormatLong, strtotime($row['col5'])));
$row[5] = api_ucfirst(api_get_local_time($row['col5'], $dateTimeFormatLong, null, date_default_timezone_get()));
$row[4] = '';
if ($table_name['table_name'] == 'document') {
@ -1724,7 +1728,7 @@ class TrackingUserLog {
*/
function display_exercise_tracking_info($view, $user_id, $course_id)
{
global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES;
global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
if(substr($view,1,1) == '1')
{
$new_view = substr_replace($view,'0',1,1);
@ -1770,7 +1774,7 @@ class TrackingUserLog {
if (is_array($results)) {
for($i = 0; $i < sizeof($results); $i++) {
$display_date = format_locale_date(get_lang('dateTimeFormatLong'), $results[$i][3]);
$display_date = api_get_local_time($results[$i][3], $dateTimeFormatLong, null, date_default_timezone_get());
echo "<tr>\n";
echo "<td class='content'>".$results[$i][0]."</td>\n";
echo "<td class='content'>".$display_date."</td>\n";
@ -1788,7 +1792,7 @@ class TrackingUserLog {
$title = GetQuizName($hpresults[$i][0],'');
if ($title == '')
$title = basename($hpresults[$i][0]);
$display_date = format_locale_date(get_lang('dateTimeFormatLong'), $hpresults[$i][3]);
$display_date = api_get_local_time($hpresults[$i][3], $dateTimeFormatLong, null, date_default_timezone_get());
?>
<tr>
<td class="content"><?php echo $title; ?></td>
@ -1856,7 +1860,8 @@ class TrackingUserLog {
if (is_array($results)) {
for($j = 0 ; $j < count($results) ; $j++) {
$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
$timestamp = strtotime($results[$j][0]);
$upload_date = api_get_local_time($results[$j][0], null, null, date_default_timezone_get());
$timestamp = strtotime($upload_date);
$beautifulDate = format_locale_date($dateTimeFormatLong,$timestamp);
echo "<tr>";
echo "<td class='content'>"
@ -2055,7 +2060,7 @@ class TrackingUserLogCSV {
*/
function display_exercise_tracking_info($view, $user_id, $course_id)
{
global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES;
global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
if(substr($view,1,1) == '1')
{
$new_view = substr_replace($view,'0',1,1);
@ -2087,7 +2092,7 @@ class TrackingUserLogCSV {
{
for($i = 0; $i < sizeof($results); $i++)
{
$display_date = format_locale_date(get_lang('dateTimeFormatLong'), $results[$i][3]);
$display_date = api_get_local_time($results[$i][3], $dateTimeFormatLong, null, date_default_timezone_get());
$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
}
}
@ -2105,8 +2110,9 @@ class TrackingUserLogCSV {
if ($title == '')
$title = basename($hpresults[$i][0]);
$display_date = api_get_local_time($hpresults[$i][3], $dateTimeFormatLong, null, date_default_timezone_get());
$display_date = format_locale_date(get_lang('dateTimeFormatLong'), $hpresults[$i][3]);
$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
}
}
@ -2155,7 +2161,8 @@ class TrackingUserLogCSV {
for($j = 0 ; $j < count($results) ; $j++)
{
$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
$timestamp = strtotime($results[$j][0]);
$upload_date = api_get_local_time($results[$j][0], null, null, date_default_timezone_get());
$timestamp = strtotime($upload_date);
$beautifulDate = format_locale_date($dateTimeFormatLong,$timestamp);
$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
}
@ -2252,4 +2259,4 @@ class TrackingUserLogCSV {
return array($title_line, $line);
}
}
?>
?>

@ -1362,7 +1362,7 @@ if ($_GET['action']=='edit')
//check tasks
if (!empty($row['startdate_assig']) && $row['startdate_assig']!='0000-00-00 00:00:00' && time()<strtotime($row['startdate_assig']))
{
$message=get_lang('TheTaskDoesNotBeginUntil').': '.$row['startdate_assig'];
$message=get_lang('TheTaskDoesNotBeginUntil').': '.api_get_local_time($row['startdate_assig'], null, null, date_default_timezone_get());
Display::display_warning_message($message);
if(!api_is_allowed_to_edit(false,true))
{
@ -1373,7 +1373,7 @@ if ($_GET['action']=='edit')
//
if (!empty($row['enddate_assig']) && $row['enddate_assig']!='0000-00-00 00:00:00' && time()>strtotime($row['enddate_assig']) && $row['enddate_assig']!='0000-00-00 00:00:00' && $row['delayedsubmit']==0)
{
$message=get_lang('TheDeadlineHasBeenCompleted').': '.$row['enddate_assig'];
$message=get_lang('TheDeadlineHasBeenCompleted').': '.api_get_local_time($row['enddate_assig'], null, null, date_default_timezone_get());
Display::display_warning_message($message);
if(!api_is_allowed_to_edit(false,true))
{
@ -1414,7 +1414,7 @@ if ($_GET['action']=='edit')
}
else
{
$message_task_startdate=$row['startdate_assig'];
$message_task_startdate=api_get_local_time($row['startdate_assig'], null, null, date_default_timezone_get());
}
if ($row['enddate_assig']=='0000-00-00 00:00:00')
@ -1423,7 +1423,7 @@ if ($_GET['action']=='edit')
}
else
{
$message_task_endate=$row['enddate_assig'];
$message_task_endate=api_get_local_time($row['enddate_assig'], null, null, date_default_timezone_get());
}
if ($row['delayedsubmit']==0)
@ -1767,13 +1767,6 @@ if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifference
{
$userinfo=Database::get_user_info_from_id($row['user_id']);
$year = substr($row['dtime'], 0, 4);
$month = substr($row['dtime'], 5, 2);
$day = substr($row['dtime'], 8, 2);
$hours=substr($row['dtime'], 11,2);
$minutes=substr($row['dtime'], 14,2);
$seconds=substr($row['dtime'], 17,2);
echo '<li style="margin-bottom: 5px;">';
($counter==0) ? $oldstyle='style="visibility: hidden;"':$oldstyle='';
($counter==0) ? $newchecked=' checked':$newchecked='';
@ -1784,7 +1777,7 @@ if ($_GET['action']=='history' or Security::remove_XSS($_POST['HistoryDifference
echo '<a href="'.api_get_self().'?action=showpage&amp;title='.$page.'&amp;view='.$row['id'].'">';
echo '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&amp;title='.$page.'&amp;view='.$row['id'].'&group_id='.$group_id.'">';
echo $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
echo api_get_local_time($row['dtime'], null, null, date_default_timezone_get());
echo '</a>';
echo ' ('.get_lang('Version').' '.$row['version'].')';
echo ' '.get_lang('By').' ';
@ -1957,14 +1950,6 @@ if ($_GET['action']=='recentchanges')
//get author
$userinfo=Database::get_user_info_from_id($obj->user_id);
//get time
$year = substr($obj->dtime, 0, 4);
$month = substr($obj->dtime, 5, 2);
$day = substr($obj->dtime, 8, 2);
$hours = substr($obj->dtime, 11,2);
$minutes = substr($obj->dtime, 14,2);
$seconds = substr($obj->dtime, 17,2);
//get type assignment icon
if($obj->assignment==1)
{
@ -1991,7 +1976,7 @@ if ($_GET['action']=='recentchanges')
$row = array ();
$row[] = $year.'-'.$month.'-'.$day.' '.$hours.':'.$minutes.":".$seconds;
$row[] = api_get_local_time($obj->dtime, null, null, date_default_timezone_get());
$row[] = $ShowAssignment.$icon_task;
$row[] = '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.urlencode($obj->reflink).'&amp;view='.$obj->id.'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.$obj->title.'</a>';
$row[] = $obj->version>1 ? get_lang('EditedBy') : get_lang('AddedBy');
@ -2047,14 +2032,6 @@ if ($_GET['action']=='allpages')
//get author
$userinfo=Database::get_user_info_from_id($obj->user_id);
//get time
$year = substr($obj->dtime, 0, 4);
$month = substr($obj->dtime, 5, 2);
$day = substr($obj->dtime, 8, 2);
$hours = substr($obj->dtime, 11,2);
$minutes = substr($obj->dtime, 14,2);
$seconds = substr($obj->dtime, 17,2);
//get type assignment icon
if($obj->assignment==1)
{
@ -2083,7 +2060,7 @@ if ($_GET['action']=='allpages')
$row[] =$ShowAssignment.$icon_task;
$row[] = '<a href="'.api_get_self().'?cidReq='.$_course[id].'&action=showpage&title='.urlencode(Security::remove_XSS($obj->reflink)).'&group_id='.Security::remove_XSS($_GET['group_id']).'">'.Security::remove_XSS($obj->title).'</a>';
$row[] = $obj->user_id <>0 ? '<a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a>' : get_lang('Anonymous').' ('.$obj->user_ip.')';
$row[] = $year.'-'.$month.'-'.$day.' '.$hours.":".$minutes.":".$seconds;
$row[] = api_get_local_time($obj->dtime, null, null, date_default_timezone_get());
if(api_is_allowed_to_edit(false,true)|| api_is_platform_admin())
{
@ -2125,7 +2102,7 @@ if ($_GET['action']=='discuss')
$sql='SELECT * FROM '.$tbl_wiki.'WHERE reflink="'.html_entity_decode(Database::escape_string(stripslashes(urldecode($page)))).'" AND '.$groupfilter.$condition_session.' ORDER BY id DESC';
$result=Database::query($sql);
$row=Database::fetch_array($result);
$lastversiondate=$row['dtime'];
$lastversiondate=api_get_local_time($row['dtime'], null, null, date_default_timezone_get());
$lastuserinfo=Database::get_user_info_from_id($row['user_id']);
//select page to discuss
@ -2408,7 +2385,7 @@ if ($_GET['action']=='discuss')
echo '<p><table>';
echo '<tr>';
echo '<td rowspan="2">'.$author_photo.'</td>';
echo '<td style=" color:#999999"><a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a> ('.$author_status.') '.$row['dtime'].' - '.get_lang('Rating').': '.$row['p_score'].' '.$imagerating.' </td>';
echo '<td style=" color:#999999"><a href="../user/userInfo.php?uInfo='.$userinfo['user_id'].'">'.api_get_person_name($userinfo['firstname'], $userinfo['lastname']).'</a> ('.$author_status.') '.api_get_local_time($row['dtime'], null, null, date_default_timezone_get()).' - '.get_lang('Rating').': '.$row['p_score'].' '.$imagerating.' </td>';
echo '</tr>';
echo '<tr>';
echo '<td>'.$row['comment'].'</td>';
@ -2452,4 +2429,4 @@ FOOTER
*/
//$_SESSION['_gid'];
Display::display_footer();
?>
?>

@ -718,6 +718,7 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
}
if ($direc_date!='' && $direc_date!='0000-00-00 00:00:00') {
$direc_date = api_get_local_time($direc_date, null, null, date_default_timezone_get());
$my_direc_date = api_ucfirst(format_locale_date($dateFormatShort,strtotime($direc_date))).'&nbsp;&nbsp;&nbsp;&nbsp;';
$my_direc_date .= ucfirst(strftime($timeNoSecFormat,strtotime($direc_date)));
$row[]= date_to_str_ago($direc_date).'<br /><span class="dropbox_date">'.$my_direc_date.'</span>'.'<!--uts='.strtotime($direc_date).'-->';
@ -779,8 +780,9 @@ function display_student_publications_list($work_dir,$sub_course_dir,$currentCou
$row[]= build_document_icon_tag('file',$work->url);
$row[]= '<a href="download.php?file='.$url.'"'.$class.'><img src="../img/filesave.gif" style="float:right;" alt="'.get_lang('Save').'" title="'.get_lang('Save').'" />'.$work->title.'</a><br />'.$work->description;
$row[]= display_user_link_work($row2['insert_user_id'],$work->author).$qualification_string;// $work->author;
$sent_date = api_ucfirst(format_locale_date($dateFormatShort,strtotime($work->sent_date))).'&nbsp;&nbsp;&nbsp;&nbsp;';
$sent_date .= ucfirst(strftime($timeNoSecFormat,strtotime($work->sent_date)));
$work_sent_date = api_get_local_time($work->sent_date, null, null, date_default_timezone_get());
$sent_date = api_ucfirst(format_locale_date($dateFormatShort,strtotime($work_sent_date))).'&nbsp;&nbsp;&nbsp;&nbsp;';
$sent_date .= ucfirst(strftime($timeNoSecFormat,strtotime($work_sent_date)));
$row[]= date_to_str_ago($work->sent_date).$add_string.'<br><span class="dropbox_date">'.$sent_date.'</span>'.'<!--uts='.strtotime($work->sent_date).'-->';
if( $is_allowed_to_edit) {

@ -0,0 +1,184 @@
<?php
require_once(api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php');
require_once(api_get_path(SYS_CODE_PATH).'newscorm/scorm.class.php');
class TestScorm extends UnitTestCase {
/*
function testScorm() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->scorm($course_code=null,$resource_id=null,$user_id=null);
$this->assertTrue(is_null($res));
//ob_end_clean();
//var_dump($res);
}*/
function testOpen() {
//ob_start();
$id = 1;
$res = scorm::open($id);
$this->assertTrue(is_null($res));
//ob_end_clean();
//var_dump($res);
}
function testParseManifest() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->parse_manifest($file='');
$this->assertTrue(is_null($res));
//ob_end_clean();
//var_dump($res);
}
function testImportManifest() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->import_manifest($course_code = 'COURSETEST');
$this->assertTrue(is_null($res));
//ob_end_clean();
//var_dump($res);
}
/*
function testImportLocalPackage() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->import_local_package($file_path,$current_dir='');
$this->assertTrue(is_string($res));
//ob_end_clean();
//var_dump($res);
}
function testImportPackage() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->import_package($zip_file_info,$current_dir = '');
$this->assertTrue(is_string($res));
//ob_end_clean();
//var_dump($res);
}*/
function testSetProximity() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->set_proximity($proxy='');
$this->assertTrue(is_bool($res));
//ob_end_clean();
//var_dump($res);
}
function testSetTheme() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->set_theme($theme='Chamilo');
$this->assertTrue(is_bool($res));
//ob_end_clean();
//var_dump($res);
}
function testSetPreviewImage() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->set_preview_image($preview_image='');
$this->assertTrue(is_bool($res));
//ob_end_clean();
//var_dump($res);
}
function testSetAuthor() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->set_author($author='');
$this->assertTrue(is_bool($res));
//ob_end_clean();
//var_dump($res);
}
function testSetMaker() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->set_maker($maker='');
$this->assertTrue(is_bool($res));
//ob_end_clean();
//var_dump($res);
}
function testExportZip() {
//ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->export_zip($lp_id=null);
$this->assertTrue(is_bool($res));
//ob_end_clean();
//var_dump($res);
}
function testGetResPath() {
//ob_start();
$res = scorm::get_res_path($id=1);
$this->assertTrue(is_string($res));
//ob_end_clean();
//var_dump($res);
}
function testGetResType() {
//ob_start();
$res = scorm::get_res_type($id = 1);
$this->assertTrue(is_string($res));
//ob_end_clean();
//var_dump($res);
}
function testGetTitle() {
//ob_start();
$res = scorm::get_title();
$this->assertTrue(is_string($res));
//ob_end_clean();
//var_dump($res);
}
function testReimportManifest() {
ob_start();
$course_code = 'COURSETEST';
$resource_id = 1;
$user_id = 1;
$obj = new scorm($course_code, $resource_id, $user_id);
$res = $obj->reimport_manifest($course = 'COURSETEST',$lp_id=null,$imsmanifest_path='');
$this->assertTrue(is_bool($res));
ob_end_clean();
//var_dump($res);
}
}
?>

@ -0,0 +1,197 @@
<?php
// $Id: setup.inc.php 2010-02-17 12:07:00Z aportugal $
/* For licensing terms, see /chamilo_license.txt */
/**
==============================================================================
* This is the settings file load than need some functions
*
* It load:
* - require_once
* - constructs
* - creation course
* - session
* - api_allow_edit
* - api_session
*
*
* @todo rewrite code to separate display, logic, database code
* @package chamilo.main
==============================================================================
*/
/**
* @todo shouldn't these settings be moved to the test_suite.php.
* if these are really configuration then we can make require_once in each tests.
* @todo use this file to load the setup in each file test.
* @todo check for duplication of require with test_suite.php
*/
/*
==============================================================================
INIT SECTION
==============================================================================
*/
ini_set('memory_limit','256M');
ini_set('max_execution_time','0');
/*
-----------------------------------------------------------
Included libraries
-----------------------------------------------------------
*/
$maindir = dirname(__FILE__).'/../main/';
$incdir = dirname(__FILE__).'/../main/inc/';
$libdir = dirname(__FILE__).'/../main/inc/lib/';
/**This global.inc file need be loaded once time*/
//require_once $incdir.'global.inc.php';
/**Files inside '/../main' */
require_once $maindir.'permissions/permissions_functions.inc.php';
require_once $maindir.'admin/calendar.lib.php';
require_once $maindir.'admin/statistics/statistics.lib.php';
require_once $maindir.'dropbox/dropbox_class.inc.php';
require_once $maindir.'dropbox/dropbox_functions.inc.php';
require_once $maindir.'survey/survey.lib.php';
require_once $maindir.'exercice/export/scorm/scorm_classes.php';
require_once $maindir.'exercice/export/qti2/qti2_classes.php';
require_once $maindir.'exercice/export/exercise_import.inc.php';
require_once $maindir.'exercice/exercise_result.class.php';
require_once $maindir.'exercice/answer.class.php';
require_once $maindir.'exercice/exercise.class.php';
require_once $maindir.'exercice/fill_blanks.class.php';
require_once $maindir.'exercice/freeanswer.class.php';
require_once $maindir.'forum/forumfunction.inc.php';
/**Files inside '/../main/lib/' */
require_once $libdir.'urlmanager.lib.php';
require_once $libdir.'fileDisplay.lib.php';
require_once $libdir.'groupmanager.lib.php';
require_once $libdir.'course.lib.php';
require_once $libdir.'usermanager.lib.php';
require_once $libdir.'social.lib.php';
require_once $libdir.'xht.lib.php';
require_once $libdir.'xmd.lib.php';
require_once $libdir.'formvalidator/FormValidator.class.php';
require_once $libdir.'exercise_show_functions.lib.php';
require_once $libdir.'fileManage.lib.php';
/**This files need be inside a buffering to clean the objects*/
ob_start();
require_once $libdir.'main_api.lib.php';
require_once $libdir.'course_document.lib.php';
require_once $libdir.'banner.lib.php';
require_once $libdir.'add_course.lib.inc.php';
require_once $incdir.'tool_navigation_menu.inc.php';
require_once $incdir.'banner.inc.php';
require_once $libdir.'geometry.lib.php';
ob_end_clean();
/**Problem with this file to test objects*/
//require_once $maindir.'exercice/exercise.lib.php';
/*
-----------------------------------------------------------
Table definitions
-----------------------------------------------------------
*/
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
/*
==============================================================================
MAIN CODE
==============================================================================
*/
global $_configuration, $_user, $_course, $cidReq;
$cidReq = 'COURSETEST';
/*
-----------------------------------------------------------
Check if the course exists
-----------------------------------------------------------
*/
$sql = "SELECT code FROM $table_course WHERE code = '$cidReq' ";
$rs = Database::query($sql, __FILE__, __LINE__);
$row = Database::fetch_row($rs);
/*
-----------------------------------------------------------
Create the course COURSETEST
-----------------------------------------------------------
*/
if (empty($row[0])) {
// create a course
$course_datos = array(
'wanted_code'=> $cidReq,
'title'=>$cidReq,
'tutor_name'=>'John Doe',
'category_code'=>'LANG',
'course_language'=>'spanish',
'course_admin_id'=>'001',
'db_prefix'=> $_configuration['db_prefix'],
'firstExpirationDelay'=>'999'
);
$res = create_course($course_datos['wanted_code'], $course_datos['title'],
$course_datos['tutor_name'], $course_datos['category_code'],
$course_datos['course_language'],$course_datos['course_admin_id'],
$course_datos['db_prefix'], $course_datos['firstExpirationDelay']);
}
$sql = "SELECT course.*, course_category.code faCode, course_category.name faName
FROM $course_table
LEFT JOIN $course_cat_table
ON course.category_code = course_category.code
WHERE course.code = '$cidReq'";
$result = Database::query($sql,__FILE__,__LINE__);
/*
-----------------------------------------------------------
Create the session
-----------------------------------------------------------
*/
if (Database::num_rows($result)>0) {
$cData = Database::fetch_array($result);
$_cid = $cData['code' ];
$_course = array();
$_course['id' ] = $cData['code' ]; //auto-assigned integer
$_course['name' ] = $cData['title' ];
$_course['official_code'] = $cData['visual_code' ]; // use in echo
$_course['sysCode' ] = $cData['code' ]; // use as key in db
$_course['path' ] = $cData['directory' ]; // use as key in path
$_course['dbName' ] = $cData['db_name' ]; // use as key in db list
$_course['dbNameGlu' ] = $_configuration['table_prefix'] . $cData['db_name'] . $_configuration['db_glue']; // use in all queries
$_course['titular' ] = $cData['tutor_name' ];
$_course['language' ] = $cData['course_language' ];
$_course['extLink' ]['url' ] = $cData['department_url' ];
$_course['extLink' ]['name'] = $cData['department_name' ];
$_course['categoryCode'] = $cData['faCode' ];
$_course['categoryName'] = $cData['faName' ];
$_course['visibility' ] = $cData['visibility' ];
$_course['subscribe_allowed'] = $cData['subscribe' ];
$_course['unubscribe_allowed'] = $cData['unsubscribe' ];
api_session_register('_cid');
api_session_register('_course');
}
/*
-----------------------------------------------------------
Load the session
-----------------------------------------------------------
*/
$_SESSION['_user']['user_id'] = 1;
$_SESSION['is_courseAdmin'] = 1;
$_SESSION['show'] = showall;
/*
-----------------------------------------------------------
Load the user
-----------------------------------------------------------
*/
$_user['user_id'] = $_SESSION['_user']['user_id'];

@ -0,0 +1,165 @@
<?php
// $Id: teardown.inc.php 2010-02-17 14:20:00Z aportugal $
/* For licensing terms, see /chamilo_license.txt */
/**
==============================================================================
* This is the settings file destroy than need some functions to finish the test
*
* It destroy:
* - require_once
* - constructs
* - creation course
* - session
* - api_allow_edit
* - api_session
*
*
* @todo rewrite code to separate display, logic, database code
* @package chamilo.main
==============================================================================
*/
/**
* @todo shouldn't these settings be moved to the test_suite.php.
* if these are really configuration then we can make require_once in each tests.
* @todo use this file to destroy the setup in each file test.
* @todo check for duplication of require with test_suite.php
*/
/*
-----------------------------------------------------------
Included libraries
-----------------------------------------------------------
*/
require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
/*
==============================================================================
MAIN CODE
==============================================================================
*/
$code = 'COURSETEST';
$res = CourseManager::delete_course($code);
$path = api_get_path(SYS_PATH).'archive';
if ($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
if (strpos($file,$code)!==false) {
if (is_dir($path.'/'.$file)) {
rmdirr($path.'/'.$file);
}
}
}
closedir($handle);
}
$dirname = api_get_path(SYS_LANG_PATH);
$perm_dir = substr(sprintf('%o', fileperms($dirname)), -4);
if ($perm_dir != '0777') {
$msg = "Error";
$this->assertTrue(is_string($msg));
} else {
$path = $dirname.'upload';
$filemode = '0777';
$res = api_chmod_R($path, $filemode);
unlink($path);
$this->assertTrue($res || IS_WINDOWS_OS); // We know, it does not work for Windows.
}
/*
function testApiIsAllowed(){
global $_course, $_user;
$tool= 'full';
$action = 'delete';
$res=api_is_allowed($tool, $action, $task_id=0);
if(!is_bool($res)){
$this->assertTrue(is_null($res));
}
$this->assertTrue($action);
$this->assertTrue($_user['user_id']);
}
function testApiNotAllowed(){
ob_start();
//api_not_allowed($print_headers = false);
$res = ob_get_contents();
$this->assertEqual($res,'');
ob_end_clean();
}
function testApiIsAllowedToCreateCourse() {
$res=api_is_allowed_to_create_course();
if(!is_bool($res)){
$this->assertTrue(is_null($res));
}
}
function testApiIsCoach(){
global $_user;
global $sessionIsCoach;
$_user['user_id']=2;
$sessionIsCoach=Database::store_result($result=false);
$res=api_is_coach();
$this->assertTrue(is_bool($res));
//var_dump($res);
$this->assertTrue($_user['user_id']);
$this->assertTrue(is_array($sessionIsCoach));
//var_dump($sessionIsCoach);
}
function testApiIsSessionAdmin(){
global $_user;
$_user['status']=true;
$res=api_is_session_admin();
$this->assertTrue(is_bool($res));
$this->assertTrue(is_array($_user));
//var_dump($_user);
}
function testApiIsCourseCoach() {
$res=api_is_course_coach();
if(!is_bool($res)){
$this->assertTrue(is_null($res));
}
}
function testApiIsSessionAdmin(){
global $_user;
$_user['status']=true;
$res=api_is_session_admin();
$this->assertTrue(is_bool($res));
$this->assertTrue(is_array($_user));
//var_dump($_user);
}
function testApiNotAllowed(){
ob_start();
//api_not_allowed($print_headers = false);
$res = ob_get_contents();
$this->assertEqual($res,'');
ob_end_clean();
}
function testApiSessionDestroy(){
if (!headers_sent()) {
$res=api_session_destroy();
}
$this->assertTrue(is_null($res));
//var_dump($res);
}
function testApiSessionStart(){
if (!headers_sent()) {
$res = api_session_start($already_sintalled=true);
}
$this->assertTrue(is_null($res));
//var_dump($res);
}
*/

@ -1,142 +1,52 @@
<?php
// $Id: test_suite.php 2010-02-17 12:07:00Z aportugal $
//Set the time limit for the tests
ini_set('memory_limit','256M');
ini_set('max_execution_time','0');
/* For licensing terms, see /chamilo_license.txt */
/**
==============================================================================
* This is the index file load when a user is testing functions in Chamilo.
*
* It load:
* - global.inc
* - files of simpletest
* - files with functions tests
*
* @todo rewrite code to separate display, logic, database code
* @package chamilo.main
==============================================================================
*/
$maindir = dirname(__FILE__).'/../main/';
$incdir = dirname(__FILE__).'/../main/inc/';
$libdir = dirname(__FILE__).'/../main/inc/lib/';
/**
* @todo shouldn't these settings be moved to the test_suite.php.
* if these are really configuration then we can make require_once in each tests.
* @todo use this file to load the setup in each file test.
* @todo check for duplication of require with test_suite.php
* @author aportugal
*/
//Need the ob start and clean else will show the objects
/*
-----------------------------------------------------------
Included libraries
-----------------------------------------------------------
*/
//Need to start to load the settings in the setup and teardown
$incdir = dirname(__FILE__).'/../main/inc/';
require_once $incdir.'global.inc.php';
//List of files than need the tests
//Files than need simpletest
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/web_tester.php';
require_once 'simpletest/mock_objects.php';
require_once 'simpletest/autorun.php';
require_once $libdir.'urlmanager.lib.php';
require_once $libdir.'fileDisplay.lib.php';
require_once $maindir.'permissions/permissions_functions.inc.php';
require_once $libdir.'groupmanager.lib.php';
require_once $libdir.'course.lib.php';
require_once $libdir.'usermanager.lib.php';
require_once $libdir.'social.lib.php';
require_once $libdir.'xht.lib.php';
require_once $libdir.'xmd.lib.php';
require_once $libdir.'formvalidator/FormValidator.class.php';
//Need the ob start and clean else will show the objects
ob_start();
require_once $libdir.'main_api.lib.php';
require_once $libdir.'course_document.lib.php';
require_once $libdir.'banner.lib.php';
require_once $libdir.'add_course.lib.inc.php';
require_once $incdir.'tool_navigation_menu.inc.php';
require_once $incdir.'banner.inc.php';
require_once $libdir.'geometry.lib.php';
ob_end_clean();
//List of files than need the tests since chamilo
require_once $maindir.'admin/calendar.lib.php';
require_once $maindir.'admin/statistics/statistics.lib.php';
require_once $maindir.'dropbox/dropbox_class.inc.php';
require_once $maindir.'dropbox/dropbox_functions.inc.php';
require_once $maindir.'survey/survey.lib.php';
require_once $maindir.'exercice/export/scorm/scorm_classes.php';
require_once $maindir.'exercice/export/qti2/qti2_classes.php';
require_once $maindir.'exercice/export/exercise_import.inc.php';
require_once $maindir.'exercice/exercise_result.class.php';
require_once $libdir.'exercise_show_functions.lib.php';
require_once $maindir.'exercice/answer.class.php';
require_once $maindir.'exercice/exercise.class.php';
require_once $maindir.'exercice/fill_blanks.class.php';
require_once $maindir.'exercice/freeanswer.class.php';
require_once $maindir.'forum/forumfunction.inc.php';
require_once $libdir.'fileManage.lib.php';
/**Problem with this file to test objects*/
//require_once $maindir.'exercice/exercise.lib.php';
/*
==============================================================================
TEST SUITE
==============================================================================
*/
class TestsSuite extends TestSuite {
function setUp() {
global $_configuration, $_user, $_course, $cidReq;
$cidReq = 'COURSETEST';
// check if course exists
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$sql = "SELECT code FROM $table_course WHERE code = '$cidReq' ";
$rs = Database::query($sql, __FILE__, __LINE__);
$row = Database::fetch_row($rs);
if (empty($row[0])) {
// create a course
$course_datos = array(
'wanted_code'=> $cidReq,
'title'=>$cidReq,
'tutor_name'=>'John Doe',
'category_code'=>'LANG',
'course_language'=>'spanish',
'course_admin_id'=>'001',
'db_prefix'=> $_configuration['db_prefix'],
'firstExpirationDelay'=>'999'
);
$res = create_course($course_datos['wanted_code'], $course_datos['title'],
$course_datos['tutor_name'], $course_datos['category_code'],
$course_datos['course_language'],$course_datos['course_admin_id'],
$course_datos['db_prefix'], $course_datos['firstExpirationDelay']);
}
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$sql = "SELECT course.*, course_category.code faCode, course_category.name faName
FROM $course_table
LEFT JOIN $course_cat_table
ON course.category_code = course_category.code
WHERE course.code = '$cidReq'";
$result = Database::query($sql,__FILE__,__LINE__);
//create the session
if (Database::num_rows($result)>0) {
$cData = Database::fetch_array($result);
$_cid = $cData['code' ];
$_course = array();
$_course['id' ] = $cData['code' ]; //auto-assigned integer
$_course['name' ] = $cData['title' ];
$_course['official_code'] = $cData['visual_code' ]; // use in echo
$_course['sysCode' ] = $cData['code' ]; // use as key in db
$_course['path' ] = $cData['directory']; // use as key in path
$_course['dbName' ] = $cData['db_name' ]; // use as key in db list
$_course['dbNameGlu' ] = $_configuration['table_prefix'] . $cData['db_name'] . $_configuration['db_glue']; // use in all queries
$_course['titular' ] = $cData['tutor_name' ];
$_course['language' ] = $cData['course_language' ];
$_course['extLink' ]['url' ] = $cData['department_url' ];
$_course['extLink' ]['name'] = $cData['department_name'];
$_course['categoryCode'] = $cData['faCode' ];
$_course['categoryName'] = $cData['faName' ];
$_course['visibility' ] = $cData['visibility'];
$_course['subscribe_allowed'] = $cData['subscribe'];
$_course['unubscribe_allowed'] = $cData['unsubscribe'];
api_session_register('_cid');
api_session_register('_course');
}
$_SESSION['_user']['user_id'] = 1;
$_user['user_id'] = $_SESSION['_user']['user_id'];
$_SESSION['is_courseAdmin'] = 1;
$_SESSION['show'] = showall;
}
function TestsSuite() {
$this->setUp();
$this->TestSuite('All tests suite');
/* $this->addTestFile(dirname(__FILE__).'/main/inc/lib/database.lib.test.php');
$this->addTestFile(dirname(__FILE__).'/main/inc/lib/add_course.lib.inc.test.php');
@ -241,9 +151,8 @@ class TestsSuite extends TestSuite {
/**FORUM*/
$this->addTestFile(dirname(__FILE__).'/main/forum/forumfunction.inc.test.php');
$this->addTestFile(dirname(__FILE__).'/main/inc/lib/main_api.lib.test.php');//this file delete the course,session and the use of api_allow
$this->addTestFile(dirname(__FILE__).'/main/inc/lib/debug.lib.inc.test.php');//this file need be to the finish of the tests
//$this->addTestFile(dirname(__FILE__).'/main/inc/lib/main_api.lib.test.php');
//$this->addTestFile(dirname(__FILE__).'/main/inc/lib/debug.lib.inc.test.php');

Loading…
Cancel
Save