From e35d455412cfd14cd8df537912662abe3d011ce9 Mon Sep 17 00:00:00 2001 From: Christian Date: Tue, 25 Oct 2022 16:09:33 -0500 Subject: [PATCH 1/5] Course - Add button about course sequence in catalogue info - refs BT#20314 --- main/template/default/course_home/about.tpl | 100 +++++++++++--------- 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/main/template/default/course_home/about.tpl b/main/template/default/course_home/about.tpl index e58b395d14..fe70894b13 100644 --- a/main/template/default/course_home/about.tpl +++ b/main/template/default/course_home/about.tpl @@ -110,70 +110,78 @@ {% if allow_subscribe == true %}
- {% if is_premium == false %} + {% if has_requirements %}
- {# public course (open world) #} - {% if 3 == course.visibility %} +

+ +

+ {{ subscribe_button }} +
+
+
{{ 'RequiredCourses'|get_lang }}
+ {% for sequence in sequences %} + {% if sequence.requirements %} +

+ {{ sequence.name }} : + {% for requirement in sequence.requirements %} + + {{ requirement.title | remove_xss }} + + {% endfor %} +

+ {% endif %} + {% endfor %} +
+ {% else %} + {% if is_premium == false %} +
+ {# public course (open world) #} + {% if 3 == course.visibility %} {{ 'CourseHomepage'|get_lang }} - {% elseif _u.logged == 0 %} + {% elseif _u.logged == 0 %} {% if 'allow_registration'|api_get_setting != 'false' %} - - - {{ 'SignUp'|get_lang }} - + + {{ 'SignUp'|get_lang }} + {% endif %} - {% elseif course.subscription %} + {% elseif course.subscription %} {{ 'CourseHomepage'|get_lang }} - {% else %} + {% else %} + href="{{ _p.web }}courses/{{ course.code }}/index.php?action=subscribe&sec_token={{ token }}" + class="btn btn-lg btn-success btn-block"> {{ 'Subscribe'|get_lang }} - {% endif %} -
- {% else %} -
-
- {{ 'SalePrice'|get_lang }} -
-
- {{ is_premium.total_price_formatted }} + {% endif %}
-
- - {{ 'BuyNow'|get_lang }} - + {% else %} +
+
+ {{ 'SalePrice'|get_lang }} +
+
+ {{ is_premium.total_price_formatted }} +
+
-
- {% endif %} - - {% if has_requirements %} -
-
{{ 'RequiredCourses'|get_lang }}
- {% for sequence in sequences %} - {% if sequence.requirements %} -

- {{ sequence.name }} : - {% for requirement in sequence.requirements %} - - {{ requirement.title | remove_xss }} - - {% endfor %} -

- {% endif %} - {% endfor %} -
+ {% endif %} {% endif %}
From acc1d74b382b53bc6e7307704d389c16d31809a2 Mon Sep 17 00:00:00 2001 From: NicoDucou Date: Wed, 26 Oct 2022 17:52:01 +0200 Subject: [PATCH 2/5] tracking: update partial translation in FR, EN, ES for graph to show on click - refs BT#20297 --- main/lang/english/trad4all.inc.php | 1 + main/lang/french/trad4all.inc.php | 1 + main/lang/spanish/trad4all.inc.php | 1 + 3 files changed, 3 insertions(+) diff --git a/main/lang/english/trad4all.inc.php b/main/lang/english/trad4all.inc.php index 3dd75e17c9..1d3dd4479a 100644 --- a/main/lang/english/trad4all.inc.php +++ b/main/lang/english/trad4all.inc.php @@ -5925,6 +5925,7 @@ $LowerCaseUser = "user"; $GenerateCertificates = "Generate certificates"; $ExportAllCertificatesToPDF = "Export all certificates to PDF"; $DeleteAllCertificates = "Delete all certificates"; +$ClickToShowGraphs = "Click to show graphics"; $dateFormatLongNoDay = "%d %B %Y"; $dateFormatOnlyDayName = "%A"; $ReturnToCourseList = "Return to the course list"; diff --git a/main/lang/french/trad4all.inc.php b/main/lang/french/trad4all.inc.php index ce3edf953c..65cf9af220 100644 --- a/main/lang/french/trad4all.inc.php +++ b/main/lang/french/trad4all.inc.php @@ -5914,6 +5914,7 @@ $LowerCaseUser = "utilisateur"; $GenerateCertificates = "Générer les certificats"; $ExportAllCertificatesToPDF = "Exporter tous les certificats à PDF"; $DeleteAllCertificates = "Supprimer tous les certificats"; +$ClickToShowGraphs = "Cliquer pour charger les graphiques"; $dateFormatLongNoDay = "%d %B %Y"; $dateFormatOnlyDayName = "%A"; $ReturnToCourseList = "Retour liste de cours"; diff --git a/main/lang/spanish/trad4all.inc.php b/main/lang/spanish/trad4all.inc.php index 60b72f9482..bf2ddd4ca5 100644 --- a/main/lang/spanish/trad4all.inc.php +++ b/main/lang/spanish/trad4all.inc.php @@ -5923,6 +5923,7 @@ $LowerCaseUser = "usuario"; $GenerateCertificates = "Generar certificados"; $ExportAllCertificatesToPDF = "Exportar todos los certificados a PDF"; $DeleteAllCertificates = "Eliminar todos los certificados"; +$ClickToShowGraphs = "Haga clic para ver los gráficos"; $dateFormatLongNoDay = "%d de %B de %Y"; $dateFormatOnlyDayName = "%A"; $ReturnToCourseList = "Regreso a lista de cursos"; From 12ecb7149db4e63b3d8f36f65f32d21dd7247733 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 26 Oct 2022 17:51:09 -0500 Subject: [PATCH 3/5] Course - Add inscription button when sequence is completed - refs BT#20314 --- main/course_info/about.php | 5 ++ main/template/default/course_home/about.tpl | 54 ++++++++++----------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/main/course_info/about.php b/main/course_info/about.php index 93cd7c80a1..bf3170e474 100644 --- a/main/course_info/about.php +++ b/main/course_info/about.php @@ -183,6 +183,11 @@ foreach ($requirements as $sequence) { } } +if ($hasRequirements) { + $sequenceList = $sequenceResourceRepo->checkRequirementsForUser($requirements, SequenceResource::COURSE_TYPE, $userId); + $allowSubscribe = $sequenceResourceRepo->checkSequenceAreCompleted($sequenceList); +} + $template = new Template($course->getTitle(), true, true, false, true, false); $template->assign('course', $courseItem); diff --git a/main/template/default/course_home/about.tpl b/main/template/default/course_home/about.tpl index fe70894b13..2595019c29 100644 --- a/main/template/default/course_home/about.tpl +++ b/main/template/default/course_home/about.tpl @@ -107,34 +107,9 @@
- {% if allow_subscribe == true %}
- {% if has_requirements %} -
-

- -

- {{ subscribe_button }} -
-
-
{{ 'RequiredCourses'|get_lang }}
- {% for sequence in sequences %} - {% if sequence.requirements %} -

- {{ sequence.name }} : - {% for requirement in sequence.requirements %} - - {{ requirement.title | remove_xss }} - - {% endfor %} -

- {% endif %} - {% endfor %} -
- {% else %} + {% if allow_subscribe == true %} {% if is_premium == false %}
{# public course (open world) #} @@ -182,10 +157,35 @@
{% endif %} + {% else %} +
+ +
+ {% endif %} + {% if has_requirements %} +
+
{{ 'RequiredCourses'|get_lang }}
+

+ {{ subscribe_button }} +

+ {% for sequence in sequences %} + {% if sequence.requirements %} +

+ {{ sequence.name }} : + {% for requirement in sequence.requirements %} + + {{ requirement.title | remove_xss }} + + {% endfor %} +

+ {% endif %} + {% endfor %} +
{% endif %}
- {% endif %} {% if course.teachers and not 'course_about_teacher_name_hide'|api_get_configuration_value %}
From 80f612a8783ecf88c9492a40761346d3e76832bc Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Thu, 27 Oct 2022 17:28:32 -0500 Subject: [PATCH 4/5] Fix returned values in callback for usort --- main/inc/lib/table_sort.class.php | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/main/inc/lib/table_sort.class.php b/main/inc/lib/table_sort.class.php index 5f85f4d489..16df084739 100755 --- a/main/inc/lib/table_sort.class.php +++ b/main/inc/lib/table_sort.class.php @@ -73,12 +73,14 @@ class TableSort switch ($type) { case SORT_NUMERIC: $function = function ($a, $b) use ($column, $compareOperator) { - $result = strip_tags($a[$column]) <= strip_tags($b[$column]); - if ('>' === $compareOperator) { - $result = strip_tags($a[$column]) > strip_tags($b[$column]); + $colA = strip_tags($a[$column]); + $colB = strip_tags($b[$column]); + + if ('>' === $compareOperator && $colA > $colB) { + return 1; } - return $result; + return $colA < $colB ? -1 : 0; }; break; case SORT_IMAGE: @@ -86,12 +88,12 @@ class TableSort $result = api_strnatcmp( api_strtolower(strip_tags($a[$column], "")), api_strtolower(strip_tags($b[$column], "")) - ) <= 0; + ); if ('>' === $compareOperator) { $result = api_strnatcmp( api_strtolower(strip_tags($a[$column], "")), api_strtolower(strip_tags($b[$column], "")) - ) > 0; + ); } return $result; @@ -100,12 +102,14 @@ class TableSort break; case SORT_DATE: $function = function ($a, $b) use ($column, $compareOperator) { - $result = strtotime(strip_tags($a[$column])) <= strtotime(strip_tags($b[$column])); - if ('>' === $compareOperator) { - $result = strtotime(strip_tags($a[$column])) > strtotime(strip_tags($b[$column])); + $dateA = strtotime(strip_tags($a[$column])); + $dateB = strtotime(strip_tags($b[$column])); + + if ('>' === $compareOperator && $dateA > $dateB) { + return 1; } - return $result; + return $dateA < $dateB ? -1 : 0; }; break; case SORT_STRING: @@ -114,12 +118,12 @@ class TableSort $result = api_strnatcmp( api_strtolower(strip_tags($a[$column])), api_strtolower(strip_tags($b[$column])) - ) <= 0; + ); if ('>' === $compareOperator) { $result = api_strnatcmp( api_strtolower(strip_tags($a[$column])), api_strtolower(strip_tags($b[$column])) - ) > 0; + ); } return $result; From 9628c951af0c8babe2f67cc8942e5c9bbad55eaa Mon Sep 17 00:00:00 2001 From: Nicolas Ducoulombier Date: Fri, 28 Oct 2022 15:56:51 +0200 Subject: [PATCH 5/5] Session : Give access in the session to the export user function for Session's general coach from the resume session page - refs BT#20259 --- main/inc/lib/api.lib.php | 13 ++++++------- main/session/resume_session.php | 3 ++- main/user/user_export.php | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) mode change 100644 => 100755 main/inc/lib/api.lib.php diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php old mode 100644 new mode 100755 index 2d6f4dbe26..a8a2ad04df --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -1328,22 +1328,22 @@ function api_protect_course_script($print_headers = false, $allow_session_admins * @param bool Whether to allow session admins as well * @param bool Whether to allow HR directors as well * @param string An optional message (already passed through get_lang) + * @param bool Whether to allow session coach as well * * @return bool True if user is allowed, false otherwise. * The function also outputs an error message in case not allowed * * @author Roan Embrechts (original author) */ -function api_protect_admin_script($allow_sessions_admins = false, $allow_drh = false, $message = null) +function api_protect_admin_script($allow_sessions_admins = false, $allow_drh = false, $message = null, $allow_session_coach = false) { if (!api_is_platform_admin($allow_sessions_admins, $allow_drh)) { - api_not_allowed(true, $message); - - return false; + if (!($allow_session_coach && api_is_coach())) { + api_not_allowed(true, $message); + return false; + } } - api_block_inactive_user(); - return true; } @@ -3369,7 +3369,6 @@ function api_is_coach($session_id = 0, $courseId = null, $check_student_view = t $sessionIsCoach = Database::store_result($result); } } - return count($sessionIsCoach) > 0; } diff --git a/main/session/resume_session.php b/main/session/resume_session.php index 5bf51e62a0..6a6660f826 100644 --- a/main/session/resume_session.php +++ b/main/session/resume_session.php @@ -8,6 +8,7 @@ use Chamilo\CoreBundle\Entity\Repository\SessionRepository; use Chamilo\CoreBundle\Entity\SequenceResource; use Chamilo\CoreBundle\Entity\Session; use Chamilo\CoreBundle\Entity\SessionRelCourseRelUser; +use ChamiloSession as PHPSession; /** * @author Bart Mollet, Julio Montoya lot of fixes @@ -23,7 +24,7 @@ $sessionId = isset($_GET['id_session']) ? (int) $_GET['id_session'] : null; if (empty($sessionId)) { api_not_allowed(true); } - +PHPSession::write('id_session',$sessionId); SessionManager::protectSession($sessionId); $codePath = api_get_path(WEB_CODE_PATH); diff --git a/main/user/user_export.php b/main/user/user_export.php index f9efe4eec9..69878e1cf2 100644 --- a/main/user/user_export.php +++ b/main/user/user_export.php @@ -5,7 +5,7 @@ require_once __DIR__.'/../inc/global.inc.php'; $this_section = SECTION_COURSES; -api_protect_admin_script(true, true); +api_protect_admin_script(true, true, null, true); $export = []; $export['file_type'] = isset($_REQUEST['file_type']) ? $_REQUEST['file_type'] : null;