Minor - merge from 1.11.x

pull/3006/head
Julio 6 years ago
parent 8b2aa0b585
commit 562606f618
  1. 2
      main/admin/course_category.php
  2. 8
      main/admin/course_edit.php
  3. 15
      main/admin/user_import.php
  4. 4
      main/admin/user_list.php
  5. 101
      main/admin/usergroup_users.php
  6. 2
      main/announcements/announcements.php
  7. 1
      main/attendance/attendance_list.php
  8. 111
      main/auth/courses.php
  9. 354
      main/auth/courses_categories.php
  10. 298
      main/auth/courses_controller.php
  11. 323
      main/auth/courses_list.php
  12. 34
      main/auth/hrm_courses.php
  13. 5
      main/auth/inscription.php
  14. 4
      main/calendar/agenda_js.php
  15. 8
      main/calendar/download.php
  16. 3
      main/course_home/course_home.php
  17. 6
      main/document/recycle.php
  18. 20
      main/document/showinframes.php
  19. 78
      main/exercise/TestCategory.php
  20. 25
      main/exercise/exercise.class.php
  21. 87
      main/exercise/exercise_show.php
  22. 4
      main/exercise/exercise_submit.php
  23. 62
      main/exercise/fill_blanks.class.php
  24. 2
      main/forum/forumfunction.inc.php
  25. 2
      main/forum/viewforum.php
  26. 2
      main/gradebook/certificate_report.php
  27. 14
      main/gradebook/gradebook_display_certificate.php
  28. 5
      main/gradebook/gradebook_display_summary.php
  29. 2
      main/gradebook/gradebook_flatview.php
  30. 30
      main/gradebook/lib/GradebookUtils.php
  31. 132
      main/gradebook/lib/be/category.class.php
  32. 4
      main/gradebook/lib/be/exerciselink.class.php
  33. 2
      main/gradebook/lib/fe/displaygradebook.php
  34. 13
      main/gradebook/lib/fe/gradebooktable.class.php
  35. 22
      main/gradebook/lib/flatview_data_generator.class.php
  36. 11
      main/inc/ajax/course_home.ajax.php
  37. 60
      main/inc/ajax/install.ajax.php
  38. 2
      main/inc/ajax/message.ajax.php
  39. 26
      main/inc/ajax/model.ajax.php
  40. 20
      main/inc/lib/AnnouncementManager.php
  41. 2
      main/inc/lib/Compilatio.php
  42. 3
      main/inc/lib/CoursesAndSessionsCatalog.class.php
  43. 14
      main/inc/lib/agenda.lib.php
  44. 20
      main/inc/lib/attendance.lib.php
  45. 30
      main/inc/lib/auth.lib.php
  46. 5
      main/inc/lib/banner.lib.php
  47. 7
      main/inc/lib/certificate.lib.php
  48. 18
      main/inc/lib/course.lib.php
  49. 100
      main/inc/lib/course_category.lib.php
  50. 17
      main/inc/lib/course_home.lib.php
  51. 27
      main/inc/lib/display.lib.php
  52. 1
      main/inc/lib/extra_field.lib.php
  53. 35
      main/inc/lib/extra_field_value.lib.php
  54. 5
      main/inc/lib/formvalidator/FormValidator.class.php
  55. 121
      main/inc/lib/link.lib.php
  56. 101
      main/inc/lib/plugin.lib.php
  57. 92
      main/inc/lib/sessionmanager.lib.php
  58. 261
      main/inc/lib/social.lib.php
  59. 76
      main/inc/lib/sortable_table.class.php
  60. 5
      main/inc/lib/thematic.lib.php
  61. 373
      main/inc/lib/tracking.lib.php
  62. 57
      main/inc/lib/usergroup.lib.php
  63. 220
      main/inc/lib/usermanager.lib.php
  64. 34
      main/inc/lib/userportal.lib.php
  65. 21
      main/inc/lib/webservices/Rest.php
  66. 8
      main/inc/lib/webservices/WebService.class.php
  67. 103
      main/lp/learnpath.class.php
  68. 10
      main/lp/lp_add.php
  69. 35
      main/lp/lp_controller.php
  70. 13
      main/lp/lp_subscribe_users.php
  71. 13
      main/session/resume_session.php
  72. 6
      main/survey/ch_comment.php
  73. 421
      main/survey/preview.php
  74. 4
      main/survey/question.php
  75. 64
      main/survey/surveyUtil.class.php
  76. 10
      main/ticket/new_ticket.php
  77. 2
      main/webservices/access_url.php
  78. 26
      main/webservices/api/v2.php
  79. 4
      main/work/work.lib.php
  80. 53
      main/work/work_list.php
  81. 2
      plugin/bbb/lib/bbb.lib.php
  82. 2
      plugin/bbb/listing.php
  83. 2
      plugin/bbb/view/listing.tpl
  84. 2
      plugin/customcertificate/src/CustomCertificatePlugin.php
  85. 4
      plugin/customcertificate/src/index.php
  86. 4
      plugin/customcertificate/src/print_certificate.php
  87. 2
      plugin/redirection/RedirectionPlugin.php
  88. 25
      plugin/studentfollowup/StudentFollowUpPlugin.php

