Update from 1.11.x

pull/3063/head
Julio 7 years ago
parent be1e996a69
commit 2fef24f7ab
  1. 153
      main/auth/courses.php
  2. 132
      main/auth/courses_categories.php
  3. 2
      main/forum/download.php
  4. 50
      main/forum/forumconfig.inc.php
  5. 158
      main/forum/forumfunction.inc.php
  6. 1
      main/forum/iframe_thread.php
  7. 2
      main/forum/index.php
  8. 1
      main/forum/reply.php
  9. 21
      main/forum/viewforum.php
  10. 4
      main/forum/viewforumcategory.php
  11. 45
      main/forum/viewthread.php
  12. 46
      main/gradebook/exercise_jump.php
  13. 17
      main/gradebook/gradebook_display_summary.php
  14. 2
      main/gradebook/gradebook_statistics.php
  15. 6
      main/gradebook/index.php
  16. 22
      main/gradebook/lib/GradebookUtils.php
  17. 13
      main/gradebook/lib/be/category.class.php
  18. 2
      main/gradebook/lib/fe/dataform.class.php
  19. 40
      main/gradebook/lib/fe/displaygradebook.php
  20. 11
      main/gradebook/lib/fe/gradebooktable.class.php
  21. 20
      main/gradebook/lib/gradebook_data_generator.class.php
  22. 74
      main/group/group_creation.php
  23. 3
      main/group/group_space.php
  24. 4
      main/group/settings.php
  25. 45
      main/inc/ajax/admin.ajax.php
  26. 22
      main/inc/ajax/agenda.ajax.php
  27. 26
      main/inc/ajax/chat.ajax.php
  28. 1
      main/inc/ajax/course_home.ajax.php
  29. 6
      main/inc/ajax/lang.ajax.php
  30. 11
      main/inc/ajax/message.ajax.php
  31. 50
      main/inc/ajax/model.ajax.php
  32. 30
      main/inc/ajax/sequence.ajax.php
  33. 99
      main/inc/ajax/social.ajax.php
  34. 114
      main/inc/ajax/statistics.ajax.php
  35. 8
      main/inc/lib/formvalidator/Element/DatePicker.php
  36. 1
      main/inc/lib/formvalidator/Element/DateRangePicker.php
  37. 9
      main/inc/lib/formvalidator/Element/DateTimePicker.php
  38. 72
      main/inc/lib/formvalidator/Element/DateTimeRangePicker.php
  39. 3
      main/inc/lib/nusoap/class.soap_fault.php
  40. 6
      main/inc/lib/nusoap/class.soap_val.php
  41. 2
      main/inc/lib/nusoap/class.soapclient.php
  42. 2
      main/inc/lib/nusoap/class.wsdl.php

