Minor - format code

remotes/angel/1.11.x
jmontoyaa 8 years ago
parent 1451a902b8
commit 3d5e047978
  1. 222
      main/admin/user_edit.php
  2. 267
      main/admin/user_export.php
  3. 287
      main/exercise/export/qti2/qti2_classes.php
  4. 88
      main/inc/lib/dashboard.lib.php
  5. 14
      main/inc/lib/fileUpload.lib.php
  6. 62
      main/inc/lib/usergroup.lib.php
  7. 19
      main/lp/aicc.class.php
  8. 255
      main/tracking/course_session_report.php

@ -2,8 +2,9 @@
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -12,11 +13,8 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(true);
$user_id = isset($_GET['user_id']) ? intval($_GET['user_id']) : intval($_POST['user_id']);
api_protect_super_admin($user_id, null, true);
$is_platform_admin = api_is_platform_admin() ? 1 : 0;
$userInfo = api_get_user_info($user_id);
$htmlHeadXtra[] = '
@ -24,39 +22,39 @@ $htmlHeadXtra[] = '
var is_platform_id = "'.$is_platform_admin.'";
function enable_expiration_date() {
document.user_edit.radio_expiration_date[0].checked=false;
document.user_edit.radio_expiration_date[1].checked=true;
document.user_edit.radio_expiration_date[0].checked=false;
document.user_edit.radio_expiration_date[1].checked=true;
}
function password_switch_radio_button(){
var input_elements = document.getElementsByTagName("input");
for (var i = 0; i < input_elements.length; i++) {
if(input_elements.item(i).name == "reset_password" && input_elements.item(i).value == "2") {
input_elements.item(i).checked = true;
}
}
var input_elements = document.getElementsByTagName("input");
for (var i = 0; i < input_elements.length; i++) {
if(input_elements.item(i).name == "reset_password" && input_elements.item(i).value == "2") {
input_elements.item(i).checked = true;
}
}
}
function display_drh_list(){
var $radios = $("input:radio[name=platform_admin]");
if (document.getElementById("status_select").value=='.COURSEMANAGER.') {
if (document.getElementById("status_select").value=='.COURSEMANAGER.') {
if (is_platform_id == 1)
document.getElementById("id_platform_admin").style.display="block";
} else if (document.getElementById("status_select").value=='.STUDENT.') {
} else if (document.getElementById("status_select").value=='.STUDENT.') {
if (is_platform_id == 1)
document.getElementById("id_platform_admin").style.display="none";
$radios.filter("[value=0]").attr("checked", true);
} else {
} else {
if (is_platform_id == 1)
document.getElementById("id_platform_admin").style.display="none";
$radios.filter("[value=0]").attr("checked", true);
}
}
}
function show_image(image,width,height) {
width = parseInt(width) + 20;
height = parseInt(height) + 20;
window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \' , resizable=0\');
width = parseInt(width) + 20;
height = parseInt(height) + 20;
window_x = window.open(image,\'windowX\',\'width=\'+ width + \', height=\'+ height + \' , resizable=0\');
}
function confirmation(name) {
@ -72,8 +70,8 @@ $gMapsPlugin = GoogleMapsPlugin::create();
$geolocalization = $gMapsPlugin->get('enable_api') === 'true';
if ($geolocalization) {
$gmapsApiKey = $gMapsPlugin->get('api_key');
$htmlHeadXtra[] = '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true&key='.$gmapsApiKey.'" ></script>';
$gmapsApiKey = $gMapsPlugin->get('api_key');
$htmlHeadXtra[] = '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true&key='.$gmapsApiKey.'" ></script>';
}
$htmlHeadXtra[] = api_get_css_asset('cropper/dist/cropper.min.css');
@ -117,27 +115,27 @@ $form->addElement('header', $tool_name);
$form->addElement('hidden', 'user_id', $user_id);
if (api_is_western_name_order()) {
// Firstname
$form->addElement('text', 'firstname', get_lang('FirstName'));
$form->applyFilter('firstname', 'html_filter');
$form->applyFilter('firstname', 'trim');
$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
// Lastname
$form->addElement('text', 'lastname', get_lang('LastName'));
$form->applyFilter('lastname', 'html_filter');
$form->applyFilter('lastname', 'trim');
$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
// Firstname
$form->addElement('text', 'firstname', get_lang('FirstName'));
$form->applyFilter('firstname', 'html_filter');
$form->applyFilter('firstname', 'trim');
$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
// Lastname
$form->addElement('text', 'lastname', get_lang('LastName'));
$form->applyFilter('lastname', 'html_filter');
$form->applyFilter('lastname', 'trim');
$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
} else {
// Lastname
$form->addElement('text', 'lastname', get_lang('LastName'));
$form->applyFilter('lastname', 'html_filter');
$form->applyFilter('lastname', 'trim');
$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
// Firstname
$form->addElement('text', 'firstname', get_lang('FirstName'));
$form->applyFilter('firstname', 'html_filter');
$form->applyFilter('firstname', 'trim');
$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
// Lastname
$form->addElement('text', 'lastname', get_lang('LastName'));
$form->applyFilter('lastname', 'html_filter');
$form->applyFilter('lastname', 'trim');
$form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required');
// Firstname
$form->addElement('text', 'firstname', get_lang('FirstName'));
$form->applyFilter('firstname', 'html_filter');
$form->applyFilter('firstname', 'trim');
$form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required');
}
// Official code
@ -159,7 +157,7 @@ if (api_get_setting('login_is_email') == 'true') {
// OpenID
if (api_get_setting('openid_authentication') == 'true') {
$form->addElement('text', 'openid', get_lang('OpenIDURL'));
$form->addElement('text', 'openid', get_lang('OpenIDURL'));
}
// Phone
@ -174,18 +172,18 @@ $form->addFile(
$allowed_picture_types = api_get_supported_image_extensions(false);
$form->addRule(
'picture',
get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')',
'filetype',
$allowed_picture_types
'picture',
get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')',
'filetype',
$allowed_picture_types
);
if (strlen($user_data['picture_uri']) > 0) {
$form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
$form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage'));
}
// Username
if (api_get_setting('login_is_email') != 'true') {
$form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH));
$form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH));
$form->addRule('username', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string) USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH);
$form->addRule('username', get_lang('OnlyLettersAndNumbersAllowed'), 'username');
@ -259,15 +257,15 @@ $display = isset($user_data['status']) && ($user_data['status'] == STUDENT || (i
// Platform admin
if (api_is_platform_admin()) {
$group = array();
$group[] = $form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'platform_admin', null, get_lang('No'), 0);
$group = array();
$group[] = $form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1);
$group[] = $form->createElement('radio', 'platform_admin', null, get_lang('No'), 0);
$user_data['status'] == 1 ? $display = 'block' : $display = 'none';
$user_data['status'] == 1 ? $display = 'block' : $display = 'none';
$form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">');
$form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false);
$form->addElement('html', '</div>');
$form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">');
$form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false);
$form->addElement('html', '</div>');
}
//Language
@ -285,16 +283,16 @@ $date = sprintf(get_lang('CreatedByXYOnZ'), 'user_information.php?user_id='.$use
$form->addElement('label', get_lang('RegistrationDate'), $date);
if (!$user_data['platform_admin']) {
// Expiration Date
$form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0);
$group = array();
$group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1);
$group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();'));
$form->addGroup($group, 'max_member_group', null, null, false);
// Active account or inactive account
$form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1);
$form->addElement('radio', 'active', '', get_lang('Inactive'), 0);
// Expiration Date
$form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0);
$group = array();
$group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1);
$group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();'));
$form->addGroup($group, 'max_member_group', null, null, false);
// Active account or inactive account
$form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1);
$form->addElement('radio', 'active', '', get_lang('Inactive'), 0);
}
$studentBossList = UserManager::getStudentBossList($user_data['user_id']);
@ -333,7 +331,7 @@ $jquery_ready_content = $returnParams['jquery_ready_content'];
// the $jquery_ready_content variable collects all functions that will be load in the $(document).ready javascript function
$htmlHeadXtra[] = '<script>
$(document).ready(function(){
'.$jquery_ready_content.'
'.$jquery_ready_content.'
});
</script>';
@ -345,18 +343,18 @@ $user_data['reset_password'] = 0;
$expiration_date = $user_data['expiration_date'];
if (empty($expiration_date)) {
$user_data['radio_expiration_date'] = 0;
$user_data['expiration_date'] = api_get_local_time();
$user_data['radio_expiration_date'] = 0;
$user_data['expiration_date'] = api_get_local_time();
} else {
$user_data['radio_expiration_date'] = 1;
$user_data['expiration_date'] = api_get_local_time($expiration_date);
$user_data['radio_expiration_date'] = 1;
$user_data['expiration_date'] = api_get_local_time($expiration_date);
}
$form->setDefaults($user_data);
$error_drh = false;
// Validate form
if ($form->validate()) {
$user = $form->getSubmitValues(1);
$user = $form->getSubmitValues(1);
$reset_password = intval($user['reset_password']);
if ($reset_password == 2 && empty($user['password'])) {
Display::addFlash(Display::return_message(get_lang('PasswordIsTooShort')));
@ -364,49 +362,49 @@ if ($form->validate()) {
exit();
}
$is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']);
$is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']);
if ($user['status'] == DRH && $is_user_subscribed_in_course) {
$error_drh = true;
} else {
$picture_element = $form->getElement('picture');
$picture = $picture_element->getValue();
if ($user['status'] == DRH && $is_user_subscribed_in_course) {
$error_drh = true;
} else {
$picture_element = $form->getElement('picture');
$picture = $picture_element->getValue();
$picture_uri = $user_data['picture_uri'];
if (isset($user['delete_picture']) && $user['delete_picture']) {
$picture_uri = UserManager::delete_user_picture($user_id);
} elseif (!empty($picture['name'])) {
$picture_uri = $user_data['picture_uri'];
if (isset($user['delete_picture']) && $user['delete_picture']) {
$picture_uri = UserManager::delete_user_picture($user_id);
} elseif (!empty($picture['name'])) {
$picture_uri = UserManager::update_user_picture(
$user_id,
$_FILES['picture']['name'],
$_FILES['picture']['tmp_name'],
$user['picture_crop_result']
);
}
}
$lastname = $user['lastname'];
$firstname = $user['firstname'];
$lastname = $user['lastname'];
$firstname = $user['firstname'];
$password = $user['password'];
$auth_source = isset($user['auth_source']) ? $user['auth_source'] : $userInfo['auth_source'];
$official_code = $user['official_code'];
$email = $user['email'];
$phone = $user['phone'];
$username = isset($user['username']) ? $user['username'] : $userInfo['username'];
$status = intval($user['status']);
$platform_admin = intval($user['platform_admin']);
$send_mail = intval($user['send_mail']);
$reset_password = intval($user['reset_password']);
$hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null;
$language = $user['language'];
$official_code = $user['official_code'];
$email = $user['email'];
$phone = $user['phone'];
$username = isset($user['username']) ? $user['username'] : $userInfo['username'];
$status = intval($user['status']);
$platform_admin = intval($user['platform_admin']);
$send_mail = intval($user['send_mail']);
$reset_password = intval($user['reset_password']);
$hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null;
$language = $user['language'];
$address = isset($user['address']) ? $user['address'] : null;
if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) {
if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) {
$expiration_date = $user['expiration_date'];
} else {
$expiration_date = null;
}
} else {
$expiration_date = null;
}
$active = $user_data['platform_admin'] ? 1 : intval($user['active']);
$active = $user_data['platform_admin'] ? 1 : intval($user['active']);
//If the user is set to admin the status will be overwrite by COURSEMANAGER = 1
if ($platform_admin == 1) {
@ -445,33 +443,33 @@ if ($form->validate()) {
UserManager::subscribeUserToBossList($user_id, $user['student_boss']);
}
if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) {
$up = UserManager::update_openid($user_id, $user['openid']);
}
if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) {
$up = UserManager::update_openid($user_id, $user['openid']);
}
$currentUserId = api_get_user_id();
$userObj = api_get_user_entity($user_id);
UserManager::add_user_as_admin($userObj);
if ($user_id != $currentUserId) {
if ($platform_admin == 1) {
$userObj = api_get_user_entity($user_id);
if ($user_id != $currentUserId) {
if ($platform_admin == 1) {
$userObj = api_get_user_entity($user_id);
UserManager::add_user_as_admin($userObj);
} else {
} else {
UserManager::remove_user_admin($user_id);
}
}
}
}
$extraFieldValue = new ExtraFieldValue('user');
$extraFieldValue->saveFieldValues($user);
$tok = Security::get_token();
$tok = Security::get_token();
Display::addFlash(Display::return_message(get_lang('UserUpdated')));
header('Location: user_list.php?sec_token='.$tok);
exit();
}
header('Location: user_list.php?sec_token='.$tok);
exit();
}
}
if ($error_drh) {

@ -1,7 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
* @package chamilo.admin
*/
$cidReset = true;
@ -18,15 +19,12 @@ $course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$session_course_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tool_name = get_lang('ExportUserListXMLCSV');
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
set_time_limit(0);
$coursesSessions = [];
$coursesSessions[''] = '--';
$allCoursesFromSessions = SessionManager::getAllCoursesFromAllSessions();
$coursesSessions = array_merge($coursesSessions, $allCoursesFromSessions);
$courses = array();
@ -36,27 +34,26 @@ $sql = "SELECT code,visual_code,title FROM $course_table ORDER BY visual_code";
global $_configuration;
if (api_is_multiple_url_enabled()) {
$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql = "SELECT code,visual_code,title
FROM $course_table as c
INNER JOIN $tbl_course_rel_access_url as course_rel_url
ON (c.id = course_rel_url.c_id)
WHERE access_url_id = $access_url_id
ORDER BY visual_code";
}
$tbl_course_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql = "SELECT code,visual_code,title
FROM $course_table as c
INNER JOIN $tbl_course_rel_access_url as course_rel_url
ON (c.id = course_rel_url.c_id)
WHERE access_url_id = $access_url_id
ORDER BY visual_code";
}
}
$result = Database::query($sql);
while ($course = Database::fetch_object($result)) {
$courses[$course->code] = $course->visual_code.' - '.$course->title;
$courses[$course->code] = $course->visual_code.' - '.$course->title;
}
$form = new FormValidator('export_users');
$form->addElement('header', $tool_name);
$form->addElement('radio', 'file_type', get_lang('OutputFileType'), 'XML', 'xml');
$form->addElement('radio', 'file_type', null, 'CSV', 'csv');
$form->addElement('radio', 'file_type', null, 'XLS', 'xls');
$form->addElement('checkbox', 'addcsvheader', get_lang('AddCSVHeader'), get_lang('YesAddCSVHeader'), '1');
$form->addElement('select', 'course_code', get_lang('OnlyUsersFromCourse'), $courses);
$form->addElement('select', 'course_session', get_lang('OnlyUsersFromCourseSession'), $coursesSessions);
@ -64,19 +61,19 @@ $form->addButtonExport(get_lang('Export'));
$form->setDefaults(array('file_type' => 'csv'));
if ($form->validate()) {
$export = $form->exportValues();
$file_type = $export['file_type'];
$course_code = Database::escape_string($export['course_code']);
$courseInfo = api_get_course_info($course_code);
$export = $form->exportValues();
$file_type = $export['file_type'];
$course_code = Database::escape_string($export['course_code']);
$courseInfo = api_get_course_info($course_code);
$courseId = isset($courseInfo['real_id']) ? $courseInfo['real_id'] : 0;
$courseSessionValue = explode(':', $export['course_session']);
$courseSessionCode = '';
$sessionId = 0;
$courseSessionId = 0;
$sessionInfo = [];
$courseSessionValue = explode(':', $export['course_session']);
$courseSessionCode = '';
$sessionId = 0;
$courseSessionId = 0;
$sessionInfo = [];
if (is_array($courseSessionValue) && isset($courseSessionValue[1])) {
if (is_array($courseSessionValue) && isset($courseSessionValue[1])) {
$courseSessionCode = $courseSessionValue[0];
$sessionId = $courseSessionValue[1];
$courseSessionInfo = api_get_course_info($courseSessionCode);
@ -84,121 +81,121 @@ if ($form->validate()) {
$sessionInfo = api_get_session_info($sessionId);
}
$sql = "SELECT
u.user_id AS UserId,
u.lastname AS LastName,
u.firstname AS FirstName,
u.email AS Email,
u.username AS UserName,
".(($_configuration['password_encryption'] != 'none') ? " " : "u.password AS Password, ")."
u.auth_source AS AuthSource,
u.status AS Status,
u.official_code AS OfficialCode,
u.phone AS Phone,
u.registration_date AS RegistrationDate";
if (strlen($course_code) > 0) {
$sql .= " FROM $user_table u, $course_user_table cu
WHERE
u.user_id = cu.user_id AND
cu.c_id = $courseId AND
cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
ORDER BY lastname,firstname";
$filename = 'export_users_'.$course_code.'_'.api_get_local_time();
} else if (strlen($courseSessionCode) > 0) {
$sql = "SELECT
u.user_id AS UserId,
u.lastname AS LastName,
u.firstname AS FirstName,
u.email AS Email,
u.username AS UserName,
".(($_configuration['password_encryption'] != 'none') ? " " : "u.password AS Password, ")."
u.auth_source AS AuthSource,
u.status AS Status,
u.official_code AS OfficialCode,
u.phone AS Phone,
u.registration_date AS RegistrationDate";
if (strlen($course_code) > 0) {
$sql .= " FROM $user_table u, $course_user_table cu
WHERE
u.user_id = cu.user_id AND
cu.c_id = $courseId AND
cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
ORDER BY lastname,firstname";
$filename = 'export_users_'.$course_code.'_'.api_get_local_time();
} else if (strlen($courseSessionCode) > 0) {
$sql .= " FROM $user_table u, $session_course_user_table scu
WHERE
u.user_id = scu.user_id AND
scu.c_id = $courseSessionId AND
scu.session_id = $sessionId
ORDER BY lastname,firstname";
WHERE
u.user_id = scu.user_id AND
scu.c_id = $courseSessionId AND
scu.session_id = $sessionId
ORDER BY lastname,firstname";
$filename = 'export_users_'.$courseSessionCode.'_'.$sessionInfo['name'].'_'.api_get_local_time();
} else {
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql .= " FROM $user_table u
INNER JOIN $tbl_user_rel_access_url as user_rel_url
ON (u.user_id= user_rel_url.user_id)
WHERE access_url_id = $access_url_id
ORDER BY lastname,firstname";
}
} else {
$sql .= " FROM $user_table u ORDER BY lastname,firstname";
}
$filename = 'export_users_'.api_get_local_time();
}
$data = array();
$extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', false);
if (!empty($export['addcsvheader'])) {
if ($export['addcsvheader'] == '1' && ($export['file_type'] == 'csv' || $export['file_type'] == 'xls')) {
if ($_configuration['password_encryption'] != 'none') {
$data[] = array(
'UserId',
'LastName',
'FirstName',
'Email',
'UserName',
'AuthSource',
'Status',
'OfficialCode',
'PhoneNumber',
'RegistrationDate'
);
} else {
$data[] = array(
'UserId',
'LastName',
'FirstName',
'Email',
'UserName',
'Password',
'AuthSource',
'Status',
'OfficialCode',
'PhoneNumber',
'RegistrationDate'
);
}
foreach ($extra_fields as $extra) {
$data[0][] = $extra[1];
}
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql .= " FROM $user_table u
INNER JOIN $tbl_user_rel_access_url as user_rel_url
ON (u.user_id= user_rel_url.user_id)
WHERE access_url_id = $access_url_id
ORDER BY lastname,firstname";
}
} else {
$sql .= " FROM $user_table u ORDER BY lastname,firstname";
}
$filename = 'export_users_'.api_get_local_time();
}
$data = array();
$extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', false);
if (!empty($export['addcsvheader'])) {
if ($export['addcsvheader'] == '1' && ($export['file_type'] == 'csv' || $export['file_type'] == 'xls')) {
if ($_configuration['password_encryption'] != 'none') {
$data[] = array(
'UserId',
'LastName',
'FirstName',
'Email',
'UserName',
'AuthSource',
'Status',
'OfficialCode',
'PhoneNumber',
'RegistrationDate',
);
} else {
$data[] = array(
'UserId',
'LastName',
'FirstName',
'Email',
'UserName',
'Password',
'AuthSource',
'Status',
'OfficialCode',
'PhoneNumber',
'RegistrationDate',
);
}
$res = Database::query($sql);
while ($user = Database::fetch_array($res, 'ASSOC')) {
$student_data = UserManager:: get_extra_user_data(
$user['UserId'],
true,
false
);
foreach ($student_data as $key=>$value) {
$key = substr($key, 6);
if (is_array($value)) {
$user[$key] = $value['extra_'.$key];
} else {
$user[$key] = $value;
}
}
$data[] = $user;
}
switch ($file_type) {
case 'xml':
Export::arrayToXml($data, $filename, 'Contact', 'Contacts');
exit;
break;
case 'csv':
Export::arrayToCsv($data, $filename);
exit;
case 'xls':
Export::arrayToXls($data, $filename);
exit;
break;
}
foreach ($extra_fields as $extra) {
$data[0][] = $extra[1];
}
}
}
$res = Database::query($sql);
while ($user = Database::fetch_array($res, 'ASSOC')) {
$student_data = UserManager:: get_extra_user_data(
$user['UserId'],
true,
false
);
foreach ($student_data as $key => $value) {
$key = substr($key, 6);
if (is_array($value)) {
$user[$key] = $value['extra_'.$key];
} else {
$user[$key] = $value;
}
}
$data[] = $user;
}
switch ($file_type) {
case 'xml':
Export::arrayToXml($data, $filename, 'Contact', 'Contacts');
exit;
break;
case 'csv':
Export::arrayToCsv($data, $filename);
exit;
case 'xls':
Export::arrayToXls($data, $filename);
exit;
break;
}
}
Display :: display_header($tool_name);

