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

pull/3213/head^2
Angel Fernando Quiroz Campos 6 years ago
commit dadbdbcc57
  1. 20
      main/document/document.php
  2. 20
      main/exercise/exercise.class.php
  3. 108
      main/exercise/exercise_submit_modal.php
  4. 18
      main/exercise/hotspot_admin.inc.php
  5. 2
      main/group/group_overview.php
  6. 67
      main/inc/lib/CoursesAndSessionsCatalog.class.php
  7. 2
      main/inc/lib/course_category.lib.php
  8. 9
      main/inc/lib/events.lib.php
  9. 7
      main/inc/lib/exercise.lib.php
  10. 7
      main/inc/lib/formvalidator/Element/DateRangePicker.php
  11. 8
      main/inc/lib/login.lib.php
  12. 29
      main/inc/lib/online.inc.php
  13. 6
      main/inc/lib/sessionmanager.lib.php
  14. 27
      main/install/configuration.dist.php
  15. 3
      main/lang/english/trad4all.inc.php
  16. 3
      main/lang/french/trad4all.inc.php
  17. 3
      main/lang/spanish/trad4all.inc.php
  18. 63
      main/lp/learnpath.class.php
  19. 68
      main/lp/lp_list.php
  20. 5
      main/session/resume_session.php
  21. 7
      main/session/session_course_list.php
  22. 8
      main/session/session_course_user_list.php
  23. 7
      main/template/default/layout/main.js.tpl
  24. 12
      main/template/default/learnpath/list.tpl
  25. 55
      tests/scripts/delete_old_users_folder.php

