Minor - format code

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

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

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

@ -147,7 +147,6 @@ class DashboardManager
$possibleplugins = self::getPossibleDashboardPluginsPath(); $possibleplugins = self::getPossibleDashboardPluginsPath();
if (count($possibleplugins) > 0) { if (count($possibleplugins) > 0) {
$selected_plugins = array_intersect(array_keys($plugin_paths), $possibleplugins); $selected_plugins = array_intersect(array_keys($plugin_paths), $possibleplugins);
$not_selected_plugins = array_diff($possibleplugins, array_keys($plugin_paths)); $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) * get data about enabled dashboard block (stored insise block table)
* @param string $path plugin path * @param string $path plugin path
*
* @return array data * @return array data
*/ */
public static function get_enabled_dashboard_blocks($path = '') public static function get_enabled_dashboard_blocks($path = '')
@ -419,8 +417,8 @@ class DashboardManager
/** /**
* display checkboxes for user dashboard list * display checkboxes for user dashboard list
* @param int User id * @param int User id
* @param int Block id * @param int Block id
* @return void * @return void
*/ */
public static function display_user_dashboard_list_checkboxes($user_id, $block_id) 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 * This function get user block data (block id with its number of column) from extra user data
* @param int User id * @param int User id
* @return array data (block_id,column) * @return array data (block_id,column)
*/ */
public static function get_user_block_data($user_id) public static function get_user_block_data($user_id)
{ {
@ -493,42 +491,42 @@ class DashboardManager
return $data; return $data;
} }
/** /**
* This function update extra user blocks data after closing a dashboard block * This function update extra user blocks data after closing a dashboard block
* @param int User id * @param int User id
* @param string plugin path * @param string plugin path
* @param integer $user_id * @param integer $user_id
* @return bool * @return bool
*/ */
public static function close_user_block($user_id, $path) public static function close_user_block($user_id, $path)
{ {
$enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path);
$user_block_data = self::get_user_block_data($user_id); $user_block_data = self::get_user_block_data($user_id);
foreach ($enabled_dashboard_blocks as $enabled_block) { foreach ($enabled_dashboard_blocks as $enabled_block) {
unset($user_block_data[$enabled_block['id']]); unset($user_block_data[$enabled_block['id']]);
} }
// get columns and blocks id for updating extra user data // get columns and blocks id for updating extra user data
$columns = array(); $columns = array();
$user_blocks_id = array(); $user_blocks_id = array();
foreach ($user_block_data as $data) { foreach ($user_block_data as $data) {
$user_blocks_id[$data['block_id']] = true; $user_blocks_id[$data['block_id']] = true;
$columns[$data['block_id']] = $data['column']; $columns[$data['block_id']] = $data['column'];
} }
// update extra user blocks data // update extra user blocks data
$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
return $upd_extra_field; return $upd_extra_field;
} }
/** /**
* get links for styles from dashboard plugins * get links for styles from dashboard plugins
* @return string links * @return string links
*/ */
public static function get_links_for_styles_from_dashboard_plugins() { 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; 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 // 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) { if (!preg_match('/^.*\.[a-zA-Z_0-9]+$/', $file_name) && $file_type) {
// Build a "MIME-types / extensions" connection table // Build a "MIME-types / extensions" connection table
static $mime_type = array(); static $mime_type = array();
$mime_type[] = 'application/msword'; $extension[] = '.doc'; $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) // Test on PC (files with no extension get application/octet-stream)
//$mime_type[] = 'application/octet-stream'; $extension[] = '.ext'; //$mime_type[] = 'application/octet-stream'; $extension[] = '.ext';
// Check whether the MIME type sent by the browser is within the table // Check whether the MIME type sent by the browser is within the table
foreach ($mime_type as $key => & $type) { foreach ($mime_type as $key => & $type) {
if ($type == $file_type) { if ($type == $file_type) {
$file_name .= $extension[$key]; $file_name .= $extension[$key];
@ -1065,7 +1061,6 @@ function unzip_uploaded_document(
// Check the zip content (real size and file extension) // Check the zip content (real size and file extension)
$zip_content_array = (array) $zip->listContent(); $zip_content_array = (array) $zip->listContent();
$realSize = 0; $realSize = 0;
foreach ($zip_content_array as & $this_content) { foreach ($zip_content_array as & $this_content) {
$realSize += $this_content['size']; $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 * @param path+filename eg: /main/document/document.php
* @return The directory depth * @return The directory depth
*/ */
function get_levels($filename) { function get_levels($filename)
{
$levels = explode('/', $filename); $levels = explode('/', $filename);
if (empty($levels[count($levels) - 1])) { if (empty($levels[count($levels) - 1])) {
unset($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 * @param string $html_file
* @return array - images path list * @return array - images path list
*/ */
function search_img_from_html($html_file) { function search_img_from_html($html_file)
{
$img_path_list = array(); $img_path_list = array();
if (!$fp = fopen($html_file, 'r')) { 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) function replace_img_path_in_html_file($original_img_path, $new_img_path, $html_file)
{ {
// Open the file // Open the file
$fp = fopen($html_file, 'r'); $fp = fopen($html_file, 'r');
$buffer = fread($fp, filesize($html_file)); $buffer = fread($fp, filesize($html_file));
$new_html_content = ''; $new_html_content = '';
// Fix the image tags // Fix the image tags
for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb; $i++) { for ($i = 0, $fileNb = count($original_img_path); $i < $fileNb; $i++) {
$replace_what = $original_img_path[$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 // 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) 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']; return $row['id'];
} }
@ -745,8 +750,12 @@ class UserGroup extends Model
* @param bool $delete_users_not_present_in_list * @param bool $delete_users_not_present_in_list
* @param array $relationType * @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); $current_list = self::get_users_by_usergroup($usergroup_id);
$course_list = self::get_courses_by_usergroup($usergroup_id); $course_list = self::get_courses_by_usergroup($usergroup_id);
$session_list = self::get_sessions_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. * 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 * Note: This method relies on configuration setting from main/inc/conf/profile.conf.php
* @param int The group id * @param int The group id
* @param string $file The common file name for the newly created photos. * @param string $file The common file name for the newly created photos.
* It will be checked and modified for compatibility with the file system. * It will be checked and modified for compatibility with the file system.
* If full name is provided, path component is ignored. * If full name is provided, path component is ignored.
* If an empty name is provided, then old user photos are deleted only, * If an empty name is provided, then old user photos are deleted only,
* @see UserManager::delete_user_picture() as the prefered way for deletion. * @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. * @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. * @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. * 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) public function update_group_picture($group_id, $file = null, $source_file = null)
@ -1233,7 +1242,7 @@ class UserGroup extends Model
WHERE usergroup_id = $id"; WHERE usergroup_id = $id";
Database::query($sql);*/ Database::query($sql);*/
$result = parent::delete($id); parent::delete($id);
} }
/** /**
@ -1401,8 +1410,13 @@ class UserGroup extends Model
* @param string style css * @param string style css
* @return array with the file and the style of an image i.e $array['file'] $array['style'] * @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 = array();
//$picture['style'] = $style; //$picture['style'] = $style;
if ($picture_file === 'unknown.jpg') { 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 * with dirname() or the file with basename(). This also works for the
* functions dealing with the user's productions, as they are located in * functions dealing with the user's productions, as they are located in
* the same directory. * the same directory.
* @param integer User ID * @param integer User ID
* @param string Type of path to return (can be 'none', 'system', 'rel', 'web') * @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 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 * @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 * @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) 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 * @author Julio Montoya
* @param array $user_list * @param array $user_list
* @param array $group_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) 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; $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 $user_id
* @param int $group_id * @param int $group_id
* @param int $relation_type * @param int $relation_type
* *
* @return boolean true if success * @return boolean true if success
* */ **/
public function add_user_to_group($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER) 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; $table_url_rel_group = $this->usergroup_rel_user_table;
@ -1752,7 +1767,6 @@ class UserGroup extends Model
* @param int $user_id * @param int $user_id
* @param int $group_id * @param int $group_id
* @param int $relation_type * @param int $relation_type
*
**/ **/
public function update_user_role($user_id, $group_id, $relation_type = GROUP_USER_PERMISSION_READER) 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 * Shows the left column of the group page
* @param int group id * @param int group id
* @param int user id * @param int user id
* * @return string
*/ */
public function show_group_column_information($group_id, $user_id, $show = '') public function show_group_column_information($group_id, $user_id, $show = '')
{ {
@ -2095,6 +2109,10 @@ class UserGroup extends Model
return $html; return $html;
} }
/**
* @param int $group_id
* @param int $topic_id
*/
public function delete_topic($group_id, $topic_id) public function delete_topic($group_id, $topic_id)
{ {
$table_message = Database::get_main_table(TABLE_MESSAGE); $table_message = Database::get_main_table(TABLE_MESSAGE);

@ -330,7 +330,7 @@ class aicc extends learnpath
* @param string Current path (optional) * @param string Current path (optional)
* @return string Absolute path to the AICC description files or empty string on error * @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. // TODO: Prepare info as given by the $_FILES[''] vector.
$file_info = array(); $file_info = array();
@ -345,7 +345,7 @@ class aicc extends learnpath
* @param string Zip file info as given by $_FILES['userFile'] * @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 * @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); } 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'); //ini_set('error_log', 'E_ALL');
@ -854,7 +854,8 @@ class aicc extends learnpath
* Static function to parse AICC ini strings. * Static function to parse AICC ini strings.
* Based on work by sinedeo at gmail dot com published on php.net (parse_ini_file()). * Based on work by sinedeo at gmail dot com published on php.net (parse_ini_file()).
* @param string INI File string * @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 * @return array Structured array
*/ */
function parse_ini_string_quotes_safe($s, $pure_strings = 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) { if ($enclosed && $data{$i + 1} == $enclosure) {
$fldval .= $chr; $fldval .= $chr;
++$i; // Skip the next character. ++$i; // Skip the next character.
} else } else {
$enclosed = !$enclosed; $enclosed = !$enclosed;
}
break; break;
case $delim: case $delim:
if (!$enclosed) { if (!$enclosed) {
$ret_array[$linecount][$fldcount++] = $fldval; $ret_array[$linecount][$fldcount++] = $fldval;
$fldval = ''; $fldval = '';
} else } else {
$fldval .= $chr; $fldval .= $chr;
}
break; break;
case "\r": case "\r":
if (!$enclosed && $data{$i + 1} == "\n") { if (!$enclosed && $data{$i + 1} == "\n") {
@ -956,8 +959,9 @@ class aicc extends learnpath
$ret_array[$linecount++][$fldcount] = $fldval; $ret_array[$linecount++][$fldcount] = $fldval;
$fldcount = 0; $fldcount = 0;
$fldval = ''; $fldval = '';
} else } else {
$fldval .= $chr; $fldval .= $chr;
}
break; break;
case "\\r": case "\\r":
if (!$enclosed && $data{$i + 1} == "\\n") { if (!$enclosed && $data{$i + 1} == "\\n") {
@ -969,8 +973,9 @@ class aicc extends learnpath
$ret_array[$linecount++][$fldcount] = $fldval; $ret_array[$linecount++][$fldcount] = $fldval;
$fldcount = 0; $fldcount = 0;
$fldval = ''; $fldval = '';
} else } else {
$fldval .= $chr; $fldval .= $chr;
}
break; break;
default: default:
$fldval .= $chr; $fldval .= $chr;

@ -14,23 +14,23 @@ $this_section = "session_my_space";
$is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin; $is_allowedToTrack = $is_courseAdmin || $is_platformAdmin || $is_courseCoach || $is_sessionAdmin;
if (!$is_allowedToTrack) { if (!$is_allowedToTrack) {
api_not_allowed(true); api_not_allowed(true);
} }
$export_to_xls = false; $export_to_xls = false;
if (isset($_GET['export'])) { if (isset($_GET['export'])) {
$export_to_xls = true; $export_to_xls = true;
} }
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
$global = true; $global = true;
} else { } else {
$global = false; $global = false;
} }
$global = true; $global = true;
$session_id = isset($_GET['session_id']) ? intval($_GET['session_id']) : null; $session_id = isset($_GET['session_id']) ? intval($_GET['session_id']) : null;
if (empty($session_id)) { if (empty($session_id)) {
$session_id = 1; $session_id = 1;
} }
$form = new FormValidator('search_simple', 'POST', '', '', null, false); $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')); $session_list = SessionManager::get_sessions_list(array(), array('name'));
$my_session_list = array(); $my_session_list = array();
foreach ($session_list as $sesion_item) { 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) { 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->addElement('select', 'session_id', get_lang('Sessions'), $my_session_list);
$form->addButtonFilter(get_lang('Filter')); $form->addButtonFilter(get_lang('Filter'));
@ -59,32 +59,32 @@ if (!empty($_REQUEST['session_id'])) {
} }
if (empty($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)); $form->setDefaults(array('session_id'=>$session_id));
$course_list = SessionManager::get_course_list_by_session_id($session_id); $course_list = SessionManager::get_course_list_by_session_id($session_id);
if (!$export_to_xls) { if (!$export_to_xls) {
Display :: display_header(get_lang("MySpace")); Display :: display_header(get_lang("MySpace"));
echo '<div class="actions">'; echo '<div class="actions">';
if ($global) { if ($global) {
echo MySpace::getTopMenu(); echo MySpace::getTopMenu();
} else { } else {
echo '<div style="float:left; clear:left"> 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=true">'.get_lang('StudentsTracking').'</a>&nbsp;|
<a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;'; <a href="courseLog.php?'.api_get_cidreq().'&studentlist=false">'.get_lang('CourseTracking').'</a>&nbsp;';
echo '</div>'; echo '</div>';
} }
echo '</div>'; echo '</div>';
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
echo MySpace::getAdminActions(); echo MySpace::getAdminActions();
} }
echo '<h2>'.get_lang('LPExerciseResultsBySession').'</h2>'; echo '<h2>'.get_lang('LPExerciseResultsBySession').'</h2>';
$form->display(); $form->display();
echo Display::return_message(get_lang('StudentScoreAverageIsCalculatedBaseInAllLPsAndAllAttempts')); echo Display::return_message(get_lang('StudentScoreAverageIsCalculatedBaseInAllLPsAndAllAttempts'));
} }
$users = SessionManager::get_users_by_session($session_id); $users = SessionManager::get_users_by_session($session_id);
@ -93,17 +93,17 @@ $course_average = $course_average_counter = array();
$counter = 0; $counter = 0;
$main_result = array(); $main_result = array();
//Getting course list //Getting course list
foreach ($course_list as $current_course) { foreach ($course_list as $current_course) {
$course_info = api_get_course_info($current_course['code']); $course_info = api_get_course_info($current_course['code']);
$_course = $course_info; $_course = $course_info;
$attempt_result = array(); $attempt_result = array();
//Getting LP list //Getting LP list
$list = new LearnpathList('', $current_course['code'], $session_id); $list = new LearnpathList('', $current_course['code'], $session_id);
$lp_list = $list->get_flat_list(); $lp_list = $list->get_flat_list();
// Looping LPs // Looping LPs
foreach ($lp_list as $lp_id =>$lp) { foreach ($lp_list as $lp_id => $lp) {
$exercise_list = Event::get_all_exercises_from_lp($lp_id, $course_info['real_id']); $exercise_list = Event::get_all_exercises_from_lp($lp_id, $course_info['real_id']);
// Looping Chamilo Exercises in LP // Looping Chamilo Exercises in LP
foreach ($exercise_list as $exercise) { 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 = 0;
$total_average_score_count = 0; $total_average_score_count = 0;
$html_result = ''; $html_result = '';
if (!empty($users) && is_array($users)) { 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 .= '<td>'.$total_average.'</td>';
$html_result .= '<tr><th>'.get_lang('User').'</th>'; $html_result .= "<td>-</td>";
foreach ($course_list as $item) { $html_result .= "</tr>";
$html_result .= '<th>'.$item['title'].'<br /> '.get_lang('AverageScore').' %</th>'; $html_result .= '</table>';
}
$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>';
} else { } else {
echo Display::return_message(get_lang('NoResults'), 'warning'); echo Display::return_message(get_lang('NoResults'), 'warning');
} }
if (!$export_to_xls) { if (!$export_to_xls) {
echo $html_result; echo $html_result;
} }
Display :: display_footer(); Display :: display_footer();

Loading…
Cancel
Save