@ -113,7 +113,7 @@ if ($action == 'add' || $action == 'edit') {
get_lang('CategoryName'),
true,
false,
['ToolbarSet' => 'Minimal']
['ToolbarSet' => 'TitleAsHtml']
);
} else {
$form->addElement('text', 'name', get_lang("CategoryName"));

@ -16,7 +16,6 @@ $this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script();
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$em = Database::getManager();
/** @var CourseCategoryRepository $courseCategoriesRepo */
$courseCategoriesRepo = $em->getRepository('ChamiloCoreBundle:CourseCategory');
@ -221,7 +220,6 @@ if (!empty($coursesInSession) && $allowEditSessionCoaches) {
$sessionTeachers = [];
foreach ($coaches as $coachId) {
$userInfo = api_get_user_info($coachId);
$sessionTeachers[] = $coachId;
if (isset($teachers[$coachId])) {
@ -230,10 +228,6 @@ if (!empty($coursesInSession) && $allowEditSessionCoaches) {
}
$groupName = 'session_coaches_'.$sessionId;
$platformTeacherId = 'platform_teachers_by_session_'.$sessionId;
$coachId = 'coaches_by_session_'.$sessionId;
$platformTeacherName = 'platform_teachers_by_session';
$coachName = 'coaches_by_session';
$sessionUrl = api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$sessionId;
$form->addElement(
'advmultiselect',
@ -508,7 +502,6 @@ function mysort(a, b) {
function valide() {
// Checking all multiple
$('select').filter(function() {
if ($(this).attr('multiple')) {
$(this).find('option').each(function() {
@ -516,7 +509,6 @@ function valide() {
});
}
});
//document.update_course.submit();
}
</script>";

@ -752,10 +752,10 @@ if (api_get_configuration_value('plugin_redirection_enabled')) {
<p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
<blockquote>
<pre>
<b>LastName</b>;<b>FirstName</b>;<b>Email</b>;UserName;Password;AuthSource;OfficialCode;PhoneNumber;Status;ExpiryDate;<span style="color:red;"><?php if (count($list) > 0) {
<b>LastName</b>;<b>FirstName</b>;<b>Email</b>;UserName;Password;AuthSource;OfficialCode;language;PhoneNumber;Status;ExpiryDate;<span style="color:red;"><?php if (count($list) > 0) {
echo implode(';', $list).';';
} ?></span>Courses;Sessions;ClassId;
<b>xxx</b>;<b>xxx</b>;<b>xxx</b>;xxx;xxx;<?php echo implode('/', $defined_auth_sources); ?>;xxx;xxx;user/teacher/drh;0000-00-00 00:00:00;<span style="color:red;"><?php if (count($list_reponse) > 0) {
<b>xxx</b>;<b>xxx</b>;<b>xxx</b>;xxx;xxx;<?php echo implode('/', $defined_auth_sources); ?>;xxx;english/spanish/(other);xxx;user/teacher/drh;0000-00-00 00:00:00;<span style="color:red;"><?php if (count($list_reponse) > 0) {
echo implode(';', $list_reponse).';';
} ?></span>xxx1|xxx2|xxx3;sessionId|sessionId|sessionId;1;<br />
</pre>
@ -773,17 +773,18 @@ if (api_get_configuration_value('plugin_redirection_enabled')) {
&lt;AuthSource&gt;<?php echo implode('/', $defined_auth_sources); ?>&lt;/AuthSource&gt;
<b>&lt;Email&gt;xxx&lt;/Email&gt;</b>
&lt;OfficialCode&gt;xxx&lt;/OfficialCode&gt;
&lt;language&gt;english/spanish/(other)&lt;/language&gt;
&lt;PhoneNumber&gt;xxx&lt;/PhoneNumber&gt;
&lt;Status&gt;user/teacher/drh<?php if ($result_xml != '') {
&lt;Status&gt;user/teacher/drh&lt;/Status&gt;<?php if ($result_xml != '') {
echo '<br /><span style="color:red;">', $result_xml;
echo '</span>';
} ?>&lt;/Status&gt;
echo '</span><br />';
} ?>
&lt;Courses&gt;xxx1|xxx2|xxx3&lt;/Courses&gt;
&lt;Sessions&gt;sessionId|sessionId|sessionId&lt;/Sessions&gt;
&lt;ClassId&gt;1&lt;/ClassId&gt;
&lt;/Contact&gt;
&lt;/Contact&gt;
&lt;/Contacts&gt;
</pre>
</blockquote>
</blockquote>
<?php
Display::display_footer();

@ -504,7 +504,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
*/
function email_filter($email)
{
return Display::encrypted_mailto_link($email, $email);
return Display::encrypted_mailto_link($email, cut($email, 26));
}
/**
@ -518,6 +518,8 @@ function email_filter($email)
*/
function user_filter($name, $params, $row)
{
$name = cut($name, 26);
return '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_information.php?user_id='.$row[0].'">'.$name.'</a>';
}

@ -4,7 +4,7 @@
/**
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
@ -13,15 +13,15 @@ $id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$usergroup = new UserGroup();
$userGroupInfo = $usergroup->get($id);
if (empty($userGroupInfo)) {
api_not_allowed(true);
}
$usergroup->protectScript($userGroupInfo);
$usergroup->protectScript($userGroupInfo, true, true);
$allowEdit = api_is_platform_admin() || isset($userGroupInfo['author_id']) && $userGroupInfo['author_id'] == api_get_user_id();
$calendarPlugin = null;
if (api_get_plugin_setting('learning_calendar', 'enabled') === 'true') {
if ($allowEdit && api_get_plugin_setting('learning_calendar', 'enabled') === 'true') {
$calendarPlugin = LearningCalendarPlugin::create();
}
@ -31,10 +31,18 @@ $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
$userId = isset($_GET['user_id']) ? (int) $_GET['user_id'] : 0;
$calendarId = isset($_REQUEST['calendar_id']) ? (int) $_REQUEST['calendar_id'] : 0;
// setting breadcrumbs
$interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')];
$courseInfo = api_get_course_info();
if (empty($courseInfo)) {
$interbreadcrumb[] = ['url' => 'usergroups.php', 'name' => get_lang('Classes')];
} else {
$interbreadcrumb[] = ['url' => api_get_path(WEB_CODE_PATH).'user/class.php?'.api_get_cidreq(), 'name' => get_lang('Classes')];
}
$interbreadcrumb[] = ['url' => '#', 'name' => $userGroupInfo['name']];
if (!empty($action)) {
$usergroup->protectScript($userGroupInfo);
}
switch ($action) {
case 'add_calendar':
$form = new FormValidator(
@ -140,7 +148,7 @@ $column_model = [
],
];
if (api_get_plugin_setting('learning_calendar', 'enabled') === 'true') {
if ($calendarPlugin) {
$columns = [
get_lang('Name'),
get_lang('Calendar'),
@ -195,25 +203,33 @@ $extraParams['autowidth'] = 'true';
$extraParams['height'] = 'auto';
$extraParams['sortname'] = 'name';
$extraParams['sortorder'] = 'desc';
$extraParams['multiselect'] = true;
$extraParams['multiselect'] = $allowEdit;
$deleteIcon = Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL);
$urlStats = api_get_path(WEB_CODE_PATH);
//$addCalendar = '<a href="'.$urlStats.'mySpace/myStudents.php?student=\'+options.rowId+\'">'.Display::return_icon('agenda.png', get_lang('Agenda'), '', ICON_SIZE_SMALL).'</a>';
$reportingIcon = Display::return_icon('statistics.png', get_lang('Reporting'), '', ICON_SIZE_SMALL);
$controlPoint = Display::return_icon('add.png', get_lang('ControlPoint'), '', ICON_SIZE_SMALL);
$link = '';
if ($calendarPlugin) {
$link = '<a href="'.$urlStats.'admin/usergroup_users.php?action=create_control_point&value=\'+value+\'&id='.$id.'&user_id=\'+options.rowId+\'">'.$controlPoint.'</a>';
}
$deleteButton = '';
if ($allowEdit) {
$deleteButton = '<a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."\'".')) return false;" href="?id='.$id.'&action=delete&user_id=\'+options.rowId+\'">'.$deleteIcon.'</a>';
}
//return \'<a href="session_edit.php?page=resume_session.php&id=\'+options.rowId+\'">'.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>'.
// With this function we can add actions to the jgrid
$action_links = '
function action_formatter(cellvalue, options, rowObject) {
var value = rowObject[5];
return \''.
'&nbsp;<a href="'.$urlStats.'admin/usergroup_users.php?action=create_control_point&value=\'+value+\'&id='.$id.'&user_id=\'+options.rowId+\'">'.$controlPoint.'</a>'.
'&nbsp;'.$link.
'&nbsp;<a href="'.$urlStats.'mySpace/myStudents.php?student=\'+options.rowId+\'">'.$reportingIcon.'</a>'.
' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."\'".')) return false;" href="?id='.$id.'&action=delete&user_id=\'+options.rowId+\'">'.$deleteIcon.'</a>\';
' '.$deleteButton.' \';
}
function extra_formatter(cellvalue, options, rowObject) {
@ -237,40 +253,43 @@ function extra_formatter(cellvalue, options, rowObject) {
$deleteUrl = api_get_path(WEB_AJAX_PATH).'usergroup.ajax.php?a=delete_user_in_usergroup&group_id='.$id;
$form = new FormValidator(
'add_multiple_calendar',
'post',
api_get_self().'?id='.$id.'&action=add_multiple_users_to_calendar'
);
$calendarPlugin->getAddUserToCalendarForm($form);
$form->addHidden('user_list', '');
$form->addButtonSave(get_lang('Add'));
if ($calendarPlugin) {
$form = new FormValidator(
'add_multiple_calendar',
'post',
api_get_self().'?id='.$id.'&action=add_multiple_users_to_calendar'
);
$calendarPlugin->getAddUserToCalendarForm($form);
$form->addHidden('user_list', '');
$form->addButtonSave(get_lang('Add'));
}
?>
<script>
$(function() {
<?php
// grid definition see the $usergroup>display() function
echo Display::grid_js(
'usergroups',
$url,
$columns,
$column_model,
$extraParams,
[],
$action_links,
true
);
?>
<?php
// grid definition see the $usergroup>display() function
echo Display::grid_js(
'usergroups',
$url,
$columns,
$column_model,
$extraParams,
[],
$action_links,
true
);
?>
$("#usergroups").jqGrid(
"navGrid",
"#usergroups_pager",
{ edit: false, add: false, del: true, search: false},
{ edit: false, add: false, del: <?php echo $allowEdit ? 'true' : 'false'; ?>, search: false},
{ height:280, reloadAfterSubmit:false }, // edit options
{ height:280, reloadAfterSubmit:false }, // add options
{ reloadAfterSubmit:false, url: "<?php echo $deleteUrl; ?>" }, // del options
{ width:500 } // search options
)
<?php if ($calendarPlugin) { ?>
.navButtonAdd('#usergroups_pager',{
caption:"<?php echo addslashes($calendarPlugin->get_lang('UpdateCalendar')); ?>",
buttonicon:"ui-icon ui-icon-plus",
@ -284,10 +303,12 @@ $(function() {
}
},
position:"last"
});
})
<?php } ?>
;
});
</script>
<?php if ($calendarPlugin) { ?>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
@ -304,18 +325,18 @@ $(function() {
</div>
</div>
</div>
<?php } ?>
<?php
$usergroup->showGroupTypeSetting = true;
// Action handling: Adding a note
if ($action === 'delete' && is_numeric($_GET['id'])) {
if ($allowEdit && $action === 'delete' && is_numeric($_GET['id'])) {
$res = $usergroup->delete_user_rel_group($_GET['user_id'], $_GET['id']);
Display::addFlash(Display::return_message(get_lang('Deleted'), 'confirmation'));
header('Location: '.api_get_self().'?id='.$id);
exit;
} else {
$usergroup->displayToolBarUserGroupUsers();
}
$usergroup->displayToolBarUserGroupUsers();
Display::display_footer();

@ -43,7 +43,7 @@ if (!empty($sessionId) && $drhHasAccessToSessionContent) {
$allowToEdit = $allowToEdit || api_is_drh();
}
// Configuration settings
// Database Table Definitions
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
$tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);

@ -51,7 +51,6 @@ if (api_is_allowed_to_edit(null, true)) {
}
$table->set_form_actions($actions);
}
if ($table->get_total_number_of_items() > 0) {
$table->display();
}

@ -42,10 +42,7 @@ if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create
// filter actions
$actions = [
'sortmycourses',
'createcoursecategory',
'subscribe',
'deletecoursecategory',
'display_courses',
'display_random_courses',
'subscribe_user_with_password',
@ -53,7 +50,6 @@ $actions = [
'subscribe_to_session',
'search_tag',
'search_session',
'set_collapsable',
'subscribe_course_validation',
'subscribe_course',
];
@ -72,73 +68,19 @@ if (empty($nameTools)) {
} else {
if (!in_array(
$action,
['sortmycourses', 'createcoursecategory', 'display_random_courses', 'display_courses', 'subscribe']
['display_random_courses', 'display_courses', 'subscribe']
)) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'auth/courses.php',
'name' => get_lang('CourseManagement'),
];
}
if ($action === 'createcoursecategory') {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses',
'name' => get_lang('SortMyCourses'),
];
}
$interbreadcrumb[] = ['url' => '#', 'name' => $nameTools];
}
// course description controller object
$courseController = new CoursesController();
// We are moving a course or category of the user up/down the list (=Sort My Courses).
if (isset($_GET['move'])) {
if (isset($_GET['course'])) {
$courseController->move_course(
$_GET['move'],
$_GET['course'],
$_GET['category']
);
}
if (isset($_GET['category']) && !isset($_GET['course'])) {
$courseController->move_category($_GET['move'], $_GET['category']);
}
}
// We are moving the course of the user to a different user defined course category (=Sort My Courses).
if (isset($_POST['submit_change_course_category'])) {
if (!empty($_POST['sec_token']) && $ctok == $_POST['sec_token']) {
$courseController->change_course_category(
$_POST['course_2_edit_category'],
$_POST['course_categories']
);
}
}
// We edit course category
if (isset($_POST['submit_edit_course_category']) &&
isset($_POST['title_course_category']) &&
strlen(trim($_POST['title_course_category'])) > 0
) {
if (!empty($_POST['sec_token']) && $ctok == $_POST['sec_token']) {
$courseController->edit_course_category(
$_POST['title_course_category'],
$_POST['edit_course_category']
);
}
}
// We are creating a new user defined course category (= Create Course Category).
if (isset($_POST['create_course_category']) &&
isset($_POST['title_course_category']) &&
strlen(trim($_POST['title_course_category'])) > 0
) {
if (!empty($_POST['sec_token']) && $ctok == $_POST['sec_token']) {
$courseController->addCourseCategory($_POST['title_course_category']);
}
}
// search courses
if (isset($_REQUEST['search_course'])) {
if (!empty($_REQUEST['sec_token']) && $ctok == $_REQUEST['sec_token']) {
@ -173,18 +115,6 @@ if (isset($_POST['unsubscribe'])) {
}
switch ($action) {
case 'deletecoursecategory':
// we are deleting a course category
if (isset($_GET['id'])) {
if (Security::check_token('get')) {
$courseController->delete_course_category($_GET['id']);
header('Location: '.api_get_self());
exit;
}
}
$courseController->courseList($action);
break;
case 'subscribe_course':
if (api_is_anonymous()) {
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php?c='.$courseCodeToSubscribe);
@ -237,12 +167,6 @@ switch ($action) {
$template->assign('content', $content);
$template->display_one_col_template();
break;
case 'createcoursecategory':
$courseController->categoryList();
break;
case 'sortmycourses':
$courseController->courseList($action);
break;
case 'subscribe':
if (!$user_can_view_page) {
api_not_allowed(true);
@ -366,37 +290,4 @@ switch ($action) {
$courseController->sessionListBySearch($limit);
break;
case 'set_collapsable':
api_block_anonymous_users();
if (!api_get_configuration_value('allow_user_course_category_collapsable')) {
api_not_allowed(true);
}
$userId = api_get_user_id();
$categoryId = isset($_REQUEST['categoryid']) ? (int) $_REQUEST['categoryid'] : 0;
$option = isset($_REQUEST['option']) ? (int) $_REQUEST['option'] : 0;
$redirect = isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : 0;
if (empty($userId) || empty($categoryId)) {
api_not_allowed(true);
}
$table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "UPDATE $table
SET collapsed = $option
WHERE user_id = $userId AND id = $categoryId";
Database::query($sql);
Display::addFlash(Display::return_message(get_lang('Updated')));
if ($redirect === 'home') {
$url = api_get_path(WEB_PATH).'user_portal.php';
header('Location: '.$url);
exit;
}
$url = api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses';
header('Location: '.$url);
exit;
break;
}

@ -33,9 +33,7 @@ if ($showSessions && isset($_POST['date'])) {
}
$userInfo = api_get_user_info();
$code = isset($code) ? $code : null;
$search = null;
$select = null;
$message = null;
?>
<script>
$(function() {
@ -69,57 +67,83 @@ $message = null;
} ?>
});
</script>
<?php
echo '<div class="row">
<div class="col-md-12">
<h2 class="title-courses">'.get_lang('CourseManagement').'</h2>
<div class="search-courses">
<div class="row">';
if ($showCourses) {
echo '<div class="col-md-'.($showSessions ? '4' : '6').'">';
if (!isset($_GET['hidden_links']) || intval($_GET['hidden_links']) != 1) {
$term = empty($_POST['search_term']) ? '' : api_htmlentities($searchTerm);
$urlAction = CourseCategory::getCourseCategoryUrl(1, $pageLength, 'ALL', 0, 'subscribe');
$formSearch = new FormValidator('search_catalog', 'post', $urlAction, null, [], FormValidator::LAYOUT_BOX_SEARCH);
$formSearch->addHidden('sec_token', $stok);
$formSearch->addHidden('search_course', 1);
$formSearch->addText('search_term', get_lang('Search'), false, ['value' => $term, 'icon' => 'search'])->setButton(true);
//$formSearch->defaultRenderer()->setElementTemplate($formSearch->getDefaultElementTemplate(),'search_term');
$search = $formSearch->returnForm();
$webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php';
$formSelect = new FormValidator('select_category', 'get', $webAction, null, []);
$formSelect->addHidden('action', $action);
$formSelect->addHidden('pageCurrent', $pageCurrent);
$formSelect->addHidden('pageLength', $pageLength);
$options = [];
foreach ($browse_course_categories[0] as $category) {
$categoryCode = $category['code'];
$countCourse = $category['count_courses'];
if (empty($countCourse)) {
continue;
}
?>
<form method="post"
action="<?php echo CourseCategory::getCourseCategoryUrl(1, $pageLength, 'ALL', 0, 'subscribe'); ?>">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="search_course" value="1"/>
<label><?php echo get_lang('Search'); ?></label>
<div class="input-group">
<input class="form-control" type="text" name="search_term"
value="<?php echo empty($_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'); ?>
</button>
</div>
</div>
</form>
<?php
}
echo '</div>';
echo '<div class="col-md-'.($showSessions ? '4' : '6').'">';
$listCategories = CoursesAndSessionsCatalog::getCourseCategoriesTree();
$categoriesSelect = getOptionSelect($listCategories, $codeType);
$webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php';
$form = '<form action="'.$webAction.'" method="GET">';
$form .= '<input type="hidden" name="action" value="'.$action.'">';
$form .= '<input type="hidden" name="pageCurrent" value="'.$pageCurrent.'">';
$form .= '<input type="hidden" name="pageLength" value="'.$pageLength.'">';
$form .= '<div class="form-group">';
$form .= '<label>'.get_lang('CourseCategories').'</label>';
$form .= $categoriesSelect;
$form .= '</div>';
$form .= '</form>';
echo $form;
echo '</div>';
}
$options[$categoryCode] = $category['name'].' ('.$countCourse.')';
}
if ($showSessions) {
$url = CourseCategory::getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions');
echo '<div class="col-md-4">
<div class="return-catalog">
<a class="btn btn-default btn-lg btn-block"
href="'.$url.'">
<em class="fa fa-arrow-right"></em>'.get_lang('SessionList').'
</a>
</div>
</div>
';
}
if (empty($codeType)) {
$codeType = 'ALL';
}
$formSelect->addSelect('category_code', get_lang('Categories'), $options, ['onchange' => 'submit();'])->setSelected($codeType);
$select = $formSelect->returnForm();
}
echo '</div></div></div></div>';
if ($showCourses && $action != 'display_sessions') {
if (!empty($message)) {
$message = Display::return_message($message, 'confirmation', false);
echo Display::return_message($message, 'confirmation', false);
}
if (!empty($error)) {
$message = Display::return_message($error, 'error', false);
echo Display::return_message($error, 'error', false);
}
if (!empty($content)) {
$message = $content;
echo $content;
}
if (!empty($searchTerm)) {
$message = "<p><strong>".get_lang('SearchResultsFor')." ".$searchTerm."</strong><br />";
echo "<p><strong>".get_lang('SearchResultsFor')." ".$searchTerm."</strong><br />";
}
$showTeacher = api_get_setting('display_teacher_in_courselist') === 'true';
@ -127,7 +151,6 @@ if ($showCourses && $action != 'display_sessions') {
$user_id = api_get_user_id();
$categoryListFromDatabase = CourseCategory::getCategories();
$courseList = [];
$categoryList = [];
if (!empty($categoryListFromDatabase)) {
foreach ($categoryListFromDatabase as $categoryItem) {
@ -136,6 +159,7 @@ if ($showCourses && $action != 'display_sessions') {
}
if (!empty($browse_courses_in_category)) {
echo '<div class="grid-courses row">';
foreach ($browse_courses_in_category as $course) {
$course_hidden = $course['visibility'] == COURSE_VISIBILITY_HIDDEN;
@ -158,47 +182,19 @@ if ($showCourses && $action != 'display_sessions') {
$creation_date = substr($course['creation_date'], 0, 10);
// display the course bloc
$html = '<div class="col-xs-12 col-sm-6 col-md-4"><div class="items items-courses">';
$course['category_title'] = '';
if (isset($course['category'])) {
$course['category_title'] = isset($categoryList[$course['category']]) ? $categoryList[$course['category']] : '';
}
if (api_get_configuration_value('hide_course_rating') === false) {
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$rating = Display::return_rating_system(
'star_'.$course['real_id'],
$ajax_url.'&course_id='.$course['real_id'],
$course['point_info']
);
}
//course return image
$course_path = api_get_path(SYS_COURSE_PATH).$course['directory'];
if (file_exists($course_path.'/course-pic.png')) {
$courseMediumImage = api_get_path(WEB_COURSE_PATH).$course['directory'].'/course-pic.png';
} else {
// without picture
$courseMediumImage = Display::return_icon(
'session_default.png',
null,
null,
null,
null,
true
);
}
if ($showTeacher) {
$teachers = CourseManager::getTeachersFromCourse($course['real_id']);
}
// Display thumbnail
$html .= returnThumbnail($course, $userRegistered);
$separator = null;
$subscribeBuy = return_register_button($course, $stok, $code, $searchTerm);
$subscribeButton = return_register_button($course, $stok, $code, $searchTerm);
// Start buy course validation
// display the course price and buy button if the buycourses plugin is enabled and this course is configured
$plugin = BuyCoursesPlugin::create();
$isThisCourseInSale = $plugin->buyCoursesForGridCatalogValidator(
@ -211,7 +207,7 @@ if ($showCourses && $action != 'display_sessions') {
$separator = $isThisCourseInSale['html'];
// set the Buy button instead register.
if ($isThisCourseInSale['verificator']) {
$subscribeBuy = $plugin->returnBuyCourseButton(
$subscribeButton = $plugin->returnBuyCourseButton(
$course['real_id'],
BuyCoursesPlugin::PRODUCT_TYPE_COURSE
);
@ -219,47 +215,54 @@ if ($showCourses && $action != 'display_sessions') {
}
// end buy course validation
// display course title and button bloc
$html .= '<div class="description">';
$html .= return_title($course, $userRegisteredInCourse);
if ($showTeacher) {
$html .= return_teacher($course);
}
// display button line
$html .= '<div class="toolbar row">';
$html .= $separator ? '<div class="col-sm-4">'.$separator.'</div>' : '';
$html .= '<div class="col-sm-8">';
// if user registered as student
if ($userRegisteredInCourse) {
$subscribeButton = return_already_registered_label('student');
$html .= return_already_registered_label('student');
if (!$course_closed) {
if ($course_unsubscribe_allowed) {
$subscribeButton = return_unregister_button($course, $stok, $searchTerm, $code);
$html .= return_unregister_button($course, $stok, $searchTerm, $code);
}
}
} elseif ($userRegisteredInCourseAsTeacher) {
// if user registered as teacher
if ($course_unsubscribe_allowed) {
$subscribeButton = return_unregister_button($course, $stok, $searchTerm, $code);
$html .= return_unregister_button($course, $stok, $searchTerm, $code);
}
} else {
// if user not registered in the course
if (!$course_closed) {
if (!$course_private) {
if ($course_subscribe_allowed) {
$subscribeButton = $subscribeBuy;
$html .= $subscribeButton;
}
}
}
}
$courseList[] = [
'id' => $course['real_id'],
'title' => $course['title'],
'category' => $course['category_title'],
'image' => $courseMediumImage,
'url' => $linkCourse = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about',
'teachers' => $teachers,
'ranking' => $rating,
'description_ajax' => CourseManager::returnDescriptionButton($course),
'subscribe' => $subscribeButton,
];
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
echo $html;
}
echo '</div>';
} else {
if (!isset($_REQUEST['subscribe_user_with_password']) &&
!isset($_REQUEST['subscribe_course'])
) {
$message = Display::return_message(
echo Display::return_message(
get_lang('ThereAreNoCoursesInThisCategory'),
'warning'
);
@ -267,16 +270,171 @@ if ($showCourses && $action != 'display_sessions') {
}
}
$template = new Template(get_lang('Course Catalog'));
$template->assign('search', $search);
$template->assign('select', $select);
$template->assign('pagination', $cataloguePagination);
$template->assign('courses', $courseList);
$template->assign('message', $message);
$layout = $template->get_template('auth/course_catalog.html.twig');
$content = $template->fetch($layout);
echo '<div class="col-md-12">';
echo $cataloguePagination;
echo '</div>';
function getOptionSelect($categories, $codeType)
{
$html = '';
$html .= '<select name="category_code" onchange="submit();" class="selectpicker form-control">';
foreach ($categories as $category) {
$categoryCode = Security::remove_XSS($category['code']);
$categoryName = Security::remove_XSS($category['name']);
$countCourse = (int) $category['number_courses'];
$level = $category['level'];
if (empty($countCourse)) {
continue;
}
if ($level > 0) {
$separate = str_repeat('--', $level);
} else {
$separate = '';
}
$html .= '<option '.($categoryCode == $codeType ? 'selected="selected" ' : '')
.' value="'.$categoryCode.'">'.$separate.' '.$categoryName.' ('.$countCourse.') </option>';
}
$html .= '</select>';
return $html;
}
/**
* Display the course catalog image of a course.
*
* @param array $course
* @param bool $registeredUser
*
* @return string HTML string
*/
function returnThumbnail($course, $registeredUser)
{
$html = '';
$title = cut($course['title'], 70);
//$linkCourse = api_get_course_url($course['code']);
$linkCourse = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about';
// course path
$course_path = api_get_path(SYS_COURSE_PATH).$course['directory'];
if (file_exists($course_path.'/course-pic.png')) {
// redimensioned image 85x85
$courseMediumImage = api_get_path(WEB_COURSE_PATH).$course['directory'].'/course-pic.png';
} else {
// without picture
$courseMediumImage = Display::return_icon(
'session_default.png',
null,
null,
null,
null,
true
);
}
$html .= '<div class="image">';
$html .= '<a href="'.$linkCourse.'" title="'.$course['title'].'">'
.'<img class="img-responsive" src="'.$courseMediumImage.'" '
.'alt="'.api_htmlentities($title).'"/></a>';
$categoryTitle = isset($course['category_title']) ? $course['category_title'] : '';
if (!empty($categoryTitle)) {
$html .= '<span class="category">'.$categoryTitle.'</span>';
$html .= '<div class="cribbon"></div>';
}
$html .= '<div class="user-actions">';
$html .= CourseManager::returnDescriptionButton($course);
$html .= '</div></div>';
return $html;
}
/**
* @param array $courseInfo
*
* @return string
*/
function return_teacher($courseInfo)
{
$teachers = CourseManager::getTeachersFromCourse($courseInfo['real_id']);
$length = count($teachers);
if (!$length) {
return '';
}
$html = '<div class="block-author">';
if ($length > 6) {
$html .= '<a
id="plist"
data-trigger="focus"
tabindex="0" role="button"
class="btn btn-default panel_popover"
data-toggle="popover"
title="'.addslashes(get_lang('CourseTeachers')).'"
data-html="true"
>
<i class="fa fa-graduation-cap" aria-hidden="true"></i>
</a>';
$html .= '<div id="popover-content-plist" class="hide">';
foreach ($teachers as $value) {
$name = $value['firstname'].' '.$value['lastname'];
$html .= '<div class="popover-teacher">';
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">
<img src="'.$value['avatar'].'" title="'.$name.'" alt="'.get_lang('UserPicture').'"/></a>';
$html .= '<div class="teachers-details"><h5>
<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">'
.$name.'</a></h5></div>';
$html .= '</div>';
}
$html .= '</div>';
} else {
foreach ($teachers as $value) {
$name = $value['firstname'].' '.$value['lastname'];
if ($length > 2) {
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">
<img src="'.$value['avatar'].'" title="'.$name.'" alt="'.get_lang('UserPicture').'"/></a>';
} else {
$html .= '<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'" title="'.$name.'">
<img src="'.$value['avatar'].'" title="'.$name.'" alt="'.get_lang('UserPicture').'"/></a>';
$html .= '<div class="teachers-details"><h5>
<a href="'.$value['url'].'" class="ajax" data-title="'.$name.'">'
.$name.'</a></h5><p>'.get_lang('Teacher').'</p></div>';
}
}
}
$html .= '</div>';
return $html;
}
/**
* Display the title of a course in course catalog.
*
* @param array $course
* @param bool $registeredUser
*
* @return string HTML string
*/
function return_title($course, $registeredUser)
{
//$linkCourse = api_get_course_url($course['code']);
$linkCourse = api_get_path(WEB_PATH).'course/'.$course['real_id'].'/about';
$html = '<div class="block-title"><h4 class="title">';
$html .= '<a title="'.$course['title'].'" href="'.$linkCourse.'">'.$course['title'].'</a>';
$html .= '</h4></div>';
if (api_get_configuration_value('hide_course_rating') === false) {
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
$rating = Display::return_rating_system(
'star_'.$course['real_id'],
$ajax_url.'&course_id='.$course['real_id'],
$course['point_info']
);
$html .= '<div class="ranking">'.$rating.'</div>';
}
echo $content;
return $html;
}
/**
* Display the goto course button of a course in the course catalog.

@ -33,57 +33,6 @@ class CoursesController
$this->model = new Auth();
}
/**
* It's used for listing courses,
* render to courses_list view.
*
* @param string $action
* @param string $message confirmation message(optional)
*/
public function courseList($action, $message = '')
{
$data = [];
$data['user_courses'] = $this->model->get_courses_of_user(api_get_user_id());
$data['user_course_categories'] = CourseManager::get_user_course_categories(api_get_user_id());
$data['courses_in_category'] = $this->model->get_courses_in_category();
$data['action'] = $action;
$data['message'] = $message;
// render to the view
$this->view->set_data($data);
$this->view->set_layout('catalog_layout');
$this->view->set_template('courses_list');
$this->view->render();
}
/**
* It's used for listing categories, render to categories_list view.
*/
public function categoryList()
{
api_block_anonymous_users();
$stok = Security::get_token();
$actions = Display::url(
Display::return_icon('back.png', get_lang('Back'), '', '32'),
api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses'
);
$actions = Display::toolbarAction('toolbar-forum', [$actions]);
$form = new FormValidator(
'create_course_category',
'post',
api_get_path(WEB_CODE_PATH).'auth/courses.php?action=createcoursecategory'
);
$form->addHidden('sec_token', $stok);
$form->addText('title_course_category', get_lang('Name'));
$form->addButtonSave(get_lang('AddCategory'), 'create_course_category');
$tpl = new Template();
$tpl->assign('content', $form->returnForm());
$tpl->assign('actions', $actions);
$tpl->display_one_col_template();
}
/**
* It's used for listing courses with categories,
* render to courses_categories view.
@ -218,129 +167,6 @@ class CoursesController
$this->view->render();
}
/**
* Create a category
* render to listing view.
*
* @param string $title
*/
public function addCourseCategory($title)
{
$result = $this->model->store_course_category($title);
if ($result) {
Display::addFlash(
Display::return_message(get_lang('CourseCategoryStored'))
);
} else {
Display::addFlash(
Display::return_message(
get_lang('ACourseCategoryWithThisNameAlreadyExists'),
'error'
)
);
}
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses');
exit;
}
/**
* Change course category
* render to listing view.
*
* @param string $course_code
* @param int $category_id
*/
public function change_course_category($course_code, $category_id)
{
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$result = $this->model->updateCourseCategory($courseId, $category_id);
if ($result) {
Display::addFlash(
Display::return_message(get_lang('EditCourseCategorySucces'))
);
}
$action = 'sortmycourses';
$this->courseList($action);
}
/**
* Move up/down courses inside a category
* render to listing view.
*
* @param string $move move to up or down
* @param string $course_code
* @param int $category_id Category id
*/
public function move_course($move, $course_code, $category_id)
{
$result = $this->model->move_course($move, $course_code, $category_id);
if ($result) {
Display::addFlash(
Display::return_message(get_lang('CourseSortingDone'))
);
}
$action = 'sortmycourses';
$this->courseList($action);
}
/**
* Move up/down categories
* render to listing view.
*
* @param string $move move to up or down
* @param int $category_id Category id
*/
public function move_category($move, $category_id)
{
$result = $this->model->move_category($move, $category_id);
if ($result) {
Display::addFlash(
Display::return_message(get_lang('CategorySortingDone'))
);
}
$action = 'sortmycourses';
$this->courseList($action);
}
/**
* Edit course category
* render to listing view.
*
* @param string $title Category title
* @param int $category Category id
*/
public function edit_course_category($title, $category)
{
$result = $this->model->store_edit_course_category($title, $category);
if ($result) {
Display::addFlash(
Display::return_message(get_lang('CourseCategoryEditStored'))
);
}
$action = 'sortmycourses';
$this->courseList($action);
}
/**
* Delete a course category
* render to listing view.
*
* @param int Category id
*/
public function delete_course_category($category_id)
{
$result = $this->model->delete_course_category($category_id);
if ($result) {
Display::addFlash(
Display::return_message(get_lang('CourseCategoryDeleted'))
);
}
$action = 'sortmycourses';
$this->courseList($action);
}
/**
* Unsubscribe user from a course
* render to listing view.
@ -376,123 +202,6 @@ class CoursesController
}
}
/**
* Get the html block for courses categories.
*
* @param string $code Current category code
* @param bool $hiddenLinks Whether hidden links
* @param array $limit
*
* @return string The HTML block
*/
public function getCoursesCategoriesBlock(
$code = null,
$hiddenLinks = false,
$limit = null
) {
$categories = CoursesAndSessionsCatalog::getCourseCategories();
$html = '';
if (!empty($categories)) {
$action = 'display_courses';
foreach ($categories[0] as $category) {
$categoryName = $category['name'];
$categoryCode = $category['code'];
$categoryCourses = $category['count_courses'];
$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="'.$categoryLink.'">';
$html .= "$categoryName ($categoryCourses)";
$html .= '</a>';
} else {
$html .= "$categoryName ($categoryCourses)";
}
}
if (!empty($categories[$categoryCode])) {
$html .= '<ul class="nav nav-list">';
foreach ($categories[$categoryCode] as $subCategory1) {
$subCategory1Name = $subCategory1['name'];
$subCategory1Code = $subCategory1['code'];
$subCategory1Courses = $subCategory1['count_courses'];
$html .= '<li>';
if ($code == $subCategory1Code) {
$html .= "<strong>$subCategory1Name ($subCategory1Courses)</strong>";
} else {
$html .= '<a href="'.$categoryLink.'">';
$html .= "$subCategory1Name ($subCategory1Courses)";
$html .= '</a>';
}
if (!empty($categories[$subCategory1Code])) {
$html .= '<ul class="nav nav-list">';
foreach ($categories[$subCategory1Code] as $subCategory2) {
$subCategory2Name = $subCategory2['name'];
$subCategory2Code = $subCategory2['code'];
$subCategory2Courses = $subCategory2['count_courses'];
$html .= '<li>';
if ($code == $subCategory2Code) {
$html .= "<strong>$subCategory2Name ($subCategory2Courses)</strong>";
} else {
$html .= '<a href="'.$categoryLink.'">';
$html .= "$subCategory2Name ($subCategory2Courses)";
$html .= '</a>';
}
if (!empty($categories[$subCategory2Code])) {
$html .= '<ul class="nav nav-list">';
foreach ($categories[$subCategory2Code] as $subCategory3) {
$subCategory3Name = $subCategory3['name'];
$subCategory3Code = $subCategory3['code'];
$subCategory3Courses = $subCategory3['count_courses'];
$html .= '<li>';
if ($code == $subCategory3Code) {
$html .= "<strong>$subCategory3Name ($subCategory3Courses)</strong>";
} else {
$html .= '<a href="'.$categoryLink.'">';
$html .= "$subCategory3Name ($subCategory3Courses)";
$html .= '</a>';
}
$html .= '</li>';
}
$html .= '</ul>';
}
$html .= '</li>';
}
$html .= '</ul>';
}
$html .= '</li>';
}
$html .= '</ul>';
}
$html .= '</li>';
}
}
return $html;
}
/**
* Get a HTML button for subscribe to session.
*
@ -512,6 +221,7 @@ class CoursesController
$includeText = false,
$btnBing = false
) {
$sessionId = (int) $sessionId;
if ($btnBing) {
$btnBing = 'btn-lg btn-block';
} else {
@ -522,7 +232,7 @@ class CoursesController
$url .= 'sequence.ajax.php?';
$url .= http_build_query([
'a' => 'get_requirements',
'id' => intval($sessionId),
'id' => $sessionId,
'type' => SequenceResource::SESSION_TYPE,
]);
@ -552,7 +262,7 @@ class CoursesController
$url .= 'auth/courses.php?';
$url .= http_build_query([
'action' => 'subscribe_to_session',
'session_id' => intval($sessionId),
'session_id' => $sessionId,
]);
$result = Display::toolbarButton(
@ -588,7 +298,7 @@ class CoursesController
$hook = HookResubscribe::create();
if (!empty($hook)) {
$hook->setEventData([
'session_id' => intval($sessionId),
'session_id' => $sessionId,
]);
try {
$hook->notifyResubscribe(HOOK_EVENT_TYPE_PRE);

@ -1,323 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for courses.
*
* @todo fix this. use twig templates
*
* @author Christian Fasanando <christian1827@gmail.com> - Beeznest
*
* @package chamilo.auth
*/
// Access rights: anonymous users can't do anything usefull here.
api_block_anonymous_users();
$stok = Security::get_token();
$courses_without_category = isset($courses_in_category[0]) ? $courses_in_category[0] : null;
echo '<div id="actions" class="actions">';
if ($action != 'createcoursecategory') {
echo '<a href="'.api_get_self().'?action=createcoursecategory">';
echo Display::return_icon('new_folder.png', get_lang('CreateCourseCategory'), '', '32');
echo '</a>';
}
echo '</div>';
if (!empty($message)) {
echo Display::return_message($message, 'confirm', false);
}
$allowCollapsable = api_get_configuration_value('allow_user_course_category_collapsable');
$teachersIcon = Display::return_icon('teacher.png', get_lang('Teachers'), null, ICON_SIZE_TINY);
// COURSES WITH CATEGORIES
if (!empty($user_course_categories)) {
$counter = 0;
$last = end($user_course_categories);
foreach ($user_course_categories as $row) {
echo Display::page_subheader($row['title']);
echo '<a name="category'.$row['id'].'"></a>';
$url = api_get_path(WEB_CODE_PATH).'auth/courses.php?categoryid='.$row['id'].'&sec_token='.$stok;
if (isset($_GET['categoryid']) && $_GET['categoryid'] == $row['id']) {
?>
<!-- We display the edit form for the category -->
<form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
<input type="hidden" name="edit_course_category" value="<?php echo $row['id']; ?>" />
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="text" name="title_course_category" value="<?php echo $row['title']; ?>" />
<button class="save" type="submit" name="submit_edit_course_category"><?php echo get_lang('Ok'); ?></button>
</form>
<?php
}
if ($action != 'unsubscribe') {
if ($allowCollapsable) {
if (isset($row['collapsed']) && $row['collapsed'] == 0) {
echo Display::url(
'<i class="fa fa-folder-open"></i>',
$url.'&action=set_collapsable&option=1'
);
} else {
echo Display::url(
'<i class="fa fa-folder"></i>',
$url.'&action=set_collapsable&option=0'
);
}
} ?>
<a href="courses.php?action=sortmycourses&amp;categoryid=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>#category<?php echo $row['id']; ?>">
<?php echo Display::display_icon('edit.png', get_lang('Edit'), '', 22); ?>
</a>
<?php if (0 != $counter) {
?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;category=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::return_icon('up.png', get_lang('Up'), '', 22); ?>
</a>
<?php
} else {
?>
<?php echo Display::return_icon('up_na.png', get_lang('Up'), '', 22); ?>
<?php
}
if ($row['id'] != $last['id']) {
?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;category=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::return_icon('down.png', get_lang('Down'), '', 22); ?>
</a>
<?php
} else {
echo Display::return_icon('down_na.png', get_lang('Down'), '', 22); ?>
<?php
} ?>
<a href="courses.php?action=deletecoursecategory&amp;id=<?php echo $row['id']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon(
'delete.png',
get_lang('Delete'),
[
'onclick' => "javascript: if (!confirm('".addslashes(
api_htmlentities(
get_lang('CourseCategoryAbout2bedeleted'),
ENT_QUOTES,
api_get_system_encoding()
)
)."')) return false;",
],
22
); ?>
</a>
<?php
}
$counter++;
echo '<br /><br />';
// Show the courses inside this category
echo '<table class="data_table">';
$number_of_courses = isset($courses_in_category[$row['id']]) ? count($courses_in_category[$row['id']]) : 0;
$key = 0;
if (!empty($courses_in_category[$row['id']])) {
foreach ($courses_in_category[$row['id']] as $course) {
echo '<tr><td>';
echo '<a name="course'.$course['code'].'"></a>';
echo '<strong>'.$course['title'].'</strong>';
echo ' ('.$course['visual_code'].')';
echo '<br />';
echo $teachersIcon;
echo '&nbsp;';
echo CourseManager::getTeacherListFromCourseCodeToString($course['code']);
echo '<br />';
if (api_get_setting('display_teacher_in_courselist') === 'true') {
echo $course['tutor'];
}
echo '</td><td valign="top">';
if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {
$edit_course = Security::remove_XSS($_GET['edit']); ?>
<form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="course_2_edit_category" value="<?php echo $edit_course; ?>" />
<select name="course_categories">
<option value="0"><?php echo get_lang('NoCourseCategory'); ?></option>
<?php foreach ($user_course_categories as $row) {
?>
<option value="<?php echo $row['id']; ?>"><?php echo $row['title']; ?></option>
<?php
} ?>
</select>
<button class="save" type="submit" name="submit_change_course_category"><?php echo get_lang('Ok'); ?></button>
</form>
<?php
} ?>
<div style="float:left;width:110px;">
<?php
if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
$icon_title = get_lang('CourseDetails').' - '.$course['title']; ?>
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>inc/ajax/course_home.ajax.php?a=show_course_information&code=<?php echo $course['code']; ?>" data-title="<?php echo $icon_title; ?>" title="<?php echo $icon_title; ?>" class="ajax">
<?php echo Display::return_icon('info.png', $icon_title, '', '22'); ?>
<?php
} ?>
</a>
<?php if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {
?>
<?php echo Display::display_icon('edit_na.png', get_lang('Edit'), '', 22); ?>
<?php
} else {
?>
<a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('edit.png', get_lang('Edit'), '', 22); ?>
</a>
<?php
} ?>
<?php if ($key > 0) {
?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('up.png', get_lang('Up'), '', 22); ?>
</a>
<?php
} else {
?>
<?php echo Display::display_icon('up_na.png', get_lang('Up'), '', 22); ?>
<?php
} ?>
<?php if ($key < $number_of_courses - 1) {
?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('down.png', get_lang('Down'), '', 22); ?>
</a>
<?php
} else {
?>
<?php echo Display::display_icon('down_na.png', get_lang('Down'), '', 22); ?>
<?php
} ?>
</div>
<div style="float:left; margin-right:10px;">
<?php
if ($course['status'] != 1) {
if ($course['unsubscr'] == 1) {
?>
<form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding())); ?>')) return false">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
<button class="btn btn-default" value="<?php echo get_lang('Unsubscribe'); ?>" name="unsub">
<?php echo get_lang('Unsubscribe'); ?>
</button>
</form>
</div>
<?php
}
}
$key++;
}
echo '</table>';
}
}
}
echo Display::page_subheader(get_lang('NoCourseCategory'));
echo '<table class="data_table">';
// COURSES WITHOUT CATEGORY
if (!empty($courses_without_category)) {
$number_of_courses = count($courses_without_category);
$key = 0;
foreach ($courses_without_category as $course) {
echo '<tr><td>';
echo '<a name="course'.$course['code'].'"></a>';
echo '<strong>'.$course['title'].'</strong>';
echo ' ('.$course['visual_code'].')';
echo '<br />';
echo $teachersIcon;
echo '&nbsp;';
echo CourseManager::getTeacherListFromCourseCodeToString($course['code']);
echo '<br />';
if (api_get_setting('display_teacher_in_courselist') === 'true') {
echo $course['tutor'];
}
echo '</td><td valign="top">';
// the edit icon OR the edit dropdown list
if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {
$edit_course = Security::remove_XSS($_GET['edit']); ?>
<div style="float:left;">
<form name="edit_course_category" method="post" action="courses.php?action=<?php echo $action; ?>">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="course_2_edit_category" value="<?php echo $edit_course; ?>" />
<select name="course_categories">
<option value="0"><?php echo get_lang("NoCourseCategory"); ?></option>
<?php foreach ($user_course_categories as $row) {
?>
<option value="<?php echo $row['id']; ?>"><?php echo $row['title']; ?></option>
<?php
} ?>
</select>
<button class="save" type="submit" name="submit_change_course_category"><?php echo get_lang('Ok'); ?></button>
</form><br />
</div>
<?php
} ?>
<div style="float:left; width:110px">
<?php
if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
$icon_title = get_lang('CourseDetails').' - '.$course['title']; ?>
<a href="<?php echo api_get_path(WEB_CODE_PATH); ?>inc/ajax/course_home.ajax.php?a=show_course_information&code=<?php echo $course['code']; ?>" data-title="<?php echo $icon_title; ?>" title="<?php echo $icon_title; ?>" class="ajax">
<?php echo Display::return_icon('info.png', $icon_title, '', '22'); ?>
</a>
<?php
}
if (isset($_GET['edit']) && $course['code'] == $_GET['edit']) {
echo Display::display_icon('edit_na.png', get_lang('Edit'), '', 22);
} else {
?>
<a href="courses.php?action=<?php echo $action; ?>&amp;edit=<?php echo $course['code']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('edit.png', get_lang('Edit'), '', 22); ?>
</a>
<?php
}
if ($key > 0) {
?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=up&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('up.png', get_lang('Up'), '', 22); ?>
</a>
<?php
} else {
echo Display::display_icon('up_na.png', get_lang('Up'), '', 22);
}
if ($key < $number_of_courses - 1) {
?>
<a href="courses.php?action=<?php echo $action; ?>&amp;move=down&amp;course=<?php echo $course['code']; ?>&amp;category=<?php echo $course['user_course_cat']; ?>&amp;sec_token=<?php echo $stok; ?>">
<?php echo Display::display_icon('down.png', get_lang('Down'), '', 22); ?>
</a>
<?php
} else {
echo Display::display_icon('down_na.png', get_lang('Down'), '', 22);
} ?>
</div>
<div style="float:left; margin-right:10px;">
<!-- cancel subscrioption-->
<?php
if ($course['status'] != 1) {
if ($course['unsubscr'] == 1) {
?>
<!-- changed link to submit to avoid action by the search tool indexer -->
<form action="<?php echo api_get_self(); ?>" method="post" onsubmit="javascript: if (!confirm('<?php echo addslashes(api_htmlentities(get_lang("ConfirmUnsubscribeFromCourse"), ENT_QUOTES, api_get_system_encoding())); ?>')) return false;">
<input type="hidden" name="sec_token" value="<?php echo $stok; ?>">
<input type="hidden" name="unsubscribe" value="<?php echo $course['code']; ?>" />
<button class="btn btn-default" value="<?php echo get_lang('Unsubscribe'); ?>" name="unsub">
<?php echo get_lang('Unsubscribe'); ?>
</button>
</form>
</div>
<?php
}
} ?>
</td>
</tr>
<?php
$key++;
}
}
?>
</table>

@ -1,11 +1,9 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course;
require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users(true);
api_block_anonymous_users();
$isHrm = api_is_drh();
@ -13,36 +11,6 @@ if (!$isHrm) {
api_not_allowed(true);
}
function formatCourseInfo(Course $course, $sessionId = 0, $showCourseCode = false)
{
$sysCoursePath = api_get_path(SYS_COURSE_PATH).$course->getDirectory();
$webCoursePath = api_get_path(WEB_COURSE_PATH).$course->getDirectory();
return [
'visibility' => $course->getVisibility(),
'link' => api_get_course_url($course->getCode(), $sessionId),
'category' => $course->getCategoryCode(),
'title' => $course->getTitle(),
'title_cut' => $course->getTitle(),
'code_course' => $showCourseCode ? $course->getCode() : null,
'image' => file_exists($sysCoursePath.'/course-pic.png')
? $webCoursePath.'/course-pic.png'
: Display::return_icon(
'session_default.png',
null,
null,
null,
null,
true
),
'teachers' => api_get_setting('display_teacher_in_courselist') === 'true'
? $teachers = CourseManager::getTeachersFromCourse($course->getId(), true)
: [],
];
}
$showCourseCode = api_get_configuration_value('display_coursecode_in_courselist') === 'true';
$hrm = api_get_user_entity(api_get_user_id());
$assignedUsers = UserManager::get_users_followed_by_drh($hrm->getId());
$users = [];

@ -636,8 +636,9 @@ if ($extraConditions && $extraFieldsLoaded) {
$element->setLabel(
[
'',
//'<textarea rows="5" disabled cols="100%">'.get_lang($condition['text_area']).'</textarea>',
'<div class="form-control" disabled=disabled style="height: 100px; overflow: auto;">'.get_lang($condition['text_area']).'</div>',
'<div class="form-control" disabled=disabled style="height: 100px; overflow: auto;">'.
get_lang(nl2br($condition['text_area'])).
'</div>',
]
);
}

@ -278,6 +278,10 @@ if ($agenda->type === 'course') {
$form->addElement('textarea', 'comment', get_lang('Comment'), ['id' => 'comment']);
}
$form->addHtml('<div id="attachment_block" style="display: none">');
$form->addLabel(get_lang('Attachment'), '<div id="attachment_text" style="display: none"></div>');
$form->addHtml('</div>');
$tpl->assign('form_add', $form->returnForm());
$tpl->assign('legend_list', api_get_configuration_value('agenda_legend'));

@ -19,18 +19,14 @@ header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
header('Cache-Control: public');
header('Pragma: no-cache');
$course_id = isset($_REQUEST['course_id']) ? $_REQUEST['course_id'] : 0;
$course_id = isset($_REQUEST['course_id']) ? (int) $_REQUEST['course_id'] : api_get_course_int_id();
$user_id = api_get_user_id();
$course_info = api_get_course_info_by_id($course_id);
$doc_url = $_REQUEST['file'];
if (empty($course_id)) {
$course_id = api_get_course_int_id();
}
if (empty($course_id) || empty($doc_url)) {
api_not_allowed();
}
$doc_url = $_REQUEST['file'];
$session_id = api_get_session_id();
$is_user_is_subscribed = CourseManager::is_user_subscribed_in_course(

@ -227,7 +227,7 @@ if (!empty($lpAutoLaunch)) {
} else {
$session_key = 'lp_autolaunch_'.$session_id.'_'.api_get_course_int_id().'_'.api_get_user_id();
if (!isset($_SESSION[$session_key])) {
//redirecting to the LP
// Redirecting to the LP
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp_data['id'];
$_SESSION[$session_key] = true;
@ -325,6 +325,7 @@ if ($documentAutoLaunch == 1) {
}
}
// Used in different pages
$tool_table = Database::get_course_table(TABLE_TOOL_LIST);
/* Introduction section (editable by course admins) */

@ -26,7 +26,7 @@ $actions .= Display::url(
);
$action = isset($_GET['action']) ? $_GET['action'] : '';
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$id = isset($_GET['id']) ? (int) $_GET['id'] : '';
$currentUrl = api_get_self().'?'.api_get_cidreq();
switch ($action) {
@ -51,8 +51,8 @@ switch ($action) {
}
$interbreadcrumb[] = [
"url" => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq(),
"name" => get_lang('Documents'),
'url' => api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq(),
'name' => get_lang('Documents'),
];
$template = new Template(get_lang('DeletedDocuments'));
$template->assign('files', $files);

@ -166,7 +166,7 @@ if (api_is_course_admin()) {
$frameheight = 165;
}
$frameReady = Display::getFrameReadyBlock('top.mainFrame');
$frameReady = Display::getFrameReadyBlock('#mainFrame');
$web_odf_supported_files = DocumentManager::get_web_odf_extension_list();
// PDF should be displayed with viewerJS
@ -226,20 +226,14 @@ if (!$playerSupported && $execute_iframe) {
</script>';
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js"></script>';
$htmlHeadXtra[] = '<script>
var updateContentHeight = function() {
my_iframe = document.getElementById("mainFrame");
if (my_iframe) {
//this doesnt seem to work in IE 7,8,9
new_height = my_iframe.contentWindow.document.body.scrollHeight;
my_iframe.height = my_iframe.contentWindow.document.body.scrollHeight + "px";
}
};
// Fixes the content height of the frame
$(window).on("load", function() {
updateContentHeight();
$(function() {
$(\'#mainFrame\').on(\'load\', function () {
this.style.height = (this.contentWindow.document.body.scrollHeight + 50) + \'px\';
});
'.$frameReady.'
)}
});
</script>';
}

@ -283,22 +283,6 @@ class TestCategory
return $result;
}
/**
* true if question id has a category.
*
* @param int $questionId
*
* @return bool
*/
public static function isQuestionHasCategory($questionId)
{
if (self::getCategoryForQuestion($questionId) > 0) {
return true;
}
return false;
}
/**
* Return the category name for question with question_id = $questionId
* In this version, a question has only 1 category.
@ -437,17 +421,6 @@ class TestCategory
return $result;
}
/**
* return the number of differents categories for a test
* input : test_id
* return : integer
* hubert.borderiou 07-04-2011.
*/
public static function getNumberOfCategoriesForTest($id)
{
return count(self::getListOfCategoriesIDForTest($id));
}
/**
* return the number of question of a category id in a test.
*
@ -672,22 +645,6 @@ class TestCategory
return $content;
}
/**
* Display signs [+] and/or (>0) after question title if question has options
* scoreAlwaysPositive and/or uncheckedMayScore.
*
* @param $objQuestion
*/
public function displayQuestionOption($objQuestion)
{
if ($objQuestion->type == MULTIPLE_ANSWER && $objQuestion->scoreAlwaysPositive) {
echo "<span style='font-size:75%'> (>0)</span>";
}
if ($objQuestion->type == MULTIPLE_ANSWER && $objQuestion->uncheckedMayScore) {
echo "<span style='font-size:75%'> [+]</span>";
}
}
/**
* sortTabByBracketLabel ($tabCategoryQuestions)
* key of $tabCategoryQuestions are the category id (0 for not in a category)
@ -863,22 +820,6 @@ class TestCategory
return '';
}
/**
* @return array
*/
public static function get_all_categories()
{
$table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
$sql = "SELECT * FROM $table ORDER BY title ASC";
$res = Database::query($sql);
$array = [];
while ($row = Database::fetch_array($res, 'ASSOC')) {
$array[] = $row;
}
return $array;
}
/**
* @param Exercise $exercise
* @param int $courseId
@ -1073,25 +1014,6 @@ class TestCategory
return $return;
}
/**
* Sorts an array.
*
* @param array $array
*
* @return array
*/
public function sort_tree_array($array)
{
foreach ($array as $key => $row) {
$parent[$key] = $row['parent_id'];
}
if (count($array) > 0) {
array_multisort($parent, SORT_ASC, $array);
}
return $array;
}
/**
* Return true if a category already exists with the same name.
*

@ -22,7 +22,7 @@ use Doctrine\DBAL\Types\Type;
*/
class Exercise
{
const PAGINATION_ITEMS_PER_PAGE = 5;
const PAGINATION_ITEMS_PER_PAGE = 20;
public $iId;
public $id;
public $name;
@ -1721,9 +1721,6 @@ class Exercise
$this->save_categories_in_exercise($this->categories);
// Updates the question position
$this->update_question_positions();
return $this->iId;
}
@ -8292,7 +8289,6 @@ class Exercise
$studentCount = 0;
$sum = 0;
$bestResult = 0;
$weight = 0;
$sumResult = 0;
$result = Database::query($sql);
while ($data = Database::fetch_array($result, 'ASSOC')) {
@ -8306,13 +8302,10 @@ class Exercise
if (!isset($students[$data['exe_user_id']])) {
if ($data['exe_weighting'] != 0) {
$students[$data['exe_user_id']] = $data['exe_result'];
$studentCount++;
if ($data['exe_result'] > $bestResult) {
$bestResult = $data['exe_result'];
}
$sum += $data['exe_result'] / $data['exe_weighting'];
$sumResult += $data['exe_result'];
$weight = $data['exe_weighting'];
}
}
}
@ -8407,15 +8400,19 @@ class Exercise
// Condition for the session
$condition_session = api_get_session_condition($sessionId, true, true);
$content = '';
$column = 0;
if ($is_allowedToEdit) {
$column = 1;
}
$table = new SortableTableFromArrayConfig(
[],
1,
$column,
self::PAGINATION_ITEMS_PER_PAGE,
'exercises_cat_'.$categoryId
);
$limit = self::PAGINATION_ITEMS_PER_PAGE;
$limit = $table->per_page;
$page = $table->page_nr;
$from = $limit * ($page - 1);
@ -8469,7 +8466,7 @@ class Exercise
active = 1
$condition_session
$categoryCondition
$keywordCondition
$keywordCondition
ORDER BY title
LIMIT $from , $limit";
}
@ -9132,7 +9129,7 @@ class Exercise
}
$currentRow = [
$row['iid'],
$row['id'],
$currentRow['title'],
$currentRow['count_questions'],
$actions,
@ -9176,7 +9173,7 @@ class Exercise
$result = Database::query($sql);
$attributes = [];
while ($row = Database :: fetch_array($result, 'ASSOC')) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$attributes[$row['iid']] = $row;
}
@ -9336,9 +9333,7 @@ class Exercise
if (empty($tableRows)) {
return '';
}
$table->setTableData($tableRows);
$table->setTotalNumberOfItems($total);
$table->set_additional_parameters([
'cidReq' => api_get_course_id(),

@ -210,8 +210,16 @@ if ($action != 'export') {
var oHidn = document.createElement("input");
oHidn.type = "hidden";
var selname = oHidn.name = "marks_" + m_id[i];
var selid = document.forms['marksform_' + m_id[i]].marks.selectedIndex;
oHidn.value = document.forms['marksform_' + m_id[i]].marks.options[selid].value;
var elMarks = document.forms['marksform_' + m_id[i]].marks;
if (elMarks.tagName.toLowerCase() === 'select') {
var selid = elMarks.selectedIndex;
oHidn.value = elMarks.options[selid].value;
} else if (elMarks.tagName.toLowerCase() === 'input') {
oHidn.value = elMarks.value;
}
f.appendChild(oHidn);
}
@ -620,14 +628,16 @@ foreach ($questionList as $questionId) {
$renderer->setFormTemplate('<form{attributes}><div>{content}</div></form>');
$renderer->setCustomElementTemplate('<div>{element}</div>');
$comnt = Event::get_comments($id, $questionId);
$default = ['comments_'.$questionId => $comnt];
$textareaId = 'comments_'.$questionId;
$default = [$textareaId => $comnt];
if ($useAdvancedEditor) {
$feedback_form->addElement(
'html_editor',
'comments_'.$questionId,
null,
$textareaId,
null,
['id' => $textareaId],
[
'ToolbarSet' => 'TestAnswerFeedback',
'Width' => '100%',
@ -635,7 +645,7 @@ foreach ($questionList as $questionId) {
]
);
} else {
$feedback_form->addElement('textarea', 'comments_'.$questionId);
$feedback_form->addElement('textarea', $textareaId, ['id' => $textareaId]);
}
$feedback_form->setDefaults($default);
$feedback_form->display();
@ -665,29 +675,60 @@ foreach ($questionList as $questionId) {
echo '<div id="'.$marksname.'" class="hidden">';
$allowDecimalScore = api_get_configuration_value('quiz_open_question_decimal_score');
$formMark = new FormValidator('marksform_'.$questionId, 'post');
$formMark->addHeader(get_lang('AssignMarks'));
$select = $formMark->addSelect('marks', get_lang('AssignMarks'), [], ['disable_js' => true]);
$model = ExerciseLib::getCourseScoreModel();
if (empty($model)) {
for ($i = 0; $i <= $questionWeighting; $i++) {
$attributes = [];
if ($questionScore == $i) {
$attributes['selected'] = 'selected';
}
$select->addOption($i, $i, $attributes);
}
if ($allowDecimalScore && empty($model)) {
$formMark->addElement(
'number',
'marks',
get_lang('AssignMarks'),
[
'step' => 0.01,
'min' => 0,
'max' => $questionWeighting,
'placeholder' => 0,
'class' => 'grade_select',
'id' => "select_marks_$questionId",
]
);
$formMark->setDefaults(['marks' => $questionScore]);
$formMark->applyFilter('marks', 'stripslashes');
$formMark->applyFilter('marks', 'trim');
$formMark->applyFilter('marks', 'floatval');
$formMark->addRule('marks', get_lang('Numeric'), 'numeric');
$formMark->addRule('marks', get_lang('ValueTooSmall'), 'min_numeric_length', 0);
$formMark->addRule('marks', get_lang('ValueTooBig'), 'max_numeric_length', $questionWeighting);
} else {
foreach ($model['score_list'] as $item) {
$i = api_number_format($item['score_to_qualify'] / 100 * $questionWeighting, 2);
$model = ExerciseLib::getModelStyle($item, $i);
$attributes = ['class' => $item['css_class']];
if ($questionScore == $i) {
$attributes['selected'] = 'selected';
$select = $formMark->addSelect(
'marks',
get_lang('AssignMarks'),
[],
['disable_js' => true, 'extra_class' => 'grade_select']
);
if (empty($model)) {
for ($i = 0; $i <= $questionWeighting; $i++) {
$attributes = [];
if ($questionScore == $i) {
$attributes['selected'] = 'selected';
}
$select->addOption($i, $i, $attributes);
}
} else {
foreach ($model['score_list'] as $item) {
$i = api_number_format($item['score_to_qualify'] / 100 * $questionWeighting, 2);
$model = ExerciseLib::getModelStyle($item, $i);
$attributes = ['class' => $item['css_class']];
if ($questionScore == $i) {
$attributes['selected'] = 'selected';
}
$select->addOption($model, $i, $attributes);
}
$select->addOption($model, $i, $attributes);
$select->updateSelectWithSelectedOption($formMark);
}
$select->updateSelectWithSelectedOption($formMark);
}
$formMark->display();

@ -1123,7 +1123,7 @@ if (!empty($error)) {
$(".block_on_enter").keypress(function(event) {
return event.keyCode != 13;
});
$(".checkCalculatedQuestionOnEnter").keypress(function(event) {
if (event.keyCode === 13) {
event.preventDefault();
@ -1480,7 +1480,7 @@ if (!empty($error)) {
) {
$showQuestion = false;
}
// Shows the question and its answers
// Shows the question and its answers
if ($showQuestion) {
ExerciseLib::showQuestion(

@ -1051,45 +1051,6 @@ class FillBlanks extends Question
}
}
/**
* return $text protected for use in regexp.
*
* @param string $text
*
* @return string
*/
public static function getRegexpProtected($text)
{
$listRegexpCharacters = [
"/",
".",
"+",
"*",
"?",
"[",
"^",
"]",
"$",
"(",
")",
"{",
"}",
"=",
"!",
">",
"|",
":",
"-",
")",
];
$result = $text;
for ($i = 0; $i < count($listRegexpCharacters); $i++) {
$result = str_replace($listRegexpCharacters[$i], "\\".$listRegexpCharacters[$i], $result);
}
return $result;
}
/**
* This function must be the same than the js one getSeparatorFromNumber above.
*
@ -1153,29 +1114,6 @@ class FillBlanks extends Question
return $listResults;
}
/**
* return the code number of the separator for the question.
*
* @param string $startSeparator
* @param string $endSeparator
*
* @return int
*/
public function getDefaultSeparatorNumber($startSeparator, $endSeparator)
{
$listSeparators = self::getAllowedSeparator();
$result = 0;
for ($i = 0; $i < count($listSeparators); $i++) {
if ($listSeparators[$i][0] == $startSeparator &&
$listSeparators[$i][1] == $endSeparator
) {
$result = $i;
}
}
return $result;
}
/**
* return the HTML display of the answer.
*

@ -929,7 +929,7 @@ function store_forum($values, $courseInfo = [], $returnId = false)
$sql = "UPDATE $table_forums SET forum_id = iid WHERE iid = $forumId";
Database::query($sql);
$courseCode = $courseInfo['code'];
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications', $courseCode);
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications');
$status = STUDENT;
if (!empty($session_id)) {

@ -87,7 +87,7 @@ if (!empty($groupId)) {
api_not_allowed(true);
}
} else {
//Course
// Course
if (!api_is_allowed_to_edit(false, true) && (
($current_forum_category && $current_forum_category['visibility'] == 0) ||
$current_forum['visibility'] == 0

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* List all certificates filtered by session/course and month/year.
*

@ -13,6 +13,12 @@ if (!api_is_student_boss()) {
api_protect_course_script(true);
}
api_block_anonymous_users();
if (!api_is_allowed_to_edit() && !api_is_student_boss()) {
api_not_allowed(true);
}
api_set_more_memory_and_time_limits();
//extra javascript functions for in html head:
@ -26,12 +32,6 @@ function confirmation() {
}
</script>";
api_block_anonymous_users();
if (!api_is_allowed_to_edit() && !api_is_student_boss()) {
api_not_allowed(true);
}
$categoryId = isset($_GET['cat_id']) ? (int) $_GET['cat_id'] : 0;
$action = isset($_GET['action']) && $_GET['action'] ? $_GET['action'] : null;
$filterOfficialCode = isset($_POST['filter']) ? Security::remove_XSS($_POST['filter']) : null;
@ -81,7 +81,7 @@ $content = '';
$courseCode = api_get_course_id();
$allowExportToZip = api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true' &&
api_get_course_setting('customcertificate_course_enable', $courseCode) == 1;
api_get_course_setting('customcertificate_course_enable', $courseInfo) == 1;
$tags = Certificate::notificationTags();

@ -121,17 +121,14 @@ switch ($action) {
if (!empty($htmlList)) {
$counter = 0;
//error_log('Loading html list');
$content = '';
foreach ($htmlList as $value) {
$content .= $value.'<pagebreak>';
//error_log('Loading html: '.$counter);
$counter++;
}
$tempFile = api_get_path(SYS_ARCHIVE_PATH).uniqid('gradebook_export_all').'.html';
file_put_contents($tempFile, $content);
//error_log('generating pdf');
$pdf->html_to_pdf(
$tempFile,
null,
@ -140,14 +137,12 @@ switch ($action) {
true,
true
);
//error_log('End generating');
}
// Delete calc_score session data
Session::erase('calc_score');
break;
case 'download':
//Session::write('use_gradebook_cache', true);
$userId = isset($_GET['user_id']) && $_GET['user_id'] ? $_GET['user_id'] : null;
$cats = Category::load($cat_id, null, null, null, null, null, false);
GradebookUtils::generateTable($courseInfo, $userId, $cats);

@ -298,4 +298,4 @@ if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'false') {
echo '</div>';
}
Display :: display_footer();
Display::display_footer();

@ -448,7 +448,6 @@ class GradebookUtils
$is_locked = $link->is_locked();
$modify_icons = null;
if (!api_is_allowed_to_edit(null, true)) {
return null;
}
@ -566,30 +565,6 @@ class GradebookUtils
return $row;
}
/**
* Remove a resource from the unique gradebook of a given course.
*
* @param int Link/Resource ID
*
* @return bool false on error, true on success
*/
public static function get_resource_from_course_gradebook($link_id)
{
if (empty($link_id)) {
return false;
}
// TODO find the corresponding category (the first one for this course, ordered by ID)
$l = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
$sql = "SELECT * FROM $l WHERE id = ".(int) $link_id;
$res = Database::query($sql);
$row = [];
if (Database::num_rows($res) > 0) {
$row = Database::fetch_array($res, 'ASSOC');
}
return $row;
}
/**
* Return the course id.
*
@ -1440,7 +1415,7 @@ class GradebookUtils
foreach ($courses as $course) {
if (!$includeNonPublicCertificates) {
$allowPublicCertificates = api_get_course_setting('allow_public_certificates', $course['code']);
$allowPublicCertificates = api_get_course_setting('allow_public_certificates', $course);
if (empty($allowPublicCertificates)) {
continue;
@ -1512,7 +1487,7 @@ class GradebookUtils
foreach ($sessionCourses as $course) {
if (!$includeNonPublicCertificates) {
$allowPublicCertificates = api_get_course_setting('allow_public_certificates', $course['code']);
$allowPublicCertificates = api_get_course_setting('allow_public_certificates');
if (empty($allowPublicCertificates)) {
continue;
@ -1665,7 +1640,6 @@ class GradebookUtils
$graph.
'<br />'.get_lang('Feedback').'<br />
<textarea class="form-control" rows="5" cols="100">&nbsp;</textarea>';
$result = $pdf->html_to_pdf_with_template(
$content,
$saveToFile,

@ -978,10 +978,8 @@ class Category implements GradebookItem
$linkres = $link->calc_score($stud_id, null);
if (!empty($linkres) && $link->get_weight() != 0) {
$students[$stud_id] = $linkres[0];
$linkweight = $link->get_weight();
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1];
$count++;
$weightsum += $linkweight;
$ressum += $linkres[0] / $link_res_denom * $linkweight;
} else {
@ -1009,10 +1007,10 @@ class Category implements GradebookItem
}
// Calculate score
$count = 0;
$ressum = 0;
$weightsum = 0;
$bestResult = 0;
$totalScorePerStudent = [];
if (!empty($cats)) {
/** @var Category $cat */
@ -1042,57 +1040,91 @@ class Category implements GradebookItem
}
if (!empty($evals)) {
/** @var Evaluation $eval */
foreach ($evals as $eval) {
$evalres = $eval->calc_score(null, $type);
$eval->setStudentList($this->getStudentList());
if (isset($evalres) && $eval->get_weight() != 0) {
$evalweight = $eval->get_weight();
$weightsum += $evalweight;
$count++;
if (!empty($evalres[1])) {
$ressum += $evalres[0] / $evalres[1] * $evalweight;
if ($type === 'best') {
$studentList = $this->getStudentList();
foreach ($studentList as $student) {
$studentId = $student['user_id'];
foreach ($evals as $eval) {
$linkres = $eval->calc_score($studentId, null);
$linkweight = $eval->get_weight();
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1];
$ressum = $linkres[0] / $link_res_denom * $linkweight;
if (!isset($totalScorePerStudent[$studentId])) {
$totalScorePerStudent[$studentId] = 0;
}
$totalScorePerStudent[$studentId] += $ressum;
}
}
} else {
/** @var Evaluation $eval */
foreach ($evals as $eval) {
$evalres = $eval->calc_score(null, $type);
$eval->setStudentList($this->getStudentList());
if ($ressum > $bestResult) {
$bestResult = $ressum;
}
} else {
if ($eval->get_weight() != 0) {
if (isset($evalres) && $eval->get_weight() != 0) {
$evalweight = $eval->get_weight();
$weightsum += $evalweight;
if (!empty($evalres[1])) {
$ressum += $evalres[0] / $evalres[1] * $evalweight;
}
if ($ressum > $bestResult) {
$bestResult = $ressum;
}
} else {
if ($eval->get_weight() != 0) {
$evalweight = $eval->get_weight();
$weightsum += $evalweight;
}
}
}
}
}
if (!empty($links)) {
/** @var EvalLink|ExerciseLink $link */
foreach ($links as $link) {
$link->setStudentList($this->getStudentList());
$studentList = $this->getStudentList();
if ($type === 'best') {
foreach ($studentList as $student) {
$studentId = $student['user_id'];
foreach ($links as $link) {
$linkres = $link->calc_score($studentId, null);
$linkweight = $link->get_weight();
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1];
$ressum = $linkres[0] / $link_res_denom * $linkweight;
if ($session_id) {
$link->set_session_id($session_id);
if (!isset($totalScorePerStudent[$studentId])) {
$totalScorePerStudent[$studentId] = 0;
}
$totalScorePerStudent[$studentId] += $ressum;
}
}
} else {
/** @var EvalLink|ExerciseLink $link */
foreach ($links as $link) {
$link->setStudentList($this->getStudentList());
$linkres = $link->calc_score($stud_id, $type);
if (!empty($linkres) && $link->get_weight() != 0) {
$students[$stud_id] = $linkres[0];
$linkweight = $link->get_weight();
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1];
if ($session_id) {
$link->set_session_id($session_id);
}
$count++;
$weightsum += $linkweight;
$ressum += $linkres[0] / $link_res_denom * $linkweight;
$linkres = $link->calc_score($stud_id, $type);
if ($ressum > $bestResult) {
$bestResult = $ressum;
}
} else {
// Adding if result does not exists
if ($link->get_weight() != 0) {
if (!empty($linkres) && $link->get_weight() != 0) {
$linkweight = $link->get_weight();
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1];
$weightsum += $linkweight;
$ressum += $linkres[0] / $link_res_denom * $linkweight;
if ($ressum > $bestResult) {
$bestResult = $ressum;
}
} else {
// Adding if result does not exists
if ($link->get_weight() != 0) {
$linkweight = $link->get_weight();
$weightsum += $linkweight;
}
}
}
}
@ -1101,6 +1133,10 @@ class Category implements GradebookItem
switch ($type) {
case 'best':
arsort($totalScorePerStudent);
$maxScore = current($totalScorePerStudent);
return [$maxScore, $this->get_weight()];
if (empty($bestResult)) {
if ($cacheAvailable) {
$cacheDriver->save($key, null);
@ -2123,7 +2159,10 @@ class Category implements GradebookItem
$sessionId
);
$userHasSkills = !empty($userSkills);
}
// Block certification links depending gradebook configuration (generate certifications)
if (empty($category->getGenerateCertificates())) {
if ($userHasSkills) {
return [
'badge_link' => Display::toolbarButton(
@ -2133,10 +2172,7 @@ class Category implements GradebookItem
),
];
}
}
// Block certification links depending gradebook configuration (generate certifications)
if (empty($category->getGenerateCertificates())) {
return false;
}
@ -2217,14 +2253,14 @@ class Category implements GradebookItem
'pdf_link' => $exportToPDF,
'pdf_url' => "$url&action=export",
];
}
if ($skillToolEnabled && $userHasSkills) {
$html['badge_link'] = Display::toolbarButton(
get_lang('ExportBadges'),
api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id",
'external-link'
);
}
if ($skillToolEnabled && $userHasSkills) {
$html['badge_link'] = Display::toolbarButton(
get_lang('ExportBadges'),
api_get_path(WEB_CODE_PATH)."gradebook/get_badges.php?user=$user_id",
'external-link'
);
}
return $html;

@ -204,10 +204,6 @@ class ExerciseLink extends AbstractLink
break;
case 'ranking':
return [null, null];
/*
$newList = [];
$ranking = AbstractLink::getCurrentUserRanking($stud_id, $link->getUserScoreList());
return $ranking;*/
break;
default:
if (!empty($stud_id)) {

@ -487,7 +487,7 @@ class DisplayGradebook
Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') == 'true' &&
api_get_course_setting('customcertificate_course_enable', $courseCode) == 1
api_get_course_setting('customcertificate_course_enable') == 1
) {
$actionsRight .= '<a href="'.api_get_path(
WEB_PLUGIN_PATH

@ -457,7 +457,6 @@ class GradebookTable extends SortableTable
}
$category_weight = $item->get_weight();
$mainCategoryWeight = $main_cat[0]->get_weight();
if ($this->teacherView) {
$weight_total_links += $data[3];
@ -472,12 +471,10 @@ class GradebookTable extends SortableTable
}
} else {
$score = $item->calc_score($this->userId);
$scoreToDisplay = '-';
if (!empty($score[1])) {
$completeScore = $scoredisplay->display_score($score, SCORE_DIV_PERCENT);
$score = $score[0] / $score[1] * $item->get_weight();
$score = $scoredisplay->display_score([$score, null], SCORE_SIMPLE);
$scoreToDisplay = Display::tip($score, $completeScore);
} else {
$categoryScore = null;
}
@ -493,9 +490,6 @@ class GradebookTable extends SortableTable
$data['result_score'][1],
];
$totalUserResult[0] += $totalResult[0] / ($totalResult[1] ?: 1) * $data[3];
$totalUserResult[1] += $data[3];
if (empty($model)) {
$totalBest = [
$scoredisplay->format_score($totalBest[0] + $data['best_score'][0]),
@ -521,7 +515,6 @@ class GradebookTable extends SortableTable
$mode = SCORE_AVERAGE;
if ($userExerciseScoreInCategory) {
$mode = SCORE_SIMPLE;
$result = ExerciseLib::convertScoreToPlatformSetting($totalAverage[0], $totalAverage[1]);
$totalAverage[0] = $result['score'];
$totalAverage[1] = $result['weight'];
@ -817,8 +810,8 @@ class GradebookTable extends SortableTable
$score = $main_cat[0]->calc_score(
$student['user_id'],
null,
api_get_course_id(),
api_get_session_id()
$course_code,
$session_id
);
if (!empty($score[0])) {
$invalidateRanking = false;
@ -919,7 +912,7 @@ class GradebookTable extends SortableTable
$content_html = DocumentManager::replace_user_info_into_html(
api_get_user_id(),
api_get_course_info(),
$course_code,
api_get_session_id()
);

@ -137,22 +137,6 @@ class FlatViewDataGenerator
$mainCategoryId = $mainCourseCategory->get_id();
}
if (isset($this->category) && !empty($this->category)) {
$categories = Category::load(
null,
null,
null,
$this->category->get_id()
);
if (!empty($categories)) {
foreach ($categories as $category) {
$sum_categories_weight_array[$category->get_id()] = $category->get_weight();
}
} else {
$sum_categories_weight_array[$this->category->get_id()] = $this->category->get_weight();
}
}
// No category was added
$course_code = api_get_course_id();
$session_id = api_get_session_id();
@ -567,8 +551,6 @@ class FlatViewDataGenerator
$show_all,
$row
);
$item_total += $result['item_total'];
$item_value_total += $result['item_value_total'];
$evaluationsAdded = $result['evaluations_added'];
$item_total = $main_weight;
@ -589,7 +571,6 @@ class FlatViewDataGenerator
$item_total += $result['item_total'];
$item_value_total += $result['item_value_total'];
$total_score = [$item_value_total, $item_total];
$style = api_get_configuration_value('gradebook_report_score_style');
if (!$show_all) {
@ -651,7 +632,6 @@ class FlatViewDataGenerator
$item_total = 0;
$item_value_total = 0;
$evaluationsAdded = [];
$model = ExerciseLib::getCourseScoreModel();
for ($count = 0; $count < $items_count && ($items_start + $count < count($this->evals_links)); $count++) {
/** @var AbstractLink $item */
@ -692,7 +672,6 @@ class FlatViewDataGenerator
} else {
$item_value = $score[0] / $divide * $item->get_weight();
}
$item_total += $item->get_weight();
$style = api_get_configuration_value('gradebook_report_score_style');
@ -728,7 +707,6 @@ class FlatViewDataGenerator
);
$temp_score = Display::tip($temp_score, $complete_score);
}
if (!empty($model)) {
$scoreToShow = '';
if (isset($score[0]) && isset($score[1])) {

@ -65,7 +65,7 @@ switch ($action) {
if (api_get_setting('homepage_view') != 'activity_big') {
$toolImage = Display::return_icon(
'tool_'.$toolImage,
$toolImage,
null,
null,
null,
@ -77,7 +77,7 @@ switch ($action) {
// Display::return_icon() also checks in the app/Resources/public/css/themes/{theme}/icons folder
$toolImage = (substr($toolImage, 0, strpos($toolImage, '.'))).'.png';
$toolImage = Display::return_icon(
'tool_'.$toolImage,
$toolImage,
get_lang(ucfirst($tool->getName())),
null,
ICON_SIZE_BIG,
@ -204,7 +204,8 @@ switch ($action) {
$count = 0;
$temp = [];
foreach ($course_list as $item) {
$list = new LearnpathList(api_get_user_id(), $item['code'], $session_id);
$courseInfo = api_get_course_info($item['code']);
$list = new LearnpathList(api_get_user_id(), $courseInfo, $session_id);
$flat_list = $list->get_flat_list();
$lps[$item['code']] = $flat_list;
$course_url = api_get_path(WEB_COURSE_PATH).$item['directory'].'/?id_session='.$session_id;
@ -342,7 +343,7 @@ switch ($action) {
$list = new LearnpathList(
api_get_user_id(),
$item['code'],
api_get_course_info($item['code']),
$session_id,
'lp.publicatedOn DESC'
);
@ -485,7 +486,7 @@ switch ($action) {
$list = new LearnpathList(
api_get_user_id(),
$item['code'],
api_get_course_info($item['code']),
$session_id
);
$flat_list = $list->get_flat_list();

@ -1,10 +1,12 @@
<?php
/* For licensing terms, see /license.txt */
use GuzzleHttp\Client;
/**
* Responses to AJAX calls for install.
*/
//require_once '../global.inc.php';
require_once __DIR__.'/../../../vendor/autoload.php';
$action = $_GET['a'];
@ -32,31 +34,49 @@ switch ($action) {
}
}
// Return error if any of the required fields is empty
if ($required_field_error) {
echo 'required_field_error';
break;
} else {
// save contact information with web service
// create a client
$client = new SoapClient('https://version.chamilo.org/contact.php?wsdl');
// call method ws_add_contact_information
$contact_params = [
'person_name' => $person_name,
'person_email' => $person_email,
'person_role' => $person_role,
'financial_decision' => $financial_decision,
'contact_language' => $contact_language,
'company_name' => $company_name,
'company_activity' => $company_activity,
'company_country' => $company_country,
'company_city' => $company_city,
];
$url = 'https://version.chamilo.org/contactv2.php';
$options = [
'verify' => false,
];
$urlValidated = false;
try {
$client = new GuzzleHttp\Client();
$res = $client->request('GET', $url, $options);
if ($res->getStatusCode() == '200' || $res->getStatusCode() == '301') {
$urlValidated = true;
}
} catch (Exception $e) {
error_log("Could not check $url from ".__FILE__);
break;
}
$result = $client->__soapCall(
'ws_add_contact_information',
['contact_params' => $contact_params]
);
echo $result;
$data = [
'person_name' => $person_name,
'person_email' => $person_email,
'person_role' => $person_role,
'financial_decision' => $financial_decision,
'contact_language' => $contact_language,
'company_name' => $company_name,
'company_activity' => $company_activity,
'company_country' => $company_country,
'company_city' => $company_city,
];
$client = new GuzzleHttp\Client();
$options['query'] = $data;
$res = $client->request('GET', $url, $options);
if ($res->getStatusCode() == '200') {
echo '1';
}
}
}
break;

@ -62,8 +62,6 @@ switch ($action) {
case 'get_count_message':
$userId = api_get_user_id();
$invitations = [];
$group_pending_invitations = 0;
// Setting notifications
$count_unread_message = 0;
if (api_get_setting('allow_message_tool') === 'true') {

@ -275,7 +275,7 @@ switch ($action) {
break;
case 'get_usergroups_users':
$usergroup = new UserGroup();
$usergroup->protectScript();
$usergroup->protectScript(null, true, true);
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
$count = $usergroup->getUserGroupUsers($id, true);
break;
@ -798,7 +798,7 @@ switch ($action) {
break;
case 'get_usergroups_teacher':
$obj = new UserGroup();
$obj->protectScript();
$obj->protectScript(null, false, true);
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'registered';
$groupFilter = isset($_REQUEST['group_filter']) ? (int) $_REQUEST['group_filter'] : 0;
$keyword = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : '';
@ -829,7 +829,7 @@ switch ($action) {
exit;
}
//3. Calculating first, end, etc
// 3. Calculating first, end, etc
$total_pages = 0;
if ($count > 0) {
if (!empty($limit)) {
@ -2205,12 +2205,20 @@ switch ($action) {
foreach ($result as $group) {
$countUsers = count($obj->get_users_by_usergroup($group['id']));
$group['users'] = $countUsers;
if ($obj->allowTeachers()) {
$group['users'] = Display::url(
$countUsers,
$urlUserGroup.'&id='.$group['id']
);
if (!empty($countUsers)) {
if ($obj->allowTeachers()) {
if (isset($group['author_id']) && $group['author_id'] == $currentUserId) {
$group['users'] = Display::url(
$countUsers,
$urlUserGroup.'&id='.$group['id']
);
}
} else {
$group['users'] = Display::url(
$countUsers,
$urlUserGroup.'&id='.$group['id']
);
}
}
if ($obj->usergroup_was_added_in_course($group['id'], $course_id)) {

@ -1034,17 +1034,17 @@ class AnnouncementManager
$sql = "SELECT DISTINCT
announcement.c_id,
count(announcement.id) count
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property ip
ON (announcement.id = ip.ref AND announcement.c_id = ip.c_id)
WHERE
ip.tool='announcement' AND
(
FROM $tbl_announcement announcement
INNER JOIN $tbl_item_property ip
ON (announcement.id = ip.ref AND announcement.c_id = ip.c_id)
WHERE
ip.tool='announcement' AND
(
ip.to_user_id = '$user_id' AND
(ip.to_group_id='0' OR ip.to_group_id IS NULL)
)
AND ip.visibility='1'
AND announcement.session_id = 0
(ip.to_group_id='0' OR ip.to_group_id IS NULL)
)
AND ip.visibility='1'
AND announcement.session_id = 0
GROUP BY announcement.c_id";
$rs = Database::query($sql);
$num_rows = Database::num_rows($rs);

@ -482,7 +482,7 @@ class Compilatio
*/
public static function plagiarismDeleteDoc($courseId, $itemId)
{
if (api_get_configuration_value('allow_compilatio_tool')) {
if (api_get_configuration_value('allow_compilatio_tool') === false) {
return false;
}

@ -580,13 +580,14 @@ class CoursesAndSessionsCatalog
s.nbrCourses > 0
";
//('$date' BETWEEN s.accessStartDate AND s.accessEndDate)
if (!is_null($date)) {
$date = Database::escape_string($date);
$dql .= "
AND (
(s.accessEndDate IS NULL)
OR
(
(
s.accessStartDate IS NOT NULL AND
s.accessEndDate IS NOT NULL AND
s.accessStartDate >= '$date' AND s.accessEndDate <= '$date')

@ -2490,12 +2490,16 @@ class Agenda
$form->addElement('textarea', 'comment', get_lang('Comment'));
$form->addLabel(
get_lang('FilesAttachment'),
'<span id="filepaths">
'<div id="filepaths" class="file-upload-event">
<div id="filepath_1">
<input type="file" name="attach_1"/><br />
'.get_lang('Description').'&nbsp;&nbsp;<input type="text" name="legend[]" /><br /><br />
<input type="file" name="attach_1"/>
<label>'.get_lang('Description').'</label>
<input class="form-control" type="text" name="legend[]" />
</div>
</span>'
</div>'
);
$form->addLabel(
@ -3041,7 +3045,7 @@ class Agenda
}
$form->addHidden('type', 'personal');
$sessions = ['0' => get_lang('Select An Option')] + $sessions;
$sessions = ['0' => get_lang('SelectAnOption')] + $sessions;
$form->addSelect(
'session_id',

@ -43,20 +43,30 @@ class Attendance
*
* @see SortableTable#get_total_number_of_items()
*/
public static function getNumberOfAttendances($active = -1)
public static function getNumberOfAttendances()
{
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$course_id = api_get_course_int_id();
$active_plus = '';
if ((isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') ||
!api_is_allowed_to_edit(null, true)
) {
$active_plus = ' AND att.active = 1';
}
$sql = "SELECT COUNT(att.id) AS total_number_of_items
FROM $tbl_attendance att
WHERE c_id = $course_id $condition_session ";
$active = (int) $active;
WHERE
c_id = $course_id AND
active <> 2 $active_plus $condition_session ";
/*$active = (int) $active;
if ($active === 1 || $active === 0) {
$sql .= "AND att.active = $active";
}
}*/
$res = Database::query($sql);
$obj = Database::fetch_object($res);

@ -96,6 +96,7 @@ class Auth
$visibilityCondition = CourseManager::getCourseVisibilitySQLCondition('course', true);
$sql = "SELECT
course.id as real_id,
course.code, course.visual_code, course.subscribe subscr, course.unsubscribe unsubscr,
course.title title, course.tutor_name tutor, course.directory, course_rel_user.status status,
course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat
@ -128,8 +129,8 @@ class Auth
*/
public function updateCourseCategory($courseId, $newcategory)
{
$courseId = intval($courseId);
$newcategory = intval($newcategory);
$courseId = (int) $courseId;
$newcategory = (int) $newcategory;
$current_user = api_get_user_id();
$table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
@ -289,7 +290,7 @@ class Auth
{
// protect data
$title = Database::escape_string($title);
$category_id = intval($category_id);
$category_id = (int) $category_id;
$result = false;
$table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "UPDATE $table
@ -315,7 +316,7 @@ class Auth
$current_user_id = api_get_user_id();
$tucc = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$category_id = intval($category_id);
$category_id = (int) $category_id;
$result = false;
$sql = "DELETE FROM $tucc
WHERE
@ -336,6 +337,27 @@ class Auth
return $result;
}
/**
* @param int $categoryId
*
* @return array|mixed
*/
public function getUserCourseCategory($categoryId)
{
$userId = api_get_user_id();
$tucc = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$categoryId = (int) $categoryId;
$sql = "SELECT * FROM $tucc
WHERE
id= $categoryId AND
user_id= $userId";
$resultQuery = Database::query($sql);
$result = Database::fetch_array($resultQuery, 'ASSOC');
return $result;
}
/**
* unsubscribe the user from a given course.
*

@ -534,7 +534,6 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
$i = 0;
$final_navigation_count = count($final_navigation);
if (!empty($final_navigation)) {
// $home_link.= '<span class="divider">/</span>';
if (!empty($home_link)) {
$lis .= Display::tag('li', $home_link);
}
@ -557,7 +556,7 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
// View as student/teacher link
if (!empty($view_as_student_link)) {
$html .= Display::tag('div', $view_as_student_link, ['id' => 'view_as_link', 'class' => 'float-right']);
$html .= Display::tag('div', $view_as_student_link, ['id' => 'view_as_link', 'class' => 'pull-right']);
}
if (!empty($navigation_right)) {
@ -566,7 +565,7 @@ function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
$lis .= Display::tag(
'li',
$item['title'],
['class' => $extra_class.' float-right']
['class' => $extra_class.' pull-right']
);
}
}

@ -612,7 +612,12 @@ class Certificate extends Model
return false;
}
if (api_get_course_setting('allow_public_certificates', $gradeBookInfo['course_code']) == 0) {
$setting = api_get_course_setting(
'allow_public_certificates',
api_get_course_info($gradeBookInfo['course_code'])
);
if ($setting == 0) {
// Printing not allowed
return false;
}

@ -769,7 +769,7 @@ class CourseManager
)
);
$send = api_get_course_setting('email_alert_to_teacher_on_new_user_in_course', $courseCode);
$send = api_get_course_setting('email_alert_to_teacher_on_new_user_in_course', $courseInfo);
if ($send == 1) {
self::email_to_tutor(
@ -785,7 +785,7 @@ class CourseManager
);
}
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications', $courseCode);
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications', $courseInfo);
if ($subscribe === 1) {
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$forums = get_forums(0, $courseCode, true, $sessionId);
@ -3698,7 +3698,7 @@ class CourseManager
$collapsableLink = '';
if ($collapsable) {
$url = api_get_path(WEB_CODE_PATH).
'auth/courses.php?categoryid='.$row['id'].'&sec_token='.$stok.'&redirect=home';
'auth/sort_my_courses.php?categoryid='.$row['id'].'&sec_token='.$stok.'&redirect=home';
$collapsed = isset($row['collapsed']) && $row['collapsed'] ? 1 : 0;
if ($collapsed === 0) {
$collapsableLink = Display::url(
@ -3926,8 +3926,6 @@ class CourseManager
$params['title_cut'] = $params['title'];
$params['category'] = $course_info['categoryName'];
$params['category_code'] = $course_info['categoryCode'];
//$params['category_id'] = $course_info['categoryId'];
//$params['color'] = Display::randomColor($params['category_id']);
$params['teachers'] = $teachers;
$params['real_id'] = $course_info['real_id'];
@ -4081,7 +4079,7 @@ class CourseManager
$session_url = '';
$params = [];
$params['icon'] = Display::return_icon(
'blackboard_blue.png',
'session.png',
null,
[],
ICON_SIZE_LARGE,
@ -4153,6 +4151,12 @@ class CourseManager
}
$params['thumbnails'] = $thumbnails;
$params['image'] = $image;
$params['html_image'] = '';
if (!empty($thumbnails)) {
$params['html_image'] = Display::img($thumbnails, $course_info['name'], ['class' => 'img-responsive']);
} else {
$params['html_image'] = Display::return_icon('session.png', $course_info['name'], ['class' => 'img-responsive'], ICON_SIZE_LARGE, $course_info['name']);
}
$params['link'] = $session_url;
$params['title'] = $session_title;
$params['name'] = $course_info['name'];
@ -4168,7 +4172,7 @@ class CourseManager
if ($load_dirs) {
$params['document'] .= '<a
id="document_preview_'.$course_info['real_id'].'_'.$course_info['id_session'].'"
class="document_preview btn btn-outline-secondary btn-sm"
class="document_preview btn btn-default btn-sm"
href="javascript:void(0);">'.
Display::returnFontAwesomeIcon('folder-open').'</a>';
$params['document'] .= Display::div('', [

@ -16,7 +16,7 @@ class CourseCategory
public static function getCategoryById($categoryId)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$categoryId = intval($categoryId);
$categoryId = (int) $categoryId;
$sql = "SELECT * FROM $table WHERE id = $categoryId";
$result = Database::query($sql);
if (Database::num_rows($result)) {
@ -29,7 +29,7 @@ class CourseCategory
/**
* Get category details from a simple category code.
*
* @param string $category The literal category code
* @param string $categoryCode The literal category code
*
* @return array
*/
@ -41,16 +41,18 @@ class CourseCategory
$result = Database::query($sql);
if (Database::num_rows($result)) {
$category = Database::fetch_array($result, 'ASSOC');
// Get access url id
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
$sql = "SELECT * FROM $table WHERE course_category_id = ".$category['id'];
$result = Database::query($sql);
$result = Database::fetch_array($result);
if ($result) {
$category['access_url_id'] = $result['access_url_id'];
}
if ($category) {
// Get access url id
$table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE_CATEGORY);
$sql = "SELECT * FROM $table WHERE course_category_id = ".$category['id'];
$result = Database::query($sql);
$result = Database::fetch_array($result);
if ($result) {
$category['access_url_id'] = $result['access_url_id'];
}
return $category;
return $category;
}
}
return [];
@ -197,11 +199,17 @@ class CourseCategory
];
$categoryId = Database::insert($table, $params);
if ($categoryId) {
self::updateParentCategoryChildrenCount($parent_id, 1);
UrlManager::addCourseCategoryListToUrl(
[$categoryId],
[api_get_current_access_url_id()]
);
self::updateParentCategoryChildrenCount($parent_id, 1);
self::addToUrl($categoryId);
return $categoryId;
}
return $categoryId;
return false;
}
/**
@ -214,7 +222,7 @@ class CourseCategory
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$categoryId = Database::escape_string($categoryId);
$delta = intval($delta);
$delta = (int) $delta;
// First get to the highest level possible in the tree
$result = Database::query("SELECT parent_id FROM $table WHERE code = '$categoryId'");
$row = Database::fetch_array($result);
@ -223,7 +231,6 @@ class CourseCategory
self::updateParentCategoryChildrenCount($row['parent_id'], $delta);
}
// Now we're at the top, get back down to update each child
//$children_count = courseCategoryChildrenCount($categoryId);
$sql = "UPDATE $table SET children_count = (children_count - ".abs($delta).") WHERE code = '$categoryId'";
if ($delta >= 0) {
$sql = "UPDATE $table SET children_count = (children_count + $delta) WHERE code = '$categoryId'";
@ -328,7 +335,7 @@ class CourseCategory
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$tree_pos = intval($tree_pos);
$tree_pos = (int) $tree_pos;
$parent_id = Database::escape_string($parent_id);
$parentIdCondition = " AND (parent_id IS NULL OR parent_id = '' )";
@ -382,7 +389,7 @@ class CourseCategory
public static function courseCategoryChildrenCount($categoryId)
{
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$categoryId = intval($categoryId);
$categoryId = (int) $categoryId;
$count = 0;
if (empty($categoryId)) {
return 0;
@ -486,7 +493,7 @@ class CourseCategory
$categorySource = Security::remove_XSS($categorySource);
if (count($categories) > 0) {
$table = new HTML_Table(['class' => 'table data_table']);
$table = new HTML_Table(['class' => 'data_table']);
$column = 0;
$row = 0;
$headers = [
@ -578,19 +585,6 @@ class CourseCategory
return Database::store_result(Database::query($sql));
}
/**
* @param int $id
*
* @return bool
*/
public static function addToUrl($id)
{
UrlManager::addCourseCategoryListToUrl(
[$id],
[api_get_current_access_url_id()]
);
}
/**
* @param string $categoryCode
*
@ -902,21 +896,14 @@ class CourseCategory
*/
public static function getCourseCatalogNameTools($action)
{
$nameTools = get_lang('SortMyCourses');
$nameTools = get_lang('MyCourses');
if (empty($action)) {
return $nameTools; //should never happen
}
switch ($action) {
case 'createcoursecategory':
$nameTools = get_lang('CreateCourseCategory');
break;
case 'subscribe':
$nameTools = get_lang('CourseManagement');
break;
case 'subscribe_user_with_password':
$nameTools = get_lang('CourseManagement');
break;
case 'display_random_courses':
case 'display_courses':
$nameTools = get_lang('CourseManagement');
@ -990,37 +977,4 @@ class CourseCategory
return true;
}
/**
* Deletes the image on disk and in the database.
*
* @param $categoryId
*
* @return bool Always returns true
*/
public static function deletePictureCategory($categoryId)
{
$dirName = 'course_category/';
$fileImage = $dirName.'cc_'.$categoryId.'.jpg';
$fileDir = api_get_path(SYS_UPLOAD_PATH).$fileImage;
if (file_exists($fileDir)) {
try {
unlink($fileDir);
} catch (Exception $e) {
error_log($e->getMessage());
}
}
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$result = Database::update(
$table,
['image' => ''],
['id = ?' => $categoryId]
);
if ($result) {
return true;
}
return false;
}
}

@ -861,7 +861,7 @@ class CourseHome
$item = [];
$studentview = false;
$tool['original_link'] = $tool['link'];
if ($tool['image'] == 'scormbuilder.gif') {
if ($tool['image'] === 'scormbuilder.gif') {
// Check if the published learnpath is visible for student
$lpId = self::getPublishedLpIdFromLink($tool['link']);
if (api_is_allowed_to_edit(null, true)) {
@ -929,9 +929,8 @@ class CourseHome
switch ($visibility) {
case '0':
$info = pathinfo($tool['image']);
$basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index"
$basename = basename($tool['image'], '.'.$info['extension']);
$tool['image'] = $basename.'_na.'.$info['extension'];
$link['name'] = Display::return_icon(
'invisible.png',
get_lang('Activate'),
@ -980,7 +979,7 @@ class CourseHome
}
}
$item['visibility'] = null;
$item['visibility'] = '';
if (isset($lnk) && is_array($lnk)) {
foreach ($lnk as $this_link) {
if (empty($tool['adminlink'])) {
@ -989,8 +988,6 @@ class CourseHome
$this_link['name'].'</a>';
}
}
} else {
$item['visibility'] .= '';
}
// NOTE : Table contains only the image file name, not full path
@ -1005,14 +1002,14 @@ class CourseHome
if ($tool['visibility'] == '0' && $toolAdmin != '1') {
$class = 'text-muted';
$info = pathinfo($tool['image']);
$basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index"
$basename = basename($tool['image'], '.'.$info['extension']);
$tool['image'] = $basename.'_na.'.$info['extension'];
}
$qm_or_amp = strpos($tool['link'], '?') === false ? '?' : '&';
// If it's a link, we don't add the cidReq
if ($tool['image'] == 'file_html.png' || $tool['image'] == 'file_html_na.png') {
if ($tool['image'] === 'file_html.png' || $tool['image'] === 'file_html_na.png') {
$tool['link'] = $tool['link'];
} else {
$tool['link'] = $tool['link'].$qm_or_amp.api_get_cidreq();
@ -1219,7 +1216,7 @@ class CourseHome
'external_na.gif',
];
$toolName = Security::remove_XSS(stripslashes($tool['name']));
$toolName = Security::remove_XSS(stripslashes(strip_tags($tool['name'])));
if (isset($tool['image']) && in_array($tool['image'], $already_translated_icons)) {
return $toolName;
@ -1819,7 +1816,7 @@ class CourseHome
}
return Display::return_icon(
'tool_'.$image,
$image,
$item['name'],
['id' => $id],
$iconSize,

@ -2388,6 +2388,33 @@ class Display
return $html;
}
/**
* @param $url
* @param $currentPage
* @param $pagesCount
* @param $totalItems
*
* @return string
*/
public static function getPagination($url, $currentPage, $pagesCount, $totalItems)
{
$pagination = '';
if ($totalItems > 1 && $pagesCount > 1) {
$pagination .= '<ul class="pagination">';
for ($i = 0; $i < $pagesCount; $i++) {
$newPage = $i + 1;
if ($currentPage == $newPage) {
$pagination .= '<li class="active"><a href="'.$url.'&page='.$newPage.'">'.$newPage.'</a></li>';
} else {
$pagination .= '<li><a href="'.$url.'&page='.$newPage.'">'.$newPage.'</a></li>';
}
}
$pagination .= '</ul>';
}
return $pagination;
}
/**
* Adds a message in the queue.
*

@ -2661,6 +2661,7 @@ JAVASCRIPT;
[
'title' => $field['display_text'],
'target' => '_blank',
'class' => 'download_extra_field',
]
);
break;

@ -1030,27 +1030,6 @@ class ExtraFieldValue extends Model
Database::query($sql);
}
/**
* Deletes values of a specific field for a specific item.
*
* @param int $item_id (session id, course id, etc)
* @param int $field_id
* @assert (-1,-1) == null
*/
public function delete_values_by_handler_and_field_id($item_id, $field_id)
{
$field_id = (int) $field_id;
$item_id = (int) $item_id;
$extraFieldType = $this->getExtraField()->getExtraFieldType();
$sql = "DELETE FROM {$this->table}
WHERE
item_id = '$item_id' AND
field_id = '$field_id'
";
Database::query($sql);
}
/**
* Deletes all values from an item.
*
@ -1108,20 +1087,6 @@ class ExtraFieldValue extends Model
return false;
}
/**
* Not yet implemented - Compares the field values of two items.
*
* @param int $item_id Item 1
* @param int $item_to_compare Item 2
*
* @todo
*
* @return mixed Differential array generated from the comparison
*/
public function compareItemValues($item_id, $item_to_compare)
{
}
/**
* Get all values for an item.
*

@ -1038,6 +1038,11 @@ EOT;
$attributes['cols'] = isset($config['cols']) ? $config['cols'] : 80;
$attributes['cols-size'] = isset($config['cols-size']) ? $config['cols-size'] : [];
$attributes['class'] = isset($config['class']) ? $config['class'] : [];
$attributes['id'] = isset($config['id']) ? $config['id'] : '';
if (empty($attributes['id'])) {
$attributes['id'] = $name;
}
$this->addElement('html_editor', $name, $label, $attributes, $config);
$this->applyFilter($name, 'trim');

@ -1314,127 +1314,6 @@ class Link extends Model
Display::addFlash(Display::return_message(get_lang('LinkMoved')));
}
/**
* CSV file import functions.
*
* @author René Haentjens , Ghent University
*
* @param string $catname
*
* @return int
*/
public static function get_cat($catname)
{
// Get category id (existing or make new).
$tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY);
$course_id = api_get_course_int_id();
$result = Database:: query(
"SELECT id FROM ".$tbl_categories."
WHERE c_id = $course_id AND category_title='".Database::escape_string($catname)."'"
);
if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array($result))) {
return $row['id']; // Several categories with same name: take the first.
}
$result = Database:: query(
"SELECT MAX(display_order) FROM ".$tbl_categories." WHERE c_id = $course_id "
);
list($max_order) = Database:: fetch_row($result);
$params = [
'c_id' => $course_id,
'category_title' => $catname,
'description' => '',
'display_order' => $max_order + 1,
];
$id = Database::insert($tbl_categories, $params);
return $id;
}
/**
* CSV file import functions.
*
* @author René Haentjens , Ghent University
*
* @param string $url
* @param string $title
* @param string $description
* @param string $on_homepage
* @param string $hidden
*/
public static function put_link($url, $cat, $title, $description, $on_homepage, $hidden)
{
$_course = api_get_course_info();
$_user = api_get_user_info();
$tbl_link = Database::get_course_table(TABLE_LINK);
$course_id = api_get_course_int_id();
$urleq = "url='".Database:: escape_string($url)."'";
$cateq = "category_id=".intval($cat);
$result = Database:: query(
"
SELECT id FROM $tbl_link
WHERE c_id = $course_id AND ".$urleq.' AND '.$cateq
);
if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array($result))) {
$sql = "UPDATE $tbl_link SET
title = '".Database:: escape_string($title)."',
description = '".Database:: escape_string($description)."'
WHERE c_id = $course_id AND id='".Database:: escape_string($row['id'])."'";
Database:: query($sql);
$ipu = 'LinkUpdated';
$rv = 1; // 1 = upd
} else {
// Add new link
$result = Database:: query(
"SELECT MAX(display_order) FROM $tbl_link
WHERE c_id = $course_id AND category_id='".intval($cat)."'"
);
list($max_order) = Database:: fetch_row($result);
Database:: query(
"INSERT INTO $tbl_link (c_id, url, title, description, category_id, display_order, on_homepage)
VALUES (".api_get_course_int_id().",
'".Database:: escape_string($url)."',
'".Database:: escape_string($title)."',
'".Database:: escape_string($description)."',
'".intval($cat)."','".(intval($max_order) + 1)."',
'".intval($on_homepage).
"')"
);
$id = Database:: insert_id();
$ipu = 'LinkAdded';
$rv = 2; // 2 = new
}
api_item_property_update(
$_course,
TOOL_LINK,
$id,
$ipu,
$_user['user_id']
);
if ($hidden && $ipu == 'LinkAdded') {
api_item_property_update(
$_course,
TOOL_LINK,
$id,
'invisible',
$_user['user_id']
);
}
return $rv;
}
/**
* This function checks if the url is a vimeo link.
*

@ -31,6 +31,7 @@ class AppPlugin
public $installedPluginListName = [];
public $installedPluginListObject = [];
private static $instance;
/**
* Constructor.
@ -39,6 +40,18 @@ class AppPlugin
{
}
/**
* @return AppPlugin
*/
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Read plugin from path.
*
@ -61,30 +74,13 @@ class AppPlugin
return $plugins;
}
/**
* @return array
*/
public function get_installed_plugins_by_region()
{
$plugins = [];
/* We retrieve all the active plugins. */
$result = api_get_settings('Plugins');
if (!empty($result)) {
foreach ($result as $row) {
$plugins[$row['variable']][] = $row['selected_value'];
}
}
return $plugins;
}
/**
* @return array
*/
public function getInstalledPluginListName()
{
if (empty($this->installedPluginListName)) {
$this->installedPluginListName = $this->get_installed_plugins();
$this->installedPluginListName = $this->getInstalledPlugins();
}
return $this->installedPluginListName;
@ -118,22 +114,46 @@ class AppPlugin
}
/**
* @param string $plugin
*
* @return bool
*/
public function isInstalled($plugin)
{
$list = self::getInstalledPlugins(false);
return in_array($plugin, $list);
}
/**
* @param bool $fromDatabase
*
* @return array
*/
public function get_installed_plugins()
public function getInstalledPlugins($fromDatabase = true)
{
$installedPlugins = [];
$plugins = api_get_settings_params(
[
"variable = ? AND selected_value = ? AND category = ? " => ['status', 'installed', 'Plugins'],
]
);
static $installedPlugins = null;
if (!empty($plugins)) {
foreach ($plugins as $row) {
$installedPlugins[$row['subkey']] = true;
if ($fromDatabase === false) {
if (is_array($installedPlugins)) {
return $installedPlugins;
}
}
if ($fromDatabase || $installedPlugins === null) {
$installedPlugins = [];
$plugins = api_get_settings_params(
[
'variable = ? AND selected_value = ? AND category = ? ' => ['status', 'installed', 'Plugins'],
]
);
if (!empty($plugins)) {
foreach ($plugins as $row) {
$installedPlugins[$row['subkey']] = true;
}
$installedPlugins = array_keys($installedPlugins);
}
$installedPlugins = array_keys($installedPlugins);
}
return $installedPlugins;
@ -145,10 +165,9 @@ class AppPlugin
*/
public function install($pluginName, $urlId = null)
{
$urlId = (int) $urlId;
if (empty($urlId)) {
$urlId = api_get_current_access_url_id();
} else {
$urlId = intval($urlId);
}
api_add_setting(
@ -180,10 +199,9 @@ class AppPlugin
*/
public function uninstall($pluginName, $urlId = null)
{
$urlId = (int) $urlId;
if (empty($urlId)) {
$urlId = api_get_current_access_url_id();
} else {
$urlId = intval($urlId);
}
// First call the custom uninstall to allow full access to global settings
@ -193,6 +211,7 @@ class AppPlugin
require $pluginPath;
}
// Second remove all remaining global settings
api_delete_settings_params(
['category = ? AND access_url = ? AND subkey = ? ' => ['Plugins', $urlId, $pluginName]]
@ -217,16 +236,6 @@ class AppPlugin
return $areas;
}
/**
* @param string $location
*
* @return bool
*/
public function is_valid_plugin_location($location)
{
return in_array($location, $this->plugin_list);
}
/**
* @param string $pluginName
*
@ -246,7 +255,7 @@ class AppPlugin
/**
* @return array
*/
public function getPluginRegions()
public function get_plugin_regions()
{
sort($this->plugin_regions);
@ -459,9 +468,9 @@ class AppPlugin
$plugin_info = $this->getPluginInfo($pluginName);
if (isset($plugin_info) && isset($plugin_info['templates'])) {
return $plugin_info['templates'];
} else {
return false;
}
return false;
}
/**

@ -488,7 +488,7 @@ class SessionManager
if (!api_is_platform_admin()) {
if (api_is_session_admin() &&
api_get_setting('allow_session_admins_to_manage_all_sessions') == 'false'
api_get_setting('allow_session_admins_to_manage_all_sessions') === 'false'
) {
$where .= " AND s.session_admin_id = $userId ";
}
@ -496,7 +496,7 @@ class SessionManager
if (!api_is_platform_admin() &&
api_is_teacher() &&
api_get_setting('allow_teachers_to_create_sessions') == 'true'
api_get_setting('allow_teachers_to_create_sessions') === 'true'
) {
$where .= " AND s.id_coach = $userId ";
}
@ -2299,7 +2299,7 @@ class SessionManager
$course_code = Database::escape_string($course_code);
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications', $course_code);
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications', $courseInfo);
$forums = [];
if ($subscribe === 1) {
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
@ -3299,33 +3299,6 @@ class SessionManager
}
}
/**
* Get the session image.
*
* @param int $id
*
* @return image path
*/
public static function getSessionImage($id)
{
$id = (int) $id;
$extraFieldValuesTable = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$sql = "SELECT value FROM $extraFieldValuesTable WHERE field_id = 16 AND item_id = ".$id;
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$sessionImage = $row['value'];
$sessionImage = api_get_path(WEB_UPLOAD_PATH).$sessionImage;
}
return $sessionImage;
} else {
$sessionImage = api_get_path(WEB_PUBLIC_PATH)."img/session_default.png";
return $sessionImage;
}
}
/**
* Get Hot Sessions (limit 8).
*
@ -3956,7 +3929,7 @@ class SessionManager
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
$session_id = (int) $session_id;
$sqlSelect = '*, c.id, c.id as real_id';
$sqlSelect = '*, c.id, c.id as real_id, c.code as course_code';
if ($getCount) {
$sqlSelect = 'COUNT(1) as count';
@ -4433,22 +4406,25 @@ class SessionManager
/**
* Copies a session with the same data to a new session.
* The new copy is not assigned to the same promotion. @see subscribe_sessions_to_promotions() for that.
* The new copy is not assigned to the same promotion.
*
*
* @param int Session ID
* @param bool Whether to copy the relationship with courses
* @param bool Whether to copy the relationship with users
* @param bool New courses will be created
* @param bool Whether to set exercises and learning paths in the new session to invisible by default
* @param int $id Session ID
* @param bool $copy_courses Whether to copy the relationship with courses
* @param bool $copyTeachersAndDrh
* @param bool $create_new_courses New courses will be created
* @param bool $set_exercises_lp_invisible Set exercises and LPs in the new session to invisible by default
*
* @return int The new session ID on success, 0 otherwise
*
* @see subscribe_sessions_to_promotions() for that.
*
* @todo make sure the extra session fields are copied too
*/
public static function copy(
$id,
$copy_courses = true,
$copy_users = true,
$copyTeachersAndDrh = true,
$create_new_courses = false,
$set_exercises_lp_invisible = false
) {
@ -4483,7 +4459,7 @@ class SessionManager
if (api_strtotime($s['coach_access_end_date']) < $now) {
$s['coach_access_end_date'] = $inOneMonth;
}
// Now try to create the session
$extraFieldValue = new ExtraFieldValue('session');
$extraFieldsValues = $extraFieldValue->getAllValuesByItem($id);
$extraFieldsValuesToCopy = [];
@ -4520,7 +4496,6 @@ class SessionManager
if ($copy_courses) {
// Register courses from the original session to the new session
$courses = self::get_course_list_by_session_id($id);
$short_courses = $new_short_courses = [];
if (is_array($courses) && count($courses) > 0) {
foreach ($courses as $course) {
@ -4528,7 +4503,6 @@ class SessionManager
}
}
$courses = null;
// We will copy the current courses of the session to new courses
if (!empty($short_courses)) {
if ($create_new_courses) {
@ -4586,11 +4560,19 @@ class SessionManager
$short_courses = $new_short_courses;
self::add_courses_to_session($sid, $short_courses, true);
$short_courses = null;
if ($create_new_courses === false && $copyTeachersAndDrh) {
foreach ($short_courses as $course) {
$coachList = self::getCoachesByCourseSession($id, $course['id']);
foreach ($coachList as $userId) {
self::set_coach_to_course_session($userId, $sid, $course['id']);
}
}
}
}
}
if ($copy_users) {
if ($copyTeachersAndDrh) {
// Register users from the original session to the new session
$users = self::get_users_by_session($id);
if (!empty($users)) {
@ -4599,23 +4581,24 @@ class SessionManager
$userData['relation_type'] = (int) $userData['relation_type'];
$userListByStatus[$userData['relation_type']][] = $userData;
}
//Subscribing in read only mode
foreach ($userListByStatus as $status => $userList) {
$userList = array_column($userList, 'user_id');
switch ($status) {
case 0:
self::subscribeUsersToSession(
$sid,
/*self::subscribeUsersToSession(
$sid,
$userList,
SESSION_VISIBLE_READ_ONLY,
SESSION_VISIBLE_READ_ONLY,
false,
true
);
true
);*/
break;
case 1:
// drh users
foreach ($userList as $drhId) {
$drhId = api_get_user_info($drhId);
self::subscribeSessionsToDrh($drhId, [$sid], false);
$userInfo = api_get_user_info($drhId);
self::subscribeSessionsToDrh($userInfo, [$sid], false, false);
}
break;
}
@ -6857,9 +6840,9 @@ SQL;
*/
public static function editUserSessionDuration($duration, $userId, $sessionId)
{
$duration = intval($duration);
$userId = intval($userId);
$sessionId = intval($sessionId);
$duration = (int) $duration;
$userId = (int) $userId;
$sessionId = (int) $sessionId;
if (empty($userId) || empty($sessionId)) {
return false;
@ -9085,6 +9068,7 @@ SQL;
}
$userRelSession = self::getUserSession($userId, $sessionId);
if ($userRelSession) {
if (isset($userRelSession['collapsed']) && $userRelSession['collapsed'] != '') {
$collapsed = $userRelSession['collapsed'];

@ -53,25 +53,6 @@ class SocialManager extends UserManager
}
}
/**
* Get relation type contact by name.
*
* @param string names of the kind of relation
*
* @return int
*
* @author isaac flores paz
*/
public static function get_relation_type_by_name($relation_type_name)
{
$list_type_friend = self::show_list_type_friends();
foreach ($list_type_friend as $value_type_friend) {
if (strtolower($value_type_friend['title']) == $relation_type_name) {
return $value_type_friend['id'];
}
}
}
/**
* Get the kind of relation between contacts.
*
@ -301,7 +282,7 @@ class SocialManager extends UserManager
$row_if_exist = Database::fetch_array($res_if_exist, 'ASSOC');
if ($row_if_exist['count'] == 1) {
$sql = 'UPDATE '.$tbl_message.' SET
msg_status=5, content = "'.$clean_message_content.'"
msg_status = 5, content = "'.$clean_message_content.'"
WHERE
user_sender_id='.$user_id.' AND
user_receiver_id='.$friend_id.' AND
@ -331,7 +312,7 @@ class SocialManager extends UserManager
$sql = 'SELECT COUNT(*) as count_message_in_box FROM '.$table.'
WHERE
user_receiver_id='.$userId.' AND
msg_status='.MESSAGE_STATUS_INVITATION_PENDING;
msg_status = '.MESSAGE_STATUS_INVITATION_PENDING;
$res = Database::query($sql);
$row = Database::fetch_array($res, 'ASSOC');
if ($row) {
@ -1242,8 +1223,8 @@ class SocialManager extends UserManager
Display::return_icon(
'announcement.png',
get_lang('Announcements')
).$announcement['course']['name'].' ('.$announcement['count'].')',
api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$announcement['course']['code']
).$announcement['course']['name'].' ('.$announcement['count'].')',
api_get_path(WEB_CODE_PATH).'announcements/announcements.php?cidReq='.$announcement['course']['code']
);
$announcements[] = Display::tag('li', $url);
}
@ -1643,10 +1624,9 @@ class SocialManager extends UserManager
$select = ' SELECT count(id) as count_items ';
}
$sql = "$select
FROM $tblMessage m
WHERE
msg_status <> ".MESSAGE_STATUS_WALL_DELETE.' AND ';
$sqlBase = "$select FROM $tblMessage m WHERE ";
$sql = [];
$sql[1] = $sqlBase."msg_status <> ".MESSAGE_STATUS_WALL_DELETE.' AND ';
// Get my own posts
$userReceiverCondition = ' (
@ -1655,24 +1635,25 @@ class SocialManager extends UserManager
parent_id = '.$parentId.'
)';
$sql .= $userReceiverCondition;
$sql[1] .= $userReceiverCondition;
$sql .= ' OR (
msg_status IN ('.MESSAGE_STATUS_PROMOTED.')
) ';
$sql[2] = $sqlBase.' msg_status = '.MESSAGE_STATUS_PROMOTED.' ';
// Get my group posts
$groupCondition = '';
if (!empty($groupId)) {
if (is_array($groupId)) {
$groupId = array_map('intval', $groupId);
$groupId = implode("','", $groupId);
$groupCondition = " OR ( group_id IN ('$groupId') ";
$groupId = implode(",", $groupId);
$groupCondition = " ( group_id IN ($groupId) ";
} else {
$groupId = (int) $groupId;
$groupCondition = " OR ( group_id = '$groupId' ";
$groupCondition = " ( group_id = $groupId ";
}
$groupCondition .= ' AND msg_status IN ('.MESSAGE_STATUS_NEW.', '.MESSAGE_STATUS_UNREAD.')) ';
$groupCondition .= ' AND (msg_status = '.MESSAGE_STATUS_NEW.' OR msg_status = '.MESSAGE_STATUS_UNREAD.')) ';
}
if (!empty($groupCondition)) {
$sql[3] = $sqlBase.$groupCondition;
}
// Get my friend posts
@ -1680,31 +1661,30 @@ class SocialManager extends UserManager
if (!empty($friendId)) {
if (is_array($friendId)) {
$friendId = array_map('intval', $friendId);
$friendId = implode("','", $friendId);
$friendCondition = " OR ( user_receiver_id IN ('$friendId') ";
$friendId = implode(",", $friendId);
$friendCondition = " ( user_receiver_id IN ($friendId) ";
} else {
$friendId = (int) $friendId;
$friendCondition = " OR ( user_receiver_id = '$friendId' ";
$friendCondition = " ( user_receiver_id = $friendId ";
}
$friendCondition .= ' AND msg_status IN ('.MESSAGE_STATUS_WALL_POST.') AND parent_id = 0) ';
$friendCondition .= ' AND msg_status = '.MESSAGE_STATUS_WALL_POST.' AND parent_id = 0) ';
}
if (!empty($groupCondition) || !empty($friendCondition)) {
$sql .= " $groupCondition $friendCondition ";
if (!empty($friendCondition)) {
$sql[4] = $sqlBase.$friendCondition;
}
if (!empty($threadList)) {
if ($getCount) {
$select = ' SELECT count(iid) count ';
$select = ' SELECT count(iid) count_items ';
} else {
$select = " SELECT
iid,
poster_id,
iid as id,
poster_id as user_sender_id,
'' as user_receiver_id,
post_date,
post_text,
post_date as send_date,
post_text as content,
'' as parent_id,
".MESSAGE_STATUS_FORUM.",
".MESSAGE_STATUS_FORUM." as msg_status,
'' as group_id,
forum_id,
thread_id,
@ -1715,72 +1695,86 @@ class SocialManager extends UserManager
$threadList = array_map('intval', $threadList);
$threadList = implode("','", $threadList);
$condition = " thread_id IN ('$threadList') ";
$sql .= "
UNION (
$select
$sql[5] = "$select
FROM c_forum_post
WHERE $condition
)
";
}
if ($getCount) {
$res = Database::query($sql);
$row = Database::fetch_array($res);
$count = 0;
foreach ($sql as $oneQuery) {
if (!empty($oneQuery)) {
$res = Database::query($oneQuery);
$row = Database::fetch_array($res);
$count += (int) $row['count_items'];
}
}
return (int) $row['count'];
return $count;
}
$sql .= ' ORDER BY send_date DESC ';
$sql .= " LIMIT $start, $length ";
$sqlOrder = ' ORDER BY send_date DESC ';
$sqlLimit = " LIMIT $start, $length ";
$messages = [];
$res = Database::query($sql);
$em = Database::getManager();
if (Database::num_rows($res) > 0) {
$repo = $em->getRepository('ChamiloCourseBundle:CForumPost');
$repoThread = $em->getRepository('ChamiloCourseBundle:CForumThread');
$groups = [];
$userGroup = new UserGroup();
$urlGroup = api_get_path(WEB_CODE_PATH).'social/group_view.php?id=';
while ($row = Database::fetch_array($res, 'ASSOC')) {
$row['group_info'] = [];
if (!empty($row['group_id'])) {
if (!in_array($row['group_id'], $groups)) {
$group = $userGroup->get($row['group_id']);
$group['url'] = $urlGroup.$group['id'];
$groups[$row['group_id']] = $group;
$row['group_info'] = $group;
} else {
$row['group_info'] = $groups[$row['group_id']];
foreach ($sql as $index => $oneQuery) {
if ($index === 5) {
// Exception only for the forum query above (field name change)
$oneQuery .= ' ORDER BY post_date DESC '.$sqlLimit;
} else {
$oneQuery .= $sqlOrder.$sqlLimit;
}
$res = Database::query($oneQuery);
$em = Database::getManager();
if (Database::num_rows($res) > 0) {
$repo = $em->getRepository('ChamiloCourseBundle:CForumPost');
$repoThread = $em->getRepository('ChamiloCourseBundle:CForumThread');
$groups = [];
$userGroup = new UserGroup();
$urlGroup = api_get_path(WEB_CODE_PATH).'social/group_view.php?id=';
while ($row = Database::fetch_array($res, 'ASSOC')) {
$row['group_info'] = [];
if (!empty($row['group_id'])) {
if (!in_array($row['group_id'], $groups)) {
$group = $userGroup->get($row['group_id']);
$group['url'] = $urlGroup.$group['id'];
$groups[$row['group_id']] = $group;
$row['group_info'] = $group;
} else {
$row['group_info'] = $groups[$row['group_id']];
}
}
}
// Forums
$row['post_title'] = '';
$row['forum_title'] = '';
$row['thread_url'] = '';
if ($row['msg_status'] == MESSAGE_STATUS_FORUM) {
/** @var CForumPost $post */
$post = $repo->find($row['id']);
/** @var CForumThread $thread */
$thread = $repoThread->find($row['thread_id']);
if ($post && $thread) {
$courseInfo = api_get_course_info_by_id($post->getCId());
$row['post_title'] = $post->getForumId();
$row['forum_title'] = $thread->getThreadTitle();
$row['thread_url'] = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.http_build_query([
'cidReq' => $courseInfo['code'],
'forum' => $post->getForumId(),
'thread' => $post->getThreadId(),
'post_id' => $post->getIid(),
]).'#post_id_'.$post->getIid();
// Forums
$row['post_title'] = '';
$row['forum_title'] = '';
$row['thread_url'] = '';
if ($row['msg_status'] == MESSAGE_STATUS_FORUM) {
/** @var CForumPost $post */
$post = $repo->find($row['id']);
/** @var CForumThread $thread */
$thread = $repoThread->find($row['thread_id']);
if ($post && $thread) {
$courseInfo = api_get_course_info_by_id($post->getCId());
$row['post_title'] = $post->getForumId();
$row['forum_title'] = $thread->getThreadTitle();
$row['thread_url'] = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.http_build_query([
'cidReq' => $courseInfo['code'],
'forum' => $post->getForumId(),
'thread' => $post->getThreadId(),
'post_id' => $post->getIid(),
]).'#post_id_'.$post->getIid();
}
}
}
$messages[] = $row;
$messages[$row['id']] = $row;
}
}
}
// Reordering messages by ID (reverse order) is enough to have the
// latest first, as there is currently no option to edit messages
// afterwards
krsort($messages);
return $messages;
}
@ -2219,77 +2213,6 @@ class SocialManager extends UserManager
$template->assign('social_avatar_block', $template->fetch($templateName));
}
/**
* @param int $user_id
* @param $link_shared
* @param $show_full_profile
*
* @return string
*/
public static function listMyFriends($user_id, $link_shared, $show_full_profile)
{
// SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT
$friends = self::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
$number_of_images = 30;
$number_friends = count($friends);
$friendHtml = '';
if ($number_friends != 0) {
if ($number_friends > $number_of_images) {
if (api_get_user_id() == $user_id) {
$friendHtml .= ' <span><a href="friends.php">'.get_lang('SeeAll').'</a></span>';
} else {
$friendHtml .= ' <span>'
.'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
.'?view=friends&height=390&width=610&user_id='.$user_id.'"'
.'class="ajax" data-title="'.get_lang('SeeAll').'" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAll').'</a></span>';
}
}
$friendHtml .= '<ul class="nav nav-list">';
$j = 1;
for ($k = 0; $k < $number_friends; $k++) {
if ($j > $number_of_images) {
break;
}
if (isset($friends[$k])) {
$friend = $friends[$k];
$name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
$user_info_friend = api_get_user_info($friend['friend_user_id'], true);
if ($user_info_friend['user_is_online']) {
$statusIcon = Display::span('', ['class' => 'online_user_in_text']);
} else {
$statusIcon = Display::span('', ['class' => 'offline_user_in_text']);
}
$friendHtml .= '<li>';
$friendHtml .= '<div>';
// the height = 92 must be the same in the image_friend_network span style in default.css
$friends_profile = UserManager::getUserPicture(
$friend['friend_user_id'],
USER_IMAGE_SIZE_SMALL
);
$friendHtml .= '<img src="'.$friends_profile.'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'"/>';
$link_shared = (empty($link_shared)) ? '' : '&'.$link_shared;
$friendHtml .= $statusIcon.'<a href="profile.php?'.'u='.$friend['friend_user_id'].$link_shared.'">'.$name_user.'</a>';
$friendHtml .= '</div>';
$friendHtml .= '</li>';
}
$j++;
}
$friendHtml .= '</ul>';
} else {
$friendHtml .= '<div class="">'.get_lang('NoFriendsInYourContactList').'<br />
<a class="btn btn-primary" href="'.api_get_path(WEB_PATH).'whoisonline.php">
<em class="fa fa-search"></em> '.get_lang('TryAndFindSomeFriends').'</a></div>';
}
$friendHtml = Display::panel($friendHtml, get_lang('SocialFriend').' ('.$number_friends.')');
return $friendHtml;
}
/**
* @param int $user_id
* @param $link_shared

@ -100,11 +100,15 @@ class SortableTable extends HTML_Table
* The array containing all data for this table.
*/
public $table_data;
public $hideItemSelector;
/**
* @var array Columns to hide
*/
private $columnsToHide = [];
private $dataFunctionParams;
private $defaultColumn;
private $defaultItemsPerPage;
/**
* Create a new SortableTable.
@ -137,7 +141,7 @@ class SortableTable extends HTML_Table
$table_id = $table_name.uniqid('table', true);
}
if (isset($parameters) && empty($parameters)) {
$parameters = ['class' => 'table table-bordered table-striped', 'id' => $table_id];
$parameters = ['class' => 'table table-bordered data_table', 'id' => $table_id];
}
$this->table_id = $table_id;
@ -145,17 +149,42 @@ class SortableTable extends HTML_Table
$this->table_name = $table_name;
$this->additional_parameters = [];
$this->param_prefix = $table_name.'_';
$this->defaultColumn = (int) $default_column;
$this->defaultItemsPerPage = $default_items_per_page;
$this->hideItemSelector = false;
$defaultRow = api_get_configuration_value('table_default_row');
if (!empty($defaultRow)) {
$this->defaultItemsPerPage = $default_items_per_page = $defaultRow;
}
$cleanSessionData = Session::read('clean_sortable_table');
if ($cleanSessionData === true) {
$this->cleanUrlSessionParams();
}
// Allow to change paginate in multiples tabs
//Session::erase($this->param_prefix.'per_page');
$this->per_page = Session::read($this->param_prefix.'per_page', $default_items_per_page);
// If per page changed, then reset the page to 1
if (!empty($this->per_page) && isset($_GET[$this->param_prefix.'per_page']) && $this->per_page != $_GET[$this->param_prefix.'per_page']) {
Session::erase($this->param_prefix.'page_nr');
$_GET[$this->param_prefix.'page_nr'] = 1;
}
$this->per_page = isset($_GET[$this->param_prefix.'per_page']) ? (int) $_GET[$this->param_prefix.'per_page'] : $this->per_page;
if (isset($_GET[$this->param_prefix.'per_page'])) {
Session::erase($this->param_prefix.'page_nr');
}
$this->page_nr = Session::read($this->param_prefix.'page_nr', 1);
$this->page_nr = isset($_GET[$this->param_prefix.'page_nr']) ? (int) $_GET[$this->param_prefix.'page_nr'] : $this->page_nr;
$this->column = Session::read($this->param_prefix.'column', $default_column);
$this->column = isset($_GET[$this->param_prefix.'column']) ? (int) $_GET[$this->param_prefix.'column'] : $this->column;
$defaultRow = api_get_configuration_value('table_default_row');
if (!empty($defaultRow)) {
$default_items_per_page = $defaultRow;
}
// Default direction.
if (in_array(strtoupper($default_order_direction), ['ASC', 'DESC'])) {
$this->direction = $default_order_direction;
@ -187,12 +216,6 @@ class SortableTable extends HTML_Table
}
}
// Allow to change paginate in multiples tabs
Session::erase($this->param_prefix.'per_page');
$this->per_page = Session::read($this->param_prefix.'per_page', $default_items_per_page);
$this->per_page = isset($_GET[$this->param_prefix.'per_page']) ? (int) $_GET[$this->param_prefix.'per_page'] : $this->per_page;
Session::write($this->param_prefix.'per_page', $this->per_page);
Session::write($this->param_prefix.'direction', $this->direction);
Session::write($this->param_prefix.'page_nr', $this->page_nr);
@ -212,6 +235,26 @@ class SortableTable extends HTML_Table
$this->dataFunctionParams = [];
}
/**
* Clean URL params when changing student view.
*/
public function cleanUrlSessionParams()
{
Session::erase('clean_sortable_table');
$prefix = $this->param_prefix;
Session::erase($prefix.'page_nr');
Session::erase($prefix.'column');
Session::erase($prefix.'direction');
Session::erase($prefix.'per_page');
$_GET[$this->param_prefix.'per_page'] = $this->default_items_per_page;
$_GET[$this->param_prefix.'page_nr'] = 1;
$_GET[$this->param_prefix.'column'] = $this->defaultColumn;
$_GET[$this->param_prefix.'direction'] = $this->direction;
}
/**
* @return array
*/
@ -710,6 +753,10 @@ class SortableTable extends HTML_Table
if ($total_number_of_items <= $this->default_items_per_page) {
return '';
}
if ($this->hideItemSelector === true) {
return '';
}
$result[] = '<form method="GET" action="'.api_get_self().'" style="display:inline;">';
$param[$this->param_prefix.'direction'] = $this->direction;
$param[$this->param_prefix.'page_nr'] = $this->page_nr;
@ -736,8 +783,7 @@ class SortableTable extends HTML_Table
}
$result[] = '<option value="'.$nr.'" '.($nr == $this->per_page ? 'selected="selected"' : '').'>'.$nr.'</option>';
}
// @todo no limits
//if ($total_number_of_items < 500) {
$result[] = '<option value="'.$total_number_of_items.'" '.($total_number_of_items == $this->per_page ? 'selected="selected"' : '').'>'.api_ucfirst(get_lang('All')).'</option>';
//}
$result[] = '</select>';
@ -913,7 +959,7 @@ class SortableTable extends HTML_Table
}
/**
* Add a filter to a column. If another filter was allready defined for the
* Add a filter to a column. If another filter was already defined for the
* given column, it will be overwritten.
*
* @param int $column The number of the column

@ -716,8 +716,9 @@ class Thematic
$tbl_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE);
$data = [];
$condition = '';
if (isset($thematic_advance_id)) {
$thematic_advance_id = intval($thematic_advance_id);
$thematic_advance_id = (int) $thematic_advance_id;
if (!empty($thematic_advance_id)) {
$condition = " AND a.id = $thematic_advance_id ";
}

@ -1839,49 +1839,6 @@ class Tracking
return false;
}
/**
* Get las connection date for a student.
*
* @param array $studentList Student id array
* @param int $days
* @param bool $getCount
*
* @return int
*/
public static function getInactiveUsers($studentList, $days, $getCount = true)
{
if (empty($studentList)) {
return 0;
}
$days = (int) $days;
$date = api_get_utc_datetime(strtotime($days.' days ago'));
$studentList = array_map('intval', $studentList);
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$select = " SELECT login_user_id ";
if ($getCount) {
$select = " SELECT count(DISTINCT login_user_id) as count";
}
$sql = "$select
FROM $tbl_track_login
WHERE
login_user_id IN (' ".implode("','", $studentList)."' ) AND
login_date < '$date'
";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if ($getCount) {
$count = Database::fetch_array($rs);
return $count['count'];
}
return Database::store_result($rs, 'ASSOC');
}
return false;
}
/**
* Get first user's connection date on the course.
*
@ -1902,51 +1859,30 @@ class Tracking
$courseId = (int) $courseId;
$session_id = (int) $session_id;
if (self::minimumTimeAvailable($session_id, $courseId)) {
$tbl_track_e_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$sql = 'SELECT access_date
FROM '.$tbl_track_e_access.'
WHERE access_user_id = '.$student_id.' AND
c_id = "'.$courseId.'" AND
access_session_id = '.$session_id.'
ORDER BY access_date ASC
LIMIT 0,1';
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if ($last_login_date = Database::result($rs, 0, 0)) {
if (empty($last_login_date)) {
return false;
}
if ($convert_date) {
return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
} else {
return $last_login_date;
}
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$sql = 'SELECT login_course_date
FROM '.$table.'
WHERE
user_id = '.$student_id.' AND
c_id = '.$courseId.' AND
session_id = '.$session_id.'
ORDER BY login_course_date ASC
LIMIT 0,1';
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if ($first_login_date = Database::result($rs, 0, 0)) {
if (empty($first_login_date)) {
return false;
}
}
} else {
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$sql = 'SELECT login_course_date
FROM '.$tbl_track_login.'
WHERE
user_id = '.$student_id.' AND
c_id = '.$courseId.' AND
session_id = '.$session_id.'
ORDER BY login_course_date ASC
LIMIT 0,1';
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if ($first_login_date = Database::result($rs, 0, 0)) {
if ($convert_date) {
return api_convert_and_format_date(
$first_login_date,
DATE_FORMAT_SHORT
);
} else {
return $first_login_date;
}
if ($convert_date) {
return api_convert_and_format_date(
$first_login_date,
DATE_FORMAT_SHORT
);
}
return $first_login_date;
}
}
@ -2467,182 +2403,6 @@ class Tracking
return $result.'%';
}
/**
* get teacher progress by course and session.
*
* @param int course id
* @param int session id
*
* @return array
*/
public static function get_teachers_progress_by_course($courseId, $sessionId)
{
$course = api_get_course_info_by_id($courseId);
$sessionId = intval($sessionId);
$courseId = intval($courseId);
$sessionCourseUserTable = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sessionTable = Database::get_main_table(TABLE_MAIN_SESSION);
//get teachers
$sql = "SELECT scu.session_id, scu.user_id, s.name
FROM $sessionCourseUserTable scu, $sessionTable s
WHERE
scu.session_id = s.id
AND scu.status = 2
AND scu.visibility = 1
AND scu.c_id = '%s'
AND scu.session_id = %s";
$query = sprintf($sql, intval($courseId), $sessionId);
$rs = Database::query($query);
$teachers = [];
while ($teacher = Database::fetch_array($rs, 'ASSOC')) {
$teachers[] = $teacher;
}
$data = [];
foreach ($teachers as $teacher) {
//total documents added
$sql = "SELECT count(*) as total
FROM c_item_property
WHERE lastedit_type = 'DocumentAdded'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalDocuments = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalDocuments = $row[0];
}
// Total links added
$sql = "SELECT count(*) as total
FROM c_item_property
WHERE lastedit_type = 'LinkAdded'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalLinks = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalLinks = $row[0];
}
//total forums added
$sql = "SELECT count(*) as total
FROM c_item_property
WHERE lastedit_type = 'ForumthreadVisible'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalForums = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalForums = $row[0];
}
//total wikis added
$sql = "SELECT COUNT(DISTINCT(ref)) as total
FROM c_item_property
WHERE lastedit_type = 'WikiAdded'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalWikis = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalWikis = $row[0];
}
// Total works added
$sql = "SELECT COUNT(*) as total
FROM c_item_property
WHERE lastedit_type = 'DirectoryCreated'
AND tool = 'work'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalWorks = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalWorks = $row[0];
}
//total announcements added
$sql = "SELECT COUNT(*) as total
FROM c_item_property
WHERE lastedit_type = 'AnnouncementAdded'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalAnnouncements = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalAnnouncements = $row[0];
}
$tutor = api_get_user_info($teacher['user_id']);
$data[] = [
'course' => $course['title'],
'session' => $teacher['name'],
'tutor' => $tutor['username'].' - '.$tutor['lastname'].' '.$tutor['firstname'],
'documents' => $totalDocuments,
'links' => $totalLinks,
'forums' => $totalForums,
'works' => $totalWorks,
'wikis' => $totalWikis,
'announcements' => $totalAnnouncements,
];
}
return $data;
}
/**
* Returns the average student progress in the learning paths of the given
* course, it will take into account the progress that were not started.
@ -3587,60 +3347,6 @@ class Tracking
return $students;
}
/**
* Get student followed by a coach inside a session.
*
* @param int Session id
* @param int Coach id
*
* @return array students list
*/
public static function get_student_followed_by_coach_in_a_session(
$id_session,
$coach_id
) {
$coach_id = intval($coach_id);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$students = [];
// At first, courses where $coach_id is coach of the course
$sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
WHERE session_id="'.$id_session.'" AND user_id='.$coach_id.' AND status=2';
$result = Database::query($sql);
while ($a_courses = Database::fetch_array($result)) {
$courseId = $a_courses['c_id'];
$sql = "SELECT DISTINCT srcru.user_id
FROM $tbl_session_course_user AS srcru
WHERE
c_id = '$courseId' AND
session_id = '".$id_session."'";
$rs = Database::query($sql);
while ($row = Database::fetch_array($rs)) {
$students[$row['user_id']] = $row['user_id'];
}
}
// Then, courses where $coach_id is coach of the session
$sql = 'SELECT id_coach FROM '.$tbl_session.'
WHERE id="'.$id_session.'" AND id_coach="'.$coach_id.'"';
$result = Database::query($sql);
//He is the session_coach so we select all the users in the session
if (Database::num_rows($result) > 0) {
$sql = 'SELECT DISTINCT srcru.user_id
FROM '.$tbl_session_course_user.' AS srcru
WHERE session_id="'.$id_session.'"';
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
$students[$row['user_id']] = $row['user_id'];
}
}
return $students;
}
/**
* Check if a coach is allowed to follow a student.
*
@ -7016,32 +6722,6 @@ class Tracking
return $allow;
}
public function getCoursesAndSessions($userId)
{
$userId = (int) $userId;
// Get the list of sessions where the user is subscribed as student
$sql = 'SELECT session_id, c_id
FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).'
WHERE user_id='.$userId;
$rs = Database::query($sql);
$tmp_sessions = [];
while ($row = Database::fetch_array($rs, 'ASSOC')) {
$tmp_sessions[] = $row['session_id'];
if ($drh_can_access_all_courses) {
if (in_array($row['session_id'], $tmp_sessions)) {
$courses_in_session[$row['session_id']][] = $row['c_id'];
}
} else {
if (isset($courses_in_session_by_coach[$row['session_id']])) {
if (in_array($row['session_id'], $tmp_sessions)) {
$courses_in_session[$row['session_id']][] = $row['c_id'];
}
}
}
}
}
}
/**
@ -7797,8 +7477,10 @@ class TrackingCourseLog
$user['first_connection'] = Tracking::get_first_connection_date_on_the_course(
$user['user_id'],
$courseId,
$session_id
$session_id,
$export_csv === false
);
$user['last_connection'] = Tracking::get_last_connection_date_on_the_course(
$user['user_id'],
$courseInfo,
@ -7806,6 +7488,11 @@ class TrackingCourseLog
$export_csv === false
);
if ($export_csv) {
$user['first_connection'] = api_get_local_time($user['first_connection']);
$user['last_connection'] = api_get_local_time($user['last_connection']);
}
if (empty($session_id)) {
$user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0).' / '.$total_surveys;
}

@ -220,7 +220,7 @@ class UserGroup extends Model
} else {
$sql = "SELECT count(a.id) as count
FROM {$this->table} a
WHERE 1 =1
WHERE 1 = 1
$authorCondition
";
$result = Database::query($sql);
@ -293,9 +293,18 @@ class UserGroup extends Model
{
// action links
echo '<div class="actions">';
echo '<a href="../admin/usergroups.php">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', '32').
'</a>';
$courseInfo = api_get_course_info();
if (empty($courseInfo)) {
echo '<a href="../admin/usergroups.php">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', '32').
'</a>';
} else {
echo Display::url(
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', '32'),
api_get_path(WEB_CODE_PATH).'user/class.php?'.api_get_cidreq()
);
}
echo '</div>';
echo Display::grid_html('usergroups');
}
@ -388,7 +397,7 @@ class UserGroup extends Model
} else {
$sql = "SELECT $select
FROM {$this->usergroup_rel_course_table} usergroup
INNER JOIN {$this->table} u
INNER JOIN {$this->table} u
ON (u.id = usergroup.usergroup_id)
INNER JOIN {$this->table_course} c
ON (usergroup.course_id = c.id)
@ -1470,10 +1479,6 @@ class UserGroup extends Model
WHERE usergroup_id = $id";
Database::query($sql);
/*$sql = "DELETE FROM $this->usergroup_rel_
WHERE usergroup_id = $id";
Database::query($sql);*/
parent::delete($id);
}
@ -1651,7 +1656,7 @@ class UserGroup extends Model
* @param string $id group id
* @param string picture group name
* @param string height
* @param string picture size it can be small_, medium_ or big_
* @param string $size_picture picture size it can be small_, medium_ or big_
* @param string style css
*
* @return array with the file and the style of an image i.e $array['file'] $array['style']
@ -2835,22 +2840,34 @@ class UserGroup extends Model
* Check permissions and blocks the page.
*
* @param array $userGroupInfo
* @param bool $checkAuthor
* @param bool $checkCourseIsAllow
*/
public function protectScript($userGroupInfo = [])
public function protectScript($userGroupInfo = [], $checkAuthor = true, $checkCourseIsAllow = false)
{
api_block_anonymous_users();
if (!api_is_platform_admin()) {
if (api_is_teacher()) {
if (!empty($userGroupInfo)) {
if ($userGroupInfo['author_id'] != api_get_user_id()) {
api_not_allowed(true);
}
if (api_is_platform_admin()) {
return true;
}
if ($checkCourseIsAllow) {
if (api_is_allowed_to_edit()) {
return true;
}
}
if ($this->allowTeachers() && api_is_teacher()) {
if ($checkAuthor && !empty($userGroupInfo)) {
if (isset($userGroupInfo['author_id']) && $userGroupInfo['author_id'] != api_get_user_id()) {
api_not_allowed(true);
}
} else {
api_protect_admin_script(true);
api_protect_limit_for_session_admin();
}
return true;
} else {
api_protect_admin_script(true);
api_protect_limit_for_session_admin();
}
}
}

@ -2456,62 +2456,6 @@ class UserManager
return $fields;
}
/**
* Build a list of extra file already uploaded in $user_folder/{$extra_field}/.
*
* @param $user_id
* @param $extra_field
* @param bool $force
* @param bool $showDelete
*
* @return bool|string
*/
public static function build_user_extra_file_list(
$user_id,
$extra_field,
$force = false,
$showDelete = false
) {
if (!$force && !empty($_POST['remove_'.$extra_field])) {
return true; // postpone reading from the filesystem
}
$extra_files = self::get_user_extra_files($user_id, $extra_field);
if (empty($extra_files)) {
return false;
}
$path_info = self::get_user_picture_path_by_id($user_id, 'web');
$path = $path_info['dir'];
$del_image = Display::returnIconPath('delete.png');
$del_text = get_lang('Delete');
$extra_file_list = '';
if (count($extra_files) > 0) {
$extra_file_list = '<div class="files-production"><ul id="productions">';
foreach ($extra_files as $file) {
$filename = substr($file, strlen($extra_field) + 1);
$extra_file_list .= '<li>'.Display::return_icon('archive.png').
'<a href="'.$path.$extra_field.'/'.urlencode($filename).'" target="_blank">
'.htmlentities($filename).
'</a> ';
if ($showDelete) {
$extra_file_list .= '<input
style="width:16px;"
type="image"
name="remove_extra_'.$extra_field.'['.urlencode($file).']"
src="'.$del_image.'"
alt="'.$del_text.'"
title="'.$del_text.' '.htmlentities($filename).'"
onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>';
}
}
$extra_file_list .= '</ul></div>';
}
return $extra_file_list;
}
/**
* Get valid filenames in $user_folder/{$extra_field}/.
*
@ -2554,33 +2498,6 @@ class UserManager
return $files; // can be an empty array
}
/**
* Remove an {$extra_file} from the user folder $user_folder/{$extra_field}/.
*
* @param int $user_id
* @param string $extra_field
* @param string $extra_file
*
* @return bool
*/
public static function remove_user_extra_file($user_id, $extra_field, $extra_file)
{
$extra_file = Security::filter_filename($extra_file);
$path_info = self::get_user_picture_path_by_id($user_id, 'system');
if (strpos($extra_file, $extra_field) !== false) {
$path_extra_file = $path_info['dir'].$extra_file;
} else {
$path_extra_file = $path_info['dir'].$extra_field.'/'.$extra_file;
}
if (is_file($path_extra_file)) {
unlink($path_extra_file);
return true;
}
return false;
}
/**
* Creates a new extra field.
*
@ -2824,18 +2741,6 @@ class UserManager
return $extraField->get_handler_field_info_by_tags($variable);
}
/**
* @param string $type
*
* @return array
*/
public static function get_all_extra_field_by_type($type)
{
$extraField = new ExtraField('user');
return $extraField->get_all_extra_field_by_type($type);
}
/**
* Get all the extra field information of a certain field (also the options).
*
@ -3611,6 +3516,13 @@ class UserManager
if (!empty($myCourseList)) {
ksort($myCourseList);
$checkPosition = array_filter(array_column($myCourseList, 'position'));
if (empty($checkPosition)) {
// The session course list doesn't have any position,
// then order the course list by course code
$list = array_column($myCourseList, 'course_code');
array_multisort($myCourseList, SORT_ASC, $list);
}
}
return $myCourseList;
@ -5355,42 +5267,6 @@ class UserManager
return false;
}
/**
* Gets the user path of user certificated.
*
* @param int The user id
*
* @return array containing path_certificate and cat_id
*/
public static function get_user_path_certificate($user_id)
{
$my_certificate = [];
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$table_gradebook_category = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$session_id = api_get_session_id();
$user_id = (int) $user_id;
if ($session_id == 0 || is_null($session_id)) {
$sql_session = 'AND (session_id='.intval($session_id).' OR isnull(session_id)) ';
} elseif ($session_id > 0) {
$sql_session = 'AND session_id='.intval($session_id);
} else {
$sql_session = '';
}
$sql = "SELECT tc.path_certificate,tc.cat_id,tgc.course_code,tgc.name
FROM $table_certificate tc, $table_gradebook_category tgc
WHERE tgc.id = tc.cat_id AND tc.user_id = $user_id
ORDER BY tc.date_certificate DESC
LIMIT 5";
$rs = Database::query($sql);
while ($row = Database::fetch_array($rs)) {
$my_certificate[] = $row;
}
return $my_certificate;
}
/**
* This function check if the user is a coach inside session course.
*
@ -5452,32 +5328,6 @@ class UserManager
return $icon_link;
}
/**
* Returns an array of the different types of user extra fields [id => title translation].
*
* @return array
*/
public static function get_user_field_types()
{
$types = [];
$types[self::USER_FIELD_TYPE_TEXT] = get_lang('FieldTypeText');
$types[self::USER_FIELD_TYPE_TEXTAREA] = get_lang('FieldTypeTextarea');
$types[self::USER_FIELD_TYPE_RADIO] = get_lang('FieldTypeRadio');
$types[self::USER_FIELD_TYPE_SELECT] = get_lang('FieldTypeSelect');
$types[self::USER_FIELD_TYPE_SELECT_MULTIPLE] = get_lang('FieldTypeSelectMultiple');
$types[self::USER_FIELD_TYPE_DATE] = get_lang('FieldTypeDate');
$types[self::USER_FIELD_TYPE_DATETIME] = get_lang('FieldTypeDatetime');
$types[self::USER_FIELD_TYPE_DOUBLE_SELECT] = get_lang('FieldTypeDoubleSelect');
$types[self::USER_FIELD_TYPE_DIVIDER] = get_lang('FieldTypeDivider');
$types[self::USER_FIELD_TYPE_TAG] = get_lang('FieldTypeTag');
$types[self::USER_FIELD_TYPE_TIMEZONE] = get_lang('FieldTypeTimezone');
$types[self::USER_FIELD_TYPE_SOCIAL_PROFILE] = get_lang('FieldTypeSocialProfile');
$types[self::USER_FIELD_TYPE_FILE] = get_lang('FieldTypeFile');
$types[self::USER_FIELD_TYPE_MOBILE_PHONE_NUMBER] = get_lang('FieldTypeMobilePhoneNumber');
return $types;
}
/**
* @param User $user
*/
@ -5679,34 +5529,6 @@ class UserManager
);
}
/**
* Get the teacher (users with COURSEMANGER status) list.
*
* @return array The list
*/
public static function getTeachersList()
{
$userTable = Database::get_main_table(TABLE_MAIN_USER);
$resultData = Database::select(
'user_id, lastname, firstname, username',
$userTable,
[
'where' => [
'status = ?' => COURSEMANAGER,
],
]
);
foreach ($resultData as &$teacherData) {
$teacherData['completeName'] = api_get_person_name(
$teacherData['firstname'],
$teacherData['lastname']
);
}
return $resultData;
}
/**
* @return array
*/
@ -5902,21 +5724,6 @@ class UserManager
return get_lang('Anonymous');
}
/**
* Displays the name of the user and makes the link to the user profile.
*
* @param $userInfo
*
* @return string
*/
public static function getUserProfileLinkWithPicture($userInfo)
{
return Display::url(
Display::img($userInfo['avatar']),
$userInfo['profile_url']
);
}
/**
* Get users whose name matches $firstname and $lastname.
*
@ -6472,19 +6279,6 @@ SQL;
}
}
/**
* @return int
*/
public static function getCountActiveUsers()
{
$table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT count(id) count FROM $table WHERE active = 1 AND status <> ".ANONYMOUS;
$result = Database::query($sql);
$row = Database::fetch_array($result);
return (int) $row['count'];
}
/**
* @param array $userInfo
* @param int $searchYear

@ -956,14 +956,14 @@ class IndexManager
$items[] = [
'class' => 'add-course',
'icon' => Display::return_icon('new-course.png', get_lang('CreateCourseRequest')),
'link' => 'main/create_course/add_course.php',
'link' => api_get_path(WEB_CODE_PATH).'create_course/add_course.php',
'title' => get_lang('CreateCourseRequest'),
];
} else {
$items[] = [
'class' => 'add-course',
'icon' => Display::return_icon('new-course.png', get_lang('CourseCreate')),
'link' => 'main/create_course/add_course.php',
'link' => api_get_path(WEB_CODE_PATH).'create_course/add_course.php',
'title' => get_lang('CourseCreate'),
];
}
@ -972,7 +972,7 @@ class IndexManager
$items[] = [
'class' => 'add-session',
'icon' => Display::return_icon('session.png', get_lang('AddSession')),
'link' => 'main/session/session_add.php',
'link' => api_get_path(WEB_CODE_PATH).'session/session_add.php',
'title' => get_lang('AddSession'),
];
}
@ -983,7 +983,7 @@ class IndexManager
$items[] = [
'class' => 'order-course',
'icon' => Display::return_icon('order-course.png', get_lang('SortMyCourses')),
'link' => api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses',
'link' => api_get_path(WEB_CODE_PATH).'auth/sort_my_courses.php',
'title' => get_lang('SortMyCourses'),
];
}
@ -993,14 +993,14 @@ class IndexManager
$items[] = [
'class' => 'history-course',
'icon' => Display::return_icon('history-course.png', get_lang('DisplayTrainingList')),
'link' => 'user_portal.php',
'link' => api_get_path(WEB_PATH).'user_portal.php',
'title' => get_lang('DisplayTrainingList'),
];
} else {
$items[] = [
'class' => 'history-course',
'icon' => Display::return_icon('history-course.png', get_lang('HistoryTrainingSessions')),
'link' => 'user_portal.php?history=1',
'link' => api_get_path(WEB_PATH).'user_portal.php?history=1',
'title' => get_lang('HistoryTrainingSessions'),
];
}
@ -1018,12 +1018,12 @@ class IndexManager
$items[] = [
'class' => 'list-course',
'icon' => Display::return_icon('catalog-course.png', get_lang('CourseCatalog')),
'link' => 'main/auth/courses.php',
'link' => api_get_path(WEB_CODE_PATH).'auth/courses.php',
'title' => get_lang('CourseCatalog'),
];
} else {
$items[] = [
'link' => 'main/dashboard/index.php',
'link' => api_get_path(WEB_CODE_PATH).'dashboard/index.php',
'title' => get_lang('Dashboard'),
];
}
@ -1338,7 +1338,7 @@ class IndexManager
if (is_array($session_categories)) {
foreach ($session_categories as $session_category) {
$session_category_id = $session_category['session_category']['id'];
// Sessions and courses that are not in a session category
if (empty($session_category_id) &&
isset($session_category['sessions'])
) {
@ -1517,11 +1517,11 @@ class IndexManager
if ($collapsable) {
$collapsableData = SessionManager::getCollapsableData(
$user_id,
$session_id,
$extraFieldValue,
$collapsableLink
);
$user_id,
$session_id,
$extraFieldValue,
$collapsableLink
);
$params['collapsed'] = $collapsableData['collapsed'];
$params['collapsable_link'] = $collapsableData['collapsable_link'];
}
@ -1767,11 +1767,11 @@ class IndexManager
$this->tpl->assign('show_tutor', (api_get_setting('show_session_coach') === 'true' ? true : false));
$this->tpl->assign('gamification_mode', $gameModeIsActive);
$this->tpl->assign('remove_session_url', api_get_configuration_value('remove_session_url'));
//$this->tpl->assign('remove_session_url', api_get_setting('session.remove_session_url'));
if ($viewGridCourses) {
$sessions_with_no_category = $this->tpl->fetch(
$this->tpl->get_template('/user_portal/grid_session.tpl')
);
);
} else {
$sessions_with_no_category = $this->tpl->fetch(
$this->tpl->get_template('user_portal/classic_session.tpl')
@ -2366,7 +2366,7 @@ class IndexManager
}
$icon = Display::return_icon(
'blackboard_blue.png',
'session.png',
$title,
['class' => 'sessionView'],
ICON_SIZE_LARGE

@ -19,6 +19,8 @@ class Rest extends WebService
const GET_AUTH = 'authenticate';
const GET_USER_MESSAGES = 'user_messages';
const POST_USER_MESSAGE_READ = 'user_message_read';
const POST_USER_MESSAGE_UNREAD = 'user_message_unread';
const SAVE_GCM_ID = 'gcm_id';
const GET_USER_COURSES = 'user_courses';
const GET_PROFILE = 'user_profile';
@ -133,7 +135,7 @@ class Rest extends WebService
*/
public static function validate($username, $apiKeyToValidate)
{
$apiKey = self::findUserApiKey($username, self::SERVIVE_NAME);
$apiKey = self::findUserApiKey($username, self::SERVICE_NAME);
if ($apiKey != $apiKeyToValidate) {
throw new Exception(get_lang('InvalidApiKey'));
@ -201,7 +203,8 @@ class Rest extends WebService
'sendDate' => $message['send_date'],
'content' => $message['content'],
'hasAttachments' => $hasAttachments,
'url' => '',
'url' => api_get_path(WEB_CODE_PATH).'messages/view_message.php?'
.http_build_query(['type' => 1, 'id' => $message['id']]),
];
}
@ -211,6 +214,10 @@ class Rest extends WebService
/**
* Get the user courses.
*
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
* @throws \Doctrine\ORM\ORMException
*
* @return array
*/
public function getUserCourses()
@ -218,18 +225,21 @@ class Rest extends WebService
$courses = CourseManager::get_courses_list_by_user_id($this->user->getId());
$data = [];
foreach ($courses as $courseId) {
foreach ($courses as $courseInfo) {
/** @var Course $course */
$course = Database::getManager()->find('ChamiloCoreBundle:Course', $courseId['real_id']);
$course = Database::getManager()->find('ChamiloCoreBundle:Course', $courseInfo['real_id']);
$teachers = CourseManager::getTeacherListFromCourseCodeToString($course->getCode());
$picturePath = CourseManager::getPicturePath($course, true)
?: Display::return_icon('session_default.png', null, null, null, null, true);
$data[] = [
'id' => $course->getId(),
'title' => $course->getTitle(),
'code' => $course->getCode(),
'directory' => $course->getDirectory(),
'urlPicture' => CourseManager::getPicturePath($course, true),
'urlPicture' => $picturePath,
'teachers' => $teachers,
'isSpecial' => !empty($courseInfo['special_course']),
];
}
@ -915,6 +925,7 @@ class Rest extends WebService
'code' => $courseInfo['code'],
'directory' => $courseInfo['directory'],
'pictureUrl' => $courseInfo['course_image_large'],
'urlPicture' => $courseInfo['course_image_large'],
'teachers' => $teachers,
];
}

@ -99,4 +99,12 @@ class WebService
$user->getSalt()
);
}
/**
* @return User
*/
public function getUser()
{
return $this->user;
}
}

@ -731,16 +731,10 @@ class learnpath
// Check course code exists.
// Check lp_name doesn't exist, otherwise append something.
$i = 0;
$name = Database::escape_string($name);
$categoryId = (int) $categoryId;
// Session id.
$session_id = api_get_session_id();
$userId = empty($userId) ? api_get_user_id() : $userId;
$check_name = "SELECT * FROM $tbl_lp
WHERE c_id = $course_id AND name = '$name'";
$res_name = Database::query($check_name);
if (empty($publicated_on)) {
$publicated_on = null;
@ -754,12 +748,16 @@ class learnpath
$expired_on = Database::escape_string(api_get_utc_datetime($expired_on));
}
$check_name = "SELECT * FROM $tbl_lp
WHERE c_id = $course_id AND name = '".Database::escape_string($name)."'";
$res_name = Database::query($check_name);
while (Database::num_rows($res_name)) {
// There is already one such name, update the current one a bit.
$i++;
$name = $name.' - '.$i;
$check_name = "SELECT * FROM $tbl_lp
WHERE c_id = $course_id AND name = '$name'";
WHERE c_id = $course_id AND name = '".Database::escape_string($name)."' ";
$res_name = Database::query($check_name);
}
// New name does not exist yet; keep it.
@ -2249,13 +2247,22 @@ class learnpath
// @todo remove this query and load the row info as a parameter
$table = Database::get_course_table(TABLE_LP_MAIN);
// Get current prerequisite
$sql = "SELECT id, prerequisite, subscribe_users, publicated_on, expired_on
$sql = "SELECT id, prerequisite, subscribe_users, publicated_on, expired_on, category_id
FROM $table
WHERE iid = $lp_id";
$rs = Database::query($sql);
$now = time();
if (Database::num_rows($rs) > 0) {
$row = Database::fetch_array($rs, 'ASSOC');
if (!empty($row['category_id'])) {
$em = Database::getManager();
$category = $em->getRepository('ChamiloCourseBundle:CLpCategory')->find($row['category_id']);
if (self::categoryIsVisibleForStudent($category, api_get_user_entity($student_id)) === false) {
return false;
}
}
$prerequisite = $row['prerequisite'];
$is_visible = true;
@ -2733,6 +2740,23 @@ class learnpath
return false;
}
/**
* Gets the status list for all LP's items.
*
* @return array Array of [index] => [item ID => current status]
*/
public function get_items_status_list()
{
$list = [];
foreach ($this->ordered_items as $item_id) {
$list[] = [
$item_id => $this->items[$item_id]->get_status(),
];
}
return $list;
}
/**
* Return the number of interactions for the given learnpath Item View ID.
* This method can be used as static.
@ -4224,24 +4248,9 @@ class learnpath
public static function toggleCategoryVisibility($id, $visibility = 1)
{
$action = 'visible';
if ($visibility != 1) {
$action = 'invisible';
$list = new LearnpathList(
api_get_user_id(),
null,
null,
null,
false,
$id
);
$lpList = $list->get_flat_list();
foreach ($lpList as $lp) {
self::toggle_visibility($lp['iid'], 0);
}
self::toggleCategoryPublish($id, 0);
$action = 'invisible';
}
return api_item_property_update(
@ -4466,10 +4475,8 @@ class learnpath
$courseId = 0,
$sessionId = 0
) {
$subscriptionSettings = self::getSubscriptionSettings();
if ($subscriptionSettings['allow_add_users_to_lp_category'] == false) {
return true;
if (empty($category)) {
return false;
}
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
@ -4478,19 +4485,34 @@ class learnpath
return true;
}
if (empty($category)) {
$courseId = empty($courseId) ? api_get_course_int_id() : (int) $courseId;
$sessionId = empty($sessionId) ? api_get_session_id() : (int) $sessionId;
$courseInfo = api_get_course_info_by_id($courseId);
$categoryVisibility = api_get_item_visibility(
$courseInfo,
TOOL_LEARNPATH_CATEGORY,
$category->getId(),
$sessionId
);
if ($categoryVisibility !== 1 && $categoryVisibility != -1) {
return false;
}
$subscriptionSettings = self::getSubscriptionSettings();
if ($subscriptionSettings['allow_add_users_to_lp_category'] == false) {
return true;
}
$users = $category->getUsers();
if (empty($users) || !$users->count()) {
return true;
}
$courseId = empty($courseId) ? api_get_course_int_id() : (int) $courseId;
$sessionId = empty($sessionId) ? api_get_session_id() : (int) $sessionId;
if ($category->hasUserAdded($user)) {
return true;
}
@ -4901,12 +4923,15 @@ class learnpath
if (empty($name)) {
return false;
}
$this->name = Database::escape_string($name);
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$name = Database::escape_string($name);
$this->name = $name;
$lp_id = $this->get_id();
$course_id = $this->course_info['real_id'];
$sql = "UPDATE $lp_table SET
name = '".Database::escape_string($this->name)."'
name = '$name'
WHERE iid = $lp_id";
$result = Database::query($sql);
// If the lp is visible on the homepage, change his name there.
@ -4915,7 +4940,7 @@ class learnpath
$session_condition = api_get_session_condition($session_id);
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
$link = 'lp/lp_controller.php?action=view&lp_id='.$lp_id.'&id_session='.$session_id;
$sql = "UPDATE $tbl_tool SET name = '$this->name'
$sql = "UPDATE $tbl_tool SET name = '$name'
WHERE
c_id = $course_id AND
(link='$link' AND image='scormbuilder.gif' $session_condition)";
@ -6223,7 +6248,7 @@ class learnpath
} else {
$parent_arrays = [];
if ($arrLP[$i]['depth'] > 1) {
//Getting list of parents
// Getting list of parents
for ($j = 0; $j < $arrLP[$i]['depth']; $j++) {
foreach ($arrLP as $item) {
if ($item['id'] == $parent_id) {
@ -7416,7 +7441,7 @@ class learnpath
public function display_hotpotatoes_form($action = 'add', $id = 0, $extra_info = '')
{
$course_id = api_get_course_int_id();
$uploadPath = DIR_HOTPOTATOES; //defined in main_api
$uploadPath = DIR_HOTPOTATOES;
if ($id != 0 && is_array($extra_info)) {
$item_title = stripslashes($extra_info['title']);
@ -9981,7 +10006,7 @@ class learnpath
ORDER BY title ASC";
$sql_hot = "SELECT * FROM $tbl_doc
WHERE
WHERE
c_id = $course_id AND
path LIKE '".$uploadPath."/%/%htm%'
$condition_session
@ -11526,7 +11551,7 @@ EOD;
if (filter_extension($new_file_name)) {
$file_extension = explode('.', $image_array['name']);
$file_extension = strtolower($file_extension[sizeof($file_extension) - 1]);
$file_extension = strtolower($file_extension[count($file_extension) - 1]);
$filename = uniqid('');
$new_file_name = $filename.'.'.$file_extension;
$new_path = $updir.'/'.$new_file_name;

@ -101,11 +101,11 @@ if (api_get_configuration_value('save_titles_as_html')) {
);
} else {
$form->addElement(
'text',
'lp_name',
api_ucfirst(get_lang('LPName')),
['autofocus' => 'autofocus']
);
'text',
'lp_name',
api_ucfirst(get_lang('LPName')),
['autofocus' => 'autofocus']
);
}
$form->applyFilter('lp_name', 'html_filter');
$form->addRule('lp_name', get_lang('ThisFieldIsRequired'), 'required');

@ -102,7 +102,7 @@ $htmlHeadXtra[] = '
var jItems = $("#lp_item_list li.li_container");
var jItem = $("#"+ itemId);
var index = jItems.index(jItem);
var total = jItems.length;
var total = jItems.length;
switch (dir) {
case "up":
@ -130,7 +130,7 @@ $htmlHeadXtra[] = '
} else {
//console.log("classic");
jItem.detach().insertBefore(jItems[index - 1]);
}
}
break;
}
@ -142,8 +142,8 @@ $htmlHeadXtra[] = '
//console.log(parentIndex);
jItem.detach().insertAfter(jItems[parentIndex]);
} else {
jItem.detach().insertBefore(jItems[index - 1]);
}
jItem.detach().insertBefore(jItems[index - 1]);
}
}
break;
case "down":
@ -155,10 +155,10 @@ $htmlHeadXtra[] = '
index = subItems.length + index;
//console.log("element is a chapter with items");
//console.log("new index = " + index);
}
}
var subItems = $(jItems[index + 1]).find("li.sub_item");
// is a chapter?
//console.log("next subItems.length: "+subItems.length);
// This is an element entering in a chapter
if (subItems.length > 0) {
// Check if im a child
@ -172,7 +172,7 @@ $htmlHeadXtra[] = '
jItem.detach().insertAfter(jItems[parentIndex]);
} else {
jItem.detach().insertAfter(subItems);
}
}
break;
}
@ -185,13 +185,13 @@ $htmlHeadXtra[] = '
// We are brothers!
if (parentId == myParentId) {
if ((index + 1) < total) {
if ((index + 1) < total) {
//console.log(index + 1);
//console.log("We are brothers");
jItem.detach().insertAfter(jItems[index + 1]);
}
jItem.detach().insertAfter(jItems[index + 1]);
}
break;
}
}
if (currentSubItems.length > 0) {
var parentIndex = jItems.index(jItem.parent().parent());
@ -200,9 +200,9 @@ $htmlHeadXtra[] = '
//console.log("parentIndex: " + parentIndex);
if (parentIndex >= 0) {
jItem.detach().insertAfter(jItems[parentIndex]);
break;
}
break;
}
//jItem.detach().insertAfter($(jItems[index]).parent().parent());
}
//var lastItem = $(jItems[index + 1]).parent().parent().find("li.li_container").last();
@ -769,7 +769,7 @@ switch ($action) {
$new_lp_id = learnpath::add_lp(
api_get_course_id(),
Security::remove_XSS($_REQUEST['lp_name']),
$_REQUEST['lp_name'],
'',
'chamilo',
'manual',
@ -1160,8 +1160,7 @@ switch ($action) {
require 'lp_list.php';
} else {
Session::write('refresh', 1);
$lp_name = Security::remove_XSS($_REQUEST['lp_name']);
$_SESSION['oLP']->set_name($lp_name);
$_SESSION['oLP']->set_name($_REQUEST['lp_name']);
$author = $_REQUEST['lp_author'];
// Fixing the author name (no body or html tags).
$auth_init = stripos($author, '<p>');
@ -1190,8 +1189,6 @@ switch ($action) {
$hide_toc_frame = null;
if (isset($_REQUEST['hide_toc_frame']) && $_REQUEST['hide_toc_frame'] == 1) {
$hide_toc_frame = $_REQUEST['hide_toc_frame'];
} else {
$hide_toc_frame = null;
}
$_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame);
$_SESSION['oLP']->set_prerequisite(isset($_POST['prerequisites']) ? (int) $_POST['prerequisites'] : 0);

@ -68,12 +68,13 @@ if (!$session) {
->getQuery()
->getResult();
} else {
$session->getUserCourseSubscriptionsByStatus($course, Session::STUDENT)
->forAll(
function ($i, SessionRelCourseRelUser $sessionCourseUser) use (&$subscribedUsers) {
$subscribedUsers[$i] = $sessionCourseUser->getUser();
}
);
$list = $session->getUserCourseSubscriptionsByStatus($course, Session::STUDENT);
if ($list) {
/** @var SessionRelCourseRelUser $sessionCourseUser */
foreach ($list as $sessionCourseUser) {
$subscribedUsers[$sessionCourseUser->getUser()->getUserId()] = $sessionCourseUser->getUser();
}
}
}
// Getting all users in a nice format.

@ -179,14 +179,17 @@ if ($session->getNbrCourses() === 0) {
$course,
$session
);
// Get coachs of the courses in session
$namesOfCoaches = [];
$coachSubscriptions = $session->getUserCourseSubscriptionsByStatus($course, Session::COACH)
->forAll(function ($index, SessionRelCourseRelUser $subscription) use (&$namesOfCoaches) {
$namesOfCoaches[] = UserManager::formatUserFullName($subscription->getUser(), true);
$coachSubscriptions = $session->getUserCourseSubscriptionsByStatus($course, Session::COACH);
return true;
});
if ($coachSubscriptions) {
/** @var SessionRelCourseRelUser $subscription */
foreach ($coachSubscriptions as $subscription) {
$namesOfCoaches[] = $subscription->getUser()->getCompleteNameWithUserName();
}
}
$orderButtons = '';
if (SessionManager::orderCourseIsEnabled()) {

@ -13,12 +13,6 @@ class ch_comment extends survey_question
*/
public function render(FormValidator $form, $questionData = [], $answers = '')
{
if (is_array($answers)) {
$content = implode('', $answers);
} else {
$content = $answers;
}
$name = 'question'.$questionData['question_id'];
$form->addTextarea($name, null);
$form->setDefaults([$name => $answers]);

@ -4,273 +4,223 @@
/**
* @package chamilo.survey
*
* @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 code
* @author Julio Montoya <gugli100@gmail.com>, Chamilo: Personality Test modifications
*
* @version $Id: survey_list.php 10680 2007-01-11 21:26:23Z pcool $
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @author Julio Montoya <gugli100@gmail.com>
*/
require_once __DIR__.'/../inc/global.inc.php';
$this_section = SECTION_COURSES;
api_protect_course_script(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_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
$course_id = api_get_course_int_id();
$courseInfo = $course_id ? api_get_course_info_by_id($course_id) : [];
$userId = api_get_user_id();
$surveyId = (int) $_GET['survey_id'];
$userInvited = 0;
$userAnonymous = 0;
$allowRequiredSurveyQuestions = api_get_configuration_value('allow_required_survey_questions');
//query to ask if logged user is allowed to see the preview (if he is invited of he is a teacher)
$sql = "SELECT survey_invitation.user
FROM $table_survey_invitation survey_invitation
LEFT JOIN $table_survey survey
ON survey_invitation.survey_code = survey.code
WHERE
survey_invitation.c_id = $course_id AND
survey.survey_id = $surveyId AND
survey_invitation.user = $userId";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$userInvited = 1;
}
// We exit here if there is no valid $_GET parameter
if (!isset($_GET['survey_id']) || !is_numeric($_GET['survey_id'])) {
api_not_allowed(
true,
Display::return_message(get_lang('InvallidSurvey'), 'error', false)
);
if (empty($surveyId)) {
api_not_allowed(true);
}
// Getting the survey information
$survey_data = SurveyManager::get_survey($surveyId);
if (empty($survey_data)) {
api_not_allowed(
true,
Display::return_message(get_lang('InvallidSurvey'), 'error', false)
);
}
$urlname = strip_tags($survey_data['title']);
if (api_is_allowed_to_edit()) {
// Breadcrumbs
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq(),
'name' => get_lang('SurveyList'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$surveyId.'&'.api_get_cidreq(),
'name' => $urlname,
];
}
$courseCode = isset($_GET['cidReq']) ? $_GET['cidReq'] : null;
$surveyAnonymous = SurveyManager::get_survey($surveyId, 0, $courseCode);
$surveyAnonymous = $surveyAnonymous['anonymous'];
if ($surveyAnonymous == 0 && api_is_anonymous()) {
api_not_allowed(true);
} elseif ($surveyAnonymous == 0 && $userInvited == 0) {
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
}
$show = 0;
$this_section = SECTION_COURSES;
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$table_survey_question_option = Database::get_course_table(TABLE_SURVEY_QUESTION_OPTION);
$course_id = api_get_course_int_id();
$courseInfo = api_get_course_info();
$allowRequiredSurveyQuestions = api_get_configuration_value('allow_required_survey_questions');
// Breadcrumbs
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'survey/survey_list.php?'.api_get_cidreq(),
'name' => get_lang('SurveyList'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'survey/survey.php?survey_id='.$surveyId.'&'.api_get_cidreq(),
'name' => strip_tags($survey_data['title']),
];
$show = 0;
Display::display_header(get_lang('SurveyPreview'));
// We exit here is the first or last question is a pagebreak (which causes errors)
SurveyUtil::check_first_last_question($surveyId, false);
$counter_question = 0;
// Only a course admin is allowed to preview a survey: you are a course admin
if (api_is_course_admin() ||
(api_is_course_admin() && $_GET['isStudentView'] == 'true') ||
api_is_allowed_to_session_edit(false, true)
) {
// Survey information
echo '<div class="page-header"><h2>'.$survey_data['survey_title'].'</h2></div>';
if (!empty($survey_data['survey_subtitle'])) {
echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>';
}
// Displaying the survey introduction
if (!isset($_GET['show'])) {
if (!empty($survey_data['survey_introduction'])) {
echo '<div class="survey_content">'.$survey_data['survey_introduction'].'</div>';
}
}
// Survey information
echo '<div class="page-header"><h2>'.$survey_data['survey_title'].'</h2></div>';
if (!empty($survey_data['survey_subtitle'])) {
echo '<div id="survey_subtitle">'.$survey_data['survey_subtitle'].'</div>';
}
// Displaying the survey thanks message
if (isset($_POST['finish_survey'])) {
echo Display::return_message(get_lang('SurveyFinished'), 'confirm');
echo $survey_data['survey_thanks'];
Display::display_footer();
exit;
// Displaying the survey introduction
if (!isset($_GET['show'])) {
if (!empty($survey_data['survey_introduction'])) {
echo '<div class="survey_content">'.$survey_data['survey_introduction'].'</div>';
}
}
$questions = [];
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.
// as long as there is no pagebreak fount we keep adding questions to the page
$questions_displayed = [];
$paged_questions = [];
$counter = 0;
$sql = "SELECT * FROM $table_survey_question
WHERE
survey_question NOT LIKE '%{{%' AND
c_id = $course_id AND
survey_id = '".$surveyId."'
ORDER BY sort ASC";
$result = Database::query($sql);
$questions_exists = true;
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result)) {
if ($survey_data['one_question_per_page'] == 1) {
if ($row['type'] != 'pagebreak') {
$paged_questions[$counter][] = $row['question_id'];
$counter++;
continue;
}
} else {
if ($row['type'] == 'pagebreak') {
$counter++;
} else {
$paged_questions[$counter][] = $row['question_id'];
}
}
}
} else {
$questions_exists = false;
}
if (array_key_exists($_GET['show'], $paged_questions)) {
$sql = "SELECT
survey_question.question_id,
survey_question.survey_id,
survey_question.survey_question,
survey_question.display,
survey_question.sort,
survey_question.type,
survey_question.max_value,
survey_question_option.question_option_id,
survey_question_option.option_text,
survey_question_option.sort as option_sort
".($allowRequiredSurveyQuestions ? ', survey_question.is_required' : '')."
FROM $table_survey_question survey_question
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 = $course_id
WHERE
survey_question.survey_id = '".$surveyId."' AND
survey_question.question_id IN (".Database::escape_string(implode(',', $paged_questions[$_GET['show']]), null, false).") AND
survey_question.c_id = $course_id AND
survey_question NOT LIKE '%{{%'
ORDER BY survey_question.sort, survey_question_option.sort ASC";
// Displaying the survey thanks message
if (isset($_POST['finish_survey'])) {
echo Display::return_message(get_lang('SurveyFinished'), 'confirm');
echo $survey_data['survey_thanks'];
Display::display_footer();
exit;
}
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
// If the type is not a pagebreak we store it in the $questions array
$questions = [];
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.
// as long as there is no pagebreak fount we keep adding questions to the page
$questions_displayed = [];
$paged_questions = [];
$counter = 0;
$sql = "SELECT * FROM $table_survey_question
WHERE
survey_question NOT LIKE '%{{%' AND
c_id = $course_id AND
survey_id = '".$surveyId."'
ORDER BY sort ASC";
$result = Database::query($sql);
$questions_exists = true;
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result)) {
if ($survey_data['one_question_per_page'] == 1) {
if ($row['type'] != 'pagebreak') {
$sort = $row['sort'];
$questions[$sort]['question_id'] = $row['question_id'];
$questions[$sort]['survey_id'] = $row['survey_id'];
$questions[$sort]['survey_question'] = $row['survey_question'];
$questions[$sort]['display'] = $row['display'];
$questions[$sort]['type'] = $row['type'];
//$questions[$sort]['options'][intval($row['option_sort'])] = $row['option_text'];
$questions[$sort]['options'][$row['question_option_id']] = $row['option_text'];
$questions[$sort]['maximum_score'] = $row['max_value'];
$questions[$row['sort']]['is_required'] = $allowRequiredSurveyQuestions && $row['is_required'];
$paged_questions[$counter][] = $row['question_id'];
$counter++;
continue;
}
} else {
if ($row['type'] == 'pagebreak') {
$counter++;
} else {
// If the type is a pagebreak we are finished loading the questions for this page
//break;
$paged_questions[$counter][] = $row['question_id'];
}
$counter_question++;
}
}
} else {
$questions_exists = false;
}
$before = 0;
if (isset($_GET['show']) && isset($paged_questions[$_GET['show'] - 1])) {
$before = count($paged_questions[$_GET['show'] - 1]);
}
$numberOfPages = SurveyManager::getCountPages($survey_data);
if (array_key_exists($_GET['show'], $paged_questions)) {
$sql = "SELECT
survey_question.question_id,
survey_question.survey_id,
survey_question.survey_question,
survey_question.display,
survey_question.sort,
survey_question.type,
survey_question.max_value,
survey_question_option.question_option_id,
survey_question_option.option_text,
survey_question_option.sort as option_sort
".($allowRequiredSurveyQuestions ? ', survey_question.is_required' : '')."
FROM $table_survey_question survey_question
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
WHERE
survey_question.survey_id = '".$surveyId."' AND
survey_question.question_id IN (".Database::escape_string(implode(',', $paged_questions[$_GET['show']]), null, false).") AND
survey_question.c_id = $course_id AND
survey_question NOT LIKE '%{{%'
ORDER BY survey_question.sort, survey_question_option.sort ASC";
// Displaying the form with the questions
if (isset($_GET['show'])) {
$show = (int) $_GET['show'] + 1;
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
// If the type is not a pagebreak we store it in the $questions array
if ($row['type'] != 'pagebreak') {
$sort = $row['sort'];
$questions[$sort]['question_id'] = $row['question_id'];
$questions[$sort]['survey_id'] = $row['survey_id'];
$questions[$sort]['survey_question'] = $row['survey_question'];
$questions[$sort]['display'] = $row['display'];
$questions[$sort]['type'] = $row['type'];
$questions[$sort]['options'][$row['question_option_id']] = $row['option_text'];
$questions[$sort]['maximum_score'] = $row['max_value'];
$questions[$row['sort']]['is_required'] = $allowRequiredSurveyQuestions && $row['is_required'];
}
}
}
$originalShow = isset($_GET['show']) ? (int) $_GET['show'] : 0;
}
$url = api_get_self().'?survey_id='.$surveyId.'&show='.$show.'&'.api_get_cidreq();
$form = new FormValidator(
'question-survey',
'post',
$url,
null,
null,
FormValidator::LAYOUT_INLINE
);
$before = 0;
if (isset($_GET['show']) && isset($paged_questions[$_GET['show'] - 1])) {
$before = count($paged_questions[$_GET['show'] - 1]);
}
if (is_array($questions) && count($questions) > 0) {
$counter = 1;
if (!empty($originalShow)) {
$before = 0;
foreach ($paged_questions as $keyQuestion => $list) {
if ($originalShow > $keyQuestion) {
$before += count($list);
}
$numberOfPages = SurveyManager::getCountPages($survey_data);
// Displaying the form with the questions
if (isset($_GET['show'])) {
$show = (int) $_GET['show'] + 1;
}
$originalShow = isset($_GET['show']) ? (int) $_GET['show'] : 0;
$url = api_get_self().'?survey_id='.$surveyId.'&show='.$show.'&'.api_get_cidreq();
$form = new FormValidator(
'question-survey',
'post',
$url,
null,
null,
FormValidator::LAYOUT_INLINE
);
if (is_array($questions) && count($questions) > 0) {
$counter = 1;
if (!empty($originalShow)) {
$before = 0;
foreach ($paged_questions as $keyQuestion => $list) {
if ($originalShow > $keyQuestion) {
$before += count($list);
}
$counter = $before + 1;
}
foreach ($questions as $key => &$question) {
$ch_type = 'ch_'.$question['type'];
/** @var survey_question $display */
$display = new $ch_type();
$form->addHtml('<div class="survey_question '.$ch_type.'">');
$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>');
$counter++;
}
$counter = $before + 1;
}
$form->addHtml('<div class="start-survey">');
foreach ($questions as $key => &$question) {
$ch_type = 'ch_'.$question['type'];
/** @var survey_question $display */
$display = new $ch_type();
$form->addHtml('<div class="survey_question '.$ch_type.'">');
$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>');
$counter++;
}
}
$form->addHtml('<div class="start-survey">');
if ($show < $numberOfPages) {
if ($show == 0) {
$form->addButton(
'next_survey_page',
get_lang('StartSurvey'),
'arrow-right',
'success'
);
} else {
$form->addButton(
'next_survey_page',
get_lang('NextQuestion'),
'arrow-right',
'success'
);
}
if ($show < $numberOfPages) {
if ($show == 0) {
$form->addButton(
'next_survey_page',
get_lang('StartSurvey'),
'arrow-right',
'success'
);
} else {
$form->addButton(
'next_survey_page',
get_lang('NextQuestion'),
'arrow-right',
'success'
);
}
}
if ($show >= $numberOfPages && isset($_GET['show']) ||
(isset($_GET['show']) && count($questions) == 0)
) {
if (isset($_GET['show'])) {
if ($show >= $numberOfPages || count($questions) == 0) {
if ($questions_exists == false) {
echo '<p>'.get_lang('ThereAreNotQuestionsForthisSurvey').'</p>';
}
@ -281,18 +231,15 @@ if (api_is_course_admin() ||
'success'
);
}
$form->addHtml('</div>');
$form->display();
if ($courseInfo) {
echo Display::toolbarButton(
get_lang('ReturnToCourseHomepage'),
api_get_course_url($courseInfo['code']),
'home'
);
}
} else {
echo Display::return_message(get_lang('NotAllowed'), 'error', false);
}
$form->addHtml('</div>');
$form->display();
echo Display::toolbarButton(
get_lang('ReturnToCourseHomepage'),
api_get_course_url($courseInfo['code']),
'home'
);
Display::display_footer();

@ -103,13 +103,11 @@ if (!in_array($_GET['type'], $possible_types)) {
Display::display_footer();
}
$error_message = '';
// Displaying the form for adding or editing the question
$ch_type = 'ch_'.$_GET['type'];
/** @var survey_question $surveyQuestion */
$surveyQuestion = new $ch_type();
//$surveyQuestion = survey_question::createQuestion($_GET['type'])
// The defaults values for the form
$formData = [];

@ -3732,70 +3732,6 @@ class SurveyUtil
return $field_list_array;
}
/**
* @author Isaac Flores Paz <florespaz@bidsoftperu.com>
*
* @param int $user_id User ID
* @param string $survey_code
* @param int $user_answer User in survey answer table (user id or anonymous)
*
* @return bool
*/
public static function show_link_available($user_id, $survey_code, $user_answer)
{
$table_survey = Database::get_course_table(TABLE_SURVEY);
$table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$survey_code = Database::escape_string($survey_code);
$user_id = (int) $user_id;
$user_answer = Database::escape_string($user_answer);
$course_id = api_get_course_int_id();
$sql = 'SELECT COUNT(*) as count
FROM '.$table_survey_invitation.'
WHERE
user='.$user_id.' AND
survey_code="'.$survey_code.'" AND
answered="1" AND
c_id = '.$course_id;
$sql2 = 'SELECT COUNT(*) as count
FROM '.$table_survey.' s
INNER JOIN '.$table_survey_question.' q
ON s.survey_id=q.survey_id AND s.c_id = q.c_id
WHERE
s.code="'.$survey_code.'" AND
q.type NOT IN("pagebreak","comment") AND
s.c_id = '.$course_id.' AND q.c_id = '.$course_id.' ';
$sql3 = 'SELECT COUNT(DISTINCT question_id) as count
FROM '.$table_survey_answer.'
WHERE survey_id=(
SELECT survey_id FROM '.$table_survey.'
WHERE
code = "'.$survey_code.'" AND
c_id = '.$course_id.'
) AND
user="'.$user_answer.'" AND
c_id = '.$course_id;
$result = Database::query($sql);
$result2 = Database::query($sql2);
$result3 = Database::query($sql3);
$row = Database::fetch_array($result, 'ASSOC');
$row2 = Database::fetch_array($result2, 'ASSOC');
$row3 = Database::fetch_array($result3, 'ASSOC');
if ($row['count'] == 1 && $row3['count'] != $row2['count']) {
return true;
} else {
return false;
}
}
/**
* Display survey question chart.
*

@ -113,16 +113,6 @@ $htmlHeadXtra[] = '<script>
var email = '.js_array($types, 'email', 'email').
'</script>';
/**
* @param $s
*
* @return string
*/
function js_str($s)
{
return '"'.addcslashes($s, "\0..\37\"\\").'"';
}
/**
* @param $array
* @param $name

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\UserBundle\Entity\User;
/**
* @package chamilo.webservices
*/

@ -58,6 +58,32 @@ try {
$messages = $restApi->getUserMessages($lastMessageId);
$restResponse->setData($messages);
break;
case Rest::POST_USER_MESSAGE_READ:
case Rest::POST_USER_MESSAGE_UNREAD:
$messagesId = isset($_POST['messages']) && is_array($_POST['messages'])
? array_map('intval', $_POST['messages'])
: [];
$messagesId = array_filter($messagesId);
if (empty($messagesId)) {
throw new Exception(get_lang('NoData'));
}
$messageStatus = $action === Rest::POST_USER_MESSAGE_READ ? MESSAGE_STATUS_NEW : MESSAGE_STATUS_UNREAD;
$data = array_flip($messagesId);
foreach ($messagesId as $messageId) {
$data[$messageId] = MessageManager::update_message_status(
$restApi->getUser()->getId(),
$messageId,
$messageStatus
);
}
$restResponse->setData($data);
break;
case Rest::GET_USER_COURSES:
$courses = $restApi->getUserCourses();
$restResponse->setData($courses);

@ -2994,7 +2994,7 @@ function getAllDocumentsFromWorkToString($workId, $courseInfo)
foreach ($documents as $doc) {
$docData = DocumentManager::get_document_data_by_id($doc['document_id'], $courseInfo['code']);
if ($docData) {
$content .= '<li><a target="_blank" href="'.$docData['url'].'">'.$docData['title'].'</a></li>';
$content .= '<li><a class="link_to_download" target="_blank" href="'.$docData['url'].'">'.$docData['title'].'</a></li>';
}
}
$content .= '</ul><br />';
@ -3457,7 +3457,7 @@ function addWorkComment($courseInfo, $userId, $parentWork, $work, $data)
}
}
$sendNotification = api_get_course_setting('email_to_teachers_on_new_work_feedback', api_get_course_id());
$sendNotification = api_get_course_setting('email_to_teachers_on_new_work_feedback');
if ($sendNotification != 1) {
$userIdListToSend = [];
}

@ -11,7 +11,7 @@ api_protect_course_script(true);
require_once 'work.lib.php';
$this_section = SECTION_COURSES;
$workId = isset($_GET['id']) ? intval($_GET['id']) : null;
$workId = isset($_GET['id']) ? (int) $_GET['id'] : null;
$courseInfo = api_get_course_info();
if (empty($workId) || empty($courseInfo)) {
@ -20,7 +20,7 @@ if (empty($workId) || empty($courseInfo)) {
// Student publications are saved with the iid in a LP
$origin = api_get_origin();
if ($origin == 'learnpath') {
if ($origin === 'learnpath') {
$em = Database::getManager();
/** @var CStudentPublication $work */
$work = $em->getRepository('ChamiloCourseBundle:CStudentPublication')->findOneBy(
@ -73,14 +73,12 @@ $onlyOnePublication = api_get_configuration_value('allow_only_one_student_public
if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_invitee()) {
$url = api_get_path(WEB_CODE_PATH).'work/upload.php?'.api_get_cidreq().'&id='.$workId;
$actionsRight = Display::url(
Display::return_icon(
'upload_file.png',
get_lang('UploadMyAssignment'),
null,
ICON_SIZE_MEDIUM
).get_lang('UploadMyAssignment'),
Display::returnFontAwesomeIcon(
' fa-upload'
).
get_lang('UploadMyAssignment'),
$url,
['class' => 'btn-toolbar']
['class' => 'btn btn-primary', 'id' => 'upload_button']
);
}
@ -107,10 +105,35 @@ if (!empty($my_folder_data['description'])) {
$content .= Display::panel($contentWork, get_lang('Description'));
}
$content .= workGetExtraFieldData($workId);
$extraFieldWorkData = workGetExtraFieldData($workId);
if (!empty($extraFieldWorkData)) {
$forceDownload = api_get_configuration_value('force_download_doc_before_upload_work');
if ($forceDownload) {
// Force to download documents first.
$downloadDocumentsFirst = addslashes(get_lang('DownloadDocumentsFirst'));
$content .= "<script>
$(function() {
var clicked = 0;
$('#upload_button').on('click', function(e) {
if (clicked == 0) {
alert('$downloadDocumentsFirst');
e.preventDefault();
}
});
$('.download_extra_field').on('click', function(e){
clicked = 1;
});
});
</script>";
}
}
$content .= $extraFieldWorkData;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$item_id = isset($_REQUEST['item_id']) ? intval($_REQUEST['item_id']) : null;
$item_id = isset($_REQUEST['item_id']) ? (int) $_REQUEST['item_id'] : null;
switch ($action) {
case 'delete':
@ -126,7 +149,7 @@ switch ($action) {
$result = getWorkDateValidationStatus($work_data);
$content .= $result['message'];
$check_qualification = intval($my_folder_data['qualification']);
$check_qualification = (int) $my_folder_data['qualification'];
if (!api_is_invitee()) {
if (!empty($work_data['enable_qualification']) && !empty($check_qualification)) {
@ -215,7 +238,7 @@ if (!api_is_invitee()) {
'width' => '60',
'align' => 'left',
'search' => 'false',
'wrap_cell' => "true",
'wrap_cell' => 'true',
],
[
'name' => 'qualification',
@ -260,7 +283,9 @@ if (!api_is_invitee()) {
</script>
';
$content .= getAllDocumentsFromWorkToString($workId, $courseInfo);
$documents = getAllDocumentsFromWorkToString($workId, $courseInfo);
$content .= $documents;
$tableWork = Display::grid_html('results');
$content .= Display::panel($tableWork);
}

@ -92,7 +92,7 @@ class bbb
// Course check
$courseInfo = api_get_course_info();
if ($courseInfo) {
$this->groupSupport = api_get_course_setting('bbb_enable_conference_in_groups', $courseInfo['code']) === '1';
$this->groupSupport = api_get_course_setting('bbb_enable_conference_in_groups', $courseInfo) === '1';
}
}
}

@ -133,7 +133,7 @@ if ($conferenceManager) {
if ($plugin->get('allow_regenerate_recording') !== 'true') {
api_not_allowed(true);
}
$allow = api_get_course_setting('bbb_force_record_generation', $courseCode) == 1 ? true : false;
$allow = api_get_course_setting('bbb_force_record_generation', $courseInfo) == 1 ? true : false;
if ($allow) {
$result = $bbb->getMeetingByRemoteId($_GET['remote_id']);
if (!empty($result)) {

@ -154,7 +154,7 @@
{{ 'CloseMeeting'|get_plugin_lang('BBBPlugin') }}
</a>
{% endif %}
{{ meeting.action_links }}
{{ meeting.action_links }}
</td>
{% endif %}

@ -233,7 +233,7 @@ class CustomCertificatePlugin extends Plugin
$courseCode = $row['course_code'];
$sessionId = $row['session_id'];
$userId = $row['user_id'];
if (api_get_course_setting('customcertificate_course_enable', $courseCode) == 1) {
if (api_get_course_setting('customcertificate_course_enable', api_get_course_info($courseCode)) == 1) {
return [
'course_code' => $courseCode,
'session_id' => $sessionId,

@ -32,8 +32,8 @@ if ($isDefault === 1) {
$courseId = api_get_course_int_id();
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
$enableCourse = api_get_course_setting('customcertificate_course_enable', $courseCode) == 1 ? true : false;
$useDefault = api_get_course_setting('use_certificate_default', $courseCode) == 1 ? true : false;
$enableCourse = api_get_course_setting('customcertificate_course_enable', $course_info) == 1 ? true : false;
$useDefault = api_get_course_setting('use_certificate_default', $course_info) == 1 ? true : false;
$defaultCertificate = 0;
$urlParams = '?'.api_get_cidreq();
}

@ -31,8 +31,8 @@ if ($default == 1) {
$courseId = api_get_course_int_id();
$courseCode = api_get_course_id();
$sessionId = api_get_session_id();
$enableCourse = api_get_course_setting('customcertificate_course_enable', $courseCode) == 1 ? true : false;
$useDefault = api_get_course_setting('use_certificate_default', $courseCode) == 1 ? true : false;
$enableCourse = api_get_course_setting('customcertificate_course_enable') == 1 ? true : false;
$useDefault = api_get_course_setting('use_certificate_default') == 1 ? true : false;
}
if (empty($courseCode)) {

@ -162,7 +162,7 @@ class RedirectionPlugin extends Plugin
{
// Check redirection plugin
$plugin = new AppPlugin();
$pluginList = $plugin->get_installed_plugins();
$pluginList = $plugin->getInstalledPlugins();
$redirectionInstalled = in_array('redirection', $pluginList);
if ($redirectionInstalled) {
$pluginInfo = $plugin->getPluginInfo('redirection');

@ -92,14 +92,8 @@ class StudentFollowUpPlugin extends Plugin
*/
public static function getPermissions($studentId, $currentUserId)
{
$params = ['variable = ? AND subkey = ?' => ['status', 'studentfollowup']];
$result = api_get_settings_params_simple($params);
$installed = false;
if (!empty($result) && $result['selected_value'] === 'installed') {
$installed = true;
}
if ($installed == false) {
$installed = AppPlugin::getInstance()->isInstalled('studentfollowup');
if ($installed === false) {
return [
'is_allow' => false,
'show_private' => false,
@ -187,8 +181,6 @@ class StudentFollowUpPlugin extends Plugin
switch ($status) {
case COURSEMANAGER:
/*$sessions = SessionManager::get_sessions_by_user($currentUserId);
$sessions = array_column($sessions, 'session_id');*/
$sessionsFull = SessionManager::getSessionsCoachedByUser($currentUserId);
$sessions = array_column($sessionsFull, 'id');
if (!empty($sessionId)) {
@ -229,19 +221,6 @@ class StudentFollowUpPlugin extends Plugin
$limit
);
/*$userList = [];
foreach ($sessions as $sessionId) {
foreach ($courses as $courseId) {
$courseInfo = ['real_id' => $courseId];
$userFromSessionList = SessionManager::getUsersByCourseSession(
$sessionId,
$courseInfo
);
$userList = array_merge($userList, $userFromSessionList);
}
$userList = array_unique($userList);
}*/
return [
'users' => $userList,
'sessions' => $sessionsFull,

Loading…
Cancel
Save