Merge branch '1.11.x' of https://github.com/chamilo/chamilo-lms into 1.11.x

pull/2487/head
Alex Aragon 8 years ago
commit d3e1ca5559
  1. 1
      app/Resources/public/css/base.css
  2. 5
      app/upload/.htaccess
  3. 97
      main/admin/add_drh_to_user.php
  4. 41
      main/admin/course_add.php
  5. 83
      main/admin/course_edit.php
  6. 42
      main/admin/course_list.php
  7. 114
      main/admin/user_information.php
  8. 109
      main/admin/user_list.php
  9. 11
      main/auth/courses.php
  10. 21
      main/auth/courses_categories.php
  11. 115
      main/auth/courses_controller.php
  12. 6
      main/exercise/TestCategory.php
  13. 4
      main/exercise/UniqueAnswerImage.php
  14. 2
      main/exercise/exercise_show.php
  15. 9
      main/exercise/hotpotatoes.lib.php
  16. 13
      main/exercise/hotpotatoes_exercise_report.php
  17. 113
      main/exercise/hotpotatoes_exercise_result.class.php
  18. 8
      main/exercise/hotspot_actionscript_admin.as.php
  19. 65
      main/exercise/hotspot_lang_conversion.php
  20. 32
      main/exercise/hotspot_save.inc.php
  21. 4
      main/exercise/hotspot_savescore.inc.php
  22. 14
      main/exercise/hotspot_updatescore.inc.php
  23. 2
      main/exercise/matching.class.php
  24. 17
      main/exercise/question_create.php
  25. 21
      main/exercise/recalculate.php
  26. 12
      main/exercise/showinframes.php
  27. 1
      main/exercise/tests_category.php
  28. 16
      main/exercise/unique_answer_no_option.class.php
  29. 16
      main/gradebook/lib/GradebookUtils.php
  30. 49
      main/gradebook/lib/be/abstractlink.class.php
  31. 87
      main/gradebook/lib/be/evaluation.class.php
  32. 1
      main/gradebook/lib/be/linkfactory.class.php
  33. 9
      main/gradebook/lib/be/result.class.php
  34. 42
      main/gradebook/lib/flatview_data_generator.class.php
  35. 33
      main/gradebook/lib/gradebook_data_generator.class.php
  36. 24
      main/gradebook/lib/results_data_generator.class.php
  37. 12
      main/gradebook/lib/scoredisplay.class.php
  38. 54
      main/gradebook/lib/user_data_generator.class.php
  39. 13
      main/gradebook/search.php
  40. BIN
      main/img/icons/22/new_group.png
  41. 38
      main/inc/ajax/user_manager.ajax.php
  42. 6
      main/inc/lib/api.lib.php
  43. 52
      main/inc/lib/course_description.lib.php
  44. 18
      main/inc/lib/document.lib.php
  45. 2
      main/inc/lib/exercise.lib.php
  46. 14
      main/inc/lib/extra_field_value.lib.php
  47. 2
      main/inc/lib/formvalidator/FormValidator.class.php
  48. 80
      main/inc/lib/image.lib.php
  49. 1
      main/inc/lib/javascript/ckeditor/config_js.php
  50. 9
      main/inc/lib/myspace.lib.php
  51. 15
      main/inc/lib/online.inc.php
  52. 19
      main/inc/lib/search/ChamiloIndexer.class.php
  53. 24
      main/inc/lib/search/xapian/XapianIndexer.class.php
  54. 3
      main/inc/lib/sessionmanager.lib.php
  55. 10
      main/inc/lib/skill.lib.php
  56. 28
      main/inc/lib/skill.visualizer.lib.php
  57. 9
      main/inc/lib/social.lib.php
  58. 6
      main/inc/lib/statistics.lib.php
  59. 21
      main/inc/lib/system_announcements.lib.php
  60. 8
      main/inc/lib/template.lib.php
  61. 8
      main/inc/lib/text.lib.php
  62. 759
      main/inc/lib/tracking.lib.php
  63. 150
      main/inc/lib/usermanager.lib.php
  64. 154
      main/install/install.lib.php
  65. 27
      main/lp/learnpath.class.php
  66. 941
      main/lp/learnpathItem.class.php
  67. 80
      main/mySpace/myStudents.php
  68. 2
      main/tracking/courseLog.php
  69. 338
      main/tracking/userlogCSV.php
  70. 47
      main/upload/upload.document.php
  71. 2
      plugin/bbb/lang/french.php
  72. 2
      plugin/sepe/install.php
  73. 2
      plugin/sepe/src/configuration.php
  74. 2
      plugin/sepe/src/identification-data.php
  75. 8
      plugin/sepe/src/sepe.lib.php
  76. 2
      plugin/sepe/src/specialty-classroom-edit.php
  77. 46
      plugin/sepe/ws/Sepe.php
  78. 22
      src/Chamilo/CoreBundle/Entity/CourseCategory.php
  79. 4
      src/Chamilo/CoreBundle/Entity/Repository/CourseCategoryRepository.php
  80. 16
      src/Chamilo/ThemeBundle/Theme/ThemeManager.php
  81. 29
      src/Chamilo/UserBundle/Entity/User.php
  82. 14
      tests/scripts/fix_student_publication_id.php
  83. 18
      tests/scripts/login_as_admin.php

