@ -102,10 +102,12 @@ class MySpace
$courseId = intval($courseId);
$courseId = intval($courseId);
$session_id = intval($session_id);
$session_id = intval($session_id);
$sql = 'SELECT login_course_date, logout_course_date FROM ' . $tbl_track_course . '
$sql = 'SELECT login_course_date, logout_course_date
WHERE user_id = '.$user_id.' AND
FROM ' . $tbl_track_course . '
c_id = '.$courseId.' AND
WHERE
session_id = '.$session_id.'
user_id = '.$user_id.' AND
c_id = '.$courseId.' AND
session_id = '.$session_id.'
ORDER BY login_course_date ASC';
ORDER BY login_course_date ASC';
$rs = Database::query($sql);
$rs = Database::query($sql);
$connections = array();
$connections = array();
@ -115,6 +117,7 @@ class MySpace
$timestamp_logout_date = api_strtotime($row['logout_course_date'], 'UTC');
$timestamp_logout_date = api_strtotime($row['logout_course_date'], 'UTC');
$connections[] = array('login' => $timestamp_login_date, 'logout' => $timestamp_logout_date);
$connections[] = array('login' => $timestamp_login_date, 'logout' => $timestamp_logout_date);
}
}
return $connections;
return $connections;
}
}
@ -312,7 +315,12 @@ class MySpace
} else {
} else {
$order = array(0 => 'lastname', 1 => 'firstname', 2 => ($sort_by_first_name ? 'firstname' : 'lastname'), 3 => 'login_date', 4 => ($sort_by_first_name ? 'firstname' : 'lastname'), 5 => ($sort_by_first_name ? 'firstname' : 'lastname'));
$order = array(0 => 'lastname', 1 => 'firstname', 2 => ($sort_by_first_name ? 'firstname' : 'lastname'), 3 => 'login_date', 4 => ($sort_by_first_name ? 'firstname' : 'lastname'), 5 => ($sort_by_first_name ? 'firstname' : 'lastname'));
}
}
$table = new SortableTable('tracking_list_coaches_myspace', array('MySpace', 'count_coaches'), null, ($is_western_name_order xor $sort_by_first_name) ? 1 : 0);
$table = new SortableTable(
'tracking_list_coaches_myspace',
array('MySpace', 'count_coaches'),
null,
($is_western_name_order xor $sort_by_first_name) ? 1 : 0
);
$parameters['view'] = 'admin';
$parameters['view'] = 'admin';
$table->set_additional_parameters($parameters);
$table->set_additional_parameters($parameters);
if ($is_western_name_order) {
if ($is_western_name_order) {
@ -532,8 +540,7 @@ class MySpace
$lessons = LearnpathList::get_course_lessons($course['code'], $sessionId);
$lessons = LearnpathList::get_course_lessons($course['code'], $sessionId);
//create columns array
//create columns array
foreach ($lessons as $lesson_id => $lesson)
foreach ($lessons as $lesson_id => $lesson) {
{
$columns[] = $lesson['name'];
$columns[] = $lesson['name'];
}
}
@ -543,17 +550,43 @@ class MySpace
* Column config
* Column config
*/
*/
$column_model = array(
$column_model = array(
array('name'=>'username', 'index'=>'username', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
array(
array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left', 'search' => 'true'),
'name' => 'username',
array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left', 'search' => 'true'),
'index' => 'username',
'align' => 'left',
'search' => 'true',
'wrap_cell' => "true",
),
array(
'name' => 'firstname',
'index' => 'firstname',
'align' => 'left',
'search' => 'true',
),
array(
'name' => 'lastname',
'index' => 'lastname',
'align' => 'left',
'search' => 'true',
),
);
);
//get dinamic column names
foreach ($lessons as $lesson_id => $lesson)
// Get dinamic column names
{
foreach ($lessons as $lesson_id => $lesson) {
$column_model[] = array('name'=> $lesson['id'], 'index'=>$lesson['id'], 'align'=>'left', 'search' => 'true');
$column_model[] = array(
'name' => $lesson['id'],
'index' => $lesson['id'],
'align' => 'left',
'search' => 'true',
);
}
}
$column_model[] = array('name'=>'total', 'index'=>'total', 'align'=>'left', 'search' => 'true');
$column_model[] = array(
'name' => 'total',
'index' => 'total',
'align' => 'left',
'search' => 'true',
);
$action_links = '';
$action_links = '';
// jqgrid will use this URL to do the selects
// jqgrid will use this URL to do the selects
@ -568,7 +601,16 @@ class MySpace
//height auto
//height auto
$extra_params['height'] = 'auto';
$extra_params['height'] = 'auto';
$table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), $action_links, true);
$table = Display::grid_js(
$tableId,
$url,
$columns,
$column_model,
$extra_params,
array(),
$action_links,
true
);
$return = '< script > $ ( f u n c t i o n ( ) { ' . $ t a b l e .
$return = '< script > $ ( f u n c t i o n ( ) { ' . $ t a b l e .
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
@ -757,10 +799,10 @@ class MySpace
// jqgrid will use this URL to do the selects
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_exercise_grade& session_id=' . $sessionId . '& course_id=' . $courseId;
$url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_exercise_grade& session_id=' . $sessionId . '& course_id=' . $courseId;
//Autowidth
// Autowidth
$extra_params['autowidth'] = 'true';
$extra_params['autowidth'] = 'true';
//height auto
// height auto
$extra_params['height'] = 'auto';
$extra_params['height'] = 'auto';
$tableId = 'exerciseGradeOverview';
$tableId = 'exerciseGradeOverview';
@ -826,16 +868,25 @@ class MySpace
// jqgrid will use this URL to do the selects
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_survey_overview& session_id=' . $sessionId . '& course_id=' . $courseId . '& survey_id=' . $surveyId . '& date_to=' . $date_to . '& date_from=' . $date_from;
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_survey_overview& session_id=' . $sessionId . '& course_id=' . $courseId . '& survey_id=' . $surveyId . '& date_to=' . $date_to . '& date_from=' . $date_from;
//Table Id
// Table Id
$tableId = 'lpProgress';
$tableId = 'lpProgress';
//Autowidth
//Autowidth
$extra_params['autowidth'] = 'true';
$extra_params['autowidth'] = 'true';
//height auto
// height auto
$extra_params['height'] = 'auto';
$extra_params['height'] = 'auto';
$table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), $action_links, true);
$table = Display::grid_js(
$tableId,
$url,
$columns,
$column_model,
$extra_params,
array(),
$action_links,
true
);
$return = '< script > $ ( f u n c t i o n ( ) { ' . $ t a b l e .
$return = '< script > $ ( f u n c t i o n ( ) { ' . $ t a b l e .
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
@ -961,52 +1012,58 @@ class MySpace
//Autowidth
//Autowidth
$extra_params['autowidth'] = 'true';
$extra_params['autowidth'] = 'true';
$extra_params['shrinkToFit'] = 'true';
$extra_params['shrinkToFit'] = 'true';
$extra_params['headertitles'] = 'true';
$extra_params['headertitles'] = 'true';
$extra_params['groupHeaders'] = array(
$extra_params['groupHeaders'] = array(
'courses_detail' => array(
'courses_detail' => array(
"startColumnName" => 'courses',
"startColumnName" => 'courses',
"numberOfColumns" => 7,
"numberOfColumns" => 7,
"titleText" => get_lang('Global'),
"titleText" => get_lang('Global'),
),
),
'lessons' => array(
'lessons' => array(
"startColumnName" => 'lessons_total',
"startColumnName" => 'lessons_total',
"numberOfColumns" => 4,
"numberOfColumns" => 4,
"titleText" => get_lang('LearningPaths'),
"titleText" => get_lang('LearningPaths'),
),
),
'exercises' => array(
'exercises' => array(
"startColumnName" => 'exercises_total',
"startColumnName" => 'exercises_total',
"numberOfColumns" => 4,
"numberOfColumns" => 4,
"titleText" => get_lang('Exercises'),
"titleText" => get_lang('Exercises'),
),
),
'forums' => array(
'forums' => array(
"startColumnName" => 'forums_total',
"startColumnName" => 'forums_total',
"numberOfColumns" => 4,
"numberOfColumns" => 4,
"titleText" => get_lang('Forums'),
"titleText" => get_lang('Forums'),
),
),
'assignments' => array(
'assignments' => array(
"startColumnName" => 'assigments_total',
"startColumnName" => 'assigments_total',
"numberOfColumns" => 4,
"numberOfColumns" => 4,
"titleText" => get_lang('Assignments'),
"titleText" => get_lang('Assignments'),
),
),
'wikis' => array(
'wikis' => array(
"startColumnName" => 'wiki_total',
"startColumnName" => 'wiki_total',
"numberOfColumns" => 5,
"numberOfColumns" => 5,
"titleText" => get_lang('Wiki'),
"titleText" => get_lang('Wiki'),
),
),
'surveys' => array(
'surveys' => array(
"startColumnName" => 'surveys_total',
"startColumnName" => 'surveys_total',
"numberOfColumns" => 4,
"numberOfColumns" => 4,
"titleText" => get_lang('Survey'),
"titleText" => get_lang('Survey'),
),
),
);
);
//height auto
//height auto
$extra_params['height'] = 'auto';
$extra_params['height'] = 'auto';
$table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), $action_links, true);
$table = Display::grid_js(
$tableId,
$url,
$columns,
$column_model,
$extra_params,
array(),
$action_links,
true
);
$return = '< script > $ ( f u n c t i o n ( ) { ' . $ t a b l e .
$return = '< script > $ ( f u n c t i o n ( ) { ' . $ t a b l e .
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
@ -1091,13 +1148,18 @@ class MySpace
*/
*/
public static function display_user_overview_export_options()
public static function display_user_overview_export_options()
{
{
$message = '';
// include the user manager and formvalidator library
// include the user manager and formvalidator library
if (isset($_GET['export']) & & $_GET['export'] == 'options') {
if (isset($_GET['export']) & & $_GET['export'] == 'options') {
// get all the defined extra fields
// get all the defined extra fields
$extrafields = UserManager::get_extra_fields(0, 50, 5, 'ASC', false, 1);
$extrafields = UserManager::get_extra_fields(0, 50, 5, 'ASC', false, 1);
// creating the form with all the defined extra fields
// 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']));
$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) {
if (is_array($extrafields) & & count($extrafields) > 0) {
foreach ($extrafields as $key => $extra) {
foreach ($extrafields as $key => $extra) {
@ -1144,7 +1206,6 @@ class MySpace
} else {
} else {
Display::display_confirmation_message(get_lang('NoAdditionalFieldsWillBeExported'), false);
Display::display_confirmation_message(get_lang('NoAdditionalFieldsWillBeExported'), false);
}
}
$message = '';
} else {
} else {
$form->display();
$form->display();
}
}
@ -1159,7 +1220,6 @@ class MySpace
}
}
Display::display_normal_message(get_lang('FollowingFieldsWillAlsoBeExported').': < br / > < ul > '.$message.'< / ul > ', false);
Display::display_normal_message(get_lang('FollowingFieldsWillAlsoBeExported').': < br / > < ul > '.$message.'< / ul > ', false);
$message = '';
}
}
}
}
}
}
@ -1167,9 +1227,8 @@ class MySpace
/**
/**
* Display a sortable table that contains an overview of all the reporting progress of all courses
* Display a sortable table that contains an overview of all the reporting progress of all courses
*/
*/
public static function display_tracking_course_overview() {
public static function display_tracking_course_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 = ' < table style = "width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed" > ';
//$t_head .= ' < caption > '.get_lang('CourseInformation').'< / caption > ';
//$t_head .= ' < caption > '.get_lang('CourseInformation').'< / caption > ';
$t_head .= '< tr > ';
$t_head .= '< tr > ';
@ -1208,6 +1267,7 @@ class MySpace
{
{
// database table definition
// database table definition
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
return Database::count_rows($main_course_table);
return Database::count_rows($main_course_table);
}
}
@ -1503,8 +1563,6 @@ class MySpace
*/
*/
public static function display_tracking_session_overview()
public static function display_tracking_session_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 = ' < table style = "width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed" > ';
//$t_head .= ' < caption > '.get_lang('CourseInformation').'< / caption > ';
//$t_head .= ' < caption > '.get_lang('CourseInformation').'< / caption > ';
$t_head .= '< tr > ';
$t_head .= '< tr > ';
@ -1558,22 +1616,8 @@ class MySpace
*/
*/
public static function get_session_data_tracking_overview($from, $number_of_items, $column, $direction)
public static function get_session_data_tracking_overview($from, $number_of_items, $column, $direction)
{
{
//global $_configuration;
// database table definition
//$access_url_id = api_get_current_access_url_id();
//$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$main_session_table = Database :: get_main_table(TABLE_MAIN_SESSION);
$main_session_table = Database :: get_main_table(TABLE_MAIN_SESSION);
/*if ($_configuration['multiple_access_urls']) {
$condition_multi_url = ", $tbl_url_rel_user as url_user WHERE user.user_id=url_user.user_id AND access_url_id='$access_url_id'";
}
global $export_csv;
if ($export_csv) {
$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
} else {
$is_western_name_order = api_is_western_name_order();
}*/
$sql = "SELECT id AS col0, name AS col1 FROM $main_session_table";
$sql = "SELECT id AS col0, name AS col1 FROM $main_session_table";
$sql .= " ORDER BY col$column $direction ";
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$sql .= " LIMIT $from,$number_of_items";
@ -2246,10 +2290,10 @@ class MySpace
lastname AS col1,
lastname AS col1,
firstname AS col2,
firstname AS col2,
").
").
"username AS col3,
"username AS col3,
user.user_id AS col4
user.user_id AS col4
FROM
FROM
$main_user_table as user $condition_multi_url
$main_user_table as user $condition_multi_url
";
";
$sql .= " ORDER BY col$column $direction ";
$sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items";
$sql .= " LIMIT $from,$number_of_items";
@ -2288,8 +2332,6 @@ class MySpace
*/
*/
public static function make_username($firstname, $lastname, $username, $language = null, $encoding = null)
public static function make_username($firstname, $lastname, $username, $language = null, $encoding = null)
{
{
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
// if username exist
// if username exist
if (!UserManager::is_username_available($username) || empty($username)) {
if (!UserManager::is_username_available($username) || empty($username)) {
$i = 0;
$i = 0;
@ -2299,7 +2341,12 @@ class MySpace
} else {
} else {
$sufix = $i;
$sufix = $i;
}
}
$desired_username = UserManager::create_username($firstname, $lastname, $language, $encoding);
$desired_username = UserManager::create_username(
$firstname,
$lastname,
$language,
$encoding
);
if (UserManager::is_username_available($desired_username.$sufix)) {
if (UserManager::is_username_available($desired_username.$sufix)) {
break;
break;
} else {
} else {
@ -2434,7 +2481,6 @@ class MySpace
foreach ($users as $index => $user) {
foreach ($users as $index => $user) {
// database table definition
// database table definition
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$username = Database::escape_string($user['UserName']);
$username = Database::escape_string($user['UserName']);
$sql = "SELECT creator_id FROM $table_user WHERE username='$username' ";
$sql = "SELECT creator_id FROM $table_user WHERE username='$username' ";
@ -2456,9 +2502,9 @@ class MySpace
* Validates imported data.
* Validates imported data.
* @param list of users
* @param list of users
*/
*/
function validate_data($users, $id_session = null) {
function validate_data($users, $id_session = null)
{
$errors = array();
$errors = array();
$usernames = array();
$new_users = array();
$new_users = array();
foreach ($users as $index => $user) {
foreach ($users as $index => $user) {
// 1. Check whether mandatory fields are set.
// 1. Check whether mandatory fields are set.
@ -2634,9 +2680,7 @@ class MySpace
} else {
} else {
$i = 0;
$i = 0;
foreach ($users as $index => $user) {
foreach ($users as $index => $user) {
$userInfo = api_get_user_info($user['id']);
$userInfo = api_get_user_info($user['id']);
if (($user['added_at_platform'] == 1 & & $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
if (($user['added_at_platform'] == 1 & & $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
if ($user['added_at_platform'] == 1) {
if ($user['added_at_platform'] == 1) {
$addedto = get_lang('UserCreatedPlatform');
$addedto = get_lang('UserCreatedPlatform');
@ -2782,6 +2826,7 @@ function get_stats($user_id, $courseId, $start_date = null, $end_date = null)
$result = array('avg' => $foo_avg, 'total' => $foo_total, 'times' => $foo_times);
$result = array('avg' => $foo_avg, 'total' => $foo_total, 'times' => $foo_times);
}
}
}
}
return $result;
return $result;
}
}
@ -2806,7 +2851,7 @@ function add_day_to($end_date) {
function get_connections_to_course_by_date($user_id, $courseId, $start_date, $end_date)
function get_connections_to_course_by_date($user_id, $courseId, $start_date, $end_date)
{
{
// Database table definitions
// Database table definitions
$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$tbl_track_course = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$course_info = api_get_course_info_by_id($courseId);
$course_info = api_get_course_info_by_id($courseId);
$user_id = intval($user_id);
$user_id = intval($user_id);
$courseId = intval($courseId);
$courseId = intval($courseId);
@ -2817,10 +2862,10 @@ function get_connections_to_course_by_date($user_id, $courseId, $start_date, $en
$sql = "SELECT login_course_date, logout_course_date
$sql = "SELECT login_course_date, logout_course_date
FROM $tbl_track_course
FROM $tbl_track_course
WHERE
WHERE
user_id = $user_id AND
user_id = $user_id AND
c_id = $courseId AND
c_id = $courseId AND
login_course_date BETWEEN '$start_date' AND '$end_date' AND
login_course_date BETWEEN '$start_date' AND '$end_date' AND
logout_course_date BETWEEN '$start_date' AND '$end_date'
logout_course_date BETWEEN '$start_date' AND '$end_date'
ORDER BY login_course_date ASC";
ORDER BY login_course_date ASC";
$rs = Database::query($sql);
$rs = Database::query($sql);
@ -2947,7 +2992,6 @@ function grapher($sql_result, $start_date, $end_date, $type = "")
$myData->setAxisName(0, get_lang('Minutes'));
$myData->setAxisName(0, get_lang('Minutes'));
$myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
$myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
// Cache definition
// Cache definition
$cachePath = api_get_path(SYS_ARCHIVE_PATH);
$cachePath = api_get_path(SYS_ARCHIVE_PATH);
$myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));
$myCache = new pCache(array('CacheFolder' => substr($cachePath, 0, strlen($cachePath) - 1)));