@ -55,14 +55,15 @@ class Ims2Question extends Question
function createAnswersForm($form)
{
return true;
return true;
}
function processAnswersCreation($form)
{
return true;
return true;
}
}
/**
* Class
* @package chamilo.exercise
@ -76,21 +77,21 @@ class ImsAnswerMultipleChoice extends Answer
public function imsExportResponses($questionIdent, $questionStatment)
{
// @todo getAnswersList() converts the answers using api_html_entity_decode()
$this->answerList = $this->getAnswersList(true);
$out = ' <choiceInteraction responseIdentifier="'.$questionIdent.'" >'."\n";
$this->answerList = $this->getAnswersList(true);
$out = ' <choiceInteraction responseIdentifier="'.$questionIdent.'" >'."\n";
$out .= ' <prompt><![CDATA['.formatExerciseQtiTitle($questionStatment).']]></prompt>'."\n";
if (is_array($this->answerList)) {
foreach ($this->answerList as $current_answer) {
$out .= '<simpleChoice identifier="answer_'.$current_answer['id'].'" fixed="false">
if (is_array($this->answerList)) {
foreach ($this->answerList as $current_answer) {
$out .= '<simpleChoice identifier="answer_'.$current_answer['id'].'" fixed="false">
<![CDATA['.formatExerciseQtiTitle($current_answer['answer']).']]>';
if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
$out .= '<feedbackInline identifier="answer_'.$current_answer['id'].'">
<![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]>
</feedbackInline>';
}
$out .= '</simpleChoice>'."\n";
}
}
if (isset($current_answer['comment']) && $current_answer['comment'] != '') {
$out .= '<feedbackInline identifier="answer_'.$current_answer['id'].'">
<![CDATA['.formatExerciseQtiTitle($current_answer['comment']).']]>
</feedbackInline>';
}
$out .= '</simpleChoice>'."\n";
}
}
$out .= ' </choiceInteraction>'."\n";
return $out;
@ -102,34 +103,36 @@ class ImsAnswerMultipleChoice extends Answer
*/
public function imsExportResponsesDeclaration($questionIdent)
{
$this->answerList = $this->getAnswersList(true);
$type = $this->getQuestionType();
if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single';
$this->answerList = $this->getAnswersList(true);
$type = $this->getQuestionType();
if ($type == MCMA) {
$cardinality = 'multiple';
} else {
$cardinality = 'single';
}
$out = ' <responseDeclaration identifier="'.$questionIdent.'" cardinality="'.$cardinality.'" baseType="identifier">'."\n";
// Match the correct answers.
$out .= ' <correctResponse>'."\n";
if (is_array($this->answerList)) {
foreach ($this->answerList as $current_answer) {
if ($current_answer['correct']) {
$out .= ' <value>answer_'.$current_answer['id'].'</value>'."\n";
}
}
}
if (is_array($this->answerList)) {
foreach ($this->answerList as $current_answer) {
if ($current_answer['correct']) {
$out .= ' <value>answer_'.$current_answer['id'].'</value>'."\n";
}
}
}
$out .= ' </correctResponse>'."\n";
//Add the grading
// Add the grading
$out .= ' <mapping>'."\n";
if (is_array($this->answerList)) {
foreach ($this->answerList as $current_answer) {
if (isset($current_answer['grade'])) {
$out .= ' <mapEntry mapKey="answer_'.$current_answer['id'].'" mappedValue="'.$current_answer['grade'].'" />'."\n";
}
}
}
if (is_array($this->answerList)) {
foreach ($this->answerList as $current_answer) {
if (isset($current_answer['grade'])) {
$out .= ' <mapEntry mapKey="answer_'.$current_answer['id'].'" mappedValue="'.$current_answer['grade'].'" />'."\n";
}
}
}
$out .= ' </mapping>'."\n";
$out .= ' </responseDeclaration>'."\n";
@ -171,28 +174,28 @@ class ImsAnswerFillInBlanks extends Answer
*/
public function imsExportResponsesDeclaration($questionIdent)
{
$this->answerList = $this->getAnswersList(true);
$this->gradeList = $this->getGradesList();
$this->answerList = $this->getAnswersList(true);
$this->gradeList = $this->getGradesList();
$out = '';
if (is_array($this->answerList)) {
foreach ($this->answerList as $answer) {
$answerKey = $answer['id'];
$answer = $answer['answer'];
$out .= ' <responseDeclaration identifier="fill_'.$answerKey.'" cardinality="single" baseType="identifier">'."\n";
$out .= ' <correctResponse>'."\n";
if (is_array($this->answerList)) {
foreach ($this->answerList as $answer) {
$answerKey = $answer['id'];
$answer = $answer['answer'];
$out .= ' <responseDeclaration identifier="fill_'.$answerKey.'" cardinality="single" baseType="identifier">'."\n";
$out .= ' <correctResponse>'."\n";
$out .= ' <value><![CDATA['.formatExerciseQtiTitle($answer).']]></value>'."\n";
$out .= ' </correctResponse>'."\n";
if (isset($this->gradeList[$answerKey])) {
$out .= ' <mapping>'."\n";
$out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'."\n";
$out .= ' </mapping>'."\n";
}
$out .= ' </responseDeclaration>'."\n";
}
}
$out .= ' </correctResponse>'."\n";
if (isset($this->gradeList[$answerKey])) {
$out .= ' <mapping>'."\n";
$out .= ' <mapEntry mapKey="'.$answer.'" mappedValue="'.$this->gradeList[$answerKey].'"/>'."\n";
$out .= ' </mapping>'."\n";
}
$out .= ' </responseDeclaration>'."\n";
}
}
return $out;
return $out;
}
}
@ -207,22 +210,22 @@ class ImsAnswerMatching extends Answer
*/
public function imsExportResponses($questionIdent, $questionStatment)
{
$this->answerList = $this->getAnswersList(true);
$maxAssociation = max(count($this->leftList), count($this->rightList));
$this->answerList = $this->getAnswersList(true);
$maxAssociation = max(count($this->leftList), count($this->rightList));
$out = '<matchInteraction responseIdentifier="'.$questionIdent.'" maxAssociations="'.$maxAssociation.'">'."\n";
$out .= $questionStatment;
//add left column
$out .= ' <simpleMatchSet>'."\n";
if (is_array($this->leftList)) {
foreach ($this->leftList as $leftKey=>$leftElement) {
$out .= '
<simpleAssociableChoice identifier="left_'.$leftKey.'" >
<![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]>
</simpleAssociableChoice>'. "\n";
}
}
if (is_array($this->leftList)) {
foreach ($this->leftList as $leftKey=>$leftElement) {
$out .= '
<simpleAssociableChoice identifier="left_'.$leftKey.'" >
<![CDATA['.formatExerciseQtiTitle($leftElement['answer']).']]>
</simpleAssociableChoice>'. "\n";
}
}
$out .= ' </simpleMatchSet>'."\n";
@ -230,14 +233,14 @@ class ImsAnswerMatching extends Answer
$out .= ' <simpleMatchSet>'."\n";
$i = 0;
if (is_array($this->rightList)) {
foreach ($this->rightList as $rightKey=>$rightElement) {
$out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
<![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]>
</simpleAssociableChoice>'. "\n";
$i++;
}
}
if (is_array($this->rightList)) {
foreach ($this->rightList as $rightKey=>$rightElement) {
$out .= '<simpleAssociableChoice identifier="right_'.$i.'" >
<![CDATA['.formatExerciseQtiTitle($rightElement['answer']).']]>
</simpleAssociableChoice>'. "\n";
$i++;
}
}
$out .= ' </simpleMatchSet>'."\n";
$out .= '</matchInteraction>'."\n";
@ -249,29 +252,29 @@ class ImsAnswerMatching extends Answer
*/
public function imsExportResponsesDeclaration($questionIdent)
{
$this->answerList = $this->getAnswersList(true);
$this->answerList = $this->getAnswersList(true);
$out = ' <responseDeclaration identifier="'.$questionIdent.'" cardinality="single" baseType="identifier">'."\n";
$out .= ' <correctResponse>'."\n";
$gradeArray = array();
if (isset($this->leftList) && is_array($this->leftList)) {
if (isset($this->leftList) && is_array($this->leftList)) {
foreach ($this->leftList as $leftKey => $leftElement) {
$i = 0;
foreach ($this->rightList as $rightKey=>$rightElement) {
if (($leftElement['match'] == $rightElement['code'])) {
$out .= ' <value>left_'.$leftKey.' right_'.$i.'</value>'."\n";
$gradeArray['left_'.$leftKey.' right_'.$i] = $leftElement['grade'];
}
$i++;
}
}
}
$i = 0;
foreach ($this->rightList as $rightKey => $rightElement) {
if (($leftElement['match'] == $rightElement['code'])) {
$out .= ' <value>left_'.$leftKey.' right_'.$i.'</value>'."\n";
$gradeArray['left_'.$leftKey.' right_'.$i] = $leftElement['grade'];
}
$i++;
}
}
}
$out .= ' </correctResponse>'."\n";
$out .= ' <mapping>'."\n";
if (is_array($gradeArray)) {
foreach ($gradeArray as $gradeKey=>$grade) {
$out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>'."\n";
}
foreach ($gradeArray as $gradeKey => $grade) {
$out .= ' <mapEntry mapKey="'.$gradeKey.'" mappedValue="'.$grade.'"/>'."\n";
}
}
$out .= ' </mapping>'."\n";
$out .= ' </responseDeclaration>'."\n";
@ -292,49 +295,49 @@ class ImsAnswerHotspot extends Answer
*/
public function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '')
{
$this->answerList = $this->getAnswersList(true);
$questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
$mimetype = mime_content_type($questionMedia);
if (empty($mimetype)) {
$mimetype = 'image/jpeg';
}
$text = ' <p>'.$questionStatment.'</p>'."\n";
$text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n";
$text .= ' <prompt>'.$questionDesc.'</prompt>'."\n";
$text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n";
$this->answerList = $this->getAnswersList(true);
$questionMedia = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/'.$questionMedia;
$mimetype = mime_content_type($questionMedia);
if (empty($mimetype)) {
$mimetype = 'image/jpeg';
}
$text = ' <p>'.$questionStatment.'</p>'."\n";
$text .= ' <graphicOrderInteraction responseIdentifier="hotspot_'.$questionIdent.'">'."\n";
$text .= ' <prompt>'.$questionDesc.'</prompt>'."\n";
$text .= ' <object type="'.$mimetype.'" width="250" height="230" data="'.$questionMedia.'">-</object>'."\n";
if (is_array($this->answerList)) {
foreach ($this->answerList as $key=>$answer) {
$key = $answer['id'];
$answerTxt = $answer['answer'];
$len = api_strlen($answerTxt);
//coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
$coords = '';
$type = 'default';
switch ($answer['hotspot_type']) {
case 'square':
$type = 'rect';
$res = array();
$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res);
$coords = $res[1].','.$res[2].','.((int) $res[1] + (int) $res[3]).",".((int) $res[2] + (int) $res[4]);
break;
case 'circle':
$type = 'circle';
$res = array();
$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res);
$coords = $res[1].','.$res[2].','.sqrt(pow(($res[1] - $res[3]), 2) + pow(($res[2] - $res[4])));
break;
case 'poly':
$type = 'poly';
$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
break;
case 'delineation' :
$type = 'delineation';
$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
break;
}
$text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
}
foreach ($this->answerList as $key => $answer) {
$key = $answer['id'];
$answerTxt = $answer['answer'];
$len = api_strlen($answerTxt);
//coords are transformed according to QTIv2 rules here: http://www.imsproject.org/question/qtiv2p1pd/imsqti_infov2p1pd.html#element10663
$coords = '';
$type = 'default';
switch ($answer['hotspot_type']) {
case 'square':
$type = 'rect';
$res = array();
$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res);
$coords = $res[1].','.$res[2].','.((int) $res[1] + (int) $res[3]).",".((int) $res[2] + (int) $res[4]);
break;
case 'circle':
$type = 'circle';
$res = array();
$coords = preg_match('/^\s*(\d+);(\d+)\|(\d+)\|(\d+)\s*$/', $answer['hotspot_coord'], $res);
$coords = $res[1].','.$res[2].','.sqrt(pow(($res[1] - $res[3]), 2) + pow(($res[2] - $res[4])));
break;
case 'poly':
$type = 'poly';
$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
break;
case 'delineation':
$type = 'delineation';
$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
break;
}
$text .= ' <hotspotChoice shape="'.$type.'" coords="'.$coords.'" identifier="'.$key.'"/>'."\n";
}
}
$text .= ' </graphicOrderInteraction>'."\n";
$out = $text;
@ -347,19 +350,19 @@ class ImsAnswerHotspot extends Answer
*/
public function imsExportResponsesDeclaration($questionIdent)
{
$this->answerList = $this->getAnswersList(true);
$this->gradeList = $this->getGradesList();
$this->answerList = $this->getAnswersList(true);
$this->gradeList = $this->getGradesList();
$out = '';
$out .= ' <responseDeclaration identifier="hotspot_'.$questionIdent.'" cardinality="ordered" baseType="identifier">'."\n";
$out .= ' <correctResponse>'."\n";
if (is_array($this->answerList)) {
foreach ($this->answerList as $answerKey=>$answer) {
$answerKey = $answer['id'];
$answer = $answer['answer'];
$out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
}
}
if (is_array($this->answerList)) {
foreach ($this->answerList as $answerKey => $answer) {
$answerKey = $answer['id'];
$answer = $answer['answer'];
$out .= '<value><![CDATA['.formatExerciseQtiTitle($answerKey).']]></value>';
}
}
$out .= ' </correctResponse>'."\n";
$out .= ' </responseDeclaration>'."\n";
@ -378,14 +381,14 @@ class ImsAnswerFree extends Answer
* Export the question part as a matrix-choice, with only one possible answer per line.
*/
public function imsExportResponses($questionIdent, $questionStatment, $questionDesc = '', $questionMedia = '')
{
return '';
}
{
return '';
}
/**
*
*/
public function imsExportResponsesDeclaration($questionIdent)
{
return '';
return '';
}
}

