Update from 1.11.x

pull/3063/head
Julio Montoya 7 years ago
parent 387a330fc0
commit fd8ba446cc
  1. 7
      main/course_info/about.php
  2. 126
      main/cron/import_csv.php
  3. 27
      main/document/document_quota.php
  4. 9
      main/document/document_slideshow.inc.php
  5. 2
      main/document/edit_odf.php
  6. 5
      main/document/show_content.php
  7. 165
      main/document/slideshow.php
  8. 28
      main/dropbox/index.php
  9. 24
      main/exercise/export/aiken/aiken_import.inc.php
  10. 14
      main/inc/ajax/course_home.ajax.php
  11. 212
      main/inc/lib/MailTemplateManager.php
  12. 26
      main/inc/lib/agenda.lib.php
  13. 74
      main/inc/lib/auth.lib.php
  14. 9
      main/inc/lib/banner.lib.php
  15. 4
      main/inc/lib/course.lib.php
  16. 1
      main/inc/lib/course_description.lib.php
  17. 124
      main/inc/lib/course_home.lib.php
  18. 50
      main/inc/lib/display.lib.php
  19. 3
      main/inc/lib/document.lib.php
  20. 1
      main/inc/lib/exercise.lib.php
  21. 11
      main/inc/lib/formvalidator/Element/DateRangePicker.php
  22. 13
      main/inc/lib/formvalidator/Element/HtmlEditor.php
  23. 11
      main/inc/lib/formvalidator/FormValidator.class.php
  24. 25
      main/inc/lib/javascript/jquery.nocopypaste.js
  25. 37
      main/inc/lib/javascript/readout_text/css/start.css
  26. 76
      main/inc/lib/javascript/readout_text/js/start.js
  27. 21
      main/inc/lib/pear/HTML/Common.php
  28. 6
      main/inc/lib/pear/HTML/QuickForm.php
  29. 1
      main/inc/lib/pear/HTML/QuickForm/Renderer.php
  30. 3
      main/inc/lib/pear/HTML/QuickForm/advanced_settings.php
  31. 6
      main/inc/lib/pear/HTML/QuickForm/advmultiselect.php
  32. 91
      main/inc/lib/pear/HTML/QuickForm/element.php
  33. 25
      main/inc/lib/pear/HTML/QuickForm/input.php
  34. 10
      main/inc/lib/pear/HTML/QuickForm/label.php
  35. 4
      main/inc/lib/pear/HTML/QuickForm/link.php
  36. 8
      main/inc/lib/pear/HTML/QuickForm/reset.php
  37. 30
      main/inc/lib/pear/HTML/QuickForm/static.php
  38. 10
      main/inc/lib/pear/HTML/QuickForm/submit.php
  39. 31
      main/inc/lib/pear/HTML/QuickForm/textarea.php
  40. 2
      main/inc/lib/template.lib.php
  41. 303
      main/inc/lib/tracking.lib.php
  42. 57
      main/inc/lib/usermanager.lib.php
  43. 31
      main/inc/lib/userportal.lib.php
  44. 23
      main/lp/embed.php
  45. 1117
      main/lp/learnpath.class.php
  46. 114
      main/lp/learnpathItem.class.php
  47. 3
      main/lp/lp_add_audio.php
  48. 25
      main/lp/lp_add_item.php
  49. 3
      main/lp/lp_admin_view.php
  50. 34
      main/lp/lp_ajax_save_item.php
  51. 3
      main/lp/lp_build.php
  52. 6
      main/lp/lp_content.php
  53. 128
      main/lp/lp_controller.php
  54. 21
      main/lp/lp_edit.php
  55. 2
      main/lp/lp_edit_item.php
  56. 3
      main/lp/lp_edit_item_prereq.php
  57. 127
      main/lp/lp_list.php
  58. 4
      main/lp/lp_upload.php
  59. 4
      main/lp/lp_view.php
  60. 3
      main/lp/lp_view_item.php
  61. 99
      main/lp/scorm_api.php
  62. 11
      main/mySpace/session.php
  63. 2
      main/social/my_skills_report.php
  64. 2
      main/social/profile.php
  65. 33
      main/template/default/agenda/month.tpl
  66. 4
      main/template/default/auth/session_catalog.tpl
  67. 39
      main/template/default/learnpath/list.tpl
  68. 8
      main/template/default/learnpath/scorm_list.tpl
  69. 83
      main/template/default/learnpath/view.tpl
  70. 2
      main/template/default/social/home.tpl
  71. 10
      main/ticket/assign_tickets.php
  72. 2
      main/ticket/categories.php
  73. 2
      main/ticket/categories_add_user.php
  74. 4
      main/ticket/course_user_list.php
  75. 2
      main/ticket/download.php
  76. 18
      main/ticket/new_ticket.php
  77. 6
      main/ticket/projects.php
  78. 1
      main/ticket/report.php
  79. 6
      main/ticket/status.php
  80. 2
      main/ticket/ticket_assign_log.php
  81. 36
      main/ticket/ticket_details.php
  82. 4
      main/ticket/tutor_report.lib.php
  83. 10
      main/ticket/update_report.php
  84. 233
      main/tracking/courseLog.php
  85. 36
      main/tracking/messages.php
  86. 1
      main/tracking/total_time.php
  87. 52
      main/user/subscribe_user.php
  88. 4
      main/webservices/registration.soap.php
  89. 2
      main/wiki/wiki.inc.php
  90. 15
      main/work/add_document.php
  91. 6
      main/work/edit.php
  92. 6
      main/work/edit_work.php
  93. 13
      main/work/upload.php
  94. 11
      main/work/view.php
  95. 105
      main/work/work.lib.php
  96. 9
      main/work/work.php
  97. 12
      main/work/work_list.php
  98. 14
      main/work/work_list_all.php