@ -29,13 +29,10 @@ if (api_get_setting('course_catalog_published') !== 'true') {
api_block_anonymous_users();
}
$user_can_view_page = false;
// For students
$user_can_view_page = true;
if (api_get_setting('allow_students_to_browse_courses') === 'false') {
$user_can_view_page = false;
} else {
$user_can_view_page = true;
}
//For teachers/admins
@ -56,6 +53,9 @@ $actions = [
'subscribe_to_session',
'search_tag',
'search_session',
'set_collapsable',
'subscribe_course_validation',
'subscribe_course',
];
$action = CoursesAndSessionsCatalog::is(CATALOG_SESSIONS) ? 'display_sessions' : 'display_courses';
@ -126,14 +126,6 @@ if (isset($_POST['submit_edit_course_category']) &&
}
}
// we are deleting a course category
if ($action == 'deletecoursecategory' && isset($_GET['id'])) {
if (!empty($_GET['sec_token']) && $ctok == $_GET['sec_token']) {
$get_id_cat = intval($_GET['id']);
$courseController->delete_course_category($get_id_cat);
}
}
// We are creating a new user defined course category (= Create Course Category).
if (isset($_POST['create_course_category']) &&
isset($_POST['title_course_category']) &&
@ -159,17 +151,6 @@ if (isset($_REQUEST['search_course'])) {
}
}
// Subscribe user to course
if (isset($_REQUEST['subscribe_course'])) {
if (!empty($_GET['sec_token']) && $ctok == $_GET['sec_token']) {
$courseController->subscribe_user(
$_GET['subscribe_course'],
$searchTerm,
$categoryCode
);
}
}
// We are unsubscribing from a course (=Unsubscribe from course).
if (isset($_GET['unsubscribe'])) {
if (!empty($_GET['sec_token']) && $ctok == $_GET['sec_token']) {
@ -189,20 +170,72 @@ if (isset($_POST['unsubscribe'])) {
}
switch ($action) {
case 'subscribe_user_with_password':
$courseController->subscribe_user(
isset($_POST['subscribe_user_with_password']) ? $_POST['subscribe_user_with_password'] : '',
$searchTerm,
isset($_POST['category_code']) ? $_POST['category_code'] : ''
case 'deletecoursecategory':
// we are deleting a course category
if (isset($_GET['id'])) {
if (Security::check_token('get')) {
$courseController->delete_course_category($_GET['id']);
header('Location: '.api_get_self());
exit;
}
}
$courseController->courseList($action);
break;
case 'subscribe_course':
if (api_is_anonymous()) {
header('Location: '.api_get_path(WEB_CODE_PATH).'auth/inscription.php?c='.$courseCodeToSubscribe);
exit;
}
$courseCodeToSubscribe = isset($_GET['subscribe_course']) ? Security::remove_XSS($_GET['subscribe_course']) : '';
if (Security::check_token('get')) {
CourseManager::autoSubscribeToCourse($courseCodeToSubscribe);
header('Location: '.api_get_self());
exit;
}
break;
case 'subscribe_course_validation':
$courseCodeToSubscribe = isset($_GET['subscribe_course']) ? Security::remove_XSS($_GET['subscribe_course']) : '';
$courseInfo = api_get_course_info($courseCodeToSubscribe);
if (empty($courseInfo)) {
header('Location: '.api_get_self());
exit;
}
$message = get_lang('CourseRequiresPassword').' ';
$message .= $courseInfo['title'].' ('.$courseInfo['visual_code'].') ';
$action = api_get_self().
'?action=subscribe_course_validation&sec_token='.Security::getTokenFromSession().'&subscribe_course='.$courseCodeToSubscribe;
$form = new FormValidator(
'subscribe_user_with_password',
'post',
$action
);
$form->addHeader($message);
$form->addElement('hidden', 'sec_token', Security::getTokenFromSession());
$form->addElement('hidden', 'subscribe_user_with_password', $courseInfo['code']);
$form->addElement('text', 'course_registration_code');
$form->addButtonSave(get_lang('SubmitRegistrationCode'));
$content = $form->returnForm();
if ($form->validate()) {
if (sha1($_POST['course_registration_code']) === $courseInfo['registration_code']) {
CourseManager::autoSubscribeToCourse($_POST['subscribe_user_with_password']);
header('Location: '.api_get_self());
exit;
} else {
Display::addFlash(Display::return_message(get_lang('CourseRegistrationCodeIncorrect')), 'warning');
header('Location: '.$action);
exit;
}
}
$template = new Template(get_lang('Subscribe'), true, true, false, false, false);
$template->assign('content', $content);
$template->display_one_col_template();
break;
case 'createcoursecategory':
$courseController->categoryList($action);
break;
case 'deletecoursecategory':
$courseController->courseList($action);
$courseController->categoryList();
break;
case 'sortmycourses':
$courseController->courseList($action);
@ -213,19 +246,6 @@ switch ($action) {
}
header('Location: '.api_get_self());
exit;
/* if (!CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) {
$courseController->courses_categories(
$action,
$categoryCode,
null,
null,
null,
$limit
);
} else {
header('Location: ' . api_get_self());
exit;
}*/
break;
case 'display_random_courses':
if (!$user_can_view_page) {
@ -262,7 +282,7 @@ switch ($action) {
$userId = api_get_user_id();
$confirmed = isset($_GET['confirm']);
$sessionId = intval($_GET['session_id']);
$sessionId = (int) $_GET['session_id'];
if (empty($userId)) {
api_not_allowed();
@ -303,13 +323,13 @@ switch ($action) {
}
SessionManager::subscribeUsersToSession(
$_GET['session_id'],
$sessionId,
[$userId],
SESSION_VISIBLE_READ_ONLY,
false
);
$coursesList = SessionManager::get_course_list_by_session_id($_GET['session_id']);
$coursesList = SessionManager::get_course_list_by_session_id($sessionId);
$count = count($coursesList);
$url = '';
@ -319,10 +339,10 @@ switch ($action) {
} elseif ($count == 1) {
// only one course, so redirect directly to this course
foreach ($coursesList as $course) {
$url = api_get_path(WEB_COURSE_PATH).$course['directory'].'/index.php?id_session='.intval($_GET['session_id']);
$url = api_get_path(WEB_COURSE_PATH).$course['directory'].'/index.php?id_session='.$sessionId;
}
} else {
$url = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.intval($_GET['session_id']);
$url = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$sessionId;
}
header('Location: '.$url);
exit;
@ -343,4 +363,37 @@ switch ($action) {
$courseController->sessionListBySearch($limit);
break;
case 'set_collapsable':
api_block_anonymous_users();
if (!api_get_configuration_value('allow_user_course_category_collapsable')) {
api_not_allowed(true);
}
$userId = api_get_user_id();
$categoryId = isset($_REQUEST['categoryid']) ? (int) $_REQUEST['categoryid'] : 0;
$option = isset($_REQUEST['option']) ? (int) $_REQUEST['option'] : 0;
$redirect = isset($_REQUEST['redirect']) ? $_REQUEST['redirect'] : 0;
if (empty($userId) || empty($categoryId)) {
api_not_allowed(true);
}
$table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "UPDATE $table
SET collapsed = $option
WHERE user_id = $userId AND id = $categoryId";
Database::query($sql);
Display::addFlash(Display::return_message(get_lang('Updated')));
if ($redirect === 'home') {
$url = api_get_path(WEB_PATH).'user_portal.php';
header('Location: '.$url);
exit;
}
$url = api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses';
header('Location: '.$url);
exit;
break;
}

@ -15,21 +15,22 @@ if (isset($_REQUEST['action']) && Security::remove_XSS($_REQUEST['action']) !==
}
$action = !empty($_REQUEST['action']) ? Security::remove_XSS($_REQUEST['action']) : 'display_courses';
global $actions;
$action = in_array($action, $actions) ? $action : 'display_courses';
$showCourses = CoursesAndSessionsCatalog::showCourses();
$showSessions = CoursesAndSessionsCatalog::showSessions();
$pageCurrent = isset($pageCurrent) ? $pageCurrent : isset($_GET['pageCurrent']) ? intval($_GET['pageCurrent']) : 1;
$pageLength = isset($pageLength) ? $pageLength : isset($_GET['pageLength']) ? intval($_GET['pageLength']) : CoursesAndSessionsCatalog::PAGE_LENGTH;
$pageTotal = intval(ceil(intval($countCoursesInCategory) / $pageLength));
$pageCurrent = isset($pageCurrent) ? $pageCurrent : isset($_GET['pageCurrent']) ? (int) $_GET['pageCurrent'] : 1;
$pageLength = isset($pageLength) ? $pageLength : isset($_GET['pageLength']) ? (int) $_GET['pageLength'] : CoursesAndSessionsCatalog::PAGE_LENGTH;
$pageTotal = (int) ceil((int) $countCoursesInCategory / $pageLength);
$cataloguePagination = $pageTotal > 1 ? CourseCategory::getCatalogPagination($pageCurrent, $pageLength, $pageTotal) : '';
$searchTerm = isset($_REQUEST['search_term']) ? Security::remove_XSS($_REQUEST['search_term']) : '';
$codeType = isset($_REQUEST['category_code']) ? Security::remove_XSS($_REQUEST['category_code']) : '';
$date = date('Y-m-d');
if ($showSessions && isset($_POST['date'])) {
$date = $_POST['date'];
} else {
$date = date('Y-m-d');
}
$userInfo = api_get_user_info();
$code = isset($code) ? $code : null;
@ -66,15 +67,17 @@ $code = isset($code) ? $code : null;
} ?>
});
</script>
<div class="row">
<?php
echo '<div class="row">
<div class="col-md-12">
<h2 class="title-courses"><?php echo get_lang('CourseManagement'); ?></h2>
<h2 class="title-courses">'.get_lang('CourseManagement').'</h2>
<div class="search-courses">
<div class="row">
<?php if ($showCourses) {
?>
<div class="col-md-<?php echo $showSessions ? '4' : '6'; ?>">
<?php if (!isset($_GET['hidden_links']) || intval($_GET['hidden_links']) != 1) {
<div class="row">';
if ($showCourses) {
echo '<div class="col-md-'.($showSessions ? '4' : '6').'">';
if (!isset($_GET['hidden_links']) || intval($_GET['hidden_links']) != 1) {
?>
<form method="post"
action="<?php echo CourseCategory::getCourseCategoryUrl(1, $pageLength, 'ALL', 0, 'subscribe'); ?>">
@ -83,9 +86,7 @@ $code = isset($code) ? $code : null;
<label><?php echo get_lang('Search'); ?></label>
<div class="input-group">
<input class="form-control" type="text" name="search_term"
value="<?php echo empty($_POST['search_term'])
? ''
: api_htmlentities($searchTerm); ?>"/>
value="<?php echo empty($_POST['search_term']) ? '' : api_htmlentities($searchTerm); ?>"/>
<div class="input-group-btn">
<button class="btn btn-default" type="submit">
<em class="fa fa-search"></em> <?php echo get_lang('Search'); ?>
@ -94,10 +95,25 @@ $code = isset($code) ? $code : null;
</div>
</form>
<?php
} ?>
</div>
<div class="col-md-<?php echo $showSessions ? '4' : '6'; ?>">
<?php
}
echo '</div>';
echo '<div class="col-md-'.($showSessions ? '4' : '6').'">';
$categoriesSelect = '';
$cacheAvailable = api_get_configuration_value('apc');
$accessUrlId = api_get_current_access_url_id();
if ($cacheAvailable === true) {
$apcVar = api_get_configuration_value('apc_prefix').'_'.$accessUrlId.'_course_categories_select';
if (apcu_exists($apcVar)) {
$categoriesSelect = apcu_fetch($apcVar);
} else {
$categoriesSelect = getOptionSelect($list_categories, $codeType);
apcu_store($apcVar, $categoriesSelect, 60);
}
} else {
$categoriesSelect = getOptionSelect($list_categories, $codeType);
}
$webAction = api_get_path(WEB_CODE_PATH).'auth/courses.php';
$form = '<form action="'.$webAction.'" method="GET">';
$form .= '<input type="hidden" name="action" value="'.$action.'">';
@ -105,30 +121,7 @@ $code = isset($code) ? $code : null;
$form .= '<input type="hidden" name="pageLength" value="'.$pageLength.'">';
$form .= '<div class="form-group">';
$form .= '<label>'.get_lang('CourseCategories').'</label>';
$form .= '<select name="category_code" onchange="submit();" class="selectpicker show-tick form-control">';
foreach ($browse_course_categories[0] as $category) {
$categoryCode = $category['code'];
$countCourse = $category['count_courses'];
if (empty($countCourse)) {
continue;
}
$form .= '<option '.($categoryCode == $codeType ? 'selected="selected" ' : '')
.' value="'.$category['code'].'">'.$category['name'].' ('.$countCourse.') </option>';
if (!empty($browse_course_categories[$categoryCode])) {
foreach ($browse_course_categories[$categoryCode] as $subCategory) {
if (empty($subCategory['count_courses'])) {
continue;
}
$subCategoryCode = $subCategory['code'];
$form .= '<option '.($subCategoryCode == $codeType
? 'selected="selected" '
: '')
.' value="'.$subCategory['code'].'">---';
echo $subCategory['name'].' ('.$subCategory['count_courses'].')</option>';
}
}
}
$form .= '</select>';
$form .= $categoriesSelect;
$form .= '</div>';
$form .= '</form>';
echo $form;
@ -136,22 +129,20 @@ $code = isset($code) ? $code : null;
}
if ($showSessions) {
?>
<div class="col-md-4">
$url = CourseCategory::getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions');
echo '<div class="col-md-4">
<div class="return-catalog">
<a class="btn btn-default btn-lg btn-block"
href="<?php echo CourseCategory::getCourseCategoryUrl(1, $pageLength, null, 0, 'display_sessions'); ?>">
<em class="fa fa-arrow-right"></em> <?php echo get_lang('SessionList'); ?>
href="'.$url.'">
<em class="fa fa-arrow-right"></em>'.get_lang('SessionList').'
</a>
</div>
</div>
<?php
} ?>
</div>
</div>
</div>
</div>
<?php
';
}
echo '</div></div></div></div>';
if ($showCourses && $action != 'display_sessions') {
if (!empty($message)) {
echo Display::return_message($message, 'confirmation', false);
@ -296,6 +287,30 @@ echo '<div class="col-md-12">';
echo $cataloguePagination;
echo '</div>';
function getOptionSelect($categories, $codeType)
{
$html = '';
$html .= '<select name="category_code" onchange="submit();" class="selectpicker form-control">';
foreach ($categories as $category) {
$categoryCode = Security::remove_XSS($category['code']);
$categoryName = Security::remove_XSS($category['name']);
$countCourse = (int) $category['number_courses'];
$level = $category['level'];
if (empty($countCourse)) {
continue;
}
if ($level > 0) {
$separate = str_repeat("--", $level);
} else {
$separate = '';
}
$html .= '<option '.($categoryCode == $codeType ? 'selected="selected" ' : '')
.' value="'.$categoryCode.'">'.$separate.' '.$categoryName.' ('.$countCourse.') </option>';
}
$html .= '</select>';
return $html;
}
/**
* Display the course catalog image of a course.
*
@ -500,9 +515,14 @@ function return_already_registered_label($in_status)
function return_register_button($course, $stok, $code, $search_term)
{
$title = get_lang('Subscribe');
$action = 'subscribe_course';
if (!empty($course['registration_code'])) {
$action = 'subscribe_course_validation';
}
$html = Display::url(
Display::returnFontAwesomeIcon('check').' '.$title,
api_get_self().'?action=subscribe_course&sec_token='.$stok.
api_get_self().'?action='.$action.'&sec_token='.$stok.
'&subscribe_course='.$course['code'].'&search_term='.$search_term.'&category_code='.$code,
['class' => 'btn btn-success btn-sm', 'title' => $title, 'aria-label' => $title]
);

@ -27,7 +27,7 @@ $doc_url = $_GET['file'];
$doc_url = str_replace('///', '&', $doc_url);
//still a space present? it must be a '+' (that got replaced by mod_rewrite)
$doc_url = str_replace(' ', '+', $doc_url);
$doc_url = str_replace('/..', '', $doc_url); //echo $doc_url;
$doc_url = str_replace('/..', '', $doc_url);
$tbl_forum_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
$tbl_forum_post = Database::get_course_table(TABLE_FORUM_POST);

@ -1,50 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @todo move the tool constants to the appropriate place
* @todo make config settings out of $forum_setting
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*
* @version february 2006, dokeos 1.8
*/
/*
Database Variables
*/
$table_categories = Database::get_course_table(TABLE_FORUM_CATEGORY);
$table_forums = Database::get_course_table(TABLE_FORUM);
$table_threads = Database::get_course_table(TABLE_FORUM_THREAD);
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
$table_mailcue = Database::get_course_table(TABLE_FORUM_MAIL_QUEUE);
$table_threads_qualify = Database::get_course_table(
TABLE_FORUM_THREAD_QUALIFY
);
$table_threads_qualify_historical = Database::get_course_table(
TABLE_FORUM_THREAD_QUALIFY_LOG
);
$forum_table_attachment = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
$table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$table_users = Database::get_main_table(TABLE_MAIN_USER);
/*
Some configuration settings
(these can go to the dokeos config settings afterwards)
*/
// if this setting is true then an I-frame will be displayed when replying
$forum_setting['show_thread_iframe_on_reply'] = true;
// if this setting is true then students and teachers can check a checkbox so
// that they receive a mail when somebody replies to the thread
$forum_setting['allow_post_notification'] = true;
// when this setting is true then the course admin can post threads that
// are important. These posts remain on top all the time (until made unsticky)
// these special posts are indicated with a special icon also
$forum_setting['allow_sticky'] = true;
// when this setting is true there will be a column that displays the
// latest post (date and poster) of the given forum.
// This requires quite some sql statements that might slow down the page with the fora.
// note: I'm currently investigating how it would be possible to increase
// the performance of this part.
$forum_setting['show_last_post'] = false;

@ -3,7 +3,6 @@
use Chamilo\CourseBundle\Entity\CForumPost;
use Chamilo\CourseBundle\Entity\CForumThread;
use Chamilo\UserBundle\Entity\User;
use ChamiloSession as Session;
use Doctrine\Common\Collections\Criteria;
@ -2808,7 +2807,7 @@ function updateThread($values)
* @param int $userId Optional. The user ID
* @param int $sessionId
*
* @return int
* @return CForumThread
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*
@ -2993,12 +2992,16 @@ function store_thread(
$lastPostId = $lastPost->getIid();
$lastThread->setThreadLastPost($lastPostId);
$em->merge($lastThread);
$em->flush();
$logInfo = [
'tool' => TOOL_FORUM,
'tool_id' => $values['forum_id'],
'tool_id_detail' => $lastThread->getIid(),
'action' => 'new-post',
'action_details' => '',
'info' => $clean_post_title,
];
Event::registerLog($logInfo);
@ -3102,7 +3105,7 @@ function store_thread(
Display::addFlash(Display::return_message($message, 'success', false));
}
return $lastThread->getIid();
return $lastThread;
}
/**
@ -3130,14 +3133,16 @@ function show_add_post_form($current_forum, $action, $id = '', $form_values = ''
$myThread = isset($_GET['thread']) ? (int) $_GET['thread'] : '';
$forumId = isset($_GET['forum']) ? (int) $_GET['forum'] : '';
$my_post = isset($_GET['post']) ? (int) $_GET['post'] : '';
$giveRevision = isset($_GET['give_revision']) && $_GET['give_revision'] == 1 ? true : false;
$giveRevision = (isset($_GET['give_revision']) && $_GET['give_revision'] == 1);
$url = api_get_self().'?'.http_build_query([
$url = api_get_self().'?'.http_build_query(
[
'action' => $action,
'forum' => $forumId,
'thread' => $myThread,
'post' => $my_post,
]).'&'.api_get_cidreq();
]
).'&'.api_get_cidreq();
$form = new FormValidator(
'thread',
@ -3310,9 +3315,9 @@ function show_add_post_form($current_forum, $action, $id = '', $form_values = ''
// If we are quoting a message we have to retrieve the information of the post we are quoting so that
// we can add this as default to the textarea.
if (($action == 'quote' || $action == 'replymessage' || $giveRevision) && !empty($my_post)) {
// We also need to put the parent_id of the post in a hidden form when
if (($action == 'quote' || $action == 'replymessage' || $giveRevision) && !empty($my_post)) {
// we are quoting or replying to a message (<> reply to a thread !!!)
$form->addHidden('post_parent_id', $my_post);
// If we are replying or are quoting then we display a default title.
@ -3374,17 +3379,32 @@ function show_add_post_form($current_forum, $action, $id = '', $form_values = ''
return false;
}
$postId = 0;
$threadId = 0;
switch ($action) {
case 'newthread':
$myThread = store_thread($current_forum, $values);
Skill::saveSkills($form, ITEM_TYPE_FORUM_THREAD, $myThread);
if ($myThread) {
$threadId = $myThread->getIid();
Skill::saveSkills($form, ITEM_TYPE_FORUM_THREAD, $threadId);
$postId = $myThread->getThreadLastPost();
}
break;
case 'quote':
case 'replythread':
case 'replymessage':
$postId = store_reply($current_forum, $values);
break;
}
if ($postId) {
$postInfo = get_post_information($postId);
if ($postInfo) {
$threadId = $postInfo['thread_id'];
}
if (isset($values['give_revision']) && $values['give_revision'] == 1) {
$extraFieldValues = new ExtraFieldValue('forum_post');
$params = [
@ -3399,11 +3419,11 @@ function show_add_post_form($current_forum, $action, $id = '', $form_values = ''
);
}
if (in_array($action, ['replythread', 'replymessage', 'quote'])) {
if (in_array($action, ['newthread', 'replythread', 'replymessage', 'quote'])) {
$extraFieldValues = new ExtraFieldValue('forum_post');
$params = [
'item_id' => $postId,
'extra_ask_for_revision' => $values['extra_ask_for_revision'],
'extra_ask_for_revision' => isset($values['extra_ask_for_revision']) ? $values['extra_ask_for_revision'] : '',
];
$extraFieldValues->saveFieldValues(
$params,
@ -3413,13 +3433,11 @@ function show_add_post_form($current_forum, $action, $id = '', $form_values = ''
);
}
}
break;
}
$url = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&'.http_build_query(
[
'forum' => $forumId,
'thread' => $myThread,
'thread' => $threadId,
]
);
@ -4401,26 +4419,22 @@ function send_notification_mails($forumId, $thread_id, $reply_info)
$current_forum_category = null;
if (isset($current_forum['forum_category'])) {
$current_forum_category = get_forumcategory_information(
$current_forum['forum_category']
);
$current_forum_category = get_forumcategory_information($current_forum['forum_category']);
}
$send_mails = false;
if ($current_thread['visibility'] == '1' &&
$current_forum['visibility'] == '1' &&
($current_forum_category && $current_forum_category['visibility'] == '1') &&
$current_forum['approval_direct_post'] != '1'
) {
$send_mails = true;
} else {
$send_mails = false;
}
// The forum category, the forum, the thread and the reply are visible to the user
if ($send_mails) {
if (!empty($forumId)) {
send_notifications($forumId, $thread_id);
}
if ($send_mails && !empty($forumId)) {
$postId = isset($reply_info['new_post_id']) ? $reply_info['new_post_id'] : 0;
send_notifications($forumId, $thread_id, $postId);
} else {
$table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
if (isset($current_forum['forum_id'])) {
@ -4490,7 +4504,8 @@ function handle_mail_cue($content, $id)
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
send_mail($row, get_thread_information($post_info['forum_id'], $post_info['thread_id']));
$forumInfo = get_forum_information($post_info['forum_id']);
send_mail($row, $forumInfo, get_thread_information($post_info['forum_id'], $post_info['thread_id']), $post_info);
}
} elseif ($content == 'thread') {
// Sending the mail to all the users that wanted to be informed for replies on this thread.
@ -4507,7 +4522,8 @@ function handle_mail_cue($content, $id)
GROUP BY users.email";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
send_mail($row, get_thread_information($row['forum_id'], $id));
$forumInfo = get_forum_information($row['forum_id']);
send_mail($row, $forumInfo, get_thread_information($row['forum_id'], $id));
}
// Deleting the relevant entries from the mailcue.
@ -4538,28 +4554,58 @@ function handle_mail_cue($content, $id)
*
* @param array
* @param array
* @param array
* @param array
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*
* @version february 2006, dokeos 1.8
*/
function send_mail($user_info = [], $thread_information = [])
function send_mail($userInfo, $forumInfo, $thread_information, $postInfo = [])
{
if (empty($userInfo) || empty($forumInfo) || empty($thread_information)) {
return false;
}
$_course = api_get_course_info();
$user_id = api_get_user_id();
$subject = get_lang('NewForumPost').' - '.$_course['official_code'];
$thread_link = '';
if (isset($thread_information) && is_array($thread_information)) {
$thread_link = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&forum='.$thread_information['forum_id'].'&thread='.$thread_information['thread_id'];
$thread_link = api_get_path(WEB_CODE_PATH).
'forum/viewthread.php?'.api_get_cidreq().'&forum='.$thread_information['forum_id'].'&thread='.$thread_information['thread_id'];
}
$email_body = get_lang('Dear').' '.api_get_person_name($userInfo['firstname'], $userInfo['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).", <br />\n\r";
$email_body .= get_lang('NewForumPost').': '.$forumInfo['forum_title'].' - '.$thread_information['thread_title']." <br />\n";
$courseId = api_get_configuration_value('global_forums_course_id');
$subject = get_lang('NewForumPost').' - '.$_course['official_code'].': '.$forumInfo['forum_title'].' - '.$thread_information['thread_title']." <br />\n";
$courseInfoTitle = get_lang('Course').': '.$_course['name'].' - ['.$_course['official_code']."] - <br />\n";
if (!empty($courseId) && $_course['real_id'] == $courseId) {
$subject = get_lang('NewForumPost').': '.$forumInfo['forum_title'].' - '.$thread_information['thread_title']." <br />\n";
$courseInfoTitle = " <br />\n";
}
$email_body = get_lang('Dear').' '.api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).", <br />\n\r";
$email_body .= get_lang('NewForumPost')."\n";
$email_body .= get_lang('Course').': '.$_course['name'].' - ['.$_course['official_code']."] - <br />\n";
$email_body .= $courseInfoTitle;
if (!empty($postInfo) && isset($postInfo['post_text'])) {
$text = cut(strip_tags($postInfo['post_text']), 100);
if (!empty($text)) {
$email_body .= get_lang('Message').": <br />\n ";
$email_body .= $text;
$email_body .= "<br /><br />\n";
}
}
$email_body .= get_lang('YouWantedToStayInformed')."<br />\n";
if (!empty($thread_link)) {
$email_body .= get_lang('ThreadCanBeFoundHere')." : <br /><a href=\"".$thread_link."\">".$thread_link."</a>\n";
}
if ($user_info['user_id'] != $user_id) {
if ($userInfo['user_id'] != $user_id) {
MessageManager::send_message(
$user_info['user_id'],
$userInfo['user_id'],
$subject,
$email_body,
[],
@ -5686,19 +5732,19 @@ function get_notifications($content, $id)
*/
function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0)
{
$_course = api_get_course_info();
//$_course = api_get_course_info();
$forumCourseId = api_get_configuration_value('global_forums_course_id');
/*$forumCourseId = api_get_configuration_value('global_forums_course_id');
if (!empty($forumCourseId)) {
if ($_course['real_id'] == $forumCourseId) {
return false;
}
}
}*/
$forum_id = (int) $forum_id;
// The content of the mail
$thread_link = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&forum='.$forum_id.'&thread='.$thread_id;
//$thread_link = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&forum='.$forum_id.'&thread='.$thread_id;
// Users who subscribed to the forum
if ($forum_id != 0) {
@ -5708,33 +5754,27 @@ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0)
}
$current_thread = get_thread_information($forum_id, $thread_id);
$current_forum = get_forum_information($current_thread['forum_id']);
$subject = get_lang('NewForumPost').' - '.$_course['official_code'].' - '.$current_forum['forum_title'].' - '.$current_thread['thread_title'];
//$current_forum = get_forum_information($current_thread['forum_id']);
//$subject = get_lang('NewForumPost').' - '.$_course['official_code'].' - '.$current_forum['forum_title'].' - '.$current_thread['thread_title'];
// User who subscribed to the thread
if ($thread_id != 0) {
$users_to_be_notified_by_thread = get_notifications('thread', $thread_id);
}
$postInfo = [];
if (!empty($post_id)) {
$postInfo = get_post_information($post_id);
}
// Merging the two
$users_to_be_notified = array_merge($users_to_be_notified_by_forum, $users_to_be_notified_by_thread);
$sender_id = api_get_user_id();
$forumInfo = get_forum_information($forum_id);
if (is_array($users_to_be_notified)) {
foreach ($users_to_be_notified as $value) {
$user_info = api_get_user_info($value['user_id']);
$email_body = get_lang('Dear').' '.api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS).", <br />\n\r";
$email_body .= get_lang('NewForumPost').": ".$current_forum['forum_title'].' - '.$current_thread['thread_title']." <br />\n";
$email_body .= get_lang('Course').': '.$_course['name'].' - ['.$_course['official_code']."] <br />\n";
$email_body .= get_lang('YouWantedToStayInformed')."<br />\n";
$email_body .= get_lang('ThreadCanBeFoundHere').': <br /> <a href="'.$thread_link.'">'.$thread_link."</a>\n";
MessageManager::send_message_simple(
$value['user_id'],
$subject,
$email_body,
$sender_id
);
$userInfo = api_get_user_info($value['user_id']);
send_mail($userInfo, $forumInfo, $current_thread, $postInfo);
}
}
}
@ -6717,6 +6757,10 @@ function postNeedsRevision($postId)
*/
function getAskRevisionButton($postId, $threadInfo)
{
if (api_get_configuration_value('allow_forum_post_revisions') === false) {
return '';
}
$postId = (int) $postId;
$status = 'btn-default';
@ -6744,13 +6788,15 @@ function giveRevisionButton($postId, $threadInfo)
return Display::toolbarButton(
get_lang('GiveRevision'),
api_get_path(WEB_CODE_PATH).'forum/reply.php?'.api_get_cidreq().'&'.http_build_query([
api_get_path(WEB_CODE_PATH).'forum/reply.php?'.api_get_cidreq().'&'.http_build_query(
[
'forum' => $threadInfo['forum_id'],
'thread' => $threadInfo['thread_id'],
'post' => $postId = (int) $postId,
'action' => 'replymessage',
'give_revision' => 1,
]),
]
),
'reply',
'primary',
['id' => "reply-to-post-{$postId}"]

@ -57,7 +57,6 @@ if (!api_is_allowed_to_edit(false, true) &&
$course_id = api_get_course_int_id();
$table_posts = Database::get_course_table(TABLE_FORUM_POST);
$table_users = Database::get_main_table(TABLE_MAIN_USER);

@ -460,7 +460,7 @@ if (is_array($forumCategories)) {
$toolActions = null;
$forumInfo['alert'] = null;
// The number of topics and posts.
if ($hideNotifications == false) {
// The number of topics and posts.
if ($forum['forum_of_group'] !== '0') {

@ -158,7 +158,6 @@ $logInfo = [
'tool_id' => $forumId,
'tool_id_detail' => $threadId,
'action' => !empty($my_action) ? $my_action : 'reply',
'action_details' => '',
];
Event::registerLog($logInfo);

@ -528,7 +528,7 @@ if (is_array($threads)) {
$html .= '<p>'.Security::remove_XSS(cut($last_post_info['post_text'], 140)).'</p>';
}
$html .= '<p>'.api_convert_and_format_date($row['insert_date']).'</p>';
$html .= '<p>'.Display::dateToStringAgoAndLongDate($row['insert_date']).'</p>';
if ($current_forum['moderated'] == 1 && api_is_allowed_to_edit(false, true)) {
$waitingCount = getCountPostsWithStatus(
@ -562,6 +562,25 @@ if (is_array($threads)) {
).' '.$row['thread_views'].' '.get_lang('Views').'<br>'.$newPost;
$html .= '</div>';
$last_post_info = get_last_post_by_thread(
$row['c_id'],
$row['thread_id'],
$row['forum_id'],
api_is_allowed_to_edit()
);
$last_post = null;
if ($last_post_info) {
$poster_info = api_get_user_info($last_post_info['poster_id']);
$post_date = Display::dateToStringAgoAndLongDate($last_post_info['post_date']);
$last_post = $post_date.'<br>'.get_lang('By').' '.display_user_link(
$last_post_info['poster_id'],
$poster_info['complete_name'],
'',
$poster_info['username']
);
}
$html .= '<div class="col-md-5">'
.Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY)
.' '.$last_post;

@ -44,7 +44,7 @@ function hidecontent(content){
// The section (tabs)
$this_section = SECTION_COURSES;
// Notification for unauthorized people.
// Including additional library scripts.
$nameTools = get_lang('ToolForum');
$_user = api_get_user_info();
@ -436,7 +436,7 @@ if ($action != 'add') {
$html .= '<div class="col-md-6">';
if (!empty($forum['last_post_id'])) {
$html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY).' ';
$html .= api_convert_and_format_date($forum['last_post_date'])
$html .= Display::dateToStringAgoAndLongDate($forum['last_post_date'])
.' '.get_lang('By').' '
.display_user_link($poster_id, $name);
}

@ -28,6 +28,7 @@ $my_search = null;
$forumId = isset($_GET['forum']) ? (int) $_GET['forum'] : 0;
$threadId = isset($_GET['thread']) ? (int) $_GET['thread'] : 0;
/* MAIN DISPLAY SECTION */
/* Retrieving forum and forum category information */
@ -83,7 +84,7 @@ $logInfo = [
];
Event::registerLog($logInfo);
$currentUrl = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?forum='.$forumId.'&'.api_get_cidreq().'&thread='.intval($threadId);
$currentUrl = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?forum='.$forumId.'&'.api_get_cidreq().'&thread='.$threadId;
switch ($my_action) {
case 'delete':
@ -128,10 +129,11 @@ switch ($my_action) {
exit;
break;
case 'ask_revision':
if (api_get_configuration_value('allow_forum_post_revisions')) {
$postId = isset($_GET['post_id']) ? $_GET['post_id'] : 0;
$result = savePostRevision($postId, $current_forum, $current_thread);
$result = savePostRevision($postId);
Display::addFlash(Display::return_message(get_lang('Saved')));
}
header('Location: '.$currentUrl);
exit;
break;
@ -151,7 +153,7 @@ if (!empty($groupId)) {
'name' => Security::remove_XSS($current_forum['forum_title']),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'forum/viewthread.php?forum='.$forumId.'&'.api_get_cidreq().'&thread='.intval($threadId),
'url' => api_get_path(WEB_CODE_PATH).'forum/viewthread.php?forum='.$forumId.'&'.api_get_cidreq().'&thread='.$threadId,
'name' => Security::remove_XSS($current_thread['thread_title']),
];
} else {
@ -187,9 +189,9 @@ if (!empty($groupId)) {
if (!api_is_allowed_to_edit(false, true) &&
($current_forum['visibility'] == 0 || $current_thread['visibility'] == 0)
) {
api_not_allowed(false);
api_not_allowed();
}
// this increases the number of times the thread has been viewed
increase_thread_view($threadId);
if ($origin == 'learnpath') {
@ -218,15 +220,14 @@ if (($current_forum_category &&
// reply link
if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
$actions .= '<a href="'.$forumUrl.'reply.php?'.api_get_cidreq().'&forum='.$forumId.'&thread='
.intval($threadId).'&action=replythread">'
.$threadId.'&action=replythread">'
.Display::return_icon('reply_thread.png', get_lang('ReplyToThread'), '', ICON_SIZE_MEDIUM)
.'</a>';
}
// new thread link
if ((
api_is_allowed_to_edit(false, true) &&
!(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId)
) ||
!(api_is_session_general_coach() && $current_forum['session_id'] != $sessionId)) ||
($current_forum['allow_new_threads'] == 1 && isset($_user['user_id'])) ||
($current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1)
) {
@ -239,20 +240,6 @@ if (($current_forum_category &&
}
}
// The different views of the thread.
if ($origin != 'learnpath') {
/*$actions .= '<a href="'.$forumUrl.'viewthread.php?'.api_get_cidreq().'&'.api_get_cidreq()
.'&forum='.intval($forumId).'&thread='.intval($threadId)
.'&search='.Security::remove_XSS(urlencode($my_search));
echo $my_url.'&view=flat">'
.Display::return_icon('forum_listview.png', get_lang('FlatView'), null, ICON_SIZE_MEDIUM)
.'</a>';
/*
echo $my_url.'&view=nested">'
.Display::return_icon('forum_nestedview.png', get_lang('NestedView'), null, ICON_SIZE_MEDIUM)
.'</a>';*/
}
$template->assign('forum_actions', $actions);
$template->assign('origin', api_get_origin());
@ -637,6 +624,17 @@ foreach ($posts as $post) {
$post['current'] = true;
}
// Replace Re: with an icon
$search = [
get_lang('ReplyShort'),
'Re:',
'RE:',
'AW:',
'Aw:',
];
$replace = '<span>'.Display::returnFontAwesomeIcon('mail-reply').'</span>';
$post['post_title'] = str_replace($search, $replace, $post['post_title']);
// The post title
$titlePost = Display::tag('h3', $post['post_title'], ['class' => 'forum_post_title']);
$post['post_title'] = '<a name="post_id_'.$post['post_id'].'"></a>';
@ -674,7 +672,6 @@ foreach ($posts as $post) {
// The post has been displayed => it can be removed from the what's new array
unset($whatsnew_post_info[$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]);
unset($_SESSION['whatsnew_post_info'][$current_forum['forum_id']][$current_thread['thread_id']][$post['post_id']]);
$count++;
}

@ -22,40 +22,31 @@ $cidReq = Security::remove_XSS($_GET['cidReq']);
$type = Security::remove_XSS($_GET['type']);
$doExerciseUrl = '';
if (isset($_GET['doexercise'])) {
$doExerciseUrl = api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.http_build_query([
'session_id' => $session_id,
'cidReq' => $cidReq,
'gradebook' => $gradebook,
'origin' => '',
'learnpath_id' => '',
'learnpath_item_id' => '',
'exerciseId' => intval($_GET['doexercise']),
]);
}
// no support for hot potatoes
if ($type == LINK_HOTPOTATOES) {
$exerciseId = $_GET['exerciseId'];
$path = Security::remove_XSS($_GET['path']);
$doExerciseUrl = api_get_path(WEB_CODE_PATH).'exercise/showinframes.php?'.http_build_query([
$doExerciseUrl = api_get_path(WEB_CODE_PATH).'exercise/showinframes.php?'.http_build_query(
[
'session_id' => $session_id,
'cidReq' => Security::remove_XSS($cidReq),
'file' => $path,
'cid' => api_get_course_id(),
'uid' => api_get_user_id(),
]);
]
);
header('Location: '.$doExerciseUrl);
exit;
}
if (isset($_GET['doexercise'])) {
if (!empty($doExerciseUrl)) {
header('Location: '.$doExerciseUrl);
exit;
} else {
$url = api_get_path(WEB_CODE_PATH).'exercise/overview.php?session_id='.$session_id.'&cidReq='.Security::remove_XSS($cidReq);
$url = api_get_path(WEB_CODE_PATH).'exercise/overview.php?'
.http_build_query(['session_id' => $session_id, 'cidReq' => $cidReq]);
if (isset($_GET['gradebook'])) {
$url .= '&gradebook=view&exerciseId='.intval($_GET['exerciseId']);
$url .= '&gradebook=view&exerciseId='.((int) $_GET['exerciseId']);
// Check if exercise is inserted inside a LP, if that's the case
$exerciseId = $_GET['exerciseId'];
@ -69,13 +60,32 @@ if (isset($_GET['doexercise'])) {
// If the exercise was added once redirect to the LP
$firstLp = current($exercise->lpList);
if (isset($firstLp['lp_id'])) {
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&lp_id='.$firstLp['lp_id'].'&action=view&isStudentView=true';
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&'
.http_build_query(
[
'lp_id' => $firstLp['lp_id'],
'action' => 'view',
'isStudentView' => 'true',
]
);
}
} else {
// If the exercise was added multiple times show the LP list
$url = api_get_path(WEB_CODE_PATH).'lp/lp_controller.php?'.api_get_cidreq().'&action=list';
}
}
} else {
$url = api_get_path(WEB_CODE_PATH).'exercise/overview.php?'.http_build_query(
[
'session_id' => $session_id,
'cidReq' => $cidReq,
'gradebook' => $gradebook,
'origin' => '',
'learnpath_id' => '',
'learnpath_item_id' => '',
'exerciseId' => (int) $_GET['exerciseId'],
]
);
}
}
}

@ -30,10 +30,6 @@ $userList = CourseManager::get_user_list_from_course_code(
switch ($action) {
case 'export_all':
$params = [];
$pdf = new PDF('A4', 'P', $params);
$pdfList = [];
$cats = Category::load($cat_id, null, null, null, null, null, false);
$studentList = CourseManager::get_user_list_from_course_code(
api_get_course_id(),
@ -44,7 +40,6 @@ switch ($action) {
);
$tpl = new Template('', false, false, false);
$courseInfo = api_get_course_info();
$params = [
'pdf_title' => sprintf(get_lang('GradeFromX'), $courseInfo['name']),
@ -56,22 +51,22 @@ switch ($action) {
'show_grade_generated_date' => true,
'show_real_course_teachers' => false,
'show_teacher_as_myself' => false,
'orientation' => 'P',
];
$pdf = new PDF('A4', $params['orientation'], $params, $tpl);
$htmlList = [];
foreach ($userList as $index => $value) {
$pdfList[] = GradebookUtils::generateTable(
$htmlList[] = GradebookUtils::generateTable(
$value['user_id'],
$cats,
false,
true,
true,
$studentList,
$pdf
);
}
if (!empty($pdfList)) {
if (!empty($htmlList)) {
// Print certificates (without the common header/footer/watermark
// stuff) and return as one multiple-pages PDF
/*$address = api_get_setting('institution_address');
@ -80,7 +75,7 @@ switch ($action) {
$pdf->custom_header = array('html' => "<h5 align='right'>$address <br />$phone</h5>");*/
// stuff) and return as one multiple-pages PDF
$pdf->html_to_pdf(
$pdfList,
$htmlList,
null,
null,
false,

@ -15,7 +15,7 @@ $eval = Evaluation::load($categoryId);
if (!isset($eval[0])) {
api_not_allowed(true);
}
// if category id is negative, then the evaluation's origin is a link
/** @var Evaluation $eval */
$eval = $eval[0];
if ($eval->get_category_id() < 0) {

@ -1003,15 +1003,17 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true)
4 => 'class="text-center"',
];
} else {
if (empty($model)) {
/*if (empty($model)) {
$gradebookTable->td_attributes = [
3 => 'class="text-right"',
4 => 'class="text-center"',
];
if (!empty($loadStats)) {
for ($z = 5; $z < count($loadStats); $z++) {
$gradebookTable->td_attributes[$z] = 'class="text-center"';
}
}
} else {
$gradebookTable->td_attributes = [
3 => 'class="text-right"',
@ -1021,7 +1023,7 @@ if (isset($first_time) && $first_time == 1 && api_is_allowed_to_edit(null, true)
if ($action == 'export_table') {
unset($gradebookTable->td_attributes[7]);
}
}*/
}
$table = $gradebookTable->return_table();

@ -228,7 +228,7 @@ class GradebookUtils
if (!api_is_allowed_to_edit(null, true)) {
$modify_icons .= Display::url(
Display::return_icon(
'stats.png',
'statistics.png',
get_lang('FlatView'),
'',
ICON_SIZE_SMALL
@ -297,7 +297,7 @@ class GradebookUtils
$modify_icons .= '<a href="gradebook_flatview.php?selectcat='.$cat->get_id().'&'.$courseParams.'">'.
Display::return_icon(
'stats.png',
'statistics.png',
get_lang('FlatView'),
'',
ICON_SIZE_SMALL
@ -1552,6 +1552,15 @@ class GradebookUtils
$alleval = $cats[0]->get_evaluations($userId);
$alllink = $cats[0]->get_links($userId);
$loadStats = [];
if (api_get_setting('gradebook_detailed_admin_view') === 'true') {
$loadStats = [1, 2, 3];
} else {
if (api_get_configuration_value('gradebook_enable_best_score') !== false) {
$loadStats = [2];
}
}
$gradebooktable = new GradebookTable(
$cat,
$allcat,
@ -1561,15 +1570,16 @@ class GradebookUtils
true, // $exportToPdf
false, // showteacher
$userId,
$studentList
$studentList,
$loadStats
);
$gradebooktable->userId = $userId;
if (api_is_allowed_to_edit()) {
$gradebooktable->td_attributes = [
if (api_is_allowed_to_edit(null, true)) {
/*$gradebooktable->td_attributes = [
4 => 'class=centered',
];
];*/
} else {
$gradebooktable->td_attributes = [
3 => 'class=centered',

@ -264,12 +264,13 @@ class Category implements GradebookItem
*/
public function setCourseListDependency($value)
{
$result = [];
if (@unserialize($value) !== false) {
$result = unserialize($value);
}
$this->courseDependency = [];
$unserialized = UnserializeApi::unserialize('not_allowed_classes', $value, true);
$this->courseDependency = $result;
if (false !== $unserialized) {
$this->courseDependency = $unserialized;
}
}
/**
@ -514,7 +515,7 @@ class Category implements GradebookItem
$sql .= ' '.$order_by;
}
}
//var_dump($sql);
$result = Database::query($sql);
$categories = [];
if (Database::num_rows($result) > 0) {

@ -116,7 +116,7 @@ class DataForm extends FormValidator
.'</a>)',
'csv'
);
//$this->addRule('file', get_lang('InvalidExtension') . ' (' . implode(',', $allowed_file_types) . ')', 'filetype', $allowed_file_types);
//$this->addElement('radio', 'file_type', null, 'XML (<a href="docs/example_xml.html" target="_blank" download>'.get_lang('ExampleXMLFile').'</a>)', 'xml');
$this->addElement('checkbox', 'overwrite', null, get_lang('OverwriteScores'));
$this->addElement('checkbox', 'ignoreerrors', null, get_lang('IgnoreErrors'));
$this->addButtonImport(get_lang('Ok'));

@ -111,7 +111,7 @@ class DisplayGradebook
if (!$evalobj->has_results()) {
$evalinfo .= '<br /><i>'.get_lang('NoResultsInEvaluation').'</i>';
}
//$evalinfo .= '<br /><br /><a href="gradebook_view_result.php?selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.Display::return_icon(('evaluation_rate.png'),get_lang('ViewResult'),'',ICON_SIZE_MEDIUM) . '</a>';
if ($page != 'statistics') {
if (api_is_allowed_to_edit(null, true)) {
$evalinfo .= '<br /><a href="gradebook_statistics.php?'.api_get_cidreq().'&selecteval='.Security::remove_XSS($_GET['selecteval']).'"> '.
@ -322,7 +322,7 @@ class DisplayGradebook
if (!empty($score)) {
$divide = $score[1] == 0 ? 1 : $score[1];
$item_value = $score[0] / $divide * $item->get_weight();
$item_value_total += $scoredisplay->format_score($item_value);
$item_value_total += $item_value;
}
}
@ -400,15 +400,6 @@ class DisplayGradebook
$actionsRight = '';
$my_api_cidreq = api_get_cidreq();
if (api_is_allowed_to_edit(null, true)) {
if (empty($grade_model_id) || $grade_model_id == -1) {
$actionsLeft .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.
Display::return_icon(
'new_folder.png',
get_lang('AddGradebook'),
[],
ICON_SIZE_MEDIUM
).'</a></td>';
}
if ($selectcat != '0') {
$my_category = $catobj->showAllCategoryInfo($catobj->get_id());
if ($my_api_cidreq == '') {
@ -416,21 +407,34 @@ class DisplayGradebook
}
if ($show_add_link && !$message_resource) {
$actionsLeft .= '<a href="gradebook_add_eval.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'" >'.
Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '', ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('new_evaluation.png', get_lang('NewEvaluation'), '',
ICON_SIZE_MEDIUM).'</a>';
$cats = Category::load($selectcat);
if ($cats[0]->get_course_code() != null && !$message_resource) {
$actionsLeft .= '<a href="gradebook_add_link.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '',
ICON_SIZE_MEDIUM).'</a>';
} else {
$actionsLeft .= '<a href="gradebook_add_link_select_course.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '', ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('new_online_evaluation.png', get_lang('MakeLink'), '',
ICON_SIZE_MEDIUM).'</a>';
}
}
}
if (empty($grade_model_id) || $grade_model_id == -1) {
$actionsLeft .= '<a href="gradebook_add_cat.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.
Display::return_icon(
'new_folder.png',
get_lang('AddGradebook'),
[],
ICON_SIZE_MEDIUM
).'</a></td>';
}
if ($selectcat != '0') {
if (!$message_resource) {
$actionsLeft .= '<a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('statistics.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>';
if ($my_category['generate_certificates'] == 1) {
$actionsLeft .= Display::url(
@ -503,7 +507,7 @@ class DisplayGradebook
if ($isDrhOfCourse) {
$actionsLeft .= '<a href="gradebook_flatview.php?'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
Display::return_icon(
'stats.png',
'statistics.png',
get_lang('FlatView'),
'',
ICON_SIZE_MEDIUM
@ -576,7 +580,7 @@ class DisplayGradebook
$header = '<div class="actions">';
if ($is_course_admin) {
$header .= '<a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('stats.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>';
$header .= '<a href="gradebook_flatview.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('statistics.png', get_lang('FlatView'), '', ICON_SIZE_MEDIUM).'</a>';
$header .= '<a href="gradebook_scoring_system.php?'.api_get_cidreq().'&selectcat='.$catobj->get_id().'">'.Display::return_icon('settings.png', get_lang('ScoreEdit'), '', ICON_SIZE_MEDIUM).'</a>';
} elseif (!(isset($_GET['studentoverview']))) {
$header .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&selectcat='.$catobj->get_id().'">'.Display::return_icon('view_list.gif', get_lang('FlatView')).' '.get_lang('FlatView').'</a>';

@ -705,7 +705,7 @@ class GradebookTable extends SortableTable
$row = [
null,
'<h3>'.get_lang('Total').'</h3>',
'<strong>'.get_lang('Total').'</strong>',
];
if (!$this->exportToPdf) {
@ -739,6 +739,7 @@ class GradebookTable extends SortableTable
$totalRanking,
SCORE_DIV,
SCORE_BOTH,
true,
true
);
@ -864,9 +865,9 @@ class GradebookTable extends SortableTable
}
if (!$this->teacherView) {
$rowTotal = [];
/*$rowTotal = [];
$rowTotal[] = ' ';
$rowTotal[] = get_lang('FinalScore');
$rowTotal[] = '<strong>'.get_lang('FinalScore').'</strong>';
if (!$this->exportToPdf) {
$rowTotal[] = ' ';
@ -881,7 +882,7 @@ class GradebookTable extends SortableTable
$rowTotal[] = ' ';
}
$sortable_data[] = $rowTotal;
$sortable_data[] = $rowTotal;*/
}
return $sortable_data;
@ -920,7 +921,7 @@ class GradebookTable extends SortableTable
["R" => 0, "G" => 0, "B" => 0]
);
$pChart->drawText(
10,
80,
16,
get_lang('Results'),
["FontSize" => 11, "Align" => TEXT_ALIGN_BOTTOMMIDDLE]

@ -354,10 +354,15 @@ class GradebookDataGenerator
api_get_session_id()
);
$scoreMode = SCORE_DIV_PERCENT_WITH_CUSTOM;
if ($this->hidePercentage) {
$scoreMode = SCORE_DIV;
}
$scoreDisplay = ScoreDisplay::instance();
$display = $scoreDisplay->display_score(
$score,
SCORE_DIV_PERCENT_WITH_CUSTOM,
$scoreMode,
SCORE_BOTH,
true
);
@ -381,15 +386,26 @@ class GradebookDataGenerator
{
$score = $item->calc_score(null, 'average');
$scoreDisplay = ScoreDisplay::instance();
$scoreMode = SCORE_DIV_PERCENT_WITH_CUSTOM;
if ($this->hidePercentage) {
$scoreMode = SCORE_DIV;
}
$display = $scoreDisplay->display_score(
$score,
SCORE_DIV_PERCENT_WITH_CUSTOM,
$scoreMode,
SCORE_BOTH,
true
);
$type = $item->get_item_type();
if ($type === 'L' && get_class($item) === 'ExerciseLink') {
$display = ExerciseLib::show_score($score[0], $score[1], false);
$result = ExerciseLib::convertScoreToPlatformSetting($score[0], $score[1]);
$score[0] = $result['score'];
$score[1] = $result['weight'];
}
return [

@ -18,7 +18,6 @@ if (!api_is_allowed_to_edit(false, true)) {
$currentUrl = api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq();
/* Create the groups */
if (isset($_POST['action'])) {
switch ($_POST['action']) {
case 'create_groups':
@ -28,7 +27,6 @@ if (isset($_POST['action'])) {
if (isset($_POST['same_category']) && $_POST['same_category']) {
$useOnlyFirstCategory = true;
}
$group1['category'] = isset($_POST['group_'.$i.'_category']) ? $_POST['group_'.$i.'_category'] : null;
for ($i = 0; $i < $_POST['number_of_groups']; $i++) {
$group1['name'] = empty($_POST['group_'.$i.'_name']) ? get_lang('Group').' '.$i : $_POST['group_'.$i.'_name'];
@ -57,7 +55,7 @@ if (isset($_POST['action'])) {
);
}
Display::addFlash(Display::return_message(get_lang('GroupsAdded')));
header("Location: ".$currentUrl);
header('Location: '.$currentUrl);
exit;
break;
case 'create_subgroups':
@ -66,13 +64,13 @@ if (isset($_POST['action'])) {
$_POST['number_of_groups']
);
Display::addFlash(Display::return_message(get_lang('GroupsAdded')));
header("Location: ".$currentUrl);
header('Location: '.$currentUrl);
exit;
break;
case 'create_class_groups':
$ids = GroupManager::create_class_groups($_POST['group_category']);
GroupManager::create_class_groups($_POST['group_category']);
Display::addFlash(Display::return_message(get_lang('GroupsAdded')));
header("Location: ".$currentUrl);
header('Location: '.$currentUrl);
exit;
break;
}
@ -256,26 +254,37 @@ EOT;
/*
* Show form to generate subgroups
*/
if (api_get_setting('allow_group_categories') === 'true' && count(GroupManager :: get_group_list()) > 0) {
$base_group_options = [];
if (api_get_setting('allow_group_categories') === 'true') {
$groups = GroupManager::get_group_list();
if (!empty($groups)) {
$base_group_options = [];
foreach ($groups as $index => $group) {
$number_of_students = GroupManager::number_of_students($group['id']);
if ($number_of_students > 0) {
$base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
$base_group_options[$group['id']] =
$group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
}
}
if (count($base_group_options) > 0) {
$create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq());
$create_subgroups_form = new FormValidator(
'create_subgroups',
'post',
api_get_self().'?'.api_get_cidreq()
);
$create_subgroups_form->addElement('header', get_lang('CreateSubgroups'));
$create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo'));
$create_subgroups_form->addElement('hidden', 'action');
$group_el = [];
$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
$group_el[] = $create_subgroups_form->createElement(
'static',
null,
null,
get_lang('CreateNumberOfGroups')
);
$group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, ['size' => 3]);
$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
$group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
$group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok'));
$group_el[] = $create_subgroups_form->addButtonSave(get_lang('Ok'), 'submit', true);
$create_subgroups_form->addGroup($group_el, 'create_groups', null, null, false);
$defaults = [];
$defaults['action'] = 'create_subgroups';
@ -283,45 +292,50 @@ EOT;
$create_subgroups_form->display();
}
}
}
/*
* Show form to generate groups from classes subscribed to the course
*/
$options['where'] = [" usergroup.course_id = ? " => api_get_course_int_id()];
$options['where'] = [' usergroup.course_id = ? ' => api_get_course_int_id()];
$obj = new UserGroup();
$classes = $obj->getUserGroupInCourse($options);
if (count($classes) > 0) {
echo '<b>'.get_lang('GroupsFromClasses').'</b>';
echo '<blockquote>';
echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
echo '<ul>';
$description = '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
$description .= '<ul>';
foreach ($classes as $index => $class) {
$number_of_users = count($obj->get_users_by_usergroup($class['id']));
echo '<li>';
echo $class['name'];
echo ' ('.$number_of_users.' '.get_lang('Users').')';
echo '</li>';
$description .= '<li>';
$description .= $class['name'];
$description .= ' ('.$number_of_users.' '.get_lang('Users').')';
$description .= '</li>';
}
echo '</ul>';
$description .= '</ul>';
$classForm = new FormValidator(
'create_class_groups_form',
'post',
api_get_self().'?'.api_get_cidreq()
);
$classForm->addHeader(get_lang('GroupsFromClasses'));
$create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq());
$create_class_groups_form->addElement('hidden', 'action');
$classForm->addHtml($description);
$classForm->addElement('hidden', 'action');
if (api_get_setting('allow_group_categories') === 'true') {
$group_categories = GroupManager :: get_categories();
$cat_options = [];
foreach ($group_categories as $index => $category) {
$cat_options[$category['id']] = $category['title'];
}
$create_class_groups_form->addElement('select', 'group_category', null, $cat_options);
$classForm->addElement('select', 'group_category', null, $cat_options);
} else {
$create_class_groups_form->addElement('hidden', 'group_category');
$classForm->addElement('hidden', 'group_category');
}
$create_class_groups_form->addElement('submit', 'submit', get_lang('Ok'));
$classForm->addButtonSave(get_lang('Ok'));
$defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY;
$defaults['action'] = 'create_class_groups';
$create_class_groups_form->setDefaults($defaults);
$create_class_groups_form->display();
echo '</blockquote>';
$classForm->setDefaults($defaults);
$classForm->display();
}
}

@ -15,11 +15,8 @@ $current_course_tool = TOOL_GROUP;
// Notice for unauthorized people.
api_protect_course_script(true);
/* Libraries & config files */
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
require_once api_get_path(SYS_CODE_PATH).'forum/forumconfig.inc.php';
/* MAIN CODE */
$group_id = api_get_group_id();
$user_id = api_get_user_id();
$current_group = GroupManager::get_group_properties($group_id);

@ -323,10 +323,10 @@ if ($form->validate()) {
$max_member != GroupManager::MEMBER_PER_GROUP_NO_LIMIT
) {
Display::addFlash(Display::return_message(get_lang('GroupTooMuchMembers'), 'warning'));
header('Location: group.php?'.api_get_cidreq(true, false));
header('Location: group.php?'.api_get_cidreq(true, false).'&category='.$categoryId);
} else {
Display::addFlash(Display::return_message(get_lang('GroupSettingsModified'), 'success'));
header('Location: group.php?'.api_get_cidreq(true, false).'&category='.$cat['id']);
header('Location: group.php?'.api_get_cidreq(true, false).'&category='.$categoryId);
}
exit;
}

@ -3,6 +3,7 @@
use Chamilo\CoreBundle\Entity\BranchSync;
use Chamilo\CoreBundle\Entity\Repository\BranchSyncRepository;
use GuzzleHttp\Client;
/**
* Responses to AJAX calls.
@ -72,6 +73,20 @@ switch ($action) {
echo file_get_contents("{$newUrlDir}{$blockName}_extra.html");
break;
case 'get_latest_news':
if (api_get_configuration_value('admin_chamilo_announcements_disable') === true) {
break;
}
try {
$latestNews = getLatestNews();
$latestNews = json_decode($latestNews, true);
echo Security::remove_XSS($latestNews['text'], COURSEMANAGER);
break;
} catch (Exception $e) {
break;
}
}
/**
@ -225,3 +240,33 @@ function check_system_version()
return '<span style="color:red">'.get_lang('ImpossibleToContactVersionServerPleaseTryAgain').'</span>';
}
/**
* Display the latest news from the Chamilo Association for admins.
*
* @throws \GuzzleHttp\Exception\GuzzleException
* @throws Exception
*
* @return string|void
*/
function getLatestNews()
{
$url = 'https://version.chamilo.org/news/latest.php';
$client = new Client();
$response = $client->request(
'GET',
$url,
[
'query' => [
'language' => api_get_interface_language(),
],
]
);
if ($response->getStatusCode() !== 200) {
throw new Exception(get_lang('DenyEntry'));
}
return $response->getBody()->getContents();
}

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Responses to AJAX calls.
*/
@ -18,7 +19,18 @@ if ($type == 'course') {
api_protect_course_script(true);
}
$logInfo = [
'tool' => TOOL_CALENDAR_EVENT,
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => $action,
'info' => '',
];
Event::registerLog($logInfo);
$agenda = new Agenda($type);
// get filtered type
$type = $agenda->getType();
switch ($action) {
case 'add_event':
@ -26,6 +38,8 @@ switch ($action) {
break;
}
$add_as_announcement = isset($_REQUEST['add_as_annonuncement']) ? $_REQUEST['add_as_annonuncement'] : null;
$title = isset($_REQUEST['title']) ? $_REQUEST['title'] : null;
$content = isset($_REQUEST['content']) ? $_REQUEST['content'] : null;
$comment = isset($_REQUEST['comment']) ? $_REQUEST['comment'] : null;
$userToSend = isset($_REQUEST['users_to_send']) ? $_REQUEST['users_to_send'] : [];
@ -33,8 +47,8 @@ switch ($action) {
$_REQUEST['start'],
$_REQUEST['end'],
$_REQUEST['all_day'],
$_REQUEST['title'],
$_REQUEST['content'],
$title,
$content,
$userToSend,
$add_as_announcement,
null, //$parentEventId = null,
@ -54,8 +68,8 @@ switch ($action) {
$_REQUEST['start'],
$_REQUEST['end'],
$_REQUEST['all_day'],
$_REQUEST['title'],
$_REQUEST['content']
$title,
$content
);
break;
case 'delete_event':

@ -49,14 +49,25 @@ switch ($action) {
case 'chatheartbeat':
$chat->heartbeat();
break;
case 'closechat':
case 'close_window':
// Closes friend window
$chatId = isset($_POST['chatbox']) ? $_POST['chatbox'] : '';
$chat->closeWindow($chatId);
echo '1';
exit;
break;
case 'close':
// Disconnects user from all chat
$chat->close();
echo '1';
exit;
break;
case 'create_room':
if (api_get_configuration_value('hide_chat_video')) {
api_not_allowed();
}
$room = VideoChat::getChatRoomByUsers(api_get_user_id(), $toUserId);
/*$room = VideoChat::getChatRoomByUsers(api_get_user_id(), $toUserId);
if ($room === false) {
$createdRoom = VideoChat::createRoom(api_get_user_id(), $toUserId);
@ -85,24 +96,31 @@ switch ($action) {
false,
false
);
echo Display::tag('p', $videoChatLink, ['class' => 'lead']);
echo Display::tag('p', $videoChatLink, ['class' => 'lead']);*/
break;
case 'get_contacts':
echo $chat->getContacts();
break;
case 'get_previous_messages':
$userId = isset($_REQUEST['user_id']) ? $_REQUEST['user_id'] : 0;
$visibleMessages = isset($_REQUEST['visible_messages']) ? $_REQUEST['visible_messages'] : null;
$visibleMessages = isset($_REQUEST['visible_messages']) ? $_REQUEST['visible_messages'] : 0;
if (empty($userId)) {
return '';
}
$items = $chat->getPreviousMessages(
$userId,
$currentUserId,
$visibleMessages
);
if (!empty($items)) {
sort($items);
echo json_encode($items);
exit;
}
echo json_encode([]);
exit;
break;
case 'notify_not_support':
$chat->send(

@ -584,7 +584,6 @@ switch ($action) {
$courseInfo = api_get_course_info_by_id($courseId);
$courseInfo['id_session'] = $sessionId;
$courseInfo['status'] = $status;
$id = 'notification_'.$courseId.'_'.$sessionId.'_'.$status;
$notificationId = Session::read($id);

@ -12,6 +12,12 @@ $action = $_REQUEST['a'];
switch ($action) {
case 'translate_html':
$translate = api_get_configuration_value('translate_html');
if (!$translate) {
exit;
}
$languageList = api_get_languages();
$hideAll = '';
foreach ($languageList['all'] as $language) {

@ -15,7 +15,7 @@ $action = $_GET['a'];
switch ($action) {
case 'get_count_message':
$userId = api_get_user_id();
$total_invitations = 0;
$invitations = [];
$group_pending_invitations = 0;
// Setting notifications
@ -40,9 +40,14 @@ switch ($action) {
} else {
$group_pending_invitations = 0;
}
$total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message);
$invitations = [
'ms_friends' => $number_of_new_messages_of_friend,
'ms_groups' => $group_pending_invitations,
'ms_inbox' => $count_unread_message,
];
}
echo $total_invitations;
header('Content-type:application/json');
echo json_encode($invitations);
break;
case 'send_message':
$subject = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : null;

@ -222,6 +222,7 @@ if (($search || $forceSearch) && ($search !== 'false')) {
$extraQuestionCondition
);
}
$whereCondition .= $extraQuestionCondition;
if (isset($filters->custom_dates)) {
@ -629,7 +630,7 @@ switch ($action) {
}
$startDate = Database::escape_string($_REQUEST['start_date']);
$whereCondition .= " AND exe_date > '$startDate' ";
$whereCondition .= " AND exe_date > '$startDate' AND te.status = '' ";
$count = ExerciseLib::get_count_exam_results(
$exerciseId,
$whereCondition,
@ -798,6 +799,10 @@ switch ($action) {
$obj = new Promotion();
$count = $obj->get_count();
break;
case 'get_mail_template':
$obj = new MailTemplateManager();
$count = $obj->get_count();
break;
case 'get_grade_models':
$obj = new GradeModel();
$count = $obj->get_count();
@ -901,7 +906,7 @@ switch ($action) {
'*',
$object->table,
[
'where' => ["session_id = ? " => $sessionId],
'where' => ['session_id = ? ' => $sessionId],
'order' => "$sidx $sord",
'LIMIT' => "$start , $limit", ]
);
@ -1385,7 +1390,6 @@ switch ($action) {
$overwriteColumnHeaderExport['only_score'] = get_lang('Score').' - '.get_lang('ScoreNote');
$overwriteColumnHeaderExport['total'] = get_lang('Score').' - '.get_lang('ScoreTest');
}
$categoryList = TestCategory::getListOfCategoriesIDForTest($exerciseId, $courseId);
if (!empty($categoryList)) {
@ -1412,6 +1416,8 @@ switch ($action) {
$columns[] = 'actions';
}
$whereCondition .= " AND te.status = '' ";
$result = ExerciseLib::get_exam_results_data(
$start,
$limit,
@ -1485,6 +1491,9 @@ switch ($action) {
break;
case 'get_sessions_tracking':
if (api_is_drh() || api_is_session_admin()) {
$orderByName = Database::escape_string($sidx);
$orderByName = in_array($orderByName, ['name', 'access_start_date']) ? $orderByName : 'name';
$orderBy = " ORDER BY $orderByName $sord";
$sessions = SessionManager::get_sessions_followed_by_drh(
api_get_user_id(),
$start,
@ -1492,7 +1501,7 @@ switch ($action) {
false,
false,
false,
null,
$orderBy,
$keyword,
$description
);
@ -1504,7 +1513,9 @@ switch ($action) {
$limit,
false,
$keyword,
$description
$description,
$sidx,
$sord
);
}
@ -1999,6 +2010,32 @@ switch ($action) {
}
$result = $new_result;
break;
case 'get_mail_template':
$columns = ['name', 'type', 'default_template', 'actions'];
if (!in_array($sidx, $columns)) {
$sidx = 'name';
}
if (!in_array($sidx, $columns)) {
$sidx = 'name';
}
$result = Database::select(
'*',
$obj->table,
[
'where' => ['url_id = ? ' => api_get_current_access_url_id()],
'order' => "$sidx $sord",
'LIMIT' => "$start , $limit",
]
);
$new_result = [];
foreach ($result as $item) {
$new_result[] = $item;
}
$result = $new_result;
break;
case 'get_grade_models':
$columns = ['name', 'description', 'actions'];
if (!in_array($sidx, $columns)) {
@ -2224,7 +2261,7 @@ switch ($action) {
if ($obj->allowTeachers()) {
$group['actions'] .= Display::url(
Display::return_icon('stats.png'),
Display::return_icon('statistics.png'),
$urlUserGroup.'&id='.$group['id']
).'&nbsp;';
}
@ -2248,6 +2285,7 @@ switch ($action) {
$allowed_actions = [
'get_careers',
'get_promotions',
'get_mail_template',
'get_usergroups',
'get_usergroups_teacher',
'get_gradebooks',

@ -42,12 +42,24 @@ switch ($action) {
$graphviz = new GraphViz();
$graphImage = '';
try {
$graphImage = $graphviz->createImageHtml($graph);
$graphImage = $graphviz->createImageSrc($graph);
echo Display::img(
$graphImage,
get_lang('GraphDependencyTree'),
['class' => 'center-block'],
false
);
} catch (UnexpectedValueException $e) {
error_log($e->getMessage().' - Graph could not be rendered in resources sequence because GraphViz command "dot" could not be executed - Make sure graphviz is installed.');
$graphImage = '<p class="text-center"><small>'.get_lang('MissingChartLibraryPleaseCheckLog').'</small></p>';
error_log(
$e->getMessage()
.' - Graph could not be rendered in resources sequence'
.' because GraphViz command "dot" could not be executed '
.'- Make sure graphviz is installed.'
);
echo '<p class="text-center"><small>'.get_lang('MissingChartLibraryPleaseCheckLog')
.'</small></p>';
}
echo $graphImage;
}
break;
}
@ -94,7 +106,15 @@ switch ($action) {
$link .= '<div class="big-icon">';
$link .= $image;
$link .= '<div class="sequence-course">'.$sessionInfo['name'].'</div>';
$link .= '<a href="#" class="sequence-id">'.$id.'</a>';
$link .= Display::tag(
'button',
$id,
[
'class' => 'sequence-id',
'title' => get_lang('UseAsReference'),
'type' => 'button',
]
);
$link .= $linkDelete;
$link .= $linkUndo;
$link .= '</div></div>';

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Message;
use Chamilo\CoreBundle\Entity\MessageLikes;
use ChamiloSession as Session;
/**
@ -249,7 +251,7 @@ switch ($action) {
$messageId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
if (empty($messageId)) {
break;
exit;
}
$userId = api_get_user_id();
@ -332,6 +334,101 @@ switch ($action) {
}
echo $html;
break;
case 'like_message':
header('Content-Type: application/json');
if (
api_is_anonymous() ||
!api_get_configuration_value('social_enable_likes_messages')
) {
echo json_encode(false);
exit;
}
$messageId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$status = isset($_GET['status']) ? $_GET['status'] : '';
$groupId = isset($_GET['group']) ? (int) $_GET['group'] : 0;
if (empty($messageId) || !in_array($status, ['like', 'dislike'])) {
echo json_encode(false);
exit;
}
$em = Database::getManager();
$messageRepo = $em->getRepository('ChamiloCoreBundle:Message');
$messageLikesRepo = $em->getRepository('ChamiloCoreBundle:MessageLikes');
/** @var Message $message */
$message = $messageRepo->find($messageId);
if (empty($message)) {
echo json_encode(false);
exit;
}
if ((int) $message->getGroupId() !== $groupId) {
echo json_encode(false);
exit;
}
if (!empty($message->getGroupId())) {
$usergroup = new UserGroup();
$groupInfo = $usergroup->get($groupId);
if (empty($groupInfo)) {
echo json_encode(false);
exit;
}
$isMember = $usergroup->is_group_member($groupId, $current_user_id);
if (GROUP_PERMISSION_CLOSED == $groupInfo['visibility'] && !$isMember) {
echo json_encode(false);
exit;
}
}
$user = api_get_user_entity($current_user_id);
$userLike = $messageLikesRepo->findOneBy(['message' => $message, 'user' => $user]);
if (empty($userLike)) {
$userLike = new MessageLikes();
$userLike
->setMessage($message)
->setUser($user);
}
if ('like' === $status) {
if ($userLike->isLiked()) {
echo json_encode(false);
exit;
}
$userLike
->setLiked(true)
->setDisliked(false);
} elseif ('dislike' === $status) {
if ($userLike->isDisliked()) {
echo json_encode(false);
exit;
}
$userLike
->setLiked(false)
->setDisliked(true);
}
$userLike
->setUpdatedAt(
api_get_utc_datetime(null, false, true)
);
$em->persist($userLike);
$em->flush();
echo json_encode(true);
break;
default:
echo '';
}

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
/**
* Responses to AJAX calls.
*/
@ -106,8 +108,9 @@ switch ($action) {
echo json_encode($list);
break;
break;
case 'recentlogins':
case 'recent_logins':
// Give a JSON array to the stats page main/admin/statistics/index.php
// for global recent logins
header('Content-type: application/json');
$list = [];
$all = Statistics::getRecentLoginStats(false, $sessionDuration);
@ -116,30 +119,113 @@ switch ($action) {
}
$list['datasets'][0]['label'] = get_lang('Logins');
$list['datasets'][0]['fillColor'] = "rgba(151,187,205,0.2)";
$list['datasets'][0]['strokeColor'] = "rgba(151,187,205,1)";
$list['datasets'][0]['pointColor'] = "rgba(151,187,205,1)";
$list['datasets'][0]['pointStrokeColor'] = "#fff";
$list['datasets'][0]['pointHighlightFill'] = "#fff";
$list['datasets'][0]['pointHighlightStroke'] = "rgba(151,187,205,1)";
$list['datasets'][0]['backgroundColor'] = 'rgba(151,187,205,0.2)';
$list['datasets'][0]['borderColor'] = 'rgba(151,187,205,1)';
$list['datasets'][0]['pointBackgroundColor'] = 'rgba(151,187,205,1)';
$list['datasets'][0]['pointBorderColor'] = '#fff';
$list['datasets'][0]['pointHoverBackgroundColor'] = '#fff';
$list['datasets'][0]['pointHoverBorderColor'] = 'rgba(151,187,205,1)';
foreach ($all as $tick => $tock) {
$list['datasets'][0]['data'][] = $tock;
}
$list['datasets'][1]['label'] = get_lang('DistinctUsersLogins');
$list['datasets'][1]['fillColor'] = "rgba(0,204,0,0.2)";
$list['datasets'][1]['strokeColor'] = "rgba(0,204,0,1)";
$list['datasets'][1]['pointColor'] = "rgba(0,204,0,1)";
$list['datasets'][1]['pointStrokeColor'] = "#fff";
$list['datasets'][1]['pointHighlightFill'] = "#fff";
$list['datasets'][1]['pointHighlightStroke'] = "rgba(0,204,0,1)";
$list['datasets'][1]['backgroundColor'] = 'rgba(0,204,0,0.2)';
$list['datasets'][1]['borderColor'] = 'rgba(0,204,0,1)';
$list['datasets'][1]['pointBackgroundColor'] = 'rgba(0,204,0,1)';
$list['datasets'][1]['pointBorderColor'] = '#fff';
$list['datasets'][1]['pointHoverBackgroundColor'] = '#fff';
$list['datasets'][1]['pointHoverBorderColor'] = 'rgba(0,204,0,1)';
$distinct = Statistics::getRecentLoginStats(true, $sessionDuration);
foreach ($distinct as $tick => $tock) {
$list['datasets'][1]['data'][] = $tock;
}
echo json_encode($list);
break;
case 'tools_usage':
case 'courses':
case 'courses_by_language':
case 'users':
case 'users_teachers':
case 'users_students':
// Give a JSON array to the stats page main/admin/statistics/index.php
// for global tools usage (number of clicks)
header('Content-type: application/json');
$list = [];
$palette = ChamiloApi::getColorPalette(true, true);
if ($action == 'tools_usage') {
$statsName = 'Tools';
$all = Statistics::getToolsStats();
} elseif ($action == 'courses') {
$statsName = 'CountCours';
$course_categories = Statistics::getCourseCategories();
// total amount of courses
$all = [];
foreach ($course_categories as $code => $name) {
$all[$name] = Statistics::countCourses($code);
}
} elseif ($action == 'courses_by_language') {
$statsName = 'CountCourseByLanguage';
$all = Statistics::printCourseByLanguageStats();
// use slightly different colors than previous chart
for ($k = 0; $k < 3; $k++) {
$item = array_shift($palette);
array_push($palette, $item);
}
} elseif ($action == 'users') {
$statsName = 'NumberOfUsers';
$countInvisible = isset($_GET['count_invisible']) ? (int) $_GET['count_invisible'] : null;
$all = [
get_lang('Teachers') => Statistics::countUsers(COURSEMANAGER, null, $countInvisible),
get_lang('Students') => Statistics::countUsers(STUDENT, null, $countInvisible),
];
} elseif ($action == 'users_teachers') {
$statsName = 'Teachers';
$course_categories = Statistics::getCourseCategories();
$countInvisible = isset($_GET['count_invisible']) ? (int) $_GET['count_invisible'] : null;
$all = [];
foreach ($course_categories as $code => $name) {
$name = str_replace(get_lang('Department'), "", $name);
$all[$name] = Statistics::countUsers(COURSEMANAGER, $code, $countInvisible);
}
// use slightly different colors than previous chart
for ($k = 0; $k < 3; $k++) {
$item = array_shift($palette);
array_push($palette, $item);
}
} elseif ($action == 'users_students') {
$statsName = 'Students';
$course_categories = Statistics::getCourseCategories();
$countInvisible = isset($_GET['count_invisible']) ? (int) $_GET['count_invisible'] : null;
$all = [];
foreach ($course_categories as $code => $name) {
$name = str_replace(get_lang('Department'), "", $name);
$all[$name] = Statistics::countUsers(STUDENT, $code, $countInvisible);
}
// use slightly different colors than previous chart
for ($k = 0; $k < 6; $k++) {
$item = array_shift($palette);
array_push($palette, $item);
}
}
foreach ($all as $tick => $tock) {
$list['labels'][] = $tick;
}
$list['datasets'][0]['label'] = get_lang($statsName);
$list['datasets'][0]['borderColor'] = 'rgba(255,255,255,1)';
$i = 0;
foreach ($all as $tick => $tock) {
$j = $i % count($palette);
$list['datasets'][0]['data'][] = $tock;
$list['datasets'][0]['backgroundColor'][] = $palette[$j];
$i++;
}
echo json_encode($list);
break;
}

@ -37,7 +37,6 @@ class DatePicker extends HTML_QuickForm_text
$id = $this->getAttribute('id');
$value = $this->getValue();
$label = $this->getLabel();
if (!empty($value)) {
$value = api_format_date($value, DATE_FORMAT_LONG_NO_DAY);
@ -82,7 +81,6 @@ class DatePicker extends HTML_QuickForm_text
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
$value = $this->getValue();
if (empty($size)) {
$sizeTemp = $this->getInputSize();
@ -101,12 +99,8 @@ class DatePicker extends HTML_QuickForm_text
}
// else just keep the $size array as received
} else {
$size = [2, intval($size), 2];
}
$size = [2, (int) $size, 2];
}
if (!empty($value)) {
$value = api_format_date($value, DATE_FORMAT_LONG_NO_DAY);
}
switch ($layout) {

@ -122,7 +122,6 @@ class DateRangePicker extends HTML_QuickForm_text
{
$js = null;
$id = $this->getAttribute('id');
$dateRange = $this->getAttribute('value');
$defaultDates = null;

@ -33,8 +33,9 @@ class DateTimePicker extends HTML_QuickForm_text
$id = $this->getAttribute('id');
$value = $this->getValue();
$formattedValue = '';
if (!empty($value)) {
$value = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
$formattedValue = api_format_date($value, DATE_TIME_FORMAT_LONG_24H);
}
$label = $this->getLabel();
@ -49,7 +50,7 @@ class DateTimePicker extends HTML_QuickForm_text
<span class="input-group-addon cursor-pointer">
<input '.$this->_getAttrString($this->_attributes).'>
</span>
<p class="form-control disabled" id="'.$id.'_alt_text">'.$value.'</p>
<p class="form-control disabled" id="'.$id.'_alt_text">'.$formattedValue.'</p>
<input class="form-control" type="hidden" id="'.$id.'_alt" value="'.$value.'">
<span class="input-group-btn">
<button class="btn btn-default" type="button"
@ -79,7 +80,7 @@ class DateTimePicker extends HTML_QuickForm_text
public function getTemplate($layout)
{
$size = $this->getColumnsSize();
$value = $this->getValue();
if (empty($size)) {
$sizeTemp = $this->getInputSize();
if (empty($size)) {
@ -97,7 +98,7 @@ class DateTimePicker extends HTML_QuickForm_text
}
// else just keep the $size array as received
} else {
$size = [2, intval($size), 2];
$size = [2, (int) $size, 2];
}
}

@ -20,10 +20,12 @@ class DateTimeRangePicker extends DateRangePicker
}
$id = $this->getAttribute('id');
$value = $this->getValue();
$dateRange = $this->getValue();
if (!empty($value)) {
$value = api_format_date($value, DATE_FORMAT_LONG_NO_DAY);
$value = '';
if (!empty($dateRange)) {
$dates = $this->parseDateRange($dateRange);
$value = api_format_date($dates['date'], DATE_FORMAT_LONG_NO_DAY);
}
return '
@ -70,7 +72,7 @@ class DateTimeRangePicker extends DateRangePicker
}
// else just keep the $size array as received
} else {
$size = [2, intval($size), 2];
$size = [2, (int) $size, 2];
}
}
@ -121,9 +123,9 @@ class DateTimeRangePicker extends DateRangePicker
<div class="col-sm-'.$size[1].'">
<div class="input-group">
<p id="'.$id.'_time_range">
<input type="text" name="'.$id.'_time_range_start" class="time start" autocomplete="off">
<input type="text" id="'.$id.'_time_range_start" name="'.$id.'_time_range_start" class="time start" autocomplete="off">
'.get_lang('To').'
<input type="text" name="'.$id.'_time_range_end" class="time end " autocomplete="off">
<input type="text" id="'.$id.'_time_range_end" name="'.$id.'_time_range_end" class="time end " autocomplete="off">
</p>
</div>
</div>
@ -143,6 +145,43 @@ class DateTimeRangePicker extends DateRangePicker
}
}
/**
* @param array $dateRange
*
* @return array
*/
public function parseDateRange($dateRange)
{
$dateRange = Security::remove_XSS($dateRange);
$dates = explode('@@', $dateRange);
$dates = array_map('trim', $dates);
$start = isset($dates[0]) ? $dates[0] : '';
$end = isset($dates[1]) ? $dates[1] : '';
$date = substr($start, 0, 10);
$start = isset($dates[0]) ? $dates[0] : '';
//$start = substr($start, 11, strlen($start));
//$end = substr($end, 11, strlen($end));
return [
'date' => $date,
'start_time' => $start,
'end_time' => $end,
];
}
/**
* @param string $value
*/
public function setValue($value)
{
$this->updateAttributes(
[
'value' => $value,
]
);
}
/**
* Get the necessary javascript for this datepicker.
*
@ -153,6 +192,18 @@ class DateTimeRangePicker extends DateRangePicker
$js = null;
$id = $this->getAttribute('id');
$dateRange = $this->getValue();
$defaultDate = '';
$startTime = '';
$endTime = '';
if (!empty($dateRange)) {
$dates = $this->parseDateRange($dateRange);
$defaultDate = $dates['date'];
$startTime = $dates['start_time'];
$endTime = $dates['end_time'];
}
$js .= "<script>
$(function() {
var txtDate = $('#$id'),
@ -163,7 +214,7 @@ class DateTimeRangePicker extends DateRangePicker
txtDate
.hide()
.datepicker({
defaultDate: '".$this->getValue()."',
defaultDate: '".$defaultDate."',
dateFormat: 'yy-mm-dd',
altField: '#{$id}_alt',
altFormat: \"".get_lang('DateFormatLongNoDayJS')."\",
@ -187,7 +238,6 @@ class DateTimeRangePicker extends DateRangePicker
.find('button')
.on('click', function (e) {
e.preventDefault();
$('#$id, #{$id}_alt').val('');
$('#{$id}_alt_text').html('');
});
@ -196,11 +246,13 @@ class DateTimeRangePicker extends DateRangePicker
'showDuration': true,
'timeFormat': 'H:i:s',
'scrollDefault': 'now',
});
$('#".$id."_time_range_start').timepicker('setTime', new Date('".$startTime."'));
$('#".$id."_time_range_end').timepicker('setTime', new Date('".$endTime."'));
var timeOnlyExampleEl = document.getElementById('".$id."_time_range');
var timeOnlyDatepair = new Datepair(timeOnlyExampleEl);
});
</script>";

@ -84,6 +84,3 @@ class nusoap_fault extends nusoap_base
class soap_fault extends nusoap_fault
{
}
?>

@ -1,8 +1,5 @@
<?php
/**
* For creating serializable abstractions of native PHP types. This class
* allows element name/namespace, XSD type, and XML attributes to be
@ -14,7 +11,8 @@
* @version $Id: class.soap_val.php,v 1.11 2007/04/06 13:56:32 snichol Exp $
* @access public
*/
class soapval extends nusoap_base {
class soapval extends nusoap_base
{
/**
* The XML element name
*

@ -92,7 +92,7 @@ class nusoap_client extends nusoap_base
* @param string $portName optional portName in WSDL document
* @access public
*/
function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
function __construct($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
parent::__construct();
$this->endpoint = $endpoint;
$this->proxyhost = $proxyhost;

@ -887,7 +887,7 @@ class wsdl extends nusoap_base
*/
function serialize($debug = 0)
{
$xml = '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>';
$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
$xml .= "\n<definitions";
foreach($this->namespaces as $k => $v) {
$xml .= " xmlns:$k=\"$v\"";

Loading…
Cancel
Save