Internal: Update from 1.11.x

pull/3466/head
Julio Montoya 5 years ago
parent 14963671d8
commit 54c2b4743a
  1. 2
      public/main/inc/lib/AnnouncementEmail.php
  2. 7
      public/main/inc/lib/agenda.lib.php
  3. 3
      public/main/session/index.php
  4. 6
      public/main/session/resume_session.php
  5. 6
      public/main/session/session_add.php
  6. 21
      public/main/session/session_category_edit.php
  7. 4
      public/main/session/session_category_list.php
  8. 1
      public/main/session/session_course_edit.php
  9. 1
      public/main/session/session_course_list.php
  10. 1
      public/main/session/session_course_user.php
  11. 24
      public/main/session/session_course_user_list.php
  12. 3
      public/main/session/session_edit.php
  13. 1
      public/main/session/session_export.php
  14. 1
      public/main/session/session_import.php
  15. 1
      public/main/session/session_import_drh.php
  16. 102
      public/main/session/session_list.php
  17. 1
      public/main/session/session_user_import.php
  18. 1
      public/main/social/download.php
  19. 1
      public/main/social/friends.php
  20. 1
      public/main/social/group_add.php
  21. 1
      public/main/social/group_edit.php
  22. 1
      public/main/social/group_invitation.php
  23. 1
      public/main/social/group_members.php
  24. 1
      public/main/social/group_topics.php
  25. 1
      public/main/social/group_waiting_list.php
  26. 1
      public/main/social/groups.php
  27. 2
      public/main/social/home.php
  28. 1
      public/main/social/map.php
  29. 1
      public/main/social/message_for_group_form.inc.php
  30. 4
      public/main/social/my_skills_report.php
  31. 3
      public/main/social/personal_data.php
  32. 78
      public/main/social/profile.php
  33. 1
      public/main/social/profile_friends_and_groups.inc.php
  34. 1
      public/main/social/promoted_messages.php
  35. 1
      public/main/social/search.php
  36. 1
      public/main/social/skills_ranking.php
  37. 1
      public/main/social/skills_wheel.php
  38. 1
      public/main/social/terms.php
  39. 18
      public/main/social/vcard_export.php
  40. 1
      public/main/social/view_promoted_message.php
  41. 29
      public/main/survey/fillsurvey.php
  42. 1
      public/main/survey/generate_link.php
  43. 1
      public/main/survey/meeting.php
  44. 1
      public/main/survey/pending.php
  45. 23
      public/main/survey/preview.php
  46. 9
      public/main/survey/reporting.php
  47. 158
      public/main/survey/survey.lib.php
  48. 93
      public/main/survey/survey.php
  49. 97
      public/main/survey/surveyUtil.class.php
  50. 1
      public/main/survey/survey_invitation.php
  51. 29
      public/main/survey/survey_invite.php
  52. 7
      public/main/survey/survey_list.php
  53. 93
      public/main/survey/survey_question.php
  54. 97
      public/main/tracking/courseLog.php
  55. 1
      public/main/tracking/course_log_resources.php
  56. 1
      public/main/tracking/course_log_tools.php
  57. 4
      public/main/tracking/course_session_report.php
  58. 1
      public/main/tracking/exams.php
  59. 1
      public/main/tracking/question_course_report.php
  60. 1
      public/main/tracking/total_time.php
  61. 1
      public/main/user/add_users_to_session.php
  62. 1
      public/main/user/career_diagram.php
  63. 1
      public/main/user/class.php
  64. 2
      public/main/user/classes.php
  65. 1
      public/main/user/resume_session.php
  66. 1
      public/main/user/session_list.php
  67. 122
      public/main/user/user.php
  68. 59
      public/main/user/user_export.php
  69. 1
      public/main/webservices/access_url.php
  70. 2
      public/main/webservices/additional_webservices.php
  71. 4
      public/main/webservices/api/tests/SaveUserTest.php
  72. 2
      public/main/webservices/api/tests/UpdateUserPauseTrainingTest.php
  73. 6
      public/main/webservices/api/v2.php
  74. 1
      public/main/webservices/cm_soap.php
  75. 1
      public/main/webservices/cm_soap_announcements.php
  76. 1
      public/main/webservices/cm_soap_course.php
  77. 1
      public/main/webservices/cm_soap_courses.php
  78. 1
      public/main/webservices/cm_soap_forum.php
  79. 1
      public/main/webservices/cm_soap_inbox.php
  80. 1
      public/main/webservices/cm_soap_user.php
  81. 1
      public/main/webservices/cm_webservice.php
  82. 1
      public/main/webservices/cm_webservice_announcements.php
  83. 1
      public/main/webservices/cm_webservice_course.php
  84. 1
      public/main/webservices/cm_webservice_courses.php
  85. 1
      public/main/webservices/cm_webservice_forum.php
  86. 1
      public/main/webservices/cm_webservice_inbox.php
  87. 1
      public/main/webservices/cm_webservice_user.php
  88. 2
      public/main/webservices/courses_list.rest.php
  89. 1
      public/main/webservices/courses_list.soap.php
  90. 1
      public/main/webservices/gradebook.php
  91. 1
      public/main/webservices/http-auth.php
  92. 1
      public/main/webservices/lp.php
  93. 1
      public/main/webservices/registration.soap.php
  94. 1
      public/main/webservices/soap.php
  95. 5
      public/main/webservices/soap.test.php
  96. 2
      public/main/webservices/soap_course.php
  97. 2
      public/main/webservices/soap_report.php
  98. 2
      public/main/webservices/soap_session.php
  99. 2
      public/main/webservices/soap_user.php
  100. 1
      public/main/webservices/testip.php
  101. Some files were not shown because too many files have changed in this diff Show More