@ -125,6 +125,10 @@ $topics = [
$subscriptionUser = CourseManager::is_user_subscribed_in_course($userId, $course->getCode());
$allowSubscribe = false;
if ($course->getSubscribe() == true || api_is_platform_admin()) {
$allowSubscribe = true;
}
$plugin = BuyCoursesPlugin::create();
$checker = $plugin->isEnabled();
$courseIsPremium = null;
@ -154,7 +158,7 @@ $courseItem = [
$metaInfo = '<meta property="og:url" content="'.$urlCourse.'" />';
$metaInfo .= '<meta property="og:type" content="website" />';
$metaInfo .= '<meta property="og:title" content="'.$courseItem['title'].'" />';
$metaInfo .= '<meta property="og:description" content="'.$courseDescription.'" />';
$metaInfo .= '<meta property="og:description" content="'.strip_tags($courseDescription).'" />';
$metaInfo .= '<meta property="og:image" content="'.$courseItem['image'].'" />';
$htmlHeadXtra[] = $metaInfo;
@ -165,6 +169,7 @@ $template->assign('course', $courseItem);
$essence = Essence\Essence::instance();
$template->assign('essence', $essence);
$template->assign('is_premium', $courseIsPremium);
$template->assign('allow_subscribe', $allowSubscribe);
$template->assign('token', $token);
$template->assign('url', $urlCourse);
$layout = $template->get_template('course_home/about.tpl');

@ -127,6 +127,8 @@ class ImportCsv
$teacherBackup = [];
$groupBackup = [];
$this->prepareImport();
if (!empty($files)) {
foreach ($files as $file) {
$fileInfo = pathinfo($file);
@ -156,6 +158,10 @@ class ImportCsv
$method = 'importCareersDiagram';
}
if ($method == 'importOpensessions') {
$method = 'importOpenSessions';
}
if ($method == 'importSubsessionsextidStatic') {
$method = 'importSubscribeUserToCourseSessionExtStatic';
}
@ -193,13 +199,12 @@ class ImportCsv
return 0;
}
$this->prepareImport();
$sections = [
'students',
'teachers',
'courses',
'sessions',
'opensessions',
'subscribe-static',
'courseinsert-static',
'unsubscribe-static',
@ -220,7 +225,7 @@ class ImportCsv
echo PHP_EOL;
$this->logger->addInfo("Reading file: $file");
$this->logger->addInfo("Loading method $method ");
if ($method == 'importSessions') {
if ($method == 'importSessions' || $method == 'importOpenSessions') {
$this->$method(
$file,
true,
@ -240,11 +245,11 @@ class ImportCsv
'teachers-static',
'courses-static',
'sessions-static',
'calendar-static',
'sessionsextid-static',
'unsubscribe-static',
'unsubsessionsextid-static',
'subsessionsextid-static',
'calendar-static',
];
foreach ($sections as $section) {
@ -453,6 +458,13 @@ class ImportCsv
''
);
CourseManager::create_course_extra_field(
'disable_import_calendar',
13,
'Disable import calendar',
''
);
// Create session extra field extra_external_session_id
SessionManager::create_session_extra_field(
$this->extraFieldIdNameList['session'],
@ -667,6 +679,10 @@ class ImportCsv
false //$send_mail = false
);
$row['extra_mail_notify_invitation'] = 1;
$row['extra_mail_notify_message'] = 1;
$row['extra_mail_notify_group_message'] = 1;
if ($userId) {
foreach ($row as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
@ -832,6 +848,10 @@ class ImportCsv
false //$send_mail = false
);
$row['extra_mail_notify_invitation'] = 1;
$row['extra_mail_notify_message'] = 1;
$row['extra_mail_notify_group_message'] = 1;
if ($result) {
foreach ($row as $key => $value) {
if (substr($key, 0, 6) === 'extra_') {
@ -1007,6 +1027,8 @@ class ImportCsv
$eventsToCreate = [];
$errorFound = false;
$courseExtraFieldValue = new ExtraFieldValue('course');
foreach ($data as $row) {
$sessionId = null;
$externalSessionId = null;
@ -1024,15 +1046,34 @@ class ImportCsv
}
$courseInfo = api_get_course_info($courseCode);
$item = $courseExtraFieldValue->get_values_by_handler_and_field_variable(
$courseInfo['real_id'],
'disable_import_calendar'
);
if (!empty($item) && isset($item['value']) && $item['value'] == 1) {
$this->logger->addInfo(
"Course '".$courseInfo['code']."' has 'disable_import_calendar' turn on. Skip"
);
$errorFound = true;
}
if (empty($courseInfo)) {
$this->logger->addInfo("Course '$courseCode' does not exists");
} else {
if ($courseInfo['visibility'] == COURSE_VISIBILITY_HIDDEN) {
$this->logger->addInfo("Course '".$courseInfo['code']."' has hidden visiblity. Skip");
$errorFound = true;
}
}
if (empty($sessionId)) {
$this->logger->addInfo("external_sessionID: ".$externalSessionId." does not exists.");
$this->logger->addInfo("external_sessionID: $externalSessionId does not exists.");
}
$teacherId = null;
$sessionInfo = [];
if (!empty($sessionId) && !empty($courseInfo)) {
$sessionInfo = api_get_session_info($sessionId);
$courseIncluded = SessionManager::relation_session_course_exist(
$sessionId,
$courseInfo['real_id']
@ -1054,7 +1095,6 @@ class ImportCsv
$teacher = current($teachers);
$teacherId = $teacher['user_id'];
} else {
$sessionInfo = api_get_session_info($sessionId);
$teacherId = $sessionInfo['id_coach'];
}
}
@ -1080,16 +1120,29 @@ class ImportCsv
$startDateMonth = substr($date, 4, 2);
$startDateDay = substr($date, 6, 8);
$startDate = $startDateYear.'-'.$startDateMonth.'-'.$startDateDay.' '.$startTime.":00";
$endDate = $startDateYear.'-'.$startDateMonth.'-'.$startDateDay.' '.$endTime.":00";
$startDate = $startDateYear.'-'.$startDateMonth.'-'.$startDateDay.' '.$startTime.':00';
$endDate = $startDateYear.'-'.$startDateMonth.'-'.$startDateDay.' '.$endTime.':00';
if (!api_is_valid_date($startDate) || !api_is_valid_date($endDate)) {
$this->logger->addInfo(
"Verify your dates: '$startDate' : '$endDate' "
);
$this->logger->addInfo("Verify your dates: '$startDate' : '$endDate' ");
$errorFound = true;
}
// Check session dates
if ($sessionInfo && !empty($sessionInfo['access_start_date'])) {
$date = new \DateTime($sessionInfo['access_start_date']);
$interval = new \DateInterval('P7D');
$date->sub($interval);
if ($date->getTimestamp() > time()) {
$this->logger->addInfo(
"Calendar event # ".$row['external_calendar_itemID']."
in session [$externalSessionId] was not added
because the startdate is more than 7 days in the future: ".$sessionInfo['access_start_date']
);
$errorFound = true;
}
}
if ($errorFound == false) {
$eventsToCreate[] = [
'start' => $startDate,
@ -1107,7 +1160,7 @@ class ImportCsv
}
if (empty($eventsToCreate)) {
$this->logger->addInfo("No events to add");
$this->logger->addInfo('No events to add');
return 0;
}
@ -1117,9 +1170,7 @@ class ImportCsv
$externalEventId = null;
$extraField = new ExtraField('calendar_event');
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable(
$extraFieldName
);
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable($extraFieldName);
if (empty($extraFieldInfo)) {
$this->logger->addInfo(
@ -1379,6 +1430,12 @@ class ImportCsv
$this->logger->addInfo(
"Mail to be sent because start date: ".$event['start']." and no announcement found."
);
$senderId = $this->defaultAdminId;
if (!empty($coaches) && isset($coaches[0]) && !empty($coaches[0])) {
$senderId = $coaches[0];
}
$announcementId = AnnouncementManager::add_announcement(
$courseInfo,
$event['session_id'],
@ -1392,12 +1449,12 @@ class ImportCsv
null,
null,
false,
$this->defaultAdminId
$senderId
);
if ($announcementId) {
$this->logger->addInfo("Announcement added: ".(int) ($announcementId)." in $info");
$this->logger->addInfo("<<--SENDING MAIL-->>");
$this->logger->addInfo("Announcement added: $announcementId in $info");
$this->logger->addInfo("<<--SENDING MAIL Sender id: $senderId-->>");
$report['mail_sent']++;
AnnouncementManager::sendEmail(
$courseInfo,
@ -1406,11 +1463,11 @@ class ImportCsv
false,
false,
$this->logger,
$this->defaultAdminId
$senderId
);
} else {
$this->logger->addError(
"Error when trying to add announcement with title ".$subject." here: $info"
"Error when trying to add announcement with title $subject here: $info and SenderId = $senderId"
);
}
} else {
@ -2186,6 +2243,21 @@ class ImportCsv
}
}
/**
* @param $file
* @param bool $moveFile
* @param array $teacherBackup
* @param array $groupBackup
*/
private function importOpenSessions(
$file,
$moveFile = true,
&$teacherBackup = [],
&$groupBackup = []
) {
$this->importSessions($file, $moveFile, $teacherBackup, $groupBackup);
}
/**
* @param string $file
* @param bool $moveFile
@ -2347,7 +2419,7 @@ class ImportCsv
$userCourseCategory = $courseUserData['user_course_cat'];
}
CourseManager::subscribeUser(
$result = CourseManager::subscribeUser(
$userId,
$courseInfo['code'],
$status,
@ -2355,9 +2427,15 @@ class ImportCsv
$userCourseCategory
);
$this->logger->addInfo(
"User $userId added to course ".$courseInfo['code']." with status '$status' with course category: '$userCourseCategory'"
);
if ($result) {
$this->logger->addInfo(
"User $userId added to course ".$courseInfo['code']." with status '$status' with course category: '$userCourseCategory'"
);
} else {
$this->logger->addInfo(
"User $userId was NOT ADDED to course ".$courseInfo['code']." with status '$status' with course category: '$userCourseCategory'"
);
}
}
}

@ -75,14 +75,17 @@ if (!empty($group_list)) {
$group_data['name'] = $group_data['name'].' * ';
}
$used_quota_bytes += $quota_bytes;
$session[] = [addslashes(get_lang('Group').': '.$group_data['name']).' ('.format_file_size($quota_bytes).')', $quota_percentage];
$session[] = [
addslashes(get_lang('Group').': '.$group_data['name']).' ('.format_file_size($quota_bytes).')',
$quota_percentage,
];
}
}
// Showing weight of documents uploaded by user
$document_list = DocumentManager::getAllDocumentData($_course);
$document_list = DocumentManager::getAllDocumentData(api_get_course_info());
if (!empty($document_list)) {
foreach ($document_list as $document_data) {
if ($document_data['insert_user_id'] == api_get_user_id() && $document_data['filetype'] == 'file') {
if ($document_data['insert_user_id'] == api_get_user_id() && $document_data['filetype'] === 'file') {
$quota_bytes += $document_data['size'];
}
}
@ -90,7 +93,10 @@ if (!empty($document_list)) {
$quota_percentage = round($quota_bytes / $total_quota_bytes, 2) * 100;
}
$session[] = [addslashes(get_lang('Teacher').': '.$user_name).' ('.format_file_size($quota_bytes).')', $quota_percentage];
$session[] = [
addslashes(get_lang('Teacher').': '.$user_name).' ('.format_file_size($quota_bytes).')',
$quota_percentage,
];
//if a sesson is active
if ($session_id != 0) {
if (!empty($course_list)) {
@ -110,11 +116,15 @@ if (!empty($document_list)) {
}
$quota_percentage = round(($total_quota_bytes - $used_quota_bytes) / $total_quota_bytes, 2) * 100;
$session[] = [addslashes(get_lang('ShowCourseQuotaUse')).' ('.format_file_size($total_quota_bytes - $used_quota_bytes).') ', $quota_percentage];
$session[] = [
addslashes(get_lang('ShowCourseQuotaUse')).' ('.format_file_size(
$total_quota_bytes - $used_quota_bytes
).') ',
$quota_percentage,
];
$quota_data = json_encode($session);
$htmlHeadXtra[] = "
<script>
$htmlHeadXtra[] = "<script>
$(document).ready(function(){
var data = ".$quota_data.";
var plot1 = jQuery.jqplot ('chart1', [data], {
@ -128,8 +138,7 @@ $(document).ready(function(){
}
},
legend: { show:true, location: 'e' }
}
);
});
});
</script>";

@ -1,8 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This is a plugin for the documents tool. It looks for .jpg, .jpeg, .gif, .png
* files (since these are the files that can be viewed in a browser) and creates
@ -30,12 +28,6 @@ use ChamiloSession as Session;
* file into document.php
*/
// Resetting the images of the slideshow = destroying the slideshow
if (isset($_GET['action']) && $_GET['action'] == 'exit_slideshow') {
Session::write('image_files_only', null);
unset($image_files_only);
}
// We check if there are images in this folder by searching the extensions for .jpg, .gif, .png
// grabbing the list of all the documents of this folder
$array_to_search = !empty($documentAndFolders) && is_array($documentAndFolders) ? $documentAndFolders : [];
@ -68,7 +60,6 @@ if ($tablename_column == 0) {
}
$image_files_only = sort_files($array_to_search);
Session::write('image_files_only', $image_files_only);
function sort_files($table)
{

@ -27,7 +27,7 @@ if (empty($documentInfo)) {
//Check user visibility
$is_visible = DocumentManager::check_visibility_tree(
$documentId,
api_get_course_id(),
api_get_course_info(),
api_get_session_id(),
api_get_user_id(),
api_get_group_id()

@ -32,6 +32,7 @@ $document_data = DocumentManager::get_document_data_by_id(
true,
$session_id
);
if ($session_id != 0 && !$document_data) {
$document_data = DocumentManager::get_document_data_by_id(
$document_id,
@ -75,7 +76,7 @@ if ($is_allowed_in_course == false) {
// Check user visibility
$is_visible = DocumentManager::check_visibility_tree(
$document_id,
api_get_course_id(),
api_get_course_info(),
api_get_session_id(),
api_get_user_id(),
api_get_group_id()
@ -94,7 +95,7 @@ header('Last-Modified: Wed, 01 Jan 2100 00:00:00 GMT');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
$browser_display_title = 'Documents - '.Security::remove_XSS($_GET['cidReq']).' - '.$file;
$file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$header_file.'?'.api_get_cidreq();
$file_url_web = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/document'.$header_file.'?'.api_get_cidreq();
$pathinfo = pathinfo($header_file);
if ($pathinfo['extension'] == 'swf') {

@ -11,11 +11,15 @@ use ChamiloSession as Session;
* @package chamilo.document
*/
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
$path = Security::remove_XSS($_GET['curdirpath']);
$curdirpath = $path = isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : null;
$courseInfo = api_get_course_info();
$pathurl = urlencode($path);
$slide_id = isset($_GET['slide_id']) ? Security::remove_XSS($_GET['slide_id']) : null;
$document_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : null;
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
if (empty($slide_id)) {
$edit_slide_id = 1;
@ -31,21 +35,39 @@ if ($path != '/') {
$sys_course_path = api_get_path(SYS_COURSE_PATH);
// Breadcrumb navigation
$url = 'document.php?curdirpath='.$pathurl;
$url = 'document.php?curdirpath='.$pathurl.'&'.api_get_cidreq();
$originaltoolname = get_lang('Documents');
$_course = api_get_course_info();
$interbreadcrumb[] = ['url' => Security::remove_XSS($url), 'name' => $originaltoolname];
$originaltoolname = get_lang('SlideShow');
$sessionId = api_get_session_id();
$groupIid = 0;
$groupMemberWithEditRights = false;
// Setting group variables.
if (!empty($groupId)) {
$group_properties = GroupManager::get_group_properties($groupId);
$groupIid = isset($group_properties['iid']) ? $group_properties['iid'] : 0;
}
Display :: display_header($originaltoolname, 'Doc');
$imageFilesOnlySession = Session::read('image_files_only');
$image_files_only = [];
// Loading the slides from the session
if (!empty($imageFilesOnlySession)) {
$image_files_only = $imageFilesOnlySession;
Display::display_header($originaltoolname, 'Doc');
$slideshowKey = 'slideshow_'.api_get_course_id().api_get_session_id().$curdirpath;
$documentAndFolders = Session::read($slideshowKey);
if (empty($documentAndFolders)) {
$documentAndFolders = DocumentManager::getAllDocumentData(
$courseInfo,
$curdirpath,
$groupIid,
null,
$isAllowedToEdit,
false
);
Session::write($slideshowKey, $documentAndFolders);
}
require 'document_slideshow.inc.php';
// Calculating the current slide, next slide, previous slide and the number of slides
$slide = null;
if ($slide_id != 'all') {
@ -54,14 +76,8 @@ if ($slide_id != 'all') {
$next_slide = $slide + 1;
}
$total_slides = count($image_files_only);
?>
<script>
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
</script>
<div class="actions">
<?php
echo '<div class="actions">';
if ($slide_id != 'all') {
$image = null;
@ -70,14 +86,13 @@ if ($slide_id != 'all') {
}
if (file_exists($image)) {
echo '<div class="actions-pagination">';
// Back forward buttons
if ($slide == 0) {
$imgp = 'action_prev_na.png';
$first = Display::return_icon('action_first_na.png');
} else {
$imgp = 'action_prev.png';
$first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'">
$first = '<a href="slideshow.php?slide_id=0&curdirpath='.$pathurl.'&'.api_get_cidreq().'">
'.Display::return_icon('action_first.png', get_lang('FirstSlide')).'
</a>';
}
@ -87,10 +102,11 @@ if ($slide_id != 'all') {
// Previous slide
if ($slide > 0) {
echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'">';
echo '<a href="slideshow.php?slide_id='.$previous_slide.'&curdirpath='.$pathurl.'&'.api_get_cidreq().'">';
}
echo Display::return_icon($imgp, get_lang('Previous'));
if ($slide > 0) {
echo '</a>';
}
@ -100,14 +116,14 @@ if ($slide_id != 'all') {
// Next slide
if ($slide < $total_slides - 1) {
echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'">';
echo '<a href="slideshow.php?slide_id='.$next_slide.'&curdirpath='.$pathurl.'&'.api_get_cidreq().'">';
}
if ($slide == $total_slides - 1) {
$imgn = 'action_next_na.png';
$last = Display::return_icon('action_last_na.png', get_lang('LastSlide'));
} else {
$imgn = 'action_next.png';
$last = '<a href="slideshow.php?slide_id='.($total_slides - 1).'&curdirpath='.$pathurl.'">
$last = '<a href="slideshow.php?slide_id='.($total_slides - 1).'&curdirpath='.$pathurl.'&'.api_get_cidreq().'">
'.Display::return_icon('action_last.png', get_lang('LastSlide')).'
</a>';
}
@ -122,9 +138,10 @@ if ($slide_id != 'all') {
}
}
// Exit the slideshow
echo '<a href="document.php?action=exit_slideshow&curdirpath='.$pathurl.'&'.api_get_cidreq().'">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
echo Display::url(
Display::return_icon('folder_up.png', get_lang('Up'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&id='.$document_id
);
// Show thumbnails
if ($slide_id != 'all') {
@ -136,17 +153,15 @@ if ($slide_id != 'all') {
// Slideshow options
echo '<a href="slideshowoptions.php?curdirpath='.$pathurl.'&'.api_get_cidreq().'">'.
Display::return_icon('settings.png', get_lang('SetSlideshowOptions'), '', ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
echo '<br />';
/* TREATING THE POST DATA FROM SLIDESHOW OPTIONS */
// If we come from slideshowoptions.php we sessionize (new word !!! ;-) the options
if (isset($_POST['Submit'])) {
// We come from slideshowoptions.php
Session::write('image_resizing', Security::remove_XSS($_POST['radio_resizing']));
if ($_POST['radio_resizing'] == "resizing" && $_POST['width'] != '' && $_POST['height'] != '') {
if ($_POST['radio_resizing'] == 'resizing' && $_POST['width'] != '' && $_POST['height'] != '') {
Session::write('image_resizing_width', Security::remove_XSS($_POST['width']));
Session::write('image_resizing_height', Security::remove_XSS($_POST['height']));
} else {
@ -154,6 +169,7 @@ if (isset($_POST['Submit'])) {
Session::write('image_resizing_height', null);
}
}
$target_width = $target_height = null;
$imageResize = Session::read('image_resizing');
// The target height and width depends if we choose resizing or no resizing
@ -236,25 +252,31 @@ if ($slide_id == 'all') {
$crop = imagecreatetruecolor($new_thumbnail_size['width'], $new_thumbnail_size['height']);
// preserve transparency
if ($imagetype == "png") {
if ($imagetype == 'png') {
imagesavealpha($crop, true);
$color = imagecolorallocatealpha($crop, 0x00, 0x00, 0x00, 127);
imagefill($crop, 0, 0, $color);
}
if ($imagetype == "gif") {
if ($imagetype == 'gif') {
$transindex = imagecolortransparent($source_img);
$palletsize = imagecolorstotal($source_img);
//GIF89a for transparent and anim (first clip), either GIF87a
if ($transindex >= 0 && $transindex < $palletsize) {
$transcol = imagecolorsforindex($source_img, $transindex);
$transindex = imagecolorallocatealpha($crop, $transcol['red'], $transcol['green'], $transcol['blue'], 127);
$transindex = imagecolorallocatealpha(
$crop,
$transcol['red'],
$transcol['green'],
$transcol['blue'],
127
);
imagefill($crop, 0, 0, $transindex);
imagecolortransparent($crop, $transindex);
}
}
//resampled image
// Resampled image
imagecopyresampled(
$crop,
$source_img,
@ -291,12 +313,22 @@ if ($slide_id == 'all') {
$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_thumbnail_file : $path.$one_image_thumbnail_file;
$image_tag[] = '<img class="img-gallery" src="download.php?doc_url='.$doc_url.'" border="0" title="'.$one_image_file.'">';
} else {
//if images aren't support by gd (not gif, jpg, jpeg, png)
if ($imagetype == "bmp") {
// use getimagesize instead api_getimagesize($image); becasuse api_getimagesize doesn't support bmp files. Put here for each show, only for a few bmp files isn't heavy
// If images aren't support by gd (not gif, jpg, jpeg, png)
if ($imagetype == 'bmp') {
// use getimagesize instead api_getimagesize($image);
// because api_getimagesize doesn't support bmp files.
// Put here for each show, only for a few bmp files isn't heavy
$original_image_size = getimagesize($image);
if ($max_thumbnail_width < $original_image_size[0] || $max_thumbnail_height < $original_image_size[1]) {
$thumbnail_size = api_calculate_image_size($original_image_size[0], $original_image_size[1], $max_thumbnail_width, $max_thumbnail_height); //don't use resize_image because doesn't run with bmp files
if ($max_thumbnail_width < $original_image_size[0] ||
$max_thumbnail_height < $original_image_size[1]
) {
//don't use resize_image because doesn't run with bmp files
$thumbnail_size = api_calculate_image_size(
$original_image_size[0],
$original_image_size[1],
$max_thumbnail_width,
$max_thumbnail_height
);
$image_height = $thumbnail_size['height'];
$image_width = $thumbnail_size['width'];
} else {
@ -304,21 +336,23 @@ if ($slide_id == 'all') {
$image_width = $original_image_size[1];
}
} else {
//example for svg files,...
// Example for svg files,...
$image_width = $max_thumbnail_width;
$image_height = $max_thumbnail_height;
}
$doc_url = ($path && $path !== '/') ? $path.'/'.$one_image_file : $path.$one_image_file;
$image_tag[] = '<img src="download.php?doc_url='.$doc_url.'" border="0" width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">';
}//end allowed image types
}//end if exist file image
}//end foreach
}//end image files only
$image_tag[] = '<img
src="download.php?doc_url='.$doc_url.'"
border="0"
width="'.$image_width.'" height="'.$image_height.'" title="'.$one_image_file.'">';
}
}
}
}
// Creating the table
$html_table = '';
$i = 0;
$count_image = count($image_tag);
$number_iteration = ceil($count_image / $number_image);
@ -344,20 +378,19 @@ if ($slide_id == 'all') {
}
}
$html .= '</div>';
}//end slide==all
}
echo $html;
/* ONE AT A TIME VIEW */
$course_id = api_get_course_int_id();
// This is for viewing all the images in the slideshow one at a time.
if ($slide_id != 'all' && !empty($image_files_only)) {
if (file_exists($image) && is_file($image)) {
$image_height_width = DocumentManager::resizeImageSlideShow($image, $target_width, $target_height);
$image_height = $image_height_width[0];
$image_width = $image_height_width[1];
$height_width_tags = null;
if ($imageResize == 'resizing') {
$height_width_tags = 'width="'.$image_width.'" height="'.$image_height.'"';
@ -371,7 +404,9 @@ if ($slide_id != 'all' && !empty($image_files_only)) {
$pathpart = $path.'/';
}
$sql = "SELECT * FROM $tbl_documents
WHERE c_id = $course_id AND path='".Database::escape_string($pathpart.$image_files_only[$slide])."'";
WHERE
c_id = $course_id AND
path = '".Database::escape_string($pathpart.$image_files_only[$slide])."'";
$result = Database::query($sql);
$row = Database::fetch_array($result);
@ -381,6 +416,7 @@ if ($slide_id != 'all' && !empty($image_files_only)) {
} else {
echo "<a href='slideshow.php?slide_id=0&curdirpath=$pathurl'>";
}
if ($path == '/') {
$path = '';
}
@ -396,13 +432,13 @@ if ($slide_id != 'all' && !empty($image_files_only)) {
var width = window.innerWidth -360;
if (initial_height>height || initial_width>width) {
start_width=width;
start_height=height;
start_width = width;
start_height= height;
} else {
start_width=initial_width;
start_height=initial_height;
start_width = initial_width;
start_height = initial_height;
}
document.write('<img id="image" src="<?php echo 'download.php?doc_url='.$path.'/'.$image_files_only[$slide]; ?>" width="'+start_width+'" height="'+start_height+'" border="0" alt="<?php echo $image_files_only[$slide]; ?>">');
document.write('<img id="image" src="<?php echo 'download.php?doc_url='.$path.'/'.$image_files_only[$slide]; ?>" width="'+start_width+'" height="'+start_height+'" border="0" alt="<?php echo $image_files_only[$slide]; ?>">');
function resizeImage() {
var resize_factor_width = width / initial_width;
@ -413,12 +449,10 @@ if ($slide_id != 'all' && !empty($image_files_only)) {
if (delta_width > delta_height) {
width = Math.ceil(initial_width * resize_factor_height);
height= Math.ceil(initial_height * resize_factor_height);
}
else if(delta_width < delta_height) {
} else if(delta_width < delta_height) {
width = Math.ceil(initial_width * resize_factor_width);
height = Math.ceil(initial_height * resize_factor_width);
}
else {
} else {
width = Math.ceil(width);
height = Math.ceil(height);
}
@ -427,19 +461,21 @@ if ($slide_id != 'all' && !empty($image_files_only)) {
document.getElementById('image').style.width = width +"px";
document.getElementById('td_image').style.background='none';
document.getElementById('image').style.visibility='visible';
};
}
if (initial_height>height || initial_width>width) {
if (initial_height > height || initial_width > width) {
document.getElementById('image').style.visibility='hidden';
document.getElementById('td_image').style.background='url(<?php echo Display::returnIconPath('loadingAnimation.gif'); ?>) center no-repeat';
document.getElementById('image').onload = resizeImage;
window.onresize = resizeImage;
}
</script>
</script>
<?php
} else {
echo "<img class=\"img-responsive\" src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."' border='0'".$height_width_tags.">";
echo "<img
class=\"img-responsive\"
src='download.php?doc_url=$path/".$image_files_only[$slide]."' alt='".$image_files_only[$slide]."'
border='0'".$height_width_tags.'>';
}
echo '</a>';
@ -453,7 +489,6 @@ if ($slide_id != 'all' && !empty($image_files_only)) {
echo '<ul class="list-unstyled">';
$aux = explode('.', htmlspecialchars($image_files_only[$slide]));
$ext = $aux[count($aux) - 1];
if ($imageResize == 'resizing') {
$resize_info = get_lang('Resizing').'<br />';
$resize_width = Session::read('image_resizing_width').' x ';
@ -500,4 +535,4 @@ if ($slide_id != 'all' && !empty($image_files_only)) {
}
}
Display :: display_footer();
Display::display_footer();

@ -18,6 +18,7 @@ if (isset($_SESSION[$_course['id']]) &&
}
$postAction = isset($_POST['action']) ? $_POST['action'] : null;
$action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null;
$view = isset($_GET['view']) ? Security::remove_XSS($_GET['view']) : null;
$viewReceivedCategory = isset($_GET['view_received_category']) ? Security::remove_XSS($_GET['view_received_category']) : null;
$viewSentCategory = isset($_GET['view_sent_category']) ? Security::remove_XSS($_GET['view_sent_category']) : null;
@ -26,6 +27,14 @@ $showSentReceivedTabs = true;
// Do the tracking
Event::event_access_tool(TOOL_DROPBOX);
$logInfo = [
'tool' => TOOL_DROPBOX,
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => $action,
];
Event::registerLog($logInfo);
/* DISPLAY SECTION */
Display::display_introduction_section(TOOL_DROPBOX);
@ -45,7 +54,6 @@ if (isset($_GET['dropbox_direction']) && in_array($_GET['dropbox_direction'], ['
}
$sort_params = Security::remove_XSS(implode('&', $sort_params));
$action = isset($_GET['action']) ? $_GET['action'] : null;
// Display the form for adding a new dropbox item.
if ($action == 'add') {
@ -271,6 +279,11 @@ if ($action != 'add') {
/* Menu Sent */
if (api_get_session_id() == 0) {
echo '<div class="actions">';
if (empty($viewSentCategory)) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".
Display::return_icon('upload_file.png', get_lang('UploadNewFile'), '', ICON_SIZE_MEDIUM).
"</a>";
}
if ($view_dropbox_category_sent != 0) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.
Display::return_icon('folder_up.png', get_lang('Up').' '.get_lang('Root'), '', ICON_SIZE_MEDIUM).
@ -280,15 +293,15 @@ if ($action != 'add') {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".
Display::return_icon('new_folder.png', get_lang('AddNewCategory'), '', ICON_SIZE_MEDIUM)."</a>\n";
}
echo '</div>';
} else {
if (api_is_allowed_to_session_edit(false, true)) {
echo '<div class="actions">';
if (empty($viewSentCategory)) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".
Display::return_icon('upload_file.png', get_lang('UploadNewFile'), '', ICON_SIZE_MEDIUM).
"</a>";
}
echo '</div>';
} else {
if (api_is_allowed_to_session_edit(false, true)) {
echo '<div class="actions">';
if ($view_dropbox_category_sent != 0) {
echo get_lang('CurrentlySeeing').': <strong>'.Security::remove_XSS($dropbox_categories[$view_dropbox_category_sent]['cat_name']).'</strong> ';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category=0&view='.$view.'">'.
@ -298,11 +311,6 @@ if ($action != 'add') {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=addsentcategory\">".
Display::return_icon('new_folder.png', get_lang('AddNewCategory'), '', ICON_SIZE_MEDIUM)."</a>\n";
}
if (empty($viewSentCategory)) {
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&view=".$view."&action=add\">".
Display::return_icon('upload_file.png', get_lang('UploadNewFile'), '', ICON_SIZE_MEDIUM).
"</a>";
}
echo '</div>';
}
}

@ -191,15 +191,22 @@ function aiken_import_exercise($file)
if (isset($question_array['description'])) {
$question->updateDescription($question_array['description']);
}
$type = $question->selectType();
$question->type = constant($type);
$question->save($exercise);
$last_question_id = $question->selectId();
//3. Create answer
$answer = new Answer($last_question_id);
$answer->new_nbrAnswers = count($question_array['answer']);
$max_score = 0;
$scoreFromFile = 0;
if (isset($question_array['score']) && !empty($question_array['score'])) {
$scoreFromFile = $question_array['score'];
}
foreach ($question_array['answer'] as $key => $answers) {
$key++;
$answer->new_answer[$key] = $answers['value'];
@ -218,6 +225,14 @@ function aiken_import_exercise($file)
$answer->new_weighting[$key] = $question_array['weighting'][$key - 1];
$max_score += $question_array['weighting'][$key - 1];
}
if (!empty($scoreFromFile) && $answer->new_correct[$key]) {
$answer->new_weighting[$key] = $scoreFromFile;
}
}
if (!empty($scoreFromFile)) {
$max_score = $scoreFromFile;
}
$answer->save();
@ -260,7 +275,6 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
$data = file($questionFilePath);
$question_index = 0;
$correct_answer = '';
$answers_array = [];
$new_question = true;
foreach ($data as $line => $info) {
@ -284,6 +298,10 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
$exercise_info['question'][$question_index]['correct_answers'][] = $correct_answer_index + 1;
//weight for correct answer
$exercise_info['question'][$question_index]['weighting'][$correct_answer_index] = 1;
} elseif (preg_match('/^SCORE:\s?(.*)/', $info, $matches)) {
$exercise_info['question'][$question_index]['score'] = (float) $matches[1];
} elseif (preg_match('/^DESCRIPTION:\s?(.*)/', $info, $matches)) {
$exercise_info['question'][$question_index]['description'] = $matches[1];
} elseif (preg_match('/^ANSWER_EXPLANATION:\s?(.*)/', $info, $matches)) {
//Comment of correct answer
$correct_answer_index = array_search($matches[1], $answers_array);
@ -325,10 +343,10 @@ function aiken_parse_file(&$exercise_info, $exercisePath, $file, $questionFile)
} else {
//Question itself (use a 100-chars long title and a larger description)
$exercise_info['question'][$question_index]['title'] = trim(substr($info, 0, 100)).'...';
$exercise_info['question'][$question_index]['description'] = $info;
//$exercise_info['question'][$question_index]['description'] = $info;
}
} else {
$exercise_info['question'][$question_index]['description'] = $info;
//$exercise_info['question'][$question_index]['description'] = $info;
}
}
}

@ -139,17 +139,17 @@ switch ($action) {
require_once __DIR__.'/../global.inc.php';
// Get the name of the database course.
$tbl_course_description = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$course_info = api_get_course_info($_GET['code']);
$content = get_lang('NoDescription');
if (!empty($course_info)) {
if (api_get_setting('course_catalog_hide_private') === 'true' &&
$course_info['visibility'] == COURSE_VISIBILITY_REGISTERED
) {
echo get_lang('PrivateAccess');
break;
}
$sql = "SELECT * FROM $tbl_course_description
$table = Database::get_course_table(TABLE_COURSE_DESCRIPTION);
$sql = "SELECT * FROM $table
WHERE c_id = ".$course_info['real_id']." AND session_id = 0
ORDER BY id";
$result = Database::query($sql);
@ -158,14 +158,14 @@ switch ($action) {
$descriptions[$description->id] = $description;
}
// Function that displays the details of the course description in html.
echo CourseManager::get_details_course_description_html(
$content = CourseManager::get_details_course_description_html(
$descriptions,
api_get_system_encoding(),
false
);
} else {
echo get_lang('NoDescription');
}
}
echo $content;
break;
case 'session_courses_lp_default':
/**

@ -0,0 +1,212 @@
<?php
/* For licensing terms, see /license.txt */
use Symfony\Component\Finder\Finder;
/**
* Class MailTemplateManager.
*/
class MailTemplateManager extends Model
{
public $columns = [
'id',
'name',
'template',
'type',
'system',
'url_id',
'default_template',
'created_at',
'updated_at',
'author_id',
];
public function __construct()
{
parent::__construct();
$this->table = 'mail_template';
}
/**
* @return int
*/
public function get_count()
{
$row = Database::select(
'count(*) as count',
$this->table,
['where' => ['url_id = ? ' => api_get_current_access_url_id()]],
'first'
);
return $row['count'];
}
/**
* Displays the title + grid.
*
* @return string html code
*/
public function display()
{
// Action links
$html = '<div class="actions" style="margin-bottom:20px">';
$html .= '<a href="'.api_get_path(WEB_CODE_PATH).'admin">'.
Display::return_icon(
'back.png',
get_lang('Back'),
'',
'32'
)
.'</a>';
$html .= '<a href="'.api_get_self().'?action=add">'.
Display::return_icon(
'add.png',
get_lang('Add'),
'',
'32'
).'</a>';
$html .= '</div>';
$html .= Display::grid_html('mail_template');
return $html;
}
/**
* Returns a Form validator Obj.
*
* @param string $url
* @param string $action
*
* @return FormValidator
*/
public function returnForm($url, $action = 'add')
{
$form = new FormValidator('template', 'post', $url);
// Setting the form elements
$header = get_lang('Add');
if ($action === 'edit') {
$header = get_lang('Modify');
}
$id = isset($_GET['id']) ? (int) $_GET['id'] : '';
$form->addElement('header', '', $header);
$form->addElement('hidden', 'id', $id);
$form->addElement(
'text',
'name',
get_lang('Name'),
['size' => '70', 'id' => 'name']
);
/*$form->addHtmlEditor(
'email_template',
get_lang('Template'),
false,
false,
[
'ToolbarSet' => 'Careers',
'Width' => '100%',
'Height' => '250',
]
);*/
$form->addTextarea(
'email_template',
get_lang('Template')
);
$finder = new Finder();
$files = $finder
->files()
->in(api_get_path(SYS_CODE_PATH).'template/default/mail')
->sort(
function ($a, $b) {
return strcmp($a->getRealpath(), $b->getRealpath());
}
);
$options = [];
/** @var SplFileInfo $file */
foreach ($files as $file) {
$options[$file->getFilename()] = $file->getFilename();
}
$form->addSelect(
'type',
get_lang('Type'),
$options
);
$defaults = $this->get($id);
if ($action === 'edit') {
$form->addLabel(get_lang('CreatedAt'), Display::dateToStringAgoAndLongDate($defaults['created_at']));
$form->addLabel(get_lang('UpdatedAt'), Display::dateToStringAgoAndLongDate($defaults['updated_at']));
$form->addButtonSave(get_lang('Modify'), 'submit');
} else {
$form->addButtonCreate(get_lang('Add'), 'submit');
}
// Setting the defaults
if (!empty($defaults)) {
$defaults['email_template'] = $defaults['template'];
}
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form;
}
/**
* @param int $id
*
* @return bool
*/
public function setDefault($id)
{
$template = $this->get($id);
if (empty($template)) {
return false;
}
$type = $template['type'];
$urlId = api_get_current_access_url_id();
$sql = "UPDATE {$this->table} SET default_template = 0
WHERE type = '$type' AND url_id = $urlId";
Database::query($sql);
$sql = "UPDATE {$this->table} SET default_template = 1
WHERE id = $id";
Database::query($sql);
return true;
}
/**
* @param int $templateId
* @param array $userInfo
*
* @return string|false
*/
public function parseTemplate($templateId, $userInfo)
{
$templateInfo = $this->get($templateId);
if (!empty($templateInfo)) {
$emailTemplate = $templateInfo['template'];
$keys = array_keys($userInfo);
foreach ($keys as $key) {
$emailTemplate = str_replace("{{user.$key}}", $userInfo[$key], $emailTemplate);
}
$template = new Template();
$template->twig->setLoader(new \Twig_Loader_String());
$emailBody = $template->twig->render($emailTemplate);
return $emailBody;
}
return false;
}
}

@ -1331,6 +1331,8 @@ class Agenda
break;
}
$this->cleanEvents();
switch ($format) {
case 'json':
if (empty($this->events)) {
@ -4063,30 +4065,6 @@ class Agenda
return $items;
}
/**
* This function retrieves one personal agenda item returns it.
*
* @param int $id The agenda item ID
*
* @return array The results of the database query, or null if not found
*/
public static function get_personal_agenda_item($id)
{
$table = Database::get_main_table(TABLE_PERSONAL_AGENDA);
$id = intval($id);
// make sure events of the personal agenda can only be seen by the user himself
$user = api_get_user_id();
$sql = " SELECT * FROM ".$table." WHERE id=".$id." AND user = ".$user;
$result = Database::query($sql);
if (Database::num_rows($result) == 1) {
$item = Database::fetch_array($result);
} else {
$item = null;
}
return $item;
}
/**
* This function calculates the startdate of the week (monday)
* and the enddate of the week (sunday)

@ -35,7 +35,7 @@ class Auth
// Secondly we select the courses that are in a category (user_course_cat<>0) and
// sort these according to the sort of the category
$user_id = intval($user_id);
$user_id = (int) $user_id;
$sql = "SELECT
course.code k,
course.visual_code vc,
@ -80,7 +80,7 @@ class Auth
/**
* This function get all the courses in the particular user category;.
*
* @return string The name of the user defined course category
* @return array
*/
public function get_courses_in_category()
{
@ -414,74 +414,4 @@ class Auth
return $result;
}
/**
* Subscribe the user to a given course.
*
* @param string $course_code Course code
*
* @return string Message about results
*/
public function subscribe_user($course_code)
{
$user_id = api_get_user_id();
$all_course_information = CourseManager::get_course_information($course_code);
if ($all_course_information['registration_code'] == '' ||
(
isset($_POST['course_registration_code']) &&
$_POST['course_registration_code'] == $all_course_information['registration_code']
)
) {
if (api_is_platform_admin()) {
$status_user_in_new_course = COURSEMANAGER;
} else {
$status_user_in_new_course = null;
}
if (CourseManager::add_user_to_course($user_id, $course_code, $status_user_in_new_course)) {
$send = api_get_course_setting('email_alert_to_teacher_on_new_user_in_course', $course_code);
if ($send == 1) {
CourseManager::email_to_tutor(
$user_id,
$all_course_information['real_id'],
$send_to_tutor_also = false
);
} elseif ($send == 2) {
CourseManager::email_to_tutor(
$user_id,
$all_course_information['real_id'],
$send_to_tutor_also = true
);
}
$url = Display::url($all_course_information['title'], api_get_course_url($course_code));
$message = sprintf(get_lang('EnrollToCourseXSuccessful'), $url);
} else {
$message = get_lang('ErrorContactPlatformAdmin');
}
return ['message' => $message];
} else {
if (isset($_POST['course_registration_code']) &&
$_POST['course_registration_code'] != $all_course_information['registration_code']
) {
return false;
}
$message = get_lang('CourseRequiresPassword').'<br />';
$message .= $all_course_information['title'].' ('.$all_course_information['visual_code'].') ';
$action = api_get_path(WEB_CODE_PATH)."auth/courses.php?action=subscribe_user_with_password&sec_token=".Security::getTokenFromSession();
$form = new FormValidator(
'subscribe_user_with_password',
'post',
$action
);
$form->addElement('hidden', 'sec_token', Security::getTokenFromSession());
$form->addElement('hidden', 'subscribe_user_with_password', $all_course_information['code']);
$form->addElement('text', 'course_registration_code');
$form->addButtonSave(get_lang('SubmitRegistrationCode'));
$content = $form->returnForm();
return ['message' => $message, 'content' => $content];
}
}
}

@ -183,18 +183,23 @@ function getCustomTabs()
* Return the active logo of the portal, based on a series of settings.
*
* @param string $theme The name of the theme folder from web/css/themes/
* @param bool $responsive add class img-responsive
*
* @return string HTML string with logo as an HTML element
*/
function return_logo($theme = '')
function return_logo($theme = '', $responsive = true)
{
$siteName = api_get_setting('siteName');
$class = 'img-responsive';
if (!$responsive) {
$class = '';
}
return ChamiloApi::getPlatformLogo(
$theme,
[
'title' => $siteName,
'class' => 'img-responsive',
'class' => $class,
'id' => 'header-logo',
]
);

@ -35,8 +35,8 @@ class CourseManager
* Creates a course.
*
* @param array $params Columns in the main.course table.
* @param int $authorId optional
* @param int $accessUrlId optional
* @param int $authorId Optional.
* @param int $accessUrlId Optional.
*
* @return mixed false if the course was not created, array with the course info
*/

@ -436,7 +436,6 @@ class CourseDescription
$default_description_icon[5] = 'laptop.png';
$default_description_icon[6] = 'teacher.png';
$default_description_icon[7] = 'assessment.png';
//$default_description_icon[8]= 'porcent.png';
$default_description_icon[8] = 'wizard.png';
return $default_description_icon;

@ -33,7 +33,9 @@ class CourseHome
switch ($cat) {
case 'Basic':
$condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND a.link=t.link AND t.position="basic" ';
if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) &&
$_SESSION['studentview'] != 'studentview'
) {
$condition_display_tools = ' WHERE
a.c_id = '.$course_id.' AND
a.link=t.link AND
@ -130,9 +132,10 @@ class CourseHome
}
foreach ($all_tools as &$tool) {
if ($tool['image'] == 'scormbuilder.gif') {
if (isset($tool['image']) && $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) &&
!learnpath::is_lp_visible_for_student(
$lpId,
@ -172,10 +175,11 @@ class CourseHome
// Setting the actual image url
$tool['img'] = Display::returnIconPath($tool['img']);
$target = isset($tool['target']) ? $tool['target'] : '';
// VISIBLE
if (($tool['visibility'] ||
((api_is_coach() || api_is_course_tutor()) && $tool['name'] == TOOL_TRACKING)) ||
((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) && $tool['name'] == TOOL_TRACKING)) ||
$cat == 'courseAdmin' || $cat == 'platformAdmin'
) {
if (strpos($tool['name'], 'visio_') !== false) {
@ -187,7 +191,7 @@ class CourseHome
$cell_content .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$tool['link'].$link_annex.'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$tool['target'].'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
} else {
// don't replace img with display::return_icon because $tool['img'] = api_get_path(WEB_IMG_PATH).$tool['img']
$cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$tool['target'].'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
$cell_content .= '<a href="'.$tool['link'].$link_annex.'" target="'.$target.'"><img src="'.$tool['img'].'" title="'.$tool_name.'" alt="'.$tool_name.'" align="absmiddle" border="0">'.$tool_name.'</a>';
}
} else {
// INVISIBLE
@ -268,7 +272,9 @@ class CourseHome
switch ($course_tool_category) {
case TOOL_PUBLIC:
$condition_display_tools = ' WHERE c_id = '.$course_id.' AND visibility = 1 ';
if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) &&
$_SESSION['studentview'] != 'studentview'
) {
$condition_display_tools = ' WHERE
c_id = '.$course_id.' AND
(visibility = 1 OR (visibility = 0 AND name = "'.TOOL_TRACKING.'")) ';
@ -306,13 +312,15 @@ class CourseHome
case TOOL_PUBLIC:
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tl.c_id = tip.c_id AND tl.c_id = $course_id AND tip.ref=tl.id
LEFT JOIN $course_item_property_table tip
ON tip.tool='link' AND tl.c_id = tip.c_id AND tl.c_id = $course_id AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility = 1";
break;
case TOOL_PUBLIC_BUT_HIDDEN:
$sql_links = "SELECT tl.*, tip.visibility
FROM $course_link_table tl
LEFT JOIN $course_item_property_table tip ON tip.tool='link' AND tl.c_id = tip.c_id AND tl.c_id = $course_id AND tip.ref=tl.id
LEFT JOIN $course_item_property_table tip
ON tip.tool='link' AND tl.c_id = tip.c_id AND tl.c_id = $course_id AND tip.ref=tl.id
WHERE tl.on_homepage='1' AND tip.visibility = 0";
break;
@ -333,8 +341,8 @@ class CourseHome
$all_tools_list[] = $properties;
}
}
$lnk = [];
if (isset($all_tools_list)) {
$lnk = [];
foreach ($all_tools_list as &$tool) {
if ($tool['image'] == 'scormbuilder.gif') {
// check if the published learnpath is visible for student
@ -383,7 +391,9 @@ class CourseHome
} elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
$html .= '<a href="javascript: void(0);" onclick="javascript: window.open(\''.htmlspecialchars($tool['link']).$qm_or_amp.api_get_cidreq().'\',\'window_chat'.api_get_course_id().'\',config=\'height=\'+600+\', width=\'+825+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="'.$tool['target'].'" '.$class.'>';
} else {
$html .= '<a href="'.htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="'.$tool['target'].'" '.$class.'>';
$target = isset($tool['target']) ? $tool['target'] : '';
$html .= '<a href="'.
htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="'.$target.'" '.$class.'>';
}
$tool_name = self::translate_tool_name($tool);
@ -398,7 +408,7 @@ class CourseHome
// This part displays the links to hide or remove a tool.
// These links are only visible by the course manager.
unset($lnk);
$lnk = [];
if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
if ($tool['visibility'] == '1' || $tool['name'] == TOOL_TRACKING) {
$link['name'] = Display::returnFontAwesomeIcon('minus');
@ -423,7 +433,8 @@ class CourseHome
}
}
if (isset($tool['adminlink'])) {
$html .= '<a href="'.$tool['adminlink'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
$html .= '<a href="'.$tool['adminlink'].'">'.
Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
}
}
if (api_is_platform_admin() && !api_is_coach()) {
@ -464,7 +475,6 @@ class CourseHome
if ($i % 2) {
$html .= "</tr>";
}
$i++;
}
}
@ -499,6 +509,7 @@ class CourseHome
// Condition for the session
$sessionId = $sessionId ?: api_get_session_id();
$course_id = $courseId ?: api_get_course_int_id();
$courseInfo = api_get_course_info_by_id($course_id);
$userId = api_get_user_id();
$user = api_get_user_entity($userId);
$condition_session = api_get_session_condition(
@ -509,14 +520,15 @@ class CourseHome
);
$lpTable = Database::get_course_table(TABLE_LP_MAIN);
$orderBy = ' ORDER BY id ';
switch ($course_tool_category) {
case TOOL_STUDENT_VIEW:
$conditions = ' WHERE visibility = 1 AND
(category = "authoring" OR category = "interaction" OR category = "plugin") AND
t.name <> "notebookteacher" ';
if ((api_is_coach() || api_is_course_tutor()) && $_SESSION['studentview'] != 'studentview') {
if ((api_is_coach() || api_is_course_tutor() || api_is_platform_admin()) &&
$_SESSION['studentview'] != 'studentview'
) {
$conditions = ' WHERE (
visibility = 1 AND (
category = "authoring" OR
@ -526,11 +538,6 @@ class CourseHome
)';
}
/*$sql = "SELECT *
FROM $course_tool_table t
$conditions AND
c_id = $course_id $condition_session
";*/
// Add order if there are LPs
$sql = "SELECT t.* FROM $course_tool_table t
LEFT JOIN $lpTable l
@ -541,9 +548,6 @@ class CourseHome
$orderBy = '';
break;
case TOOL_AUTHORING:
/*$sql = "SELECT * FROM $course_tool_table t
WHERE category = 'authoring' AND c_id = $course_id $condition_session
";*/
$sql = "SELECT t.* FROM $course_tool_table t
LEFT JOIN $lpTable l
ON (t.c_id = l.c_id AND link LIKE concat('%/lp_controller.php?action=view&lp_id=', l.id, '&%'))
@ -648,18 +652,22 @@ class CourseHome
case 'scormbuilder.gif':
$lpId = self::getPublishedLpIdFromLink($temp_row['link']);
$lp = new learnpath(
api_get_course_id(),
$courseInfo['code'],
$lpId,
$userId
);
$path = $lp->get_preview_image_path(ICON_SIZE_BIG);
$add = learnpath::is_lp_visible_for_student(
$lpId,
$userId,
api_get_course_id(),
api_get_session_id()
);
if (api_is_allowed_to_edit(null, true)) {
$add = true;
} else {
$add = learnpath::is_lp_visible_for_student(
$lpId,
$userId,
$courseInfo['code'],
$sessionId
);
}
if ($path) {
$temp_row['custom_image'] = $path;
}
@ -754,12 +762,10 @@ class CourseHome
}
if (isset($tmp_all_tools_list)) {
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
foreach ($tmp_all_tools_list as $tool) {
if ($tool['image'] == 'blog.gif') {
// Init
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
// Get blog id
$blog_id = substr($tool['link'], strrpos($tool['link'], '=') + 1, strlen($tool['link']));
// Get blog members
@ -779,23 +785,24 @@ class CourseHome
}
}
}
$all_tools_list = CourseHome::filterPluginTools($all_tools_list, $course_tool_category);
return $all_tools_list;
$list = self::filterPluginTools($all_tools_list, $course_tool_category);
return $list;
}
/**
* Displays the tools of a certain category.
*
* @param array $all_tools_list List of tools as returned by get_tools_category()
* @param bool $rows
*
* @return array
*/
public static function show_tools_category($all_tools_list, $rows = false)
public static function show_tools_category($all_tools_list)
{
$_user = api_get_user_info();
$theme = api_get_setting('homepage_view');
if ($theme === 'vertical_activity') {
//ordering by get_lang name
$order_tool_list = [];
@ -818,7 +825,6 @@ class CourseHome
$session_id = api_get_session_id();
$is_platform_admin = api_is_platform_admin();
$allowEditionInSession = api_get_configuration_value('allow_edit_tool_visibility_in_session');
if ($session_id == 0) {
$is_allowed_to_edit = api_is_allowed_to_edit(null, true) && api_is_course_admin();
} else {
@ -828,7 +834,6 @@ class CourseHome
}
}
$i = 0;
$items = [];
$app_plugin = new AppPlugin();
@ -978,26 +983,24 @@ class CourseHome
$tool['link'] = $web_code_path.$tool['link'];
}
$class = '';
if ($tool['visibility'] == '0' && $toolAdmin != '1') {
$class = 'text-muted';
$info = pathinfo($tool['image']);
$basename = basename($tool['image'], '.'.$info['extension']); // $file is set to "index"
$tool['image'] = $basename.'_na.'.$info['extension'];
} else {
$class = '';
}
$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') {
$tool['link'] = $tool['link'].$qm_or_amp;
$tool['link'] = $tool['link'];
} else {
$tool['link'] = $tool['link'].$qm_or_amp.api_get_cidreq();
}
$tool_link_params = [];
$toolIid = isset($tool["iid"]) ? $tool["iid"] : null;
$toolIid = isset($tool['iid']) ? $tool['iid'] : null;
//@todo this visio stuff should be removed
if (strpos($tool['name'], 'visio_') !== false) {
@ -1045,6 +1048,7 @@ class CourseHome
.$tool['original_link'].$qm_or_amp.api_get_cidreq();
}
$icon = Display::return_icon(
$tool['image'],
$tool_name,
@ -1053,6 +1057,24 @@ class CourseHome
false
);
// Used in the top bar
$iconMedium = Display::return_icon(
$tool['image'],
$tool_name,
['class' => 'tool-icon', 'id' => 'toolimage_'.$toolIid],
ICON_SIZE_MEDIUM,
false
);
// Used for vertical navigation
$iconSmall = Display::return_icon(
$tool['image'],
$tool_name,
['class' => 'tool-img', 'id' => 'toolimage_'.$toolIid],
ICON_SIZE_SMALL,
false
);
/*if (!empty($tool['custom_icon'])) {
$image = self::getCustomWebIconPath().$tool['custom_icon'];
$icon = Display::img(
@ -1075,6 +1097,10 @@ class CourseHome
}
$item['url_params'] = $tool_link_params;
$item['icon'] = Display::url($icon, $tool_link_params['href'], $tool_link_params);
$item['only_icon'] = $icon;
$item['only_icon_medium'] = $iconMedium;
$item['only_icon_small'] = $iconSmall;
$item['only_href'] = $tool_link_params['href'];
$item['tool'] = $tool;
$item['name'] = $tool_name;
$tool_link_params['id'] = 'is'.$tool_link_params['id'];
@ -1084,7 +1110,6 @@ class CourseHome
$tool_link_params
);
$items[] = $item;
$i++;
} // end of foreach
}
@ -1113,15 +1138,14 @@ class CourseHome
*/
public static function show_session_data($id_session)
{
$session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$sessionInfo = api_get_session_info($id_session);
if (empty($sessionInfo)) {
return '';
}
$sql = 'SELECT name FROM '.$session_category_table.'
$table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$sql = 'SELECT name FROM '.$table.'
WHERE id = "'.intval($sessionInfo['session_category_id']).'"';
$rs_category = Database::query($sql);
$session_category = '';
@ -1178,13 +1202,15 @@ class CourseHome
$toolName = Security::remove_XSS(stripslashes($tool['name']));
if (in_array($tool['image'], $already_translated_icons)) {
if (isset($tool['image']) && in_array($tool['image'], $already_translated_icons)) {
return $toolName;
}
$toolName = api_underscore_to_camel_case($toolName);
if (isset($GLOBALS['Tool'.$toolName])) {
if (isset($tool['category']) && 'plugin' !== $tool['category'] &&
isset($GLOBALS['Tool'.$toolName])
) {
return get_lang('Tool'.$toolName);
}

@ -2806,4 +2806,54 @@ HTML;
return $content;
}
/**
* @param string $frameName
*
* @return string
*/
public static function getFrameReadyBlock($frameName)
{
$defaultFeatures = ['playpause', 'current', 'progress', 'duration', 'tracks', 'volume', 'fullscreen', 'vrview'];
$features = api_get_configuration_value('video_features');
if (!empty($features) && isset($features['features'])) {
foreach ($features['features'] as $feature) {
if ($feature === 'vrview') {
continue;
}
$defaultFeatures[] = $feature;
}
}
$defaultFeatures = implode("','", $defaultFeatures);
$frameReady = '
$.frameReady(function() {
$(document).ready(function () {
$("video:not(.skip), audio:not(.skip)").mediaelementplayer({
pluginPath: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/build/",
features: ["'.$defaultFeatures.'"],
success: function(mediaElement, originalNode, instance) {
},
vrPath: "'.api_get_path(WEB_PUBLIC_PATH).'assets/vrview/build/vrview.js"
});
});
}, "'.$frameName.'",
{
load: [
{ type:"script", id:"_fr1", src:"'.api_get_jquery_web_path().'"},
{ type:"script", id:"_fr7", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/MathJax/MathJax.js?config=AM_HTMLorMML"},
{ type:"script", id:"_fr4", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/jquery-ui.min.js"},
{ type:"stylesheet", id:"_fr5", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/themes/smoothness/jquery-ui.min.css"},
{ type:"stylesheet", id:"_fr6", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/themes/smoothness/theme.css"},
{ type:"script", id:"_fr2", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
{ type:"script", id:"_fr3", src:"'.api_get_path(WEB_CODE_PATH).'glossary/glossary.js.php?'.api_get_cidreq().'"},
{type: "script", id: "_media1", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/build/mediaelement-and-player.min.js"},
{type: "stylesheet", id: "_media2", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/build/mediaelementplayer.min.css"},
{type: "stylesheet", id: "_media4", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/plugins/vrview/vrview.css"},
{type: "script", id: "_media4", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/plugins/vrview/vrview.js"},
]
});';
return $frameReady;
}
}

@ -173,7 +173,6 @@ class DocumentManager
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'ppm' => 'image/x-portable-pixmap',
'ppt' => 'application/vnd.ms-powerpoint',
'pps' => 'application/vnd.ms-powerpoint',
'ps' => 'application/postscript',
'qt' => 'video/quicktime',
'ra' => 'audio/x-realaudio',
@ -679,7 +678,7 @@ class DocumentManager
foreach ($documentData as $row) {
$isVisible = self::check_visibility_tree(
$row['id'],
$courseInfo['code'],
$courseInfo,
$sessionId,
api_get_user_id(),
$toGroupId

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\TrackEExercises;
use ChamiloSession as Session;
/**

@ -53,6 +53,7 @@ class DateRangePicker extends HTML_QuickForm_text
*/
public function parseDateRange($dateRange)
{
$dateRange = Security::remove_XSS($dateRange);
$dates = explode('/', $dateRange);
$dates = array_map('trim', $dates);
$start = isset($dates[0]) ? $dates[0] : '';
@ -82,7 +83,7 @@ class DateRangePicker extends HTML_QuickForm_text
$d = DateTime::createFromFormat($format, $dates['end']);
$resultEnd = $d && $d->format($format) == $dates['end'];
if (!($resultStart) || !$resultEnd) {
if (!$resultStart || !$resultEnd) {
return false;
}
@ -133,7 +134,7 @@ class DateRangePicker extends HTML_QuickForm_text
}
$minDate = null;
$minDateValue = $this->getAttribute('minDate');
$minDateValue = Security::remove_XSS($this->getAttribute('minDate'));
if (!empty($minDateValue)) {
$minDate = "
minDate: '{$minDateValue}',
@ -141,7 +142,7 @@ class DateRangePicker extends HTML_QuickForm_text
}
$maxDate = null;
$maxDateValue = $this->getAttribute('maxDate');
$maxDateValue = Security::remove_XSS($this->getAttribute('maxDate'));
if (!empty($maxDateValue)) {
$maxDate = "
maxDate: '{$maxDateValue}',
@ -149,13 +150,13 @@ class DateRangePicker extends HTML_QuickForm_text
}
$format = 'YYYY-MM-DD HH:mm';
$formatValue = $this->getAttribute('format');
$formatValue = Security::remove_XSS($this->getAttribute('format'));
if (!empty($formatValue)) {
$format = $formatValue;
}
$timePicker = 'true';
$timePickerValue = $this->getAttribute('timePicker');
$timePickerValue = Security::remove_XSS($this->getAttribute('timePicker'));
if (!empty($timePickerValue)) {
$timePicker = $timePickerValue;
}

@ -31,7 +31,7 @@ class HtmlEditor extends HTML_QuickForm_textarea
$config = []
) {
if (empty($name)) {
return false;
throw new \Exception('Name is required');
}
parent::__construct($name, $elementLabel, $attributes);
@ -86,7 +86,7 @@ class HtmlEditor extends HTML_QuickForm_textarea
*/
public function getFrozenHtml()
{
return $this->getValue();
return Security::remove_XSS($this->getValue());
}
/**
@ -98,12 +98,13 @@ class HtmlEditor extends HTML_QuickForm_textarea
{
$result = '';
if ($this->editor) {
$this->editor->value = $this->getValue();
$value = $this->getCleanValue();
$this->editor->setName($this->getName());
if ($style == true) {
$result = $this->editor->createHtmlStyle();
if ($style === true) {
$result = $this->editor->createHtmlStyle($value);
} else {
$result = $this->editor->createHtml();
$result = $this->editor->createHtml($value);
}
}

@ -178,16 +178,21 @@ EOT;
* Adds a text field to the form.
* A trim-filter is attached to the field.
*
* @param string $label The label for the form-element
* @param string|array $label The label for the form-element
* @param string $name The element name
* @param bool $required (optional) Is the form-element required (default=true)
* @param array $attributes (optional) List of attributes for the form-element
*
* @return HTML_QuickForm_text
*/
public function addText($name, $label, $required = true, $attributes = [])
public function addText($name, $label, $required = true, $attributes = [], $createElement = false)
{
$element = $this->addElement('text', $name, $label, $attributes);
if ($createElement) {
$element = $this->createElement('text', $name, $label, $attributes);
} else {
$element = $this->addElement('text', $name, $label, $attributes);
}
$this->applyFilter($name, 'trim');
if ($required) {
$this->addRule($name, get_lang('ThisFieldIsRequired'), 'required');

@ -0,0 +1,25 @@
/**
* When included, this snippet prevents contextual menus and keystrokes that
* make it possible to cut/paste/copy text from the page.
* This is useful for very secure exams.
* @author Alberto Torreblanca
*/
$(document).ready(function(){
$(document).on("cut copy paste contextmenu",function(e) {
e.preventDefault();
});
$(document).keydown(function(e) {
var forbiddenKeys = new Array('c', 'x', 'v', 'p', 's');
var keyCode = (e.keyCode) ? e.keyCode : e.which;
var isCtrl;
isCtrl = e.ctrlKey
if (isCtrl) {
for (i = 0; i < forbiddenKeys.length; i++) {
if (forbiddenKeys[i] == String.fromCharCode(keyCode).toLowerCase()) {
return false;
}
}
}
return true;
});
});

@ -0,0 +1,37 @@
body {
font-size: 25px;
line-height: 1.25em !important;
text-align: justify;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.text-highlight {
-webkit-transition: color .3s linear, text-shadow .3s linear;
-khtml-transition: color .3s linear, text-shadow .3s linear;
-moz-transition: color .3s linear, text-shadow .3s linear;
-ms-transition: color .3s linear, text-shadow .3s linear;
transition: color .3s linear, text-shadow .3s linear;
}
.text-highlight.active {
color: red;
-webkit-text-shadow: 0px 0px 1px rgba(255, 0, 0, 1);
-khtml-text-shadow: 0px 0px 1px rgba(255, 0, 0, 1);
-moz-text-shadow: 0px 0px 1px rgba(255, 0, 0, 1);
-ms-text-shadow: 0px 0px 1px rgba(255, 0, 0, 1);
text-shadow: 0px 0px 1px rgba(255, 0, 0, 1);
-webkit-transition: color .3s linear, text-shadow .3s linear;
-khtml-transition: color .3s linear, text-shadow .3s linear;
-moz-transition: color .3s linear, text-shadow .3s linear;
-ms-transition: color .3s linear, text-shadow .3s linear;
transition: color .3s linear, text-shadow .3s linear;
}
br {
margin-bottom: 1em;
}

@ -0,0 +1,76 @@
/* For licensing terms, see /license.txt */
$(function () {
var parent$ = window.parent.$,
playerSelector = '#' + parent$('mediaelementwrapper').attr('id') + '_html5',
$player = parent$(playerSelector);
var player = $player.get(0),
def = $.Deferred();
if (!$player.length) {
processText(wordsCount);
return;
}
player.preload = 'auto';
function processText(turns) {
var tagEnd = '</span> ',
tagStart = tagEnd + '<span class="text-highlight">',
wordsPerSecond = Math.ceil(wordsCount / turns);
var indexes = Object.keys(words);
var output = '';
for (var i = 0; i < turns; i++) {
var block = indexes.slice(i * wordsPerSecond, i * wordsPerSecond + wordsPerSecond),
index = block[0];
if (!index) {
continue;
}
output += tagStart + words[index];
for (var j = 1; j < block.length; j++) {
index = block[j];
output += ' ' + words[index];
}
}
output += tagEnd;
output = output.slice(tagEnd.length);
$('.page-blank').html(output);
def.resolve(output);
return def.promise();
}
player.ontimeupdate = function () {
var block = Math.ceil(this.currentTime);
$('.text-highlight')
.removeClass('active')
.filter(function (index) {
return index + 1 == block;
})
.addClass('active');
};
player.onloadedmetadata = function () {
var turns = Math.ceil(this.duration);
processText(turns)
.then(function (output) {
var to = window.setTimeout(function () {
player.play();
window.clearTimeout(to);
}, 1500);
});
}
});

@ -148,6 +148,7 @@ class HTML_Common
$strAttr .= ' ' . $key . '= "' . $value. '"';
}
}
return $strAttr;
}
@ -157,7 +158,7 @@ class HTML_Common
* @access private
* @return array
*/
function _parseAttributes($attributes)
public function _parseAttributes($attributes)
{
if (is_array($attributes)) {
$ret = array();
@ -253,14 +254,15 @@ class HTML_Common
* @access public
* @return string|null returns null if an attribute does not exist
*/
function getAttribute($attr)
public function getAttribute($attr)
{
$attr = strtolower($attr);
if (isset($this->_attributes[$attr])) {
return $this->_attributes[$attr];
}
return null;
} //end func getAttribute
}
/**
* Sets the value of the attribute
@ -458,17 +460,6 @@ class HTML_Common
*/
function charset($newCharset = null)
{
// Modified by Ivan Tcholakov, 16-MAR-2010
//static $charset = 'ISO-8859-1';
static $charset;
if (!isset($charset)) {
$charset = api_get_system_encoding();
}
//
if (!is_null($newCharset)) {
$charset = $newCharset;
}
return $charset;
return 'UTF-8';
} // end func charset
}

@ -350,19 +350,19 @@ class HTML_QuickForm extends HTML_Common
if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
foreach ($filter as $val) {
if (!is_callable($val)) {
throw new \Exception("Callback function does not exist in QuickForm::setDefaults()");
throw new \Exception('Callback function does not exist in QuickForm::setDefaults()');
} else {
$defaultValues = $this->_recursiveFilter($val, $defaultValues);
}
}
} elseif (!is_callable($filter)) {
throw new \Exception("Callback function does not exist in QuickForm::setDefaults()");
throw new \Exception('Callback function does not exist in QuickForm::setDefaults()');
} else {
$defaultValues = $this->_recursiveFilter($filter, $defaultValues);
}
}
$this->_defaultValues = HTML_QuickForm::arrayMerge($this->_defaultValues, $defaultValues);
$this->_defaultValues = self::arrayMerge($this->_defaultValues, $defaultValues);
$this->_constantValues = $this->_defaultValues;
foreach (array_keys($this->_elements) as $key) {
$this->_elements[$key]->onQuickFormEvent('updateValue', null, $this);

@ -155,4 +155,3 @@ class HTML_QuickForm_Renderer
return;
} // end func finishGroup
} // end class HTML_QuickForm_Renderer
?>

@ -53,8 +53,7 @@ class HTML_QuickForm_advanced_settings extends HTML_QuickForm_static
}
$html .= '
<button id="'.$name.'" type="button" class="btn btn-default advanced_options"
data-toggle="button" aria-pressed="false" autocomplete="off">
<button id="'.$name.'" type="button" class="btn btn-default advanced_options" aria-pressed="false">
<em class="fa fa-bars"></em> '.$label.'
</button>
';

@ -640,8 +640,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
'id' => $selectId.'',
'name' => $selectNameFrom,
);
$this->_attributesUnselected
= array_merge($this->_attributes, $this->_attributesUnselected);
$this->_attributesUnselected = array_merge($this->_attributes, $this->_attributesUnselected);
$attrUnselected = $this->_getAttrString($this->_attributesUnselected);
// set name of Select To Box
@ -650,8 +649,7 @@ class HTML_QuickForm_advmultiselect extends HTML_QuickForm_select
'id' => $selectId.'_to',
'name' => $selectNameTo,
);
$this->_attributesSelected
= array_merge($this->_attributes, $this->_attributesSelected);
$this->_attributesSelected = array_merge($this->_attributes, $this->_attributesSelected);
$attrSelected = $this->_getAttrString($this->_attributesSelected);
// set name of Select hidden Box

@ -43,17 +43,15 @@ class HTML_QuickForm_element extends HTML_Common
/**
* Label of the field
* @var string
* @since 1.3
* @access private
*/
var $_label = '';
public $_label = '';
/**
* Label "for" a field... (Chamilo LMS customization)
* @var string
* @access private
*/
var $_label_for = '';
public $_label_for = '';
/**
* Form element type
@ -61,7 +59,7 @@ class HTML_QuickForm_element extends HTML_Common
* @since 1.0
* @access private
*/
var $_type = '';
public $_type = '';
/**
* Flag to tell if element is frozen
@ -69,7 +67,7 @@ class HTML_QuickForm_element extends HTML_Common
* @since 1.0
* @access private
*/
var $_flagFrozen = false;
public $_flagFrozen = false;
/**
* Does the element support persistant data when frozen
@ -77,7 +75,7 @@ class HTML_QuickForm_element extends HTML_Common
* @since 1.3
* @access private
*/
var $_persistantFreeze = false;
public $_persistantFreeze = false;
protected $columnsSize;
@ -179,9 +177,6 @@ class HTML_QuickForm_element extends HTML_Common
return 3.2;
} // end func apiVersion
// }}}
// {{{ getType()
/**
* Returns element type
*
@ -194,9 +189,6 @@ class HTML_QuickForm_element extends HTML_Common
return $this->_type;
} // end func getType
// }}}
// {{{ setName()
/**
* Sets the input field name
*
@ -207,12 +199,8 @@ class HTML_QuickForm_element extends HTML_Common
*/
public function setName($name)
{
// interface method
} //end func setName
// }}}
// {{{ getName()
/**
* Returns the element name
*
@ -222,12 +210,8 @@ class HTML_QuickForm_element extends HTML_Common
*/
public function getName()
{
// interface method
} //end func getName
// }}}
// {{{ setValue()
/**
* Sets the value of the form element
*
@ -238,12 +222,8 @@ class HTML_QuickForm_element extends HTML_Common
*/
public function setValue($value)
{
// interface
} // end func setValue
// }}}
// {{{ getValue()
/**
* Returns the value of the form element
*
@ -253,12 +233,30 @@ class HTML_QuickForm_element extends HTML_Common
*/
public function getValue()
{
// interface
return null;
} // end func getValue
/**
* @return string
*/
public function getCleanValue()
{
$value = $this->cleanValueFromParameter($this->getValue());
// }}}
return $value;
}
// {{{ freeze()
/**
* @param string $value
*
* @return string
*/
public function cleanValueFromParameter($value)
{
$value = @htmlspecialchars($value, ENT_COMPAT, HTML_Common::charset());
return $value;
}
/**
* Freeze the element so that only its value is returned
@ -271,9 +269,6 @@ class HTML_QuickForm_element extends HTML_Common
$this->_flagFrozen = true;
} //end func freeze
// }}}
// {{{ unfreeze()
/**
* Unfreezes the element so that it becomes editable
*
@ -286,9 +281,6 @@ class HTML_QuickForm_element extends HTML_Common
$this->_flagFrozen = false;
}
// }}}
// {{{ getFrozenHtml()
/**
* Returns the value of field without HTML tags
*
@ -302,11 +294,15 @@ class HTML_QuickForm_element extends HTML_Common
// Modified by Ivan Tcholakov, 16-MAR-2010.
//return ('' != $value? htmlspecialchars($value): '&nbsp;') .
// $this->_getPersistantData();
if (!empty($value)) {
$value = $this->getCleanValue();
} else {
$value = '&nbsp;';
}
$value .= $this->_getPersistantData();
$value = ('' != $value ? @htmlspecialchars($value, ENT_COMPAT, HTML_Common::charset()): '&nbsp;') .
$this->_getPersistantData();
return '<span class="freeze">'.$value.'</span>';
//
} //end func getFrozenHtml
/**
@ -329,9 +325,6 @@ class HTML_QuickForm_element extends HTML_Common
}
}
// }}}
// {{{ isFrozen()
/**
* Returns whether or not the element is frozen
*
@ -344,9 +337,6 @@ class HTML_QuickForm_element extends HTML_Common
return $this->_flagFrozen;
} // end func isFrozen
// }}}
// {{{ setPersistantFreeze()
/**
* Sets wether an element value should be kept in an hidden field
* when the element is frozen or not
@ -361,9 +351,6 @@ class HTML_QuickForm_element extends HTML_Common
$this->_persistantFreeze = $persistant;
} //end func setPersistantFreeze
// }}}
// {{{ setLabel()
/**
* Sets display text for the element
*
@ -381,9 +368,6 @@ class HTML_QuickForm_element extends HTML_Common
}
} //end func setLabel
// }}}
// {{{ getLabel()
/**
* Returns display text for the element
*
@ -407,9 +391,6 @@ class HTML_QuickForm_element extends HTML_Common
return $this->_label_for;
} //end func getLabelFor
// }}}
// {{{ _findValue()
/**
* Tries to find the element value from the values array
*
@ -451,9 +432,6 @@ class HTML_QuickForm_element extends HTML_Common
}
} //end func _findValue
// }}}
// {{{ onQuickFormEvent()
/**
* Called by HTML_QuickForm whenever form event is made on this element
*
@ -547,9 +525,6 @@ class HTML_QuickForm_element extends HTML_Common
return $this->_prepareValue($value, $assoc);
}
// }}}
// {{{ _prepareValue()
/**
* Used by exportValue() to prepare the value for returning
*
@ -609,8 +584,4 @@ class HTML_QuickForm_element extends HTML_Common
return $this;
}
}

@ -1,6 +1,4 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Base class for <input /> form elements
*
@ -35,8 +33,6 @@
*/
class HTML_QuickForm_input extends HTML_QuickForm_element
{
// {{{ constructor
/**
* Class constructor
*
@ -52,9 +48,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
parent::__construct($elementName, $elementLabel, $attributes);
} //end constructor
// }}}
// {{{ setType()
/**
* Sets the element type
*
@ -69,9 +62,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
$this->updateAttributes(array('type'=>$type));
} // end func setType
// }}}
// {{{ setName()
/**
* Sets the input field name
*
@ -85,9 +75,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
$this->updateAttributes(array('name'=>$name));
} //end func setName
// }}}
// {{{ getName()
/**
* Returns the element name
*
@ -100,9 +87,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
return $this->getAttribute('name');
} //end func getName
// }}}
// {{{ setValue()
/**
* Sets the value of the form element
*
@ -116,9 +100,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
$this->updateAttributes(array('value'=>$value));
} // end func setValue
// }}}
// {{{ getValue()
/**
* Returns the value of the form element
*
@ -131,9 +112,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
return $this->getAttribute('value');
} // end func getValue
// }}}
// {{{ toHtml()
/**
* Returns the input field in HTML
*
@ -150,9 +128,6 @@ class HTML_QuickForm_input extends HTML_QuickForm_element
}
} //end func toHtml
// }}}
// {{{ onQuickFormEvent()
/**
* Called by HTML_QuickForm whenever form event is made on this element
*

@ -19,8 +19,6 @@
*/
class HTML_QuickForm_label extends HTML_QuickForm_static
{
// {{{ constructor
/**
* Class constructor
*
@ -36,12 +34,4 @@ class HTML_QuickForm_label extends HTML_QuickForm_static
parent::__construct(null, $label, $text, $attributes);
$this->_type = 'html';
}
/**
* @return string
*/
public function toHtml()
{
return parent::toHtml();
}
}

@ -188,8 +188,4 @@ class HTML_QuickForm_link extends HTML_QuickForm_static
{
return;
} //end func getFrozenHtml
// }}}
} //end class HTML_QuickForm_textarea
?>

@ -2,8 +2,6 @@
class HTML_QuickForm_reset extends HTML_QuickForm_button
{
// {{{ constructor
/**
* Class constructor
*
@ -22,9 +20,6 @@ class HTML_QuickForm_reset extends HTML_QuickForm_button
$this->setType('reset');
} //end constructor
// }}}
// {{{ freeze()
/**
* Freeze the element so that only its value is returned
*
@ -35,7 +30,4 @@ class HTML_QuickForm_reset extends HTML_QuickForm_button
{
return false;
} //end func freeze
// }}}
}

@ -32,9 +32,6 @@
*/
class HTML_QuickForm_static extends HTML_QuickForm_element
{
// {{{ properties
/**
* Display text
* @var string
@ -42,9 +39,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
*/
var $_text = null;
// }}}
// {{{ constructor
/**
* Class constructor
*
@ -61,9 +55,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
$this->_text = $text;
} //end constructor
// }}}
// {{{ setName()
/**
* Sets the element name
*
@ -76,9 +67,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
$this->updateAttributes(array('name'=>$name));
} //end func setName
// }}}
// {{{ getName()
/**
* Returns the element name
*
@ -90,9 +78,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
return $this->getAttribute('name');
} //end func getName
// }}}
// {{{ setText()
/**
* Sets the text
*
@ -105,9 +90,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
$this->_text = $text;
} // end func setText
// }}}
// {{{ setValue()
/**
* Sets the text (uses the standard setValue call to emulate a form element.
*
@ -120,9 +102,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
$this->setText($text);
} // end func setValue
// }}}
// {{{ toHtml()
/**
* Returns the static text element in HTML
*
@ -134,9 +113,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
return $this->_getTabs() . $this->_text;
} //end func toHtml
// }}}
// {{{ getFrozenHtml()
/**
* Returns the value of field without HTML tags
*
@ -148,9 +124,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
return $this->toHtml();
} //end func getFrozenHtml
// }}}
// {{{ onQuickFormEvent()
/**
* Called by HTML_QuickForm whenever form event is made on this element
*
@ -181,9 +154,6 @@ class HTML_QuickForm_static extends HTML_QuickForm_element
return true;
} // end func onQuickFormEvent
// }}}
// {{{ exportValue()
/**
* We override this here because we don't want any values from static elements
*/

@ -34,8 +34,6 @@
*/
class HTML_QuickForm_submit extends HTML_QuickForm_input
{
// {{{ constructor
/**
* Class constructor
*
@ -53,9 +51,6 @@ class HTML_QuickForm_submit extends HTML_QuickForm_input
$this->setType('submit');
} //end constructor
// }}}
// {{{ freeze()
/**
* Freeze the element so that only its value is returned
*
@ -67,9 +62,6 @@ class HTML_QuickForm_submit extends HTML_QuickForm_input
return false;
} //end func freeze
// }}}
// {{{ exportValue()
/**
* Only return the value if it is found within $submitValues (i.e. if
* this particular submit button was clicked)
@ -79,6 +71,4 @@ class HTML_QuickForm_submit extends HTML_QuickForm_input
return $this->_prepareValue($this->_findValue($submitValues), $assoc);
}
// }}}
} //end class HTML_QuickForm_submit
?>

@ -40,7 +40,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
* @since 1.0
* @access private
*/
public $_value = null;
public $_value;
/**
* Class constructor
@ -62,6 +62,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
parent::__construct($elementName, $elementLabel, $attributes);
$this->_persistantFreeze = true;
$this->_type = 'textarea';
$this->_value = null;
}
/**
@ -77,9 +78,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->updateAttributes(array('name'=>$name));
} //end func setName
// }}}
// {{{ getName()
/**
* Returns the element name
*
@ -92,9 +90,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
return $this->getAttribute('name');
} //end func getName
// }}}
// {{{ setValue()
/**
* Sets value for textarea element
*
@ -108,9 +103,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->_value = $value;
} //end func setValue
// }}}
// {{{ getValue()
/**
* Returns the value of the form element
*
@ -123,9 +115,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
return $this->_value;
} // end func getValue
// }}}
// {{{ setWrap()
/**
* Sets wrap type for textarea element
*
@ -139,9 +128,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->updateAttributes(array('wrap' => $wrap));
} //end func setWrap
// }}}
// {{{ setRows()
/**
* Sets height in rows for textarea element
*
@ -155,9 +141,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->updateAttributes(array('rows' => $rows));
} //end func setRows
// }}}
// {{{ setCols()
/**
* Sets width in cols for textarea element
*
@ -171,9 +154,6 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
$this->updateAttributes(array('cols' => $cols));
} //end func setCols
// }}}
// {{{ toHtml()
/**
* Returns the textarea element in HTML
*
@ -206,10 +186,7 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
*/
public function getFrozenHtml()
{
// Modified by Ivan Tcholakov, 16-MAR-2010.
//$value = htmlspecialchars($this->getValue());
$value = @htmlspecialchars($this->getValue(), ENT_COMPAT, HTML_Common::charset());
//
$value = $this->getCleanValue();
if ($this->getAttribute('wrap') == 'off') {
$html = $this->_getTabs() . '<pre>' . $value."</pre>\n";
} else {
@ -281,6 +258,4 @@ class HTML_QuickForm_textarea extends HTML_QuickForm_element
break;
}
}
}

@ -716,7 +716,9 @@ class Template
// Logo
$logo = return_logo($this->theme);
$logoPdf = return_logo($this->theme, false);
$this->assign('logo', $logo);
$this->assign('logo_pdf', $logoPdf);
$this->assign('show_media_element', 1);
}

@ -435,6 +435,15 @@ class Tracking
$lesson_status = $row['mystatus'];
$score = $row['myscore'];
$time_for_total = $row['mytime'];
if (self::minimunTimeAvailable($session_id, $course_id)) {
$timeCourse = self::getCalculateTime($user_id, $course_id, $session_id);
Session::write('trackTimeCourse', $timeCourse);
$lp_time = $timeCourse[TOOL_LEARNPATH];
$lpTime = (int) $lp_time[$lp_id];
$time_for_total = $lpTime;
}
$time = learnpathItem::getScormTimeFromParameter('js', $row['mytime']);
if ($score == 0) {
@ -1836,6 +1845,30 @@ class Tracking
$courseId = (int) $courseId;
$session_id = (int) $session_id;
if (self::minimunTimeAvailable($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;
}
}
}
} else {
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$sql = 'SELECT login_course_date
FROM '.$tbl_track_login.'
@ -1858,6 +1891,7 @@ class Tracking
}
}
}
}
return false;
}
@ -1882,14 +1916,26 @@ class Tracking
$student_id = (int) $student_id;
$session_id = (int) $session_id;
$courseId = $courseInfo['real_id'];
$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 DESC
LIMIT 0,1';
if (self::minimunTimeAvailable($session_id, $courseId)) {
// Show the last date on which the user acceed the session when it was active
$where_condition = '';
$userInfo = api_get_user_info($student_id);
if ($userInfo['status'] == 5 && $session_id > 0) {
// fin de acceso a la sesión
$sessionInfo = SessionManager::fetch($session_id);
$last_access = $sessionInfo['access_end_date'];
$where_condition = ' AND logout_course_date < "'.$last_access.'" ';
}
$tbl_track_e_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$sql = "SELECT logout_course_date
FROM $tbl_track_e_course_access
WHERE user_id = $student_id AND
c_id = $courseId AND
session_id = $session_id $where_condition
ORDER BY logout_course_date DESC
LIMIT 0,1";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
@ -1902,6 +1948,7 @@ class Tracking
$now = time();
//If the last connection is > than 7 days, the text is red
//345600 = 7 days in seconds
/*
if ($now - $last_login_date_timestamp > 604800) {
if ($convert_date) {
$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
@ -1910,6 +1957,53 @@ class Tracking
'.Display::return_icon('messagebox_warning.gif').'
</a>'
: null;
return $icon.Display::label($last_login_date, 'warning');
} else {
return $last_login_date;
}
} else {
*/
if ($convert_date) {
return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
} else {
return $last_login_date;
}
//}
}
}
} else {
$tbl_track_e_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$sql = "SELECT logout_course_date
FROM $tbl_track_e_course_access
WHERE user_id = $student_id AND
c_id = $courseId AND
session_id = $session_id
ORDER BY logout_course_date DESC
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;
}
//see #5736
$last_login_date_timestamp = api_strtotime($last_login_date);
$now = time();
//If the last connection is > than 7 days, the text is red
//345600 = 7 days in seconds
if ($now - $last_login_date_timestamp > 604800) {
if ($convert_date) {
$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
$icon = api_is_allowed_to_edit() ?
'<a href="'.api_get_path(
WEB_CODE_PATH
).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang(
'RemindInactiveUser'
).'">
'.Display::return_icon('messagebox_warning.gif').'
</a>'
: null;
return $icon.Display::label($last_login_date, 'warning');
} else {
@ -1924,6 +2018,7 @@ class Tracking
}
}
}
}
return false;
}
@ -2782,10 +2877,6 @@ class Tracking
$condition_user1 AND
session_id = $session_id
GROUP BY lp_id, user_id";
if ($debug) {
echo 'get LP results';
var_dump($sql);
}
$rs_last_lp_view_id = Database::query($sql);
$global_result = 0;
@ -3211,7 +3302,6 @@ class Tracking
WHERE c_id = $course_id $condition_lp";
$result = Database::query($sql);
$session_condition = api_get_session_condition($session_id);
echo $sql;
// calculates time
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result)) {
@ -3683,6 +3773,8 @@ class Tracking
* @param bool $getCount
* @param string $keyword
* @param string $description
* @param string $orderByName
* @param string $orderByDirection
*
* @return mixed
*/
@ -3692,12 +3784,14 @@ class Tracking
$limit = 0,
$getCount = false,
$keyword = '',
$description = ''
$description = '',
$orderByName = '',
$orderByDirection = ''
) {
// table definition
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$coach_id = intval($coach_id);
$coach_id = (int) $coach_id;
$select = " SELECT * FROM ";
if ($getCount) {
@ -3724,6 +3818,15 @@ class Tracking
$tbl_session_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_SESSION);
$access_url_id = api_get_current_access_url_id();
$orderBy = '';
if (!empty($orderByName)) {
if (in_array($orderByName, ['name', 'access_start_date'])) {
$orderByDirection = in_array(strtolower($orderByDirection), ['asc', 'desc']) ? $orderByDirection : 'asc';
$orderByName = Database::escape_string($orderByName);
$orderBy .= " ORDER BY $orderByName $orderByDirection";
}
}
$sql = "
$select
(
@ -3756,7 +3859,7 @@ class Tracking
WHERE
access_url_id = $access_url_id
$keywordCondition
) as sessions $limitCondition
) as sessions $limitCondition $orderBy
";
$rs = Database::query($sql);
@ -3768,7 +3871,7 @@ class Tracking
$sessions = [];
while ($row = Database::fetch_array($rs)) {
if ($row['access_start_date'] == '0000-00-00 00:00:00') {
if ($row['access_start_date'] === '0000-00-00 00:00:00') {
$row['access_start_date'] = null;
}
@ -3777,8 +3880,7 @@ class Tracking
if (!empty($sessions)) {
foreach ($sessions as &$session) {
if (empty($session['access_start_date'])
) {
if (empty($session['access_start_date'])) {
$session['status'] = get_lang('SessionActive');
} else {
$time_start = api_strtotime($session['access_start_date'], 'UTC');
@ -5727,6 +5829,10 @@ class Tracking
if (!empty($lp_list) > 0) {
foreach ($lp_list as $lp_id => $learnpath) {
if (!$learnpath['lp_visibility']) {
continue;
}
$progress = self::get_avg_student_progress(
$user_id,
$course,
@ -6720,6 +6826,158 @@ class Tracking
return $html;
}
/**
* @param int $userId
* @param int $courseId
* @param int $sessionId
*
* @return array
*/
public static function getCalculateTime($userId, $courseId, $sessionId)
{
$userId = (int) $userId;
$courseId = (int) $courseId;
$sessionId = (int) $sessionId;
if (empty($userId) || empty($courseId)) {
return [];
}
$lpTime = [];
$sql = "SELECT MIN(date_reg) min, MAX(date_reg) max
FROM track_e_access_complete
WHERE
user_id = $userId AND
c_id = $courseId AND
session_id = $sessionId AND
login_as = 0
ORDER BY date_reg ASC
LIMIT 1";
$rs = Database::query($sql);
$firstConnection = '';
$lastConnection = '';
if (Database::num_rows($rs) > 0) {
$value = Database::fetch_array($rs);
$firstConnection = $value['min'];
$lastConnection = $value['max'];
}
$sql = "SELECT * FROM track_e_access_complete
WHERE
user_id = $userId AND
c_id = $courseId AND
session_id = $sessionId AND
login_as = 0 AND current_id <> 0";
$res = Database::query($sql);
$reg = [];
while ($row = Database::fetch_assoc($res)) {
$reg[$row['id']] = $row;
$reg[$row['id']]['date_reg'] = strtotime($row['date_reg']);
}
$sessions = [];
foreach ($reg as $key => $value) {
$sessions[$value['current_id']][$value['tool']][] = $value;
}
$quizTime = 0;
$result = [];
$totalTime = 0;
foreach ($sessions as $listPerTool) {
$min = 0;
$max = 0;
$sessionDiff = 0;
foreach ($listPerTool as $tool => $results) {
$beforeItem = [];
foreach ($results as $item) {
if (empty($beforeItem)) {
$beforeItem = $item;
continue;
}
$partialTime = $item['date_reg'] - $beforeItem['date_reg'];
if ($item['date_reg'] > $max) {
$max = $item['date_reg'];
}
if (empty($min)) {
$min = $item['date_reg'];
}
if ($item['date_reg'] < $min) {
$min = $item['date_reg'];
}
switch ($tool) {
case TOOL_AGENDA:
case TOOL_FORUM:
case TOOL_ANNOUNCEMENT:
case TOOL_COURSE_DESCRIPTION:
case TOOL_SURVEY:
case TOOL_NOTEBOOK:
case TOOL_GRADEBOOK:
case TOOL_DROPBOX:
case 'Reports':
case 'Videoconference':
case TOOL_LINK:
case TOOL_CHAT:
case 'course-main':
if (!isset($result[$tool])) {
$result[$tool] = 0;
}
$result[$tool] += $partialTime;
break;
case TOOL_LEARNPATH:
if ($item['tool_id'] != $beforeItem['tool_id']) {
continue;
}
if (!isset($lpTime[$item['tool_id']])) {
$lpTime[$item['tool_id']] = 0;
}
$lpTime[$item['tool_id']] += $partialTime;
break;
case TOOL_QUIZ:
if (!isset($lpTime[$item['action_details']])) {
$lpTime[$item['action_details']] = 0;
}
if ($beforeItem['action'] == 'learnpath_id') {
$lpTime[$item['action_details']] += $partialTime;
} else {
$quizTime += $partialTime;
}
break;
}
$beforeItem = $item;
}
}
$sessionDiff += $max - $min;
if ($sessionDiff > 0) {
$totalTime += $sessionDiff;
}
}
$totalLp = 0;
foreach ($lpTime as $value) {
$totalLp += $value;
}
$result[TOOL_LEARNPATH] = $lpTime;
$result[TOOL_QUIZ] = $quizTime;
$result['total_learnpath'] = $totalLp;
$result['total_time'] = $totalTime;
$result['number_connections'] = count($sessions);
$result['first'] = $firstConnection;
$result['last'] = $lastConnection;
return $result;
}
/**
* Gets the IP of a given user, using the last login before the given date.
*
@ -7489,8 +7747,9 @@ class TrackingCourseLog
$direction,
$includeInvitedUsers = false
) {
global $user_ids, $course_code, $export_csv, $csv_content, $session_id;
global $user_ids, $course_code, $export_csv, $session_id;
$csv_content = [];
$course_code = Database::escape_string($course_code);
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
@ -7737,6 +7996,10 @@ class TrackingCourseLog
$users[] = array_values($user_row);
}
if ($export_csv) {
Session::write('csv_content', $csv_content);
}
Session::erase('additional_user_profile_info');
Session::erase('extra_field_info');

@ -1098,7 +1098,8 @@ class UserManager
$encrypt_method = '',
$send_email = false,
$reset_password = 0,
$address = null
$address = null,
$emailTemplate = []
) {
$hook = HookUpdateUser::create();
if (!empty($hook)) {
@ -2996,8 +2997,8 @@ class UserManager
// sessions, BT#14115) but executing a similar query twice and grouping
// the results afterwards in PHP takes about 1/1000th of the time
// (0.1s + 0.0s) for the same set of data, so we do it this way...
$dqlStudent = $dql." WHERE scu.user = :user AND url.accessUrlId = :url ";
$dqlCoach = $dql." WHERE s.generalCoach = :user AND url.accessUrlId = :url ";
$dqlStudent = $dql.' WHERE scu.user = :user AND url.accessUrlId = :url ';
$dqlCoach = $dql.' WHERE s.generalCoach = :user AND url.accessUrlId = :url ';
// Default order
$order = 'ORDER BY sc.name, s.name';
@ -3027,7 +3028,7 @@ class UserManager
if ($orderSetting == 'asc') {
// Put null values at the end
// https://stackoverflow.com/questions/12652034/how-can-i-order-by-null-in-dql
$order = " ORDER BY _isFieldNull asc, s.accessEndDate asc";
$order = ' ORDER BY _isFieldNull asc, s.accessEndDate asc';
}
break;
}
@ -3148,10 +3149,7 @@ class UserManager
$ignore_visibility_for_admins
);
$courseIsVisible = !in_array(
$course['visibility'],
$closedVisibilityList
);
$courseIsVisible = !in_array($course['visibility'], $closedVisibilityList);
if ($courseIsVisible === false || $sessionCourseVisibility == SESSION_INVISIBLE) {
$blockedCourseCount++;
}
@ -3176,6 +3174,19 @@ class UserManager
}
}
$collapsed = '';
$collapsedAction = '';
if ($collapsable) {
$collapsableData = Sessionmanager::getCollapsableData(
$user_id,
$session_id,
$extraField,
$collapsableLink
);
$collapsed = $collapsableData['collapsed'];
$collapsedAction = $collapsableData['collapsable_link'];
}
$categories[$row['session_category_id']]['sessions'][] = [
'session_name' => $row['name'],
'session_id' => $row['id'],
@ -3184,6 +3195,8 @@ class UserManager
'coach_access_start_date' => $row['coach_access_start_date'] ? $row['coach_access_start_date']->format('Y-m-d H:i:s') : null,
'coach_access_end_date' => $row['coach_access_end_date'] ? $row['coach_access_end_date']->format('Y-m-d H:i:s') : null,
'courses' => $courseList,
'collapsed' => $collapsed,
'collapsable_link' => $collapsedAction,
];
}
@ -4587,8 +4600,8 @@ class UserManager
/**
* Deletes a contact.
*
* @param int user friend id
* @param bool true will delete ALL friends relationship from $friend_id
* @param bool $friend_id
* @param bool $real_removed true will delete ALL friends relationship
* @param string $with_status_condition
*
* @author isaac flores paz <isaac.flores@dokeos.com>
@ -5924,7 +5937,7 @@ SQL;
*/
public static function loginAsUser($userId, $checkIfUserCanLoginAs = true)
{
$userId = intval($userId);
$userId = (int) $userId;
$userInfo = api_get_user_info($userId);
// Check if the user is allowed to 'login_as'
@ -5938,6 +5951,15 @@ SQL;
}
if ($userId) {
$logInfo = [
'tool' => 'logout',
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => '',
'info' => 'Change user (login as)',
];
Event::registerLog($logInfo);
// Logout the current user
self::loginDelete(api_get_user_id());
@ -5964,6 +5986,15 @@ SQL;
// will be useful later to know if the user is actually an admin or not (example reporting)
Session::write('login_as', true);
$logInfo = [
'tool' => 'login',
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => '',
'info' => $userId,
];
Event::registerLog($logInfo);
return true;
}
@ -5979,8 +6010,8 @@ SQL;
public static function loginDelete($userId)
{
$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$userId = intval($userId);
$query = "DELETE FROM ".$online_table." WHERE login_user_id = $userId";
$userId = (int) $userId;
$query = "DELETE FROM $online_table WHERE login_user_id = $userId";
Database::query($query);
}

@ -885,6 +885,7 @@ class IndexManager
'link' => api_get_path(WEB_PATH).'main/messages/inbox.php',
'title' => get_lang('Inbox').$cant_msg,
];
$items[] = [
'class' => 'new-message-social',
'icon' => Display::return_icon('new-message.png', get_lang('Compose')),
@ -901,6 +902,14 @@ class IndexManager
'title' => get_lang('PendingInvitations').$total_invitations,
];
}
}
$items[] = [
'class' => 'personal-data',
'icon' => Display::return_icon('database.png', get_lang('PersonalDataReport')),
'link' => api_get_path(WEB_CODE_PATH).'social/personal_data.php',
'title' => get_lang('PersonalDataReport'),
];
if (api_get_configuration_value('allow_my_files_link_in_homepage')) {
if (api_get_setting('allow_my_files') !== 'false') {
@ -912,7 +921,6 @@ class IndexManager
];
}
}
}
$items[] = [
'class' => 'profile-social',
@ -946,6 +954,17 @@ class IndexManager
];
}
if (true === api_get_configuration_value('whispeak_auth_enabled')) {
$itemTitle = WhispeakAuthPlugin::create()->get_title();
$items[] = [
'class' => 'whispeak-enrollment',
'icon' => Display::return_icon('addworkuser.png', $itemTitle),
'link' => WhispeakAuthPlugin::getEnrollmentUrl(),
'title' => $itemTitle,
];
}
return $items;
}
@ -1329,10 +1348,7 @@ class IndexManager
if ($specialCourses) {
if ($categoryCodeFilter) {
$specialCourses = self::filterByCategory(
$specialCourses,
$categoryCodeFilter
);
$specialCourses = self::filterByCategory($specialCourses, $categoryCodeFilter);
}
$this->tpl->assign('courses', $specialCourses);
// Ofaj
@ -1342,6 +1358,7 @@ class IndexManager
);
$courseCompleteList = array_merge($courseCompleteList, $specialCourses);
}
if ($courses['in_category'] || $courses['not_category']) {
foreach ($courses['in_category'] as $courseData) {
if (!empty($courseData['courses'])) {
@ -1700,7 +1717,9 @@ class IndexManager
$session_id,
'session_course_item'
);
$html_courses_session[] = $c[1];
if (isset($c[1])) {
$html_courses_session[] = $c[1];
}
}
$count_courses_session++;
$count++;

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
require_once __DIR__.'/../inc/global.inc.php';
$type = $_REQUEST['type'];
@ -11,6 +13,27 @@ if (empty($type) || empty($src)) {
$iframe = '';
switch ($type) {
case 'download':
/** @var learnpath $learnPath */
$learnPath = Session::read('oLP');
$itemId = isset($_GET['lp_item_id']) ? $_GET['lp_item_id'] : '';
if (!$learnPath || empty($itemId)) {
api_not_allowed();
}
$file = learnpath::rl_get_resource_link_for_learnpath(
api_get_course_int_id(),
$learnPath->get_id(),
$itemId,
$learnPath->get_view_id()
);
$iframe = Display::return_message(
Display::url(get_lang('Download'), $file, ['class' => 'btn btn-primary']),
'info',
false
);
break;
case 'youtube':
$src = '//www.youtube.com/embed/'.$src;
$iframe .= '<div id="content" style="width: 700px ;margin-left:auto; margin-right:auto;"><br />';

File diff suppressed because it is too large Load Diff

@ -1889,6 +1889,7 @@ class learnpathItem
$sessionLifetime = 3600;
}
if (!Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
$fixedAddedMinute = 5 * 60; // Add only 5 minutes
if ($time > $sessionLifetime) {
error_log("fixAbusiveTime: Total time is too big: $time replaced with: $fixedAddedMinute");
@ -1897,6 +1898,53 @@ class learnpathItem
}
return $time;
} else {
// Calulate minimum and accumulated time
$user_id = api_get_user_id();
$myLP = learnpath::getLpFromSession(api_get_course_id(), $this->lp_id, $user_id);
$timeLp = $myLP->getAccumulateWorkTime();
$timeTotalCourse = $myLP->getAccumulateWorkTimeTotalCourse();
/*
$timeLp = $_SESSION['oLP']->getAccumulateWorkTime();
$timeTotalCourse = $_SESSION['oLP']->getAccumulateWorkTimeTotalCourse();
*/
// Minimum connection percentage
$perc = 100;
// Time from the course
$tc = $timeTotalCourse;
/*if (!empty($sessionId) && $sessionId != 0) {
$sql = "SELECT hours, perc FROM plugin_licences_course_session WHERE session_id = $sessionId";
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$aux = Database::fetch_assoc($res);
$perc = $aux['perc'];
$tc = $aux['hours'] * 60;
}
}*/
// Percentage of the learning paths
$pl = 0;
if (!empty($timeTotalCourse)) {
$pl = $timeLp / $timeTotalCourse;
}
// Minimum time for each learning path
$accumulateWorkTime = ($pl * $tc * $perc / 100);
$time_seg = intval($accumulateWorkTime * 60);
if ($time_seg < $sessionLifetime) {
$sessionLifetime = $time_seg;
}
if ($time > $sessionLifetime) {
$fixedAddedMinute = $time_seg + mt_rand(0, 300);
if (self::DEBUG > 2) {
error_log("Total time is too big: $time replaced with: $fixedAddedMinute");
}
$time = $fixedAddedMinute;
}
return $time;
}
}
/**
@ -2175,10 +2223,9 @@ class learnpathItem
break;
}
}
if (empty($this->prereq_alert) && !$andstatus) {
$this->prereq_alert = get_lang(
'LearnpathPrereqNotCompleted'
);
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
}
return $andstatus;
@ -2451,7 +2498,8 @@ class learnpathItem
) {
/** @var learnpathItem $itemToCheck */
$itemToCheck = $items[$refs_list[$prereqs_string]];
if ($itemToCheck->type == 'quiz') {
if ($itemToCheck->type === 'quiz') {
// 1. Checking the status in current items.
$status = $itemToCheck->get_status(true);
$returnstatus = $status == $this->possible_status[2] || $status == $this->possible_status[3];
@ -2495,8 +2543,18 @@ class learnpathItem
LIMIT 0, 1';
$rs_quiz = Database::query($sql);
if ($quiz = Database::fetch_array($rs_quiz)) {
$minScore = $items[$refs_list[$this->get_id()]]->getPrerequisiteMinScore();
$maxScore = $items[$refs_list[$this->get_id()]]->getPrerequisiteMaxScore();
/** @var learnpathItem $myItemToCheck */
$myItemToCheck = $items[$refs_list[$this->get_id()]];
$minScore = $myItemToCheck->getPrerequisiteMinScore();
$maxScore = $myItemToCheck->getPrerequisiteMaxScore();
if (empty($minScore)) {
// Try with mastery_score
$masteryScoreAsMin = $myItemToCheck->get_mastery_score();
if (!empty($masteryScoreAsMin)) {
$minScore = $masteryScoreAsMin;
}
}
if (isset($minScore) && isset($minScore)) {
// Taking min/max prerequisites values see BT#5776
@ -2542,17 +2600,29 @@ class learnpathItem
exe_exo_id = '.$items[$refs_list[$prereqs_string]]->path.' AND
exe_user_id = '.$user_id.' AND
orig_lp_id = '.$this->lp_id.' AND
orig_lp_item_id = '.$prereqs_string.' ';
orig_lp_item_id = '.$prereqs_string;
$rs_quiz = Database::query($sql);
if (Database::num_rows($rs_quiz) > 0) {
while ($quiz = Database::fetch_array($rs_quiz)) {
$minScore = $items[$refs_list[$this->get_id()]]->getPrerequisiteMinScore();
$maxScore = $items[$refs_list[$this->get_id()]]->getPrerequisiteMaxScore();
/** @var learnpathItem $myItemToCheck */
$myItemToCheck = $items[$refs_list[$this->get_id()]];
$minScore = $myItemToCheck->getPrerequisiteMinScore();
$maxScore = $myItemToCheck->getPrerequisiteMaxScore();
if (empty($minScore)) {
// Try with mastery_score
$masteryScoreAsMin = $myItemToCheck->get_mastery_score();
if (!empty($masteryScoreAsMin)) {
$minScore = $masteryScoreAsMin;
}
}
if (isset($minScore) && isset($minScore)) {
// Taking min/max prerequisites values see BT#5776
if ($quiz['exe_result'] >= $minScore && $quiz['exe_result'] <= $maxScore) {
if ($quiz['exe_result'] >= $minScore &&
$quiz['exe_result'] <= $maxScore
) {
$returnstatus = true;
break;
} else {
@ -2581,6 +2651,24 @@ class learnpathItem
}
}
return $returnstatus;
} elseif ($itemToCheck->type === 'student_publication') {
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
$workId = $items[$refs_list[$prereqs_string]]->path;
$count = get_work_count_by_student($user_id, $workId);
if ($count >= 1) {
$returnstatus = true;
} else {
$returnstatus = false;
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
if (self::DEBUG > 1) {
error_log(
'Student pub, prereq'.$prereqs_string.' not completed',
0
);
}
}
return $returnstatus;
} else {
$status = $itemToCheck->get_status(false);
@ -2651,6 +2739,8 @@ class learnpathItem
return $returnstatus;
}
} else {
return $returnstatus;
}
}
} else {
@ -2701,9 +2791,7 @@ class learnpathItem
}
}
if (!$orstatus && empty($this->prereq_alert)) {
$this->prereq_alert = get_lang(
'LearnpathPrereqNotCompleted'
);
$this->prereq_alert = get_lang('LearnpathPrereqNotCompleted');
}
return $orstatus;

@ -19,8 +19,7 @@ $submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
$type = isset($_GET['type']) ? $_GET['type'] : null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
if ((!$is_allowed_to_edit) || $isStudentView) {
error_log('New LP - User not authorized in lp_add_audio.php');
if (!$is_allowed_to_edit || $isStudentView) {
header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
exit;
}

@ -24,7 +24,6 @@ $lpId = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0;
$submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
$type = isset($_GET['type']) ? $_GET['type'] : null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
$is_allowed_to_edit = api_is_allowed_to_edit(null, false);
$listUrl = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=view&lp_id='.$lpId.'&'.api_get_cidreq().'&isStudentView=true';
@ -47,6 +46,30 @@ if ($learnPath->get_lp_session_id() != api_get_session_id()) {
}
$htmlHeadXtra[] = '<script>'.$learnPath->get_js_dropdown_array()."
function load_cbo(id, previousId) {
if (!id) {
return false;
}
previousId = previousId || 'previous';
var cbo = document.getElementById(previousId);
for (var i = cbo.length - 1; i > 0; i--) {
cbo.options[i] = null;
}
var k=0;
for (var i = 1; i <= child_name[id].length; i++){
var option = new Option(child_name[id][i - 1], child_value[id][i - 1]);
option.style.paddingLeft = '40px';
cbo.options[i] = option;
k = i;
}
cbo.options[k].selected = true;
$('#' + previousId).selectpicker('refresh');
}
$(function() {
if ($('#previous')) {
if('parent is'+$('#idParent').val()) {

@ -30,8 +30,7 @@ $learnpath_id = (int) $_REQUEST['lp_id'];
$submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
$_course = api_get_course_info();
if ((!$is_allowed_to_edit) || ($isStudentView)) {
error_log('New LP - User not authorized in lp_admin_view.php');
if (!$is_allowed_to_edit || $isStudentView) {
header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
exit;
}

@ -85,7 +85,7 @@ function save_item(
if (!is_a($myLP, 'learnpath')) {
if ($debug) {
error_log("mylp variable is not an learnpath object");
error_log('mylp variable is not an learnpath object');
}
return null;
@ -146,7 +146,7 @@ function save_item(
}
} else {
if ($debug > 1) {
error_log("Score not updated");
error_log('Score not updated');
}
}
@ -164,7 +164,7 @@ function save_item(
}
} else {
if ($debug > 1) {
error_log("Status not updated");
error_log('Status not updated');
}
}
@ -248,8 +248,14 @@ function save_item(
) {
if ($score >= $masteryScore) {
$myLPI->set_status('passed');
if ($debug) {
error_log('Set status: passed');
}
} else {
$myLPI->set_status('failed');
if ($debug) {
error_log('Set status: failed');
}
}
$statusIsSet = true;
}
@ -261,6 +267,9 @@ function save_item(
*/
if (!$statusIsSet && !$masteryScore && !$statusSignalReceived) {
if (!empty($status)) {
if ($debug) {
error_log("Set status: $status because: statusSignalReceived ");
}
$myLPI->set_status($status);
$statusIsSet = true;
}
@ -276,6 +285,9 @@ function save_item(
if (!$statusIsSet && $credit == 'no-credit' && !$statusSignalReceived) {
$mode = $myLPI->get_lesson_mode();
if ($mode == 'browse' && $status == 'browsed') {
if ($debug) {
error_log("Set status: $status because mode browse");
}
$myLPI->set_status($status);
$statusIsSet = true;
}
@ -319,6 +331,9 @@ function save_item(
$myStatus = 'failed';
}
}
if ($debug) {
error_log("Set status: $myStatus because lmsFinish || userNavigatesAway");
}
$myLPI->set_status($myStatus);
$statusIsSet = true;
}
@ -410,6 +425,10 @@ function save_item(
$myStatusInDB != 'failed'
) {
$myStatusInMemory = $myLPI->get_status(false);
if ($debug) {
error_log("myStatusInMemory: $myStatusInMemory");
}
if ($myStatusInMemory != $myStatusInDB) {
$myStatus = $myStatusInMemory;
} else {
@ -472,6 +491,15 @@ function save_item(
$return .= "update_stats();";
}
$logInfo = [
'tool' => TOOL_LEARNPATH,
'tool_id' => $myLP->get_id(),
'tool_id_detail' => $myLP->get_current_item_id(),
'action' => 'save_item',
'info' => '',
];
Event::registerLog($logInfo);
// To be sure progress is updated.
$myLP->save_last();

@ -27,8 +27,7 @@ $learnpath_id = (int) $_REQUEST['lp_id'];
$submit = $_POST['submit_button'];
/* MAIN CODE */
if ((!$is_allowed_to_edit) || ($isStudentView)) {
error_log('New LP - User not authorized in lp_build.php');
if (!$is_allowed_to_edit || $isStudentView) {
header('location:lp_controller.php?action=view&lp_id='.$learnpath_id.'&'.api_get_cidreq());
exit;
}

@ -62,7 +62,7 @@ if ($dir) {
$src = $learnPath->fixBlockedLinks($src);
break;
}
$src = 'blank.php?error=prerequisites&prerequisite_message='.$learnPath->error;
$src = 'blank.php?error=prerequisites&prerequisite_message='.Security::remove_XSS($learnPath->error);
break;
case 2:
$learnPath->stop_previous_item();
@ -72,7 +72,7 @@ if ($dir) {
$src = $learnPath->get_link('http', $lpItemId);
$learnPath->start_current_item(); // starts time counter manually if asset
} else {
$src = 'blank.php?error=prerequisites&prerequisite_message='.$learnPath->error;
$src = 'blank.php?error=prerequisites&prerequisite_message='.Security::remove_XSS($learnPath->error);
}
break;
case 3:
@ -116,5 +116,5 @@ if ($debug > 0) {
error_log('New LP - In lp_content.php - Loading '.$src);
}
Session::write('oLP', $learnPath);
header("Location: ".urldecode($src));
header('Location: '.urldecode($src));
exit;

@ -263,13 +263,14 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $
// Select the lp in the database and check which type it is (scorm/chamilo/aicc) to generate the
// right object.
if (!empty($_REQUEST['lp_id'])) {
$lp_id = intval($_REQUEST['lp_id']);
$lp_id = $_REQUEST['lp_id'];
} else {
$lp_id = intval($myrefresh_id);
$lp_id = $myrefresh_id;
}
$lp_id = (int) $lp_id;
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
if (is_numeric($lp_id)) {
if (!empty($lp_id)) {
$sel = "SELECT iid, lp_type FROM $lp_table WHERE c_id = $course_id AND id = $lp_id";
if ($debug > 0) {
error_log(' querying '.$sel);
@ -283,6 +284,14 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $
error_log('Found row type '.$type);
error_log('Calling constructor: '.api_get_course_id().' - '.$lp_id.' - '.api_get_user_id());
}
$logInfo = [
'tool' => TOOL_LEARNPATH,
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => 'lp_load',
];
Event::registerLog($logInfo);
switch ($type) {
case 1:
$oLP = new learnpath(api_get_course_id(), $lpIid, api_get_user_id());
@ -369,6 +378,36 @@ if ($debug) {
error_log('Entered lp_controller.php -+- (action: '.$action.')');
}
$eventLpId = $lp_id = !empty($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : 0;
if (empty($lp_id)) {
if (isset($_SESSION['oLP'])) {
$eventLpId = $_SESSION['oLP']->get_id();
}
}
$lp_detail_id = 0;
switch ($action) {
case '':
case 'list':
$eventLpId = 0;
break;
case 'view':
case 'content':
$lp_detail_id = $_SESSION['oLP']->get_current_item_id();
break;
default:
$lp_detail_id = (!empty($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0);
break;
}
$logInfo = [
'tool' => TOOL_LEARNPATH,
'tool_id' => $eventLpId,
'tool_id_detail' => $lp_detail_id,
'action' => !empty($action) ? $action : 'list',
];
Event::registerLog($logInfo);
// format title to be displayed correctly if QUIZ
$post_title = '';
if (isset($_POST['title'])) {
@ -392,6 +431,54 @@ if ($debug > 0) {
}
switch ($action) {
case 'send_notify_teacher':
// Enviar correo al profesor
$studentInfo = api_get_user_info();
$course_info = api_get_course_info();
global $_configuration;
$root_web = $_configuration['root_web'];
if (api_get_session_id() > 0) {
$session_info = api_get_session_info(api_get_session_id());
$course_name = $session_info['name'];
$course_url = $root_web.'courses/'.$course_info['code'].'/index.php?id_session='.api_get_session_id();
} else {
$course_name = $course_info['title'];
$course_url = $root_web.'courses/'.$course_info['code'].'/index.php?';
}
$url = Display::url($course_name, $course_url, ['title' => get_lang('GoToCourse')]);
$coachList = CourseManager::get_coachs_from_course(api_get_session_id(), api_get_course_int_id());
foreach ($coachList as $coach_course) {
$recipient_name = $coach_course['full_name'];
$coachInfo = api_get_user_info($coach_course['user_id']);
$email = $coachInfo['email'];
$tplContent = new Template(null, false, false, false, false, false);
// variables for the default template
$tplContent->assign('name_teacher', $recipient_name);
$tplContent->assign('name_student', $studentInfo['complete_name']);
$tplContent->assign('course_name', $course_name);
$tplContent->assign('course_url', $url);
//$tplContent->assign('telefono', $telefono);
//$tplContent->assign('prefix', $prefix);
$layoutContent = $tplContent->get_template('mail/content_ending_learnpath.tpl');
$emailBody = $tplContent->fetch($layoutContent);
api_mail_html(
$recipient_name,
$email,
sprintf(get_lang('StudentXFinishedLp'), $studentInfo['complete_name']),
$emailBody,
$studentInfo['complete_name'],
$studentInfo['email'],
true
);
}
Display::addFlash(Display::return_message(get_lang('MessageSent')));
require 'lp_list.php';
break;
case 'add_item':
if (!$is_allowed_to_edit) {
api_not_allowed(true);
@ -451,6 +538,27 @@ switch ($action) {
$description,
$prerequisites
);
} elseif ($_POST['type'] == TOOL_READOUT_TEXT) {
if (isset($_POST['path']) && $_GET['edit'] != 'true') {
$document_id = $_POST['path'];
} else {
$document_id = $_SESSION['oLP']->createReadOutText(
$_course,
$_POST['content_lp'],
$_POST['title'],
$directoryParentId
);
}
$new_item_id = $_SESSION['oLP']->add_item(
$parent,
$previous,
TOOL_READOUT_TEXT,
$document_id,
$post_title,
$description,
$prerequisites
);
} else {
// For all other item types than documents,
// load the item using the item type and path rather than its ID.
@ -736,6 +844,7 @@ switch ($action) {
$is_success = true;
}
Display::addFlash(Display::return_message(get_lang('Updated')));
$url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq();
header('Location: '.$url);
exit;
@ -1007,12 +1116,9 @@ switch ($action) {
$hide_toc_frame = null;
}
$_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame);
$_SESSION['oLP']->set_prerequisite(
isset($_POST['prerequisites']) ? (int) $_POST['prerequisites'] : 0
);
$_SESSION['oLP']->set_use_max_score(
isset($_POST['use_max_score']) ? 1 : 0
);
$_SESSION['oLP']->set_prerequisite(isset($_POST['prerequisites']) ? (int) $_POST['prerequisites'] : 0);
$_SESSION['oLP']->setAccumulateWorkTime(isset($_REQUEST['accumulate_work_time']) ? $_REQUEST['accumulate_work_time'] : 0);
$_SESSION['oLP']->set_use_max_score(isset($_POST['use_max_score']) ? 1 : 0);
$subscribeUsers = isset($_REQUEST['subscribe_users']) ? 1 : 0;
$_SESSION['oLP']->setSubscribeUsers($subscribeUsers);
@ -1041,9 +1147,7 @@ switch ($action) {
}
$extraFieldValue = new ExtraFieldValue('lp');
$params = [
'lp_id' => $_SESSION['oLP']->lp_id,
];
$_REQUEST['item_id'] = $_SESSION['oLP']->lp_id;
$extraFieldValue->saveFieldValues($_REQUEST);
if ($_FILES['lp_preview_image']['size'] > 0) {

@ -159,6 +159,14 @@ $form->addElement('html', '</div>');
$form->addElement('html', '<div class="col-md-2"></div>');
$form->addElement('html', '</div>');
//Start date
// Time Control
if (Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id())) {
$accumulateTime = $_SESSION['oLP']->getAccumulateWorkTime();
$form->addText('accumulate_work_time', [get_lang('LpMinTime'), get_lang('LpMinTimeDescription')]);
$defaults['accumulate_work_time'] = $accumulateTime;
}
// Start date
$form->addElement(
'checkbox',
'activate_start_date_check',
@ -218,6 +226,17 @@ $form->addElement(
get_lang('AccumulateScormTime')
);
$options = learnpath::getIconSelect();
if (!empty($options)) {
$form->addSelect(
'extra_lp_icon',
get_lang('Icon'),
$options
);
$defaults['extra_lp_icon'] = learnpath::getSelectedIcon($lpId);
}
$enableLpExtraFields = false;
if ($enableLpExtraFields) {
$extraField = new ExtraField('lp');
@ -241,7 +260,7 @@ if ($enableLpExtraFields) {
</script>';
}
$htmlHeadXtra[] = '<script>'.$learnPath->get_js_dropdown_array()."</script>";
$htmlHeadXtra[] = '<script>'.$learnPath->get_js_dropdown_array().'</script>';
$defaults['publicated_on'] = !empty($publicated_on) && $publicated_on !== '0000-00-00 00:00:00'
? api_get_local_time($publicated_on)

@ -38,7 +38,6 @@ $learnpath_id = (int) $_REQUEST['lp_id'];
$submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
if (!$is_allowed_to_edit || $isStudentView) {
error_log('New LP - User not authorized in lp_edit_item.php');
header('location:lp_controller.php?action=view&lp_id='.$learnpath_id.'&'.api_get_cidreq());
exit;
}
@ -150,7 +149,6 @@ if (!empty($path_file) && isset($path_parts['extension']) && $path_parts['extens
} else {
echo $learnPath->return_new_tree();
}
echo '</div>';
echo '<div id="doc_form" class="col-md-8">';

@ -25,8 +25,7 @@ $learnpath_id = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : null;
$submit = isset($_POST['submit_button']) ? $_POST['submit_button'] : null;
/* MAIN CODE */
if ((!$is_allowed_to_edit) || ($isStudentView)) {
error_log('New LP - User not authorized in lp_edit_item_prereq.php');
if (!$is_allowed_to_edit || $isStudentView) {
header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
exit;
}

@ -73,35 +73,7 @@ $message = '';
$actions = '';
if ($is_allowed_to_edit) {
if (!empty($dialog_box)) {
switch ($_GET['dialogtype']) {
case 'confirmation':
$message = Display::return_message($dialog_box, 'success');
break;
case 'error':
$message = Display::return_message($dialog_box, 'danger');
break;
case 'warning':
$message = Display::return_message($dialog_box, 'warning');
break;
default:
$message = Display::return_message($dialog_box);
break;
}
}
$actionLeft = '';
if (!$sessionId) {
$actionLeft .= Display::url(
Display::return_icon(
'new_folder.png',
get_lang('AddCategory'),
[],
ICON_SIZE_MEDIUM
),
api_get_self().'?'.api_get_cidreq().'&action=add_lp_category'
);
}
$actionLeft .= Display::url(
Display::return_icon(
'new_learnpath.png',
@ -132,6 +104,18 @@ if ($is_allowed_to_edit) {
'../upload/upload_ppt.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH
);
}
if (!$sessionId) {
$actionLeft .= Display::url(
Display::return_icon(
'new_folder.png',
get_lang('AddCategory'),
[],
ICON_SIZE_MEDIUM
),
api_get_self().'?'.api_get_cidreq().'&action=add_lp_category'
);
}
$actions = Display::toolbarAction('actions-lp', [$actionLeft]);
}
@ -169,7 +153,11 @@ if ($filteredCategoryId) {
}
$test_mode = api_get_setting('server_type');
$showBlockedPrerequisite = api_get_configuration_value('show_prerequisite_as_blocked');
$allowLpChamiloExport = api_get_configuration_value('allow_lp_chamilo_export');
$allowMinTime = Tracking::minimunTimeAvailable(api_get_session_id(), api_get_course_int_id());
$user = api_get_user_entity($userId);
$ending = true;
$data = [];
/** @var CLpCategory $item */
@ -212,15 +200,24 @@ foreach ($categories as $item) {
continue;
}
$showBlockedPrerequisite = api_get_configuration_value('show_prerequisite_as_blocked');
$allowLpChamiloExport = api_get_configuration_value('allow_lp_chamilo_export');
$listData = [];
$lpTimeList = [];
if ($allowMinTime) {
$lpTimeList = Tracking::getCalculateTime($userId, api_get_course_int_id(), api_get_session_id());
}
$options = learnpath::getIconSelect();
if (!empty($flat_list)) {
$max = count($flat_list);
$counter = 0;
$current = 0;
$autolaunch_exists = false;
$accumulateWorkTimeTotal = 0;
if ($allowMinTime) {
$accumulateWorkTimeTotal = learnpath::getAccumulateWorkTimeTotal(api_get_course_int_id());
}
foreach ($flat_list as $id => $details) {
$id = $details['lp_old_id'];
// Validation when belongs to a session.
@ -347,6 +344,13 @@ foreach ($categories as $item) {
);
}
if (!empty($options)) {
$icon = learnpath::getSelectedIconHtml($id);
if (!empty($icon)) {
$icon_learnpath = $icon;
}
}
// Students can see the lp but is inactive
if (!$is_allowed_to_edit && $lpVisibility == false &&
$showBlockedPrerequisite == true
@ -392,6 +396,64 @@ foreach ($categories as $item) {
}
}
if ($progress < 100) {
$ending = false;
}
$dsp_time = '';
$linkMinTime = '';
if ($allowMinTime) {
// Minimum time (in minutes) to pass the learning path
$accumulateWorkTime = learnpath::getAccumulateWorkTimePrerequisite($id, api_get_course_int_id());
if ($accumulateWorkTime > 0) {
$lpTime = isset($lpTimeList[TOOL_LEARNPATH][$id]) ? $lpTimeList[TOOL_LEARNPATH][$id] : 0;
// Connect with the plugin_licences_course_session table
// which indicates what percentage of the time applies
$perc = 100;
// Percentage of the learning paths
$pl = 0;
if (!empty($accumulateWorkTimeTotal)) {
$pl = $accumulateWorkTime / $accumulateWorkTimeTotal;
}
// Minimum time for each learning path
$accumulateWorkTime = ($pl * $accumulateWorkTimeTotal * $perc / 100);
// If the time spent is less than necessary, then we show an icon in the actions column indicating the warning
if ($lpTime < ($accumulateWorkTime * 60)) {
$linkMinTime = Display::return_icon(
'warning.png',
get_lang('LpMinTimeWarning').' - '.api_time_to_hms($lpTime).' / '.api_time_to_hms(
$accumulateWorkTime * 60
)
);
} else {
$linkMinTime = Display::return_icon(
'check.png',
get_lang('LpMinTimeWarning').' - '.api_time_to_hms($lpTime).' / '.api_time_to_hms(
$accumulateWorkTime * 60
)
);
}
$linkMinTime .= '&nbsp;<b>'.api_time_to_hms($lpTime).' / '.api_time_to_hms($accumulateWorkTime * 60).'</b>';
// Calculate the percentage exceeded of the time for the "exceeding the minimum time" bar
if ($lpTime >= ($accumulateWorkTime * 60)) {
$time_progress_perc = '100%';
$time_progress_value = 100;
} else {
$time_progress_value = intval(($lpTime * 100) / ($accumulateWorkTime * 60));
}
if ($time_progress_value < 100) {
$ending = false;
}
$dsp_time = learnpath::get_progress_bar($time_progress_value, '%');
}
}
$token_parameter = "&sec_token=$token";
$dsp_edit_lp = null;
$dsp_publish = null;
@ -404,7 +466,7 @@ foreach ($categories as $item) {
$actionUpdateScormFile = '';
$actionExportToCourseBuild = '';
// Only for "Chamilo" packages
$allowExportCourseFormat = $allowLpChamiloExport && $details['lp_maker'] == 'Chamilo';
$allowExportCourseFormat = $allowLpChamiloExport && $details['lp_maker'] === 'Chamilo';
if ($is_allowed_to_edit) {
// EDIT LP
@ -893,6 +955,7 @@ foreach ($categories as $item) {
'action_subscribe_users' => $subscribeUsers,
'action_update_scorm' => $actionUpdateScormFile,
'action_export_to_course_build' => $actionExportToCourseBuild,
'info_time_prerequisite' => $linkMinTime,
];
$lpIsShown = true;
@ -933,6 +996,7 @@ $template = new Template($nameTools);
$template->assign('subscription_settings', $subscriptionSettings);
$template->assign('is_allowed_to_edit', $is_allowed_to_edit);
$template->assign('is_invitee', api_is_invitee());
$template->assign('is_ending', $ending);
$template->assign('actions', $actions);
$template->assign('categories', $categories);
$template->assign('message', $message);
@ -940,6 +1004,7 @@ $template->assign('introduction', $introduction);
$template->assign('data', $data);
$template->assign('lp_is_shown', $lpIsShown);
$template->assign('filtered_category', $filteredCategoryId);
$template->assign('allow_min_time', $allowMinTime);
$templateName = $template->get_template('learnpath/list.tpl');
$content = $template->fetch($templateName);
$template->assign('content', $content);

@ -11,10 +11,8 @@ use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
*
* @author Yannick Warnier <ywarnier@beeznest.org>
*/
// Flag to allow for anonymous user - needs to be set before global.inc.php.
$use_anonymous = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_course_script();
$course_dir = api_get_course_path().'/scorm';
$course_sys_dir = api_get_path(SYS_COURSE_PATH).$course_dir;
if (empty($_POST['current_dir'])) {

@ -244,7 +244,7 @@ if (!isset($src)) {
}
if (isset($file_info['extension']) &&
api_strtolower(substr($file_info['extension'], 0, 3) == 'pdf')
api_strtolower(substr($file_info['extension'], 0, 3)) == 'pdf'
) {
$src = api_get_path(WEB_CODE_PATH).'lp/lp_view_item.php?lp_item_id='.$lp_item_id.'&'.api_get_cidreq();
}
@ -401,7 +401,6 @@ if ($lp->mode == 'fullscreen') {
window.open('$src','content_id','toolbar=0,location=0,status=0,scrollbars=1,resizable=1');
</script>";
}
// Set flag to ensure lp_header.php is loaded by this script (flag is unset in lp_header.php).
Session::write('loaded_lp_view', true);
$display_none = '';
@ -535,6 +534,7 @@ $template->assign('glossary_tool_available_list', ['true', 'lp', 'exercise_and_l
$gamificationMode = api_get_setting('gamification_mode');
// ...AND this learning path is set in gamification mode, then change the display
$gamificationMode = $gamificationMode && $lp->seriousgame_mode;
$template->assign('gamification_mode', $gamificationMode);
$template->assign('glossary_extra_tools', api_get_setting('show_glossary_in_extra_tools'));
$template->assign('show_glossary_in_documents', api_get_setting('show_glossary_in_documents'));

@ -58,8 +58,7 @@ $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$isStudentView = (empty($_REQUEST['isStudentView']) ? 0 : (int) $_REQUEST['isStudentView']);
$learnpath_id = (int) $_REQUEST['lp_id'];
if ((!$is_allowed_to_edit) || $isStudentView) {
error_log('New LP - User not authorized in lp_view_item.php');
if (!$is_allowed_to_edit || $isStudentView) {
header('Location: '.api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?action=view&lp_id='.$learnpath_id.'&'.api_get_cidreq());
exit;
}

@ -303,7 +303,7 @@ function LMSInitialize() {
dataType: 'script',
async: false,
success:function(data) {
jQuery("video:not(.skip), audio:not(.skip)").mediaelementplayer();
$('video:not(.skip), audio:not(.skip)').mediaelementplayer();
}
});
@ -843,7 +843,7 @@ function LMSSetValue(param, val) {
echo " var mycommit = LMSCommit('force');";
}
?>
return(return_value);
return return_value;
}
/**
@ -1519,7 +1519,9 @@ function switch_item(current_item, next_item){
1,
olms.statusSignalReceived
);
reinit_updatable_vars_list();
xajax_switch_item_toc(
olms.lms_lp_id,
olms.lms_user_id,
@ -2357,6 +2359,7 @@ function attach_glossary_into_scorm(type) {
src = url+'&type=link&src='+src;
src = src.replace('https', 'http');
$(this).attr('href', src);
$(this).attr('target', '_blank');
var myAnchor = $('<a><img width="16px" src="<?php echo Display::returnIconPath('link-external.png'); ?>"/></a>').attr("href", src).attr('target', '_blank').attr('class', 'generated');
$(this).after(myAnchor);
$(this).after('-');
@ -2366,3 +2369,95 @@ function attach_glossary_into_scorm(type) {
}
}
}
/**
* Updates the time bar with the new status. Prevents the need of a page refresh and flickering
* @param integer Number of completed items
* @param integer Number of items in total
* @param string Display mode (absolute 'abs' or percentage '%').Defaults to %
*/
function update_time_bar(nbr_complete, nbr_total, mode)
{
logit_lms('update_progress_bar('+nbr_complete+', '+nbr_total+', '+mode+')',3);
logit_lms(
'update_progress_bar with params: lms_lp_id= ' + olms.lms_lp_id +
', lms_view_id= '+ olms.lms_view_id + ' lms_user_id= '+ olms.lms_user_id,
3
);
if (mode == '') {
mode='%';
}
if (nbr_total == 0) {
nbr_total=1;
}
var percentage = (nbr_complete/nbr_total)*100;
percentage = Math.round(percentage);
var progress_bar = $("#progress_bar_value2");
progress_bar.css('width', percentage + "%");
var mytext = '';
switch(mode){
case 'abs':
mytext = nbr_complete + '/' + nbr_total;
break;
case '%':
default:
mytext = percentage + '%';
break;
}
progress_bar.html(mytext);
return true;
}
/**
* Update chronometer
*/
function update_chronometer(text_hour, text_minute, text_second)
{
$("#hour").text(text_hour);
$("#minute").text(text_minute);
$("#second").text(text_second);
var timerData = {
hour: parseInt($("#hour").text()),
minute: parseInt($("#minute").text()),
second: parseInt($("#second").text())
};
/*
var timerData = {
hour: text_hour,
minute: text_minute,
second: text_second
};
*/
//window.timerInterval = null;
clearInterval(window.timerInterval);
window.timerInterval = setInterval(function(){
// Seconds
timerData.second++;
if(timerData.second >= 60) {
timerData.second = 0;
timerData.minute++;
}
// Minutes
if(timerData.minute >= 60) {
timerData.minute = 0;
timerData.hour++;
}
$("#hour").text(timerData.hour < 10 ? '0' + timerData.hour : timerData.hour);
//$("#hour").text(timerData.hour);
$("#minute").text(timerData.minute < 10 ? '0' + timerData.minute : timerData.minute);
//$("#minute").text(timerData.minute);
$("#second").text(timerData.second < 10 ? '0' + timerData.second : timerData.second);
//$("#second").text(timerData.second);
}, 1000);
return true;
}

@ -13,19 +13,14 @@ require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users();
$this_section = SECTION_TRACKING;
api_block_anonymous_users();
$export_csv = false;
if (isset($_GET['export']) && $_GET['export'] == 'csv') {
$export_csv = true;
}
$id_coach = api_get_user_id();
if (isset($_GET['id_coach']) && $_GET['id_coach'] != '') {
$id_coach = intval($_GET['id_coach']);
} else {
$id_coach = api_get_user_id();
$id_coach = (int) $_GET['id_coach'];
}
$allowToTrack = api_is_platform_admin(true, true) || api_is_teacher();
@ -35,7 +30,7 @@ if (!$allowToTrack) {
}
$htmlHeadXtra[] = api_get_jqgrid_js();
$interbreadcrumb[] = ["url" => "index.php", "name" => get_lang('MySpace')];
$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('MySpace')];
Display::display_header(get_lang('Sessions'));
if (api_is_platform_admin(true, true)) {

@ -121,7 +121,7 @@ if ($isStudent) {
$action = 'filterBySkill';
}
$courses = CourseManager::get_courses_list();
$courses = CourseManager::getCoursesFollowedByUser($userId, DRH);
$tableRows = [];
$reportTitle = null;

@ -175,7 +175,6 @@ $sessionList = SessionManager::getSessionsFollowedByUser(
$friend_html = SocialManager::listMyFriendsBlock($user_id, $link_shared);
$wallSocialAddPost = SocialManager::getWallForm(api_get_self());
// Social Post Wall
$posts = SocialManager::getWallMessagesByUser($friendId);
$socialAutoExtendLink = SocialManager::getAutoExtendLink($user_id, $countPost);
@ -223,7 +222,6 @@ $social_right_content = '';
$listInvitations = '';
if ($show_full_profile) {
// MY GROUPS
$results = $userGroup->get_groups_by_user($friendId, 0);
$grid_my_groups = [];
$max_numbers_of_group = 4;

@ -417,7 +417,8 @@ $(document).ready(function() {
content: onHoverInfo,
position: {
at: 'top center',
my: 'bottom center'
my: 'bottom center',
viewport: $(window)
}
});
}
@ -428,6 +429,36 @@ $(document).ready(function() {
var diffDays = moment(end).diff(start, 'days');
var endDateMinusOne = '';
// If event is not editable then just return the qtip
if (!calEvent.editable) {
var onHoverInfo = '';
{% if calEvent.description %}
if (calEvent.description) {
onHoverInfo = calEvent.description;
}
{% endif %}
{% if on_hover_info.comment %}
if (calEvent.comment) {
onHoverInfo = onHoverInfo + calEvent.comment;
}
{% endif %}
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
$(this).qtip({
overwrite: false,
show: {ready: true},
content: onHoverInfo,
position: {
at: 'top center',
my: 'bottom center',
viewport: $(window)
}
});
return;
}
}
if (end) {
var clone = end.clone();
endDateMinusOne = clone.subtract(1, 'days').format('{{ js_format_date }}');

@ -100,7 +100,7 @@
</a>
</h4>
</div>
{% if show_tutor %}
{% if show_tutor and item.coach_id %}
<div class="block-author">
<div class="author-card">
<a href="{{ item.coach_url }}" class="ajax" data-title="{{ item.coach_name }}">
@ -220,4 +220,4 @@
</div>
<!-- end view session grib -->
{{ catalog_pagination }}
{% endblock %}
{% endblock %}

@ -103,16 +103,24 @@
<table class="table table-hover table-striped">
<thead>
<tr>
<th>{{ "Title"|get_lang }}</th>
<th>
{{ "Title"|get_lang }}
</th>
{% if is_allowed_to_edit %}
<th>{{ "PublicationDate"|get_lang }}</th>
<th>{{ "ExpirationDate"|get_lang }}</th>
<th>{{ "Progress"|get_lang }}</th>
{% if allow_min_time %}
<th>{{ "TimeSpentTimeRequired"|get_lang }}</th>
{% endif %}
<th>{{ "AuthoringOptions"|get_lang }}</th>
{% else %}
{% if not is_invitee %}
<th>{{ "Progress"|get_lang }}</th>
{% endif %}
{% if allow_min_time %}
<th>{{ "TimeSpentTimeRequired"|get_lang }}</th>
{% endif %}
<th>{{ "Actions"|get_lang }}</th>
{% endif %}
</tr>
@ -140,12 +148,26 @@
<td>
{{ row.dsp_progress }}
</td>
{% if allow_min_time %}
<td>
{% if row.info_time_prerequisite %}
{{ row.info_time_prerequisite }}
{% endif %}
</td>
{% endif %}
{% else %}
{% if not is_invitee %}
<td>
{{ row.dsp_progress }}
</td>
{% endif %}
{% if allow_min_time %}
<td>
{% if row.info_time_prerequisite %}
{{ row.info_time_prerequisite }}
{% endif %}
</td>
{% endif %}
{% endif %}
<td>
{{ row.action_build }}
@ -485,6 +507,21 @@
{% endif %}
{% endfor %}
</div>
{% if not is_invitee and lp_is_shown and allow_min_time %}
<div class="controls text-center">
{% if not is_ending %}
<button class="btn btn-primary" type="button" disabled>
{{ 'IHaveFinishedTheLessonsNotifyTheTeacher'|get_lang }}
</button>
{% else %}
<a href="{{ web_self ~ "?" ~ _p.web_cid_query ~ "&action=send_notify_teacher" }}" class="btn btn-primary">
{{ 'IHaveFinishedTheLessonsNotifyTheTeacher'|get_lang }}
</a>
{% endif %}
</div>
{% endif %}
{% if is_allowed_to_edit and not lp_is_shown %}
<div id="no-data-view">
<h2>{{ "LearningPaths"|get_lang }}</h2>

@ -14,7 +14,7 @@
{% else %}
<div class="item {{ item.css_level }}" title="{{ item.description }}">
<a name="atoc_{{ item.id }}"></a>
<a class="items-list" href="#"
<a data-type="type-{{ item.type }}" class="items-list" href="#"
onclick="switch_item('{{ item.current_id }}','{{ item.id }}'); return false;">
{{ item.title }}
</a>
@ -40,7 +40,7 @@
<li id="toc_{{ item.id }}" class="{{ item.class }} item-{{ item.type }}">
<div class="sub-item type-{{ item.type }}">
<a name="atoc_{{ item.id }}"></a>
<a class="item-action" href="#"
<a data-type="type-{{ item.type }}" class="item-action" href="#"
onclick="switch_item('{{ item.current_id }}','{{ item.id }}'); return false;">
<i class="fa fa-chevron-circle-right" aria-hidden="true"></i>
{{ item.title }}
@ -79,7 +79,7 @@
class="{{ subitem.class }} {{ subitem.type }} {{ counter == final ? 'final':'' }}">
<div class="sub-item item-{{ subitem.type }}">
<a name="atoc_{{ subitem.id }}"></a>
<a class="item-action" href="#"
<a data-type="type-{{ subitem.type }}" class="item-action" href="#"
onclick="switch_item('{{ subitem.current_id }}','{{ subitem.id }}'); return false;">
<i class="fa fa-chevron-circle-right" aria-hidden="true"></i>
{{ subitem.title }}
@ -96,4 +96,4 @@
</div>
</div>
{% endif %}
{% endif %}

@ -20,12 +20,93 @@
</div>
{% endif %}
</div>
{% if show_audio_player %}
<div id="lp_media_file" class="audio-scorm">
{{ media_player }}
</div>
{% endif %}
{% if lp_accumulate_work_time != '' %}
{% set lp_progress %}
<style>
#timer .container{display:table;background:#777;color:#eee;font-weight:bold;width:100%;text-align:center;text-shadow:1px 1px 4px #999;}
#timer .container div{display:table-cell;font-size:24px;padding:0px;width:20px;}
#timer .container .divider{width:10px;color:#ddd;}
#btn-comenzar{box-sizing:border-box;background:#eee;border:none;margin:0 auto;padding:20px;width:100%;font-size:30px;color:#777;}
#btn-comenzar:hover{background:#fff;}
</style>
<script>
$(document).ready(function() {
var timerData = {
hour: parseInt($("#hour").text()),
minute: parseInt($("#minute").text()),
second: parseInt($("#second").text())
};
//window.timerInterval = null;
clearInterval(window.timerInterval);
window.timerInterval = setInterval(function(){
// Seconds
timerData.second++;
if (timerData.second >= 60) {
timerData.second = 0;
timerData.minute++;
}
// Minutes
if (timerData.minute >= 60) {
timerData.minute = 0;
timerData.hour++;
}
$("#hour").text(timerData.hour < 10 ? '0' + timerData.hour : timerData.hour);
$("#minute").text(timerData.minute < 10 ? '0' + timerData.minute : timerData.minute);
$("#second").text(timerData.second < 10 ? '0' + timerData.second : timerData.second);
}, 1000);
})
</script>
<div class="row">
<div class="col-xs-4">
<b>
{{ "ProgressSpentInLp"|get_lang|format(lp_accumulate_work_time) }}
</b>
</div>
<div class="col-xs-8">
<div id="progress_bar">
{{ progress_bar }}
</div>
</div>
</div>
<div class="row">
<div class="col-xs-4">
<b>
{{ "TimeSpentInLp"|get_lang|format(lp_accumulate_work_time) }}
</b>
</div>
<div class="col-xs-8">
<div id="timer">
<div class="container">
<div id="hour">{{ hour }}</div>
<div class="divider">:</div>
<div id="minute">{{ minute }}</div>
<div class="divider">:</div>
<div id="second">{{ second }}</div>
<div id="slash"> / </div>
<div>{{ hour_min }}</div>
</div>
</div>
</div>
</div>
{% endset %}
{% else %}
{% set lp_progress %}
<div id="progress_bar">
{{ progress_bar }}
</div>
{% endset %}
{% endif %}
{% if gamification_mode == 1 %}
<!--- gamification -->
<div id="scorm-gamification">

@ -58,9 +58,7 @@
<div id="listFriends"
class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
{{ social_friend_block }}
<div class="search-friend">
{{ search_friends_form }}
</div>

@ -16,9 +16,9 @@ $course_code = $course_info['code'];
echo '<form action="tutor.php" name="assign" id ="assign">';
echo '<div id="confirmation"></div>';
$id = intval($_GET['id']);
$id = (int) $_GET['id'];
$tblWeeklyReport = Database::get_main_table('rp_reporte_semanas');
$sql = "SELECT * FROM $tblWeeklyReport WHERE id = '$id'";
$sql = "SELECT * FROM $tblWeeklyReport WHERE id = $id";
$sql_tasks = "SELECT id AS colid, title as coltitle
FROM ".Database::get_course_table(TABLE_STUDENT_PUBLICATION)."
WHERE parent_id = 0
@ -27,7 +27,7 @@ $sql_tasks = "SELECT id AS colid, title as coltitle
FROM $tblWeeklyReport
WHERE
course_code = '$course_code' AND
id != '$id'
id != $id
)";
$sql_forum = "SELECT thread_id AS colid, thread_title AS coltitle
FROM ".Database::get_course_table(TABLE_FORUM_THREAD)."
@ -36,7 +36,7 @@ $sql_forum = "SELECT thread_id AS colid, thread_title AS coltitle
FROM $tblWeeklyReport
WHERE
course_code = '$course_code' AND
id != '$id'
id != $id
)";
$rs = Database::fetch_object(Database::query($sql));
$result_tareas = Database::query($sql_tasks);
@ -65,7 +65,7 @@ while ($row = Database::fetch_assoc($result_forum)) {
echo '</select></div><div>';
echo '<div class="row">
<div class="formw">
<button class="save" name="edit" type="button" value="'.get_lang('Edit').'" onClick="save('."$id".');">'.
<button class="save" name="edit" type="button" value="'.get_lang('Edit').'" onClick="save('.$id.');">'.
get_lang('Edit').'</button>
</div>
</div>';

@ -37,7 +37,7 @@ if ($table->per_page == 0) {
}
$formToString = '';
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$projectId = isset($_GET['project_id']) ? (int) $_GET['project_id'] : 0;
$project = TicketManager::getProject($projectId);

@ -8,7 +8,7 @@ require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script(true);
$categoryId = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0;
$categoryId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
$projectId = isset($_GET['project_id']) ? (int) $_GET['project_id'] : '';
$categoryInfo = TicketManager::getCategory($categoryId);

@ -1,12 +1,14 @@
<?php
/* For licensing terms, see /license.txt */
exit;
/**
* @package chamilo.plugin.ticket
*/
require_once __DIR__.'/../inc/global.inc.php';
$userId = intval($_GET['user_id']);
$userId = (int) $_GET['user_id'];
$userInfo = api_get_user_info($userId);
$coursesList = CourseManager::get_courses_list_by_user_id($userId, false, true);

@ -13,7 +13,7 @@ if (!isset($_GET['id']) || !isset($_GET['ticket_id'])) {
api_not_allowed(true);
}
$ticket_id = intval($_GET['ticket_id']);
$ticket_id = (int) $_GET['ticket_id'];
$ticketInfo = TicketManager::get_ticket_detail_by_id($ticket_id);
if (empty($ticketInfo)) {
api_not_allowed(true);

@ -146,21 +146,21 @@ function js_array($array, $name, $key)
function save_ticket()
{
$content = $_POST['content'];
if ($_POST['phone'] != '') {
if (!empty($_POST['phone'])) {
$content .= '<p style="color:red">&nbsp;'.get_lang('Phone').': '.$_POST['phone'].'</p>';
}
$course_id = isset($_POST['course_id']) ? $_POST['course_id'] : '';
$sessionId = isset($_POST['session_id']) ? $_POST['session_id'] : '';
$category_id = isset($_POST['category_id']) ? $_POST['category_id'] : '';
$course_id = isset($_POST['course_id']) ? (int) $_POST['course_id'] : '';
$sessionId = isset($_POST['session_id']) ? (int) $_POST['session_id'] : '';
$category_id = isset($_POST['category_id']) ? (int) $_POST['category_id'] : '';
$project_id = $_POST['project_id'];
$project_id = (int) $_POST['project_id'];
$subject = $_POST['subject'];
$other_area = (int) $_POST['other_area'];
$personal_email = $_POST['personal_email'];
$source = $_POST['source_id'];
$user_id = isset($_POST['user_id']) ? $_POST['user_id'] : 0;
$priority = isset($_POST['priority_id']) ? $_POST['priority_id'] : '';
$status = isset($_POST['status_id']) ? $_POST['status_id'] : '';
$source = (int) $_POST['source_id'];
$user_id = isset($_POST['user_id']) ? (int) $_POST['user_id'] : 0;
$priority = isset($_POST['priority_id']) ? (int) $_POST['priority_id'] : '';
$status = isset($_POST['status_id']) ? (int) $_POST['status_id'] : '';
$file_attachments = $_FILES;
if (TicketManager::add(

@ -30,7 +30,7 @@ if ($table->per_page == 0) {
}
$formToString = '';
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$action = isset($_GET['action']) ? $_GET['action'] : '';
$interbreadcrumb[] = [
@ -82,7 +82,7 @@ switch ($action) {
}
break;
case 'edit':
$item = TicketManager::getProject($_GET['id']);
$item = TicketManager::getProject($id);
if (empty($item)) {
api_not_allowed(true);
}
@ -105,7 +105,7 @@ switch ($action) {
'sys_lastedit_datetime' => api_get_utc_datetime(),
'sys_lastedit_user_id' => api_get_user_id(),
];
TicketManager::updateProject($_GET['id'], $params);
TicketManager::updateProject($id, $params);
Display::addFlash(Display::return_message(get_lang('Updated')));
header("Location: ".api_get_self());
exit;

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

@ -32,7 +32,7 @@ if ($table->per_page == 0) {
}
$formToString = '';
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$action = isset($_GET['action']) ? $_GET['action'] : '';
$interbreadcrumb[] = [
@ -89,7 +89,7 @@ switch ($action) {
$url = api_get_self().'?action=edit&id='.$id;
$form = TicketManager::getStatusForm($url);
$item = TicketManager::getStatus($_GET['id']);
$item = TicketManager::getStatus($id);
$form->setDefaults([
'name' => $item->getName(),
'description' => $item->getDescription(),
@ -102,7 +102,7 @@ switch ($action) {
'name' => $values['name'],
'description' => $values['description'],
];
$cat = TicketManager::updateStatus($_GET['id'], $params);
$cat = TicketManager::updateStatus($id, $params);
Display::addFlash(Display::return_message(get_lang('Updated')));
header("Location: ".api_get_self());
exit;

@ -12,7 +12,7 @@ if (!isset($_POST['ticket_id'])) {
exit;
}
$ticket_id = intval($_POST['ticket_id']);
$ticket_id = (int) $_POST['ticket_id'];
$history = TicketManager::get_assign_log($ticket_id);
?>
<table width="200px" border="0" cellspacing="2" cellpadding="2">

@ -119,12 +119,17 @@ $htmlHeadXtra[] = '<style>
}
</style>';
$ticket_id = $_GET['ticket_id'];
$ticket_id = (int) $_REQUEST['ticket_id'];
$ticket = TicketManager::get_ticket_detail_by_id($ticket_id);
if (!isset($ticket['ticket'])) {
if (!isset($ticket['ticket']) ||
// make sure it's either a user assigned to this ticket, or the reporter, or and admin
!($ticket['ticket']['assigned_last_user'] == $user_id ||
$ticket['ticket']['sys_insert_user_id'] == $user_id ||
$isAdmin)
) {
api_not_allowed(true);
}
if (!isset($_GET['ticket_id'])) {
if (!isset($_REQUEST['ticket_id'])) {
header('Location: '.api_get_path(WEB_CODE_PATH).'ticket/tickets.php');
exit;
}
@ -150,7 +155,7 @@ if (!isset($_GET['ticket_id'])) {
$title = 'Ticket #'.$ticket['ticket']['code'];
if (isset($_REQUEST['close'])) {
TicketManager::close_ticket($_REQUEST['ticket_id'], $user_id);
TicketManager::close_ticket($ticket_id, $user_id);
$ticket['ticket']['status_id'] = TicketManager::STATUS_CLOSE;
$ticket['ticket']['status'] = get_lang('Closed');
}
@ -169,11 +174,11 @@ foreach ($messages as $message) {
$receivedMessage = '';
if (!empty($message['subject'])) {
$receivedMessage = '<b>'.get_lang('Subject').': </b> '.$message['subject'].'<br/>';
$receivedMessage = '<b>'.get_lang('Subject').': </b> '.Security::remove_XSS($message['subject']).'<br />';
}
if (!empty($message['message'])) {
$receivedMessage = '<b>'.get_lang('Message').':</b><br/>'.$message['message'].'<br/>';
$receivedMessage = '<b>'.get_lang('Message').':</b><br />'.Security::remove_XSS($message['message']).'<br />';
}
$attachmentLinks = '';
@ -206,7 +211,7 @@ foreach ($messages as $message) {
$counter++;
}
$subject = get_lang('ReplyShort').': '.$ticket['ticket']['subject'];
$subject = get_lang('ReplyShort').': '.Security::remove_XSS($ticket['ticket']['subject']);
if ($ticket['ticket']['status_id'] != TicketManager::STATUS_FORWARDED &&
$ticket['ticket']['status_id'] != TicketManager::STATUS_CLOSE
@ -219,10 +224,8 @@ if ($ticket['ticket']['status_id'] != TicketManager::STATUS_FORWARDED &&
$formToShow = $form->returnForm();
if ($form->validate()) {
$ticket_id = $_POST['ticket_id'];
$content = $_POST['content'];
$ticket_id = (int) $_POST['ticket_id'];
$messageToSend = '';
$subject = $_POST['subject'];
$message = isset($_POST['confirmation']) ? true : false;
$file_attachments = $_FILES;
@ -258,8 +261,8 @@ if ($ticket['ticket']['status_id'] != TicketManager::STATUS_FORWARDED &&
TicketManager::updateTicket(
[
'priority_id' => $_POST['priority_id'],
'status_id' => $_POST['status_id'],
'priority_id' => (int) $_POST['priority_id'],
'status_id' => (int) $_POST['status_id'],
],
$ticket_id,
api_get_user_id()
@ -311,11 +314,11 @@ if ($ticket['ticket']['status_id'] != TicketManager::STATUS_FORWARDED &&
}
}
$messageToSend .= $content;
$messageToSend .= $_POST['content'];
TicketManager::insertMessage(
$ticket_id,
$subject,
$_POST['subject'],
$messageToSend,
$file_attachments,
$user_id,
@ -353,7 +356,7 @@ echo '<table width="100%" >
<tr>
<td colspan="3">
<h1>'.$title.'</h1>
<h2>'.$ticket['ticket']['subject'].'</h2>
<h2>'.Security::remove_XSS($ticket['ticket']['subject']).'</h2>
<p>
'.$senderData.' '.
get_lang('Created').' '.
@ -407,11 +410,12 @@ if ($ticket['ticket']['course_url'] != null) {
<td colspan="2"></td>
</tr>';
}
echo '<tr>
<td>
<hr />
<b>'.get_lang('Description').':</b> <br />
'.$ticket['ticket']['message'].'
'.Security::remove_XSS($ticket['ticket']['message']).'
<hr />
</td>
</tr>

@ -28,7 +28,7 @@ function initializeReport($course_code)
$resWeeks = Database::query($sqlWeeks);
$weeks = Database::fetch_object($resWeeks);
$obj = Database::fetch_object($res);
$weeksCount = (!isset($_POST['weeksNumber'])) ? (($weeks->semanas == 0) ? 7 : $weeks->semanas) : $_POST['weeksNumber'];
$weeksCount = (!isset($_POST['weeksNumber'])) ? (($weeks->semanas == 0) ? 7 : $weeks->semanas) : (int) $_POST['weeksNumber'];
$weeksCount = Database::escape_string($weeksCount);
Database::query("REPLACE INTO $table_semanas_curso (course_code , semanas) VALUES ('$course_code','$weeksCount')");
if (intval($obj->cant) != $weeksCount) {
@ -57,7 +57,7 @@ function initializeReport($course_code)
if (!Database::query($sql)) {
return false;
} else {
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
$page = (!isset($_GET['page'])) ? 1 : (int) $_GET['page'];
Database::query("UPDATE $table_students_report sr SET sr.work_ok = 1
WHERE CONCAT (sr.user_id,',',sr.week_report_id)

@ -7,17 +7,17 @@
exit;
require_once __DIR__.'/../inc/global.inc.php';
$work_id = intval($_POST['work_id']);
$forum_id = intval($_POST['forum_id']);
$rs_id = intval($_POST['rs_id']);
$work_id = (int) $_POST['work_id'];
$forum_id = (int) $_POST['forum_id'];
$rs_id = (int) $_POST['rs_id'];
api_protect_course_script();
if (!api_is_allowed_to_edit()) {
echo Display::return_message(get_lang("DeniedAccess"), 'error');
} else {
$sql = "UPDATE ".Database::get_main_table('rp_reporte_semanas')."
SET work_id = '$work_id', forum_id = '$forum_id'
WHERE id ='$rs_id'";
SET work_id = $work_id, forum_id = $forum_id
WHERE id = $rs_id";
Database::query($sql);
echo Display::return_message(get_lang('Updated'), 'confirm');
}

@ -1,22 +1,30 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
use ChamiloSession as Session;
/**
* @package chamilo.tracking
*/
require_once __DIR__.'/../inc/global.inc.php';
$current_course_tool = TOOL_TRACKING;
$courseId = api_get_course_id();
$courseInfo = api_get_course_info($courseId);
$courseInfo = api_get_course_info(api_get_course_id());
$courseCode = $courseInfo['code'];
$course_code = $courseCode = $courseInfo['code'];
$sessionId = api_get_session_id();
// PERSON_NAME_DATA_EXPORT is buggy
$sortByFirstName = api_sort_by_first_name();
$from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null;
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$session_id = isset($_REQUEST['id_session']) ? (int) $_REQUEST['id_session'] : 0;
$htmlHeadXtra[] = api_get_js('chartjs/Chart.min.js');
$htmlHeadXtra[] = ' ';
$this_section = SECTION_COURSES;
if ($from == 'myspace') {
@ -25,11 +33,10 @@ if ($from == 'myspace') {
}
// Access restrictions.
$is_allowedToTrack = Tracking::isAllowToTrack($session_id);
$is_allowedToTrack = Tracking::isAllowToTrack($sessionId);
if (!$is_allowedToTrack) {
api_not_allowed(true);
exit;
}
// If the user is a HR director (drh)
@ -50,7 +57,6 @@ if (api_is_drh()) {
}
$coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
if (!empty($coursesFollowedList)) {
$coursesFollowedList = array_keys($coursesFollowedList);
}
@ -65,16 +71,15 @@ if (api_is_drh()) {
// then check if he has also been given access to the corresponding courses
$coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
$coursesFollowedList = array_keys($coursesFollowedList);
if (!in_array(api_get_course_id(), $coursesFollowedList)) {
if (!in_array($courseId, $coursesFollowedList)) {
api_not_allowed(true);
exit;
}
}
}
if ($export_csv) {
if (!empty($session_id)) {
Session::write('id_session', $session_id);
if (!empty($sessionId)) {
Session::write('id_session', $sessionId);
}
ob_start();
}
@ -86,6 +91,7 @@ if (!empty($columnsToHideFromSetting) && isset($columnsToHideFromSetting['column
$columnsToHide = json_encode($columnsToHide);
$csv_content = [];
// Scripts for reporting array hide/show columns
$js = "<script>
// hide column and display the button to unhide it
@ -129,15 +135,12 @@ $htmlHeadXtra[] = $js;
// Database table definitions.
//@todo remove this calls
$TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$TABLETRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLECOURSE = Database::get_main_table(TABLE_MAIN_COURSE);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$TABLEQUIZ = Database::get_course_table(TABLE_QUIZ_TEST);
$sessionId = api_get_session_id();
// Breadcrumbs.
if (isset($_GET['origin']) && $_GET['origin'] == 'resume_session') {
$interbreadcrumb[] = [
@ -158,21 +161,19 @@ $view = isset($_REQUEST['view']) ? $_REQUEST['view'] : '';
$nameTools = get_lang('Tracking');
// getting all the students of the course
if (empty($session_id)) {
$tpl = new Template($nameTools);
// Registered students in a course outside session.
$a_students = CourseManager::get_student_list_from_course_code(
api_get_course_id()
);
// getting all the students of the course
if (empty($sessionId)) {
// Registered students in a course outside session.
$a_students = CourseManager::get_student_list_from_course_code($courseId);
} else {
// Registered students in session.
$a_students = CourseManager::get_student_list_from_course_code(
api_get_course_id(),
true,
$sessionId
);
$a_students = CourseManager::get_student_list_from_course_code($courseId, true, $sessionId);
}
$nbStudents = count($a_students);
$user_ids = array_keys($a_students);
$extra_info = [];
$userProfileInfo = [];
// Getting all the additional information of an additional profile field.
@ -189,9 +190,7 @@ if (isset($_GET['additional_profile_field'])) {
$user_array
);
$extra_info[$fieldId] = UserManager::get_extra_field_information(
$fieldId
);
$extra_info[$fieldId] = UserManager::get_extra_field_information($fieldId);
}
}
@ -201,8 +200,6 @@ Session::write('extra_field_info', $extra_info);
// Display the header.
Display::display_header($nameTools, 'Tracking');
/* MAIN CODE */
$actionsLeft = TrackingCourseLog::actionsLeft('users', $sessionId);
$actionsRight = '<div class="pull-right">';
@ -220,6 +217,7 @@ $users_tracking_per_page = '';
if (isset($_GET['users_tracking_per_page'])) {
$users_tracking_per_page = '&users_tracking_per_page='.intval($_GET['users_tracking_per_page']);
}
$actionsRight .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&export=csv&'.$addional_param.$users_tracking_per_page.'">
'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsRight .= '</div>';
@ -243,13 +241,14 @@ echo Display::toolbarAction(
);
$course_name = get_lang('Course').' '.$courseInfo['name'];
if ($session_id) {
if ($sessionId) {
$titleSession = Display::return_icon(
'session.png',
get_lang('Session'),
[],
ICON_SIZE_SMALL
).' '.api_get_session_name($session_id);
).' '.api_get_session_name($sessionId);
$titleCourse = Display::return_icon(
'course.png',
get_lang('Course'),
@ -273,9 +272,9 @@ $teacherList = CourseManager::getTeacherListFromCourseCodeToString(
);
$coaches = null;
if (!empty($session_id)) {
if (!empty($sessionId)) {
$coaches = CourseManager::get_coachs_from_course_to_string(
$session_id,
$sessionId,
$courseInfo['real_id'],
',',
true,
@ -283,7 +282,6 @@ if (!empty($session_id)) {
);
}
$html = '';
if (!empty($teacherList)) {
$html .= Display::page_subheader2(get_lang('Teachers'));
$html .= $teacherList;
@ -330,12 +328,99 @@ if ($showReporting) {
}
}
$html .= Display::page_subheader2(get_lang('StudentList'));
$trackingColumn = isset($_GET['users_tracking_column']) ? $_GET['users_tracking_column'] : null;
$trackingDirection = isset($_GET['users_tracking_direction']) ? $_GET['users_tracking_direction'] : null;
// PERSON_NAME_DATA_EXPORT is buggy
$sortByFirstName = api_sort_by_first_name();
if ($nbStudents > 0) {
$usersTracking = TrackingCourseLog::get_user_data(null, $nbStudents, $trackingColumn, $trackingDirection, false);
$numberStudentsCompletedLP = 0;
$averageStudentsTestScore = 0;
$scoresDistribution = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
$userScoreList = [];
$listStudentIds = [];
$timeStudent = [];
$certificateCount = 0;
$category = Category::load(
null,
null,
$course_code,
null,
null,
$sessionId
);
if (count($a_students) > 0) {
$hideReports = api_get_configuration_value('hide_course_report_graph');
if ($hideReports == false) {
foreach ($usersTracking as $userTracking) {
$userInfo = api_get_user_info_from_username($userTracking[3]);
if (empty($userInfo)) {
continue;
}
$userId = $userInfo['user_id'];
if ($userTracking[5] === '100%') {
$numberStudentsCompletedLP++;
}
$averageStudentTestScore = substr($userTracking[7], 0, -1);
$averageStudentsTestScore += $averageStudentTestScore;
if ($averageStudentTestScore === '100') {
$reducedAverage = 9;
} else {
$reducedAverage = floor($averageStudentTestScore / 10);
}
if (isset($scoresDistribution[$reducedAverage])) {
$scoresDistribution[$reducedAverage]++;
}
$scoreStudent = substr($userTracking[5], 0, -1) + substr($userTracking[7], 0, -1);
list($hours, $minutes, $seconds) = preg_split('/:/', $userTracking[4]);
$minutes = round((3600 * $hours + 60 * $minutes + $seconds) / 60);
$certificate = false;
if (isset($category[0]) && $category[0]->is_certificate_available($userId)) {
$certificate = true;
$certificateCount++;
}
$listStudent = [
'id' => $userId,
'fullname' => $userInfo['complete_name'],
'score' => floor($scoreStudent / 2),
'total_time' => $minutes,
'avatar' => $userInfo['avatar'],
'certicate' => $certificate,
];
$listStudentIds[] = $userId;
$userScoreList[] = $listStudent;
}
uasort($userScoreList, 'sort_by_order');
$averageStudentsTestScore = round($averageStudentsTestScore / $nbStudents);
$colors = ChamiloApi::getColorPalette(true, true, 10);
$tpl->assign('chart_colors', json_encode($colors));
$tpl->assign('certificate_count', $certificateCount);
$tpl->assign('score_distribution', json_encode($scoresDistribution));
$tpl->assign('json_time_student', json_encode($userScoreList));
$tpl->assign('students_test_score', $averageStudentsTestScore);
$tpl->assign('students_completed_lp', $numberStudentsCompletedLP);
$tpl->assign('number_students', $nbStudents);
$tpl->assign('top_students', $userScoreList);
$trackingSummaryLayout = $tpl->get_template('tracking/tracking_course_log.tpl');
$content = $tpl->fetch($trackingSummaryLayout);
echo $content;
}
}
$html .= Display::page_subheader2(get_lang('StudentList'));
if ($nbStudents > 0) {
$getLangXDays = get_lang('XDays');
$form = new FormValidator(
'reminder_form',
@ -386,20 +471,20 @@ if (count($a_students) > 0) {
$all_datas = [];
$course_code = $_course['id'];
$user_ids = array_keys($a_students);
$table = new SortableTable(
'users_tracking',
['TrackingCourseLog', 'get_number_of_users'],
['TrackingCourseLog', 'get_user_data'],
1
$table = new SortableTableFromArray(
$usersTracking,
1,
20,
'users_tracking'
);
$parameters['cidReq'] = isset($_GET['cidReq']) ? Security::remove_XSS($_GET['cidReq']) : '';
$parameters['id_session'] = $session_id;
$parameters['id_session'] = $sessionId;
$parameters['from'] = isset($_GET['myspace']) ? Security::remove_XSS($_GET['myspace']) : null;
$table->set_additional_parameters($parameters);
$headers = [];
// tab of header texts
$table->set_header(0, get_lang('OfficialCode'), true);
@ -418,21 +503,50 @@ if (count($a_students) > 0) {
$table->set_header(3, get_lang('Login'), false);
$headers['login'] = get_lang('Login');
$table->set_header(4, get_lang('TrainingTime').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('CourseTimeInfo'), ['align' => 'absmiddle', 'hspace' => '3px']), false, ['style' => 'width:110px;']);
$table->set_header(
4,
get_lang('TrainingTime').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('CourseTimeInfo'), ['align' => 'absmiddle', 'hspace' => '3px']),
false,
['style' => 'width:110px;']
);
$headers['training_time'] = get_lang('TrainingTime');
$table->set_header(5, get_lang('CourseProgress').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ScormAndLPProgressTotalAverage'), ['align' => 'absmiddle', 'hspace' => '3px']), false, ['style' => 'width:110px;']);
Display::return_icon(
'info3.gif',
get_lang('ScormAndLPProgressTotalAverage'),
['align' => 'absmiddle', 'hspace' => '3px']
),
false,
['style' => 'width:110px;']
);
$headers['course_progress'] = get_lang('CourseProgress');
$table->set_header(6, get_lang('ExerciseProgress').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ExerciseProgressInfo'), ['align' => 'absmiddle', 'hspace' => '3px']), false, ['style' => 'width:110px;']);
Display::return_icon(
'info3.gif',
get_lang('ExerciseProgressInfo'),
['align' => 'absmiddle', 'hspace' => '3px']
),
false,
['style' => 'width:110px;']
);
$headers['exercise_progress'] = get_lang('ExerciseProgress');
$table->set_header(7, get_lang('ExerciseAverage').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ExerciseAverageInfo'), ['align' => 'absmiddle', 'hspace' => '3px']), false, ['style' => 'width:110px;']);
Display::return_icon('info3.gif', get_lang('ExerciseAverageInfo'), ['align' => 'absmiddle', 'hspace' => '3px']),
false,
['style' => 'width:110px;']
);
$headers['exercise_average'] = get_lang('ExerciseAverage');
$table->set_header(8, get_lang('Score').'&nbsp;'.
Display::return_icon('info3.gif', get_lang('ScormAndLPTestTotalAverage'), ['align' => 'absmiddle', 'hspace' => '3px']), false, ['style' => 'width:110px;']);
Display::return_icon(
'info3.gif',
get_lang('ScormAndLPTestTotalAverage'),
['align' => 'absmiddle', 'hspace' => '3px']
),
false,
['style' => 'width:110px;']
);
$headers['score'] = get_lang('Score');
$table->set_header(9, get_lang('Student_publication'), false);
$headers['student_publication'] = get_lang('Student_publication');
@ -441,7 +555,7 @@ if (count($a_students) > 0) {
$table->set_header(11, get_lang('Classes'));
$headers['clasess'] = get_lang('Classes');
if (empty($session_id)) {
if (empty($sessionId)) {
$table->set_header(12, get_lang('Survey'), false);
$headers['survey'] = get_lang('Survey');
$table->set_header(13, get_lang('FirstLoginInCourse'), false);
@ -529,7 +643,7 @@ if ($export_csv) {
$csv_headers[] = get_lang('Student_publication');
$csv_headers[] = get_lang('Messages');
if (empty($session_id)) {
if (empty($sessionId)) {
$csv_headers[] = get_lang('Survey');
}
@ -543,19 +657,26 @@ if ($export_csv) {
}
ob_end_clean();
$csvContentInSession = Session::read('csv_content');
// Adding headers before the content.
array_unshift($csv_content, $csv_headers);
if ($session_id) {
array_unshift($csvContentInSession, $csv_headers);
if ($sessionId) {
$sessionData = [];
$sessionInfo = api_get_session_info($session_id);
$sessionInfo = api_get_session_info($sessionId);
$sessionDates = SessionManager::parseSessionDates($sessionInfo);
array_unshift($csv_content, [get_lang('Date'), $sessionDates['access']]);
array_unshift($csv_content, [get_lang('SessionName'), $sessionInfo['name']]);
array_unshift($csvContentInSession, [get_lang('Date'), $sessionDates['access']]);
array_unshift($csvContentInSession, [get_lang('SessionName'), $sessionInfo['name']]);
}
Export::arrayToCsv($csv_content, 'reporting_student_list');
Export::arrayToCsv($csvContentInSession, 'reporting_student_list');
exit;
}
Display::display_footer();
function sort_by_order($a, $b)
{
return $a['score'] <= $b['score'];
}

@ -23,9 +23,39 @@ if (empty($fromUserId) || empty($toUserId)) {
if (api_is_drh()) {
$isFollowed = UserManager::is_user_followed_by_drh($fromUserId, api_get_user_id());
if (!$isFollowed) {
api_not_allowed(true);
}
if (api_drh_can_access_all_session_content()) {
$students = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus(
'drh_all',
api_get_user_id(),
false,
0, //$from,
null, //$limit,
null, //$column,
'desc', //$direction,
null, //$keyword,
null, //$active,
null, //$lastConnectionDate,
null,
null,
STUDENT
);
if (empty($students)) {
api_not_allowed(true);
}
$userIdList = [];
foreach ($students as $student) {
$userIdList[] = $student['user_id'];
}
if (!in_array($fromUserId, $userIdList)) {
api_not_allowed(true);
}
} else {
if (!$isFollowed) {
api_not_allowed(true);
}
}
}
$usersData[$toUserId] = api_get_user_info($toUserId);

@ -86,7 +86,6 @@ $columnsToHide = json_encode($columnsToHide);
$csv_content = [];
// Database table definitions.
//@todo remove this calls
$TABLETRACK_DOWNLOADS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$TABLETRACK_EXERCISES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLECOURSE = Database::get_main_table(TABLE_MAIN_COURSE);

@ -30,25 +30,25 @@ if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
$tool_name = get_lang("SubscribeUserToCourse");
$tool_name = get_lang('SubscribeUserToCourse');
$type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
$keyword = isset($_REQUEST['keyword']) ? Security::remove_XSS($_REQUEST['keyword']) : null;
$courseInfo = api_get_course_info();
if ($type == COURSEMANAGER) {
$tool_name = get_lang("SubscribeUserToCourseAsTeacher");
$tool_name = get_lang('SubscribeUserToCourseAsTeacher');
}
//extra entries in breadcrumb
$interbreadcrumb[] = [
"url" => "user.php?".api_get_cidreq(),
"name" => get_lang("ToolUser"),
'url' => 'user.php?'.api_get_cidreq(),
'name' => get_lang('ToolUser'),
];
if ($keyword) {
$interbreadcrumb[] = [
"url" => "subscribe_user.php?type=".$type.'&'.api_get_cidreq(),
"name" => $tool_name,
'url' => 'subscribe_user.php?type='.$type.'&'.api_get_cidreq(),
'name' => $tool_name,
];
$tool_name = get_lang('SearchResults');
}
@ -59,10 +59,10 @@ $list_not_register_user = '';
if (isset($_REQUEST['register'])) {
$userInfo = api_get_user_info($_REQUEST['user_id']);
$message = $userInfo['complete_name_with_username'].' '.get_lang('AddedToCourse');
if ($userInfo) {
if ($type === COURSEMANAGER) {
if (!empty($sessionId)) {
$message = $userInfo['complete_name_with_username'].' '.get_lang('AddedToCourse');
SessionManager::set_coach_to_course_session(
$_REQUEST['user_id'],
$sessionId,
@ -75,14 +75,13 @@ if (isset($_REQUEST['register'])) {
$courseInfo['code'],
COURSEMANAGER
);
Display::addFlash(Display::return_message($message));
}
} else {
CourseManager::subscribeUser(
$_REQUEST['user_id'],
$courseInfo['code']
);
Display::addFlash(Display::return_message($message));
}
}
header('Location:'.api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'&type='.$type);
exit;
@ -92,30 +91,34 @@ if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'subscribe':
if (is_array($_POST['user'])) {
$isSuscribe = [];
foreach ($_POST['user'] as $index => $user_id) {
$userInfo = api_get_user_info($user_id);
if ($userInfo) {
if ($type === COURSEMANAGER) {
if (!empty($sessionId)) {
$is_suscribe[] = SessionManager::set_coach_to_course_session(
$message = $userInfo['complete_name_with_username'].' '.get_lang('AddedToCourse');
$result = SessionManager::set_coach_to_course_session(
$user_id,
$sessionId,
$courseInfo['real_id']
);
if ($result) {
$isSuscribe[] = $message;
}
} else {
$is_suscribe[] = CourseManager::subscribeUser(
$user_id,
$courseInfo['code'],
COURSEMANAGER
);
CourseManager::subscribeUser($user_id, $courseInfo['code'], COURSEMANAGER);
}
} else {
$is_suscribe[] = CourseManager::subscribeUser(
$user_id,
$courseInfo['code']
);
CourseManager::subscribeUser($user_id, $courseInfo['code']);
}
}
}
if (!empty($isSuscribe)) {
foreach ($isSuscribe as $info) {
Display::addFlash(Display::return_message($info));
}
$message = $userInfo['complete_name_with_username'].' '.get_lang('AddedToCourse');
Display::addFlash(Display::return_message($message));
}
}
@ -164,8 +167,7 @@ if (!empty($_POST['keyword'])) {
echo '<br/>'.get_lang('SearchResultsFor').' <span style="font-style: italic ;"> '.$keyword_name.' </span><br>';
}
Display :: display_header($tool_name, "User");
Display :: display_header($tool_name, 'User');
// Build search-form
switch ($type) {
@ -176,7 +178,7 @@ switch ($type) {
$url = api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'&type='.COURSEMANAGER;
break;
}
$actionsLeft = '';
$actionsLeft = Display::url(
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM),
$url

@ -4653,7 +4653,7 @@ function WSSubscribeUserToCourse($params)
if ($debug) {
error_log('WSSubscribeUserToCourse courseCode: '.$courseCode);
}
$result = CourseManager::add_user_to_course($user_id, $courseCode, $status, false, false);
$result = CourseManager::subscribeUser($user_id, $courseCode, $status, 0, 0, false);
if ($result) {
$resultValue = 1;
if ($debug) {
@ -4767,7 +4767,7 @@ function WSSubscribeUserToCourseSimple($params)
if ($debug) {
error_log('Try to register: user_id= '.$user_id.' to course: '.$course_data['code']);
}
if (!CourseManager::add_user_to_course($user_id, $course_data['code'], $status, false, false)) {
if (!CourseManager::subscribeUser($user_id, $course_data['code'], $status, 0, false, false)) {
$result = 'User was not registered possible reasons: User already registered to the course,
Course visibility doesnt allow user subscriptions ';
if ($debug) {

@ -6033,7 +6033,7 @@ class Wiki
'addnew'
).'>'
.Display::return_icon(
'add.png',
'new_document.png',
get_lang('AddNew'),
'',
ICON_SIZE_MEDIUM

@ -14,6 +14,11 @@ if (empty($workId)) {
api_not_allowed(true);
}
$blockAddDocuments = api_get_configuration_value('block_student_publication_add_documents');
if ($blockAddDocuments) {
api_not_allowed(true);
}
$my_folder_data = get_work_data_by_id($workId);
if (empty($my_folder_data)) {
api_not_allowed(true);
@ -59,7 +64,7 @@ if (empty($docId)) {
$documentId = $doc['document_id'];
$docData = DocumentManager::get_document_data_by_id($documentId, $courseInfo['code']);
if ($docData) {
$url = api_get_path(WEB_CODE_PATH).'work/add_document.php?action=delete&id='.$workId.'&document_id='.$documentId.'&'.api_get_cidreq();
$url = $urlDocument.'?action=delete&id='.$workId.'&document_id='.$documentId.'&'.api_get_cidreq();
$link = Display::url(get_lang('Remove'), $url, ['class' => 'btn btn-danger']);
echo $docData['title'].' '.$link.'<br />';
}
@ -69,12 +74,16 @@ if (empty($docId)) {
$documentTree = DocumentManager::get_document_preview(
$courseInfo,
null,
false,
null,
api_get_session_id(),
false,
'/',
api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&'.api_get_cidreq()
api_get_path(WEB_CODE_PATH).'work/add_document.php?id='.$workId.'&'.api_get_cidreq(),
false,
false,
false,
false
);
echo Display::page_subheader(get_lang('Documents'));
echo $documentTree;

@ -6,6 +6,12 @@ $current_course_tool = TOOL_STUDENTPUBLICATION;
api_protect_course_script(true);
$blockEdition = api_get_configuration_value('block_student_publication_edition');
if ($blockEdition && !api_is_platform_admin()) {
api_not_allowed(true);
}
// Including files
require_once 'work.lib.php';

@ -14,6 +14,12 @@ if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
$blockEdition = api_get_configuration_value('block_student_publication_edition');
if ($blockEdition && !api_is_platform_admin()) {
api_not_allowed(true);
}
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();

@ -44,21 +44,14 @@ $token = Security::get_token();
$student_can_edit_in_session = api_is_allowed_to_session_edit(false, true);
$onlyOnePublication = api_get_configuration_value('allow_only_one_student_publication_per_user');
// @todo add an option to allow/block multiple attempts.
/*
if (!empty($workInfo) && !empty($workInfo['qualification'])) {
if ($onlyOnePublication) {
$count = get_work_count_by_student($user_id, $work_id);
if ($count >= 1) {
Display::display_header();
if (api_get_course_setting('student_delete_own_publication') == '1') {
echo Display::return_message(get_lang('CantUploadDeleteYourPaperFirst'), 'warning');
} else {
echo Display::return_message(get_lang('YouAlreadySentAPaperYouCantUpload'), 'warning');
api_not_allowed(true);
}
Display::display_footer();
exit;
}
}*/
$homework = get_work_assignment_by_id($workInfo['id']);
$validationStatus = getWorkDateValidationStatus($homework);

@ -28,6 +28,12 @@ $interbreadcrumb[] = [
$my_folder_data = get_work_data_by_id($work['parent_id']);
$courseInfo = api_get_course_info();
$blockScoreEdition = api_get_configuration_value('block_student_publication_score_edition');
if ($blockScoreEdition && !empty($work['qualification']) && !api_is_platform_admin()) {
api_not_allowed(true);
}
protectWork(api_get_course_info(), $work['parent_id']);
$isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh(
@ -130,6 +136,11 @@ if ((user_is_author($id) || $isDrhOfCourse || (api_is_allowed_to_edit() || api_i
}
}
$blockScoreEdition = api_get_configuration_value('block_student_publication_score_edition');
if ($blockScoreEdition && !api_is_platform_admin()) {
$url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$my_folder_data['id'];
}
header('Location: '.$url);
exit;
break;

@ -109,11 +109,9 @@ function get_work_data_by_path($path, $courseId = 0)
*/
function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
{
$id = intval($id);
$courseId = intval($courseId);
if (empty($courseId)) {
$courseId = api_get_course_int_id();
}
$id = (int) $id;
$courseId = ((int) $courseId) ?: api_get_course_int_id();
$course = api_get_course_entity($courseId);
$table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$sessionCondition = '';
@ -121,6 +119,8 @@ function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
$sessionCondition = api_get_session_condition($sessionId, true);
}
$webCodePath = api_get_path(WEB_CODE_PATH);
$sql = "SELECT * FROM $table
WHERE
id = $id AND c_id = $courseId
@ -132,17 +132,23 @@ function get_work_data_by_id($id, $courseId = 0, $sessionId = 0)
if (empty($work['title'])) {
$work['title'] = basename($work['url']);
}
$work['download_url'] = api_get_path(WEB_CODE_PATH).'work/download.php?id='.$work['id'].'&'.api_get_cidreq();
$work['view_url'] = api_get_path(WEB_CODE_PATH).'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
$work['show_url'] = api_get_path(WEB_CODE_PATH).'work/show_file.php?id='.$work['id'].'&'.api_get_cidreq();
$work['download_url'] = $webCodePath.'work/download.php?id='.$work['id'].'&'.api_get_cidreq();
$work['view_url'] = $webCodePath.'work/view.php?id='.$work['id'].'&'.api_get_cidreq();
$work['show_url'] = $webCodePath.'work/show_file.php?id='.$work['id'].'&'.api_get_cidreq();
$work['show_content'] = '';
if ($work['contains_file']) {
$fileInfo = pathinfo($work['title']);
if (is_array($fileInfo) &&
!empty($fileInfo['extension']) &&
in_array($fileInfo['extension'], ['jpg', 'png', 'gif'])
) {
$work['show_content'] = '<img src="'.$work['show_url'].'"/>';
$fileType = mime_content_type(
api_get_path(SYS_COURSE_PATH).$course->getDirectory().'/'.$work['url']
);
if (in_array($fileType, ['image/jpeg', 'image/jpg', 'image/png', 'image/gif'])) {
$work['show_content'] = Display::img($work['show_url'], $work['title']);
} elseif (false !== strpos($fileType, 'video/')) {
$work['show_content'] = Display::tag(
'video',
get_lang('FileFormatNotSupported'),
['src' => $work['show_url']]
);
}
}
@ -1404,6 +1410,7 @@ function getWorkListTeacher(
}
$url = api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq();
$blockEdition = api_get_configuration_value('block_student_publication_edition');
while ($work = Database::fetch_array($result, 'ASSOC')) {
$workId = $work['id'];
$work['type'] = Display::return_icon('work.png');
@ -1456,10 +1463,14 @@ function getWorkListTeacher(
$work['title'] .= ' '.Display::label(get_count_work($work['id']), 'success');
$work['sent_date'] = api_get_local_time($work['sent_date']);
$editLink = Display::url(
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL),
api_get_path(WEB_CODE_PATH).'work/edit_work.php?id='.$workId.'&'.api_get_cidreq()
);
if ($blockEdition && !api_is_platform_admin()) {
$editLink = '';
} else {
$editLink = Display::url(
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL),
api_get_path(WEB_CODE_PATH).'work/edit_work.php?id='.$workId.'&'.api_get_cidreq()
);
}
$correctionLink = '&nbsp;'.Display::url(
Display::return_icon('upload_package.png', get_lang('UploadCorrections'), '', ICON_SIZE_SMALL),
@ -1932,6 +1943,9 @@ function get_work_user_list(
ICON_SIZE_SMALL
);
$blockEdition = api_get_configuration_value('block_student_publication_edition');
$blockScoreEdition = api_get_configuration_value('block_student_publication_score_edition');
while ($work = Database::fetch_array($result, 'ASSOC')) {
$item_id = $work['id'];
// Get the author ID for that document from the item_property table
@ -2015,7 +2029,10 @@ function get_work_user_list(
if ($qualification_exists) {
$feedback .= ' ';
}
$feedback .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
$feedback .= '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang(
'View'
).'">'.
$count.' '.Display::returnFontAwesomeIcon('comments-o').'</a> ';
}
@ -2049,9 +2066,13 @@ function get_work_user_list(
// Actions.
$action = '';
if (api_is_allowed_to_edit()) {
$action .= '<a
href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'"
title="'.get_lang('View').'">'.$rateIcon.'</a> ';
if ($blockScoreEdition && !api_is_platform_admin() && !empty($work['qualification_score'])) {
$rateLink = '';
} else {
$rateLink = '<a href="'.$url.'view.php?'.api_get_cidreq().'&id='.$item_id.'" title="'.get_lang('View').'">'.
$rateIcon.'</a> ';
}
$action .= $rateLink;
if ($unoconv && empty($work['contains_file'])) {
$action .= '<a f
@ -2125,14 +2146,25 @@ function get_work_user_list(
} else {
$action .= Display::return_icon('edit_na.png', get_lang('Comment'), [], ICON_SIZE_SMALL);
}
} else {
if ($blockEdition && !api_is_platform_admin()) {
$editLink = '';
} else {
if ($qualification_exists) {
$action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Edit').'" >'.
$editLink = '<a href="'.$url.'edit.php?'.api_get_cidreq(
).'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang(
'Edit'
).'" >'.
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>';
} else {
$action .= '<a href="'.$url.'edit.php?'.api_get_cidreq().'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang('Modify').'">'.
$editLink = '<a href="'.$url.'edit.php?'.api_get_cidreq(
).'&item_id='.$item_id.'&id='.$work['parent_id'].'" title="'.get_lang(
'Modify'
).'">'.
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>';
}
}
$action .= $editLink;
}
if ($work['contains_file']) {
@ -2832,15 +2864,22 @@ function getStudentSubscribedToWork(
* @param int $userId
* @param int $workId
* @param int $courseId
* @param bool $forceAccessForCourseAdmins
*
* @return bool
*/
function allowOnlySubscribedUser($userId, $workId, $courseId)
function allowOnlySubscribedUser($userId, $workId, $courseId, $forceAccessForCourseAdmins = false)
{
if (api_is_platform_admin() || api_is_allowed_to_edit()) {
return true;
}
if ($forceAccessForCourseAdmins) {
if (api_is_course_admin() || api_is_coach()) {
return true;
}
}
return userIsSubscribedToWork($userId, $workId, $courseId);
}
@ -4981,7 +5020,7 @@ function getWorkUserListData(
*/
function downloadFile($id, $course_info, $isCorrection)
{
return getFile($id, $course_info, true, $isCorrection);
return getFile($id, $course_info, true, $isCorrection, true);
}
/**
@ -4989,12 +5028,13 @@ function downloadFile($id, $course_info, $isCorrection)
* @param array $course_info
* @param bool $download
* @param bool $isCorrection
* @param bool $forceAccessForCourseAdmins
*
* @return bool
*/
function getFile($id, $course_info, $download = true, $isCorrection = false)
function getFile($id, $course_info, $download = true, $isCorrection = false, $forceAccessForCourseAdmins = false)
{
$file = getFileContents($id, $course_info, 0, $isCorrection);
$file = getFileContents($id, $course_info, 0, $isCorrection, $forceAccessForCourseAdmins);
if (!empty($file) && is_array($file)) {
return DocumentManager::file_send_for_download(
$file['path'],
@ -5013,10 +5053,11 @@ function getFile($id, $course_info, $download = true, $isCorrection = false)
* @param array $courseInfo
* @param int $sessionId
* @param bool $correction
* @param bool $forceAccessForCourseAdmins
*
* @return array|bool
*/
function getFileContents($id, $courseInfo, $sessionId = 0, $correction = false)
function getFileContents($id, $courseInfo, $sessionId = 0, $correction = false, $forceAccessForCourseAdmins = false)
{
$id = (int) $id;
if (empty($courseInfo) || empty($id)) {
@ -5060,7 +5101,8 @@ function getFileContents($id, $courseInfo, $sessionId = 0, $correction = false)
$isAllow = allowOnlySubscribedUser(
api_get_user_id(),
$row['parent_id'],
$courseInfo['real_id']
$courseInfo['real_id'],
$forceAccessForCourseAdmins
);
if (empty($isAllow)) {
@ -5101,7 +5143,8 @@ function getFileContents($id, $courseInfo, $sessionId = 0, $correction = false)
$is_editor = api_is_allowed_to_edit(true, true, true);
$student_is_owner_of_work = user_is_author($row['id'], api_get_user_id());
if ($is_editor ||
if (($forceAccessForCourseAdmins && $isAllow) ||
$is_editor ||
$student_is_owner_of_work ||
($doc_visible_for_all && $work_is_visible)
) {

@ -120,6 +120,15 @@ if (!empty($groupId)) {
// Stats
Event::event_access_tool(TOOL_STUDENTPUBLICATION);
$logInfo = [
'tool' => TOOL_STUDENTPUBLICATION,
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => $action,
'action_details' => '',
];
Event::registerLog($logInfo);
$groupId = api_get_group_id();
$isTutor = false;
if (!empty($groupId)) {

@ -69,6 +69,7 @@ $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
$actionsRight = '';
$onlyOnePublication = api_get_configuration_value('allow_only_one_student_publication_per_user');
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(
@ -83,6 +84,17 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !api_is_in
);
}
if ($onlyOnePublication) {
$count = get_work_count_by_student(
api_get_user_id(),
$my_folder_data['id']
);
if (!empty($count) && $count >= 1) {
$actionsRight = '';
}
}
$tpl = new Template('');
$content = Display::toolbarAction('toolbar-work', [$actionsLeft, $actionsRight]);

@ -169,8 +169,12 @@ $actionsLeft = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_
Display::return_icon('back.png', get_lang('BackToWorksList'), '', ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfCourse) {
$blockAddDocuments = api_get_configuration_value('block_student_publication_add_documents');
if (!$blockAddDocuments) {
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_document.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('new_document.png', get_lang('AddDocument'), '', ICON_SIZE_MEDIUM).'</a>';
}
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/add_user.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('addworkuser.png', get_lang('AddUsers'), '', ICON_SIZE_MEDIUM).'</a>';
@ -181,8 +185,14 @@ if (api_is_allowed_to_session_edit(false, true) && !empty($workId) && !$isDrhOfC
$display_output = '<a href="'.api_get_path(WEB_CODE_PATH).'work/work_missing.php?'.api_get_cidreq().'&amp;id='.$workId.'&amp;list=without">'.
Display::return_icon('exercice_uncheck.png', get_lang('ViewUsersWithoutTask'), '', ICON_SIZE_MEDIUM)."</a>";
$actionsLeft .= '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
$actionsLeft .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
$editLink = '<a href="'.api_get_path(WEB_CODE_PATH).'work/edit_work.php?'.api_get_cidreq().'&id='.$workId.'">';
$editLink .= Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_MEDIUM).'</a>';
$blockEdition = api_get_configuration_value('block_student_publication_edition');
if ($blockEdition && !api_is_platform_admin()) {
$editLink = '';
}
$actionsLeft .= $editLink;
$count = get_count_work($workId);
if ($count > 0) {

Loading…
Cancel
Save