@ -147,7 +147,6 @@ class DashboardManager
$possibleplugins = self::getPossibleDashboardPluginsPath();
if (count($possibleplugins) > 0) {
$selected_plugins = array_intersect(array_keys($plugin_paths), $possibleplugins);
$not_selected_plugins = array_diff($possibleplugins, array_keys($plugin_paths));
@ -309,13 +308,12 @@ class DashboardManager
}
}
return $block_data;
}
return $block_data;
}
/**
* get data about enabled dashboard block (stored insise block table)
* @param string $path plugin path
*
* @return array data
*/
public static function get_enabled_dashboard_blocks($path = '')
@ -419,8 +417,8 @@ class DashboardManager
/**
* display checkboxes for user dashboard list
* @param int User id
* @param int Block id
* @param int User id
* @param int Block id
* @return void
*/
public static function display_user_dashboard_list_checkboxes($user_id, $block_id)
@ -471,8 +469,8 @@ class DashboardManager
/**
* This function get user block data (block id with its number of column) from extra user data
* @param int User id
* @return array data (block_id,column)
* @param int User id
* @return array data (block_id,column)
*/
public static function get_user_block_data($user_id)
{
@ -493,42 +491,42 @@ class DashboardManager
return $data;
}
/**
* This function update extra user blocks data after closing a dashboard block
* @param int User id
* @param string plugin path
* @param integer $user_id
* @return bool
*/
public static function close_user_block($user_id, $path)
/**
* This function update extra user blocks data after closing a dashboard block
* @param int User id
* @param string plugin path
* @param integer $user_id
* @return bool
*/
public static function close_user_block($user_id, $path)
{
$enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path);
$user_block_data = self::get_user_block_data($user_id);
foreach ($enabled_dashboard_blocks as $enabled_block) {
unset($user_block_data[$enabled_block['id']]);
}
// get columns and blocks id for updating extra user data
$columns = array();
$user_blocks_id = array();
foreach ($user_block_data as $data) {
$user_blocks_id[$data['block_id']] = true;
$columns[$data['block_id']] = $data['column'];
}
// update extra user blocks data
$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
return $upd_extra_field;
}
/**
* get links for styles from dashboard plugins
* @return string links
*/
public static function get_links_for_styles_from_dashboard_plugins() {
return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL;
}
$enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path);
$user_block_data = self::get_user_block_data($user_id);
foreach ($enabled_dashboard_blocks as $enabled_block) {
unset($user_block_data[$enabled_block['id']]);
}
// get columns and blocks id for updating extra user data
$columns = array();
$user_blocks_id = array();
foreach ($user_block_data as $data) {
$user_blocks_id[$data['block_id']] = true;
$columns[$data['block_id']] = $data['column'];
}
// update extra user blocks data
$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
return $upd_extra_field;
}
/**
* get links for styles from dashboard plugins
* @return string links
*/
public static function get_links_for_styles_from_dashboard_plugins() {
return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL;
}
}