@ -6047,7 +6047,6 @@ ul#toolnavbox-two li a.btn{
-webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
-o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
height: 38px;
}
.select2-container .select2-search--inline .select2-search__field{
margin-top: 3px !important;

@ -1,3 +1,6 @@
<FilesMatch "(?i)\.(php5|php4|php|php3|php2|phtml|pl|py|jsp|asp|sh|cgi)$">
deny from all
# Apache 2.2
#deny from all
# Apache 2.4
Require all denied
</FilesMatch>

@ -0,0 +1,97 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\UserBundle\Entity\User,
Chamilo\CoreBundle\Entity\UserRelUser;
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
if (!isset($_REQUEST['u'])) {
api_not_allowed(true);
}
$em = Database::getManager();
$relationsRepo = $em->getRepository('ChamiloCoreBundle:UserRelUser');
/** @var User $user */
$user = UserManager::getManager()->find($_REQUEST['u']);
if (!$user) {
api_not_allowed(true);
}
$subscribedUsers = $user->getHrm();
$hrmOptions = [];
/** @var UserRelUser $subscribedUser */
foreach ($subscribedUsers as $subscribedUser) {
/** @var User $hrm */
$hrm = UserManager::getManager()->find($subscribedUser->getFriendUserId());
if (!$hrm) {
continue;
}
$hrmOptions[$hrm->getId()] = $hrm->getCompleteNameWithUsername();
}
$form = new FormValidator('assign_hrm');
$form->addUserAvatar('u', get_lang('User'), 'medium');
$form->addSelectAjax(
'hrm',
get_lang('HrmList'),
$hrmOptions,
['multiple' => 'multiple', 'url' => api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=user_by_role']
);
$form->addButtonSave(get_lang('Send'));
$form->setDefaults([
'u' => $user,
'hrm' => array_keys($hrmOptions)
]);
if ($form->validate()) {
/** @var UserRelUser $subscribedUser */
foreach ($subscribedUsers as $subscribedUser) {
$em->remove($subscribedUser);
};
$em->flush();
$values = $form->exportValues();
foreach ($values['hrm'] as $hrmId) {
/** @var User $hrm */
$hrm = UserManager::getManager()->find($hrmId);
if (!$hrm) {
continue;
}
if ($hrm->getStatus() !== DRH) {
continue;
}
UserManager::subscribeUsersToHRManager($hrm->getId(), [$user->getId()], false);
}
Display::addFlash(
Display::return_message(get_lang('AssignedUsersHaveBeenUpdatedSuccessfully'), 'success')
);
header('Location: '.api_get_path(WEB_CODE_PATH).'admin/user_information.php?user_id='.$user->getId());
exit;
}
$interbreadcrumb[] = ['name' => get_lang('PlatformAdmin'), 'url' => 'index.php'];
$interbreadcrumb[] = ['name' => get_lang('UserList'), 'url' => 'user_list.php'];
$interbreadcrumb[] = ['name' => $user->getCompleteName(), 'url' => 'user_information.php?user_id='.$user->getId()];
$toolName = get_lang('AssignHrmToUser');
$view = new Template($toolName);
$view->assign('header', $toolName);
$view->assign('content', $form->returnForm());
$view->display_one_col_template();

@ -78,24 +78,6 @@ $form->addText(
$form->applyFilter('visual_code', 'api_strtoupper');
$form->applyFilter('visual_code', 'html_filter');
$form->addRule(
'visual_code',
get_lang('Max'),
'maxlength',
CourseManager::MAX_COURSE_LENGTH_CODE
);
$form->addElement(
'select',
'course_teachers',
get_lang('CourseTeachers'),
$teachers,
[
'id' => 'course_teachers',
'multiple' => 'multiple'
]
);
$form->applyFilter('course_teachers', 'html_filter');
$countCategories = $courseCategoriesRepo->countAllInAccessUrl($accessUrlId);
@ -116,9 +98,8 @@ if ($countCategories >= 100) {
/** @var CourseCategory $category */
foreach ($categories as $category) {
$categoriesOptions[$category->getCode()] = $category->__toString();
$categoriesOptions[$category->getCode()] = (string) $category;
}
$form->addSelect(
'category_code',
get_lang('CourseFaculty'),
@ -126,6 +107,26 @@ if ($countCategories >= 100) {
);
}
$form->addRule(
'visual_code',
get_lang('Max'),
'maxlength',
CourseManager::MAX_COURSE_LENGTH_CODE
);
$form->addElement(
'select',
'course_teachers',
get_lang('CourseTeachers'),
$teachers,
[
'id' => 'course_teachers',
'multiple' => 'multiple'
]
);
$form->applyFilter('course_teachers', 'html_filter');
// Course department
$form->addText(
'department_name',

@ -143,7 +143,48 @@ $form->addText(
$form->applyFilter('visual_code', 'strtoupper');
$form->applyFilter('visual_code', 'html_filter');
$form->addElement('advmultiselect', 'course_teachers', get_lang('CourseTeachers'), $allTeachers);
$countCategories = $courseCategoriesRepo->countAllInAccessUrl($urlId);
if ($countCategories >= 100) {
// Category code
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_category';
$categorySelect = $form->addElement(
'select_ajax',
'category_code',
get_lang('CourseFaculty'),
null,
['url' => $url]
);
if (!empty($courseInfo['categoryCode'])) {
$data = \CourseCategory::getCategory($courseInfo['categoryCode']);
$categorySelect->addOption($data['name'], $data['code']);
}
} else {
$courseInfo['category_code'] = $courseInfo['categoryCode'];
$categories = $courseCategoriesRepo->findAllInAccessUrl($urlId);
$categoriesOptions = [null => get_lang('None')];
/** @var CourseCategory $category */
foreach ($categories as $category) {
$categoriesOptions[$category->getCode()] = (string) $category;
}
$form->addSelect(
'category_code',
get_lang('CourseFaculty'),
$categoriesOptions
);
}
$form->addElement(
'advmultiselect',
'course_teachers',
get_lang('CourseTeachers'),
$allTeachers
);
$courseInfo['course_teachers'] = $course_teachers;
if (array_key_exists('add_teachers_to_sessions_courses', $courseInfo)) {
$form->addElement(
@ -158,7 +199,10 @@ $coursesInSession = SessionManager::get_session_by_course($courseInfo['real_id']
if (!empty($coursesInSession)) {
foreach ($coursesInSession as $session) {
$sessionId = $session['id'];
$coaches = SessionManager::getCoachesByCourseSession($sessionId, $courseInfo['real_id']);
$coaches = SessionManager::getCoachesByCourseSession(
$sessionId,
$courseInfo['real_id']
);
$teachers = $allTeachers;
$sessionTeachers = array();
@ -191,41 +235,6 @@ if (!empty($coursesInSession)) {
}
}
$countCategories = $courseCategoriesRepo->countAllInAccessUrl($urlId);
if ($countCategories >= 100) {
// Category code
$url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_category';
$categorySelect = $form->addElement(
'select_ajax',
'category_code',
get_lang('CourseFaculty'),
null,
['url' => $url]
);
if (!empty($courseInfo['categoryCode'])) {
$data = \CourseCategory::getCategory($courseInfo['categoryCode']);
$categorySelect->addOption($data['name'], $data['code']);
}
} else {
$courseInfo['category_code'] = $courseInfo['categoryCode'];
$categories = $courseCategoriesRepo->findAllInAccessUrl($urlId);
$categoriesOptions = [null => get_lang('None')];
/** @var CourseCategory $category */
foreach ($categories as $category) {
$categoriesOptions[$category->getCode()] = $category->__toString();
}
$form->addSelect(
'category_code',
get_lang('CourseFaculty'),
$categoriesOptions
);
}
$form->addText('department_name', get_lang('CourseDepartment'), false, array('size' => '60'));
$form->applyFilter('department_name', 'html_filter');
$form->applyFilter('department_name', 'trim');

@ -146,17 +146,15 @@ function get_course_data($from, $number_of_items, $column, $direction)
$res = Database::query($sql);
$courses = array();
$languages = api_get_languages_to_array();
while ($course = Database::fetch_array($res)) {
// Place colour icons in front of courses.
$show_visual_code = $course['visual_code'] != $course[2] ? Display::label($course['visual_code'], 'info') : null;
$course[1] = get_course_visibility_icon($course[8]).'<a href="'.api_get_path(WEB_COURSE_PATH).$course[9].'/index.php">'.$course[1].'</a> '.$show_visual_code;
$course[5] = $course[5] == SUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$course[6] = $course[6] == UNSUBSCRIBE_ALLOWED ? get_lang('Yes') : get_lang('No');
$language = isset($languages[$course[3]]) ? $languages[$course[3]] : $course[3];
$course_rem = array(
$courseItem = array(
$course[0],
$course[1],
$course[2],
@ -166,7 +164,7 @@ function get_course_data($from, $number_of_items, $column, $direction)
$course[6],
$course[7],
);
$courses[] = $course_rem;
$courses[] = $courseItem;
}
return $courses;
@ -258,19 +256,39 @@ function get_course_visibility_icon($v)
$style = 'margin-bottom:0;margin-right:5px;';
switch ($v) {
case 0:
return Display::return_icon('bullet_red.png', get_lang('CourseVisibilityClosed'), array('style' => $style));
return Display::return_icon(
'bullet_red.png',
get_lang('CourseVisibilityClosed'),
array('style' => $style)
);
break;
case 1:
return Display::return_icon('bullet_orange.png', get_lang('Private'), array('style' => $style));
return Display::return_icon(
'bullet_orange.png',
get_lang('Private'),
array('style' => $style)
);
break;
case 2:
return Display::return_icon('bullet_green.png', get_lang('OpenToThePlatform'), array('style' => $style));
return Display::return_icon(
'bullet_green.png',
get_lang('OpenToThePlatform'),
array('style' => $style)
);
break;
case 3:
return Display::return_icon('bullet_blue.png', get_lang('OpenToTheWorld'), array('style' => $style));
return Display::return_icon(
'bullet_blue.png',
get_lang('OpenToTheWorld'),
array('style' => $style)
);
break;
case 4:
return Display::return_icon('bullet_grey.png', get_lang('CourseVisibilityHidden'), array('style' => $style));
return Display::return_icon(
'bullet_grey.png',
get_lang('CourseVisibilityHidden'),
array('style' => $style)
);
break;
default:
return '';
@ -414,7 +432,11 @@ if (isset($_GET['search']) && $_GET['search'] === 'advanced') {
});
</script>';
$actions = Display::toolbarAction('toolbar', [$actions1, $actions2, $actions3, $actions4], [2, 4, 3, 3]);
$actions = Display::toolbarAction(
'toolbar',
[$actions1, $actions2, $actions3, $actions4],
[2, 4, 3, 3]
);
if (isset($_GET['session_id']) && !empty($_GET['session_id'])) {
// Create a sortable table with the course data filtered by session

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\UserBundle\Entity\User,
Chamilo\CoreBundle\Entity\UserRelUser;
/**
* Script showing information about a user (name, e-mail, courses and sessions)
@ -22,6 +24,8 @@ if (empty($user)) {
api_not_allowed(true);
}
/** @var User $userEntity */
$userEntity = api_get_user_entity($user['user_id']);
$myUserId = api_get_user_id();
if (!api_is_student_boss()) {
@ -43,24 +47,29 @@ $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$csvContent = [];
// only allow platform admins to login_as, or session admins only for students (not teachers nor other admins)
$login_as_icon = '';
$editUser = '';
$exportLink = '';
$vCardExportLink = '';
$actions = [
Display::url(
Display::return_icon('statistics.png', get_lang('Reporting'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?'.http_build_query([
'student' => intval($_GET['user_id'])
]),
['title' => get_lang('Reporting')]
)
];
if (api_is_platform_admin()) {
$login_as_icon =
'<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php'
.'?action=login_as&user_id='.$userId.'&'
.'sec_token='.$_SESSION['sec_token'].'">'
.Display::return_icon(
$actions[] = Display::url(
Display::return_icon(
'login_as.png',
get_lang('LoginAs'),
array(),
[],
ICON_SIZE_MEDIUM
).'</a>';
),
api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$userId.'&'
.'sec_token='.$_SESSION['sec_token']
);
$editUser = Display::url(
$actions[] = Display::url(
Display::return_icon(
'edit.png',
get_lang('Edit'),
@ -70,24 +79,28 @@ if (api_is_platform_admin()) {
api_get_path(WEB_CODE_PATH).'admin/user_edit.php?user_id='.$userId
);
$exportLink = Display::url(
$actions[] = Display::url(
Display::return_icon(
'export_csv.png',
get_lang('ExportAsCSV'),
'',
[],
ICON_SIZE_MEDIUM
),
api_get_self().'?user_id='.$userId.'&action=export'
);
$vCardExportLink = Display::url(
$actions[] = Display::url(
Display::return_icon(
'vcard.png',
get_lang('UserInfo'),
'',
[],
ICON_SIZE_MEDIUM
),
api_get_path(WEB_PATH).'main/social/vcard_export.php?userId='.$userId
);
$actions[] = Display::url(
Display::return_icon('new_group.png', get_lang('AddHrmToUser'), [], ICON_SIZE_MEDIUM),
api_get_path(WEB_PATH).'main/admin/add_drh_to_user.php?u='.$userId
);
}
$studentBossList = UserManager::getStudentBossList($userId);
@ -315,7 +328,7 @@ if (count($sessions) > 0) {
$csvContent[] = array_map('strip_tags', $row);
$data[] = $row;
$result = TrackingUserLogCSV::getToolInformation(
$result = Tracking::getToolInformation(
$userId,
$courseInfo,
$id_session
@ -422,7 +435,7 @@ if (Database::num_rows($res) > 0) {
$csvContent[] = array_map('strip_tags', $row);
$data[] = $row;
$result = TrackingUserLogCSV::getToolInformation(
$result = Tracking::getToolInformation(
$userId,
$courseInfo,
0
@ -539,15 +552,7 @@ if (isset($_GET['action'])) {
Display::display_header($tool_name);
echo '<div class="actions">
<a href="'.api_get_path(WEB_CODE_PATH).'mySpace/myStudents.php?student='.intval($_GET['user_id']).'" title="'.get_lang('Reporting').'">'.
Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_MEDIUM).'
</a>
'.$login_as_icon.'
'.$editUser.'
'.$exportLink.'
'.$vCardExportLink.'
</div>';
echo Display::toolbarAction('toolbar-user-information', [implode(PHP_EOL, $actions)]);
echo Display::page_header($tool_name);
$fullUrlBig = UserManager::getUserPicture(
@ -581,6 +586,61 @@ if ($studentBossList) {
echo $studentBossListToString;
}
$hrmList = $userEntity->getHrm();
if ($hrmList) {
echo Display::page_subheader(get_lang('HrmList'));
echo '<div class="row">';
/** @var UserRelUser $hrm */
foreach ($hrmList as $hrm) {
$hrmInfo = api_get_user_info($hrm->getFriendUserId());
$userPicture = isset($hrmInfo["avatar_medium"]) ? $hrmInfo["avatar_medium"] : $hrmInfo["avatar"];
echo '<div class="col-sm-4 col-md-3">';
echo '<div class="media">';
echo '<div class="media-left">';
echo Display::img($userPicture, $hrmInfo['complete_name'], ['class' => 'media-object'], false);
echo '</div>';
echo '<div class="media-body">';
echo '<h4 class="media-heading">'.$hrmInfo['complete_name'].'</h4>';
echo $hrmInfo['username'];
echo '</div>';
echo '</div>';
echo '</div>';
}
echo '</div>';
}
if ($user['status'] == DRH) {
$usersAssigned = UserManager::get_users_followed_by_drh($userId);
if ($usersAssigned) {
echo Display::page_subheader(get_lang('AssignedUsersListToHumanResourcesManager'));
echo '<div class="row">';
foreach ($usersAssigned as $userAssigned) {
$userAssigned = api_get_user_info($userAssigned['user_id']);
$userPicture = isset($userAssigned["avatar_medium"]) ? $userAssigned["avatar_medium"] : $userAssigned["avatar"];
echo '<div class="col-sm-4 col-md-3">';
echo '<div class="media">';
echo '<div class="media-left">';
echo Display::img($userPicture, $userAssigned['complete_name'], ['class' => 'media-object'], false);
echo '</div>';
echo '<div class="media-body">';
echo '<h4 class="media-heading">'.$userAssigned['complete_name'].'</h4>';
echo $userAssigned['username'];
echo '</div>';
echo '</div>';
echo '</div>';
}
echo '</div>';
}
}
if (api_get_setting('allow_social_tool') === 'true') {
echo Display::page_subheader(get_lang('SocialData'));
echo $socialInformation;

@ -156,8 +156,36 @@ $this_section = SECTION_PLATFORM_ADMIN;
if ($action == 'login_as') {
$check = Security::check_token('get');
if (isset($_GET['user_id']) && $check) {
$result = loginUser($_GET['user_id']);
if ($result == false) {
$result = UserManager::loginAsUser($_GET['user_id']);
if ($result) {
$userInfo = api_get_user_info();
$firstname = $userInfo['firstname'];
$lastname = $userInfo['lastname'];
$userId = $userInfo['id'];
if (api_is_western_name_order()) {
$message = sprintf(
get_lang('AttemptingToLoginAs'),
$firstname,
$lastname,
$userId
);
} else {
$message = sprintf(
get_lang('AttemptingToLoginAs'),
$lastname,
$firstname,
$userId
);
}
$target_url = api_get_path(WEB_PATH)."user_portal.php";
$message .= '<br />'.sprintf(get_lang('LoginSuccessfulGoToX'), '<a href="'.$target_url.'">'.$target_url.'</a>');
Display :: display_header(get_lang('UserList'));
echo Display::return_message($message, 'normal', false);
Display :: display_footer();
exit;
} else {
api_not_allowed(true);
}
}
@ -368,83 +396,6 @@ function prepare_user_sql_query($is_count)
return $sql;
}
/**
* Make sure this function is protected because it does NOT check password!
*
* This function defines globals.
* @param int $userId
*
* @return false|null False on failure, redirection on success
* @author Evie Embrechts
* @author Yannick Warnier <yannick.warnier@dokeos.com>
*/
function loginUser($userId)
{
$userId = intval($userId);
$userInfo = api_get_user_info($userId);
// Check if the user is allowed to 'login_as'
$canLoginAs = api_can_login_as($userId);
if (!$canLoginAs || empty($userInfo)) {
return false;
}
$firstname = $userInfo['firstname'];
$lastname = $userInfo['lastname'];
if (api_is_western_name_order()) {
$message = sprintf(
get_lang('AttemptingToLoginAs'),
$firstname,
$lastname,
$userId
);
} else {
$message = sprintf(
get_lang('AttemptingToLoginAs'),
$lastname,
$firstname,
$userId
);
}
if ($userId) {
// Logout the current user
LoginDelete(api_get_user_id());
Session::erase('_user');
Session::erase('is_platformAdmin');
Session::erase('is_allowedCreateCourse');
Session::erase('_uid');
// Cleaning session variables
$_user['firstName'] = $userInfo['firstname'];
$_user['lastName'] = $userInfo['lastname'];
$_user['mail'] = $userInfo['email'];
$_user['official_code'] = $userInfo['official_code'];
$_user['picture_uri'] = $userInfo['picture_uri'];
$_user['user_id'] = $userId;
$_user['id'] = $userId;
$_user['status'] = $userInfo['status'];
// Filling session variables with new data
Session::write('_uid', $userId);
Session::write('_user', $userInfo);
Session::write('is_platformAdmin', (bool) (UserManager::is_admin($userId)));
Session::write('is_allowedCreateCourse', (bool) ($userInfo['status'] == 1));
// will be useful later to know if the user is actually an admin or not (example reporting)
Session::write('login_as', true);
$target_url = api_get_path(WEB_PATH)."user_portal.php";
$message .= '<br />'.sprintf(get_lang('LoginSuccessfulGoToX'), '<a href="'.$target_url.'">'.$target_url.'</a>');
Display :: display_header(get_lang('UserList'));
echo Display::return_message($message, 'normal', false);
Display :: display_footer();
exit;
}
}
/**
* Get the total number of users on the platform
* @see SortableTable#get_total_number_of_items()

@ -62,6 +62,7 @@ if (isset($_GET['action']) && in_array($_GET['action'], $actions)) {
}
$categoryCode = isset($_GET['category_code']) && !empty($_GET['category_code']) ? $_GET['category_code'] : 'ALL';
$searchTerm = isset($_REQUEST['search_term']) ? Security::remove_XSS($_REQUEST['search_term']) : '';
$nameTools = CourseCategory::getCourseCatalogNameTools($action);
if (empty($nameTools)) {
@ -145,13 +146,14 @@ if (isset($_POST['create_course_category']) &&
if (isset($_REQUEST['search_course'])) {
if ($ctok == $_REQUEST['sec_token']) {
$courses_controller->search_courses(
$_REQUEST['search_term'],
$searchTerm,
null,
null,
null,
$limit,
true
);
exit;
}
}
@ -160,7 +162,7 @@ if (isset($_REQUEST['subscribe_course'])) {
if ($ctok == $_GET['sec_token']) {
$courses_controller->subscribe_user(
$_GET['subscribe_course'],
$_GET['search_term'],
$searchTerm,
$categoryCode
);
}
@ -168,11 +170,10 @@ if (isset($_REQUEST['subscribe_course'])) {
// We are unsubscribing from a course (=Unsubscribe from course).
if (isset($_GET['unsubscribe'])) {
$search_term = isset($_GET['search_term']) ? $_GET['search_term'] : null;
if ($ctok == $_GET['sec_token']) {
$courses_controller->unsubscribe_user_from_course(
$_GET['unsubscribe'],
$search_term,
$searchTerm,
$categoryCode
);
}
@ -188,7 +189,7 @@ switch ($action) {
case 'subscribe_user_with_password':
$courses_controller->subscribe_user(
isset($_POST['subscribe_user_with_password']) ? $_POST['subscribe_user_with_password'] : '',
isset($_POST['search_term']) ? $_POST['search_term'] : '',
$searchTerm,
isset($_POST['category_code']) ? $_POST['category_code'] : ''
);
break;

@ -19,7 +19,7 @@ $pageCurrent = isset($pageCurrent) ? $pageCurrent : isset($_GET['pageCurrent'])
$pageLength = isset($pageLength) ? $pageLength : isset($_GET['pageLength']) ? intval($_GET['pageLength']) : CoursesAndSessionsCatalog::PAGE_LENGTH;
$pageTotal = intval(ceil(intval($countCoursesInCategory) / $pageLength));
$cataloguePagination = $pageTotal > 1 ? CourseCategory::getCatalogPagination($pageCurrent, $pageLength, $pageTotal) : '';
$search_term = isset($search_term) ? $search_term : null;
$searchTerm = isset($_REQUEST['search_term']) ? Security::remove_XSS($_REQUEST['search_term']) : '';
if ($showSessions && isset($_POST['date'])) {
$date = $_POST['date'];
@ -78,7 +78,7 @@ $code = isset($code) ? $code : null;
<input class="form-control" type="text" name="search_term"
value="<?php echo(empty($_POST['search_term'])
? ''
: api_htmlentities(Security::remove_XSS($_POST['search_term']))); ?>"/>
: api_htmlentities($searchTerm)); ?>"/>
<div class="input-group-btn">
<button class="btn btn-default" type="submit">
<em class="fa fa-search"></em> <?php echo get_lang('Search'); ?>
@ -112,8 +112,7 @@ $code = isset($code) ? $code : null;
$categoryCode = $category['code'];
$countCourse = $category['count_courses'];
$form .= '<option '.($categoryCode == $codeType ? 'selected="selected" ' : '')
.' value="'
.$category['code'].'">'.$category['name'].' ( '.$countCourse.' ) </option>';
.' value="'.$category['code'].'">'.$category['name'].' ('.$countCourse.') </option>';
if (!empty($browse_course_categories[$categoryCode])) {
foreach ($browse_course_categories[$categoryCode] as $subCategory) {
$subCategoryCode = $subCategory['code'];
@ -121,9 +120,7 @@ $code = isset($code) ? $code : null;
.($subCategoryCode == $codeType
? 'selected="selected" '
: '')
.' value="'.$subCategory['code'].'">---'.$subCategory['name'].' ( '
.$subCategory['count_courses']
.' )</option>';
.' value="'.$subCategory['code'].'">---'.$subCategory['name'].' ('.$subCategory['count_courses'].')</option>';
}
}
}
@ -161,8 +158,8 @@ if ($showCourses && $action != 'display_sessions') {
echo $content;
}
if (!empty($search_term)) {
echo "<p><strong>".get_lang('SearchResultsFor')." ".Security::remove_XSS($_POST['search_term'])."</strong><br />";
if (!empty($searchTerm)) {
echo "<p><strong>".get_lang('SearchResultsFor')." ".$searchTerm."</strong><br />";
}
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
@ -205,7 +202,7 @@ if ($showCourses && $action != 'display_sessions') {
$html .= returnThumbnail($course, $userRegistered);
$separator = null;
$subscribeButton = return_register_button($course, $stok, $code, $search_term);
$subscribeButton = return_register_button($course, $stok, $code, $searchTerm);
// start buycourse validation
// display the course price and buy button if the buycourses plugin is enabled and this course is configured
@ -242,13 +239,13 @@ if ($showCourses && $action != 'display_sessions') {
$html .= return_already_registered_label('student');
if (!$course_closed) {
if ($course_unsubscribe_allowed) {
$html .= return_unregister_button($course, $stok, $search_term, $code);
$html .= return_unregister_button($course, $stok, $searchTerm, $code);
}
}
} elseif ($userRegisteredInCourseAsTeacher) {
// if user registered as teacher
if ($course_unsubscribe_allowed) {
$html .= return_unregister_button($course, $stok, $search_term, $code);
$html .= return_unregister_button($course, $stok, $searchTerm, $code);
}
} else {
// if user not registered in the course

@ -101,14 +101,21 @@ class CoursesController
$data['countCoursesInCategory'] = $this->model->count_courses_in_category($category_code);
if ($action === 'display_random_courses') {
// Random value is used instead limit filter
$data['browse_courses_in_category'] = $this->model->browse_courses_in_category(null, 12);
$data['browse_courses_in_category'] = $this->model->browse_courses_in_category(
null,
12
);
$data['countCoursesInCategory'] = count($data['browse_courses_in_category']);
} else {
if (!isset($category_code)) {
$category_code = $browse_course_categories[0][1]['code']; // by default first category
}
$limit = isset($limit) ? $limit : CourseCategory::getLimitArray();
$data['browse_courses_in_category'] = $this->model->browse_courses_in_category($category_code, null, $limit);
$data['browse_courses_in_category'] = $this->model->browse_courses_in_category(
$category_code,
null,
$limit
);
}
$data['browse_course_categories'] = $browse_course_categories;
@ -170,10 +177,16 @@ class CoursesController
$data = array();
$limit = !empty($limit) ? $limit : CourseCategory::getLimitArray();
$browse_course_categories = $this->model->browse_course_categories();
$data['countCoursesInCategory'] = $this->model->count_courses_in_category('ALL', $search_term);
$data['browse_courses_in_category'] = $this->model->search_courses($search_term, $limit, $justVisible);
$data['browse_course_categories'] = $browse_course_categories;
$data['countCoursesInCategory'] = $this->model->count_courses_in_category(
'ALL',
$search_term
);
$data['browse_courses_in_category'] = $this->model->search_courses(
$search_term,
$limit,
$justVisible
);
$data['browse_course_categories'] = $browse_course_categories;
$data['search_term'] = Security::remove_XSS($search_term); //filter before showing in template
// getting all the courses to which the user is subscribed to
@ -254,9 +267,16 @@ class CoursesController
{
$result = $this->model->store_course_category($category_title);
if ($result) {
Display::addFlash(Display::return_message(get_lang('CourseCategoryStored')));
Display::addFlash(
Display::return_message(get_lang('CourseCategoryStored'))
);
} else {
Display::addFlash(Display::return_message(get_lang('ACourseCategoryWithThisNameAlreadyExists'), 'error'));
Display::addFlash(
Display::return_message(
get_lang('ACourseCategoryWithThisNameAlreadyExists'),
'error'
)
);
}
$action = 'sortmycourses';
$this->courses_list($action);
@ -275,7 +295,9 @@ class CoursesController
$result = $this->model->updateCourseCategory($courseId, $category_id);
if ($result) {
Display::addFlash(Display::return_message(get_lang('EditCourseCategorySucces')));
Display::addFlash(
Display::return_message(get_lang('EditCourseCategorySucces'))
);
}
$action = 'sortmycourses';
$this->courses_list($action);
@ -292,7 +314,9 @@ class CoursesController
{
$result = $this->model->move_course($move, $course_code, $category_id);
if ($result) {
Display::addFlash(Display::return_message(get_lang('CourseSortingDone')));
Display::addFlash(
Display::return_message(get_lang('CourseSortingDone'))
);
}
$action = 'sortmycourses';
$this->courses_list($action);
@ -308,7 +332,9 @@ class CoursesController
{
$result = $this->model->move_category($move, $category_id);
if ($result) {
Display::addFlash(Display::return_message(get_lang('CategorySortingDone')));
Display::addFlash(
Display::return_message(get_lang('CategorySortingDone'))
);
}
$action = 'sortmycourses';
$this->courses_list($action);
@ -324,7 +350,9 @@ class CoursesController
{
$result = $this->model->store_edit_course_category($title, $category);
if ($result) {
Display::addFlash(Display::return_message(get_lang('CourseCategoryEditStored')));
Display::addFlash(
Display::return_message(get_lang('CourseCategoryEditStored'))
);
}
$action = 'sortmycourses';
$this->courses_list($action);
@ -339,7 +367,9 @@ class CoursesController
{
$result = $this->model->delete_course_category($category_id);
if ($result) {
Display::addFlash(Display::return_message(get_lang('CourseCategoryDeleted')));
Display::addFlash(
Display::return_message(get_lang('CourseCategoryDeleted'))
);
}
$action = 'sortmycourses';
$this->courses_list($action);
@ -352,21 +382,30 @@ class CoursesController
* @param string $search_term
* @param string $category_code
*/
public function unsubscribe_user_from_course($course_code, $search_term = null, $category_code = null)
{
public function unsubscribe_user_from_course(
$course_code,
$search_term = null,
$category_code = null
) {
$result = $this->model->remove_user_from_course($course_code);
$message = '';
$error = '';
if ($result) {
Display::addFlash(Display::return_message(get_lang('YouAreNowUnsubscribed')));
Display::addFlash(
Display::return_message(get_lang('YouAreNowUnsubscribed'))
);
}
$action = 'sortmycourses';
if (!empty($search_term)) {
$this->search_courses($search_term, $message, $error);
} else {
$this->courses_categories('subcribe', $category_code, $message, $error);
$this->courses_categories(
'subcribe',
$category_code,
$message,
$error
);
}
}
@ -390,19 +429,21 @@ class CoursesController
$html .= '<li>';
$categoryLink = CourseCategory::getCourseCategoryUrl(
1,
$limit['length'],
$categoryCode,
$hiddenLinks,
$action
);
if ($code == $categoryCode) {
$html .= '<strong>';
$html .= "$categoryName ($categoryCourses)";
$html .= '</strong>';
} else {
if (!empty($categoryCourses)) {
$html .= '<a href="'.CourseCategory::getCourseCategoryUrl(
1,
$limit['length'],
$categoryCode,
$hiddenLinks,
$action
).'">';
$html .= '<a href="'.$categoryLink.'">';
$html .= "$categoryName ($categoryCourses)";
$html .= '</a>';
} else {
@ -421,13 +462,7 @@ class CoursesController
if ($code == $subCategory1Code) {
$html .= "<strong>$subCategory1Name ($subCategory1Courses)</strong>";
} else {
$html .= '<a href="'.CourseCategory::getCourseCategoryUrl(
1,
$limit['length'],
$categoryCode,
$hiddenLinks,
$action
).'">';
$html .= '<a href="'.$categoryLink.'">';
$html .= "$subCategory1Name ($subCategory1Courses)";
$html .= '</a>';
}
@ -445,13 +480,7 @@ class CoursesController
if ($code == $subCategory2Code) {
$html .= "<strong>$subCategory2Name ($subCategory2Courses)</strong>";
} else {
$html .= '<a href="'.CourseCategory::getCourseCategoryUrl(
1,
$limit['length'],
$categoryCode,
$hiddenLinks,
$action
).'">';
$html .= '<a href="'.$categoryLink.'">';
$html .= "$subCategory2Name ($subCategory2Courses)";
$html .= '</a>';
}
@ -469,13 +498,7 @@ class CoursesController
if ($code == $subCategory3Code) {
$html .= "<strong>$subCategory3Name ($subCategory3Courses)</strong>";
} else {
$html .= '<a href="'.CourseCategory::getCourseCategoryUrl(
1,
$limit['length'],
$categoryCode,
$hiddenLinks,
$action
).'">';
$html .= '<a href="'.$categoryLink.'">';
$html .= "$subCategory3Name ($subCategory3Courses)";
$html .= '</a>';
}

@ -745,8 +745,10 @@ class TestCategory
*
* @return string
*/
public static function get_stats_table_by_attempt($exerciseId, $category_list = array())
{
public static function get_stats_table_by_attempt(
$exerciseId,
$category_list = array()
) {
if (empty($category_list)) {
return null;
}

@ -220,7 +220,8 @@ class UniqueAnswerImage extends UniqueAnswer
$selectQuestion
);
$group['url'.$i] = $form->createElement(
'text', 'url'.$i,
'text',
'url'.$i,
get_lang('Other').': ',
array(
'class' => 'col-md-2',
@ -317,7 +318,6 @@ class UniqueAnswerImage extends UniqueAnswer
{
$destinationStr.=$destination_id.';';
} */
$goodAnswer = $correct == $i ? true : false;
if ($goodAnswer) {
$nbrGoodAnswers++;

@ -801,7 +801,7 @@ foreach ($questionList as $questionId) {
}
} else {
foreach ($model['score_list'] as $item) {
$i = api_number_format($item['score_to_qualify']/100 * $questionWeighting, 2);
$i = api_number_format($item['score_to_qualify'] / 100 * $questionWeighting, 2);
$model = ExerciseLib::getModelStyle($item, $i);
echo '<option value="'.$i.'" '.(($i == $questionScore) ? "selected='selected'" : '').'>'.$model.'</option>';
}

@ -14,7 +14,8 @@ $dbTable = Database::get_course_table(TABLE_DOCUMENT);
/**
* Creates a hotpotato directory.
*
* If a directory of that name already exists, don't create any. If a file of that name exists, remove it and create a directory.
* If a directory of that name already exists, don't create any.
* If a file of that name exists, remove it and create a directory.
* @param string $base_work_dir Wanted path
* @return boolean Always true so far
*/
@ -95,7 +96,9 @@ function GetComment($path, $courseCode = '')
* Sets the comment in the database for a particular path.
* @param string $path File path
* @param string $comment Comment to set
* @return Doctrine\DBAL\Driver\Statement|null Result of the database operation (Database::query will output some message directly on error anyway)
* @return Doctrine\DBAL\Driver\Statement|null
* Result of the database operation
* (Database::query will output some message directly on error anyway)
*/
function SetComment($path, $comment)
{
@ -346,7 +349,7 @@ function GenerateHpFolder($folder)
if (is_dir($full_name)) {
$filelist[] = $file;
}
}
}
}
}
}

@ -290,10 +290,17 @@ function exportExcel() {
$(function() {
<?php
echo Display::grid_js('results', $url, $columns, $column_model, $extra_params, array(), $action_links, true);
echo Display::grid_js(
'results',
$url,
$columns,
$column_model,
$extra_params,
array(),
$action_links,
true
);
if ($is_allowedToEdit || $is_tutor) { ?>
//setSearchSelect("status");
//
//view:true, del:false, add:false, edit:false, excel:true}

@ -19,6 +19,7 @@ class HotpotatoesExerciseResult
* @param string The document path (for HotPotatoes retrieval)
* @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
* @param string $document_path
* @return bool
*/
public function getExercisesReporting($document_path, $hotpotato_name)
{
@ -226,17 +227,37 @@ class HotpotatoesExerciseResult
}
if ($with_column_user) {
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Email')
);
$column++;
if (api_is_western_name_order()) {
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('FirstName')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('LastName')
);
$column++;
} else {
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('LastName')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('FirstName')
);
$column++;
}
}
@ -267,19 +288,47 @@ class HotpotatoesExerciseResult
}
}
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Title')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('StartDate')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('EndDate')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')');
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Duration').' ('.get_lang('MinMinutes').')'
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Score')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Total')
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status'));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
get_lang('Status')
);
$line++;
foreach ($this->results as $row) {
@ -298,14 +347,46 @@ class HotpotatoesExerciseResult
$column++;
if (api_is_western_name_order()) {
$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
api_html_entity_decode(
strip_tags($row['first_name']),
ENT_QUOTES,
$charset
)
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
api_html_entity_decode(
strip_tags($row['last_name']),
ENT_QUOTES,
$charset
)
);
$column++;
} else {
$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
api_html_entity_decode(
strip_tags($row['last_name']),
ENT_QUOTES,
$charset
)
);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$worksheet->setCellValueByColumnAndRow(
$column,
$line,
api_html_entity_decode(
strip_tags($row['first_name']),
ENT_QUOTES,
$charset
)
);
$column++;
}
}

@ -97,10 +97,10 @@ for ($i = 1; $i <= $nbrAnswers; $i++) {
}*/
}
// This is a good answer, count + 1 for nmbr of clicks
if ($answers['weighting'][$i] > 0) {
$nmbrTries++;
}
// This is a good answer, count + 1 for nmbr of clicks
if ($answers['weighting'][$i] > 0) {
$nmbrTries++;
}
$hotSpot['coord'] = $answers['hotspot_coordinates'][$i];
$data['hotspots'][] = $hotSpot;

@ -1,58 +1,51 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Hotspot language conversion
* @package chamilo.exercise
* @author
* Hotspot language conversion
* @package chamilo.exercise
* @author
* @deprecated ?
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
/**
* Code
* @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
*/
require_once __DIR__.'/../inc/global.inc.php';
$hotspot_lang_file = api_get_path(SYS_LANG_PATH);
if (isset($_GET['lang'])) {
//$search = array('../','\\0','\\');
$lang = urldecode($_GET['lang']);
if (preg_match('/^[a-zA-Z0-9\._-]+$/', $lang)) {
//$lang = str_replace($search,$replace,urldecode($_GET['lang']));
if (file_exists($hotspot_lang_file.$lang.'/hotspot.inc.php'))
$hotspot_lang_file .= $lang.'/hotspot.inc.php';
else
$hotspot_lang_file .= 'english/hotspot.inc.php';
} else {
$hotspot_lang_file .= 'english/hotspot.inc.php';
}
//$search = array('../','\\0','\\');
$lang = urldecode($_GET['lang']);
if (preg_match('/^[a-zA-Z0-9\._-]+$/', $lang)) {
//$lang = str_replace($search,$replace,urldecode($_GET['lang']));
if (file_exists($hotspot_lang_file.$lang.'/hotspot.inc.php')) {
$hotspot_lang_file .= $lang.'/hotspot.inc.php';
} else {
$hotspot_lang_file .= 'english/hotspot.inc.php';
}
} else {
$hotspot_lang_file .= 'english/hotspot.inc.php';
}
} else {
$hotspot_lang_file .= 'english/hotspot.inc.php';
$hotspot_lang_file .= 'english/hotspot.inc.php';
}
$file = file($hotspot_lang_file);
$temp = array();
foreach ($file as $value)
{
$explode = explode('=', $value);
foreach ($file as $value) {
$explode = explode('=', $value);
if (count($explode) > 1)
{
$explode[0] = trim($explode[0]);
$explode[0] = '&'.substr($explode[0], 1, strlen($explode[0]));
if (count($explode) > 1) {
$explode[0] = trim($explode[0]);
$explode[0] = '&'.substr($explode[0], 1, strlen($explode[0]));
$explode[1] = trim($explode[1]);
$explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1);
$explode[1] = str_replace('"', '', $explode[1]);
$explode[1] = trim($explode[1]);
$explode[1] = substr($explode[1], 0, strlen($explode[1]) - 1);
$explode[1] = str_replace('"', '', $explode[1]);
$temp[] = $explode[0].'='.$explode[1];
}
$temp[] = $explode[0].'='.$explode[1];
}
}
foreach ($temp as $value)
{
echo $value.' ';
foreach ($temp as $value) {
echo $value.' ';
}
?>

@ -15,24 +15,24 @@ $questionId = intval($_GET['questionId']);
$answerId = intval($_GET['answerId']);
if ($_GET['type'] == "square" || $_GET['type'] == "circle") {
$hotspot_type = $_GET['type'];
$hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height'];
$hotspot_type = $_GET['type'];
$hotspot_coordinates = $_GET['x'].";".$_GET['y']."|".$_GET['width']."|".$_GET['height'];
}
if ($_GET['type'] == "poly" || $_GET['type'] == "delineation" || $_GET['type'] == "oar") {
$hotspot_type = $_GET['type'];
$tmp_coord = explode(",", $_GET['co']);
$i = 0;
$hotspot_coordinates = "";
foreach ($tmp_coord as $coord) {
if ($i % 2 == 0) {
$delimiter = ";";
} else {
$delimiter = "|";
}
$hotspot_coordinates .= $coord.$delimiter;
$i++;
}
$hotspot_coordinates = api_substr($hotspot_coordinates, 0, -2);
$hotspot_type = $_GET['type'];
$tmp_coord = explode(",", $_GET['co']);
$i = 0;
$hotspot_coordinates = "";
foreach ($tmp_coord as $coord) {
if ($i % 2 == 0) {
$delimiter = ";";
} else {
$delimiter = "|";
}
$hotspot_coordinates .= $coord.$delimiter;
$i++;
}
$hotspot_coordinates = api_substr($hotspot_coordinates, 0, -2);
}
$course_id = api_get_course_int_id();
$sql = "UPDATE $TBL_ANSWER SET

@ -25,8 +25,8 @@ if ($_GET['answerId'] == "0") {
// user clicked ON a hotspot
$hit = 1;
$answerId = api_substr($_GET['answerId'], 22, 2);
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
}
//round-up the coordinates
$coords = explode('/', $coordinates);

@ -20,16 +20,16 @@ $hotspotId = $_GET['hotspotId'];
$exerciseId = $objExercise->selectId();
if ($_GET['answerId'] == "0") { // click is NOT on a hotspot
$hit = 0;
$answerId = $hotspotId;
$answerId = $hotspotId;
// remove from session
unset($_SESSION['exerciseResult'][$questionId][$answerId]);
// remove from session
unset($_SESSION['exerciseResult'][$questionId][$answerId]);
} else { // user clicked ON a hotspot
$hit = 1;
$answerId = $hotspotId;
$hit = 1;
$answerId = $hotspotId;
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
// Save into session
$_SESSION['exerciseResult'][$questionId][$answerId] = $hit;
}
//round-up the coordinates

@ -63,7 +63,7 @@ class Matching extends Question
$nb_matches++;
$nb_options++;
}
} else if (!empty($this->id)) {
} elseif (!empty($this->id)) {
if (count($answer->nbrAnswers) > 0) {
$nb_matches = $nb_options = 0;
for ($i = 1; $i <= $answer->nbrAnswers; $i++) {

@ -51,17 +51,17 @@ $sql = "SELECT id,title,type,description, results_disabled
$result = Database::query($sql);
$exercises['-'] = '-'.get_lang('SelectExercise').'-';
while ($row = Database :: fetch_array($result)) {
$exercises[$row['id']] = cut($row['title'], EXERCISE_MAX_NAME_SIZE);
$exercises[$row['id']] = cut($row['title'], EXERCISE_MAX_NAME_SIZE);
}
$form->addElement('select', 'exercise', get_lang('Exercise'), $exercises);
// generate default content
$form->addElement(
'checkbox',
'is_content',
null,
get_lang('GenerateDefaultContent'),
array('checked' => true)
'checkbox',
'is_content',
null,
get_lang('GenerateDefaultContent'),
array('checked' => true)
);
// the submit button
@ -93,7 +93,7 @@ if ($form->validate()) {
}
header('Location: admin.php?exerciseId='.$values['exercise'].'&newQuestion=yes&isContent='.$values['is_content'].'&answerType='.$answer_type);
exit;
} else {
} else {
// header
Display::display_header($nameTools);
@ -108,7 +108,8 @@ if ($form->validate()) {
Display::display_footer();
}
function check_question_type($parameter) {
function check_question_type($parameter)
{
$question_list = Question::get_question_type_list();
foreach ($question_list as $key => $value) {
$valid_question_types[] = $key;

@ -21,24 +21,23 @@ $trackedExercise = $em
->getRepository('ChamiloCoreBundle:TrackEExercises')
->find(intval($_REQUEST['id']));
if (
$trackedExercise->getExeUserId() != intval($_REQUEST['user']) ||
if ($trackedExercise->getExeUserId() != intval($_REQUEST['user']) ||
$trackedExercise->getExeExoId() != intval($_REQUEST['exercise'])
) {
api_not_allowed(true);
exit;
}
$attemps = $em->getRepository('ChamiloCoreBundle:TrackEAttempt')
$attempts = $em->getRepository('ChamiloCoreBundle:TrackEAttempt')
->findBy([
'exeId' => $trackedExercise->getExeId(),
'userId' => $trackedExercise->getExeUserId()
]);
$newResult = 0;
foreach ($attemps as $attemp) {
$questionId = $attemp->getQuestionId();
/** @var \Chamilo\CoreBundle\Entity\TrackEAttempt $attempt */
foreach ($attempts as $attempt) {
$questionId = $attempt->getQuestionId();
$question = $em->find('ChamiloCourseBundle:CQuizQuestion', $questionId);
@ -52,20 +51,16 @@ foreach ($attemps as $attemp) {
]);
$newMarks = 0;
foreach ($answers as $answer) {
if ($answer->getId() != $attemp->getAnswer()) {
if ($answer->getId() != $attempt->getAnswer()) {
continue;
}
$newMarks += $answer->getPonderation();
}
$newResult += $newMarks;
$attemp->setMarks($newMarks);
$em->merge($attemp);
$attempt->setMarks($newMarks);
$em->merge($attempt);
}
$trackedExercise->setExeResult($newResult);

@ -2,9 +2,9 @@
/* For licensing terms, see /license.txt */
/**
* Code library for HotPotatoes integration.
* @package chamilo.exercise
* @author Istvan Mandak
* Code library for HotPotatoes integration.
* @package chamilo.exercise
* @author Istvan Mandak
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -28,10 +28,10 @@ my_delete($full_file_path.$user_id.'.t.html');
$content = ReadFileCont($full_file_path.$user_id.'.t.html');
if ($content == '') {
$content = ReadFileCont($full_file_path);
$content = ReadFileCont($full_file_path);
// Do not move this like:
$mit = "function Finish(){";
$js_content = "
$mit = "function Finish(){";
$js_content = "
// Code added - start
var SaveScoreVariable = 0;
function mySaveScore() {

@ -5,6 +5,7 @@
hubert.borderiou
Manage tests category page
*/
$htmlHeadXtra[] = '
<script>
function confirmDelete(in_txt, in_id) {

@ -397,19 +397,19 @@ class UniqueAnswerNoOption extends Question
// sets the total weighting of the question
$this->updateWeighting($questionWeighting);
$this->save($exercise);
}
}
/**
* @inheritdoc
*/
public function return_header($exercise, $counter = null, $score = null)
public function return_header($exercise, $counter = null, $score = null)
{
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang("Choice").'</th>
<th>'.get_lang("ExpectedChoice").'</th>
<th>'.get_lang("Answer").'</th>';
$header = parent::return_header($exercise, $counter, $score);
$header .= '<table class="'.$this->question_table_class.'">
<tr>
<th>'.get_lang("Choice").'</th>
<th>'.get_lang("ExpectedChoice").'</th>
<th>'.get_lang("Answer").'</th>';
$header .= '<th>'.get_lang("Comment").'</th>';
$header .= '</tr>';

@ -482,8 +482,14 @@ class GradebookUtils
* @param null $mainCourseCategory
* @return array
*/
public static function get_printable_data($cat, $users, $alleval, $alllinks, $params, $mainCourseCategory = null)
{
public static function get_printable_data(
$cat,
$users,
$alleval,
$alllinks,
$params,
$mainCourseCategory = null
) {
$datagen = new FlatViewDataGenerator(
$users,
$alleval,
@ -684,8 +690,10 @@ class GradebookUtils
* @param int $cat_id The category id
* @return array
*/
public static function get_list_gradebook_certificates_by_user_id($user_id, $cat_id = null)
{
public static function get_list_gradebook_certificates_by_user_id(
$user_id,
$cat_id = null
) {
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql = 'SELECT
gc.score_certificate,

@ -27,6 +27,46 @@ abstract class AbstractLink implements GradebookItem
public $course_id;
public $studentList;
/**
* @return bool
*/
abstract function has_results();
/**
* @return string
*/
abstract function get_link();
/**
* @return bool
*/
abstract function is_valid_link();
/**
* @return string
*/
abstract function get_type_name();
/**
* @return bool
*/
abstract function needs_name_and_description();
/**
* @return bool
*/
abstract function needs_max();
/**
* @return bool
*/
abstract function needs_results();
/**
* @return bool
*/
abstract function is_allowed_to_change_name();
/**
* Constructor
*/
@ -485,6 +525,7 @@ abstract class AbstractLink implements GradebookItem
/**
* Internal function used by get_target_categories()
* @param integer $level
* @return array
*/
private function add_target_subcategories($targets, $level, $catid)
{
@ -551,14 +592,6 @@ abstract class AbstractLink implements GradebookItem
return 'link';
}
abstract function has_results();
abstract function get_link();
abstract function is_valid_link();
abstract function get_type_name();
abstract function needs_name_and_description();
abstract function needs_max();
abstract function needs_results();
abstract function is_allowed_to_change_name();
/* Seems to be not used anywhere */
public function get_not_created_links()

@ -221,8 +221,8 @@ class Evaluation implements GradebookItem
$visible = null,
$locked = null
) {
$tbl_grade_evaluations = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql = 'SELECT * FROM '.$tbl_grade_evaluations;
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql = 'SELECT * FROM '.$table;
$paramcount = 0;
if (isset($id)) {
@ -231,36 +231,51 @@ class Evaluation implements GradebookItem
}
if (isset($user_id)) {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
if ($paramcount != 0) {
$sql .= ' AND';
} else {
$sql .= ' WHERE';
}
$sql .= ' user_id = '.intval($user_id);
$paramcount++;
}
if (isset($course_code) && $course_code <> '-1') {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
if ($paramcount != 0) {
$sql .= ' AND';
} else {
$sql .= ' WHERE';
}
$sql .= " course_code = '".Database::escape_string($course_code)."'";
$paramcount++;
}
if (isset($category_id)) {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
if ($paramcount != 0) {
$sql .= ' AND';
} else {
$sql .= ' WHERE';
}
$sql .= ' category_id = '.intval($category_id);
$paramcount++;
}
if (isset($visible)) {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
if ($paramcount != 0) {
$sql .= ' AND';
} else {
$sql .= ' WHERE';
}
$sql .= ' visible = '.intval($visible);
$paramcount++;
}
if (isset($locked)) {
if ($paramcount != 0) $sql .= ' AND';
else $sql .= ' WHERE';
if ($paramcount != 0) {
$sql .= ' AND';
} else {
$sql .= ' WHERE';
}
$sql .= ' locked = '.intval($locked);
}
@ -312,9 +327,9 @@ class Evaluation implements GradebookItem
isset($this->eval_max) &&
isset($this->visible)
) {
$tbl_grade_evaluations = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql = 'INSERT INTO '.$tbl_grade_evaluations
$sql = 'INSERT INTO '.$table
.' (name, user_id, weight, max, visible';
if (isset($this->description)) {
$sql .= ',description';
@ -635,10 +650,9 @@ class Evaluation implements GradebookItem
// -> movable to root or other course independent categories
// - evaluation inside a course
// -> movable to root, independent categories or categories inside the course
$user = (api_is_platform_admin() ? null : api_get_user_id());
$user = api_is_platform_admin() ? null : api_get_user_id();
$targets = array();
$level = 0;
$root = array(0, get_lang('RootCat'), $level);
$targets[] = $root;
@ -646,14 +660,22 @@ class Evaluation implements GradebookItem
$crscats = Category::load(null, null, $this->course_code, 0);
foreach ($crscats as $cat) {
$targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
$targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
$targets = $this->add_target_subcategories(
$targets,
$level + 1,
$cat->get_id()
);
}
}
$indcats = Category::load(null, $user, 0, 0);
foreach ($indcats as $cat) {
$targets[] = array($cat->get_id(), $cat->get_name(), $level + 1);
$targets = $this->add_target_subcategories($targets, $level + 1, $cat->get_id());
$targets = $this->add_target_subcategories(
$targets,
$level + 1,
$cat->get_id()
);
}
return $targets;
@ -733,16 +755,17 @@ class Evaluation implements GradebookItem
public function get_not_subscribed_students($first_letter_user = '')
{
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_grade_results = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'SELECT user_id,lastname,firstname,username FROM '.$tbl_user
." WHERE lastname LIKE '".Database::escape_string($first_letter_user)."%'"
.' AND status = '.STUDENT
.' AND user_id NOT IN'
.' (SELECT user_id FROM '.$tbl_grade_results
.' WHERE evaluation_id = '.intval($this->id)
.' )'
.' ORDER BY lastname';
$sql = "SELECT user_id,lastname,firstname,username
FROM $tbl_user
WHERE
lastname LIKE '".Database::escape_string($first_letter_user)."%' AND
status = ".STUDENT." AND user_id NOT IN (
SELECT user_id FROM $table
WHERE evaluation_id = ".intval($this->id)."
)
ORDER BY lastname";
$result = Database::query($sql);
$users = Database::store_result($result);
@ -759,7 +782,10 @@ class Evaluation implements GradebookItem
public function find_evaluations($name_mask, $selectcat)
{
$rootcat = Category::load($selectcat);
$evals = $rootcat[0]->get_evaluations((api_is_allowed_to_create_course() ? null : api_get_user_id()), true);
$evals = $rootcat[0]->get_evaluations(
(api_is_allowed_to_create_course() ? null : api_get_user_id()),
true
);
$foundevals = array();
foreach ($evals as $eval) {
if (!(api_strpos(api_strtolower($eval->get_name()), api_strtolower($name_mask)) === false)) {
@ -787,7 +813,9 @@ class Evaluation implements GradebookItem
public function lock($locked)
{
$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql = "UPDATE $table_evaluation SET locked = '".intval($locked)."' WHERE id='".intval($this->id)."'";
$sql = "UPDATE $table_evaluation
SET locked = '".intval($locked)."'
WHERE id='".intval($this->id)."'";
Database::query($sql);
}
@ -804,7 +832,6 @@ class Evaluation implements GradebookItem
public function delete_linked_data()
{
}
public function getStudentList()

@ -18,6 +18,7 @@ class LinkFactory
* @param string $course_code course code
* @param int $category_id parent category
* @param int $visible visible
* @return array
*/
public static function load(
$id = null,

@ -83,6 +83,7 @@ class Result
* @param $id result id
* @param $user_id user id (student)
* @param $evaluation_id evaluation where this is a result for
* @return array
*/
public static function load($id = null, $user_id = null, $evaluation_id = null)
{
@ -255,8 +256,8 @@ class Result
*/
public function save()
{
$tbl_grade_results = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'UPDATE '.$tbl_grade_results.'
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'UPDATE '.$table.'
SET user_id = ' . $this->get_user_id()
. ', evaluation_id = '.$this->get_evaluation_id()
. ', score = ';
@ -275,8 +276,8 @@ class Result
*/
public function delete()
{
$tbl_grade_results = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'DELETE FROM '.$tbl_grade_results.' WHERE id = '.$this->id;
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'DELETE FROM '.$table.' WHERE id = '.$this->id;
Database::query($sql);
}
}

@ -863,7 +863,14 @@ class FlatViewDataGenerator
$row[] = array(
$item_value,
trim($scoredisplay->display_score($real_score, SCORE_CUSTOM, null, true))
trim(
$scoredisplay->display_score(
$real_score,
SCORE_CUSTOM,
null,
true
)
)
);
$item_value_total += $item_value;
$final_score += $score[0];
@ -873,7 +880,14 @@ class FlatViewDataGenerator
$total_score = array($final_score, $item_total);
$row[] = array(
$final_score,
trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true))
trim(
$scoredisplay->display_score(
$total_score,
SCORE_CUSTOM,
null,
true
)
)
);
} else {
for ($count = 0; $count < count($this->evals_links); $count++) {
@ -884,7 +898,17 @@ class FlatViewDataGenerator
$item_total += $item->get_weight();
$score_denom = ($score[1] == 0) ? 1 : $score[1];
$score_final = ($score[0] / $score_denom) * 100;
$row[] = array($score_final, trim($scoredisplay->display_score($score, SCORE_CUSTOM, null, true)));
$row[] = array(
$score_final,
trim(
$scoredisplay->display_score(
$score,
SCORE_CUSTOM,
null,
true
)
)
);
}
$total_score = array($item_value, $item_total);
@ -892,7 +916,17 @@ class FlatViewDataGenerator
if ($displayWarning) {
echo Display::return_message($total_score[1], 'warning');
}
$row[] = array($score_final, trim($scoredisplay->display_score($total_score, SCORE_CUSTOM, null, true)));
$row[] = array(
$score_final,
trim(
$scoredisplay->display_score(
$total_score,
SCORE_CUSTOM,
null,
true
)
)
);
}
$data[] = $row;

@ -327,21 +327,25 @@ class GradebookDataGenerator
];
//}
$display = $scoredisplay->display_score(
$score,
SCORE_DIV_PERCENT_WITH_CUSTOM
);
$type = $item->get_item_type();
if ($type == 'L' && get_class($item) == 'ExerciseLink') {
$display = ExerciseLib::show_score($score[0], $score[1], false);
}
$display = $scoredisplay->display_score(
$score,
SCORE_DIV_PERCENT_WITH_CUSTOM
);
return array(
'display' => $display,
'score' => $score,
'score_weight' => $scoreWeight,
);
$type = $item->get_item_type();
if ($type == 'L' && get_class($item) == 'ExerciseLink') {
$display = ExerciseLib::show_score(
$score[0],
$score[1],
false
);
}
return array(
'display' => $display,
'score' => $score,
'score_weight' => $scoreWeight,
);
}
}
@ -374,6 +378,7 @@ class GradebookDataGenerator
* Returns the link to the certificate generation, if the score is enough, otherwise
* returns an empty string. This only works with categories.
* @param object Item
* @return string
*/
public function get_certificate_link($item)
{

@ -54,8 +54,13 @@ class ResultsDataGenerator
* 4 ['score'] : student's score
* 5 ['display'] : custom score display (only if custom scoring enabled)
*/
public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false, $pdf = false)
{
public function get_data(
$sorting = 0,
$start = 0,
$count = null,
$ignore_score_color = false,
$pdf = false
) {
// do some checks on count, redefine if invalid value
$number_decimals = api_get_setting('gradebook_number_decimals');
if (!isset($count)) {
@ -86,12 +91,13 @@ class ResultsDataGenerator
$ignore_score_color
);
}
$user['percentage_score'] = intval($scoredisplay->display_score(
array($result->get_score(), $this->evaluation->get_max()),
SCORE_PERCENT,
SCORE_BOTH,
true
)
$user['percentage_score'] = intval(
$scoredisplay->display_score(
array($result->get_score(), $this->evaluation->get_max()),
SCORE_PERCENT,
SCORE_BOTH,
true
)
);
if ($pdf && $number_decimals == null) {
$user['scoreletter'] = $result->get_score();
@ -132,7 +138,7 @@ class ResultsDataGenerator
* @param bool Whether we want the real score (2/4 (50 %)) or the transformation (A, B, C, etc)
* @param bool Whether we want to ignore the score color
* @param boolean $realscore
* @result string The score as we want to show it
* @return string The score as we want to show it
*/
private function get_score_display($score, $realscore, $ignore_score_color = false)
{

@ -20,11 +20,12 @@ class ScoreDisplay
/**
* Get the instance of this class
* @param int $category_id
* @return ScoreDisplay
*/
public static function instance($category_id = 0)
{
static $instance;
if (!isset ($instance)) {
if (!isset($instance)) {
$instance = new ScoreDisplay($category_id);
}
@ -197,8 +198,11 @@ class ScoreDisplay
* @param int score color percent (optional)
* @param int gradebook category id (optional)
*/
public function update_custom_score_display_settings($displays, $scorecolpercent = 0, $category_id = null)
{
public function update_custom_score_display_settings(
$displays,
$scorecolpercent = 0,
$category_id = null
) {
$this->custom_display = $displays;
$this->custom_display_conv = $this->convert_displays($this->custom_display);
@ -448,6 +452,7 @@ class ScoreDisplay
/**
* Depends on the teacher's configuration of thresholds. i.e. [0 50] "Bad", [50:100] "Good"
* @param array $score
* @return string
*/
private function display_custom($score)
{
@ -564,7 +569,6 @@ class ScoreDisplay
private function sort_display($item1, $item2)
{
if ($item1['score'] === $item2['score']) {
return 0;
} else {
return ($item1['score'] < $item2['score'] ? -1 : 1);

@ -39,7 +39,6 @@ class UserDataGenerator
public function __construct($userid, $evals = array(), $links = array())
{
$this->userid = $userid;
$evals_filtered = array();
$result = array();
foreach ($evals as $eval) {
$toadd = true;
@ -87,8 +86,12 @@ class UserDataGenerator
* 5: student's score
* 6: student's score as custom display (only if custom scoring enabled)
*/
public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false)
{
public function get_data(
$sorting = 0,
$start = 0,
$count = null,
$ignore_score_color = false
) {
// do some checks on count, redefine if invalid value
if (!isset($count)) {
$count = count($this->items) - $start;
@ -167,7 +170,7 @@ class UserDataGenerator
* @param $item2
* @return int
*/
function sort_by_type($item1, $item2)
public function sort_by_type($item1, $item2)
{
if ($item1->get_item_type() == $item2->get_item_type()) {
return $this->sort_by_name($item1, $item2);
@ -181,10 +184,14 @@ class UserDataGenerator
* @param $item2
* @return int
*/
function sort_by_course($item1, $item2)
public function sort_by_course($item1, $item2)
{
$name1 = api_strtolower($this->get_course_name_from_code_cached($item1->get_course_code()));
$name2 = api_strtolower($this->get_course_name_from_code_cached($item2->get_course_code()));
$name1 = api_strtolower(
$this->get_course_name_from_code_cached($item1->get_course_code())
);
$name2 = api_strtolower(
$this->get_course_name_from_code_cached($item2->get_course_code())
);
return api_strnatcmp($name1, $name2);
}
@ -193,7 +200,7 @@ class UserDataGenerator
* @param $item2
* @return int
*/
function sort_by_category($item1, $item2)
public function sort_by_category($item1, $item2)
{
$cat1 = $this->get_category_cached($item1->get_category_id());
$cat2 = $this->get_category_cached($item2->get_category_id());
@ -208,7 +215,7 @@ class UserDataGenerator
* @param $item2
* @return int
*/
function sort_by_name($item1, $item2)
public function sort_by_name($item1, $item2)
{
return api_strnatcmp($item1->get_name(), $item2->get_name());
}
@ -218,7 +225,7 @@ class UserDataGenerator
* @param $item2
* @return int
*/
function sort_by_average($item1, $item2)
public function sort_by_average($item1, $item2)
{
$score1 = $this->avgcache[$item1->get_item_type().$item1->get_id()];
$score2 = $this->avgcache[$item2->get_item_type().$item2->get_id()];
@ -231,7 +238,7 @@ class UserDataGenerator
* @param $item2
* @return int
*/
function sort_by_score($item1, $item2)
public function sort_by_score($item1, $item2)
{
$score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()];
$score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()];
@ -244,7 +251,7 @@ class UserDataGenerator
* @param $item2
* @return int
*/
function sort_by_mask($item1, $item2)
public function sort_by_mask($item1, $item2)
{
$score1 = $this->scorecache[$item1->get_item_type().$item1->get_id()];
$score2 = $this->scorecache[$item2->get_item_type().$item2->get_id()];
@ -257,7 +264,7 @@ class UserDataGenerator
* @param $score2
* @return int
*/
function compare_scores($score1, $score2)
public function compare_scores($score1, $score2)
{
if (!isset($score1)) {
return (isset($score2) ? 1 : 0);
@ -325,7 +332,11 @@ class UserDataGenerator
$displaytype |= SCORE_IGNORE_SPLIT;
}
return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_DEFAULT);
return $scoredisplay->display_score(
$studscore,
$displaytype,
SCORE_ONLY_DEFAULT
);
}
/**
@ -341,7 +352,12 @@ class UserDataGenerator
if ($ignore_score_color) {
$displaytype |= SCORE_IGNORE_SPLIT;
}
return $scoredisplay->display_score($studscore, $displaytype, SCORE_ONLY_CUSTOM);
return $scoredisplay->display_score(
$studscore,
$displaytype,
SCORE_ONLY_CUSTOM
);
}
/**
@ -350,7 +366,9 @@ class UserDataGenerator
*/
private function get_course_name_from_code_cached($coursecode)
{
if (isset($this->coursecodecache) && isset($this->coursecodecache[$coursecode])) {
if (isset($this->coursecodecache) &&
isset($this->coursecodecache[$coursecode])
) {
return $this->coursecodecache[$coursecode];
} else {
$name = CourseManager::getCourseNameFromCode($coursecode);
@ -365,7 +383,9 @@ class UserDataGenerator
*/
private function get_category_cached($category_id)
{
if (isset($this->categorycache) && isset ($this->categorycache[$category_id])) {
if (isset($this->categorycache) &&
isset($this->categorycache[$category_id])
) {
return $this->categorycache[$category_id];
} else {
$cat = Category::load($category_id);

@ -30,8 +30,7 @@ $searchForm->addButtonSearch();
if ($searchForm->validate()) {
$firstname = $searchForm->getSubmitValue('firstname');
$lastname = $searchForm->getSubmitValue('lastname');
$userList = UserManager::getUserByName($firstname, $lastname);
$userList = UserManager::getUsersByName($firstname, $lastname);
if (empty($userList)) {
Display::addFlash(
@ -54,12 +53,18 @@ if ($searchForm->validate()) {
}
$courseList = GradebookUtils::getUserCertificatesInCourses($userId, false);
$sessionList = GradebookUtils::getUserCertificatesInSessions($userId, false);
$sessionList = GradebookUtils::getUserCertificatesInSessions(
$userId,
false
);
if (empty($courseList) && empty($sessionList)) {
Display::addFlash(
Display::return_message(
sprintf(get_lang('TheUserXNotYetAchievedCertificates'), $userInfo['complete_name']),
sprintf(
get_lang('TheUserXNotYetAchievedCertificates'),
$userInfo['complete_name']
),
'warning'
)
);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Doctrine\Common\Collections\Criteria,
Chamilo\UserBundle\Entity\User;
/**
* Responses to AJAX calls
@ -179,6 +181,42 @@ switch ($action) {
echo '-1';
}
break;
case 'user_by_role':
api_block_anonymous_users(false);
$criteria = new Criteria();
$criteria
->where(
Criteria::expr()->orX(
Criteria::expr()->contains('username', $_REQUEST['q']),
Criteria::expr()->contains('firstname', $_REQUEST['q']),
Criteria::expr()->contains('lastname', $_REQUEST['q'])
)
)
->andWhere(
Criteria::expr()->eq('status', DRH)
);
$users = UserManager::getRepository()->matching($criteria);
if (!$users->count()) {
echo json_encode([]);
break;
}
$items = [];
/** @var User $user */
foreach ($users as $user) {
$items[] = [
'id' => $user->getId(),
'text' => $user->getCompleteNameWithUsername()
];
}
header('Content-Type: application/json');
echo json_encode(['items' => $items]);
break;
default:
echo '';
}

@ -1852,13 +1852,13 @@ function api_get_course_info_by_id($id = null)
course_category.name faName
FROM $course_table
LEFT JOIN $course_cat_table
ON course.category_code = course_category.code
ON course.category_code = course_category.code
WHERE course.id = $id";
$result = Database::query($sql);
$_course = array();
if (Database::num_rows($result) > 0) {
$course_data = Database::fetch_array($result);
$_course = api_format_course_array($course_data);
$row = Database::fetch_array($result);
$_course = api_format_course_array($row);
}
return $_course;
}

@ -29,7 +29,6 @@ class CourseDescription
*/
public function __construct()
{
}
/**
@ -75,16 +74,23 @@ class CourseDescription
*/
public function get_description_data()
{
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$condition_session = api_get_session_condition($this->session_id, true, true);
$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$condition_session = api_get_session_condition(
$this->session_id,
true,
true
);
$course_id = api_get_course_int_id();
$sql = "SELECT * FROM $tbl_course_description
$sql = "SELECT * FROM $table
WHERE c_id = $course_id $condition_session
ORDER BY id ";
$rs = Database::query($sql);
$data = array();
while ($description = Database::fetch_array($rs)) {
$data['descriptions'][$description['id']] = Security::remove_XSS($description, STUDENT);
$data['descriptions'][$description['id']] = Security::remove_XSS(
$description,
STUDENT
);
}
return $data;
@ -103,7 +109,7 @@ class CourseDescription
$courseId = null,
$session_id = null
) {
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
@ -113,8 +119,11 @@ class CourseDescription
}
$condition_session = api_get_session_condition($session_id);
$description_type = intval($description_type);
$sql = "SELECT * FROM $tbl_course_description
WHERE c_id = $courseId AND description_type='$description_type' $condition_session ";
$sql = "SELECT * FROM $table
WHERE
c_id = $courseId AND
description_type = '$description_type'
$condition_session ";
$rs = Database::query($sql);
$data = array();
if ($description = Database::fetch_array($rs)) {
@ -136,7 +145,7 @@ class CourseDescription
*/
public function get_data_by_id($id, $course_code = '', $session_id = null)
{
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_id = api_get_course_int_id();
if (!isset($session_id)) {
@ -148,7 +157,7 @@ class CourseDescription
$course_id = $course_info['real_id'];
}
$id = intval($id);
$sql = "SELECT * FROM $tbl_course_description
$sql = "SELECT * FROM $table
WHERE c_id = $course_id AND id='$id' $condition_session ";
$rs = Database::query($sql);
$data = array();
@ -170,11 +179,11 @@ class CourseDescription
*/
public function get_max_description_type()
{
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_id = api_get_course_int_id();
$sql = "SELECT MAX(description_type) as MAX
FROM $tbl_course_description
FROM $table
WHERE c_id = $course_id AND session_id='".$this->session_id."'";
$rs = Database::query($sql);
$max = Database::fetch_array($rs);
@ -244,7 +253,7 @@ class CourseDescription
*/
public function insert_stats($description_type)
{
$tbl_stats_item_property = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY);
$description_id = $this->get_id_by_description_type($description_type);
$course_id = api_get_course_int_id();
$course_code = api_get_course_id();
@ -266,7 +275,7 @@ class CourseDescription
'session_id' => $this->session_id,
];
$result = Database::insert($tbl_stats_item_property, $params);
$result = Database::insert($table, $params);
return $result ? 1 : 0;
}
@ -279,7 +288,6 @@ class CourseDescription
public function update()
{
$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$params = [
'title' => $this->title,
'content' => $this->content,
@ -319,9 +327,9 @@ class CourseDescription
*/
public function delete()
{
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_id = api_get_course_int_id();
$sql = "DELETE FROM $tbl_course_description
$sql = "DELETE FROM $table
WHERE
c_id = $course_id AND
id = '".intval($this->id)."' AND
@ -350,11 +358,13 @@ class CourseDescription
*/
public function get_id_by_description_type($description_type)
{
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_id = api_get_course_int_id();
$sql = "SELECT id FROM $tbl_course_description
WHERE c_id = $course_id AND description_type = '".intval($description_type)."'";
$sql = "SELECT id FROM $table
WHERE
c_id = $course_id AND
description_type = '".intval($description_type)."'";
$rs = Database::query($sql);
$row = Database::fetch_array($rs);
$description_id = $row['id'];
@ -497,7 +507,6 @@ class CourseDescription
}
/**
*
* Set description session id
*
* @param int $session_id
@ -517,7 +526,6 @@ class CourseDescription
}
/**
*
* Set progress of a description
*
* @param string $progress

@ -2167,11 +2167,23 @@ class DocumentManager
* @return array List of file paths. An additional field containing 'local' or 'remote' helps determine
* if the file should be copied into the zip or just linked
*/
public static function get_resources_from_source_html($source_html, $is_file = false, $type = null, $recursivity = 1)
{
public static function get_resources_from_source_html(
$source_html,
$is_file = false,
$type = null,
$recursivity = 1
) {
$max = 5;
$attributes = array();
$wanted_attributes = array('src', 'url', '@import', 'href', 'value', 'flashvars', 'poster');
$wanted_attributes = array(
'src',
'url',
'@import',
'href',
'value',
'flashvars',
'poster'
);
$explode_attributes = array('flashvars' => 'file');
$abs_path = '';

@ -2141,7 +2141,7 @@ HOTSPOT;
//Admin can always delete the attempt
if (($locked == false || api_is_platform_admin()) && !api_is_student_boss()) {
$ip = TrackingUserLog::get_ip_from_user_event(
$ip = Tracking::get_ip_from_user_event(
$results[$i]['exe_user_id'],
api_get_utc_datetime(),
false

@ -106,12 +106,20 @@ class ExtraFieldValue extends Model
// Parse params.
foreach ($extraFields as $fieldDetails) {
if ($fieldDetails['visible_to_self'] != 1 && !api_is_platform_admin(true, true)) {
continue;
}
$field_variable = $fieldDetails['variable'];
// if the field is not visible to the user in the end, we need to apply special rules
if ($fieldDetails['visible_to_self'] != 1) {
//only admins should be able to add those values
if (!api_is_platform_admin(true, true)) {
// although if not admin but sent through a CLI script, we should accept it as well
if (PHP_SAPI != 'cli') {
continue; //not a CLI script, so don't write the value to DB
}
}
}
if (isset($params['extra_'.$field_variable])) {
$value = $params['extra_'.$field_variable];
} else {

@ -1764,7 +1764,7 @@ EOT;
*/
public function addUserAvatar($name, $label, $imageSize = 'small', $subtitle = '')
{
return $this->addElement('InputUser', $name, $label, ['image_size' => $imageSize, 'sub_title' => $subtitle]);
return $this->addElement('UserAvatar', $name, $label, ['image_size' => $imageSize, 'sub_title' => $subtitle]);
}
}

@ -24,7 +24,10 @@ class Image
if (class_exists('Imagick')) {
$this->image_wrapper = new ImagickWrapper($path);
} else {
echo Display::return_message('Class Imagick not found', 'warning');
echo Display::return_message(
'Class Imagick not found',
'warning'
);
exit;
}
}
@ -39,13 +42,21 @@ class Image
if ($width >= $max_size_for_picture) {
// scale height
$new_height = round($height * ($max_size_for_picture / $width));
$this->image_wrapper->resize($max_size_for_picture, $new_height, 0);
$this->image_wrapper->resize(
$max_size_for_picture,
$new_height,
0
);
}
} else { // height > $width
if ($height >= $max_size_for_picture) {
// scale width
$new_width = round($width * ($max_size_for_picture / $height));
$this->image_wrapper->resize($new_width, $max_size_for_picture, 0);
$this->image_wrapper->resize(
$new_width,
$max_size_for_picture,
0
);
}
}
}
@ -61,10 +72,23 @@ class Image
$width = intval($cropParameters[2]);
$height = intval($cropParameters[3]);
$image = $this->image_wrapper->crop($x, $y, $width, $height, $src_width, $src_height);
$image = $this->image_wrapper->crop(
$x,
$y,
$width,
$height,
$src_width,
$src_height
);
return $image;
}
/**
* @param string $file
* @param int $compress
* @param null $convert_file_to
* @return bool
*/
public function send_image(
$file = '',
$compress = -1,
@ -77,11 +101,17 @@ class Image
);
}
/**
* @return array
*/
public function get_image_size()
{
return $this->image_wrapper->get_image_size();
}
/**
* @return array
*/
public function get_image_info()
{
return $this->image_wrapper->get_image_info();
@ -124,6 +154,9 @@ abstract class ImageWrapper
abstract function crop($x, $y, $width, $height, $src_width, $src_height);
abstract function send_image($file = '', $compress = -1, $convert_file_to = null);
/**
* @return array
*/
public function get_image_info()
{
return array(
@ -155,6 +188,9 @@ class ImagickWrapper extends ImageWrapper
parent::__construct($path);
}
/**
*
*/
public function set_image_wrapper()
{
if ($this->debug) error_log('Image::set_image_wrapper loaded');
@ -175,11 +211,10 @@ class ImagickWrapper extends ImageWrapper
public function fill_image_info()
{
$image_info = $this->image->identifyImage();
$this->width = $image_info['geometry']['width'];
$this->height = $image_info['geometry']['height'];
$this->type = strtolower($this->image->getImageFormat());
$image_info = $this->image->identifyImage();
$this->width = $image_info['geometry']['width'];
$this->height = $image_info['geometry']['height'];
$this->type = strtolower($this->image->getImageFormat());
if (in_array($this->type, $this->allowed_extensions)) {
$this->image_validated = true;
@ -233,8 +268,11 @@ class ImagickWrapper extends ImageWrapper
$this->height = $height;
}
public function send_image($file = '', $compress = -1, $convert_file_to = null)
{
public function send_image(
$file = '',
$compress = -1,
$convert_file_to = null
) {
if (!$this->image_validated) {
return false;
}
@ -323,6 +361,9 @@ class GDWrapper extends ImageWrapper
}
}
/**
* @return array
*/
public function get_image_size()
{
$return_array = array('width'=>0, 'height'=>0);
@ -448,6 +489,12 @@ class GDWrapper extends ImageWrapper
@imagedestroy($src);
}
/**
* @param string $file
* @param int $compress
* @param null $convert_file_to
* @return bool|int
*/
public function send_image($file = '', $compress = -1, $convert_file_to = null)
{
if (!$this->image_validated) {
@ -515,7 +562,16 @@ class GDWrapper extends ImageWrapper
imagealphablending($dest_img, false);
imagesavealpha($dest_img, true);
imagecolortransparent($dest_img, $transparent);
imagecopy($dest_img, $this->bg, 0, 0, 0, 0, imagesx($this->bg), imagesx($this->bg));
imagecopy(
$dest_img,
$this->bg,
0,
0,
0,
0,
imagesx($this->bg),
imagesx($this->bg)
);
imagefilter($dest_img, IMG_FILTER_GRAYSCALE);
$this->bg = $dest_img;

@ -10,6 +10,7 @@ if (api_get_setting('more_buttons_maximized_mode') === 'true') {
}
$template = new Template();
$template->setCSSEditor();
$template->assign('moreButtonsInMaximizedMode', $moreButtonsInMaximizedMode);
$template->assign('course_condition', api_get_cidreq());

@ -2689,8 +2689,12 @@ class MySpace
* @param $orderDirection
* @return array
*/
public static function getUserDataAccessTrackingOverview($from, $numberItems, $column, $orderDirection)
{
public static function getUserDataAccessTrackingOverview(
$from,
$numberItems,
$column,
$orderDirection
) {
$user = Database::get_main_table(TABLE_MAIN_USER);
$course = Database::get_main_table(TABLE_MAIN_COURSE);
$track_e_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
@ -2733,7 +2737,6 @@ class MySpace
$sql .= " LIMIT $from,$numberItems";
$result = Database::query($sql);
//$clicks = Tracking::get_total_clicks_by_session();
$data = array();
while ($user = Database::fetch_assoc($result)) {
$data[] = $user;

@ -130,7 +130,7 @@ function online_logout($user_id = null, $logout_redirect = false)
Database::query($sql);
}
LoginDelete($user_id); //from inc/lib/online.inc.php - removes the "online" status
UserManager::loginDelete($user_id);
//the following code enables the use of an external logout function.
//example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php
@ -160,19 +160,6 @@ function online_logout($user_id = null, $logout_redirect = false)
}
}
/**
* Remove all login records from the track_e_online stats table, for the given user ID.
* @param int User ID
* @param integer $user_id
* @return void
*/
function LoginDelete($user_id)
{
$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$user_id = intval($user_id);
$query = "DELETE FROM ".$online_table." WHERE login_user_id = $user_id";
Database::query($query);
}
/**
* @param int $user_id

@ -25,7 +25,7 @@ class ChamiloIndexer extends XapianIndexer
* @param int $search_did Search engine document id from search_engine_ref table
* @return boolean False on error or nothing to do, true otherwise
*/
function set_terms(
public function set_terms(
$terms_string,
$prefix,
$course_code,
@ -82,22 +82,19 @@ class ChamiloIndexer extends XapianIndexer
* Get the terms stored at database
* @return array Array of terms
*/
function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id)
public function get_terms_on_db($prefix, $course_code, $tool_id, $ref_id)
{
require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php';
$terms = get_specific_field_values_list_by_prefix($prefix, $course_code, $tool_id, $ref_id);
$terms = get_specific_field_values_list_by_prefix(
$prefix,
$course_code,
$tool_id,
$ref_id
);
$prefix_terms = array();
foreach ($terms as $term) {
$prefix_terms[] = $term['value'];
}
return $prefix_terms;
}
}
if (!function_exists('trim_value')) {
function trim_value(&$value)
{
$value = trim($value);
}
}

@ -67,7 +67,7 @@ abstract class XapianIndexer
/**
* Connect to the database, and create it if it doesn't exist
*/
function connectDb($path = null, $dbMode = null, $lang = 'english')
public function connectDb($path = null, $dbMode = null, $lang = 'english')
{
if ($this->db != null) {
return $this->db;
@ -102,7 +102,7 @@ abstract class XapianIndexer
* Simple getter for the db attribute
* @return object The db attribute
*/
function getDb()
public function getDb()
{
return $this->db;
}
@ -112,7 +112,7 @@ abstract class XapianIndexer
* @param string Chunk of text
* @return void
*/
function addChunk($chunk)
public function addChunk($chunk)
{
$this->chunks[] = $chunk;
}
@ -122,7 +122,7 @@ abstract class XapianIndexer
*
* @return integer New Xapian document ID or null upon failure
*/
function index()
public function index()
{
try {
if (!empty($this->chunks)) {
@ -163,7 +163,7 @@ abstract class XapianIndexer
* @param int did Xapian::docid
* @return mixed XapianDocument, or false on error
*/
function get_document($did)
public function get_document($did)
{
if ($this->db == null) {
$this->connectDb();
@ -183,7 +183,7 @@ abstract class XapianIndexer
* @param XapianDocument $doc xapian document to push into the db
* @return mixed xapian document data or FALSE if error
*/
function get_document_data($doc)
public function get_document_data($doc)
{
if ($this->db == null) {
$this->connectDb();
@ -209,7 +209,7 @@ abstract class XapianIndexer
* (usually 'T' for title, 'A' for author)
* @return boolean false on error
*/
function update_terms($did, $terms, $prefix)
public function update_terms($did, $terms, $prefix)
{
$doc = $this->get_document($did);
if ($doc === false) {
@ -231,7 +231,7 @@ abstract class XapianIndexer
*
* @param int did Xapian::docid
*/
function remove_document($did)
public function remove_document($did)
{
if ($this->db == null) {
$this->connectDb();
@ -252,7 +252,7 @@ abstract class XapianIndexer
* @param XapianDocument $doc The xapian document where to add the term
* @return mixed XapianDocument, or false on error
*/
function add_term_to_doc($term, $doc)
public function add_term_to_doc($term, $doc)
{
if (!is_a($doc, 'XapianDocument')) {
return false;
@ -272,7 +272,7 @@ abstract class XapianIndexer
* @param XapianDocument $doc The xapian document where to add the term
* @return mixed XapianDocument, or false on error
*/
function remove_term_from_doc($term, $doc)
public function remove_term_from_doc($term, $doc)
{
if (!is_a($doc, 'XapianDocument')) {
return false;
@ -292,7 +292,7 @@ abstract class XapianIndexer
* @param int $did xapian document id of the document to replace
* @return mixed
*/
function replace_document($doc, $did)
public function replace_document($doc, $did)
{
if (!is_a($doc, 'XapianDocument')) {
return false;
@ -312,7 +312,7 @@ abstract class XapianIndexer
/**
* Class destructor
*/
function __destruct()
public function __destruct()
{
unset($this->db);
unset($this->stemmer);

@ -165,9 +165,6 @@ class SessionManager
if (empty($name)) {
$msg = get_lang('SessionNameIsRequired');
return $msg;
} elseif (empty($coachId)) {
$msg = get_lang('CoachIsRequired');
return $msg;
} elseif (!empty($startDate) && !api_is_valid_date($startDate, 'Y-m-d H:i') && !api_is_valid_date($startDate, 'Y-m-d H:i:s')) {
$msg = get_lang('InvalidStartDate');
return $msg;

@ -543,7 +543,15 @@ class SkillRelUser extends Model
*/
class Skill extends Model
{
public $columns = array('id', 'name', 'description', 'access_url_id', 'short_code', 'icon', 'criteria');
public $columns = array(
'id',
'name',
'description',
'access_url_id',
'short_code',
'icon',
'criteria'
);
public $required = array('name');
/** Array of colours by depth, for the coffee wheel. Each depth has 4 col */

@ -8,29 +8,34 @@
class SkillVisualizer
{
public $block_size = 120; //see CSS window class
public $canvas_x = 1024;
public $canvas_y = 800;
public $canvas_x = 1024;
public $canvas_y = 800;
public $offset_x = 0;
public $offset_y = 50;
public $offset_x = 0;
public $offset_y = 50;
public $space_between_blocks_x = 100;
public $space_between_blocks_y = 150;
public $center_x = null;
private $html = '';
private $type = 'read';
private $js = '';
private $html = '';
private $type = 'read';
private $js = '';
function __construct($skills, $type = 'read')
/**
* SkillVisualizer constructor.
* @param $skills
* @param string $type
*/
public function __construct($skills, $type = 'read')
{
$this->skills = $skills;
$this->type = $type;
$this->center_x = intval($this->offset_x + $this->canvas_x / 2 - $this->block_size / 2);
}
function prepare_skill_box($skill, $position, $class)
public function prepare_skill_box($skill, $position, $class)
{
$block_id = $skill['id'];
@ -72,7 +77,6 @@ class SkillVisualizer
$class = 'edit_window';
$end_point = 'editEndpoint';
} else {
if ($skill['done_by_user'] == 1) {
$class = 'done_window';
$end_point = 'doneEndpoint';
@ -121,9 +125,7 @@ class SkillVisualizer
$skill_count = sizeof($this->skills);
//$corner = 360 / $skill_count;
$count = 0;
$brothers = array();
foreach ($this->skills as &$skill) {
if (!in_array($skill['parent_id'], array(0, 1))) {
continue;
@ -147,7 +149,7 @@ class SkillVisualizer
$x = $this->canvas_x / 2 - $this->block_size / 2;
} else {
$max = isset($this->skills[$skill['parent_id']]['children']) ? count($this->skills[$skill['parent_id']]['children']) : 0;
foreach ($this->skills[$skill['parent_id']]['children'] as $id => $sk) {
foreach ($this->skills[$skill['parent_id']]['children'] as $id => $sk) {
if ($skill['id'] == $sk['id']) {
break;
}

@ -66,6 +66,7 @@ class SocialManager extends UserManager
* @param int user id
* @param int user friend id
* @param string
* @return int
* @author isaac flores paz
*/
public static function get_relation_between_contacts($user_id, $user_friend)
@ -132,8 +133,12 @@ class SocialManager extends UserManager
* @author Julio Montoya <gugli100@gmail.com> Cleaning code, function renamed, $load_extra_info option added
* @author isaac flores paz
*/
public static function get_friends($user_id, $id_group = null, $search_name = null, $load_extra_info = true)
{
public static function get_friends(
$user_id,
$id_group = null,
$search_name = null,
$load_extra_info = true
) {
$list_ids_friends = array();
$tbl_my_friend = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
$tbl_my_user = Database::get_main_table(TABLE_MAIN_USER);

@ -333,7 +333,11 @@ class Statistics
array('title' => get_lang('UserInfo'))
);
$row[6] = TrackingUserLog::get_ip_from_user_event($row[6], $row[7], true);
$row[6] = Tracking::get_ip_from_user_event(
$row[6],
$row[7],
true
);
if (empty($row[6])) {
$row[6] = get_lang('Unknown');
}

@ -136,8 +136,12 @@ class SystemAnnouncementManager
* @param string $user_id
* @return string
*/
public static function displayAllAnnouncements($visibility, $id = -1, $start = 0, $user_id = '')
{
public static function displayAllAnnouncements(
$visibility,
$id = -1,
$start = 0,
$user_id = ''
) {
$user_selected_language = api_get_interface_language();
$start = intval($start);
$userGroup = new UserGroup();
@ -342,7 +346,9 @@ class SystemAnnouncementManager
$db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
if (!checkdate($date_start_to_compare[1], $date_start_to_compare[2], $date_start_to_compare[0])) {
Display::addFlash(Display::return_message(get_lang('InvalidStartDate'), 'warning'));
Display::addFlash(
Display::return_message(get_lang('InvalidStartDate'), 'warning')
);
return false;
}
@ -352,13 +358,17 @@ class SystemAnnouncementManager
$date_end_to_compare[0]) &&
!checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0])
) {
Display::addFlash(Display::return_message(get_lang('InvalidEndDate'), 'warning'));
Display::addFlash(
Display::return_message(get_lang('InvalidEndDate'), 'warning')
);
return false;
}
if (strlen(trim($title)) == 0) {
Display::addFlash(Display::return_message(get_lang('InvalidTitle'), 'warning'));
Display::addFlash(
Display::return_message(get_lang('InvalidTitle'), 'warning')
);
return false;
}
@ -879,7 +889,6 @@ class SystemAnnouncementManager
ALTER TABLE sys_announcement ADD COLUMN visible_session_admin INT DEFAULT 0;
ALTER TABLE sys_announcement ADD COLUMN visible_boss INT DEFAULT 0;
*/
return api_get_configuration_value('system_announce_extra_roles');
}

@ -184,7 +184,7 @@ class Template
// Setting administrator variables
$this->setAdministratorParams();
$this->setCSSEditor();
//$this->setCSSEditor();
// Header and footer are showed by default
$this->set_footer($show_footer);
@ -649,12 +649,6 @@ class Template
}
}
if (is_file(api_get_path(SYS_CSS_PATH).$this->themeDir.'editor.css')) {
$css[] = api_get_path(WEB_CSS_PATH).$this->themeDir.'editor.css';
} else {
$css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'editor.css');
}
$css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).$this->themeDir.'default.css');
$css_file_to_string = null;

@ -861,3 +861,11 @@ function underScoreToCamelCase($string, $capitalizeFirstCharacter = true)
return $str;
}
/**
* @param string $value
*/
function trim_value(& $value)
{
$value = trim($value);
}

@ -1595,8 +1595,11 @@ class Tracking
*
* @return int Time in seconds
*/
public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
{
public static function get_time_spent_on_the_course(
$user_id,
$courseId,
$session_id = 0
) {
$courseId = intval($courseId);
$session_id = intval($session_id);
$tbl_track_course = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
@ -2638,7 +2641,9 @@ class Tracking
if (empty($session_id)) {
$sql = "SELECT DISTINCT(id), use_max_score
FROM $lp_table
WHERE c_id = $course_id AND (session_id = 0 OR session_id IS NULL ) $condition_lp ";
WHERE
c_id = $course_id AND
(session_id = 0 OR session_id IS NULL) $condition_lp ";
} else {
$sql = "SELECT DISTINCT(id), use_max_score
FROM $lp_table
@ -2726,16 +2731,20 @@ class Tracking
}
// Getting the most recent attempt
$sql = "SELECT lp_iv.id as lp_item_view_id,
lp_iv.score as score,
lp_i.max_score,
lp_iv.max_score as max_score_item_view,
lp_i.path,
lp_i.item_type,
lp_i.id as iid
$sql = "SELECT
lp_iv.id as lp_item_view_id,
lp_iv.score as score,
lp_i.max_score,
lp_iv.max_score as max_score_item_view,
lp_i.path,
lp_i.item_type,
lp_i.id as iid
FROM $lp_item_view_table as lp_iv
INNER JOIN $lp_item_table as lp_i
ON (lp_i.id = lp_iv.lp_item_id AND lp_iv.c_id = lp_i.c_id)
ON (
lp_i.id = lp_iv.lp_item_id AND
lp_iv.c_id = lp_i.c_id
)
WHERE
lp_iv.c_id = $course_id AND
lp_i.c_id = $course_id AND
@ -2771,16 +2780,12 @@ class Tracking
lp_view_id = $lp_view_id AND
(lp_i.item_type='sco' OR lp_i.item_type='".TOOL_QUIZ."')
";
if ($debug) var_dump($sql);
$res_max_score = Database::query($sql);
while ($row_max_score = Database::fetch_array($res_max_score, 'ASSOC')) {
$list[] = $row_max_score;
}
}
if ($debug) var_dump($list);
// Go through each scorable element of this view
$score_of_scorm_calculate = 0;
foreach ($list as $row_max_score) {
@ -2789,7 +2794,6 @@ class Tracking
// Came from the lp_item_view
$max_score_item_view = $row_max_score['max_score_item_view'];
$score = $row_max_score['score'];
if ($debug) echo '<h3>Item Type: '.$row_max_score['item_type'].'</h3>';
if ($row_max_score['item_type'] == 'sco') {
@ -2830,12 +2834,12 @@ class Tracking
$sql = "SELECT exe_id, exe_result
FROM $tbl_stats_exercices
WHERE
exe_exo_id = '$item_path' AND
exe_user_id = $user_id AND
orig_lp_item_id = $item_id AND
exe_exo_id = '$item_path' AND
exe_user_id = $user_id AND
orig_lp_item_id = $item_id AND
orig_lp_item_view_id = $lp_item_view_id AND
c_id = $course_id AND
session_id = $session_id AND
c_id = $course_id AND
session_id = $session_id AND
status = ''
ORDER BY $order
LIMIT 1";
@ -3170,14 +3174,12 @@ class Tracking
public static function get_student_followed_by_coach($coach_id)
{
$coach_id = intval($coach_id);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$students = [];
// At first, courses where $coach_id is coach of the course //
$sql = 'SELECT session_id, c_id
FROM ' . $tbl_session_course_user.'
@ -3407,11 +3409,11 @@ class Tracking
// Then, courses where $coach_id is coach of the session
$sql = 'SELECT DISTINCT course.code
FROM ' . $tbl_session_course.' as session_course
INNER JOIN ' . $tbl_session.' as session
FROM '.$tbl_session_course.' as session_course
INNER JOIN '.$tbl_session.' as session
ON session.id = session_course.session_id
AND session.id_coach = ' . $coach_id.'
INNER JOIN ' . $tbl_course.' as course
AND session.id_coach = '.$coach_id.'
INNER JOIN '.$tbl_course.' as course
ON course.id = session_course.c_id';
if (api_is_multiple_url_enabled()) {
@ -3419,13 +3421,13 @@ class Tracking
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$sql = 'SELECT DISTINCT c.code
FROM ' . $tbl_session_course.' as session_course
FROM '.$tbl_session_course.' as session_course
INNER JOIN '.$tbl_course.' c
ON (c.id = session_course.c_id)
INNER JOIN ' . $tbl_session.' as session
INNER JOIN '.$tbl_session.' as session
ON session.id = session_course.session_id
AND session.id_coach = ' . $coach_id.'
INNER JOIN ' . $tbl_course.' as course
AND session.id_coach = '.$coach_id.'
INNER JOIN '.$tbl_course.' as course
ON course.id = session_course.c_id
INNER JOIN '.$tbl_course_rel_access_url.' course_rel_url
ON (course_rel_url.c_id = c.id)';
@ -3612,8 +3614,11 @@ class Tracking
* return count of assignments including sessions, 0 = session is not filtered
* @return int Number of documents
*/
public static function count_student_uploaded_documents($student_id, $course_code, $session_id = null)
{
public static function count_student_uploaded_documents(
$student_id,
$course_code,
$session_id = null
) {
// get the information of the course
$a_course = api_get_course_info($course_code);
if (!empty($a_course)) {
@ -3664,8 +3669,11 @@ class Tracking
* if param $session_id is null(default) return count of assignments
* including sessions, 0 = session is not filtered
*/
public static function count_student_assignments($student_id, $course_code = null, $session_id = null)
{
public static function count_student_assignments(
$student_id,
$course_code = null,
$session_id = null
) {
if (empty($student_id)) {
return 0;
}
@ -4242,8 +4250,6 @@ class Tracking
return $a_students;
}
/**
* get count clicks about tools most used by course
* @param int $courseId
@ -4284,132 +4290,6 @@ class Tracking
return $data;
}
/**
* Get total clicks
* THIS FUNCTION IS NOT BEEN USED, IT WAS MEANT TO BE USE WITH track_e_course_access.date_from and track_e_course_access.date_to,
* BUT NO ROW MATCH THE CONDITION, IT SHOULD BE FINE TO USE IT WHEN YOU USE USER DEFINED DATES AND NO CHAMILO DATES
* @param int User Id
* @param int Course Id
* @param int Session Id (optional), if param $session_id is 0 (default) it'll return results including sessions, 0 = session is not filtered
* @param string Date from
* @param string Date to
* @return array Data
* @author César Perales cesar.perales@beeznest.com 2014-01-16
*/
public static function get_total_clicks($userId, $courseId, $sessionId = 0, $date_from = '', $date_to = '')
{
$course = api_get_course_info_by_id($courseId);
$tables = array(
TABLE_STATISTIC_TRACK_E_LASTACCESS => array(
'course' => 'c_id',
'session' => 'access_session_id',
'user' => 'access_user_id',
'start_date'=> 'access_date',
),
TABLE_STATISTIC_TRACK_E_ACCESS => array(
'course' => 'c_id',
'session' => 'access_session_id',
'user' => 'access_user_id',
'start_date'=> 'access_date',
),
#TABLE_STATISTIC_TRACK_E_LOGIN, array(,, 'login_date', 'logout_date');
TABLE_STATISTIC_TRACK_E_DOWNLOADS => array(
'course' => 'c_id',
'session' => 'down_session_id',
'user' => 'down_user_id',
'start_date'=> 'down_date',
),
TABLE_STATISTIC_TRACK_E_LINKS => array(
'course' => 'c_id',
'session' => 'links_session_id',
'user' => 'links_user_id',
'start_date'=> 'links_date',
),
TABLE_STATISTIC_TRACK_E_ONLINE => array(
'course' => 'c_id',
'session' => 'session_id',
'user' => 'login_user_id',
'start_date'=> 'login_date',
),
#TABLE_STATISTIC_TRACK_E_HOTPOTATOES,
/*TABLE_STATISTIC_TRACK_E_COURSE_ACCESS => array(
'course' => 'c_id',
'session' => 'session_id',
'user' => 'user_id',
'start_date'=> 'login_course_date',
'end_date' => 'logout_course_date',
),*/
TABLE_STATISTIC_TRACK_E_EXERCISES => array(
'course' => 'c_id',
'session' => 'session_id',
'user' => 'exe_user_id',
'start_date'=> 'exe_date',
),
TABLE_STATISTIC_TRACK_E_ATTEMPT => array(
'course' => 'c_id',
'session' => 'session_id',
'user' => 'user_id',
'start_date'=> 'tms',
),
#TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING,
#TABLE_STATISTIC_TRACK_E_DEFAULT,
TABLE_STATISTIC_TRACK_E_UPLOADS => array(
'course' => 'c_id',
'session' => 'upload_session_id',
'user' => 'upload_user_id',
'start_date'=> 'upload_date',
),
);
foreach ($tables as $tableName => $fields) {
//If session is defined, add it to query
$where = '';
if (isset($sessionId) && !empty($sessionId)) {
$sessionField = $fields['session'];
$where .= " AND $sessionField = $sessionId";
}
//filter by date
if (!empty($date_from) && !empty($date_to)) {
$fieldStartDate = $fields['start_date'];
if (!isset($fields['end_date'])) {
$where .= sprintf(" AND ($fieldStartDate BETWEEN '%s' AND '%s' )", $date_from, $date_to);
} else {
$fieldEndDate = $fields['end_date'];
$where .= sprintf(" AND fieldStartDate >= '%s'
AND $fieldEndDate <= '%s'", $date_from, $date_to);
}
}
//query
$sql = "SELECT %s as user, count(*) as total
FROM %s
WHERE %s = '%s'
AND %s = %s
$where
GROUP BY %s";
$sql = sprintf($sql,
$fields['user'], //user field
$tableName, //FROM
$fields['course'], //course condition
$course['real_id'], //course condition
$fields['user'], //user condition
$userId, //user condition
$fields['user'] //GROUP BY
);
$rs = Database::query($sql);
//iterate query
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs)) {
$data[$row['user']] = (isset($data[$row['user']])) ? $data[$row['user']] + $row[total] : $row['total'];
}
}
}
return $data;
}
/**
* get documents most downloaded by course
* @param string Course code
@ -4419,9 +4299,11 @@ class Tracking
* @param int Limit (optional, default = 0, 0 = without limit)
* @return array documents downloaded
*/
public static function get_documents_most_downloaded_by_course($course_code, $session_id = 0, $limit = 0)
{
//protect data
public static function get_documents_most_downloaded_by_course(
$course_code,
$session_id = 0,
$limit = 0
) {
$courseId = api_get_course_int_id($course_code);
$data = array();
@ -4648,7 +4530,6 @@ class Tracking
}
$html = '';
// Course list
if ($show_courses) {
if (!empty($courses)) {
@ -4751,8 +4632,7 @@ class Tracking
// Session list
if (!empty($course_in_session)) {
$main_session_graph = '';
//Load graphics only when calling to an specific session
$session_graph = array();
// Load graphics only when calling to an specific session
$all_exercise_graph_name_list = array();
$my_results = array();
$all_exercise_graph_list = array();
@ -6514,6 +6394,139 @@ class Tracking
return $html;
}
/**
* Gets the IP of a given user, using the last login before the given date
* @param int User ID
* @param string Datetime
* @param bool Whether to return the IP as a link or just as an IP
* @param string If defined and return_as_link if true, will be used as the text to be shown as the link
* @return string IP address (or false on error)
* @assert (0,0) === false
*/
public static function get_ip_from_user_event(
$user_id,
$event_date,
$return_as_link = false,
$body_replace = null
) {
if (empty($user_id) || empty($event_date)) {
return false;
}
$user_id = intval($user_id);
$event_date = Database::escape_string($event_date);
$table_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql_ip = "SELECT login_date, user_ip
FROM $table_login
WHERE login_user_id = $user_id AND login_date < '$event_date'
ORDER BY login_date DESC LIMIT 1";
$ip = '';
$res_ip = Database::query($sql_ip);
if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
$row_ip = Database::fetch_row($res_ip);
if ($return_as_link) {
$ip = Display::url(
(empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
array('title' => get_lang('TraceIP'), 'target' => '_blank')
);
} else {
$ip = $row_ip[1];
}
}
return $ip;
}
/**
* @param int $userId
* @param array $courseInfo
* @param int $sessionId
* @return array
*/
public static function getToolInformation(
$userId,
$courseInfo,
$sessionId = 0
) {
$csvContent = array();
$courseToolInformation = '';
$headerTool = array(
array(get_lang('Title')),
array(get_lang('CreatedAt')),
array(get_lang('UpdatedAt')),
);
$headerListForCSV = array();
foreach ($headerTool as $item) {
$headerListForCSV[] = $item[0];
}
$courseForumInformationArray = getForumCreatedByUser(
$userId,
$courseInfo['real_id'],
$sessionId
);
if (!empty($courseForumInformationArray)) {
$csvContent[] = array();
$csvContent[] = [get_lang('Forums')];
$csvContent[] = $headerListForCSV;
foreach ($courseForumInformationArray as $row) {
$csvContent[] = $row;
}
$courseToolInformation .= Display::page_subheader2(
get_lang('Forums')
);
$courseToolInformation .= Display::return_sortable_table(
$headerTool,
$courseForumInformationArray
);
}
$courseWorkInformationArray = getWorkCreatedByUser(
$userId,
$courseInfo['real_id'],
$sessionId
);
if (!empty($courseWorkInformationArray)) {
$csvContent[] = null;
$csvContent[] = [get_lang('Works')];
$csvContent[] = $headerListForCSV;
foreach ($courseWorkInformationArray as $row) {
$csvContent[] = $row;
}
$csvContent[] = null;
$courseToolInformation .= Display::page_subheader2(
get_lang('Works')
);
$courseToolInformation .= Display::return_sortable_table(
$headerTool,
$courseWorkInformationArray
);
}
$courseToolInformationTotal = null;
if (!empty($courseToolInformation)) {
$sessionTitle = null;
if (!empty($sessionId)) {
$sessionTitle = ' ('.api_get_session_name($sessionId).')';
}
$courseToolInformationTotal .= Display::page_subheader(
$courseInfo['title'].$sessionTitle
);
$courseToolInformationTotal .= $courseToolInformation;
}
return array(
'array' => $csvContent,
'html' => $courseToolInformationTotal
);
}
}
/**
@ -6808,7 +6821,11 @@ class TrackingCourseLog
);
$row[3] = $row['col3'];
$ip = TrackingUserLog::get_ip_from_user_event($row['user_id'], $row['col5'], true);
$ip = Tracking::get_ip_from_user_event(
$row['user_id'],
$row['col5'],
true
);
if (empty($ip)) {
$ip = get_lang('Unknown');
}
@ -6952,7 +6969,7 @@ class TrackingCourseLog
* @since Nov 2009
* @version 1.8.6.2
*/
public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
public static function getAdditionalProfileInformationOfFieldByUser($field_id, $users)
{
// Database table definition
$table_user = Database::get_main_table(TABLE_MAIN_USER);
@ -7024,12 +7041,18 @@ class TrackingCourseLog
public function sort_users($a, $b)
{
return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
return strcmp(
trim(api_strtolower($a[$_SESSION['tracking_column']])),
trim(api_strtolower($b[$_SESSION['tracking_column']]))
);
}
public function sort_users_desc($a, $b)
{
return strcmp(trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
return strcmp(
trim(api_strtolower($b[$_SESSION['tracking_column']])),
trim(api_strtolower($a[$_SESSION['tracking_column']]))
);
}
/**
@ -7051,8 +7074,13 @@ class TrackingCourseLog
* @param $includeInvitedUsers boolean Whether include the invited users
* @return array
*/
public static function get_user_data($from, $number_of_items, $column, $direction, $includeInvitedUsers = false)
{
public static function get_user_data(
$from,
$number_of_items,
$column,
$direction,
$includeInvitedUsers = false
) {
global $user_ids, $course_code, $export_csv, $is_western_name_order, $csv_content, $session_id;
$course_code = Database::escape_string($course_code);
@ -7088,7 +7116,6 @@ class TrackingCourseLog
}
$invitedUsersCondition = '';
if (!$includeInvitedUsers) {
$invitedUsersCondition = " AND user.status != ".INVITEE;
}
@ -7308,383 +7335,3 @@ class TrackingCourseLog
return $users;
}
}
/**
* @package chamilo.tracking
*/
class TrackingUserLog
{
/**
* Gets the IP of a given user, using the last login before the given date
* @param int User ID
* @param string Datetime
* @param bool Whether to return the IP as a link or just as an IP
* @param string If defined and return_as_link if true, will be used as the text to be shown as the link
* @return string IP address (or false on error)
* @assert (0,0) === false
*/
public static function get_ip_from_user_event(
$user_id,
$event_date,
$return_as_link = false,
$body_replace = null
) {
if (empty($user_id) || empty($event_date)) {
return false;
}
$user_id = intval($user_id);
$event_date = Database::escape_string($event_date);
$table_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql_ip = "SELECT login_date, user_ip
FROM $table_login
WHERE login_user_id = $user_id AND login_date < '$event_date'
ORDER BY login_date DESC LIMIT 1";
$ip = '';
$res_ip = Database::query($sql_ip);
if ($res_ip !== false && Database::num_rows($res_ip) > 0) {
$row_ip = Database::fetch_row($res_ip);
if ($return_as_link) {
$ip = Display::url(
(empty($body_replace) ? $row_ip[1] : $body_replace), 'http://www.whatsmyip.org/ip-geo-location/?ip='.$row_ip[1],
array('title' => get_lang('TraceIP'), 'target' => '_blank')
);
} else {
$ip = $row_ip[1];
}
}
return $ip;
}
}
/**
* @package chamilo.tracking
*/
class TrackingUserLogCSV
{
/**
* Displays the number of logins every month for a specific user in a specific course.
* @param $view
* @param int $user_id
* @param int $course_id
* @param int $session_id
* @return array
*/
public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
{
$MonthsLong = $GLOBALS['MonthsLong'];
$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
// protected data
$user_id = intval($user_id);
$session_id = intval($session_id);
$course_id = intval($course_id);
$tempView = $view;
if (substr($view, 0, 1) == '1') {
$new_view = substr_replace($view, '0', 0, 1);
$title[1] = get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
FROM $track_access_table
WHERE access_user_id = $user_id
AND c_id = $course_id
AND access_session_id = $session_id
GROUP BY YEAR(access_date),MONTH(access_date)
ORDER BY YEAR(access_date),MONTH(access_date) ASC";
//$results = getManyResults2Col($sql);
$results = getManyResults3Col($sql);
$title_line = get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
$line = '';
$total = 0;
if (is_array($results)) {
for ($j = 0; $j < count($results); $j++) {
$line .= $results[$j][0].';'.$results[$j][1]."\n";
$total = $total + $results[$j][1];
}
$line .= get_lang('Total').";".$total."\n";
} else {
$line = get_lang('NoResult')."</center></td>";
}
} else {
$new_view = substr_replace($view, '1', 0, 1);
}
return array($title_line, $line);
}
/**
* Displays the exercise results for a specific user in a specific course.
* @param string $view
* @param int $user_id User ID
* @param string $courseCode Course code
* @return array
* @todo remove globals
*/
public function display_exercise_tracking_info($view, $userId, $courseCode)
{
global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
$courseId = api_get_course_int_id($courseCode);
$userId = intval($userId);
if (substr($view, 1, 1) == '1') {
$new_view = substr_replace($view, '0', 1, 1);
$title[1] = get_lang('ExercicesDetails');
$line = '';
$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
WHERE te.c_id = $courseId
AND te.exe_user_id = $userId
AND te.exe_exo_id = ce.id
ORDER BY ce.title ASC, te.exe_date ASC";
$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
FROM $TABLETRACK_HOTPOTATOES AS te
WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
ORDER BY te.c_id ASC, te.exe_date ASC";
$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
$NoTestRes = 0;
$NoHPTestRes = 0;
$results = StatsUtils::getManyResultsXCol($sql, 4);
$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
if (is_array($results)) {
for ($i = 0; $i < sizeof($results); $i++) {
$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
}
} else {
// istvan begin
$NoTestRes = 1;
}
// The Result of Tests
if (is_array($hpresults)) {
for ($i = 0; $i < sizeof($hpresults); $i++) {
$title = GetQuizName($hpresults[$i][0], '');
if ($title == '') {
$title = basename($hpresults[$i][0]);
}
$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
}
} else {
$NoHPTestRes = 1;
}
if ($NoTestRes == 1 && $NoHPTestRes == 1) {
$line = get_lang('NoResult');
}
} else {
$new_view = substr_replace($view, '1', 1, 1);
}
return array($title_line, $line);
}
/**
* Displays the student publications for a specific user in a specific course.
* @todo remove globals
*/
public function display_student_publications_tracking_info($view, $user_id, $course_id)
{
global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
$_course = api_get_course_info();
$user_id = intval($user_id);
$course_id = intval($course_id);
if (substr($view, 2, 1) == '1') {
$sql = "SELECT u.upload_date, w.title, w.author, w.url
FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
WHERE
u.upload_work_id = w.id AND
u.upload_user_id = '$user_id' AND
u.c_id = '$course_id'
ORDER BY u.upload_date DESC";
$results = StatsUtils::getManyResultsXCol($sql, 4);
$title[1] = get_lang('WorksDetails');
$line = '';
$title_line = get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
if (is_array($results)) {
for ($j = 0; $j < count($results); $j++) {
$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
}
} else {
$line = get_lang('NoResult');
}
}
return array($title_line, $line);
}
/**
* Displays the links followed for a specific user in a specific course.
* @todo remove globals
*/
public function display_links_tracking_info($view, $userId, $courseCode)
{
global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
$courseId = api_get_course_int_id($courseCode);
$userId = intval($userId);
$line = null;
if (substr($view, 3, 1) == '1') {
$new_view = substr_replace($view, '0', 3, 1);
$title[1] = get_lang('LinksDetails');
$sql = "SELECT cl.title, cl.url
FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
WHERE sl.links_link_id = cl.id
AND sl.c_id = $courseId
AND sl.links_user_id = $userId
GROUP BY cl.title, cl.url";
$results = StatsUtils::getManyResults2Col($sql);
$title_line = get_lang('LinksTitleLinkColumn')."\n";
if (is_array($results)) {
for ($j = 0; $j < count($results); $j++) {
$line .= $results[$j][0]."\n";
}
} else {
$line = get_lang('NoResult');
}
} else {
$new_view = substr_replace($view, '1', 3, 1);
}
return array($title_line, $line);
}
/**
* Displays the documents downloaded for a specific user in a specific course.
* @param string kind of view inside tracking info
* @param int User id
* @param string Course code
* @param int Session id (optional, default = 0)
* @return void
*/
public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
{
// protect data
$user_id = intval($user_id);
$courseId = api_get_course_int_id($courseCode);
$session_id = intval($session_id);
$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
if (substr($view, 4, 1) == '1') {
$new_view = substr_replace($view, '0', 4, 1);
$title[1] = get_lang('DocumentsDetails');
$sql = "SELECT down_doc_path
FROM $downloads_table
WHERE c_id = $courseId
AND down_user_id = $user_id
AND down_session_id = $session_id
GROUP BY down_doc_path";
$results = StatsUtils::getManyResults1Col($sql);
$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
$line = null;
if (is_array($results)) {
for ($j = 0; $j < count($results); $j++) {
$line .= $results[$j]."\n";
}
} else {
$line = get_lang('NoResult');
}
} else {
$new_view = substr_replace($view, '1', 4, 1);
}
return array($title_line, $line);
}
/**
* @param int $userId
* @param array $courseInfo
* @param int $sessionId
* @return array
*/
public static function getToolInformation(
$userId,
$courseInfo,
$sessionId = 0
) {
$csvContent = array();
$courseToolInformation = '';
$headerTool = array(
array(get_lang('Title')),
array(get_lang('CreatedAt')),
array(get_lang('UpdatedAt')),
);
$headerListForCSV = array();
foreach ($headerTool as $item) {
$headerListForCSV[] = $item[0];
}
$courseForumInformationArray = getForumCreatedByUser(
$userId,
$courseInfo['real_id'],
$sessionId
);
if (!empty($courseForumInformationArray)) {
$csvContent[] = array();
$csvContent[] = [get_lang('Forums')];
$csvContent[] = $headerListForCSV;
foreach ($courseForumInformationArray as $row) {
$csvContent[] = $row;
}
$courseToolInformation .= Display::page_subheader2(
get_lang('Forums')
);
$courseToolInformation .= Display::return_sortable_table(
$headerTool,
$courseForumInformationArray
);
}
$courseWorkInformationArray = getWorkCreatedByUser(
$userId,
$courseInfo['real_id'],
$sessionId
);
if (!empty($courseWorkInformationArray)) {
$csvContent[] = null;
$csvContent[] = [get_lang('Works')];
$csvContent[] = $headerListForCSV;
foreach ($courseWorkInformationArray as $row) {
$csvContent[] = $row;
}
$csvContent[] = null;
$courseToolInformation .= Display::page_subheader2(
get_lang('Works')
);
$courseToolInformation .= Display::return_sortable_table(
$headerTool,
$courseWorkInformationArray
);
}
$courseToolInformationTotal = null;
if (!empty($courseToolInformation)) {
$sessionTitle = null;
if (!empty($sessionId)) {
$sessionTitle = ' ('.api_get_session_name($sessionId).')';
}
$courseToolInformationTotal .= Display::page_subheader(
$courseInfo['title'].$sessionTitle
);
$courseToolInformationTotal .= $courseToolInformation;
}
return array(
'array' => $csvContent,
'html' => $courseToolInformationTotal
);
}
}

@ -7,6 +7,7 @@ use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder;
use Symfony\Component\Security\Core\Encoder\EncoderFactory;
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder;
use Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder;
use ChamiloSession as Session;
/**
*
@ -4478,13 +4479,20 @@ class UserManager
/**
* Subscribes users to human resource manager (Dashboard feature)
* @param int $hr_dept_id
* @param array $users_id
* @param int affected rows
* */
public static function subscribeUsersToHRManager($hr_dept_id, $users_id)
* @param int $hr_dept_id
* @param array $users_id
* @param bool $deleteOtherAssignedUsers
* @return int
*/
public static function subscribeUsersToHRManager($hr_dept_id, $users_id, $deleteOtherAssignedUsers = true)
{
return self::subscribeUsersToUser($hr_dept_id, $users_id, USER_RELATION_TYPE_RRHH);
return self::subscribeUsersToUser(
$hr_dept_id,
$users_id,
USER_RELATION_TYPE_RRHH,
false,
$deleteOtherAssignedUsers
);
}
/**
@ -4493,8 +4501,16 @@ class UserManager
* @param array $subscribedUsersId The id of suscribed users
* @param string $relationType The relation type
* @param bool $deleteUsersBeforeInsert
* @param bool $deleteOtherAssignedUsers
* @return int
*/
public static function subscribeUsersToUser($userId, $subscribedUsersId, $relationType, $deleteUsersBeforeInsert = false)
public static function subscribeUsersToUser(
$userId,
$subscribedUsersId,
$relationType,
$deleteUsersBeforeInsert = false,
$deleteOtherAssignedUsers = true
)
{
$userRelUserTable = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
$userRelAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@ -4503,29 +4519,31 @@ class UserManager
$relationType = intval($relationType);
$affectedRows = 0;
if (api_get_multiple_access_url()) {
// Deleting assigned users to hrm_id
$sql = "SELECT s.user_id FROM $userRelUserTable s
if ($deleteOtherAssignedUsers) {
if (api_get_multiple_access_url()) {
// Deleting assigned users to hrm_id
$sql = "SELECT s.user_id FROM $userRelUserTable s
INNER JOIN $userRelAccessUrlTable a ON (a.user_id = s.user_id)
WHERE
friend_user_id = $userId AND
relation_type = $relationType AND
access_url_id = ".api_get_current_access_url_id();
} else {
$sql = "SELECT user_id FROM $userRelUserTable
} else {
$sql = "SELECT user_id FROM $userRelUserTable
WHERE friend_user_id = $userId
AND relation_type = $relationType";
}
$result = Database::query($sql);
}
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result)) {
$sql = "DELETE FROM $userRelUserTable
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result)) {
$sql = "DELETE FROM $userRelUserTable
WHERE
user_id = {$row['user_id']} AND
friend_user_id = $userId AND
relation_type = $relationType";
Database::query($sql);
Database::query($sql);
}
}
}
@ -5214,7 +5232,7 @@ class UserManager
* @param string $lastname Lastname to search
* @return array The user list
*/
public static function getUserByName($firstname, $lastname)
public static function getUsersByName($firstname, $lastname)
{
$firstname = Database::escape_string($firstname);
$lastname = Database::escape_string($lastname);
@ -5281,4 +5299,98 @@ SQL;
return Display::tabsOnlyLink($headers, $optionSelected);
}
}
/**
* Make sure this function is protected because it does NOT check password!
*
* This function defines globals.
* @param int $userId
* @param bool $checkIfUserCanLoginAs
* @return array
* @author Evie Embrechts
* @author Yannick Warnier <yannick.warnier@dokeos.com>
*/
public static function loginAsUser($userId, $checkIfUserCanLoginAs = true)
{
$userId = intval($userId);
$userInfo = api_get_user_info($userId);
// Check if the user is allowed to 'login_as'
$canLoginAs = true;
if ($checkIfUserCanLoginAs) {
$canLoginAs = api_can_login_as($userId);
}
if (!$canLoginAs || empty($userInfo)) {
return false;
}
if ($userId) {
// Logout the current user
self::loginDelete(api_get_user_id());
Session::erase('_user');
Session::erase('is_platformAdmin');
Session::erase('is_allowedCreateCourse');
Session::erase('_uid');
// Cleaning session variables
$_user['firstName'] = $userInfo['firstname'];
$_user['lastName'] = $userInfo['lastname'];
$_user['mail'] = $userInfo['email'];
$_user['official_code'] = $userInfo['official_code'];
$_user['picture_uri'] = $userInfo['picture_uri'];
$_user['user_id'] = $userId;
$_user['id'] = $userId;
$_user['status'] = $userInfo['status'];
// Filling session variables with new data
Session::write('_uid', $userId);
Session::write('_user', $userInfo);
Session::write('is_platformAdmin', (bool) UserManager::is_admin($userId));
Session::write('is_allowedCreateCourse', (bool) ($userInfo['status'] == 1));
// will be useful later to know if the user is actually an admin or not (example reporting)
Session::write('login_as', true);
return true;
}
return false;
}
/**
* Remove all login records from the track_e_online stats table,
* for the given user ID.
* @param int User ID
* @param integer $user_id
* @return void
*/
public static function loginDelete($user_id)
{
$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$user_id = intval($user_id);
$query = "DELETE FROM ".$online_table." WHERE login_user_id = $user_id";
Database::query($query);
}
/**
* Login as first admin user registered in the platform
* @return array
*/
public static function logInAsFirstAdmin()
{
$adminList = self::get_all_administrators();
if (!empty($adminList)) {
$userInfo = current($adminList);
if (!empty($userInfo)) {
$result = self::loginAsUser($userInfo['user_id'], false);
if ($result && api_is_platform_admin()) {
return api_get_user_info();
}
}
}
return [];
}
}

@ -3191,80 +3191,8 @@ function migrateSwitch($fromVersion, $manager, $processFiles = true)
if ($result) {
error_log('Migrations files were executed ('.date('Y-m-d H:i:s').')');
$connection->executeQuery("ALTER TABLE course_category MODIFY COLUMN auth_course_child VARCHAR(40) DEFAULT 'TRUE'");
error_log('Fix c_student_publication.post_group_id');
// Fix post_group_id
$sql = "SELECT * FROM c_student_publication WHERE (post_group_id <> 0 AND post_group_id is not null)";
$statement = $connection->executeQuery($sql);
$result = $statement->fetchAll();
foreach ($result as $row) {
$groupId = $row['post_group_id'];
$courseId = $row['c_id'];
$workIid = $row['iid'];
$sql = "SELECT iid from c_group_info WHERE c_id = $courseId AND iid = $groupId";
$statement = $connection->executeQuery($sql);
$count = $statement->rowCount();
if ($count == 0) {
$sql = "SELECT iid from c_group_info WHERE c_id = $courseId AND id = $groupId";
$statement = $connection->executeQuery($sql);
$count = $statement->rowCount();
if ($count > 0) {
$rowGroup = $statement->fetch();
$newGroupId = $rowGroup['iid'];
if ($newGroupId) {
$sqlUpdate = "UPDATE c_student_publication
SET post_group_id = $newGroupId
WHERE
c_id = $courseId AND
iid = $workIid
";
$connection->executeQuery($sqlUpdate);
}
}
}
}
error_log('End - Fix c_student_publication.post_group_id');
// Delete c_student_publication from any session that doesn't exist anymore
$sql = "DELETE FROM c_student_publication
WHERE session_id NOT IN (SELECT id FROM session) AND (session_id <> 0 AND session_id is not null)";
$connection->executeQuery($sql);
error_log('Fix work documents');
// Fix work documents that don't have c_item_property value
$sql = "SELECT * FROM c_student_publication WHERE parent_id IS NOT NULL";
$statement = $connection->executeQuery($sql);
$result = $statement->fetchAll();
foreach ($result as $row) {
$groupId = $row['post_group_id'];
$courseId = $row['c_id'];
$sessionId = $row['session_id'];
$workId = $row['id'];
$itemInfo = api_get_item_property_info(
$courseId,
'work',
$workId,
$sessionId
);
$courseInfo = api_get_course_info_by_id($courseId);
if (empty($itemInfo)) {
api_item_property_update(
$courseInfo,
'work',
$workId,
'visible',
1,
$groupId,
null,
null,
null,
$sessionId
);
}
}
error_log('End - Fix work documents');
fixPostGroupIds($connection);
$sql = "UPDATE settings_current SET selected_value = '1.11.0' WHERE variable = 'chamilo_database_version'";
$connection->executeQuery($sql);
@ -3288,3 +3216,83 @@ function migrateSwitch($fromVersion, $manager, $processFiles = true)
return true;
}
/**
* @param \Doctrine\DBAL\Connection $connection
*/
function fixPostGroupIds($connection)
{
$connection->executeQuery("ALTER TABLE course_category MODIFY COLUMN auth_course_child VARCHAR(40) DEFAULT 'TRUE'");
error_log('Fix c_student_publication.post_group_id');
// Fix post_group_id
$sql = "SELECT * FROM c_student_publication WHERE (post_group_id <> 0 AND post_group_id is not null)";
$statement = $connection->executeQuery($sql);
$result = $statement->fetchAll();
foreach ($result as $row) {
$groupId = $row['post_group_id'];
$courseId = $row['c_id'];
$workIid = $row['iid'];
$sql = "SELECT iid from c_group_info WHERE c_id = $courseId AND iid = $groupId";
$statement = $connection->executeQuery($sql);
$count = $statement->rowCount();
if ($count == 0) {
$sql = "SELECT iid from c_group_info WHERE c_id = $courseId AND id = $groupId";
$statement = $connection->executeQuery($sql);
$count = $statement->rowCount();
if ($count > 0) {
$rowGroup = $statement->fetch();
$newGroupId = $rowGroup['iid'];
if ($newGroupId) {
$sqlUpdate = "UPDATE c_student_publication
SET post_group_id = $newGroupId
WHERE
c_id = $courseId AND
iid = $workIid
";
$connection->executeQuery($sqlUpdate);
}
}
}
}
error_log('End - Fix c_student_publication.post_group_id');
// Delete c_student_publication from any session that doesn't exist anymore
$sql = "DELETE FROM c_student_publication
WHERE session_id NOT IN (SELECT id FROM session) AND (session_id <> 0 AND session_id is not null)";
$connection->executeQuery($sql);
error_log('Fix work documents');
// Fix work documents that don't have c_item_property value
$sql = "SELECT * FROM c_student_publication WHERE parent_id IS NOT NULL";
$statement = $connection->executeQuery($sql);
$result = $statement->fetchAll();
foreach ($result as $row) {
$groupId = $row['post_group_id'];
$courseId = $row['c_id'];
$sessionId = $row['session_id'];
$workId = $row['id'];
$itemInfo = api_get_item_property_info(
$courseId,
'work',
$workId,
$sessionId
);
$courseInfo = api_get_course_info_by_id($courseId);
if (empty($itemInfo)) {
api_item_property_update(
$courseInfo,
'work',
$workId,
'visible',
1,
$groupId,
null,
null,
null,
$sessionId
);
}
}
error_log('End - Fix work documents');
}

@ -3158,9 +3158,9 @@ class learnpath
'passed' => 'scorm_completed',
'succeeded' => 'scorm_completed',
'browsed' => 'scorm_completed',
];
foreach ($toc_list as $item) {
];
foreach ($toc_list as $item) {
$list['id'] = $item['id'];
$list['status'] = $item['status'];
$cssStatus = null;
@ -4175,9 +4175,9 @@ class learnpath
false,
$id
);
$learPaths = $list->get_flat_list();
foreach ($learPaths as $lp) {
$lpList = $list->get_flat_list();
foreach ($lpList as $lp) {
learnpath::toggle_visibility($lp['iid'], 0);
}
@ -5924,13 +5924,23 @@ class learnpath
}
} else {
$edit_icon .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit_item&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id.'&path_item='.$arrLP[$i]['path'].'" class="btn btn-default">';
$edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
$edit_icon .= Display::return_icon(
'edit.png',
get_lang('LearnpathEditModule'),
array(),
ICON_SIZE_TINY
);
$edit_icon .= '</a>';
}
} else {
if ($arrLP[$i]['item_type'] == TOOL_LP_FINAL_ITEM) {
$edit_icon .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit_item&id='.$arrLP[$i]['id'].'&lp_id='.$this->lp_id.'" class="btn btn-default">';
$edit_icon .= Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_TINY);
$edit_icon .= Display::return_icon(
'edit.png',
get_lang('Edit'),
array(),
ICON_SIZE_TINY
);
$edit_icon .= '</a>';
}
}
@ -12064,8 +12074,3 @@ EOD;
}
}
if (!function_exists('trim_value')) {
function trim_value(& $value) {
$value = trim($value);
}
}

File diff suppressed because it is too large Load Diff

@ -469,7 +469,7 @@ $avg_student_progress = round($avg_student_progress, 2);
$time_spent_on_the_course = 0;
if (!empty($courseInfo)) {
$time_spent_on_the_course = api_time_to_hms(
Tracking:: get_time_spent_on_the_course(
Tracking::get_time_spent_on_the_course(
$user_info['user_id'],
$courseInfo['real_id'],
$sessionId
@ -478,12 +478,15 @@ if (!empty($courseInfo)) {
}
// get information about connections on the platform by student
$first_connection_date = Tracking :: get_first_connection_date($user_info['user_id']);
$first_connection_date = Tracking::get_first_connection_date($user_info['user_id']);
if ($first_connection_date == '') {
$first_connection_date = get_lang('NoConnexion');
}
$last_connection_date = Tracking :: get_last_connection_date($user_info['user_id'], true);
$last_connection_date = Tracking::get_last_connection_date(
$user_info['user_id'],
true
);
if ($last_connection_date == '') {
$last_connection_date = get_lang('NoConnexion');
}
@ -534,70 +537,71 @@ $table_title = Display::return_icon(
).$user_info['complete_name'];
echo Display::page_subheader($table_title);
$userPicture = UserManager::getUserPicture($user_info['user_id']);
$userPicture = UserManager::getUserPicture($user_info['user_id'], USER_IMAGE_SIZE_BIG);
$userGroupManager = new UserGroup();
$userGroups = $userGroupManager->getNameListByUser(
$user_info['user_id'],
UserGroup::NORMAL_CLASS
);
?>
<img src="<?php echo $userPicture ?>">
<div class="row">
<div class="col-sm-6">
<div class="col-sm-2">
<img src="<?php echo $userPicture ?>" class="thumbnail img-responsive">
</div>
<div class="col-sm-5">
<table class="table table-striped table-hover">
<thead>
<tr>
<th><?php echo get_lang('Information'); ?></th>
<th colspan="2"><?php echo get_lang('Information'); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td><?php echo get_lang('Name').' : '.$user_info['complete_name']; ?></td>
<td><?php echo get_lang('Name'); ?></td>
<td><?php echo $user_info['complete_name']; ?></td>
</tr>
<tr>
<td><?php echo get_lang('Email'); ?></td>
<td>
<?php
echo get_lang('Email').' : ';
if (!empty($user_info['email'])) {
echo '<a href="mailto:'.$user_info['email'].'">'.$user_info['email'].'</a>';
} else {
echo get_lang('NoEmail');
} ?>
echo !empty($user_info['email'])
? '<a href="mailto:'.$user_info['email'].'">'.$user_info['email'].'</a>'
: get_lang('NoEmail');
?>
</td>
</tr>
<tr>
<td>
<?php echo get_lang('Tel').' : ';
if (!empty($user_info['phone'])) {
echo $user_info['phone'];
} else {
echo get_lang('NoTel');
}
?>
</td>
<td><?php echo get_lang('Tel'); ?></td>
<td><?php echo !empty($user_info['phone']) ? $user_info['phone'] : get_lang('NoTel'); ?></td>
</tr>
<tr>
<td>
<?php
echo get_lang('OfficialCode').' : ';
if (!empty($user_info['official_code'])) {
echo $user_info['official_code'];
} else {
echo get_lang('NoOfficialCode');
}
?>
</td>
<td><?php echo get_lang('OfficialCode') ?></td>
<td><?php
echo !empty($user_info['official_code'])
? $user_info['official_code']
: get_lang('NoOfficialCode');
?></td>
</tr>
<tr>
<td><?php echo get_lang('OnLine').' : '.$online; ?> </td>
<td><?php echo get_lang('OnLine'); ?></td>
<td><?php echo $online; ?></td>
</tr>
<?php
if (!empty($course_code)) {
?>
<tr>
<td>
<a href="access_details.php?student=<?php echo $student_id; ?>&course=<?php echo $course_code; ?>&origin=<?php echo $origin; ?>&cidReq=<?php echo $course_code; ?>&id_session=<?php echo $sessionId; ?>"><?php echo get_lang('SeeAccesses'); ?></a>
</td>
<td colspan="2"><?php
echo Display::url(
get_lang('SeeAccesses'),
'access_details.php?'.http_build_query([
'student' => $student_id,
'course' => $course_code,
'origin' => $origin,
'cidReq' => $course_code,
'id_session' => $sessionId
])
);
?></td>
</tr>
<?php
}
@ -624,7 +628,7 @@ $userGroups = $userGroupManager->getNameListByUser(
</tbody>
</table>
</div>
<div class="col-sm-6">
<div class="col-sm-5">
<table class="table table-striped table-hover">
<thead>
<tr>

@ -194,7 +194,7 @@ if (isset($_GET['additional_profile_field'])) {
foreach ($_GET['additional_profile_field'] as $fieldId) {
// Fetching only the user that are loaded NOT ALL user in the portal.
$userProfileInfo[$fieldId] = TrackingCourseLog::get_addtional_profile_information_of_field_by_user(
$userProfileInfo[$fieldId] = TrackingCourseLog::getAdditionalProfileInformationOfFieldByUser(
$fieldId,
$user_array
);

@ -1,338 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
// TODO: Is this file deprecated?
/**
* @package chamilo.tracking
* @todo clean code - structure is unclear and difficult to modify
*/
$uInfo = $_REQUEST['uInfo'];
$view = $_REQUEST['view'];
require_once __DIR__.'/../inc/global.inc.php';
// Roles and rights system
$user_id = api_get_user_id();
$course_id = api_get_course_id();
$courseId = api_get_course_int_id();
//YW Hack security to quick fix RolesRights bug
$is_allowed = true;
require_once api_get_path(SYS_CODE_PATH).'exercise/hotpotatoes.lib.php';
/* Header */
/*
$interbreadcrumb[]= array ("url"=>"../group/group.php", "name"=> get_lang('BredCrumpGroups'));
$interbreadcrumb[]= array ("url"=>"../group/group_space.php?gidReq=$_gid", "name"=> get_lang('BredCrumpGroupSpace'));
*/
if ($uInfo) {
$interbreadcrumb[] = array(
"url" => "../user/userInfo.php?uInfo=$uInfo",
"name" => get_lang('BredCrumpUsers')
);
}
$nameTools = get_lang('ToolName');
/* Constants and variables */
$is_allowedToTrack = $is_courseAdmin;
$is_course_member = CourseManager::is_user_subscribed_in_real_or_linked_course(
$user_id,
$courseId
);
// Database Table Definitions
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database::get_main_table(
TABLE_MAIN_SESSION_COURSE_USER
);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
$now = api_get_utc_datetime();
$sql = "SELECT 1
FROM $tbl_session_course_user AS session_course_user
INNER JOIN $tbl_session AS session
ON session_course_user.session_id = session.id
AND ((access_start_date <= '$now'
AND access_end_date >= '$now')
OR (access_start_date IS NULL AND access_end_date IS NULL))
WHERE session_id='".api_get_session_id()."' AND c_id = $courseId";
//echo $sql;
$result = Database::query($sql);
if (!Database::num_rows($result)) {
$disabled = true;
}
$tbl_learnpath_main = Database::get_course_table(TABLE_LP_MAIN);
$tbl_learnpath_item = Database::get_course_table(TABLE_LP_ITEM);
$tbl_learnpath_view = Database::get_course_table(TABLE_LP_VIEW);
$tbl_learnpath_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
$documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
// The variables for the days and the months
$DaysShort = api_get_week_days_short();
$DaysLong = api_get_week_days_long();
$MonthsLong = api_get_months_long();
$MonthsShort = api_get_months_short();
//$is_allowedToTrack = $is_groupTutor; // allowed to track only user of one group
//$is_allowedToTrackEverybodyInCourse = $is_allowed[EDIT_RIGHT]; // allowed to track all students in course
//YW hack security to fix RolesRights bug
$is_allowedToTrack = true; // allowed to track only user of one group
$is_allowedToTrackEverybodyInCourse = $is_allowedToTrack; // allowed to track all students in course
/* MAIN SECTION */
$title[0] = '';
$title[1] = '';
$line = '';
$title_line = '';
// check if uid is tutor of this group
if (($is_allowedToTrack || $is_allowedToTrackEverybodyInCourse)) {
if (!$uInfo && !isset($uInfo)) {
/*
* Display list of user of this group
*/
if ($is_allowedToTrackEverybodyInCourse) {
// if user can track everybody : list user of course
$sql = "SELECT count(user_id)
FROM $TABLECOURSUSER
WHERE c_id = '$courseId' AND relation_type<>".COURSE_RELATION_TYPE_RRHH."";
} else {
// if user can only track one group : list users of this group
$sql = "SELECT count(user)
FROM $TABLECOURSE_GROUPSUSER
WHERE group_id = '$_gid'";
}
$userGroupNb = StatsUtils::getOneResult($sql);
$step = 25; // number of student per page
if ($userGroupNb > $step) {
if (!isset($offset)) {
$offset = 0;
}
$next = $offset + $step;
$previous = $offset - $step;
$navLink = "";
if ($previous >= 0) {
}
if ($next < $userGroupNb) {
}
} else {
$offset = 0;
}
echo $navLink;
if (!settype($offset, 'integer') || !settype($step, 'integer')) {
die('Offset or step variables are not integers.');
} //sanity check of integer vars
if ($is_allowedToTrackEverybodyInCourse) {
// list of users in this course
$sql = "SELECT u.user_id, u.firstname,u.lastname
FROM $TABLECOURSUSER cu , $TABLEUSER u
WHERE cu.user_id = u.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
AND cu.c_id = '$courseId'
LIMIT $offset,$step";
} else {
// list of users of this group
$sql = "SELECT u.user_id, u.firstname,u.lastname
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
WHERE gu.user_id = u.user_id
AND gu.group_id = '$_gid'
LIMIT $offset,$step";
}
$list_users = getManyResults3Col($sql);
for ($i = 0; $i < sizeof($list_users); $i++) {
// just sum $i up
}
} else { // if uInfo is set
/*
* Informations about student uInfo
*/
// these checks exists for security reasons, neither a prof nor a tutor can see statistics of a user from
// another course, or group
if ($is_allowedToTrackEverybodyInCourse) {
// check if user is in this course
$tracking_is_accepted = $is_course_member;
$tracked_user_info = api_get_user_info($uInfo);
$title[0] = $tracked_user_info[1].'_'.$tracked_user_info[2];
} else {
// check if user is in the group of this tutor
$sql = "SELECT u.firstname,u.lastname, u.email
FROM $TABLECOURSE_GROUPSUSER gu , $TABLEUSER u
WHERE gu.user_id = u.user_id
AND gu.group_id = '$_gid'
AND u.user_id = '$uInfo'";
$query = Database::query($sql);
$tracked_user_info = @Database::fetch_assoc($query);
if (is_array($tracked_user_info)) {
$tracking_is_accepted = true;
}
$title[0] = $tracked_user_info['firstname'].'_'.$tracked_user_info['lastname'];
}
if ($tracking_is_accepted) {
$tracked_user_info['email'] == '' ? $mail_link = get_lang(
'NoEmail'
) : $mail_link = Display::encrypted_mailto_link(
$tracked_user_info['email']
);
if (!isset($view)) {
$view = '0000000';
}
//Logins
list($title_line1, $line1) = TrackingUserLogCSV::display_login_tracking_info(
$view,
$uInfo,
$courseId
);
//Exercise results
list($title_line2, $line2) = TrackingUserLogCSV::display_exercise_tracking_info(
$view,
$uInfo,
$_cid
);
//Student publications uploaded
list($title_line3, $line3) = TrackingUserLogCSV::display_student_publications_tracking_info(
$view,
$uInfo,
$courseId
);
//Links usage
list($title_line4, $line4) = TrackingUserLogCSV::display_links_tracking_info(
$view,
$uInfo,
$_cid
);
//Documents downloaded
list($title_line5, $line5) = TrackingUserLogCSV::display_document_tracking_info(
$view,
$uInfo,
$_cid
);
$title_line = $title_line1.$title_line2.$title_line3.$title_line4.$title_line5;
$line = $line1.$line2.$line3.$line4.$line5;
} else {
echo get_lang('ErrorUserNotInGroup');
}
/*
* Scorm contents and Learning Path
*/
//TODO: scorm tools is in work and the logs will change in few days...
/*if(substr($view,5,1) == '1')
{
$new_view = substr_replace($view,'0',5,1);
$title[1]=get_lang('ScormContentColumn');
$line ='';
$sql = "SELECT id, name FROM $tbl_learnpath_main";
$result=Database::query($sql);
$ar=Database::fetch_array($result);
if (is_array($ar))
{
while ($ar['id'] != '') {
$lp_title = stripslashes($ar['name']);
echo "<tr><td>";
echo "<a href='".api_get_self()."?view=".$view."&scormcontopen=".$ar['id']."&uInfo=$uInfo' class='specialLink'>$lp_title</a>";
echo "</td></tr>";
if ($ar['id']==$scormcontopen) { //have to list the students here
$contentId=$ar['id'];
$sql3 = "SELECT iv.status, iv.score, i.title, iv.total_time " .
"FROM $tbl_learnpath_item i " .
"INNER JOIN $tbl_learnpath_item_view iv ON i.id=iv.lp_item_id " .
"INNER JOIN $tbl_learnpath_view v ON iv.lp_view_id=v.id " .
"WHERE (v.user_id=$uInfo and v.lp_id=$contentId) ORDER BY v.id, i.id";
$result3=Database::query($sql3);
$ar3=Database::fetch_array($result3);
if (is_array($ar3)) {
$title_line=get_lang('ScormTitleColumn').";".get_lang('ScormStatusColumn').";".get_lang('ScormScoreColumn').";".get_lang('ScormTimeColumn')."\n";
while ($ar3['status'] != '') {
require_once('../lp/learnpathItem.class.php');
$time = learnpathItem::get_scorm_time('php',$ar3['total_time']);
$line .= $title.';'.$ar3['status'].';'.$ar3['score'].';'.$time."\n";
$ar3=Database::fetch_array($result3);
}
} else {
$line .= get_lang('ScormNeverOpened');
}
}
$ar=Database::fetch_array($result);
}
} else {
$noscorm=true;
}
if ($noscorm) {
$line=get_lang('NoResult');
}
} else {
$new_view = substr_replace($view,'1',5,1);
}*/
}
/*
* Export to a CSV file
* force the browser to save the file instead of opening it
*/
$len = strlen($title_line.$line);
header('Content-type: application/octet-stream');
//header('Content-Type: application/force-download');
header('Content-length: '.$len);
$filename = html_entity_decode(
str_replace(
":",
"",
str_replace(" ", "_", $title[0].'_'.$title[1].'.csv')
)
);
$filename = api_replace_dangerous_char($filename);
if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
header('Content-Disposition: filename= '.$filename);
} else {
header('Content-Disposition: attachment; filename= '.$filename);
}
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
header('Pragma: ');
header('Cache-Control: ');
header(
'Cache-Control: public'
); // IE cannot download from sessions without a cache
}
header('Content-Description: '.$filename);
header('Content-transfer-encoding: binary');
echo api_html_entity_decode($title_line, ENT_QUOTES, $charset);
echo api_html_entity_decode($line, ENT_QUOTES, $charset);
exit;
} else { // not allowed
api_not_allowed();
}

@ -47,9 +47,9 @@ api_display_tool_title($nameTools.$add_group_to_title);
*/
//user has submitted a file
if (isset($_FILES['user_upload'])) {
$upload_ok = process_uploaded_file($_FILES['user_upload']);
if ($upload_ok) {
//file got on the server without problems, now process it
$upload_ok = process_uploaded_file($_FILES['user_upload']);
if ($upload_ok) {
//file got on the server without problems, now process it
$new_path = handle_uploaded_document(
$_course,
$_FILES['user_upload'],
@ -61,21 +61,21 @@ if (isset($_FILES['user_upload'])) {
$_POST['unzip'],
$_POST['if_exists']
);
$new_comment = isset($_POST['comment']) ? Database::escape_string(trim($_POST['comment'])) : '';
$new_title = isset($_POST['title']) ? Database::escape_string(trim($_POST['title'])) : '';
$new_comment = isset($_POST['comment']) ? Database::escape_string(trim($_POST['comment'])) : '';
$new_title = isset($_POST['title']) ? Database::escape_string(trim($_POST['title'])) : '';
if ($new_path && ($new_comment || $new_title))
if (($docid = DocumentManager::get_document_id($_course, $new_path))) {
$table_document = Database::get_course_table(TABLE_DOCUMENT);
$ct = '';
if ($new_path && ($new_comment || $new_title))
if (($docid = DocumentManager::get_document_id($_course, $new_path))) {
$table_document = Database::get_course_table(TABLE_DOCUMENT);
$ct = '';
if ($new_comment) {
$ct .= ", comment='$new_comment'";
}
if ($new_title) {
$ct .= ", title='$new_title'";
}
Database::query("UPDATE $table_document SET".substr($ct, 1)." WHERE id = '$docid'");
}
Database::query("UPDATE $table_document SET".substr($ct, 1)." WHERE id = '$docid'");
}
//check for missing images in html files
$missing_files = check_for_missing_files($base_work_dir.$_POST['curdirpath'].$new_path);
if ($missing_files) {
@ -133,7 +133,7 @@ if (isset($_POST['submit_image'])) {
//they want to create a directory
if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
$added_slash = $path == '/' ? '' : '/';
$dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']);
$dir_name = $path.$added_slash.api_replace_dangerous_char($_POST['dirname']);
$created_dir = create_unexisting_directory(
$_course,
api_get_user_id(),
@ -153,18 +153,19 @@ if (isset($_POST['create_dir']) && $_POST['dirname'] != '') {
}
if (isset($_GET['createdir'])) {
//create the form that asks for the directory name
$new_folder_text = '<form action="'.api_get_self().'" method="POST">';
$new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>';
$new_folder_text .= get_lang('NewDir').' ';
$new_folder_text .= '<input type="text" name="dirname"/>';
$new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>';
$new_folder_text .= '</form>';
//show the form
echo Display::return_message($new_folder_text, 'normal');
} else { //give them a link to create a directory
//create the form that asks for the directory name
$new_folder_text = '<form action="'.api_get_self().'" method="POST">';
$new_folder_text .= '<input type="hidden" name="curdirpath" value="'.$path.'"/>';
$new_folder_text .= get_lang('NewDir').' ';
$new_folder_text .= '<input type="text" name="dirname"/>';
$new_folder_text .= '<input type="submit" name="create_dir" value="'.get_lang('Ok').'"/>';
$new_folder_text .= '</form>';
//show the form
echo Display::return_message($new_folder_text, 'normal');
} else {
//give them a link to create a directory
?>
<p>
<p>
<a href="<?php echo api_get_self(); ?>?path=<?php echo $path; ?>&amp;createdir=1">
<?php echo Display::return_icon('new_folder.gif'); ?>
<?php echo(get_lang('CreateDir')); ?>

@ -42,7 +42,7 @@ $strings['NoGroup'] = 'Sans groupe';
$strings['UrlMeetingToShare'] = 'URL à partager';
$strings['AdminView'] = 'View for administrators';
$strings['max_users_limit'] = 'Utilisateurs maximum' ;
$strings['max_users_limit'] = 'Utilisateurs maximum';
$strings['max_users_limit_help'] = 'Nombre maximum d\'utilisateurs simultanés dans une salle de vidéoconférence de cours ou cours-session. Laisser vide ou sur 0 pour ne pas assigner de limite.';
$strings['MaxXUsersWarning'] = 'Cette salle de conférence est limitée à %s utilisateurs simultanés.';
$strings['MaxXUsersReached'] = 'La limite de %s utilisateurs simultanés a été atteinte dans cette salle de conférence. Veuillez rafraîchir dans quelque minutes pour voir si un siège s\'est libéré, ou attendre l\'ouverture d\'une nouvelle salle de conférence pour participer.';

@ -4,7 +4,7 @@
* Config the plugin
* @package chamilo.plugin.sepe
*/
require_once __DIR__ . '/config.php';
require_once __DIR__.'/config.php';
if (!api_is_platform_admin()) {
die ('You must have admin permissions to install plugins');

@ -37,5 +37,5 @@ if (api_is_platform_admin()) {
$tpl->assign('content', $content);
$tpl->display_one_col_template();
} else {
header('Location:' . api_get_path(WEB_PATH));
header('Location:'.api_get_path(WEB_PATH));
}

@ -32,5 +32,5 @@ if (api_is_platform_admin()) {
$tpl->assign('content', $content);
$tpl->display_one_col_template();
} else {
header('Location:' . api_get_path(WEB_PATH));
header('Location:'.api_get_path(WEB_PATH));
}

@ -52,7 +52,7 @@ function checkIdentificationData()
$result = Database::query($sql);
if (Database::affected_rows($result) > 0) {
return true;
}else{
} else {
return false;
}
}
@ -218,7 +218,7 @@ function getTutorsSpecialty($specialtyId)
$res = Database::query($sql);
$aux = array();
while ($row = Database::fetch_assoc($res)) {
if (!in_array($row['id'],$tutorsList)) {
if (!in_array($row['id'], $tutorsList)) {
$tutor = array();
$tutor['id'] = $row['id'];
if (trim($row['firstname']) != '' || trim($row['lastname']) != '') {
@ -253,7 +253,7 @@ function getInfoSpecialtyTutor($tutorId)
return $row;
}
function freeTeacherList($teacherList,$specialtyId,$platform_user_id)
function freeTeacherList($teacherList, $specialtyId, $platform_user_id)
{
global $tableSepeSpecialtyTutors;
global $tableSepeTutors;
@ -492,7 +492,7 @@ function getSpecialtyTutorId($specialtyId, $tutorId)
return $row['id'];
}
function checkInsertNewLog($platformUserId,$actionId)
function checkInsertNewLog($platformUserId, $actionId)
{
global $tableSepeLogParticipant;
$sql = "SELECT * FROM $tableSepeLogParticipant WHERE platform_user_id = $platformUserId AND action_id = $actionId";

@ -129,5 +129,5 @@ if (api_is_platform_admin()) {
$tpl->assign('content', $content);
$tpl->display_one_col_template();
} else {
header('Location:' . api_get_path(WEB_PATH));
header('Location:'.api_get_path(WEB_PATH));
}

@ -350,10 +350,10 @@ class Sepe
'action_id' => $actionId,
'specialty_origin' => $specialtyOrigin,
'professional_area' => $professionalArea,
'specialty_code' =>$specialtyCode ,
'specialty_code' =>$specialtyCode,
'center_origin' => $centerOrigin,
'center_code' => $centerCode,
'start_date' => $startDate ,
'start_date' => $startDate,
'end_date' => $endDate,
'modality_impartition' => $modalityImpartition,
'classroom_hours' => $classroomHours,
@ -368,7 +368,7 @@ class Sepe
'night_access_number' => $nightAccessNumber,
'night_total_duration' => $nightTotalDuration,
'attendees_count' => $attendeesCount,
'learning_activity_count' => $learningActivityCount ,
'learning_activity_count' => $learningActivityCount,
'attempt_count' => $attemptCount,
'evaluation_activity_count' => $evaluationActivityCount
);
@ -400,17 +400,17 @@ class Sepe
$centerCode = $centro->CODIGO_CENTRO;
$sql = "SELECT id FROM $tableCenters WHERE center_origin='".$centerOrigin."' AND center_code='".$centerCode."';";
$res = Database::query($sql);
if (Database::num_rows($res)>0) {
if (Database::num_rows($res) > 0) {
$aux_row = Database::fetch_assoc($res);
$centerId = $aux_row['id'];
} else {
$sql = "INSERT INTO $tableCenters (center_origin, center_code)
VALUES ('" . $centerOrigin . "','" . $centerCode . "');";
VALUES ('".$centerOrigin."','".$centerCode."');";
Database::query($sql);
$centerId = Database::insert_id();
}
$sql = "INSERT INTO $tableSpecialtyClassroom (specialty_id, center_id)
VALUES ('" . $specialtyId . "','" . $centerId . "')";
VALUES ('".$specialtyId."','".$centerId."')";
Database::query($sql);
$id = Database::insert_id();
@ -450,12 +450,12 @@ class Sepe
$sql = "SELECT id FROM $tableTutors WHERE
document_type='".$documentType."' AND document_number='".$documentNumber."' AND document_letter='".$documentLetter."';";
$res = Database::query($sql);
if (Database::num_rows($res)>0) {
if (Database::num_rows($res) > 0) {
$aux_row = Database::fetch_assoc($res);
$tutorId = $aux_row['id'];
} else {
$sql = "INSERT INTO $tableTutors (document_type, document_number, document_letter)
VALUES ('" . $documentType . "','" . $documentNumber . "','" . $documentLetter . "');";
VALUES ('".$documentType."','".$documentNumber."','".$documentLetter."');";
Database::query($sql);
$tutorId = Database::insert_id();
}
@ -469,7 +469,7 @@ class Sepe
);
}
$sql = "INSERT INTO $tableSpecialityTutors (specialty_id, tutor_id, tutor_accreditation, professional_experience, teaching_competence, experience_teleforming, training_teleforming)
VALUES ('" . $specialtyId . "','" . $tutorId . "','" . $tutorAccreditation . "','" . $professionalExperience . "','" . $teachingCompetence . "','" . $experienceTeleforming . "','" . $trainingTeleforming . "');";
VALUES ('".$specialtyId."','".$tutorId."','".$tutorAccreditation."','".$professionalExperience."','".$teachingCompetence."','".$experienceTeleforming."','".$trainingTeleforming."');";
Database::query($sql);
}
}
@ -511,7 +511,7 @@ class Sepe
$documentLetterCompany = isset($participant->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->LETRA_NIF) ? $participant->CONTRATO_FORMACION->ID_TUTOR_EMPRESA->LETRA_NIF : null;
if (!empty($documentTypeCompany) || !empty($documentNumberCompany) || !empty($documentLetterCompany)) {
$tmp_e = Database::query('SELECT id FROM '.$tableTutorsCompany.' WHERE document_type="'.$documentTypeCompany.'" AND document_number="'.$documentNumberCompany.'" AND document_letter="'.$documentLetterCompany.'";');
if (Database::num_rows($tmp_e)>0) {
if (Database::num_rows($tmp_e) > 0) {
$row_tmp = Database::fetch_assoc($tmp_e);
$tutorIdCompany = $row_tmp['id'];
Database::query("UPDATE $tableTutorsCompany SET company='1' WHERE id='".$tutorIdCompany."'");
@ -531,7 +531,7 @@ class Sepe
$documentLetterTraining = isset($participant->CONTRATO_FORMACION->ID_TUTOR_FORMACION->LETRA_NIF) ? $participant->CONTRATO_FORMACION->ID_TUTOR_FORMACION->LETRA_NIF : null;
if (!empty($documentTypeTraining) || !empty($documentNumberTraining) || !empty($documentLetterTraining)) {
$tmp_f = Database::query('SELECT id FROM '.$tableTutorsCompany.' WHERE document_type="'.$documentTypeTraining.'" AND document_number="'.$documentNumberTraining.'" AND document_letter="'.$documentLetterTraining.'";');
if (Database::num_rows($tmp_f)>0) {
if (Database::num_rows($tmp_f) > 0) {
$row_tmp = Database::fetch_assoc($tmp_f);
$tutorIdTraining = $row_tmp['id'];
Database::query("UPDATE $tableTutorsCompany SET training='1' WHERE id='".$tutorIdTraining."'");
@ -623,7 +623,7 @@ class Sepe
$table_aux = Database::get_main_table('plugin_sepe_participants_specialty');
$sql = "INSERT INTO $table_aux (participant_id,specialty_origin,professional_area,specialty_code,registration_date,leaving_date,center_origin,center_code,start_date,end_date,final_result,final_qualification,final_score)
VALUES ('" . $participantId . "','" . $specialtyOrigin . "','" . $professionalArea . "','" . $specialtyCode . "','" . $registrationDate . "','" . $leavingDate . "','" . $centerOrigin . "','" . $centerCode . "','" . $startDate . "','" . $endDate . "','" . $finalResult . "','" . $finalQualification . "','" . $finalScore . "');";
VALUES ('".$participantId."','".$specialtyOrigin."','".$professionalArea."','".$specialtyCode."','".$registrationDate."','".$leavingDate."','".$centerOrigin."','".$centerCode."','".$startDate."','".$endDate."','".$finalResult."','".$finalQualification."','".$finalScore."');";
Database::query($sql);
$participantSpecialtyId = Database::insert_id();
if (empty($participantSpecialtyId)) {
@ -653,7 +653,7 @@ class Sepe
$table_aux2 = Database::get_main_table('plugin_sepe_participants_specialty_tutorials');
$sql = "INSERT INTO $table_aux2 (participant_specialty_id,center_origin,center_code,start_date,end_date)
VALUES ('" . $participantSpecialtyId . "','" . $centerOrigin . "','" . $centerCode . "','" . $startDate . "','" . $endDate . "');";
VALUES ('".$participantSpecialtyId."','".$centerOrigin."','".$centerCode."','".$startDate."','".$endDate."');";
$rs = Database::query($sql);
if (!$rs) {
return array(
@ -747,7 +747,7 @@ class Sepe
while ($aux = Database::fetch_assoc($rs)) {
$specialtyId = $aux['id'];
$sql = "SELECT * FROM $classRoomTable
WHERE specialty_id='" . $specialtyId . "'";
WHERE specialty_id='".$specialtyId."'";
$resultClassroom = Database::query($sql);
if (Database::num_rows($resultClassroom) === 0) {
return array(
@ -772,14 +772,14 @@ class Sepe
$classroomCenterList->append($classroomCenter);
}
$sql = "SELECT * FROM $specialityTutorTable
WHERE specialty_id='" . $specialtyId . "'";
WHERE specialty_id='".$specialtyId."'";
$resultSpecialtyTutor = Database::query($sql);
$trainingTutors = new ArrayObject();
if (Database::num_rows($resultSpecialtyTutor)) {
while ($tmp_aux = Database::fetch_assoc($resultSpecialtyTutor)) {
$sql = "SELECT * FROM $tutorTable
WHERE id='" . $tmp_aux['tutor_id'] . "'
WHERE id='".$tmp_aux['tutor_id']."'
LIMIT 1";
$rs_tutor = Database::query($sql);
if (Database::num_rows($rs_tutor)) {
@ -906,8 +906,8 @@ class Sepe
$obj->HORARIO_TARDE->DURACION_TOTAL = $aux['afternoon_total_duration'];
}
if (!empty($aux['night_participants_number']) ||
!empty($aux['night_access_number']) ||
if (!empty($aux['night_participants_number']) ||
!empty($aux['night_access_number']) ||
!empty($aux['night_total_duration'])
) {
$obj->HORARIO_NOCHE = new stdClass();
@ -916,9 +916,9 @@ class Sepe
$obj->HORARIO_NOCHE->DURACION_TOTAL = $aux['night_total_duration'];
}
if (!empty($aux['attendees_count']) ||
!empty($aux['learning_activity_count']) ||
!empty($aux['attempt_count']) ||
if (!empty($aux['attendees_count']) ||
!empty($aux['learning_activity_count']) ||
!empty($aux['attempt_count']) ||
!empty($aux['evaluation_activity_count'])
) {
$obj->SEGUIMIENTO_EVALUACION = new stdClass();
@ -963,7 +963,7 @@ class Sepe
$participantId = $aux['id'];
$sql = "SELECT * FROM $participantsSpecialityTable
WHERE participant_id='" . $participantId . "'";
WHERE participant_id='".$participantId."'";
$resultParticipantSpecialty = Database::query($sql);
$namespace = null;
@ -971,7 +971,7 @@ class Sepe
while ($tmp = Database::fetch_assoc($resultParticipantSpecialty)) {
$participantSpecialtyId = $tmp['id'];
$sql = "SELECT * FROM $participantsSpecialityTutorialsTable
WHERE participant_specialty_id='" . $participantSpecialtyId . "'";
WHERE participant_specialty_id='".$participantSpecialtyId."'";
$resultTutorials = Database::query($sql);
$classroomTutorials = new ArrayObject();

@ -22,6 +22,15 @@ use Doctrine\ORM\Mapping as ORM;
*/
class CourseCategory
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
@ -71,17 +80,6 @@ class CourseCategory
*/
private $authCatChild;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* Set name
*
@ -260,6 +258,6 @@ class CourseCategory
{
$name = strip_tags($this->name);
return "({$this->code}) $name";
return "$name ({$this->code})";
}
}

@ -29,7 +29,7 @@ class CourseCategoryRepository extends EntityRepository
)
->where(
$qb->expr()->eq('a.accessUrlId', $accessUrl)
)
)->orderBy('c.treePos', 'ASC')
->getQuery();
return $query->getResult();
@ -59,4 +59,4 @@ class CourseCategoryRepository extends EntityRepository
return (int) $count;
}
}
}

@ -7,7 +7,6 @@
namespace Chamilo\ThemeBundle\Theme;
use Assetic\Asset\AssetCollection;
use Assetic\Asset\AssetReference;
use Assetic\Factory\AssetFactory;
@ -19,9 +18,12 @@ use Symfony\Component\DependencyInjection\Container;
use Chamilo\FoundationBundle\Util\DependencyResolver;
use Symfony\Component\HttpKernel\Config\FileLocator;
/**
* Class ThemeManager
* @package Chamilo\ThemeBundle\Theme
*/
class ThemeManager
{
/** @var Container */
protected $container;
@ -29,11 +31,16 @@ class ThemeManager
protected $javascripts = array();
protected $locations = array();
protected $locations = array();
protected $resolverClass;
function __construct($container, $resolverClass = null)
/**
* ThemeManager constructor.
* @param $container
* @param null $resolverClass
*/
public function __construct($container, $resolverClass = null)
{
$this->container = $container;
$this->resolverClass = $resolverClass ?: 'Chamilo\ThemeBundle\Util\DependencyResolver';
@ -105,5 +112,4 @@ class ThemeManager
{
return $this->container->get('file_locator');
}
}

@ -9,6 +9,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Mapping as ORM;
//use Sonata\UserBundle\Entity\BaseUser as BaseUser;
use Doctrine\ORM\Query\Expr\Join;
use Sonata\UserBundle\Model\User as BaseUser;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\File;
@ -2443,4 +2444,32 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser
{
return $this->sessionAsGeneralCoach;
}
/**
* Get the HRM list from the user
* @return array
*/
public function getHrm()
{
$em = \Database::getManager();
$qb = $em->createQueryBuilder();
$hrmList = $qb
->select('uru')
->from('ChamiloCoreBundle:UserRelUser', 'uru')
->innerJoin('ChamiloCoreBundle:AccessUrlRelUser', 'auru', Join::WITH, 'auru.userId = uru.friendUserId')
->where(
$qb->expr()->eq('auru.accessUrlId', api_get_current_access_url_id())
)
->andWhere(
$qb->expr()->eq('uru.userId', $this->id)
)
->andWhere(
$qb->expr()->eq('uru.relationType', USER_RELATION_TYPE_RRHH)
)
->getQuery()
->getResult();
return $hrmList;
}
}

@ -0,0 +1,14 @@
<?php
exit;
/* For license terms, see /license.txt */
if (PHP_SAPI != 'cli') {
die('This script can only be launched from the command line');
}
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'install/install.lib.php';
$connection = Database::getManager()->getConnection();
fixPostGroupIds($connection);

@ -0,0 +1,18 @@
<?php
/* For licensing terms, see /license.txt */
exit;
if (PHP_SAPI != 'cli') {
die('This script can only be executed from the command line');
}
require_once __DIR__.'/../../main/inc/global.inc.php';
$userInfo = UserManager::logInAsFirstAdmin();
if (api_is_platform_admin()) {
echo 'Logged as admin user: '.$userInfo['complete_name'];
} else {
echo 'NOT logged as admin ';
}
Loading…
Cancel
Save