Browse Source

Add link for teacher for access to closed course - refs BT#12493

Angel Fernando Quiroz Campos 8 years ago
parent
commit
88de33947d

+ 11 - 0
main/inc/lib/course.lib.php

@@ -3784,6 +3784,17 @@ class CourseManager
                 $params['code_course'] = '(' . $course_info['visual_code'] . ') ';
             }
 
+            $params['current_user_is_teacher'] = false;
+
+            /** @var array $teacher */
+            foreach ($teachers as $teacher) {
+                if ($teacher['id'] != $user_id) {
+                    continue;
+                }
+
+                $params['current_user_is_teacher'] = true;
+            }
+
             $params['visibility'] = $course_info['visibility'];
             $params['link'] = $courseUrl;
             $params['thumbnails'] = $thumbnails;

+ 2 - 2
main/template/default/user_portal/classic_courses_with_category.tpl

@@ -9,7 +9,7 @@
                     {% for item in category.courses %}
                         <div class="row">
                             <div class="col-md-2">
-                                {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
+                                {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') and not item.current_user_is_teacher %}
                                     <span class="thumbnail">
                                         {% if item.thumbnails != '' %}
                                             <img src="{{ item.thumbnails }}" title="{{ item.title }}"
@@ -47,7 +47,7 @@
                                     </div>
                                 {% endif %}
                                 <h4 class="course-items-title">
-                                    {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
+                                    {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') and not item.current_user_is_teacher %}
                                         {{ item.title }} {{ item.code_course }}
                                     {% else %}
                                         <a href="{{ item.link }}">

+ 2 - 2
main/template/default/user_portal/classic_courses_without_category.tpl

@@ -5,7 +5,7 @@
             <div class="panel-body">
                 <div class="row">
                     <div class="col-md-2">
-                        {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
+                        {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') and not item.current_user_is_teacher %}
                             <span class="thumbnail">
                                 {% if item.thumbnails != '' %}
                                     <img src="{{ item.thumbnails }}" title="{{ item.title }}"
@@ -43,7 +43,7 @@
                             </div>
                         {% endif %}
                         <h4 class="course-items-title">
-                            {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
+                            {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') and not item.current_user_is_teacher %}
                                 {{ item.title }} {{ item.code_course }}
                             {% else %}
                                 <a href="{{ item.link }}">

+ 1 - 1
main/template/default/user_portal/grid_courses_with_category.tpl

@@ -57,7 +57,7 @@
                                 </div>
                                 <div class="description">
                                     <h4 class="title">
-                                        {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
+                                        {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') and not item.current_user_is_teacher %}
                                             {{ item.title }} {{ item.code_course }}
                                         {% else %}
                                             <a href="{{ item.link }}">{{ item.title }} {{ item.code_course }}</a>

+ 1 - 1
main/template/default/user_portal/grid_courses_without_category.tpl

@@ -54,7 +54,7 @@
                         </div>
                         <div class="description">
                             <h4 class="title">
-                                {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
+                                {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') and not item.current_user_is_teacher %}
                                     {{ item.title }} {{ item.code_course }}
                                 {% else %}
                                     <a href="{{ item.link }}">{{ item.title }} {{ item.code_course }}</a>