@ -826,9 +826,7 @@ function add_ext_on_mime($file_name, $file_type)
// Check whether the file has an extension AND whether the browser has sent a MIME Type
if (!preg_match('/^.*\.[a-zA-Z_0-9]+$/', $file_name) && $file_type) {
// Build a "MIME-types / extensions" connection table
static $mime_type = array();
$mime_type[] = 'application/msword'; $extension[] = '.doc';
@ -891,9 +889,7 @@ function add_ext_on_mime($file_name, $file_type)
// Test on PC (files with no extension get application/octet-stream)
//$mime_type[] = 'application/octet-stream'; $extension[] = '.ext';
// Check whether the MIME type sent by the browser is within the table
foreach ($mime_type as $key => & $type) {
if ($type == $file_type) {
$file_name .= $extension[$key];
@ -1065,7 +1061,6 @@ function unzip_uploaded_document(
// Check the zip content (real size and file extension)
$zip_content_array = (array) $zip->listContent();
$realSize = 0;
foreach ($zip_content_array as & $this_content) {
$realSize += $this_content['size'];
@ -1375,7 +1370,8 @@ function item_property_update_on_folder($_course, $path, $user_id)
* @param path+filename eg: /main/document/document.php
* @return The directory depth
*/
function get_levels($filename) {
function get_levels($filename)
{
$levels = explode('/', $filename);
if (empty($levels[count($levels) - 1])) {
unset($levels[count($levels) - 1]);
@ -1440,8 +1436,8 @@ function set_default_settings($upload_path, $filename, $filetype = 'file')
* @param string $html_file
* @return array - images path list
*/
function search_img_from_html($html_file) {
function search_img_from_html($html_file)
{
$img_path_list = array();
if (!$fp = fopen($html_file, 'r')) {
@ -1726,13 +1722,11 @@ function move_uploaded_file_collection_into_directory(
function replace_img_path_in_html_file($original_img_path, $new_img_path, $html_file)
{
// Open the file
$fp = fopen($html_file, 'r');
$buffer = fread($fp, filesize($html_file));
$new_html_content = '';
// Fix the image tags
for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb; $i++) {
$replace_what = $original_img_path[$i];
// We only need the directory and the filename /path/to/file_html_files/missing_file.gif -> file_html_files/missing_file.gif

@ -160,7 +160,12 @@ class UserGroup extends Model
*/
public function get_id_by_name($name)
{
$row = Database::select('id', $this->table, array('where' => array('name = ?' => $name)), 'first');
$row = Database::select(
'id',
$this->table,
array('where' => array('name = ?' => $name)),
'first'
);
return $row['id'];
}
@ -745,8 +750,12 @@ class UserGroup extends Model
* @param bool $delete_users_not_present_in_list
* @param array $relationType
*/
public function subscribe_users_to_usergroup($usergroup_id, $list, $delete_users_not_present_in_list = true, $relationType = '')
{
public function subscribe_users_to_usergroup(
$usergroup_id,
$list,
$delete_users_not_present_in_list = true,
$relationType = ''
) {
$current_list = self::get_users_by_usergroup($usergroup_id);
$course_list = self::get_courses_by_usergroup($usergroup_id);
$session_list = self::get_sessions_by_usergroup($usergroup_id);
@ -1080,14 +1089,14 @@ class UserGroup extends Model
/**
* Creates new group pictures in various sizes of a user, or deletes user pfotos.
* Note: This method relies on configuration setting from main/inc/conf/profile.conf.php
* @param int The group id
* @param string $file The common file name for the newly created photos.
* @param int The group id
* @param string $file The common file name for the newly created photos.
* It will be checked and modified for compatibility with the file system.
* If full name is provided, path component is ignored.
* If an empty name is provided, then old user photos are deleted only,
* @see UserManager::delete_user_picture() as the prefered way for deletion.
* @param string $source_file The full system name of the image from which user photos will be created.
* @return mixed Returns the resulting common file name of created images which usually should be stored in database.
* @param string $source_file The full system name of the image from which user photos will be created.
* @return mixed Returns the resulting common file name of created images which usually should be stored in database.
* When an image is removed the function returns an empty string. In case of internal error or negative validation it returns FALSE.
*/
public function update_group_picture($group_id, $file = null, $source_file = null)
@ -1233,7 +1242,7 @@ class UserGroup extends Model
WHERE usergroup_id = $id";
Database::query($sql);*/
$result = parent::delete($id);
parent::delete($id);
}
/**
@ -1401,8 +1410,13 @@ class UserGroup extends Model
* @param string style css
* @return array with the file and the style of an image i.e $array['file'] $array['style']
*/
public function get_picture_group($id, $picture_file, $height, $size_picture = GROUP_IMAGE_SIZE_MEDIUM, $style = '')
{
public function get_picture_group(
$id,
$picture_file,
$height,
$size_picture = GROUP_IMAGE_SIZE_MEDIUM,
$style = ''
) {
$picture = array();
//$picture['style'] = $style;
if ($picture_file === 'unknown.jpg') {
@ -1457,11 +1471,11 @@ class UserGroup extends Model
* with dirname() or the file with basename(). This also works for the
* functions dealing with the user's productions, as they are located in
* the same directory.
* @param integer User ID
* @param string Type of path to return (can be 'none', 'system', 'rel', 'web')
* @param bool Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
* @param bool If we want that the function returns the /main/img/unknown.jpg image set it at true
* @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
* @param integer User ID
* @param string Type of path to return (can be 'none', 'system', 'rel', 'web')
* @param bool Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
* @param bool If we want that the function returns the /main/img/unknown.jpg image set it at true
* @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
*/
public function get_group_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false)
{
@ -1664,8 +1678,9 @@ class UserGroup extends Model
* @author Julio Montoya
* @param array $user_list
* @param array $group_list
* @param int $relation_type
* */
* @param int $relation_type
* @return array
**/
public function add_users_to_groups($user_list, $group_list, $relation_type = GROUP_USER_PERMISSION_READER)
{
$table_url_rel_group = $this->usergroup_rel_user_table;
@ -1693,7 +1708,7 @@ class UserGroup extends Model
}
}
}
return $result_array;
return $result_array;
}
/**
@ -1721,9 +1736,9 @@ class UserGroup extends Model
* @param int $user_id
* @param int $group_id
* @param int $relation_type
*
*
* @return boolean true if success
* */
**/
public function add_user_to_group($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER)
{
$table_url_rel_group = $this->usergroup_rel_user_table;
@ -1752,7 +1767,6 @@ class UserGroup extends Model
* @param int $user_id
* @param int $group_id
* @param int $relation_type
*
**/
public function update_user_role($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER)
{
@ -2011,7 +2025,7 @@ class UserGroup extends Model
* Shows the left column of the group page
* @param int group id
* @param int user id
*
* @return string
*/
public function show_group_column_information($group_id, $user_id, $show = '')
{
@ -2095,6 +2109,10 @@ class UserGroup extends Model
return $html;
}
/**
* @param int $group_id
* @param int $topic_id
*/
public function delete_topic($group_id, $topic_id)
{
$table_message = Database::get_main_table(TABLE_MESSAGE);

@ -330,7 +330,7 @@ class aicc extends learnpath
* @param string Current path (optional)
* @return string Absolute path to the AICC description files or empty string on error
*/
function import_local_package($file_path, $current_dir = '')
public function import_local_package($file_path, $current_dir = '')
{
// TODO: Prepare info as given by the $_FILES[''] vector.
$file_info = array();
@ -345,7 +345,7 @@ class aicc extends learnpath
* @param string Zip file info as given by $_FILES['userFile']
* @return string Absolute path to the AICC config files directory or empty string on error
*/
function import_package($zip_file_info, $current_dir = '')
public function import_package($zip_file_info, $current_dir = '')
{
if ($this->debug > 0) { error_log('In aicc::import_package('.print_r($zip_file_info, true).',"'.$current_dir.'") method', 0); }
//ini_set('error_log', 'E_ALL');
@ -854,7 +854,8 @@ class aicc extends learnpath
* Static function to parse AICC ini strings.
* Based on work by sinedeo at gmail dot com published on php.net (parse_ini_file()).
* @param string INI File string
* @param array List of names of sections that should be considered as containing only hard string data (no variables), provided in lower case
* @param array List of names of sections that should be considered
* as containing only hard string data (no variables), provided in lower case
* @return array Structured array
*/
function parse_ini_string_quotes_safe($s, $pure_strings = array())
@ -936,15 +937,17 @@ class aicc extends learnpath
if ($enclosed && $data{$i + 1} == $enclosure) {
$fldval .= $chr;
++$i; // Skip the next character.
} else
} else {
$enclosed = !$enclosed;
}
break;
case $delim:
if (!$enclosed) {
$ret_array[$linecount][$fldcount++] = $fldval;
$fldval = '';
} else
} else {
$fldval .= $chr;
}
break;
case "\r":
if (!$enclosed && $data{$i + 1} == "\n") {
@ -956,8 +959,9 @@ class aicc extends learnpath
$ret_array[$linecount++][$fldcount] = $fldval;
$fldcount = 0;
$fldval = '';
} else
} else {
$fldval .= $chr;
}
break;
case "\\r":
if (!$enclosed && $data{$i + 1} == "\\n") {
@ -969,8 +973,9 @@ class aicc extends learnpath
$ret_array[$linecount++][$fldcount] = $fldval;
$fldcount = 0;
$fldval = '';
} else
} else {
$fldval .= $chr;
}
break;
default:
$fldval .= $chr;

@ -14,23 +14,23 @@ $this_section = "session_my_space";
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
if (!$is_allowedToTrack) {
api_not_allowed(true);
api_not_allowed(true);
}
$export_to_xls = false;
if (isset($_GET['export'])) {
$export_to_xls = true;
$export_to_xls = true;
}
if (api_is_platform_admin()) {
$global = true;
$global = true;
} else {
$global = false;
$global = false;
}
$global = true;
$session_id = isset($_GET['session_id']) ? intval($_GET['session_id']) : null;
if (empty($session_id)) {
$session_id = 1;
$session_id = 1;
}
$form = new FormValidator('search_simple', 'POST', '', '', null, false);
@ -39,10 +39,10 @@ $form = new FormValidator('search_simple', 'POST', '', '', null, false);
$session_list = SessionManager::get_sessions_list(array(), array('name'));
$my_session_list = array();
foreach ($session_list as $sesion_item) {
$my_session_list[$sesion_item['id']] = $sesion_item['name'];
$my_session_list[$sesion_item['id']] = $sesion_item['name'];
}
if (count($session_list) == 0) {
$my_session_list[0] = get_lang('None');
$my_session_list[0] = get_lang('None');
}
$form->addElement('select', 'session_id', get_lang('Sessions'), $my_session_list);
$form->addButtonFilter(get_lang('Filter'));
@ -59,32 +59,32 @@ if (!empty($_REQUEST['session_id'])) {
}
if (empty($session_id)) {
$session_id = key($my_session_list);
$session_id = key($my_session_list);
}
$form->setDefaults(array('session_id'=>$session_id));
$course_list = SessionManager::get_course_list_by_session_id($session_id);
if (!$export_to_xls) {
Display :: display_header(get_lang("MySpace"));
echo '<div class="actions">';
if ($global) {
echo MySpace::getTopMenu();
} else {
echo '<div style="float:left; clear:left">
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;';
echo '</div>';
}
echo '</div>';
if (api_is_platform_admin()) {
echo MySpace::getAdminActions();
}
echo '<h2>'.get_lang('LPExerciseResultsBySession').'</h2>';
$form->display();
echo Display::return_message(get_lang('StudentScoreAverageIsCalculatedBaseInAllLPsAndAllAttempts'));
Display :: display_header(get_lang("MySpace"));
echo '<div class="actions">';
if ($global) {
echo MySpace::getTopMenu();
} else {
echo '<div style="float:left; clear:left">
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;';
echo '</div>';
}
echo '</div>';
if (api_is_platform_admin()) {
echo MySpace::getAdminActions();
}
echo '<h2>'.get_lang('LPExerciseResultsBySession').'</h2>';
$form->display();
echo Display::return_message(get_lang('StudentScoreAverageIsCalculatedBaseInAllLPsAndAllAttempts'));
}
$users = SessionManager::get_users_by_session($session_id);
@ -93,17 +93,17 @@ $course_average = $course_average_counter = array();
$counter = 0;
$main_result = array();
//Getting course list
foreach ($course_list as $current_course) {
$course_info = api_get_course_info($current_course['code']);
$_course = $course_info;
$attempt_result = array();
foreach ($course_list as $current_course) {
$course_info = api_get_course_info($current_course['code']);
$_course = $course_info;
$attempt_result = array();
//Getting LP list
$list = new LearnpathList('', $current_course['code'], $session_id);
$lp_list = $list->get_flat_list();
//Getting LP list
$list = new LearnpathList('', $current_course['code'], $session_id);
$lp_list = $list->get_flat_list();
// Looping LPs
foreach ($lp_list as $lp_id =>$lp) {
// Looping LPs
foreach ($lp_list as $lp_id => $lp) {
$exercise_list = Event::get_all_exercises_from_lp($lp_id, $course_info['real_id']);
// Looping Chamilo Exercises in LP
foreach ($exercise_list as $exercise) {
@ -119,110 +119,105 @@ foreach ($course_list as $current_course) {
}
}
}
$main_result[$current_course['code']] = $attempt_result;
$main_result[$current_course['code']] = $attempt_result;
}
$total_average_score = 0;
$total_average_score_count = 0;
$html_result = '';
if (!empty($users) && is_array($users)) {
$html_result .= '<table class="data_table">';
$html_result .= '<tr><th>'.get_lang('User').'</th>';
foreach ($course_list as $item) {
$html_result .= '<th>'.$item['title'].'<br /> '.get_lang('AverageScore').' %</th>';
}
$html_result .= '<th>'.get_lang('AverageScore').' %</th>';
$html_result .= '<th>'.get_lang('LastConnexionDate').'</th></tr>';
foreach ($users as $user) {
$total_student = 0;
$counter++;
$s_css_class = 'row_even';
if ($counter % 2 == 0) {
$s_css_class = 'row_odd';
}
$html_result .= "<tr class='$s_css_class'>
<td >";
$html_result .= $user['firstname'].' '.$user['lastname'];
$html_result .= "</td>";
// Getting course list
$counter = 0;
$total_result_by_user = 0;
foreach ($course_list as $current_course) {
$total_course = 0;
$html_result .= "<td>";
$result = '-';
if (isset($main_result[$current_course['code']][$user['user_id']])) {
$user_info_stat = $main_result[$current_course['code']][$user['user_id']];
if (!empty($user_info_stat['result']) && !empty($user_info_stat['attempts'])) {
$result = round(
$user_info_stat['result'] / $user_info_stat['attempts'] * 100,
2
);
$total_course += $result;
$total_result_by_user += $result;
$course_average[$current_course['code']] += $total_course;
$course_average_counter[$current_course['code']]++;
$result = $result.' ('.$user_info_stat['attempts'].' '.get_lang('Attempts').')';
$counter++;
}
}
$html_result .= $result;
$html_result .= "</td>";
}
if (empty($counter)) {
$total_student = '-';
} else {
$total_student = $total_result_by_user / $counter;
$total_average_score += $total_student;
$total_average_score_count++;
}
$string_date = Tracking :: get_last_connection_date($user['user_id'], true);
$html_result .= "<td>$total_student</td><td>$string_date</td></tr>";
}
$html_result .= "<tr><th>".get_lang('AverageScore')."</th>";
$total_average = 0;
$counter = 0;
foreach ($course_list as $course_item) {
if (!empty($course_average_counter[$course_item['code']])) {
$average_per_course = round(
$course_average[$course_item['code']] / ($course_average_counter[$course_item['code']] * 100) * 100,
2
);
} else {
$average_per_course = '-';
}
if (!empty($average_per_course)) {
$counter++;
}
$total_average = $total_average + $average_per_course;
$html_result .= "<td>$average_per_course</td>";
}
if (!empty($total_average_score_count)) {
$total_average = round($total_average_score / ($total_average_score_count * 100) * 100, 2);
} else {
$total_average = '-';
}
$html_result .= '<table class="data_table">';
$html_result .= '<tr><th>'.get_lang('User').'</th>';
foreach ($course_list as $item) {
$html_result .= '<th>'.$item['title'].'<br /> '.get_lang('AverageScore').' %</th>';
}
$html_result .= '<th>'.get_lang('AverageScore').' %</th>';
$html_result .= '<th>'.get_lang('LastConnexionDate').'</th></tr>';
foreach ($users as $user) {
$total_student = 0;
$counter++;
$s_css_class = 'row_even';
if ($counter % 2 == 0) {
$s_css_class = 'row_odd';
}
$html_result .= "<tr class='$s_css_class'>
<td >";
$html_result .= $user['firstname'].' '.$user['lastname'];
$html_result .= "</td>";
// Getting course list
$counter = 0;
$total_result_by_user = 0;
foreach ($course_list as $current_course) {
$total_course = 0;
$html_result .= "<td>";
$result = '-';
if (isset($main_result[$current_course['code']][$user['user_id']])) {
$user_info_stat = $main_result[$current_course['code']][$user['user_id']];
if (!empty($user_info_stat['result']) && !empty($user_info_stat['attempts'])) {
$result = round(
$user_info_stat['result'] / $user_info_stat['attempts'] * 100,
2
);
$total_course += $result;
$total_result_by_user += $result;
$course_average[$current_course['code']] += $total_course;
$course_average_counter[$current_course['code']]++;
$result = $result.' ('.$user_info_stat['attempts'].' '.get_lang(
'Attempts'
).')';
$counter++;
}
}
$html_result .= $result;
$html_result .= "</td>";
}
if (empty($counter)) {
$total_student = '-';
} else {
$total_student = $total_result_by_user / $counter;
$total_average_score += $total_student;
$total_average_score_count++;
}
$string_date = Tracking :: get_last_connection_date($user['user_id'], true);
$html_result .= "<td>$total_student</td><td>$string_date</td></tr>";
}
$html_result .= "<tr><th>".get_lang('AverageScore')."</th>";
$total_average = 0;
$counter = 0;
foreach ($course_list as $course_item) {
if (!empty($course_average_counter[$course_item['code']])) {
$average_per_course = round(
$course_average[$course_item['code']] / ($course_average_counter[$course_item['code']] * 100) * 100,
2
);
} else {
$average_per_course = '-';
}
if (!empty($average_per_course)) {
$counter++;
}
$total_average = $total_average + $average_per_course;
$html_result .= "<td>$average_per_course</td>";
}
if (!empty($total_average_score_count)) {
$total_average = round($total_average_score / ($total_average_score_count * 100) * 100, 2);
} else {
$total_average = '-';
}
$html_result .= '<td>'.$total_average.'</td>';
$html_result .= "<td>-</td>";
$html_result .= "</tr>";
$html_result .= '</table>';
$html_result .= '<td>'.$total_average.'</td>';
$html_result .= "<td>-</td>";
$html_result .= "</tr>";
$html_result .= '</table>';
} else {
echo Display::return_message(get_lang('NoResults'), 'warning');
echo Display::return_message(get_lang('NoResults'), 'warning');
}
if (!$export_to_xls) {
echo $html_result;
echo $html_result;
}
Display :: display_footer();

Loading…
Cancel
Save