Feature #272 - Changes that lead loading the file sortabletable.class.php (and the tree of related files) only when it is necessary, on explicit statement require_once. Previously this file loaded on every page, which is waste of computing resource.

skala
Ivan Tcholakov 15 years ago
parent 2db99f2af3
commit 5974516888
  1. 1
      main/admin/access_urls.php
  2. 1
      main/admin/class_list.php
  3. 1
      main/admin/languages.php
  4. 1
      main/admin/settings.php
  5. 17
      main/admin/specific_fields.php
  6. 9
      main/admin/statistics/index.php
  7. 1
      main/admin/sub_language.php
  8. 5
      main/admin/system_announcements.php
  9. 9
      main/admin/user_fields.php
  10. 9
      main/admin/user_fields_options.php
  11. 1
      main/document/document.php
  12. 35
      main/exercice/exercice.php
  13. 9
      main/gradebook/gradebook_showlog_eval.php
  14. 1
      main/gradebook/gradebook_showlog_link.php
  15. 1
      main/group/group.php
  16. 1
      main/inc/course_document.inc.php
  17. 16
      main/inc/lib/display.lib.php
  18. 53
      main/mySpace/course.php
  19. 59
      main/mySpace/index.php
  20. 223
      main/mySpace/myspace.lib.php
  21. 21
      main/mySpace/session.php
  22. 29
      main/mySpace/student.php
  23. 3
      main/newscorm/lp_list_search.php
  24. 9
      main/reservation/m_category.php
  25. 5
      main/reservation/rsys.php
  26. 3
      main/survey/survey.lib.php
  27. 19
      main/survey/survey_invitation.php
  28. 11
      main/survey/survey_list.php
  29. 33
      main/tracking/courseLog.php
  30. 3
      tests/main/inc/lib/sortabletable.class.test.php

@ -9,6 +9,7 @@
$language_file = 'admin';
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();

@ -32,6 +32,7 @@ $language_file = 'admin';
$cidReset = true;
require '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();

@ -27,6 +27,7 @@ $cidReset = true;
// include global script
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once 'sub_language.class.php';
$this_section = SECTION_PLATFORM_ADMIN;