@ -850,18 +850,22 @@ if ($is_certificate_mode) {
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
if (isset($_GET['createdir'])) {
$interbreadcrumb[] = [
'url' => $document_data['document_url'],
'name' => $document_data['title'],
];
} else {
// Hack in order to not add the document to the breadcrumb in case it is a link
if ($document_data['filetype'] != 'link') {
if ($document_data) {
$interbreadcrumb[] = [
'url' => '#',
'url' => $document_data['document_url'],
'name' => $document_data['title'],
];
}
} else {
if ($document_data) {
// Hack in order to not add the document to the breadcrumb in case it is a link
if ($document_data['filetype'] != 'link') {
$interbreadcrumb[] = [
'url' => '#',
'name' => $document_data['title'],
];
}
}
}
} else {
$counter = 0;

@ -3188,6 +3188,7 @@ class Exercise
if ($this->getFeedbackType() === EXERCISE_FEEDBACK_TYPE_POPUP) {
//$params['data-block-div-after-closing'] = "question_div_$question_id";
$params['data-block-closing'] = 'true';
$params['class'] .= ' no-header ';
}
$html .= Display::url(
@ -3641,7 +3642,7 @@ class Exercise
$answerDestination = null;
$userAnsweredQuestion = false;
$correctAnswerId = null;
$correctAnswerId = [];
for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) {
$answer = $objAnswerTmp->selectAnswer($answerId);
$answerComment = $objAnswerTmp->selectComment($answerId);
@ -3679,14 +3680,14 @@ class Exercise
if ($studentChoice) {
$questionScore += $answerWeighting;
$answerDestination = $objAnswerTmp->selectDestination($answerId);
$correctAnswerId = $answerId;
$correctAnswerId[] = $answerId;
}
} else {
$studentChoice = $choice == $answerAutoId ? 1 : 0;
if ($studentChoice) {
$questionScore += $answerWeighting;
$answerDestination = $objAnswerTmp->selectDestination($answerId);
$correctAnswerId = $answerId;
$correctAnswerId[] = $answerId;
}
}
break;
@ -3709,11 +3710,12 @@ class Exercise
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
if (!empty($studentChoice)) {
$correctAnswerId[] = $answerAutoId;
if ($studentChoice == $answerCorrect) {
$questionScore += $true_score;
} else {
if ($quiz_question_options[$studentChoice]['name'] == "Don't know" ||
$quiz_question_options[$studentChoice]['name'] == "DoubtScore"
if ($quiz_question_options[$studentChoice]['name'] === "Don't know" ||
$quiz_question_options[$studentChoice]['name'] === "DoubtScore"
) {
$questionScore += $doubt_score;
} else {
@ -3798,14 +3800,11 @@ class Exercise
$real_answers[$answerId] = (bool) $studentChoice;
if (isset($studentChoice)) {
$correctAnswerId[] = $answerAutoId;
$questionScore += $answerWeighting;
}
}
$totalScore += $answerWeighting;
if ($debug) {
error_log("studentChoice: $studentChoice");
}
break;
case GLOBAL_MULTIPLE_ANSWER:
if ($from_database) {
@ -4590,6 +4589,8 @@ class Exercise
if (isset($choice[$answerAutoId]) &&
$answerCorrect == $choice[$answerAutoId]
) {
$correctAnswerId[] = $answerAutoId;
$questionScore += $answerWeighting;
$totalScore += $answerWeighting;
$user_answer = Display::span($answerMatching[$choice[$answerAutoId]]);
@ -4758,6 +4759,7 @@ class Exercise
$user_array = substr($user_array, 0, -1) ?: '';
} else {
if (!empty($studentChoice)) {
$correctAnswerId[] = $answerAutoId;
$newquestionList[] = $questionId;
}

@ -1,11 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* @package chamilo.exercise
*
* @author Julio Montoya <gugli100@gmail.com>
*/
require_once __DIR__.'/../inc/global.inc.php';
@ -68,11 +67,19 @@ function SendEx(num) {
} else {
num -= 1;
window.location.href = "exercise_submit.php?'.api_get_cidreq().'&tryagain=1&exerciseId='.$exerciseId.'&num="+num+"&learnpath_item_id='.$learnpath_item_id.'&learnpath_id='.$learnpath_id.'";
}
}
return false;
}
</script>';
$header = '';
if ($objExercise->getFeedbackType() === EXERCISE_FEEDBACK_TYPE_POPUP) {
$header = '
<div class="modal-header">
<h4 class="modal-title" id="global-modal-title">'.get_lang('Incorrect').'</h4>
</div>';
}
echo '<div id="delineation-container">';
// Getting the options by js
if (empty($choiceValue) && empty($hotSpot) && $loaded) {
@ -106,6 +113,7 @@ if (empty($choiceValue) && empty($hotSpot) && $loaded) {
$links .= $icon;
}
}
echo $header;
echo '<div class="row"><div class="col-md-5 col-md-offset-7"><h5 class="pull-right">'.$links.'</h5></div></div>';
exit;
}
@ -113,18 +121,18 @@ if (empty($choiceValue) && empty($hotSpot) && $loaded) {
if (empty($choiceValue) && empty($hotSpot)) {
echo "<script>
// this works for only radio buttons
var f = window.document.frm_exercise;
var f = window.document.frm_exercise;
var choice_js = {answers: []};
var hotspot = new Array();
var hotspotcoord = new Array();
var counter = 0;
for (var i = 0; i < f.elements.length; i++) {
if (f.elements[i].type == 'radio' && f.elements[i].checked) {
for (var i = 0; i < f.elements.length; i++) {
if (f.elements[i].type == 'radio' && f.elements[i].checked) {
choice_js.answers.push(f.elements[i].value);
counter ++;
}
if (f.elements[i].type == 'checkbox' && f.elements[i].checked) {
choice_js.answers.push(f.elements[i].value);
counter ++;
@ -132,7 +140,7 @@ if (empty($choiceValue) && empty($hotSpot)) {
if (f.elements[i].type == 'hidden') {
var name = f.elements[i].name;
if (name.substr(0,7) == 'hotspot') {
hotspot.push(f.elements[i].value);
}
@ -142,9 +150,9 @@ if (empty($choiceValue) && empty($hotSpot)) {
}
}
}
var my_choice = $('*[name*=\"choice[".$questionId."]\"]').serialize();
var hotspot = $('*[name*=\"hotspot[".$questionId."]\"]').serialize();
var hotspot = $('*[name*=\"hotspot[".$questionId."]\"]').serialize();
";
// IMPORTANT
@ -153,13 +161,11 @@ if (empty($choiceValue) && empty($hotSpot)) {
$url = api_get_path(WEB_CODE_PATH).'exercise/exercise_submit_modal.php?'.api_get_cidreq().$extraUrl;
echo ' url = "'.addslashes($url).'&hotspotcoord="+ hotspotcoord + "&"+ hotspot + "&"+ my_choice;';
echo "$('#global-modal .modal-body').load(url);";
echo '</script>';
exit;
}
$choice = [];
$choice[$questionId] = isset($choiceValue) ? $choiceValue : null;
if (!is_array($exerciseResult)) {
$exerciseResult = [];
}
@ -218,11 +224,6 @@ switch ($answerType) {
}
break;
case CALCULATED_ANSWER:
/*$_SESSION['calculatedAnswerId'][$questionId] = mt_rand(
1,
$nbrAnswers
);*/
//var_dump($_SESSION['calculatedAnswerId'][$questionId]);
break;
}
@ -245,33 +246,91 @@ $result = $objExercise->manage_answer(
$manageAnswerHtmlContent = ob_get_clean();
$contents = '';
$answerCorrect = false;
$partialCorrect = false;
if (!empty($result)) {
switch ($answerType) {
case UNIQUE_ANSWER:
case MULTIPLE_ANSWER:
case UNIQUE_ANSWER:
case DRAGGABLE:
case HOT_SPOT_DELINEATION:
case CALCULATED_ANSWER:
if ($result['score'] == $result['weight']) {
$answerCorrect = true;
}
// Check partial correct
if (false === $answerCorrect) {
if (!empty($result['score'])) {
$partialCorrect = true;
}
}
break;
}
}
$header = '';
if ($objExercise->getFeedbackType() === EXERCISE_FEEDBACK_TYPE_DIRECT) {
if (isset($result['correct_answer_id'])) {
/** @var Answer $answer */
$answerId = $result['correct_answer_id'];
$contents = $objAnswerTmp->selectComment($answerId);
foreach ($result['correct_answer_id'] as $answerId) {
/** @var Answer $answer */
$contents .= $objAnswerTmp->selectComment($answerId);
}
}
} else {
$contents = Display::return_message(get_lang('Incorrect'), 'warning');
$message = get_lang('Incorrect');
//$contents = Display::return_message($message, 'warning');
if ($answerCorrect) {
$contents = Display::return_message(get_lang('Correct'), 'success');
$message = get_lang('Correct');
//$contents = Display::return_message($message, 'success');
} else {
if ($partialCorrect) {
$message = get_lang('PartialCorrect');
}
}
$comments = '';
if ($answerType != HOT_SPOT_DELINEATION) {
if (isset($result['correct_answer_id'])) {
$table = new HTML_Table(['class' => 'table data_table']);
$row = 0;
$table->setCellContents($row, 0, get_lang('YourAnswer'));
if ($answerType != DRAGGABLE) {
$table->setCellContents($row, 1, get_lang('Comment'));
}
$data = [];
foreach ($result['correct_answer_id'] as $answerId) {
$answer = $objAnswerTmp->getAnswerByAutoId($answerId);
if (!empty($answer) && isset($answer['comment'])) {
$data[] = [$answer['answer'], $answer['comment']];
} else {
$answer = $objAnswerTmp->selectAnswer($answerId);
$comment = $objAnswerTmp->selectComment($answerId);
$data[] = [$answer, $comment];
}
}
if (!empty($data)) {
$row = 1;
foreach ($data as $dataItem) {
$table->setCellContents($row, 0, $dataItem[0]);
$table->setCellContents($row, 1, $dataItem[1]);
$row++;
}
$comments = $table->toHtml();
}
}
}
$contents .= $comments;
$header = '
<div class="modal-header">
<h4 class="modal-title" id="global-modal-title">'.$message.'</h4>
</div>';
}
if ($answerType === HOT_SPOT_DELINEATION) {
$contents = $manageAnswerHtmlContent;
}
@ -350,6 +409,7 @@ if ($destinationId == -1) {
}
if (!empty($links)) {
echo $header;
echo '<div>'.$contents.'</div>';
echo '<div style="padding-left: 450px"><h5>'.$links.'</h5></div>';
echo '</div>';

@ -683,14 +683,20 @@ if (isset($modifyAnswers)) {
$option1 = $option2 = $option3 = '';
for ($k = 1; $k <= 100; $k++) {
$selected1 = $selected2 = $selected3 = '';
if ($k == $threadhold1[$i]) {
$selected1 = 'selected="selected"';
if (isset($threadhold1[$i])) {
if ($k == $threadhold1[$i]) {
$selected1 = 'selected="selected"';
}
}
if ($k == $threadhold2[$i]) {
$selected2 = 'selected="selected"';
if (isset($threadhold2[$i])) {
if ($k == $threadhold2[$i]) {
$selected2 = 'selected="selected"';
}
}
if ($k == $threadhold3[$i]) {
$selected3 = 'selected="selected"';
if (isset($threadhold3[$i])) {
if ($k == $threadhold3[$i]) {
$selected3 = 'selected="selected"';
}
}
$option1 .= '<option '.$selected1.' >'.$k.' % </option>';
$option2 .= '<option '.$selected2.' >'.$k.' % </option>';

@ -45,7 +45,7 @@ if (isset($_GET['action'])) {
$surveyId = $data['item_id'];
$surveyData = SurveyManager::get_survey($surveyId, 0, api_get_course_id());
if (!empty($surveyData)) {
$filename = 'survey_results_'.$surveyId.'.xlsx';
$filename = $surveyData['code'].'.xlsx';
$exportList[] = @SurveyUtil::export_complete_report_xls($surveyData, $filename, 0, true);
}
}

@ -196,7 +196,7 @@ class CoursesAndSessionsCatalog
}
// count courses that are in no category
$countCourses = CourseCategory::countCoursesInCategory();
$countCourses = CourseCategory::countCoursesInCategory('NONE');
$categories['NONE'] = [
'id' => 0,
'name' => get_lang('WithoutCategory'),
@ -541,13 +541,31 @@ class CoursesAndSessionsCatalog
}
/**
* Gets the extra fields listed in configuration option course_catalogue_order_by_extrafield.
* Gets extra fields listed in configuration option course_catalog_settings/extra_field_sort_options sorting order.
*
* @return array "extra_field_$id" => order (1 = ascending, -1 = descending)
*/
public static function courseExtraFieldSortingOrder()
{
$order = [];
$variableOrder = api_get_configuration_sub_value('course_catalog_settings/extra_field_sort_options', []);
foreach (self::getCourseExtraFieldsAvailableForSorting() as $extraField) {
$order['extra_field_'.$extraField->getId()] = $variableOrder[$extraField->getVariable()];
}
return $order;
}
/**
* Gets the extra fields listed in configuration option course_catalog_settings/extra_field_sort_options.
*
* @return ExtraField[]
*/
public static function getCourseExtraFieldsAvailableForSorting()
{
$variables = api_get_configuration_sub_value('course_catalogue_order_by_extrafield/fields');
$variables = array_keys(
api_get_configuration_sub_value('course_catalog_settings/extra_field_sort_options', [])
);
if (is_array($variables) && !empty($variables)) {
return ExtraField::getExtraFieldsFromVariablesOrdered($variables, ExtraField::COURSE_FIELD_TYPE);
}
@ -555,6 +573,26 @@ class CoursesAndSessionsCatalog
return [];
}
/**
* Builds the list of possible course standard sort criteria.
*
* @return array option name => order (1 = ascending, -1 = descending)
*/
public static function courseStandardSortOrder()
{
return api_get_configuration_sub_value(
'course_catalog_settings/standard_sort_options',
[
'title' => 1,
'creation_date' => -1,
'count_users' => -1, // subscription count
'point_info/point_average' => -1, // average score
'point_info/total_score' => -1, // score sum
'point_info/users' => -1, // vote count
]
);
}
/**
* Builds the list of possible course sort criteria to be used in an HTML select element.
*
@ -563,7 +601,7 @@ class CoursesAndSessionsCatalog
public static function courseSortOptions()
{
/** @var $extraFields ExtraField[] */
$options = [
$standardLabels = [
'title' => get_lang('Title'),
'creation_date' => get_lang('CreationDate'),
'count_users' => get_lang('SubscriptionCount'),
@ -571,6 +609,10 @@ class CoursesAndSessionsCatalog
'point_info/total_score' => get_lang('TotalScore'),
'point_info/users' => get_lang('VoteCount'),
];
$options = [];
foreach (array_keys(self::courseStandardSortOrder()) as $name) {
$options[$name] = $standardLabels[$name] ?: $name;
}
foreach (self::getCourseExtraFieldsAvailableForSorting() as $extraField) {
$options['extra_field_'.$extraField->getId()] = $extraField->getDisplayText();
}
@ -578,6 +620,11 @@ class CoursesAndSessionsCatalog
return $options;
}
public static function courseSortOrder()
{
return self::courseStandardSortOrder() + self::courseExtraFieldSortingOrder();
}
/**
* Wrapper for self::searchCourses which locally sorts the results according to $sortKey.
*
@ -636,14 +683,8 @@ class CoursesAndSessionsCatalog
unset($course);
}
}
$descKeys = [
'count_users',
'creation_date',
'point_info/point_average',
'point_info/total_score',
'point_info/users',
];
usort($courses, function ($a, $b) use ($sortKeys, $descKeys) {
$sortOrder = self::courseSortOrder();
usort($courses, function ($a, $b) use ($sortKeys, $sortOrder) {
foreach ($sortKeys as $key) {
$valueA = array_key_exists($key, $a) ? $a[$key] : null;
$valueB = array_key_exists($key, $b) ? $b[$key] : null;
@ -651,7 +692,7 @@ class CoursesAndSessionsCatalog
$aIsLessThanB = (is_string($valueA) && is_string($valueB))
? strtolower($valueA) < strtolower($valueB)
: $valueA < $valueB;
$reverseOrder = in_array($key, $descKeys);
$reverseOrder = (array_key_exists($key, $sortOrder) && -1 === $sortOrder[$key]);
$aIsBeforeB = ($aIsLessThanB xor $reverseOrder);
return $aIsBeforeB ? -1 : 1;

@ -616,7 +616,7 @@ class CourseCategory
}
$categoryFilter = '';
if ($categoryCode === 'ALL') {
if ($categoryCode === 'ALL' || empty($categoryCode)) {
// Nothing to do
} elseif ($categoryCode === 'NONE') {
$categoryFilter = ' AND category_code = "" ';

@ -543,6 +543,7 @@ class Event
$position = Database::escape_string($position);
$now = api_get_utc_datetime();
$course_id = (int) $course_id;
$recording = api_get_configuration_value('quiz_answer_extra_recording') == true;
// check user_id or get from context
if (empty($user_id)) {
@ -648,16 +649,16 @@ class Event
error_log("Insert attempt with id #$attempt_id");
}
if (defined('ENABLED_LIVE_EXERCISE_TRACKING')) {
if ($recording) {
if ($debug) {
error_log("Saving e attempt recording ");
}
$attempt_recording = [
'exe_id' => $attempt_id,
'question_id' => $question_id,
'answer' => $answer,
'marks' => $score,
'insert_date' => $now,
'author' => '',
'session_id' => $session_id,
];
Database::insert($recording_table, $attempt_recording);
@ -675,13 +676,13 @@ class Event
]
);
if (defined('ENABLED_LIVE_EXERCISE_TRACKING')) {
if ($recording) {
$attempt_recording = [
'exe_id' => $exe_id,
'question_id' => $question_id,
'answer' => $answer,
'marks' => $score,
'insert_date' => $now,
'author' => '',
'session_id' => $session_id,
];

@ -930,7 +930,12 @@ class ExerciseLib
WHERE exe_id = $exe_id AND question_id= $questionId";
$rsLastAttempt = Database::query($sql);
$rowLastAttempt = Database::fetch_array($rsLastAttempt);
$answer = $rowLastAttempt['answer'];
$answer = null;
if (isset($rowLastAttempt['answer'])) {
$answer = $rowLastAttempt['answer'];
}
if (empty($answer)) {
$_SESSION['calculatedAnswerId'][$questionId] = mt_rand(
1,

@ -182,12 +182,17 @@ class DateRangePicker extends HTML_QuickForm_text
$timePicker = 'false';
}
$timeIncrement = 30;
if (api_get_configuration_value('timepicker_increment')) {
$timeIncrement = api_get_configuration_value('timepicker_increment');
}
// timeFormat: 'hh:mm'
$js .= "<script>
$(function() {
$('#$id').daterangepicker({
timePicker: $timePicker,
timePickerIncrement: 30,
timePickerIncrement: $timeIncrement,
timePicker12Hour: false,
$defaultDates
$maxDate

@ -317,16 +317,12 @@ class Login
// a uid is given (log in succeeded)
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
$track_e_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = "SELECT user.*, a.user_id is_admin, UNIX_TIMESTAMP(login.login_date) login_date
$sql = "SELECT user.*, a.user_id is_admin
FROM $user_table
LEFT JOIN $admin_table a
ON user.user_id = a.user_id
LEFT JOIN $track_e_login login
ON user.user_id = login.login_user_id
WHERE user.user_id = '".$_user['user_id']."'
ORDER BY login.login_date DESC LIMIT 1";
WHERE user.user_id = ".$_user['user_id'];
$result = Database::query($sql);

@ -15,8 +15,9 @@ use ChamiloSession as Session;
*/
/**
* Insert a login reference for the current user into the track_e_online stats table.
* This table keeps trace of the last login. Nothing else matters (we don't keep traces of anything older).
* Insert a login reference for the current user into the track_e_online stats
* table. This table keeps trace of the last login. Nothing else matters (we
* don't keep traces of anything older).
*
* @param int user id
*/
@ -37,16 +38,22 @@ function LoginCheck($uid)
$access_url_id = api_get_current_access_url_id();
}
$session_id = api_get_session_id();
// if the $_course array exists this means we are in a course and we have to store this in the who's online table also
// to have the x users in this course feature working
if (is_array($_course) && count($_course) > 0 && !empty($_course['id'])) {
$query = "REPLACE INTO ".$online_table." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id)
VALUES ($uid,$uid,'$login_date','$user_ip', '".$_course['real_id']."' , '$session_id' , '$access_url_id' )";
} else {
$query = "REPLACE INTO ".$online_table." (login_id,login_user_id,login_date,user_ip, c_id, session_id, access_url_id)
VALUES ($uid,$uid,'$login_date','$user_ip', 0, '$session_id', '$access_url_id')";
$cid = 0;
if (is_array($_course) && count($_course) > 0 && !empty($_course['real_id'])) {
$cid = intval($_course['real_id']);
}
$query = "SELECT login_id FROM $online_table WHERE login_id = $uid";
$resLogin = Database::query($query);
if (Database::num_rows($resLogin) > 0) {
$query = "UPDATE $online_table SET
login_date = '$login_date',
user_ip = '$user_ip',
c_id = $cid,
session_id = $session_id,
access_url_id = $access_url_id
WHERE login_id = $uid";
Database::query($query);
}
Database::query($query);
}
}

@ -9255,10 +9255,8 @@ class SessionManager
/**
* @return int
*/
public static function getCountUsersInCourseSession(
Course $course,
Session $session
) {
public static function getCountUsersInCourseSession(Course $course, Session $session)
{
return Database::getManager()
->createQuery("
SELECT COUNT(scu)

@ -1452,6 +1452,20 @@ $_configuration['course_catalog_settings'] = [
'redirect_after_subscription' => 'course_home', // or 'course_catalog' to stay in the page
'extra_fields_in_search_form' => ['variable1', 'variable2'],
'extra_fields_in_course_block' => ['variable3', 'variable4'],
'standard_sort_options' => [
// 1 means allow sorting in ascending order
// -1 means allow sorting in descending order
'title' => 1,
'creation_date' => -1,
'count_users' => -1, // subscription count
'point_info/point_average' => -1, // average score
'point_info/total_score' => -1, // score sum
'point_info/users' => -1, // vote count
],
'extra_field_sort_options' => [
'variable5' => -1,
'variable6' => 1,
],
];
*/
@ -1466,11 +1480,6 @@ $_configuration['course_catalog_settings'] = [
// Disable sending emails.
//$_configuration['disable_send_mail'] = false;
// Page "Catalog" extra fields to be used as sorting criteria
/*$_configuration['course_catalogue_order_by_extrafield'] = [
'fields' => ['duree_en_min'],
];*/
// CKEditor font names
/*$_configuration['ck_editor_font_names'] = [
'names' => [
@ -1515,6 +1524,11 @@ $_configuration['auth_password_links'] = [
// ALTER TABLE c_lp_category ADD COLUMN session_id INT(11) DEFAULT NULL;
//$_configuration['allow_session_lp_category'] = false;
// Enable recording of all answers (even temporary) in the track_e_attempt_recording table
// This requires a column to be added to the table with the following query:
// ALTER TABLE track_e_attempt_recording ADD COLUMN answer longtext default '' AFTER question_id;
//$_configuration['quiz_answer_extra_recording'] = false;
// KEEP THIS AT THE END
// -------- Custom DB changes
// Add user activation by confirmation email
@ -1522,3 +1536,6 @@ $_configuration['auth_password_links'] = [
// You need add a new option called "confirmation" to the registration settings
//INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_registration', 'confirmation', 'MailConfirmation');
// ------ (End) Custom DB changes
//Allows to add increment in minutes to the date range component timepicker, example: 5,10,30 minutes
//$_configuration['timepicker_increment'] = 5;

@ -8517,4 +8517,7 @@ $ExportSurveyResults = "Export survey results";
$PointAverage = "Average score";
$TotalScore = "Score Sum";
$ExportResults = "Export results";
$QuizBrowserCheckOK = "Your browser has been verified. You can safely proceed.";
$QuizBrowserCheckKO = "Your browser could not be verified. Please try again, or try another browser or device before starting your test.";
$PartialCorrect = "Partially correct";
?>

@ -8449,4 +8449,7 @@ $ExportSurveyResults = "Exporter les résultats des enquêtes";
$PointAverage = "Moyenne des scores";
$TotalScore = "Somme des scores";
$ExportResults = "Exporter les résultats";
$QuizBrowserCheckOK = "Votre navigateur a été vérifié. Vous pouvez continuer en sécurité.";
$QuizBrowserCheckKO = "Votre navigateur n'a pas pu être vérifié. Essayer à nouveau s'il vous plaît, ou essayer un autre navigateur ou support avant de commencer votre test.";
$PartialCorrect = "Partiellement correct";
?>

@ -8545,4 +8545,7 @@ $ExportSurveyResults = "Exportar resultados de encuestas";
$PointAverage = "Puntajes promedio";
$TotalScore = "Suma de puntajes";
$ExportResults = "Exportar resultados";
$QuizBrowserCheckOK = "Su navegador ha sido verificado. Puede proceder con seguridad.";
$QuizBrowserCheckKO = "Su navegador no pudo ser verificado. Inténtelo de nuevo o pruebe con otro navegador o dispositivo antes de comenzar el examen.";
$PartialCorrect = "Parcialmente correcto";
?>

@ -2323,8 +2323,7 @@ class learnpath
$row = Database::fetch_array($rs, 'ASSOC');
if (!empty($row['category_id'])) {
$em = Database::getManager();
$category = $em->getRepository('ChamiloCourseBundle:CLpCategory')->find($row['category_id']);
$category = self::getCategory($row['category_id']);
if (self::categoryIsVisibleForStudent($category, api_get_user_entity($student_id)) === false) {
return false;
}
@ -4533,9 +4532,7 @@ class learnpath
);
$em = Database::getManager();
/** @var CLpCategory $category */
$category = $em->find('ChamiloCourseBundle:CLpCategory', $id);
$category = self::getCategory($id);
if (!$category) {
return false;
@ -4717,10 +4714,8 @@ class learnpath
*
* @return bool
*/
public static function categoryIsPublished(
CLpCategory $category,
$courseId
) {
public static function categoryIsPublished(CLpCategory $category, $courseId)
{
$link = self::getCategoryLinkForTool($category->getId());
$em = Database::getManager();
@ -12041,16 +12036,12 @@ EOD;
/**
* @param array $params
*
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
*/
public static function updateCategory($params)
{
$em = Database::getManager();
/** @var CLpCategory $item */
$item = $em->find('ChamiloCourseBundle:CLpCategory', $params['id']);
$item = self::getCategory($params['id']);
if ($item) {
$item->setName($params['name']);
$em->merge($item);
@ -12060,18 +12051,12 @@ EOD;
/**
* @param int $id
*
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
*/
public static function moveUpCategory($id)
{
$id = (int) $id;
$em = Database::getManager();
/** @var CLpCategory $item */
$item = $em->find('ChamiloCourseBundle:CLpCategory', $id);
$item = self::getCategory($id);
if ($item) {
$em = Database::getManager();
$position = $item->getPosition() - 1;
$item->setPosition($position);
$em->persist($item);
@ -12088,11 +12073,9 @@ EOD;
*/
public static function moveDownCategory($id)
{
$id = (int) $id;
$em = Database::getManager();
/** @var CLpCategory $item */
$item = $em->find('ChamiloCourseBundle:CLpCategory', $id);
$item = self::getCategory($id);
if ($item) {
$em = Database::getManager();
$position = $item->getPosition() + 1;
$item->setPosition($position);
$em->persist($item);
@ -12133,7 +12116,7 @@ EOD;
/**
* @param int $courseId
*
* @return mixed
* @return CLpCategory[]
*/
public static function getCategories($courseId)
{
@ -12146,13 +12129,29 @@ EOD;
return $repo->getBySortableGroupsQuery(['cId' => $courseId])->getResult();
}
public static function getCategorySessionId($id)
{
if (false === api_get_configuration_value('allow_session_lp_category')) {
return 0;
}
$table = Database::get_course_table(TABLE_LP_CATEGORY);
$id = (int) $id;
$sql = "SELECT session_id FROM $table WHERE iid = $id";
$result = Database::query($sql);
$result = Database::fetch_array($result, 'ASSOC');
if ($result) {
return (int) $result['session_id'];
}
return 0;
}
/**
* @param int $id
*
* @throws \Doctrine\ORM\ORMException
* @throws \Doctrine\ORM\OptimisticLockException
* @throws \Doctrine\ORM\TransactionRequiredException
*
* @return CLpCategory
*/
public static function getCategory($id)

@ -69,6 +69,15 @@ $introduction = Display::return_introduction_section(
$message = '';
$actions = '';
$allowCategory = true;
if (!empty($sessionId)) {
$allowCategory = false;
if (api_get_configuration_value('allow_session_lp_category')) {
$allowCategory = true;
}
}
if ($is_allowed_to_edit) {
$actionLeft = '';
$actionLeft .= Display::url(
@ -102,14 +111,6 @@ if ($is_allowed_to_edit) {
);
}
$allowCategory = true;
if (!empty($sessionId)) {
$allowCategory = false;
if (api_get_configuration_value('allow_session_lp_category')) {
$allowCategory = true;
}
}
if ($allowCategory) {
$actionLeft .= Display::url(
Display::return_icon(
@ -126,13 +127,27 @@ if ($is_allowed_to_edit) {
$token = Security::get_token();
$categoriesTempList = learnpath::getCategories($courseId);
$firstSessionCategoryId = 0;
if ($allowCategory) {
$newCategoryFiltered = [];
foreach ($categoriesTempList as $category) {
$categorySessionId = (int) learnpath::getCategorySessionId($category->getId());
if ($categorySessionId === $sessionId || $categorySessionId === 0) {
$newCategoryFiltered[] = $category;
}
if (!empty($sessionId) && empty($firstSessionCategoryId) && $categorySessionId == $sessionId) {
$firstSessionCategoryId = $category->getId();
}
}
$categoriesTempList = $newCategoryFiltered;
}
$categoryTest = new CLpCategory();
$categoryTest->setId(0);
$categoryTest->setName(get_lang('WithOutCategory'));
$categoryTest->setPosition(0);
$categories = [
$categoryTest,
];
$categories = [$categoryTest];
if (!empty($categoriesTempList)) {
$categories = array_merge($categories, $categoriesTempList);
@ -201,13 +216,9 @@ $tableCategory = Database::get_course_table(TABLE_LP_CATEGORY);
/** @var CLpCategory $item */
foreach ($categories as $item) {
$categoryId = $item->getId();
if (!empty($sessionId) && api_get_configuration_value('allow_session_lp_category')) {
$sql = "SELECT session_id FROM $tableCategory WHERE iid = $categoryId";
$result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC');
if ($row) {
$item->setSessionId((int) $row['session_id']);
}
if (!empty($sessionId) && $allowCategory) {
$categorySessionId = learnpath::getCategorySessionId($categoryId);
$item->setSessionId($categorySessionId);
}
if ($categoryId !== 0 && $subscriptionSettings['allow_add_users_to_lp_category'] == true) {
@ -225,6 +236,21 @@ foreach ($categories as $item) {
}
}
if ($allowCategory && !empty($sessionId)) {
// Check base course
if (0 === $item->getSessionId()) {
$categoryVisibility = api_get_item_visibility(
$courseInfo,
TOOL_LEARNPATH_CATEGORY,
$categoryId,
0
);
if ($categoryVisibility == 0) {
continue;
}
}
}
if ($user && !learnpath::categoryIsVisibleForStudent($item, $user)) {
continue;
}
@ -940,10 +966,7 @@ foreach ($categories as $item) {
$item->getId(),
$sessionId
),
'category_is_published' => learnpath::categoryIsPublished(
$item,
$courseInfo['real_id']
),
'category_is_published' => learnpath::categoryIsPublished($item, $courseInfo['real_id']),
'lp_list' => $listData,
];
}
@ -990,6 +1013,7 @@ if ($ending && $allLpTimeValid && api_get_configuration_value('download_files_af
}
$template = new Template($nameTools);
$template->assign('first_session_category', $firstSessionCategoryId);
$template->assign('session_star_icon', Display::return_icon('star.png', get_lang('Session')));
$template->assign('subscription_settings', $subscriptionSettings);
$template->assign('is_allowed_to_edit', $is_allowed_to_edit);

@ -172,10 +172,7 @@ if ($session->getNbrCourses() === 0) {
/** @var Course $course */
foreach ($courses as $course) {
// Select the number of users
$numberOfUsers = SessionManager::getCountUsersInCourseSession(
$course,
$session
);
$numberOfUsers = SessionManager::getCountUsersInCourseSession($course, $session);
// Get coachs of the courses in session
$namesOfCoaches = [];

@ -1,8 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -34,7 +33,7 @@ if (!list($session_name) = Database::fetch_row($result)) {
exit;
}
if ($action == 'delete') {
if ($action === 'delete') {
$idChecked = $_REQUEST['idChecked'];
if (is_array($idChecked) && count($idChecked) > 0) {
$my_temp = [];

@ -1,9 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @package chamilo.admin
*/
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -26,7 +24,7 @@ $course_code = Database::escape_string(trim($_GET['course_code']));
$courseInfo = api_get_course_info($course_code);
$courseId = $courseInfo['real_id'];
$page = isset($_GET['page']) ? intval($_GET['page']) : null;
$page = isset($_GET['page']) ? (int) $_GET['page'] : null;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$default_sort = api_sort_by_first_name() ? 'firstname' : 'lastname';
$sort = isset($_GET['sort']) && in_array($_GET['sort'], ['lastname', 'firstname', 'username'])
@ -44,7 +42,7 @@ if (is_array($idChecked)) {
$my_temp = [];
foreach ($idChecked as $id) {
// forcing the intval
$my_temp[] = intval($id);
$my_temp[] = (int) $id;
}
$idChecked = $my_temp;
}

@ -58,6 +58,11 @@ $(function() {
if ($(this).hasClass('no-close-button')) {
globalModal.find('.close').hide();
}
if ($(this).hasClass('no-header')) {
globalModal.find('.modal-header').hide();
}
var contentUrl = this.href;
var loadModalContent = $.get(contentUrl);
var self = $(this);
@ -78,8 +83,6 @@ $(function() {
modalTitle = self.data('title') || ' ';
modalDialog.removeClass('modal-lg modal-sm').css('width', '');
if (modalSize && modalSize.length != 0) {
switch (modalSize) {
case 'lg':

@ -42,8 +42,8 @@
</a>
{% endif %}
{% if not _c.session_id %}
{% if loop.index0 == 1 %}
{% if lp_data.category.sessionId == _c.session_id %}
{% if loop.index0 == 1 or first_session_category == lp_data.category.id %}
<a href="#">
<img src="{{ "up_na.png"|icon }}" alt="{{ "Move"|get_lang }}">
</a>
@ -67,7 +67,7 @@
{% endif %}
{% endif %}
{% if lp_data.category.sessionId == _c.session_id %}
{# {% if lp_data.category.sessionId == _c.session_id %}#}
{% if lp_data.category_visibility == 0 %}
<a href="lp_controller.php?{{ _p.web_cid_query ~ '&' ~ {'action':'toggle_category_visibility', 'id':lp_data.category.id, 'new_status':1}|url_encode }}"
title="{{ 'Show'|get_lang }}">
@ -79,9 +79,9 @@
<img src="{{ 'visible.png'|icon }}" alt="{{ 'Hide'|get_lang }}">
</a>
{% endif %}
{% endif %}
{# {% endif %}#}
{% if not _c.session_id %}
{# {% if not _c.session_id %}#}
{% if lp_data.category_is_published == 0 %}
<a href="lp_controller.php?{{ _p.web_cid_query ~ '&' ~ {'action':'toggle_category_publish', 'id':lp_data.category.id, 'new_status':1}|url_encode }}"
title="{{ 'LearnpathPublish'|get_lang }}">
@ -94,7 +94,7 @@
<img src="{{ 'lp_publish.png'|icon }}" alt="{{ 'Hide'|get_lang }}">
</a>
{% endif %}
{% endif %}
{# {% endif %}#}
{% if lp_data.category.sessionId == _c.session_id %}
<a href="{{ 'lp_controller.php?' ~ _p.web_cid_query ~ '&action=delete_lp_category&id=' ~ lp_data.category.getId() }}"

@ -0,0 +1,55 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Delete folders from users that have been deleted from the platform
* and where the personal folder in app/upload/users/[num]/[user_id]/
* was left behind.
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
// Remove the following line to enable
exit;
if (PHP_SAPI != 'cli') {
die('This script can only be executed from the command line');
}
require_once __DIR__.'/../../main/inc/global.inc.php';
$userFolder = $_configuration['root_sys'].'app/upload/users/';
$usersIds = [];
$sql1 = "SELECT id FROM user";
$res1 = Database::query($sql1);
while ($row1 = Database::fetch_array($res1)) {
$usersIds[$row1['id']] = true;
}
$list = scandir($userFolder);
foreach ($list as $directory) {
$directory = trim($directory);
if (substr($directory, 0, 1) == '.') {
continue;
}
if (intval($directory) != $directory) {
continue;
}
echo $userFolder.$directory."\n";
$subList = scandir($userFolder.'/'.$directory);
foreach ($subList as $subDirectory) {
$subDirectory = trim($subDirectory);
if (substr($subDirectory, 0, 1) == '.') {
continue;
}
if ($subDirectory == 'my_files') {
continue;
}
$fullDirectory = $directory.'/'.$subDirectory;
if (!empty($usersIds[$subDirectory])) {
echo "User ".$subDirectory." exists\n";
} else {
//echo "User ".$directory." does not exists\n";
$thisUserFolder = $userFolder.$fullDirectory;
//echo "Folder exists but user has been deleted: ".$thisUserFolder."\n";
echo "rm -rf $thisUserFolder\n";
exec("rm -rf ".$thisUserFolder);
}
}
}
Loading…
Cancel
Save