@ -230,7 +230,7 @@ class AnnouncementEmail
$id = $this->announcement->getIid();
$course_id = $this->course['real_id'];
$sql = "SELECT * FROM $table
WHERE c_id = $course_id AND announcement_id = $id ";
WHERE announcement_id = $id ";
$rs = Database::query($sql);
while ($row = Database::fetch_array($rs)) {
$result[] = $row;

@ -276,9 +276,7 @@ class Agenda
$id = $event->getId();
break;
case 'course':
$senderId = $this->getSenderId();
$sessionId = $this->getSessionId();
$userEntity = api_get_user_entity(api_get_user_id());
$sessionEntity = api_get_session_entity($sessionId);
$courseEntity = api_get_course_entity($this->course['real_id']);
$groupEntity = api_get_group_entity(api_get_group_id());
@ -300,10 +298,7 @@ class Agenda
$event->setParentEventId($parentEventId);
}
$event
// ->addCourseLink($courseEntity, $groupEntity, $sessionEntity)
->setParent($courseEntity)
;
$event->setParent($courseEntity);
if (!empty($usersToSend)) {
$sendTo = $this->parseSendToArray($usersToSend);

@ -42,7 +42,7 @@ Session::erase('duration_time');
$userId = api_get_user_id();
$session_info = SessionManager::fetch($session_id);
$session_list = SessionManager::get_sessions_by_general_coach(api_get_user_id());
$session_list = SessionManager::get_sessions_by_coach(api_get_user_id());
$courseList = SessionManager::get_course_list_by_session_id($session_id);
$userIsGeneralCoach = SessionManager::user_is_general_coach($userId, $session_id);
@ -663,7 +663,6 @@ $tabs = [
$tabToHide = api_get_setting('session.hide_tab_list');
if (!empty($tabToHide)) {
$tabToHide = explode(',', $tabToHide);
foreach ($tabToHide as $columnId) {
unset($headers[$columnId]);
unset($tabs[$columnId]);

@ -24,7 +24,6 @@ if (empty($sessionId)) {
}
SessionManager::protectSession($sessionId);
$codePath = api_get_path(WEB_CODE_PATH);
$tool_name = get_lang('Session overview');
@ -173,10 +172,7 @@ if (0 === $session->getNbrCourses()) {
foreach ($courses as $sessionRelCourse) {
$course = $sessionRelCourse->getCourse();
// Select the number of users
$numberOfUsers = SessionManager::getCountUsersInCourseSession(
$course,
$session
);
$numberOfUsers = SessionManager::getCountUsersInCourseSession($course, $session);
// Get coachs of the courses in session
$namesOfCoaches = [];

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
@ -383,6 +384,7 @@ if ($form->validate()) {
$showDescription = isset($params['show_description']) ? 1 : 0;
$sendSubscriptionNotification = isset($params['send_subscription_notification']);
$isThisImageCropped = isset($params['picture_crop_result']);
$status = isset($params['status']) ? $params['status'] : 0;
$extraFields = [];
foreach ($params as $key => $value) {
@ -435,7 +437,9 @@ if ($form->validate()) {
$showDescription,
$extraFields,
null,
$sendSubscriptionNotification
$sendSubscriptionNotification,
api_get_current_access_url_id(),
$status
);
if ($return == strval(intval($return))) {

@ -1,15 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Edition script for sessions categories.
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
// setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(true);
$id = intval($_GET['id']);
$id = (int) $_GET['id'];
$formSent = 0;
$errorMsg = '';
@ -31,9 +30,16 @@ if (!$infos = Database::fetch_array($result)) {
header('Location: session_list.php');
exit();
}
$year_start = $month_start = $day_start = null;
$year_end = $month_end = $day_end = null;
list($year_start, $month_start, $day_start) = explode('-', $infos['date_start']);
list($year_end, $month_end, $day_end) = explode('-', $infos['date_end']);
if ($infos['date_start']) {
list($year_start, $month_start, $day_start) = explode('-', $infos['date_start']);
}
if ($infos['date_end']) {
list($year_end, $month_end, $day_end) = explode('-', $infos['date_end']);
}
if (!api_is_platform_admin() && $infos['session_admin_id'] != $_user['user_id'] && !api_is_session_admin()) {
api_not_allowed(true);
@ -94,7 +100,8 @@ if (!empty($return)) {
<div class="form-group">
<div class="col-sm-offset-3 col-sm-6">
<?php echo get_lang('The time limit of a category is referential, will not affect the boundaries of a training session'); ?>
<a href="javascript://" onclick="if(document.getElementById('options').style.display == 'none'){document.getElementById('options').style.display = 'block';}else{document.getElementById('options').style.display = 'none';}"><?php echo get_lang('Edit time limit'); ?></a>
<a href="javascript://" onclick="if(document.getElementById('options').style.display == 'none'){document.getElementById('options').style.display = 'block';}else{document.getElementById('options').style.display = 'none';}">
<?php echo get_lang('Edit time limit'); ?></a>
</div>
</div>
<div style="display: <?php echo $formSent ? 'display' : 'none'; ?>;" id="options">

@ -2,9 +2,7 @@
/* For licensing terms, see /license.txt */
/**
* List sessions categories.
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;
@ -23,7 +24,7 @@ $course_code = Database::escape_string(trim($_GET['course_code']));
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$page = isset($_GET['page']) ? intval($_GET['page']) : null;
$page = isset($_GET['page']) ? (int) $_GET['page'] : null;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$default_sort = api_sort_by_first_name() ? 'firstname' : 'lastname';
$sort = isset($_GET['sort']) && in_array($_GET['sort'], ['lastname', 'firstname', 'username'])
@ -41,7 +42,7 @@ if (is_array($idChecked)) {
$my_temp = [];
foreach ($idChecked as $id) {
// forcing the intval
$my_temp[] = intval($id);
$my_temp[] = (int) $id;
}
$idChecked = $my_temp;
}
@ -82,19 +83,28 @@ switch ($action) {
$limit = 20;
$from = $page * $limit;
$is_western_name_order = api_is_western_name_order();
$urlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$urlId = api_get_current_access_url_id();
$sql = "
SELECT DISTINCT u.user_id,"
.($is_western_name_order ? 'u.firstname, u.lastname' : 'u.lastname, u.firstname')
.", u.username, scru.user_id as is_subscribed
FROM $tbl_session_rel_user s
INNER JOIN $tbl_user u ON (u.user_id=s.user_id)
INNER JOIN $tbl_user u
ON (u.id = s.user_id)
INNER JOIN $urlTable url
ON (url.user_id = u.id)
LEFT JOIN $tbl_session_rel_course_rel_user scru
ON (s.session_id = scru.session_id AND s.user_id = scru.user_id AND scru.c_id = $courseId)
WHERE s.session_id = $id_session
WHERE
s.session_id = $id_session AND
url.access_url_id = $urlId
ORDER BY $sort $direction
LIMIT $from,".($limit + 1);
if ('desc' == $direction) {
if ($direction === 'desc') {
$direction = 'asc';
} else {
$direction = 'desc';
@ -102,9 +112,7 @@ if ('desc' == $direction) {
$result = Database::query($sql);
$users = Database::store_result($result);
$nbr_results = sizeof($users);
$nbr_results = count($users);
$tool_name = get_lang('Session').': '.$session_name.' - '.get_lang('Course').': '.$course_title;
$interbreadcrumb[] = ['url' => 'session_list.php', 'name' => get_lang('Session list')];

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -79,6 +80,8 @@ if (api_is_multiple_url_enabled()) {
$result = Database::query($sql);
$coaches = Database::store_result($result);
$thisYear = date('Y');
$coachesOption = [
'' => '----- '.get_lang('none').' -----',
];

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;

@ -6,7 +6,6 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$error_message = '';
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(true);
api_protect_limit_for_session_admin();

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;

@ -1,11 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/**
* List sessions in an efficient and usable way.
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
@ -16,7 +16,40 @@ $htmlHeadXtra[] = api_get_jqgrid_js();
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$idChecked = isset($_REQUEST['idChecked']) ? $_REQUEST['idChecked'] : null;
$list_type = isset($_REQUEST['list_type']) ? $_REQUEST['list_type'] : 'custom';
$listType = isset($_REQUEST['list_type']) ? Security::remove_XSS($_REQUEST['list_type']) : SessionManager::getDefaultSessionTab();
switch ($action) {
case 'delete':
$sessionInfo = api_get_session_info($idChecked);
if ($sessionInfo) {
$response = SessionManager::delete($idChecked);
if ($response) {
Display::addFlash(
Display::return_message(get_lang('Deleted').': '.Security::remove_XSS($sessionInfo['name']))
);
}
}
$url = 'session_list.php';
if ('custom' !== $listType) {
$url = 'session_list.php?list_type='.$listType;
}
header('Location: '.$url);
exit();
break;
case 'copy':
$result = SessionManager::copy($idChecked);
if ($result) {
Display::addFlash(Display::return_message(get_lang('ItemCopied')));
} else {
Display::addFlash(Display::return_message(get_lang('ThereWasAnError'), 'error'));
}
$url = 'session_list.php';
if ('custom' !== $listType) {
$url = 'session_list.php?list_type='.$listType;
}
header('Location: '.$url);
break;
}
$tool_name = get_lang('SessionList');
Display::display_header($tool_name);
@ -92,22 +125,19 @@ if (isset($_REQUEST['id_category'])) {
}
}
$url .= '&list_type='.$list_type;
$result = SessionManager::getGridColumns($list_type);
$url .= '&list_type='.$listType;
$result = SessionManager::getGridColumns($listType);
$columns = $result['columns'];
$column_model = $result['column_model'];
// Autowidth
$extra_params['autowidth'] = 'true';
// height auto
$extra_params['height'] = 'auto';
// Custom params
$extra_params['sortname'] = 'display_end_date';
$extra_params['sortorder'] = 'desc';
switch ($listType) {
case 'custom':
$extra_params['sortname'] = 'display_end_date';
$extra_params['sortorder'] = 'desc';
break;
}
if (!isset($_GET['keyword'])) {
$extra_params['postData'] = [
@ -157,7 +187,7 @@ $orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
grid.showCol('name').trigger('reloadGrid');
for (key in added_cols) {
grid.showCol(key);
};
}
}
var second_filters = [];
@ -216,9 +246,8 @@ $orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
?>
setSearchSelect("status");
var grid = $("#sessions"),
prmSearch = {
var prmSearch = {
multipleSearch : true,
overlay : false,
width: 'auto',
@ -295,7 +324,15 @@ $orderUrl = api_get_path(WEB_AJAX_PATH).'session.ajax.php?a=order';
searchDialogAll.addClass("table");
var searchDialog = $("#searchmodfbox_"+grid[0].id);
searchDialog.addClass("ui-jqgrid ui-widget ui-widget-content ui-corner-all");
searchDialog.css({position:"absolute", "z-index":"100", "float":"left", "top":"55%", "left" : "25%", "padding" : "5px", "border": "1px solid #CCC"})
searchDialog.css({
position: "absolute",
"z-index": "100",
"float": "left",
"top": "55%",
"left": "25%",
"padding": "5px",
"border": "1px solid #CCC"
})
var gbox = $("#gbox_"+grid[0].id);
gbox.before(searchDialog);
gbox.css({clear:"left"});
@ -326,14 +363,6 @@ if (api_is_platform_admin()) {
Display::return_icon('folder.png', get_lang('Sessions categories list'), '', ICON_SIZE_MEDIUM).'</a>';
}
/*if ($list_type == 'complete') {
echo '<a href="'.api_get_self().'?list_type=simple">'.
Display::return_icon('view_remove.png', get_lang('Simple'), '', ICON_SIZE_MEDIUM).'</a>';
} else {
echo '<a href="'.api_get_self().'?list_type=complete">'.
Display::return_icon('view_text.png', get_lang('Complete'), '', ICON_SIZE_MEDIUM).'</a>';
}*/
echo $actions;
if (api_is_platform_admin()) {
echo '<div class="pull-right">';
@ -341,14 +370,13 @@ if (api_is_platform_admin()) {
$form = new FormValidator(
'search_simple',
'get',
'',
api_get_self().'?list_type='.$listType,
'',
[],
FormValidator::LAYOUT_INLINE
);
$form->addElement('text', 'keyword', null, [
'aria-label' => get_lang('Search'),
]);
$form->addElement('text', 'keyword', null, ['aria-label' => get_lang('Search')]);
$form->addHidden('list_type', $listType);
$form->addButtonSearch(get_lang('Search'));
$form->display();
echo '</div>';
@ -359,22 +387,8 @@ if (api_is_platform_admin()) {
}
echo '</div>';
$tabs = [
[
'content' => get_lang('SessionListCustom'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php',
],
[
'content' => get_lang('SessionList'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list_simple.php',
],
[
'content' => get_lang('Complete'),
'url' => api_get_path(WEB_CODE_PATH).'session/session_list_simple.php?list_type=complete',
],
];
echo SessionManager::getSessionListTabs($listType);
echo Display::tabsOnlyLink($tabs, 1);
echo '<div id="session-table" class="table-responsive">';
echo Display::grid_html('sessions');
echo '</div>';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
@ -54,7 +55,6 @@ $social_group_block = SocialManager::getGroupBlock($user_id);
$friend_html = SocialManager::listMyFriendsBlock($user_id);
// Block Social Sessions
$wallSocialAddPost = SocialManager::getWallForm(api_get_self());
$socialAutoExtendLink = SocialManager::getAutoExtendLink($user_id, $countPost);

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,12 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;
/**
* Show the skills report.
*
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
*/
use Chamilo\CoreBundle\Framework\Container;
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Repository\LegalRepository;
@ -8,7 +9,6 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_set_more_memory_and_time_limits();
api_block_anonymous_users();
if (api_get_configuration_value('disable_gdpr')) {
@ -151,7 +151,6 @@ switch ($action) {
$explanation = $form->getSubmitValue('explanation');
UserManager::createDataPrivacyExtraFields();
UserManager::update_extra_field_value(
$userId,
'request_for_legal_agreement_consent_removal',

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
@ -20,7 +21,29 @@ if ('true' != api_get_setting('allow_social_tool')) {
exit;
}
$bossId = isset($_REQUEST['sup']) ? (int) $_REQUEST['sup'] : 0;
$user_id = api_get_user_id();
$redirectToBossId = 0;
if (!empty($bossId)) {
$bossList = UserManager::getStudentBossList($user_id);
if (!empty($bossList)) {
foreach ($bossList as $boss) {
$bossId = $boss['boss_id'];
$bossInfo = api_get_user_info($bossId);
if (!empty($bossInfo)) {
$redirectToBossId = $bossId;
break;
}
}
}
}
if (!empty($redirectToBossId)) {
header('Location: '.api_get_self().'?u='.$redirectToBossId);
exit;
}
$friendId = isset($_GET['u']) ? (int) $_GET['u'] : api_get_user_id();
$show_full_profile = true;
//social tab
@ -101,26 +124,7 @@ if (isset($_GET['u']) && is_numeric($_GET['u']) && $_GET['u'] != api_get_user_id
];
}
Session::write('social_user_id', (int) $user_id);
// Setting some course info
/*$course_list_code = [];
$personal_course_list = UserManager::get_personal_session_course_list($friendId, 50);
$i = 1;
$list = [];
if (is_array($personal_course_list)) {
foreach ($personal_course_list as $my_course) {
if ($i <= 10) {
$list[] = SocialManager::get_logged_user_course_html($my_course, $i);
$course_list_code[] = ['code' => $my_course['code']];
} else {
break;
}
$i++;
}
//to avoid repeted courses
$course_list_code = array_unique_dimensional($course_list_code);
}*/
Session::write('social_user_id', $user_id);
// Social Block Menu
$menu = SocialManager::show_social_menu(
@ -132,7 +136,6 @@ $menu = SocialManager::show_social_menu(
//Setting some session info
$user_info = api_get_user_info($friendId);
//$sessionList = SessionManager::getSessionsFollowedByUser($friendId, $user_info['status']);
$sessionList = [];
// My friends
@ -150,20 +153,6 @@ $listInvitations = '';
if ($show_full_profile) {
$social_group_info_block = SocialManager::getGroupBlock($friendId);
/*
$my_courses = null;
// COURSES LIST
if (is_array($list)) {
$i = 1;
foreach ($list as $key => $value) {
if (empty($value[2])) { //if out of any session
$my_courses .= $value[1];
$i++;
}
}
$social_course_block .= $my_courses;
}*/
// Block Social Sessions
if (count($sessionList) > 0) {
$social_session_block = $sessionList;
@ -181,17 +170,6 @@ if ($show_full_profile) {
// Images uploaded by course
$file_list = '';
/*
if (is_array($course_list_code) && count($course_list_code) > 0) {
foreach ($course_list_code as $course) {
$file_list .= UserManager::get_user_upload_files_by_course(
$user_id,
$course['code'],
'images'
);
}
}*/
$count_pending_invitations = 0;
if (!isset($_GET['u']) ||
(isset($_GET['u']) && $_GET['u'] == api_get_user_id())
@ -255,14 +233,6 @@ if ($show_full_profile) {
}
$images_uploaded = null;
// Images uploaded by course
/*if (!empty($file_list)) {
$images_uploaded .= '<div><h3>'.get_lang('Uploaded images').'</h3></div>';
$images_uploaded .= '<div class="social-content-information">';
$images_uploaded .= $file_list;
$images_uploaded .= '</div>';
$socialRightInformation .= SocialManager::social_wrapper_div($images_uploaded, 4);
}*/
}
if (!empty($user_info['competences']) || !empty($user_info['diplomas'])

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use JeroenDesloovere\VCard\VCard;
@ -11,7 +12,6 @@ use JeroenDesloovere\VCard\VCard;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
api_protect_admin_script();
if (isset($_REQUEST['userId'])) {
$userId = intval($_REQUEST['userId']);
@ -22,10 +22,24 @@ if (isset($_REQUEST['userId'])) {
// Return User Info to vCard Export
$userInfo = api_get_user_info($userId, true, false, true);
/* Get the relationship between current user and vCard user */
$currentUserId = api_get_user_id();
$hasRelation = SocialManager::get_relation_between_contacts(
$currentUserId,
$userId,
true
);
if ($hasRelation == 0) {
/* if has not relation, check if are admin */
api_protect_admin_script();
}
if (empty($userInfo)) {
api_not_allowed(true);
}
if (api_get_user_id() != $userId && !SocialManager::get_relation_between_contacts(api_get_user_id(), $userId)) {
api_not_allowed(true);
}
// Pre-Loaded User Info
$language = get_lang('Language').': '.$userInfo['language'];

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;

@ -378,7 +378,6 @@ if (count($_POST) > 0) {
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
$option_value = $row['value'];
//$option_value = 0;
$survey_question_answer = $value;
// We save the answer after making sure that a possible previous attempt is deleted
@ -406,7 +405,6 @@ if (count($_POST) > 0) {
}
$user_id = api_get_user_id();
if (0 == $user_id) {
$user_id = $survey_invitation['user'];
}
@ -674,7 +672,8 @@ if (1 == $survey_data['shuffle']) {
$shuffle = ' BY RAND() ';
}
if ((isset($_GET['show']) && '' != $_GET['show']) ||
$pageBreakText = [];
if ((isset($_GET['show']) && $_GET['show'] != '') ||
isset($_POST['personality'])
) {
// Getting all the questions for this page and add them to a
@ -709,6 +708,7 @@ if ((isset($_GET['show']) && '' != $_GET['show']) ||
} else {
if ('pagebreak' == $row['type']) {
$counter++;
$pageBreakText[$counter] = $row['survey_question'];
} else {
$paged_questions[$counter][] = $row['question_id'];
}
@ -1001,6 +1001,7 @@ if ((isset($_GET['show']) && '' != $_GET['show']) ||
$counter++;
} elseif ('pagebreak' == $row['type']) {
$counter++;
$pageBreakText[$counter] = $row['survey_question'];
} else {
// ids from question of the current survey
$paged_questions_sec[$counter][] = $row['question_id'];
@ -1105,6 +1106,7 @@ if ((isset($_GET['show']) && '' != $_GET['show']) ||
} else {
if ('pagebreak' == $row['type']) {
$counter++;
$pageBreakText[$counter] = $row['survey_question'];
} else {
// ids from question of the current survey
$paged_questions[$counter][] = $row['question_id'];
@ -1237,6 +1239,11 @@ $form = new FormValidator(
);
$form->addHidden('language', $p_l);
$showNumber = true;
if (SurveyManager::hasDependency($survey_data)) {
$showNumber = false;
}
if (isset($questions) && is_array($questions)) {
$originalShow = isset($_GET['show']) ? (int) $_GET['show'] : 0;
$questionCounter = 1;
@ -1252,6 +1259,18 @@ if (isset($questions) && is_array($questions)) {
$form->addHtml('<div class="start-survey">');
$js = '';
if (isset($pageBreakText[$originalShow]) && !empty(strip_tags($pageBreakText[$originalShow]))) {
// Only show page-break texts if there is something there, apart from
// HTML tags
$form->addHtml(
'<div>'.
Security::remove_XSS($pageBreakText[$originalShow]).
'</div>'
);
$form->addHtml('<br />');
}
foreach ($questions as $key => &$question) {
$ch_type = 'ch_'.$question['type'];
$questionNumber = $questionCounter;
@ -1273,7 +1292,9 @@ if (isset($questions) && is_array($questions)) {
// @todo move this in a function.
$form->addHtml('<div class="survey_question '.$ch_type.' '.$parentClass.'">');
$form->addHtml('<div style="float:left; font-weight: bold; margin-right: 5px;"> '.$questionNumber.'. </div>');
if ($showNumber) {
$form->addHtml('<div style="float:left; font-weight: bold; margin-right: 5px;"> '.$questionNumber.'. </div>');
}
$form->addHtml('<div>'.Security::remove_XSS($question['survey_question']).'</div> ');
$userAnswerData = SurveyUtil::get_answers_of_question_by_user($question['survey_id'], $question['question_id']);

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course;

@ -76,6 +76,7 @@ if (isset($_POST['finish_survey'])) {
}
$questions = [];
$pageBreakText = [];
if (isset($_GET['show'])) {
// Getting all the questions for this page and add them to a
// multidimensional array where the first index is the page.
@ -101,6 +102,7 @@ if (isset($_GET['show'])) {
} else {
if ('pagebreak' == $row['type']) {
$counter++;
$pageBreakText[$counter] = $row['survey_question'];
} else {
$paged_questions[$counter][] = $row['question_id'];
}
@ -191,7 +193,24 @@ if (is_array($questions) && count($questions) > 0) {
$counter = $before + 1;
}
$showNumber = true;
if (SurveyManager::hasDependency($survey_data)) {
$showNumber = false;
}
$js = '';
if (isset($pageBreakText[$originalShow]) && !empty(strip_tags($pageBreakText[$originalShow]))) {
// Only show page-break texts if there is something there, apart from
// HTML tags
$form->addHtml(
'<div>'.
Security::remove_XSS($pageBreakText[$originalShow]).
'</div>'
);
$form->addHtml('<br />');
}
foreach ($questions as $key => &$question) {
$ch_type = 'ch_'.$question['type'];
$display = survey_question::createQuestion($question['type']);
@ -211,7 +230,9 @@ if (is_array($questions) && count($questions) > 0) {
$js .= survey_question::getQuestionJs($question);
$form->addHtml('<div class="survey_question '.$ch_type.' '.$parentClass.'">');
$form->addHtml('<div style="float:left; font-weight: bold; margin-right: 5px;"> '.$counter.'. </div>');
if ($showNumber) {
$form->addHtml('<div style="float:left; font-weight: bold; margin-right: 5px;"> '.$counter.'. </div>');
}
$form->addHtml('<div>'.Security::remove_XSS($question['survey_question']).'</div> ');
$display->render($form, $question);
$form->addHtml('</div>');

@ -58,16 +58,21 @@ if (!api_is_allowed_to_edit(false, true) || $isDrhOfCourse) {
$exportReport = isset($_REQUEST['export_report']) ? $_REQUEST['export_report'] : '';
$format = isset($_REQUEST['export_format']) ? $_REQUEST['export_format'] : '';
if (!empty($exportReport) && !empty($format)) {
$compact = false;
switch ($format) {
case 'xls':
$filename = 'survey_results_'.$survey_id.'.xlsx';
SurveyUtil::export_complete_report_xls($survey_data, $filename, $userId);
exit;
break;
case 'csv-compact':
$compact = true;
// no break
case 'csv':
default:
$data = SurveyUtil::export_complete_report($survey_data, $userId);
$filename = 'survey_results_'.$survey_id.'.csv';
$data = SurveyUtil::export_complete_report($survey_data, $userId, $compact);
$filename = 'survey_results_'.$survey_id.($compact ? '_compact' : '').'.csv';
header('Content-type: application/octet-stream');
header('Content-Type: application/force-download');

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CSurvey;
@ -682,6 +683,8 @@ class SurveyManager
}
/**
* Copy given survey to a new (optional) given survey ID.
*
* @param int $survey_id
* @param int $new_survey_id
* @param int $targetCourseId
@ -742,7 +745,7 @@ class SurveyManager
}
$sql = "SELECT * FROM $table_survey_question_group
WHERE c_id = $course_id AND survey_id='".$survey_id."'";
WHERE c_id = $course_id AND survey_id = $survey_id";
$res = Database::query($sql);
while ($row = Database::fetch_array($res, 'ASSOC')) {
$params = [
@ -762,7 +765,7 @@ class SurveyManager
// Get questions
$sql = "SELECT * FROM $table_survey_question
WHERE c_id = $course_id AND survey_id='".$survey_id."'";
WHERE c_id = $course_id AND survey_id = $survey_id";
$res = Database::query($sql);
while ($row = Database::fetch_array($res, 'ASSOC')) {
$params = [
@ -1495,6 +1498,8 @@ class SurveyManager
* @param int $question_id the id of the question
* @param bool $shared
*
* @return mixed False on error, true if the question could be deleted
*
* @todo also delete the answers to this question
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
@ -1517,12 +1522,16 @@ class SurveyManager
$sql = "DELETE FROM $table
WHERE
c_id = $course_id AND
survey_id='".$survey_id."' AND
question_id='".$question_id."'";
Database::query($sql);
survey_id = $survey_id AND
question_id = $question_id";
$result = Database::query($sql);
if (false == $result) {
return false;
}
// Deleting the options of the question of the survey
self::delete_survey_question_option($survey_id, $question_id, $shared);
// Deleting the options of the question of the survey
return true;
}
/**
@ -1571,8 +1580,9 @@ class SurveyManager
{
$course_id = api_get_course_int_id();
$type = $form_content['type'];
// A percentage question type has options 1 -> 100
if ('percentage' === $form_content['type']) {
if ($type === 'percentage') {
for ($i = 1; $i < 101; $i++) {
$form_content['answers'][] = $i;
}
@ -2114,7 +2124,7 @@ class SurveyManager
}
/**
* This function copy survey specifying course id and session id where will be copied.
* Copy survey specifying course ID and session ID where will be copied.
*
* @param int $surveyId
* @param int $targetCourseId target course id
@ -2159,7 +2169,7 @@ class SurveyManager
Database::query($sql);
$sql = "SELECT * FROM $surveyQuestionGroupTable
WHERE survey_id = $surveyId AND c_id = $originalCourseId ";
WHERE c_id = $originalCourseId AND survey_id = $surveyId";
$res = Database::query($sql);
while ($row = Database::fetch_array($res, 'ASSOC')) {
$params = [
@ -2178,7 +2188,7 @@ class SurveyManager
// Get questions
$sql = "SELECT * FROM $surveyQuestionTable
WHERE survey_id = $surveyId AND c_id = $originalCourseId";
WHERE c_id = $originalCourseId AND survey_id = $surveyId";
$res = Database::query($sql);
while ($row = Database::fetch_array($res, 'ASSOC')) {
$params = [
@ -2240,6 +2250,88 @@ class SurveyManager
return false;
}
/**
* Copy/duplicate one question (into the same survey).
* Note: Relies on the question iid to find all necessary info.
*
* @param int $questionId
*
* @return int The new question's iid, or 0 on error
*/
public static function copyQuestion($questionId)
{
if (empty($questionId)) {
return 0;
}
$questionId = (int) $questionId;
$questionTable = Database::get_course_table(TABLE_SURVEY_QUESTION);
$optionsTable = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
// Get questions
$sql = "SELECT * FROM $questionTable WHERE iid = $questionId";
$res = Database::query($sql);
if (false == $res) {
// Could not find this question
return 0;
}
$row = Database::fetch_array($res, 'ASSOC');
$params = [
'c_id' => $row['c_id'],
'survey_id' => $row['survey_id'],
'survey_question' => trim($row['survey_question'])."'",
'survey_question_comment' => $row['survey_question_comment'],
'type' => $row['type'],
'display' => $row['display'],
'shared_question_id' => $row['shared_question_id'],
'max_value' => $row['max_value'],
'survey_group_pri' => $row['survey_group_pri'],
'survey_group_sec1' => $row['survey_group_sec1'],
'survey_group_sec2' => $row['survey_group_sec2'],
];
if (api_get_configuration_value('allow_required_survey_questions')) {
if (isset($row['is_required'])) {
$params['is_required'] = $row['is_required'];
}
}
// Get question position
$sqlSort = "SELECT max(sort) as sort FROM $questionTable
WHERE survey_id = ".$row['survey_id'];
$resSort = Database::query($sqlSort);
$rowSort = Database::fetch_assoc($resSort);
$params['sort'] = $rowSort['sort'] + 1;
// Insert the new question
$insertId = Database::insert($questionTable, $params);
if (false == $insertId) {
return 0;
}
// Normalize question_id with iid
$sql = "UPDATE $questionTable
SET question_id = iid
WHERE iid = $insertId";
Database::query($sql);
// Get questions options
$sql = "SELECT * FROM $optionsTable WHERE question_id = $questionId";
$res = Database::query($sql);
while ($row = Database::fetch_assoc($res)) {
$params = [
'c_id' => $row['c_id'],
'question_id' => $insertId,
'survey_id' => $row['survey_id'],
'option_text' => $row['option_text'],
'sort' => $row['sort'],
'value' => $row['value'],
];
$optionId = Database::insert($optionsTable, $params);
if ($optionId) {
$sql = "UPDATE $optionsTable SET question_option_id = $optionId WHERE iid = $optionId";
Database::query($sql);
}
}
return $insertId;
}
/**
* @param array $surveyData
*
@ -2420,6 +2512,42 @@ class SurveyManager
return true;
}
public static function hasDependency($survey)
{
if (false === api_get_configuration_value('survey_question_dependency')) {
return false;
}
if (empty($survey)) {
return false;
}
if (!isset($survey['survey_id'])) {
return false;
}
$courseId = (int) $survey['c_id'];
$surveyId = (int) $survey['survey_id'];
$table = Database::get_course_table(TABLE_SURVEY_QUESTION);
$sql = "SELECT COUNT(iid) count FROM $table
WHERE
c_id = $courseId AND
survey_id = $surveyId AND
parent_option_id <> 0
LIMIT 1
";
$result = Database::query($sql);
$row = Database::fetch_array($result);
if ($row) {
return $row['count'] > 0;
}
return false;
}
/**
* @param array $survey
*
@ -2431,8 +2559,8 @@ class SurveyManager
return 0;
}
$courseId = $survey['c_id'];
$surveyId = $survey['survey_id'];
$courseId = (int) $survey['c_id'];
$surveyId = (int) $survey['survey_id'];
$table = Database::get_course_table(TABLE_SURVEY_QUESTION);
@ -2530,7 +2658,8 @@ class SurveyManager
$groupId = 0
) {
$invitationRepo = Database::getManager()->getRepository('ChamiloCourseBundle:CSurveyInvitation');
$invitations = $invitationRepo->findBy(
return $invitationRepo->findBy(
[
'user' => $userId,
'cId' => $courseId,
@ -2540,8 +2669,6 @@ class SurveyManager
],
['invitationDate' => 'DESC']
);
return $invitations;
}
/**
@ -2699,6 +2826,7 @@ class SurveyManager
);
SurveyUtil::saveInvitations(
$surveyId,
['users' => $tutor['user_id']],
$subject,
$content,

@ -33,9 +33,12 @@ if (!api_is_allowed_to_edit(false, true) ||
}
// Database table definitions
$table_survey = Database::get_course_table(TABLE_SURVEY);
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$table_survey_question_group = Database::get_course_table(TABLE_SURVEY_QUESTION_GROUP);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$survey_id = (int) $_GET['survey_id'];
$course_id = api_get_course_int_id();
@ -94,32 +97,63 @@ if ($is_survey_type_1 && ('addgroup' == $action || 'deletegroup' == $action)) {
exit;
}
$htmlHeadXtra[] = '<script>'.api_get_language_translate_html().'</script>';
$my_question_id_survey = isset($_GET['question_id']) ? (int) $_GET['question_id'] : null;
$my_survey_id_survey = (int) $_GET['survey_id'];
$message_information = isset($_GET['message']) ? Security::remove_XSS($_GET['message']) : null;
// Displaying the header
Display::display_header($tool_name, 'Survey');
// Action handling
$my_action_survey = Security::remove_XSS($action);
$my_question_id_survey = isset($_GET['question_id']) ? Security::remove_XSS($_GET['question_id']) : null;
$my_survey_id_survey = Security::remove_XSS($_GET['survey_id']);
if (isset($action)) {
if (('moveup' == $action || 'movedown' == $action) && isset($_GET['question_id'])) {
SurveyManager::move_survey_question(
$my_action_survey,
$my_question_id_survey,
$my_survey_id_survey
);
echo Display::return_message(get_lang('The question has been moved'), 'confirmation');
if (!empty($action)) {
switch ($action) {
case 'copyquestion':
$copied = SurveyManager::copyQuestion($_GET['question_id']);
if (false !== $copied) {
$sendmsg = 'QuestionAdded';
} else {
$sendmsg = 'ErrorOccurred';
}
if ('delete' == $action && is_numeric($_GET['question_id'])) {
SurveyManager::delete_survey_question(
break;
case 'delete':
$result = SurveyManager::delete_survey_question(
$my_survey_id_survey,
$my_question_id_survey,
$survey_data['is_shared']
);
if (false == $result) {
$sendmsg = 'ErrorOccured';
} else {
$sendmsg = 'Deleted';
}
break;
case 'moveup':
case 'movedown':
SurveyManager::move_survey_question(
$action,
$my_question_id_survey,
$my_survey_id_survey
);
$sendmsg = 'SurveyQuestionMoved';
break;
}
header('Location: '.api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$survey_id.'&sendmsg='.$sendmsg);
exit;
}
$htmlHeadXtra[] = '<script>'.api_get_language_translate_html().'</script>';
// Displaying the header
Display::display_header($tool_name, 'Survey');
// Show error/success messages, if any
if (!$is_survey_type_1 && !empty($_GET['sendmsg'])) {
$messageType = 'confirmation';
if (in_array($_GET['sendmsg'], ['ErrorOccurred'])) {
$messageType = 'error';
}
echo Display::return_message(
get_lang($_GET['sendmsg']),
'confirmation',
false
);
}
if (!empty($survey_data['survey_version'])) {
@ -222,7 +256,7 @@ if (0 == $survey_data['survey_type']) {
}
// Displaying the table header with all the questions
echo '<table class="table table-bordered">';
echo '<table class="table table-bordered data_table">';
echo '<thead>';
echo '<tr>';
echo ' <th width="5%">'.get_lang('N°').'</th>';
@ -252,7 +286,7 @@ $sql = "SELECT survey_question.*, count(survey_question_option.question_option_i
LEFT JOIN $table_survey_question_option survey_question_option
ON
survey_question.question_id = survey_question_option.question_id AND
survey_question_option.c_id = survey_question.c_id
survey_question_option.c_id = $course_id
WHERE
survey_question.survey_id = $survey_id AND
survey_question.c_id = $course_id
@ -261,8 +295,20 @@ $sql = "SELECT survey_question.*, count(survey_question_option.question_option_i
$result = Database::query($sql);
$question_counter_max = Database::num_rows($result);
$questionsGroupClass = '';
while ($row = Database::fetch_array($result, 'ASSOC')) {
echo '<tr>';
$breakClass = '';
// Visually impact questions between page breaks by changing the bg color
if ($row['type'] == 'pagebreak') {
$breakClass = ' highlight';
if (empty($questionsGroupClass)) {
$questionsGroupClass = 'row_even';
} else {
$questionsGroupClass = '';
}
}
echo '<tr class="'.$questionsGroupClass.$breakClass.'">';
echo ' <td>'.$question_counter.'</td>';
echo ' <td>';
@ -298,7 +344,10 @@ while ($row = Database::fetch_array($result, 'ASSOC')) {
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
}
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("Delete surveyQuestion").'?', ENT_QUOTES, $charset)).'\')) return false;">'.
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=copyquestion&type='.$row['type'].'&survey_id='.$survey_id.'&question_id='.$row['question_id'].'">'.
Display::return_icon('copy.png', get_lang('Copy'), '', ICON_SIZE_SMALL).'</a>';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/survey.php?'.api_get_cidreq().'&action=delete&survey_id='.$survey_id.'&question_id='.$row['question_id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("DeleteSurveyQuestion").'?', ENT_QUOTES, $charset)).'\')) return false;">'.
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
if (3 != $survey_data['survey_type']) {
if ($question_counter > 1) {

@ -456,9 +456,7 @@ class SurveyUtil
}
break;
case 'multipleresponse':
$finalAnswer = isset($answers[$question['question_id']])
? $answers[$question['question_id']]
: '';
$finalAnswer = isset($answers[$question['question_id']]) ? $answers[$question['question_id']] : '';
break;
default:
$finalAnswer = '';
@ -629,7 +627,7 @@ class SurveyUtil
$sql = "SELECT * FROM $table_survey_question
WHERE
c_id = $course_id AND
survey_id='".$surveyId."' AND
survey_id = $surveyId AND
survey_question NOT LIKE '%{{%' AND
type <>'pagebreak'
ORDER BY sort ASC
@ -1280,7 +1278,8 @@ class SurveyUtil
$content .= '<th>
<a href="'.$url.'&action=userreport&user='.$user.'">'
.$user_displayed.'</a>
.$user_displayed.'
</a>
</th>'; // the user column
} else {
$content .= '<th>'.$user.'</th>'; // the user column
@ -1354,8 +1353,14 @@ class SurveyUtil
* Quite similar to display_complete_report(), returns an HTML string
* that can be used in a csv file.
*
* @param array $survey_data The basic survey data as initially obtained by SurveyManager::get_survey()
* @param int $user_id The ID of the user asking for the report
* @param bool $compact Whether to present the long (v marks with multiple columns per question) or compact (one column per question) answers format
*
* @todo consider merging this function with display_complete_report
*
* @throws Exception
*
* @return string The contents of a csv file
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
@ -1429,7 +1434,7 @@ class SurveyUtil
is_array($_POST['questions_filter']) &&
in_array($row['question_id'], $_POST['questions_filter']))
) {
if ($row['number_of_options'] == 0 or $compact) {
if ($row['number_of_options'] == 0 || $compact) {
$return .= str_replace(
"\r\n",
' ',
@ -1526,7 +1531,7 @@ class SurveyUtil
survey_id = $surveyId
";
if ($user_id != 0) {
$user_id = intval($user_id);
$user_id = (int) $user_id;
$sql .= " AND user = $user_id ";
}
$sql .= ' ORDER BY user ASC ';
@ -1550,8 +1555,8 @@ class SurveyUtil
$answers_of_user = [];
}
if ('open' == $possible_answers_type[$row['question_id']] ||
'comment' == $possible_answers_type[$row['question_id']]
if ('open' === $possible_answers_type[$row['question_id']] ||
'comment' === $possible_answers_type[$row['question_id']]
) {
$temp_id = 'open'.$open_question_iterator;
$answers_of_user[$row['question_id']][$temp_id] = $row;
@ -1578,10 +1583,12 @@ class SurveyUtil
/**
* Add a line to the csv file.
*
* @param array Possible answers
* @param array User's answers
* @param mixed User ID or user details as string - Used as a string in the result string
* @param bool Whether to display user fields or not
* @param array $survey_data Basic survey data (we're mostly interested in the 'anonymous' index)
* @param array $possible_options Possible answers
* @param array $answers_of_user User's answers
* @param mixed $user User ID or user details as string - Used as a string in the result string
* @param bool $display_extra_user_fields Whether to display user fields or not
* @param bool $compact Whether to show answers as different column values (true) or one column per option (false, default)
*
* @return string One line of the csv file
*
@ -2350,10 +2357,11 @@ class SurveyUtil
* and additional users in the database
* and sends the invitations by email.
*
* @param $users_array Users $array array can be both a list of course uids AND a list of additional emailaddresses
* @param $invitation_title Title $string of the invitation, used as the title of the mail
* @param $invitation_text Text $string of the invitation, used as the text of the mail.
* The text has to contain a **link** string or this will automatically be added to the end
* @param int $surveyId
* @param array $users_array Users array can be both a list of course uids AND a list of additional email addresses
* @param string $invitation_title title of the mail
* @param string $invitation_text text of the mail has to contain a **link** string or
* this will automatically be added to the end
* @param int $reminder
* @param bool $sendmail
* @param int $remindUnAnswered
@ -2366,6 +2374,7 @@ class SurveyUtil
* @version January 2007
*/
public static function saveInvitations(
$surveyId,
$users_array,
$invitation_title,
$invitation_text,
@ -2375,12 +2384,13 @@ class SurveyUtil
$isAdditionalEmail = false,
$hideLink = false
) {
$surveyId = (int) $surveyId;
if (!is_array($users_array)) {
return 0;
}
// Getting the survey information
$survey_data = SurveyManager::get_survey($_GET['survey_id']);
$survey_data = SurveyManager::get_survey($surveyId);
$survey_invitations = self::get_invitations($survey_data['survey_code']);
$already_invited = self::get_invited_users($survey_data['code']);
@ -2389,7 +2399,7 @@ class SurveyUtil
if (1 == $remindUnAnswered) {
// Remind only unanswered users
$reminder = 1;
$exclude_users = SurveyManager::get_people_who_filled_survey($_GET['survey_id']);
$exclude_users = SurveyManager::get_people_who_filled_survey($surveyId);
}
$counter = 0; // Nr of invitations "sent" (if sendmail option)
@ -2891,8 +2901,6 @@ class SurveyUtil
$table->set_header(2, get_lang('SurveyCourse code'));
$table->set_header(3, get_lang('Questions'));
$table->set_header(4, get_lang('Author'));
//$table->set_header(5, get_lang('Language'));
//$table->set_header(6, get_lang('Shared'));
$table->set_header(5, get_lang('Available from'));
$table->set_header(6, get_lang('Until'));
$table->set_header(7, get_lang('Invite'));
@ -2909,7 +2917,13 @@ class SurveyUtil
}
$table->set_column_filter(8, 'anonymous_filter');
$table->set_form_actions(['delete' => get_lang('Delete survey')]);
$actions = [
'export_all' => get_lang('ExportResults'),
'send_to_tutors' => get_lang('SendToGroupTutors'),
'multiplicate' => get_lang('MultiplicateQuestions'),
'delete' => get_lang('DeleteSurvey'),
];
$table->set_form_actions($actions);
$table->display();
}
@ -2990,14 +3004,10 @@ class SurveyUtil
* @param int $survey_id the id of the survey
* @param bool $drh
*
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
* @return string html code that are the actions that can be performed on any survey
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*
* @return string html code that are the actions that can be performed on any survey
*
* @version January 2007
*/
public static function modify_filter($survey_id, $drh = false)
@ -3033,13 +3043,13 @@ class SurveyUtil
$type = $survey->getSurveyType();
// Coach can see that only if the survey is in his session
if (api_is_allowed_to_edit() ||
api_is_element_in_the_session(TOOL_SURVEY, $survey_id)
) {
$editUrl = $codePath.'survey/create_new_survey.php?'.
if (api_is_allowed_to_edit() || api_is_element_in_the_session(TOOL_SURVEY, $survey_id)) {
$configUrl = $codePath.'survey/create_new_survey.php?'.
http_build_query($params + ['action' => 'edit', 'survey_id' => $survey_id]);
$editUrl = $codePath.'survey/survey.php?'.
http_build_query($params + ['survey_id' => $survey_id]);
if (3 == $survey->getSurveyType()) {
$editUrl = $codePath.'survey/edit_meeting.php?'.
$configUrl = $codePath.'survey/edit_meeting.php?'.
http_build_query($params + ['action' => 'edit', 'survey_id' => $survey_id]);
}
@ -3047,6 +3057,10 @@ class SurveyUtil
Display::return_icon('edit.png', get_lang('Edit')),
$editUrl
);
$actions[] = Display::url(
Display::return_icon('settings.png', get_lang('Configure')),
$configUrl
);
if (SurveyManager::survey_generation_hash_available()) {
$actions[] = Display::url(
@ -3604,17 +3618,18 @@ class SurveyUtil
}
echo '<tr>';
if (0 == $row['answered']) {
if ($row['answered'] == 0) {
echo '<td>';
echo Display::return_icon(
'statistics.png',
get_lang('Create survey'),
[],
$url = self::generateFillSurveyLink($row['invitation_code'], $_course, $row['session_id']);
$icon = Display::return_icon(
'survey.png',
get_lang('ClickHereToAnswerTheSurvey'),
['style' => 'margin-top: -4px'],
ICON_SIZE_TINY
);
$url = self::generateFillSurveyLink($row['invitation_code'], $_course, $row['session_id']);
echo '<a href="'.$url.'">
'.$row['title']
'.$icon
.$row['title']
.'</a></td>';
} else {
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
@ -3622,8 +3637,8 @@ class SurveyUtil
$_course
);
$icon = Display::return_icon(
'statistics_na.png',
get_lang('Survey'),
'survey_na.png',
get_lang('SurveysDone'),
[],
ICON_SIZE_TINY
);

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -61,8 +61,6 @@ if (api_is_course_admin()) {
];
}
$tool_name = get_lang('Publication of the survey');
// Displaying the header
Display::display_header($tool_name, 'Survey');
echo '<script>
@ -102,24 +100,10 @@ $form = new FormValidator(
'post',
api_get_self().'?survey_id='.$survey_id.'&'.api_get_cidreq()
);
$form->addElement('header', '', $tool_name);
// Course users
$complete_user_list = CourseManager::get_user_list_from_course_code(
api_get_course_id(),
api_get_session_id(),
'',
api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname'
);
$possible_users = [];
foreach ($complete_user_list as &$user) {
$possible_users[$user['user_id']] = api_get_person_name(
$user['firstname'],
$user['lastname']
);
}
$form->addHeader($tool_name);
$sessionId = api_get_session_id();
CourseManager::addUserGroupMultiSelect($form, []);
CourseManager::addUserGroupMultiSelect($form, [], true);
// Additional users
$form->addElement(
@ -196,8 +180,11 @@ if ($form->validate()) {
}
}
$survey = Database::getManager()->getRepository('ChamiloCourseBundle:CSurvey')->find($survey_data['survey_id']);
// Save the invitation mail
SurveyUtil::save_invite_mail(
SurveyUtil::saveInviteMail(
$survey,
$values['mail_text'],
$values['mail_title'],
!empty($survey_data['invite_mail'])
@ -205,6 +192,7 @@ if ($form->validate()) {
// Saving the invitations for the course users
$count_course_users = SurveyUtil::saveInvitations(
$survey_data['survey_id'],
$users,
$values['mail_title'],
$values['mail_text'],
@ -224,6 +212,7 @@ if ($form->validate()) {
}
$counter_additional_users = SurveyUtil::saveInvitations(
$survey_data['survey_id'],
$additional_users,
$values['mail_title'],
$values['mail_text'],

@ -5,9 +5,10 @@
use ChamiloSession as Session;
/**
* @author unknown, the initial survey that did not make it in 1.8 because of bad code
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of the code
* @author Julio Montoya Armas <gugli100@gmail.com>, Chamilo: Personality Test modification and rewriting large parts of the code
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: cleanup, refactoring and rewriting large parts of
* the code
* @author Julio Montoya Armas <gugli100@gmail.com>, Chamilo: Personality Test modification and rewriting large parts
* of the code
*
* @todo use quickforms for the forms
*/

@ -180,7 +180,8 @@ class survey_question
$allowParent = true;
break;
case 'multiplechoiceother':
$toolName = get_lang('SurveyMultipleAnswerWithOther');
$toolName = get_lang('SurveyQuestionMultipleChoiceWithOther');
$questionComment = get_lang('SurveyQuestionMultipleChoiceWithOtherComment');
$allowParent = true;
break;
case 'pagebreak':
@ -276,18 +277,17 @@ class survey_question
}
$this->html .= ' <tr><td colspan="">
<fieldset style="border:1px solid black"><legend>'.get_lang('Condition').'</legend>
<fieldset style="border:1px solid black">
<legend>'.get_lang('Condition').'</legend>
<b>'.get_lang('Primary').'</b><br />
'.'<input type="radio" name="choose" value="1" '.((1 == $formData['choose']) ? 'checked' : '').
'><select name="assigned">'.$grouplist.'</select><br />';
<input type="radio" name="choose" value="1" '.(($formData['choose'] == 1) ? 'checked' : '').'>
<select name="assigned">'.$grouplist.'</select><br />';
$this->html .= '
<b>'.get_lang('Secondary').'</b><br />
'.'<input type="radio" name="choose" value="2" '.((2 == $formData['choose']) ? 'checked' : '').
'><select name="assigned1">'.$grouplist1.'</select> '.
'<select name="assigned2">'.$grouplist2.'</select>'
.'</fieldset><br />';
<input type="radio" name="choose" value="2" '.(($formData['choose'] == 2) ? 'checked' : '').'>
<select name="assigned1">'.$grouplist1.'</select>
<select name="assigned2">'.$grouplist2.'</select>
</fieldset><br />';
}
$this->setForm($form);
@ -302,19 +302,22 @@ class survey_question
{
if (isset($_GET['question_id']) && !empty($_GET['question_id'])) {
/**
* Check if survey has answers first before update it, this is because if you update it, the question
* options will delete and re-insert in database loosing the iid and question_id to verify the correct answers.
* Prevent the edition of already-answered questions to avoid
* inconsistent answers. Use the configuration option
* survey_allow_answered_question_edit to change this behaviour.
*/
$surveyId = isset($_GET['survey_id']) ? (int) $_GET['survey_id'] : 0;
$answersChecker = SurveyUtil::checkIfSurveyHasAnswers($surveyId);
if (!$answersChecker) {
$this->buttonList[] = $this->getForm()->addButtonUpdate(get_lang('Edit question'), 'save', true);
$allowQuestionEdit = api_get_configuration_value('survey_allow_answered_question_edit') == true;
if ($allowQuestionEdit or !$answersChecker) {
$this->buttonList[] = $this->getForm()->addButtonUpdate(get_lang('ModifyQuestionSurvey'), 'save', true);
} else {
$this->getForm()->addHtml('
<div class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-8">
<div class="alert alert-info">'.get_lang('You can\'t edit this question because answers by students have already been registered').'</div>
<div class="alert alert-info">'.
get_lang('YouCantNotEditThisQuestionBecauseAlreadyExistAnswers').'</div>
</div>
<div class="col-sm-2"></div>
</div>
@ -486,7 +489,7 @@ class survey_question
*
* @return mixed
*/
public function save($surveyData, $formData)
public function save($surveyData, $formData, $dataFromDatabase = [])
{
// Saving a question
if (isset($_POST['buttons']) && isset($_POST['buttons']['save'])) {
@ -597,34 +600,76 @@ class survey_question
*/
public static function getQuestionJs($question)
{
if (empty($question)) {
return '';
}
$list = self::getDependency($question);
if (empty($list)) {
return '';
}
$js = '';
$type = $question['type'];
$questionId = $question['question_id'];
$newList = [];
foreach ($list as $child) {
$childQuestionId = $child['question_id'];
$optionId = $child['parent_option_id'];
$newList[$optionId] = $childQuestionId;
$newList[$optionId][] = $childQuestionId;
}
if ('multipleresponse' === $type) {
$multiple = '';
foreach ($newList as $optionId => $child) {
$multiple .= '
$(\'input[name="question'.$questionId.'['.$optionId.']"]\').on("change", function() {
var isChecked= $(this).is(\':checked\');
var checkedValue = $(this).val();
if (isChecked) {
$.each(list, function(index, value) {
$(".with_parent_" + value).find("input").prop("checked", false);
});
var questionId = $(this).val();
var questionToShow = list[questionId];
$(".with_parent_" + questionToShow).show();
} else {
var checkedValue = list[checkedValue];
}
});
';
}
$js = '
<script>
$(function() {
var list = '.json_encode($newList).';
'.$multiple.'
});
</script>';
return $js;
}
$js .= '
$js = '
<script>
$(function() {
var list = '.json_encode($newList).';
$("input[name=question'.$questionId.']").on("click", function() {
$.each(list, function(index, value) {
$(".with_parent_" + value).hide();
$(".with_parent_" + value).find("input").prop("checked", false);
$(".with_parent_only_hide_" + value).hide();
$.each(value, function(index, itemValue) {
$(".with_parent_" + itemValue).hide();
$(".with_parent_" + itemValue).find("input").prop("checked", false);
$(".with_parent_only_hide_" + itemValue).hide();
});
});
var questionId = $(this).val();
var questionToShow = list[questionId];
$(".with_parent_" + questionToShow).show();
var questionToShowList = list[questionId];
$.each(questionToShowList, function(index, value) {
$(".with_parent_" + value).show();
});
});
});
</script>';

@ -644,47 +644,38 @@ if ($nbStudents > 0) {
$table->set_header(
4,
get_lang('Time').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('Time spent in the course'), ['align' => 'absmiddle', 'hspace' => '3px']),
false,
['style' => 'width:110px;']
get_lang('TrainingTime').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('CourseTimeInfo'), [], ICON_SIZE_TINY),
false
);
$headers['training_time'] = get_lang('Time');
$table->set_header(5, get_lang('Progress').'&nbsp;'.
Display::return_icon(
'info3.gif',
get_lang('Average progress in courses'),
['align' => 'absmiddle', 'hspace' => '3px']
),
false,
['style' => 'width:110px;']
$headers['training_time'] = get_lang('TrainingTime');
$table->set_header(
5,
get_lang('CourseProgress').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), [], ICON_SIZE_TINY),
false
);
$headers['course_progress'] = get_lang('Progress');
$table->set_header(6, get_lang('Exercise progress').'&nbsp;'.
Display::return_icon(
'info3.gif',
get_lang('Exercise progressInfo'),
['align' => 'absmiddle', 'hspace' => '3px']
),
false,
['style' => 'width:110px;']
$headers['course_progress'] = get_lang('CourseProgress');
$table->set_header(
6,
get_lang('ExerciseProgress').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ExerciseProgressInfo'), [], ICON_SIZE_TINY),
false
);
$headers['exercise_progress'] = get_lang('Exercise progress');
$table->set_header(7, get_lang('Exercise average').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('Exercise averageInfo'), ['align' => 'absmiddle', 'hspace' => '3px']),
false,
['style' => 'width:110px;']
$headers['exercise_progress'] = get_lang('ExerciseProgress');
$table->set_header(
7,
get_lang('ExerciseAverage').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ExerciseAverageInfo'), [], ICON_SIZE_TINY),
false
);
$headers['exercise_average'] = get_lang('Exercise average');
$table->set_header(8, get_lang('Score').'&nbsp;'.
Display::return_icon(
'info3.gif',
get_lang('Average of tests in Learning Paths'),
['align' => 'absmiddle', 'hspace' => '3px']
),
false,
['style' => 'width:110px;']
$headers['exercise_average'] = get_lang('ExerciseAverage');
$table->set_header(
8,
get_lang('Score').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), [], ICON_SIZE_TINY),
false
);
$headers['score'] = get_lang('Score');
$table->set_header(9, get_lang('Assignments'), false);
@ -705,20 +696,22 @@ if ($nbStudents > 0) {
$headers['first_login'] = get_lang('FirstLoginInCourse');
$table->set_header(14, get_lang('LatestLoginInCourse'), false);
$headers['latest_login'] = get_lang('LatestLoginInCourse');
if (isset($_GET['additional_profile_field'])) {
$counter = 15;
foreach ($_GET['additional_profile_field'] as $fieldId) {
$table->set_header($counter, $extra_info[$fieldId]['display_text'], false);
$headers[$extra_info[$fieldId]['variable']] = $extra_info[$fieldId]['display_text'];
$counter++;
$counter = 15;
if (api_get_setting('show_email_addresses') === 'true') {
$table->set_header($counter, get_lang('Email'), false);
$headers['email'] = get_lang('Email');
$counter++;
}
if (isset($_GET['additional_profile_field'])) {
foreach ($_GET['additional_profile_field'] as $fieldId) {
$table->set_header($counter, $extra_info[$fieldId]['display_text'], false);
$headers[$extra_info[$fieldId]['variable']] = $extra_info[$fieldId]['display_text'];
$counter++;
$parameters['additional_profile_field'] = $fieldId;
}
$table->set_header($counter, get_lang('Details'), false);
$headers['details'] = get_lang('Details');
} else {
$table->set_header(15, get_lang('Details'), false);
$headers['details'] = get_lang('Details');
}
}
$table->set_header($counter, get_lang('Details'), false);
$headers['Details'] = get_lang('Details');
if (!empty($fields)) {
foreach ($fields as $key => $value) {
@ -917,7 +910,11 @@ if (!empty($groupList)) {
$totalLpProgress += $lpProgress;
}
$lpProgress = round($totalLpProgress / $nbStudents, 2).' %';
if (empty($nbStudents)) {
$lpProgress = '0 %';
} else {
$lpProgress = round($totalLpProgress / $nbStudents, 2).' %';
}
$totalBestScoreAverageNotInLP = 0;
$bestScoreAverageNotInLP = 0;
if (!empty($exerciseList)) {

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;

@ -1,9 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Report.
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$cidReset = true;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/*

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @author Julio Montoya <gugli100@gmail.com>
*/

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -421,10 +422,35 @@ if (api_is_allowed_to_edit(null, true)) {
if (isset($_GET['user_id']) && is_numeric($_GET['user_id']) &&
($_GET['user_id'] != $_user['user_id'] || api_is_platform_admin())
) {
CourseManager::unsubscribe_user($_GET['user_id'], $courseCode, 0);
Display::addFlash(
Display::return_message(get_lang('User is now unsubscribed'))
);
$user_id = (int) $_GET['user_id'];
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$sql = "SELECT user.id as user_id
FROM $tbl_user user
INNER JOIN $tbl_session_rel_user reluser
ON user.id = reluser.user_id AND reluser.relation_type <> ".SESSION_RELATION_TYPE_RRHH."
INNER JOIN $tbl_session_rel_course rel_course
ON rel_course.session_id = reluser.session_id
WHERE
user.id = $user_id AND
rel_course.c_id = $courseId ";
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
if ($row['user_id'] == $user_id || $row['user_id'] == "") {
CourseManager::unsubscribe_user($_GET['user_id'], $courseCode);
Display::addFlash(
Display::return_message(get_lang('UserUnsubscribed'))
);
} else {
Display::addFlash(
Display::return_message(
get_lang('ThisStudentIsSubscribeThroughASession')
)
);
}
}
}
} else {
@ -636,7 +662,6 @@ if (!isset($origin) || 'learnpath' != $origin) {
Display::display_footer();
}
/* Helper functions for the users lists in course */
/**
* Get the users to display on the current page.
*/
@ -646,7 +671,7 @@ function get_number_of_users()
$sessionId = api_get_session_id();
$courseCode = api_get_course_id();
$active = isset($_GET['active']) ? $_GET['active'] : null;
$type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
$type = isset($_REQUEST['type']) ? (int) $_REQUEST['type'] : STUDENT;
if (empty($sessionId)) {
$status = $type;
@ -659,7 +684,7 @@ function get_number_of_users()
}
if (!empty($sessionId)) {
$a_course_users = CourseManager::get_user_list_from_course_code(
$users = CourseManager::get_user_list_from_course_code(
$courseCode,
$sessionId,
null,
@ -674,7 +699,7 @@ function get_number_of_users()
$active
);
} else {
$a_course_users = CourseManager::get_user_list_from_course_code(
$users = CourseManager::get_user_list_from_course_code(
$courseCode,
0,
null,
@ -690,14 +715,14 @@ function get_number_of_users()
);
}
foreach ($a_course_users as $o_course_user) {
foreach ($users as $user) {
if ((
isset($_GET['keyword']) &&
searchUserKeyword(
$o_course_user['firstname'],
$o_course_user['lastname'],
$o_course_user['username'],
$o_course_user['official_code'],
$user['firstname'],
$user['lastname'],
$user['username'],
$user['official_code'],
$_GET['keyword']
)
) || !isset($_GET['keyword']) || empty($_GET['keyword'])
@ -726,9 +751,9 @@ function searchUserKeyword($firstname, $lastname, $username, $official_code, $ke
false !== api_strripos($official_code, $keyword)
) {
return true;
} else {
return false;
}
return false;
}
/**
@ -745,7 +770,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
{
global $is_western_name_order;
global $extraFields;
$type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
$type = isset($_REQUEST['type']) ? (int) $_REQUEST['type'] : STUDENT;
$course_info = api_get_course_info();
$sessionId = api_get_session_id();
$course_code = $course_info['code'];
@ -805,7 +830,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
}
}
$a_course_users = CourseManager::get_user_list_from_course_code(
$users = CourseManager :: get_user_list_from_course_code(
$course_code,
$sessionId,
$limit,
@ -820,14 +845,14 @@ function get_user_data($from, $number_of_items, $column, $direction)
$active
);
foreach ($a_course_users as $user_id => $o_course_user) {
foreach ($users as $user_id => $userData) {
if ((
isset($_GET['keyword']) &&
searchUserKeyword(
$o_course_user['firstname'],
$o_course_user['lastname'],
$o_course_user['username'],
$o_course_user['official_code'],
$userData['firstname'],
$userData['lastname'],
$userData['username'],
$userData['official_code'],
$_GET['keyword']
)
) || !isset($_GET['keyword']) || empty($_GET['keyword'])
@ -844,35 +869,35 @@ function get_user_data($from, $number_of_items, $column, $direction)
$photo = Display::img($userInfo['avatar_small'], $userInfo['complete_name'], [], false);
$temp[] = $user_id;
$temp[] = $photo;
$temp[] = $o_course_user['official_code'];
$temp[] = $userData['official_code'];
if ($is_western_name_order) {
$temp[] = $o_course_user['firstname'];
$temp[] = $o_course_user['lastname'];
$temp[] = $userData['firstname'];
$temp[] = $userData['lastname'];
} else {
$temp[] = $o_course_user['lastname'];
$temp[] = $o_course_user['firstname'];
$temp[] = $userData['lastname'];
$temp[] = $userData['firstname'];
}
$temp[] = $o_course_user['username'];
$temp[] = $userData['username'];
// Groups.
$temp[] = implode(', ', $groupsNameListParsed);
// Status
$default_status = get_lang('Learner');
if ((isset($o_course_user['status_rel']) && 1 == $o_course_user['status_rel']) ||
(isset($o_course_user['status_session']) && 2 == $o_course_user['status_session'])
$default_status = get_lang('Student');
if ((isset($userData['status_rel']) && $userData['status_rel'] == 1) ||
(isset($userData['status_session']) && $userData['status_session'] == 2)
) {
$default_status = get_lang('Teacher');
} elseif (isset($o_course_user['is_tutor']) && 1 == $o_course_user['is_tutor']) {
$default_status = get_lang('Coach');
$default_status = get_lang('CourseManager');
} elseif (isset($userData['is_tutor']) && $userData['is_tutor'] == 1) {
$default_status = get_lang('Tutor');
}
$temp[] = $default_status;
// active
$temp[] = $o_course_user['active'];
$temp[] = $userData['active'];
$extraFieldOption = new ExtraFieldOption('user');
$extraFieldValue = new ExtraFieldValue('user');
@ -882,24 +907,27 @@ function get_user_data($from, $number_of_items, $column, $direction)
$user_id,
$extraField['id']
);
if (isset($data['value'])) {
$optionList = $extraFieldOption->get_field_option_by_field_and_option(
$extraField['id'],
$data['value']
);
if (!empty($optionList)) {
$options = implode(', ', array_column($optionList, 'display_text'));
$temp[] = $options;
$temp[] = Security::remove_XSS($options);
} else {
$temp[] = Security::remove_XSS($data['value']);
}
} else {
$temp[] = $data['value'];
$temp[] = '';
}
}
}
// User id for actions
$temp[] = $user_id;
$temp['is_tutor'] = isset($o_course_user['is_tutor']) ? $o_course_user['is_tutor'] : '';
$temp['user_status_in_course'] = isset($o_course_user['status_rel']) ? $o_course_user['status_rel'] : '';
$temp['is_tutor'] = isset($userData['is_tutor']) ? $userData['is_tutor'] : '';
$temp['user_status_in_course'] = isset($userData['status_rel']) ? $userData['status_rel'] : '';
} else {
$userInfo = api_get_user_info($user_id);
$userPicture = $userInfo['avatar'];
@ -908,21 +936,21 @@ function get_user_data($from, $number_of_items, $column, $direction)
$temp[] = '';
$temp[] = $photo;
$temp[] = $o_course_user['official_code'];
$temp[] = $userData['official_code'];
if ($is_western_name_order) {
$temp[] = $o_course_user['firstname'];
$temp[] = $o_course_user['lastname'];
$temp[] = $userData['firstname'];
$temp[] = $userData['lastname'];
} else {
$temp[] = $o_course_user['lastname'];
$temp[] = $o_course_user['firstname'];
$temp[] = $userData['lastname'];
$temp[] = $userData['firstname'];
}
$temp[] = $o_course_user['username'];
$temp[] = $userData['username'];
// Group.
$temp[] = implode(', ', $groupsNameListParsed);
if (1 == $course_info['unsubscribe']) {
if ($course_info['unsubscribe'] == 1) {
//User id for actions
$temp[] = $user_id;
}

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';
@ -7,7 +8,6 @@ $this_section = SECTION_COURSES;
api_protect_admin_script(true, true);
$export = [];
$export['file_type'] = isset($_REQUEST['file_type']) ? $_REQUEST['file_type'] : null;
$export['course_code'] = isset($_REQUEST['course_code']) ? $_REQUEST['course_code'] : null;
$export['course_session'] = isset($_REQUEST['course_session']) ? $_REQUEST['course_session'] : null;
@ -16,12 +16,12 @@ $export['session'] = isset($_REQUEST['session']) ? $_REQUEST['session'] : null;
// Database table definitions
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$userTable = Database::get_main_table(TABLE_MAIN_USER);
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$session_course_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$session_user_table = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$file_type = $export['file_type'];
$fileType = $export['file_type'];
$course_code = Database::escape_string($export['course_code']);
$courseInfo = api_get_course_info($course_code);
$courseId = isset($courseInfo['real_id']) ? $courseInfo['real_id'] : 0;
@ -45,8 +45,20 @@ if (is_array($courseSessionValue) && isset($courseSessionValue[1])) {
$sessionInfo = api_get_session_info($sessionId);
}
$extraUrlJoin = '';
$extraUrlCondition = '';
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
$extraUrlJoin .= " INNER JOIN $tbl_user_rel_access_url as user_rel_url
ON (u.id = user_rel_url.user_id) ";
$extraUrlCondition = " AND access_url_id = $access_url_id";
}
}
$sql = "SELECT
u.user_id AS UserId,
u.id AS UserId,
u.lastname AS LastName,
u.firstname AS FirstName,
u.email AS Email,
@ -58,48 +70,57 @@ $sql = "SELECT
u.phone AS Phone,
u.registration_date AS RegistrationDate";
if (strlen($course_code) > 0) {
$sql .= " FROM $user_table u, $course_user_table cu
$sql .= " FROM $userTable u
INNER JOIN $course_user_table cu
ON (u.id = cu.user_id)
$extraUrlJoin
WHERE
u.user_id = cu.user_id AND
cu.c_id = $courseId AND
cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
$extraUrlCondition
ORDER BY lastname,firstname";
$filename = 'export_users_'.$course_code.'_'.api_get_local_time();
} elseif (strlen($courseSessionCode) > 0) {
$sql .= " FROM $user_table u, $session_course_user_table scu
$sql .= " FROM $userTable u
INNER JOIN $session_course_user_table scu
ON (u.id = scu.user_id)
$extraUrlJoin
WHERE
u.user_id = scu.user_id AND
scu.c_id = $courseSessionId AND
scu.session_id = $sessionId
$extraUrlCondition
ORDER BY lastname,firstname";
$filename = 'export_users_'.$courseSessionCode.'_'.$sessionInfo['name'].'_'.api_get_local_time();
} elseif ($sessionId > 0) {
$sql .= " FROM $user_table u, $session_user_table su
$sql .= " FROM $userTable u
INNER JOIN $session_user_table su
ON (u.id = su.user_id)
$extraUrlJoin
WHERE
u.user_id = su.user_id AND
su.session_id = $sessionId
$extraUrlCondition
ORDER BY lastname,firstname";
$filename = 'export_users_'.$sessionInfo['name'].'_'.api_get_local_time();
} else {
if (api_is_multiple_url_enabled()) {
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if (-1 != $access_url_id) {
$sql .= " FROM $user_table u
if ($access_url_id != -1) {
$sql .= " FROM $userTable u
INNER JOIN $tbl_user_rel_access_url as user_rel_url
ON (u.user_id= user_rel_url.user_id)
ON (u.id = user_rel_url.user_id)
WHERE access_url_id = $access_url_id
ORDER BY lastname,firstname";
}
} else {
$sql .= " FROM $user_table u ORDER BY lastname,firstname";
$sql .= " FROM $userTable u ORDER BY lastname,firstname";
}
$filename = 'export_users_'.api_get_local_time();
}
$data = [];
$extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', false);
if ('1' == $export['addcsvheader'] && 'csv' == $export['file_type']) {
if ('none' != $_configuration['password_encryption']) {
if ($export['addcsvheader'] == '1' && $export['file_type'] === 'csv') {
if ($_configuration['password_encryption'] !== 'none') {
$data[] = [
'UserId',
'LastName',
@ -135,12 +156,12 @@ if ('1' == $export['addcsvheader'] && 'csv' == $export['file_type']) {
$res = Database::query($sql);
while ($user = Database::fetch_array($res, 'ASSOC')) {
$student_data = UserManager:: get_extra_user_data(
$studentData = UserManager:: get_extra_user_data(
$user['UserId'],
true,
false
);
foreach ($student_data as $key => $value) {
foreach ($studentData as $key => $value) {
$key = substr($key, 6);
if (is_array($value)) {
$user[$key] = $value['extra_'.$key];
@ -151,7 +172,7 @@ while ($user = Database::fetch_array($res, 'ASSOC')) {
$data[] = $user;
}
switch ($file_type) {
switch ($fileType) {
case 'xml':
Export::arrayToXml($data, $filename, 'Contact', 'Contacts');
exit;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Framework\Container;

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @author Francis Gonzales
*/

@ -28,7 +28,6 @@ class SaveUserTest extends V2TestCase
$loginName = 'testUser'.time();
$email = 'testUser@local';
$status = 5;
$userId = $this->integer(
[
'loginname' => $loginName,
@ -56,8 +55,7 @@ class SaveUserTest extends V2TestCase
}
/**
* Creates a test user with an extra field
* asserts that the extra field values were saved
* Creates a test user with an extra field asserts that the extra field values were saved.
*
* @throws Exception if it cannot delete the created test user
*/

@ -27,7 +27,7 @@ class UpdateUserPauseTrainingTest extends V2TestCase
'pause_formation' => 0,
'start_pause_date' => '2020-06-30 10:00',
'end_pause_date' => '2020-06-30 11:00',
'allow_notifications' => 0,
'disable_emails' => 1,
];
$userId = $this->integer($params);

@ -343,15 +343,17 @@ try {
break;
case Rest::UPDATE_USER_PAUSE_TRAINING:
$allow = api_get_plugin_setting('pausetraining', 'tool_enable') === 'true';
$allowPauseFormation = api_get_plugin_setting('pausetraining', 'allow_users_to_edit_pause_formation') === 'true';
if (false === $allow || false === $allowPauseFormation) {
if (false === $allow) {
throw new Exception(get_lang('Plugin configured'));
}
if (empty($_POST['user_id'])) {
throw new Exception('user_id is required');
}
if (null === $restApi) {
throw new Exception('Check that the username and api_key are field in the request');
}
$plugin = PauseTraining::create();
$data = $plugin->updateUserPauseTraining($_POST['user_id'], $_POST);
$restResponse->setData([$data]);

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/cm_webservice_announcements.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/cm_webservice_course.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/cm_webservice_courses.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/cm_webservice_forum.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/cm_webservice_inbox.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/cm_webservice_user.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\User;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script provides the caller service with a list
* of courses that have a certain level of visibility

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Skill as SkillManager;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$realm = 'The batcave';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once __DIR__.'/../inc/global.inc.php';

@ -1,4 +1,7 @@
<?php /* For licensing terms, see /license.txt */
<?php
/* For licensing terms, see /license.txt */
/**
* Test script for soap.php.
*

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Configures the WSCourse SOAP service.
*/

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Configures the WSReport SOAP service.
*/

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Configures the WSSession SOAP service.
*/

@ -1,5 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Configures the WSUser SOAP service.
*/

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
$ip = trim($_SERVER['REMOTE_ADDR']);

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save