@ -27,6 +27,7 @@ if ($_GET['category']=='Templates') {
$cidReset=true;
// including some necessary dokeos files
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';

@ -24,19 +24,20 @@
* @package dokeos.admin
*/
$language_file[] = 'admin';
// including some necessary dokeos files
require('../inc/global.inc.php');
// Including some necessary chamilo files
require '../inc/global.inc.php';
// user permissions
// User permissions
api_protect_admin_script();
// breadcrumb
$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ("url" => 'specific_fields.php', "name" => get_lang('SpecificSearchFields'));
// Breadcrumb
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields'));
$libpath = api_get_path(LIBRARY_PATH);
include_once ($libpath.'specific_fields_manager.lib.php');
require_once ($libpath.'formvalidator/FormValidator.class.php');
require_once $libpath.'sortabletable.class.php';
include_once $libpath.'specific_fields_manager.lib.php';
require_once $libpath.'formvalidator/FormValidator.class.php';
// Create an add-field box
$form = new FormValidator('add_field','post','','',null,false);

@ -25,14 +25,15 @@
* @package dokeos.statistics
==============================================================================
*/
// name of the language file that needs to be included
$language_file=array('admin','tracking');
// Language files that need to be included
$language_file = array('admin', 'tracking');
$cidReset = true;
include('../../inc/global.inc.php');
require '../../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
api_protect_admin_script();
$interbreadcrumb[] = array ("url" => "../index.php", "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => '../index.php', 'name' => get_lang('PlatformAdmin'));
$tool_name = get_lang('Statistics');
Display::display_header($tool_name);

@ -9,6 +9,7 @@
$language_file = 'admin';
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once 'sub_language.class.php';
require_once api_get_path(LIBRARY_PATH).'array.lib.php';
$this_section=SECTION_PLATFORM_ADMIN;

@ -12,9 +12,10 @@ $language_file = array ('admin', 'agenda');
$cidReset = true;
// including the global dokeos files
require_once ('../inc/global.inc.php');
require '../inc/global.inc.php';
// including additional libraries
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
@ -110,7 +111,7 @@ if (isset ($_GET['action']) && $_GET['action'] == 'add') {
}
// Edit an announcement
if (isset ($_GET['action']) && $_GET['action'] == 'edit') {
$announcement = SystemAnnouncementManager :: get_announcement($_GET['id']);
$values['id'] = $announcement->id;
$values['title'] = $announcement->title;

@ -6,14 +6,15 @@
==============================================================================
*/
// name of the language file that needs to be included
$language_file = array('admin','registration');
$language_file = array('admin', 'registration');
$cidReset = true;
// including necessary libraries
require ('../inc/global.inc.php');
require '../inc/global.inc.php';
$libpath = api_get_path(LIBRARY_PATH);
include_once ($libpath.'usermanager.lib.php');
require_once ($libpath.'formvalidator/FormValidator.class.php');
require_once $libpath.'sortabletable.class.php';
require_once $libpath.'usermanager.lib.php';
require_once $libpath.'formvalidator/FormValidator.class.php';
// section for the tabs
$this_section=SECTION_PLATFORM_ADMIN;

@ -24,18 +24,19 @@
==============================================================================
*/
// name of the language file that needs to be included
$language_file = array('admin','registration');
$language_file = array('admin', 'registration');
// resetting the course information
$cidReset = true;
// including the global library
require ('../inc/global.inc.php');
require '../inc/global.inc.php';
// including additional libraries
$libpath = api_get_path(LIBRARY_PATH);
include_once ($libpath.'usermanager.lib.php');
require_once ($libpath.'formvalidator/FormValidator.class.php');
require_once $libpath.'sortabletable.class.php';
include_once $libpath.'usermanager.lib.php';
require_once $libpath.'formvalidator/FormValidator.class.php';
// section for the tabs
$this_section=SECTION_PLATFORM_ADMIN;

@ -43,6 +43,7 @@ $lib_path = api_get_path(LIBRARY_PATH);
require_once $lib_path.'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
api_protect_course_script(true);
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery

@ -7,7 +7,7 @@
* @author Olivier Brouckaert, original author
* @author Denes Nagy, HotPotatoes integration
* @author Wolfgang Schneider, code/html cleanup
* @author Julio Montoya <gugli100@gmail.com>, lots of cleanup + several improvements
* @author Julio Montoya <gugli100@gmail.com>, lots of cleanup + several improvements
* @version $Id:exercice.php 12269 2007-05-03 14:17:37Z elixir_julian $
*/
@ -16,6 +16,7 @@ $language_file = 'exercice';
// including the global library
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once '../gradebook/lib/be.inc.php';
// setting the tabs
$this_section = SECTION_COURSES;
@ -520,15 +521,15 @@ if ($is_allowedToEdit) {
if (!empty ($choice)) {
// construction of Exercise
$objExerciseTmp = new Exercise();
$objExerciseTmp = new Exercise();
$check = Security::check_token('get');
if ($objExerciseTmp->read($exerciseId)) {
if ($check) {
switch ($choice) {
case 'delete' : // deletes an exercise
$objExerciseTmp->delete();
//delete link of exercise of gradebook tool
$sql = 'SELECT gl.id FROM ' . $tbl_grade_link . ' gl WHERE gl.type="1" AND gl.ref_id="' . $exerciseId . '";';
$result = Database::query($sql);
@ -547,7 +548,7 @@ if ($is_allowedToEdit) {
$objExerciseTmp->save();
// "WHAT'S NEW" notification: update table item_property (previously last_tooledit)
Display :: display_confirmation_message(get_lang('VisibilityChanged'));
break;
case 'disable' : // disables an exercise
$objExerciseTmp->disable();
@ -565,13 +566,13 @@ if ($is_allowedToEdit) {
Display :: display_confirmation_message(get_lang('ResultsEnabled'));
break;
case 'clean_results' : //clean student results
$quantity_results_deleted= $objExerciseTmp->clean_results();
$quantity_results_deleted= $objExerciseTmp->clean_results();
Display :: display_confirmation_message(sprintf(get_lang('XResultsCleaned'),$quantity_results_deleted));
break;
case 'copy_exercise' : //copy an exercise
$objExerciseTmp->copy_exercise();
Display :: display_confirmation_message(get_lang('ExerciseCopied'));
break;
case 'copy_exercise' : //copy an exercise
$objExerciseTmp->copy_exercise();
Display :: display_confirmation_message(get_lang('ExerciseCopied'));
break;
}
}
}
@ -868,9 +869,9 @@ if ($show == 'test') {
$myorigin = (empty ($origin) ? '' : '&origin=' . $origin);
$mylpid = (empty ($learnpath_id) ? '' : '&learnpath_id=' . $learnpath_id);
$mylpitemid = (empty ($learnpath_item_id) ? '' : '&learnpath_item_id=' . $learnpath_item_id);
$token = Security::get_token();
$token = Security::get_token();
while ($row = Database :: fetch_array($result)) {
//validacion when belongs to a session
$session_img = api_get_session_image($row['session_id'], $_user['status']);
@ -911,10 +912,10 @@ if ($show == 'test') {
?>
<td>
<a href="admin.php?<?php echo api_get_cidreq()?>&amp;exerciseId=<?php echo $row['id']; ?>"><img src="../img/wizard_small.gif" border="0" title="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('Edit'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=copy_exercise&amp;sec_token=<?php echo$token; ?>&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset)); echo " ".$row['title']; echo "?"; ?>')) return false;"><img width="16" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=copy_exercise&amp;sec_token=<?php echo$token; ?>&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset)); echo " ".$row['title']; echo "?"; ?>')) return false;"><img width="16" src="../img/cd.gif" border="0" title="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CopyExercise'),ENT_QUOTES,$charset); ?>" /></a>
<a href="exercice.php?<?php echo api_get_cidreq()?>&amp;choice=clean_results&amp;sec_token=<?php echo$token; ?>&amp;exerciseId=<?php echo $row['id']; ?>" onclick="javascript:if(!confirm('<?php echo addslashes(api_htmlentities(get_lang('AreYouSureToDeleteResults'),ENT_QUOTES,$charset)); echo " ".$row['title']; echo "?"; ?>')) return false;" ><img width="16" src="../img/clean_group.gif" border="0" title="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" alt="<?php echo api_htmlentities(get_lang('CleanStudentResults'),ENT_QUOTES,$charset); ?>" /></a>
<?php
if ($row['results_disabled']) {
@ -1364,7 +1365,7 @@ if ($_configuration['tracking_enabled'] && ($show == 'result')) {
}
$parameters=array('cidReq'=>Security::remove_XSS($_GET['cidReq']),'show'=>Security::remove_XSS($_GET['show']),'filter' => Security::remove_XSS($_GET['filter']),'gradebook' =>Security::remove_XSS($_GET['gradebook']));
$table = new SortableTableFromArrayConfig($list_info, 1,20,'quiz_table');
$table->set_additional_parameters($parameters);
if ($is_allowedToEdit || $is_tutor) {

@ -2,10 +2,11 @@
/* For licensing terms, see /license.txt */
$language_file = 'gradebook';
//$cidReset = true;
require_once ('../inc/global.inc.php');
require_once ('lib/be.inc.php');
require_once ('lib/gradebook_functions.inc.php');
require_once ('lib/fe/evalform.class.php');
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';
api_block_anonymous_users();
block_students();

@ -3,6 +3,7 @@
$language_file = 'gradebook';
//$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once 'lib/be.inc.php';
require_once 'lib/gradebook_functions.inc.php';
require_once 'lib/fe/evalform.class.php';

@ -19,6 +19,7 @@
$language_file = 'group';
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
$this_section = SECTION_COURSES;
// Notice for unauthorized people.

@ -8,6 +8,7 @@ require 'global.inc.php';
/* Libraries */
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'course_document.lib.php';
require_once api_get_path(LIBRARY_PATH).'fckeditor/repository.php';
require_once api_get_path(SYS_CODE_PATH).'document/document.inc.php';

@ -14,7 +14,7 @@
*/
/*
all public functions are stored inside the Display class
CLASS Display
public functions inside
@ -39,7 +39,7 @@ all public functions are stored inside the Display class
* @version 1.0.4
* @package dokeos.library
*/
require_once 'sortabletable.class.php';
class Display {
private function __construct() {
@ -229,6 +229,9 @@ class Display {
* @author bart.mollet@hogent.be
*/
public static function display_sortable_table ($header, $content, $sorting_options = array (), $paging_options = array (), $query_vars = null, $form_actions=array(), $style='table') {
if (!class_exists('SortableTable')) {
require_once 'sortabletable.class.php';
}
global $origin;
$column = isset ($sorting_options['column']) ? $sorting_options['column'] : 0;
$default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
@ -268,6 +271,9 @@ class Display {
*/
public static function display_sortable_grid ($name, $header, $content, $paging_options = array (), $query_vars = null, $form_actions=array(), $vibility_options = true) {
if (!class_exists('SortableTable')) {
require_once 'sortabletable.class.php';
}
global $origin;
$column = 0;
$default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
@ -298,6 +304,9 @@ class Display {
* @return string html grid
*/
public static function return_sortable_grid ($name, $header, $content, $paging_options = array (), $query_vars = null, $form_actions=array(), $vibility_options = true, $sort_data = true) {
if (!class_exists('SortableTable')) {
require_once 'sortabletable.class.php';
}
global $origin;
$column = 0;
$default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;
@ -338,6 +347,9 @@ class Display {
*/
public static function display_sortable_config_table ($header, $content, $sorting_options = array (), $paging_options = array (), $query_vars = null, $column_show=array(),$column_order=array(),$form_actions=array()) {
if (!class_exists('SortableTable')) {
require_once 'sortabletable.class.php';
}
global $origin;
$column = isset ($sorting_options['column']) ? $sorting_options['column'] : 0;
$default_items_per_page = isset ($paging_options['per_page']) ? $paging_options['per_page'] : 20;

@ -10,6 +10,7 @@ $language_file = array ('admin', 'registration', 'index', 'trad4all', 'tracking'
$cidReset = true;
require '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
@ -63,27 +64,27 @@ $a_courses = array();
if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
$title = '';
if (empty($id_session)) {
if (empty($id_session)) {
if (isset($_GET['user_id'])) {
$user_id = intval($_GET['user_id']);
$user_info = api_get_user_info($user_id);
$title = get_lang('AssignedCoursesTo').' '.api_get_person_name($user_info['firstname'], $user_info['lastname']);
$courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);
$title = get_lang('AssignedCoursesTo').' '.api_get_person_name($user_info['firstname'], $user_info['lastname']);
$courses = CourseManager::get_course_list_of_user_as_course_admin($user_id);
} else {
$title = get_lang('YourCourseList');
$courses = CourseManager::get_courses_followed_by_drh($_user['user_id']);
$courses = CourseManager::get_courses_followed_by_drh($_user['user_id']);
}
} else {
$session_name = api_get_session_name($id_session);
$title = api_htmlentities($session_name,ENT_QUOTES,$charset).' : '.get_lang('CourseListInSession');
$session_name = api_get_session_name($id_session);
$title = api_htmlentities($session_name,ENT_QUOTES,$charset).' : '.get_lang('CourseListInSession');
$courses = Tracking::get_courses_list_from_session($id_session);
}
$a_courses = array_keys($courses);
if (!api_is_session_admin()) {
$menu_items[] = '<a href="index.php?view=drh_students&amp;display=yourstudents">'.get_lang('Students').'</a>';
$menu_items[] = '<a href="teachers.php">'.get_lang('Teachers').'</a>';
$menu_items[] = '<a href="teachers.php">'.get_lang('Teachers').'</a>';
if (empty($_GET['user_id']) && empty($id_session)) {
$menu_items[] = get_lang('Courses');
} else {
@ -91,7 +92,7 @@ if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
}
$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
}
echo '<div class="actions-title" style ="font-size:10pt;">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
@ -101,9 +102,9 @@ if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
echo '&nbsp;|&nbsp;';
}
}
}
}
if (count($a_courses) > 0) {
echo '&nbsp;&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';
echo '&nbsp;&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';
}
echo '</div>';
echo '<h4>'.$title.'</h4>';
@ -133,18 +134,18 @@ if ($show_import_icon) {
echo "</div><br />";
}
if (!api_is_drh() && !api_is_session_admin() && !api_is_platform_admin()) {
if (!api_is_drh() && !api_is_session_admin() && !api_is_platform_admin()) {
/*if (api_is_platform_admin()) {
if (empty($id_session)) {
$courses = CourseManager::get_real_course_list();
if (empty($id_session)) {
$courses = CourseManager::get_real_course_list();
} else {
$courses = Tracking::get_courses_list_from_session($id_session);
}
} else {*/
$courses = Tracking::get_courses_followed_by_coach($_user['user_id'], $id_session);
//}
//}
$a_courses = array_keys($courses);
}
}
$nb_courses = count($a_courses);
@ -178,17 +179,17 @@ if (is_array($a_courses)) {
$course = CourseManager :: get_course_information($course_code);
$avg_assignments_in_course = $avg_messages_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = 0;
// students directly subscribed to the course
// students directly subscribed to the course
if (empty($id_session)) {
$sql = "SELECT user_id FROM $tbl_user_course as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";
} else {
$sql = "SELECT id_user as user_id FROM $tbl_session_course_user srcu WHERE srcu. course_code='$course_code' AND id_session = '$id_session' AND srcu.status<>2";
}
$sql = "SELECT id_user as user_id FROM $tbl_session_course_user srcu WHERE srcu. course_code='$course_code' AND id_session = '$id_session' AND srcu.status<>2";
}
$rs = Database::query($sql);
$rs = Database::query($sql);
$users = array();
while ($row = Database::fetch_array($rs)) { $users[] = $row['user_id']; }
if (count($users) > 0) {
$nb_students_in_course = count($users);
// tracking datas
@ -197,11 +198,11 @@ if (is_array($a_courses)) {
$avg_time_spent_in_course = Tracking :: get_time_spent_on_the_course ($users, $course_code, $id_session);
$messages_in_course = Tracking :: count_student_messages ($users, $course_code, $id_session);
$assignments_in_course = Tracking :: count_student_assignments ($users, $course_code, $id_session);
$avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course);
$avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2);
$avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2);
} else {
$avg_time_spent_in_course = null;
$avg_progress_in_course = null;
@ -209,7 +210,7 @@ if (is_array($a_courses)) {
$messages_in_course = null;
$assignments_in_course = null;
}
$tematic_advance_progress = 0;
$course_description = new CourseDescription();
$course_description->set_session_id($id_session);
@ -221,7 +222,7 @@ if (is_array($a_courses)) {
} else {
$tematic_advance_progress = '-';
}
$table_row = array();
$table_row[] = $course['title'];
$table_row[] = $nb_students_in_course;

@ -4,7 +4,7 @@
* @todo use constant for $this_section
*/
// name of the language file that needs to be included
$language_file = array ('registration', 'index', 'tracking');
$language_file = array('registration', 'index', 'tracking');
// resetting the course id
$cidReset = true;
@ -13,6 +13,7 @@ $cidReset = true;
require_once '../inc/global.inc.php';
// including additional libraries
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
@ -125,15 +126,15 @@ global $_configuration;
// interbreadcrumbs
if (api_is_allowed_to_create_course() && $_GET['display'] != 'yourstudents') {
$session_id = intval($_GET['session_id']);
$session_id = intval($_GET['session_id']);
if (!empty($session_id)) {
$courses = Tracking::get_courses_followed_by_coach($_user['user_id'], $session_id);
} else {
$courses = CourseManager::get_course_list_of_user_as_course_admin($_user['user_id']);
$courses = CourseManager::get_course_list_of_user_as_course_admin($_user['user_id']);
}
$nb_teacher_courses = count($courses);
$sessions = Tracking::get_sessions_coached_by_user($_user['user_id']);
$nb_sessions = count($sessions);
@ -141,19 +142,19 @@ if (api_is_allowed_to_create_course() && $_GET['display'] != 'yourstudents') {
if (!$is_coach && !$is_platform_admin) {
$view = 'teacher';
}
if ($view == 'teacher' && empty($session_id)) {
if ($view == 'teacher' && empty($session_id)) {
$menu_items[] = get_lang('TeacherInterface');
if ($nb_teacher_courses) {
$title = get_lang('YourCourseList');
}
} else {
if (!empty($session_id)) {
} else {
if (!empty($session_id)) {
$session_name = api_get_session_name($session_id);
$title = ucfirst($session_name);
}
$title = ucfirst($session_name);
}
$menu_items[] = '<a href="'.api_get_self().'?view=teacher">'.get_lang('TeacherInterface').'</a>';
}
}
@ -186,7 +187,7 @@ if ($is_platform_admin && $_GET['display'] != 'yourstudents') {
}
if ($is_drh || $_GET['display'] == 'yourstudents') {
$view = 'drh';
$view = 'drh';
$menu_items[] = get_lang('Students');
$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
@ -217,7 +218,7 @@ echo '<h4>'.$title.'</h4>';
if (($is_drh && $view == 'drh') || $_GET['display'] == 'yourstudents') {
// get data for human resources manager
$students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT));
$courses_of_the_platform = CourseManager :: get_real_course_list();
$courses_of_the_platform = CourseManager :: get_real_course_list();
foreach ($courses_of_the_platform as $course) {
$courses[$course['code']] = $course['code'];
}
@ -240,7 +241,7 @@ if ($view == 'coach' || $view == 'drh') {
foreach ($students as $student_id) {
// inactive students
$last_connection_date = Tracking :: get_last_connection_date($student_id, true, true);
if ($last_connection_date !== false) {
if ($last_connection_date !== false) {
if (time() - (3600 * 24 * 7) > $last_connection_date) {
$nb_inactive_students++;
}
@ -371,7 +372,7 @@ if ($view == 'coach' || $view == 'drh') {
'.(is_null($nb_assignments) ? '' : round($nb_assignments, 2)).'
</td>
</tr>
</table><br />
</table><br />
<a href="student.php?display=yourstudents">'.get_lang('SeeStudentList').'</a>
</div>';
}
@ -508,7 +509,7 @@ if (api_is_allowed_to_create_course() && $view == 'teacher') {
);
$table->display();
}
// display sessions
if ($nb_sessions > 0 && !isset($_GET['session_id'])) {
echo '<h4>'.get_lang('Sessions').'</h4>';
@ -517,46 +518,46 @@ if (api_is_allowed_to_create_course() && $view == 'teacher') {
$table->set_header(1, get_lang('Date'));
$table->set_header(2, get_lang('NbCoursesPerSession'));
$table->set_header(3, get_lang('Details'), false);
$all_data = array();
foreach ($sessions as $session) {
$count_courses_in_session = count(Tracking::get_courses_followed_by_coach($_user['user_id'], $session['id']));
foreach ($sessions as $session) {
$count_courses_in_session = count(Tracking::get_courses_followed_by_coach($_user['user_id'], $session['id']));
$row = array();
$row[] = $session['name'];
if ($session['date_start'] != '0000-00-00' && $session['date_end'] != '0000-00-00') {
$row[] = get_lang('From').' '.api_convert_and_format_date($session['date_start'], DATE_FORMAT_SHORT, date_default_timezone_get()).' '.get_lang('To').' '.api_convert_and_format_date($session['date_end'], DATE_FORMAT_SHORT, date_default_timezone_get());
} else {
$row[] = ' - ';
}
$row[] = $count_courses_in_session;
$row[] = '<a href="'.api_get_self().'?session_id='.$session['id'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
$row[] = '<a href="'.api_get_self().'?session_id='.$session['id'].'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
$all_data[] = $row;
}
if (!isset($tracking_column)) {
$tracking_column = 0;
}
if ($_GET['tracking_direction'] == 'DESC') {
usort($all_data, 'rsort_sessions');
} else {
usort($all_data, 'sort_sessions');
}
if ($export_csv) {
usort($csv_content, 'sort_sessions');
}
foreach ($all_data as $row) {
$table -> addRow($row);
}
$table -> setColAttributes(1, array('align' => 'center'));
$table -> setColAttributes(2, array('align' => 'center'));
$table -> setColAttributes(3, array('align' => 'center'));
$table -> display();
}
$table -> display();
}
}
if ($is_platform_admin && $view == 'admin' && $_GET['display'] != 'yourstudents') {

@ -1,13 +1,14 @@
<?php
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
class MySpace {
class MySpace {
/* For licensing terms, see /dokeos_license.txt */
/**
* This function serves exporting data in CSV format.
* @param array $header The header labels.
@ -16,36 +17,36 @@ class MySpace {
* @return string mixed Returns a message (string) if an error occurred.
*/
function export_csv($header, $data, $file_name = 'export.csv') {
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
$archive_url = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
if (!$open = fopen($archive_path.$file_name, 'w+')) {
$message = get_lang('noOpen');
} else {
$info = '';
foreach ($header as $value) {
$info .= $value.';';
}
$info .= "\r\n";
foreach ($data as $row) {
foreach ($row as $value) {
$info .= $value.';';
}
$info .= "\r\n";
}
fwrite($open, $info);
fclose($open);
@chmod($file_name, api_get_permissions_for_new_files());
header("Location:".$archive_url.$file_name);
}
return $message;
}
/**
* Gets the connections to a course as an array of login and logout time
*
@ -55,44 +56,44 @@ class MySpace {
* @return array Conections
*/
function get_connections_to_course($user_id, $course_code, $session_id = 0) {
// Database table definitions
$tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$tbl_main = Database :: get_main_table(TABLE_MAIN_COURSE);
// protect data
$user_id = intval($user_id);
$course_code = Database::escape_string($course_code);
$session_id = intval($session_id);
$sql_query = 'SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.$course_code.'";';
$result = Database::query($sql_query);
$row_query = Database::fetch_array($result, 'ASSOC');
$course_true = isset($row_query['course_code']) ? $row_query['course_code']: $course_code;
$sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
WHERE user_id = '.$user_id.'
AND course_code="'.$course_true.'" AND session_id = '.$session_id.' ORDER BY login_course_date ASC';
$rs = Database::query($sql);
$connections = array();
while ($row = Database::fetch_array($rs)) {
$login_date = $row['login_course_date'];
$logout_date = $row['logout_course_date'];
$login_date = api_get_local_time($login_date, null, date_default_timezone_get());
$logout_date = api_get_local_time($logout_date, null, date_default_timezone_get());
$timestamp_login_date = api_strtotime($login_date);
$timestamp_logout_date = api_strtotime($logout_date);
$connections[] = array('login' => $timestamp_login_date, 'logout' => $timestamp_logout_date);
}
return $connections;
}
/**
* TODO: Not used, to b deleted?
* Enter description here...
@ -107,17 +108,17 @@ class MySpace {
// Database table definitions
$tbl_track_course = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$tbl_main = Database :: get_main_table(TABLE_MAIN_COURSE);
$sql_query = 'SELECT visual_code as course_code FROM '.$tbl_main.' c WHERE code="'.Database :: escape_string($course_code).'";';
$result = Database::query($sql_query);
$row_query = Database::fetch_array($result,'ASSOC');
$course_true = isset($row_query['course_code']) ? $row_query['course_code']: $course_code;
$sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
WHERE user_id = ' . intval($user_id) . '
AND course_code="' . Database::escape_string($course_true) . '"
ORDER BY login_course_date DESC';
$rs = Database::query($sql);
$connections = array();
while ($row = Database::fetch_array($rs)) {
@ -129,7 +130,7 @@ class MySpace {
}
return $connections;
}
/**
* Creates a small table in the last column of the table with the user overview
*
@ -156,10 +157,10 @@ class MySpace {
$return .= ' <th>'.get_lang('FirstLogin').'</th>';
$return .= ' <th>'.get_lang('LatestLogin').'</th>';
$return .= ' </tr>';*/
// database table definition
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
// getting all the courses of the user
$sql = "SELECT * FROM $tbl_course_user WHERE user_id = '".Database::escape_string($user_id)."' AND relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
$result = Database::query($sql);
@ -203,7 +204,7 @@ class MySpace {
*/
function display_tracking_user_overview() {
MySpace::display_user_overview_export_options();
$t_head .= ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>';
$t_head .= '<tr>';
@ -221,12 +222,12 @@ class MySpace {
//$t_head .= ' <th><div style="width:60px">'.get_lang('FirstLogin').'</div></th>';
$t_head .= ' <th style="padding:0;border-bottom:0;border-right:0;"><span>'.get_lang('LatestLogin').'</span></th>';
$t_head .= ' </tr></table>';
$addparams = array('view' => 'admin', 'display' => 'useroverview');
$table = new SortableTable('tracking_user_overview', array('MySpace','get_number_of_users_tracking_overview'), array('MySpace','get_user_data_tracking_overview'), 0);
$table->additional_parameters = $addparams;
$table->set_header(0, get_lang('OfficialCode'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
if (api_is_western_name_order()) {
$table->set_header(1, get_lang('FirstName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
@ -240,7 +241,7 @@ class MySpace {
$table->set_column_filter(4, array('MySpace','course_info_tracking_filter'));
$table->display();
}
/**
* Displays a form with all the additionally defined user fields of the profile
* and give you the opportunity to include these in the CSV export
@ -252,20 +253,20 @@ class MySpace {
function display_user_overview_export_options() {
// include the user manager and formvalidator library
if ($_GET['export'] == 'options') {
// get all the defined extra fields
$extrafields = UserManager::get_extra_fields(0, 50, 5, 'ASC', false);
// creating the form with all the defined extra fields
$form = new FormValidator('exportextrafields', 'post', api_get_self()."?view=".Security::remove_XSS($_GET['view']).'&display='.Security::remove_XSS($_GET['display']).'&export='.Security::remove_XSS($_GET['export']));
if (is_array($extrafields) && count($extrafields) > 0) {
foreach ($extrafields as $key => $extra) {
$form->addElement('checkbox', 'extra_export_field'.$extra[0], '', $extra[3]);
}
$form->addElement('style_submit_button','submit', get_lang('Ok'),'class="save"' );
// setting the default values for the form that contains all the extra fields
if (is_array($_SESSION['additional_export_fields'])) {
foreach ($_SESSION['additional_export_fields'] as $key => $value) {
@ -276,14 +277,14 @@ class MySpace {
} else {
$form->addElement('html', Display::display_warning_message(get_lang('ThereAreNotExtrafieldsAvailable')));
}
if ($form->validate()) {
// exporting the form values
$values = $form->exportValues();
// re-initialising the session that contains the additional fields that need to be exported
$_SESSION['additional_export_fields'] = array();
// adding the fields that are checked to the session
$message = '';
foreach ($values as $field_ids => $value) {
@ -291,14 +292,14 @@ class MySpace {
$_SESSION['additional_export_fields'][] = str_replace('extra_export_field', '', $field_ids);
}
}
// adding the fields that will be also exported to a message string
if (is_array($_SESSION['additional_export_fields'])) {
foreach ($_SESSION['additional_export_fields'] as $key => $extra_field_export) {
$message .= '<li>'.$extrafields[$extra_field_export][3].'</li>';
}
}
// Displaying a feedback message
if (!empty($_SESSION['additional_export_fields'])) {
Display::display_confirmation_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', false);
@ -309,22 +310,22 @@ class MySpace {
} else {
$form->display();
}
} else {
if (!empty($_SESSION['additional_export_fields'])) {
// get all the defined extra fields
$extrafields = UserManager::get_extra_fields(0, 50, 5, 'ASC');
foreach ($_SESSION['additional_export_fields'] as $key => $extra_field_export) {
$message .= '<li>'.$extrafields[$extra_field_export][3].'</li>';
}
Display::display_normal_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', false);
$message = '';
}
}
}
}
/**
* Get general information about the exercise performance of the user
* the total obtained score (all the score on all the questions)
@ -333,7 +334,7 @@ class MySpace {
* the success percentage
* @param integer $user_id the id of the user
* @param string $course_code the course code
* @return array
* @return array
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version Dokeos 1.8.6
* @since November 2008
@ -353,13 +354,13 @@ class MySpace {
$score_possible += $row['exe_weighting'];
$questions_answered ++;
}
if ($score_possible != 0) {
$percentage = round(($score_obtained / $score_possible * 100), 2);
} else {
$percentage = null;
}
return array('score_obtained' => $score_obtained, 'score_possible' => $score_possible, 'questions_answered' => $questions_answered, 'percentage' => $percentage);
}
@ -371,14 +372,14 @@ class MySpace {
* @since October 2008
*/
function export_tracking_user_overview() {
// database table definitions
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
$sort_by_first_name = api_sort_by_first_name();
// the values of the sortable table
if ($_GET['tracking_user_overview_page_nr']) {
$from = $_GET['tracking_user_overview_page_nr'];
@ -399,9 +400,9 @@ class MySpace {
} else {
$direction = 'ASC';
}
$user_data = MySpace::get_user_data_tracking_overview($from, 1000, $orderby, $direction);
// the first line of the csv file with the column headers
$csv_row = array();
$csv_row[] = get_lang('OfficialCode');
@ -415,9 +416,9 @@ class MySpace {
$csv_row[] = get_lang('LoginName');
$csv_row[] = get_lang('CourseCode');
// the additional user defined fields (only those that were selected to be exported)
$fields = UserManager::get_extra_fields(0, 50, 5, 'ASC');
if (is_array($_SESSION['additional_export_fields'])) {
foreach ($_SESSION['additional_export_fields'] as $key => $extra_field_export) {
$csv_row[] = $fields[$extra_field_export][3];
@ -437,7 +438,7 @@ class MySpace {
$csv_row[] = get_lang('FirstLogin', '');
$csv_row[] = get_lang('LatestLogin', '');
$csv_content[] = $csv_row;
// the other lines (the data)
foreach ($user_data as $key => $user) {
// getting all the courses of the user
@ -457,7 +458,7 @@ class MySpace {
$csv_row[] = $row[0];
// the additional defined user fields
$extra_fields = MySpace::get_user_overview_export_extra_fields($user[4]);
if (is_array($field_names_to_be_exported)) {
foreach ($field_names_to_be_exported as $key => $extra_field_export) {
$csv_row[] = $extra_fields[$extra_field_export];
@ -485,7 +486,7 @@ class MySpace {
$csv_row[] = Tracking :: get_first_connection_date_on_the_course ($user[4], $row[0]);
// last connection
$csv_row[] = strip_tags(Tracking :: get_last_connection_date_on_the_course ($user[4], $row[0]));
$csv_content[] = $csv_row;
}
}
@ -498,14 +499,14 @@ class MySpace {
* @return array
*/
function get_course_data($from, $number_of_items, $column, $direction) {
global $courses, $csv_content, $charset, $session_id;
// definition database tables
// definition database tables
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$a_course_students = array();
$course_data = array();
$courses_code = array_keys($courses);
@ -513,50 +514,50 @@ class MySpace {
foreach ($courses_code as &$code) {
$code = "'$code'";
}
// get all courses with limit
$sql = "SELECT course.code as col1, course.title as col2
FROM $tbl_course course
WHERE course.code IN (".implode(',',$courses_code).")";
if (!in_array($direction, array('ASC','DESC'))) $direction = 'ASC';
$column = intval($column);
$from = intval($from);
$number_of_items = intval($number_of_items);
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$res = Database::query($sql);
while ($row_course = Database::fetch_row($res)) {
$course_code = $row_course[0];
$course_info = api_get_course_info($course_code);
$avg_assignments_in_course = $avg_messages_in_course = $nb_students_in_course = $avg_progress_in_course = $avg_score_in_course = $avg_time_spent_in_course = $avg_score_in_exercise = 0;
// students directly subscribed to the course
// students directly subscribed to the course
if (empty($session_id)) {
$sql = "SELECT user_id FROM $tbl_course_user as course_rel_user WHERE course_rel_user.status='5' AND course_rel_user.course_code='$course_code'";
} else {
$sql = "SELECT id_user as user_id FROM $tbl_session_course_user srcu WHERE srcu. course_code='$course_code' AND id_session = '$session_id' AND srcu.status<>2";
}
$rs = Database::query($sql);
$sql = "SELECT id_user as user_id FROM $tbl_session_course_user srcu WHERE srcu. course_code='$course_code' AND id_session = '$session_id' AND srcu.status<>2";
}
$rs = Database::query($sql);
$users = array();
while ($row = Database::fetch_array($rs)) { $users[] = $row['user_id']; }
if (count($users) > 0) {
$nb_students_in_course = count($users);
$avg_assignments_in_course = Tracking::count_student_assignments($users, $course_code, $session_id);
$avg_messages_in_course = Tracking::count_student_messages($users, $course_code, $session_id);
$avg_messages_in_course = Tracking::count_student_messages($users, $course_code, $session_id);
$avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code, array(), $session_id);
$avg_score_in_course = Tracking :: get_avg_student_score($users, $course_code, array(), $session_id);
$avg_score_in_exercise = Tracking::get_avg_student_exercise_score($users, $course_code, 0, $session_id);
$avg_time_spent_in_course = Tracking::get_time_spent_on_the_course($users, $course_code, $session_id);
$avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2);
$avg_score_in_course = round($avg_score_in_course / $nb_students_in_course, 2);
$avg_score_in_exercise = round($avg_score_in_exercise / $nb_students_in_course, 2);
$avg_time_spent_in_course = api_time_to_hms($avg_time_spent_in_course / $nb_students_in_course);
} else {
$avg_time_spent_in_course = null;
$avg_progress_in_course = null;
@ -574,7 +575,7 @@ class MySpace {
$table_row[] = is_null($avg_score_in_exercise) ? '' : $avg_score_in_exercise.'%';
$table_row[] = $avg_messages_in_course;
$table_row[] = $avg_assignments_in_course;
//set the "from" value to know if I access the Reporting by the chamilo tab or the course link
$table_row[] = '<center><a href="../tracking/courseLog.php?cidReq='.$course_code.'&studentlist=true&from=myspace&id_session='.$session_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></center>';
$csv_content[] = array(
@ -591,7 +592,7 @@ class MySpace {
}
return $course_data;
}
/**
* get the numer of users of the platform
*
@ -604,11 +605,11 @@ class MySpace {
function get_number_of_users_tracking_overview() {
// database table definition
$main_user_table = Database :: get_main_table(TABLE_MAIN_USER);
// query
$sql = 'SELECT user_id FROM '.$main_user_table;
$result = Database::query($sql);
// return the number of results
return Database::num_rows($result);
}
@ -652,7 +653,7 @@ class MySpace {
}
return $return;
}
/**
* Get all information that the user with user_id = $user_data has
* entered in the additionally defined profile fields
@ -703,7 +704,7 @@ class MySpace {
return $username_array;
}
}
/**
* Checks if there are repeted users in a given array
* @param array $usernames list of the usernames in the uploaded file
@ -714,7 +715,7 @@ class MySpace {
function check_user_in_array($usernames, $user_array) {
$user_list = array_keys($usernames);
$username = $user_array['username'].$user_array['sufix'];
if (in_array($username, $user_list)) {
$user_array['sufix'] += $usernames[$username];
$usernames[$username]++;
@ -724,7 +725,7 @@ class MySpace {
$result_array = array($usernames, $user_array);
return $result_array;
}
/**
* Checks whether a username has been already subscribed in a session.
* @param string a given username
@ -750,7 +751,7 @@ class MySpace {
}
}
}
/**
This function checks whether some users in the uploaded file repeated and creates unique usernames if necesary.
A case: Within the file there is an user repeted twice (Julio Montoya / Julio Montoya) and the username fields are empty.
@ -796,7 +797,7 @@ class MySpace {
}
return $new_users;
}
/**
* This functions checks whether there are users that are already registered in the DB by different creator than the current coach.
* @param string a given username
@ -813,7 +814,7 @@ class MySpace {
$username = Database::escape_string($user['UserName']);
//echo "<br>";
$sql = "SELECT creator_id FROM $table_user WHERE username='$username' ";
$rs = Database::query($sql);
$creator_id = Database::result($rs, 0, 0);
// check if we are the creators or not
@ -826,7 +827,7 @@ class MySpace {
}
return $errors;
}
/**
* Validates imported data.
* @param list of users
@ -841,7 +842,7 @@ class MySpace {
if (api_get_setting('registration', 'email') == 'true') {
$mandatory_fields[] = 'Email';
}
foreach ($mandatory_fields as $key => $field) {
if (!isset ($user[$field]) || strlen($user[$field]) == 0) {
$user['error'] = get_lang($field.'Mandatory');
@ -853,9 +854,9 @@ class MySpace {
$user['error'] = get_lang('UserNameTooLong');
$errors[] = $user;
}
$user['UserName'] = trim($user['UserName']);
if (empty($user['UserName'])) {
$user['UserName'] = UserManager::create_username($user['FirstName'], $user['LastName']);
}
@ -864,7 +865,7 @@ class MySpace {
$results = array('errors' => $errors, 'users' => $new_users);
return $results;
}
/**
* Adds missing user-information (which isn't required, like password, etc).
*/
@ -875,7 +876,7 @@ class MySpace {
}
return $user;
}
/**
* Saves imported data.
*/
@ -884,10 +885,10 @@ class MySpace {
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$id_session = intval($id_session);
$sendMail = $_POST['sendMail'] ? 1 : 0;
// Adding users to the platform.
$new_users = array();
foreach ($users as $index => $user) {
@ -905,7 +906,7 @@ class MySpace {
}
// Update user list.
$users = $new_users;
// Inserting users.
$super_list = array();
foreach ($course_list as $enreg_course) {
@ -924,21 +925,21 @@ class MySpace {
$new_users[] = $user;
}
$super_list[] = $new_users;
//update the nbr_users field
$sql_select = "SELECT COUNT(id_user) as nbUsers FROM $tbl_session_rel_course_rel_user WHERE id_session='$id_session' AND course_code='$enreg_course'";
$rs = Database::query($sql_select);
list($nbr_users) = Database::fetch_array($rs);
$sql_update = "UPDATE $tbl_session_rel_course SET nbr_users=$nbr_users WHERE id_session='$id_session' AND course_code='$enreg_course'";
Database::query($sql_update);
$sql_update = "UPDATE $tbl_session SET nbr_users= '$nbr_users' WHERE id='$id_session'";
Database::query($sql_update);
}
// We don't delete the users (thoughts while dreaming)
//$sql_delete = "DELETE FROM $tbl_session_rel_user WHERE id_session = '$id_session'";
//Database::query($sql_delete);
$new_users = array();
foreach ($users as $index => $user) {
$userid = $user['id'];
@ -947,7 +948,7 @@ class MySpace {
$user['added_at_session'] = 1;
$new_users[] = $user;
}
$users = $new_users;
$registered_users = get_lang('FileImported').'<br /> Import file results : <br />';
// Sending emails.
@ -961,14 +962,14 @@ class MySpace {
$emailheaders = 'From: '.api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS).' <'.api_get_setting('emailAdministrator').">\n";
$emailheaders .= 'Reply-To: '.api_get_setting('emailAdministrator');
@api_send_mail($emailto, $emailsubject, $emailbody, $emailheaders);
if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
if ($user['added_at_platform'] == 1) {
$addedto = get_lang('UserCreatedPlatform');
} else {
$addedto = ' ';
}
if ($user['added_at_session'] == 1) {
$addedto .= get_lang('UserInSession');
}
@ -987,11 +988,11 @@ class MySpace {
} else {
$addedto = ' ';
}
if ($user['added_at_session'] == 1) {
$addedto .= ' '.get_lang('UserInSession');
}
$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
} else {
$addedto = get_lang('UserNotAdded');
@ -999,13 +1000,13 @@ class MySpace {
}
}
}
header('Location: course.php?id_session='.$id_session.'&action=show_message&message='.urlencode($registered_users));
exit ();
//header('Location: resume_session.php?id_session='.$id_session);
}
/**
* Reads CSV-file.
* @param string $file Path to the CSV-file
@ -1021,7 +1022,7 @@ class MySpace {
}
return $users;
}
/**
* XML-parser: the handler at the beginning of element.
*/
@ -1037,7 +1038,7 @@ class MySpace {
$current_tag = $data;
}
}
/**
* XML-parser: the handler at the end of element.
*/
@ -1058,7 +1059,7 @@ class MySpace {
break;
}
}
/**
* XML-parser: the handler for character data.
*/
@ -1067,7 +1068,7 @@ class MySpace {
global $current_value;
$current_value = $data;
}
/**
* Reads XML-file.
* @param string $file Path to the XML-file

@ -11,6 +11,7 @@ $language_file = array ('registration', 'index', 'trad4all', 'tracking', 'admin'
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
@ -75,18 +76,18 @@ if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
} else {
$id_coach = $_user['user_id'];
}
if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
$a_sessions = SessionManager::get_sessions_followed_by_drh($_user['user_id']);
if (!api_is_session_admin()) {
$menu_items[] = '<a href="index.php?view=drh_students&amp;display=yourstudents">'.get_lang('Students').'</a>';
$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
}
}
$menu_items[] = get_lang('Sessions');
echo '<div class="actions-title" style ="font-size:10pt;">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
@ -96,20 +97,20 @@ if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
echo '&nbsp;|&nbsp;';
}
}
}
}
if (count($a_sessions) > 0) {
echo '&nbsp;&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';
echo '<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
echo '<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
}
echo '</div>';
echo '<h4>'.get_lang('YourSessionsList').'</h4>';
} else {
} else {
/*if (api_is_platform_admin()) {
$a_sessions = SessionManager::get_sessions_list();
} else {*/
$a_sessions = Tracking :: get_sessions_coached_by_user($id_coach);
//}
//}
}
$nb_sessions = count($a_sessions);
@ -119,7 +120,7 @@ if ($export_csv) {
}
if ($nb_sessions > 0) {
if (!api_is_drh()) {
echo '<div align="right">
<a href="javascript: void(0);" onclick="javascript: window.print();"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
@ -143,7 +144,7 @@ if ($nb_sessions > 0) {
} else {
$row[] = ' - ';
}
$row[] = count(Tracking::get_courses_list_from_session($session['id']));
if ($export_csv) {

@ -9,6 +9,7 @@ $language_file = array ('registration', 'index', 'tracking', 'admin');
$cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'tracking.lib.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
@ -102,7 +103,7 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
$is_western_name_order = api_is_western_name_order();
}
$sort_by_first_name = api_sort_by_first_name();
if (api_is_drh() || $_GET['display'] == 'yourstudents') {
$title = get_lang('YourStudents');
@ -112,7 +113,7 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
$user_id = intval($_GET['user_id']);
$user_info = api_get_user_info($user_id);
$title = api_get_person_name($user_info['firstname'], $user_info['lastname']).' : '.get_lang('Students');
$courses_by_teacher = CourseManager::get_course_list_of_user_as_course_admin($user_id);
$courses_by_teacher = CourseManager::get_course_list_of_user_as_course_admin($user_id);
$students_by_course = array();
if (!empty($courses_by_teacher)) {
foreach ($courses_by_teacher as $course) {
@ -124,22 +125,22 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
}
}
}
$students = array_unique($students);
$students = array_unique($students);
} else {
$students = array_keys(UserManager::get_users_followed_by_drh($_user['user_id'], STUDENT));
}
$courses_of_the_platform = CourseManager :: get_real_course_list();
$courses_of_the_platform = CourseManager :: get_real_course_list();
foreach ($courses_of_the_platform as $course) {
$courses[$course['code']] = $course['code'];
}
}
$menu_items[] = '<a href="index.php?view=drh_students">'.get_lang('Students').'</a>';
$menu_items[] = '<a href="teachers.php">'.get_lang('Trainers').'</a>';
$menu_items[] = '<a href="course.php">'.get_lang('Courses').'</a>';
$menu_items[] = '<a href="session.php">'.get_lang('Sessions').'</a>';
echo '<div class="actions-title" style ="font-size:10pt;">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {
@ -149,16 +150,16 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
echo '&nbsp;|&nbsp;';
}
}
}
}
if (count($students) > 0) {
echo '&nbsp;&nbsp;<a href="javascript: void(0);" onclick="javascript: window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a> ';
echo '<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
echo '<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>';
}
echo '</div>';
echo '<h4>'.$title.'</h4>';
} else {
echo '<div align="left" style="float:left"><h4>'.$title.'</h4></div>
<div align="right">
@ -166,7 +167,7 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
<a href="'.api_get_self().'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
</div><div class="clear"></div>';
}
if (isset($_GET['id_coach'])) {
$coach_id = intval($_GET['id_coach']);
} else {
@ -177,7 +178,7 @@ if ($isCoach || api_is_platform_admin() || api_is_drh()) {
if ($isCoach) {
$courses = Tracking :: get_courses_followed_by_coach($coach_id);
$students = Tracking :: get_student_followed_by_coach($coach_id);
}
}
} else {
$students = Tracking :: get_student_followed_by_coach_in_a_session($_GET['id_session'], $coach_id);
}

@ -7,10 +7,11 @@
* @author: Diego Escalante Urrelo <diegoe@gmail.com>
* @author: Marco Antonio Villegas Vega <marvil07@gmail.com>
*/
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require api_get_path(LIBRARY_PATH).'search/search_widget.php';
require api_get_path(LIBRARY_PATH).'search/DokeosQuery.php';
require_once api_get_path(LIBRARY_PATH).'search/IndexableChunk.class.php';
require_once api_get_path(LIBRARY_PATH).'/specific_fields_manager.lib.php';
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
$htmlHeadXtra[] = '<link rel="stylesheet" type="text/css" href="'. api_get_path(WEB_PATH) .'main/newscorm/lp_list_search.css" />';
event_access_tool(TOOL_SEARCH);

@ -28,18 +28,21 @@
Category-manager (add, edit & delete)
---------------------------------------------------------------------
*/
require_once('rsys.php');
require_once 'rsys.php';
// TODO: The global initialization scripts loads once again here. To be checked.
$language_file = 'admin';
$cidReset = true;
require ('../inc/global.inc.php');
require '../inc/global.inc.php';
//
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
Rsys :: protect_script('m_category');
$tool_name = get_lang('BookingSystem');
$interbreadcrumb[] = array ("url" => "../admin/index.php", "name" => get_lang('PlatformAdmin'));
$interbreadcrumb[] = array ('url' => '../admin/index.php', 'name' => get_lang('PlatformAdmin'));
/**
---------------------------------------------------------------------

@ -1769,9 +1769,10 @@ class Rsys {
}
$language_file = 'reservation';
$cidReset = true;
require_once ('../inc/global.inc.php');
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
Rsys :: init();
require_once 'rcalendar.php';
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
?>

@ -31,7 +31,8 @@
*/
$config['survey']['debug'] = false;
//require_once '../inc/global.inc.php';
require_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>'; //jQuery
$htmlHeadXtra[] = '<script type="text/javascript" language="javascript">

@ -28,15 +28,16 @@
// name of the language file that needs to be included
$language_file = 'survey';
// including the global dokeos file
require ('../inc/global.inc.php');
// including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
require_once('survey.lib.php');
require_once (api_get_path(LIBRARY_PATH)."course.lib.php");
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
require_once (api_get_path(LIBRARY_PATH)."mail.lib.inc.php");
// Including the global initialization file
require '../inc/global.inc.php';
// Including additional libraries
//require_once (api_get_path(LIBRARY_PATH).'survey.lib.php');
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once 'survey.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
if (!api_is_allowed_to_edit(false,true))

@ -40,16 +40,17 @@ if (!isset ($_GET['cidReq'])){
}
// including the global dokeos file
require_once '../inc/global.inc.php';
$this_section=SECTION_COURSES;
$this_section = SECTION_COURSES;
// including additional libraries
//require_once (api_get_path(LIBRARY_PATH)."/survey.lib.php");
require_once('survey.lib.php');
require_once (api_get_path(LIBRARY_PATH)."/course.lib.php");
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
//require_once api_get_path(LIBRARY_PATH).'survey.lib.php';
require_once 'survey.lib.php';
require_once api_get_path(LIBRARY_PATH).'course.lib.php';
//Tracking
event_access_tool(TOOL_SURVEY);
/** @todo this has to be moved to a more appropriate place (after the display_header of the code)*/
if (!api_is_allowed_to_edit(false,true)) //coach can see this
{

@ -21,7 +21,7 @@ $language_file[] = 'admin';
$language_file[] = 'tracking';
$language_file[] = 'scorm';
//$cidReset = true; //TODO: delete this line bug 457
// including the global Dokeos file
// including the global initialization file
require_once '../inc/global.inc.php';
// the section (for the tabs)
@ -42,8 +42,9 @@ if (!$is_allowedToTrack && !api_is_session_admin()) {
api_not_allowed();
Display :: display_footer();
exit;
}
// including additional libraries
// Including additional libraries
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathItem.class.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
@ -62,7 +63,7 @@ $export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$session_id = intval($_REQUEST['id_session']);
if ($export_csv) {
if (!empty($session_id)) {
if (!empty($session_id)) {
$_SESSION['id_session'] = $session_id;
}
ob_start();
@ -125,10 +126,10 @@ Display::display_header($nameTools, 'Tracking');
// getting all the students of the course
if (!empty($_SESSION['id_session'])) {
// registered students in session
$a_students = CourseManager :: get_student_list_from_course_code($_course['id'], true, $_SESSION['id_session']);
$a_students = CourseManager :: get_student_list_from_course_code($_course['id'], true, $_SESSION['id_session']);
} else {
// registered students in a course outside session
$a_students = CourseManager :: get_student_list_from_course_code($_course['id']);
$a_students = CourseManager :: get_student_list_from_course_code($_course['id']);
}
$nbStudents = count($a_students);
@ -176,7 +177,7 @@ echo '</div>';
if ($_GET['studentlist'] == 'false') {
$course_code = api_get_course_id();
echo'<br /><br />';
// learning path tracking
@ -248,8 +249,8 @@ if ($_GET['studentlist'] == 'false') {
while ($quiz = Database::fetch_array($rs)) {
$quiz_avg_score = 0;
if ($count_students > 0) {
foreach ($student_ids as $student_id) {
$avg_student_score = Tracking::get_avg_student_exercise_score($student_id, $course_code, $quiz['id'], $session_id);
foreach ($student_ids as $student_id) {
$avg_student_score = Tracking::get_avg_student_exercise_score($student_id, $course_code, $quiz['id'], $session_id);
$quiz_avg_score += $avg_student_score;
}
}
@ -309,7 +310,7 @@ if ($_GET['studentlist'] == 'false') {
echo '<div class="report_section">
<h4>'.Display::return_icon('acces_tool.gif', get_lang('ToolsMostUsed')).get_lang('ToolsMostUsed').'</h4>
<table class="data_table">';
$tools_most_used = Tracking::get_tools_most_used_by_course($course_code, $session_id);
if ($export_csv) {
@ -466,13 +467,13 @@ if ($_GET['studentlist'] == 'false') {
$all_datas = array();
$course_code = $_course['id'];
$user_ids = array_keys($a_students);
$table = new SortableTable('users_tracking', array('TrackingCourseLog','get_number_of_users'), array('TrackingCourseLog','get_user_data'), (api_is_western_name_order() xor api_sort_by_first_name()) ? 3 : 2);
$parameters['cidReq'] = Security::remove_XSS($_GET['cidReq']);

@ -1,5 +1,6 @@
<?php
require_once(api_get_path(LIBRARY_PATH).'export.lib.inc.php');
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
class TestSortableTable extends UnitTestCase {

Loading…
Cancel
Save