From 586f3855312ec1c0866ca55c9ab968ce9ffd3a4c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 22 Dec 2020 10:40:11 +0100 Subject: [PATCH] Update from 1.11.x --- assets/css/scorm.css | 49 ++++++++++++++++++- public/main/inc/ajax/course.ajax.php | 21 ++++++++ public/main/inc/ajax/gradebook.ajax.php | 14 ++++++ public/main/survey/survey.lib.php | 26 ++++++++-- public/main/tracking/course_log_resources.php | 2 +- public/main/tracking/course_log_tools.php | 2 +- .../main/tracking/course_session_report.php | 2 +- .../main/tracking/question_course_report.php | 2 +- 8 files changed, 108 insertions(+), 10 deletions(-) diff --git a/assets/css/scorm.css b/assets/css/scorm.css index dc9f082f21..dc681b26cd 100644 --- a/assets/css/scorm.css +++ b/assets/css/scorm.css @@ -1,4 +1,4 @@ -image-avatar/* +/* File used to display Learning Path item in student view If scorm.css file exists in theme folder, scorm.css file is used instead of this one See https://support.chamilo.org/issues/6976 @@ -524,7 +524,6 @@ See https://support.chamilo.org/issues/6976 } .c-menu-right { display: inline-flex; - width: 100%; position: relative; top: 0; left: 0; @@ -703,6 +702,52 @@ See https://support.chamilo.org/issues/6976 .tabs-right{ text-align: right; } + +#learning_path_toc .panel-default{ + border: none; + box-shadow: none; +} +.status-heading .panel-heading{ + padding: 0; +} +.status-heading .panel-heading .item-header{ + padding: 10px 15px 10px 30px; + display: inline-block; + width: 100%; + color: #333333; + font-weight: bold; + background: url("../../public/img/scorm/folder-item-open.png") #f5f5f5 no-repeat 10px center; +} +#learning_path_toc .child_item.lp_item_type_document.scorm_completed{ + background: url(../../public/img/icons/svg/check-completed.svg) #FFFFFF right center no-repeat; +} +#learning_path_toc .child_item.lp_item_type_document.scorm_not_attempted{ + background: url(../../public/img/icons/svg/check-not-attempted.svg) #FFFFFF right center no-repeat; +} +#learning_path_toc .root_item.lp_item_type_document.scorm_completed{ + background: url(../../public/img/icons/svg/check-completed.svg) #FFFFFF right center no-repeat; +} +#learning_path_toc .root_item.lp_item_type_document.scorm_not_attempted{ + background: url(../../public/img/icons/svg/check-not-attempted.svg) #FFFFFF right center no-repeat; +} +#learning_path_toc .root_item.lp_item_type_document.scorm_highlight{ + background-color: #f1f4f9; +} +#learning_path_toc .child_item.lp_item_type_document.scorm_highlight{ + background-color: #f1f4f9; +} +.status-heading .panel-heading .item-action{ + padding: 10px 15px; + display: inline-block; + width: 100%; + background-color: transparent; + color: #525252; + border-left: 1px solid #cdcdcd; +} +#learning_path_toc .panel-collapse .panel-body{ + padding: 10px 0 10px 10px; +} + /* END LP VIEW COLLAPSE */ /* Small devices (tablets, 768px and up) */ @media (min-width: 768px) { diff --git a/public/main/inc/ajax/course.ajax.php b/public/main/inc/ajax/course.ajax.php index 4f860ae086..0045d0d2ee 100644 --- a/public/main/inc/ajax/course.ajax.php +++ b/public/main/inc/ajax/course.ajax.php @@ -121,8 +121,16 @@ switch ($action) { break; } + $categoryToAvoid = ''; + if (!api_is_platform_admin()) { + $categoryToAvoid = api_get_configuration_value('course_category_code_to_use_as_model'); + } $list = []; foreach ($categories as $item) { + $categoryCode = $item['code']; + if (!empty($categoryToAvoid) && $categoryToAvoid == $categoryCode) { + continue; + } $list['items'][] = [ 'id' => $item['id'], 'text' => strip_tags($item['name']), @@ -156,6 +164,19 @@ switch ($action) { ); } elseif (api_is_teacher()) { $courseList = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_id(), $_GET['q']); + $category = api_get_configuration_value('course_category_code_to_use_as_model'); + if (!empty($category)) { + $alreadyAdded = []; + if (!empty($courseList)) { + $alreadyAdded = array_column($courseList, 'id'); + } + $coursesInCategory = CourseCategory::getCoursesInCategory($category, $_GET['q']); + foreach ($coursesInCategory as $course) { + if (!in_array($course['id'], $alreadyAdded)) { + $courseList[] = $course; + } + } + } } } diff --git a/public/main/inc/ajax/gradebook.ajax.php b/public/main/inc/ajax/gradebook.ajax.php index 55d826ec97..5fa795dce5 100644 --- a/public/main/inc/ajax/gradebook.ajax.php +++ b/public/main/inc/ajax/gradebook.ajax.php @@ -10,6 +10,20 @@ api_protect_course_script(true); $action = $_REQUEST['a']; switch ($action) { + case 'add_gradebook_comment': + if (true !== api_get_configuration_value('allow_gradebook_comments')) { + exit; + } + if (api_is_allowed_to_edit(null, true)) { + $userId = $_REQUEST['user_id'] ?? 0; + $gradeBookId = $_REQUEST['gradebook_id'] ?? 0; + $comment = $_REQUEST['comment'] ?? ''; + GradebookUtils::saveComment($gradeBookId, $userId, $comment); + echo 1; + exit; + } + echo 0; + break; case 'get_gradebook_weight': if (api_is_allowed_to_edit(null, true)) { $cat_id = $_GET['cat_id']; diff --git a/public/main/survey/survey.lib.php b/public/main/survey/survey.lib.php index 9529ed10cd..3aa2dd7e45 100644 --- a/public/main/survey/survey.lib.php +++ b/public/main/survey/survey.lib.php @@ -2470,9 +2470,23 @@ class SurveyManager } ksort($newQuestionList); + $order = api_get_configuration_value('survey_duplicate_order_by_name'); foreach ($itemList as $class) { $className = $class['name']; $users = $class['users']; + $userInfoList = []; + foreach ($users as $userId) { + $userInfoList[] = api_get_user_info($userId); + } + + if ($order) { + usort( + $userInfoList, + function ($a, $b) { + return $a['lastname'] > $b['lastname']; + } + ); + } foreach ($newQuestionList as $question) { $text = $question['question']; @@ -2488,15 +2502,14 @@ class SurveyManager 'survey_id' => $surveyId, 'question_id' => 0, 'shared_question_id' => 0, - 'answers' => $question['answers'], + 'answers' => $question['answers'] ?? null, ]; self::save_question($surveyData, $values, false); $classCounter++; continue; } - foreach ($users as $userId) { - $userInfo = api_get_user_info($userId); + foreach ($userInfoList as $userInfo) { if (false !== strpos($text, $studentTag)) { $replacedText = str_replace($studentTag, $userInfo['complete_name'], $text); @@ -2758,7 +2771,12 @@ class SurveyManager if (empty($sessionId)) { $subscribe = CourseManager::is_user_subscribed_in_course($userId, $courseCode); } else { - $subscribe = CourseManager::is_user_subscribed_in_course($userId, $courseCode, true, $sessionId); + $subscribe = CourseManager::is_user_subscribed_in_course( + $userId, + $courseCode, + true, + $sessionId + ); } // User is not subscribe skip! diff --git a/public/main/tracking/course_log_resources.php b/public/main/tracking/course_log_resources.php index c9ffa88dca..e3180600f7 100644 --- a/public/main/tracking/course_log_resources.php +++ b/public/main/tracking/course_log_resources.php @@ -66,7 +66,7 @@ if ($export_csv || $exportXls) { if ($exportXls) { Export::arrayToXls($csvData); } - die; + exit; } if (empty($session_id)) { diff --git a/public/main/tracking/course_log_tools.php b/public/main/tracking/course_log_tools.php index 70a8ed51ea..fa7ffd4237 100644 --- a/public/main/tracking/course_log_tools.php +++ b/public/main/tracking/course_log_tools.php @@ -448,7 +448,7 @@ if ($linkReporting) { if ($export_csv) { $temp = [ $row['title'], - $row['count_visits'].' '.get_lang('clicks', ''), + $row['count_visits'].' '.get_lang('clicks'), ]; $csv_content[] = $temp; } diff --git a/public/main/tracking/course_session_report.php b/public/main/tracking/course_session_report.php index d541949f0e..6c00c5cf30 100644 --- a/public/main/tracking/course_session_report.php +++ b/public/main/tracking/course_session_report.php @@ -121,7 +121,7 @@ $total_average_score = 0; $total_average_score_count = 0; $html_result = ''; if (!empty($users) && is_array($users)) { - $html_result .= ''; + $html_result .= '
'; $html_result .= ''; foreach ($course_list as $item) { $html_result .= ''; diff --git a/public/main/tracking/question_course_report.php b/public/main/tracking/question_course_report.php index a2fa45733e..9af5bea6fa 100644 --- a/public/main/tracking/question_course_report.php +++ b/public/main/tracking/question_course_report.php @@ -173,7 +173,7 @@ $course_average = []; $counter = 0; if (!empty($main_question_list) && is_array($main_question_list)) { - $html_result .= '
'.get_lang('User').''.$item['title'].'
'.get_lang('Average score').' %
'; + $html_result .= '
'; $html_result .= ''; $html_result .= '';
'.get_lang('Question'). Display::return_icon('info3.gif', get_lang('These questions have been taken from the learning paths'), ['align' => 'absmiddle', 'hspace' => '3px']).''.$course_info['visual_code'].' '.get_lang('Average score').Display::return_icon('info3.gif', get_lang('All learners attempts are considered'), ['align' => 'absmiddle', 'hspace' => '3px']).'