Переглянути джерело

add list view course classic BT#11017

Alex Aragon 9 роки тому
батько
коміт
7e2e475014

+ 21 - 3
app/Resources/public/css/base.css

@@ -4856,6 +4856,15 @@ div#chat-remote-video video {
   width: 100px;
   height: 100px;
 }
+/* list courses classic*/
+.classic-courses .teachers{
+    margin: 0;
+    padding: 0;
+    display: inline-block;
+}
+.classic-courses .teachers li{
+    display: inline-block;
+}
 /* list my course user*/
 
 .grid-courses .items{
@@ -4880,12 +4889,17 @@ div#chat-remote-video video {
 .grid-courses .items .image{
     position: relative;
 }
+.grid-courses .items .image .pin{
+    position: absolute;
+    top: -10px;
+    right: -10px;
+    z-index: 2;
+}
 .grid-courses .items .image .black_shadow{
     top: 0px;
     left: 0px;
     width: 100%;
     height: 100%;
-    cursor: pointer;
     padding-top: 40px;
     opacity: 0;
     box-sizing: border-box;
@@ -4914,7 +4928,7 @@ div#chat-remote-video video {
     position: absolute;
     bottom: 0px;
     right: -10px;
-    background-color: #35DF86;
+    background-color: #FD6600;
     color: #fff;
     padding: 5px 10px;
     font-size: 11px;
@@ -4924,7 +4938,7 @@ div#chat-remote-video video {
 .grid-courses .items .cribbon{
     width: 0;
     height: 0;
-    border-top: 10px solid #19BF69;
+    border-top: 10px solid #FD3414;
     border-right: 10px solid transparent;
     position: absolute;
     bottom: -10px;
@@ -5961,6 +5975,10 @@ a.sessionView {
     .gallery .canvas-two{
         width: 100%;
     }
+    .grid-courses .items{
+        margin-left: 5%;
+        margin-right: 5%;
+    }
 }
 
 .elfinder-cwd-filename {

BIN
main/img/icons/48/drawing-pin.png


+ 31 - 80
main/inc/lib/course.lib.php

@@ -1891,6 +1891,7 @@ class CourseManager
         $listTeachers = array();
         $teachers = array();
         $count = 0;
+        
         while ($teacher = Database::fetch_array($rs)) {
             $userPicture = UserManager::getUserPicture($teacher['user_id'], USER_IMAGE_SIZE_SMALL);
             $teachers['id'] = $teacher['user_id'];
@@ -3404,7 +3405,7 @@ class CourseManager
      * @param bool      Whether to show the document quick-loader or not
      * @return string
      */
-    public static function display_special_courses($user_id, $load_dirs = false)
+    public static function returnSpecialCourses($user_id, $load_dirs = false)
     {
         $user_id = intval($user_id);
         $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
@@ -3418,6 +3419,7 @@ class CourseManager
         }
         $html = null;
         $courseCount = 0;
+        $listCourse = array();
         if (!empty($with_special_courses)) {
             $sql = "SELECT
                         course.id,
@@ -3435,7 +3437,7 @@ class CourseManager
 
             $rs_special_course = Database::query($sql);
             $number_of_courses = Database::num_rows($rs_special_course);
-
+            $showCustomIcon = api_get_setting('course_images_in_courses_list');
             $key = 0;
 
             if ($number_of_courses > 0) {
@@ -3455,97 +3457,46 @@ class CourseManager
                         $course['status'] = STUDENT;
                     }
 
-                    $params['icon'] = Display::return_icon(
-                        'blackboard.png',
-                        api_htmlentities($course_info['title']),
-                        array(),
-                        ICON_SIZE_LARGE
-                    );
-
-                    $params['right_actions'] = '';
+                    $params['edit_actions'] = '';
                     if (api_is_platform_admin()) {
-                        if ($load_dirs) {
-                            $params['right_actions'] .= '<a id="document_preview_' . $course['id'] . '_0" class="document_preview" href="javascript:void(0);">' .
-                                Display::return_icon(
-                                    'folder.png',
-                                    get_lang('Documents'),
-                                    array('align' => 'absmiddle'),
-                                    ICON_SIZE_SMALL
-                                ).'</a>';
-                            $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' .
-                                Display::return_icon(
-                                    'edit.png',
-                                    get_lang('Edit'),
-                                    array('align' => 'absmiddle'),
-                                    ICON_SIZE_SMALL
-                                ).'</a>';
-                            $params['right_actions'] .= Display::div('', array(
-                                    'id' => 'document_result_' . $course['id'] . '_0',
-                                    'class' => 'document_preview_container'
-                                ));
-                        } else {
-                            $params['right_actions'] .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'] . '">' .
-                                Display::return_icon('edit.png',
-                                    get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL) . '</a>';
-                        }
-                        if ($course['status'] == COURSEMANAGER) {
-                            //echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;'));
-                        }
-                    } else {
-                        if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
-                            if ($load_dirs) {
-                                $params['right_actions'] .= '<a id="document_preview_' . $course['id'] . '_0" class="document_preview" href="javascript:void(0);">' .
-                                    Display::return_icon(
-                                        'folder.png',
-                                        get_lang('Documents'),
-                                        array('align' => 'absmiddle'),
-                                        ICON_SIZE_SMALL
-                                    ).'</a>';
-                                $params['right_actions'] .= Display::div('', array(
-                                        'id' => 'document_result_' . $course['id'] . '_0',
-                                        'class' => 'document_preview_container'
-                                    ));
-                            }
-                        }
-                    }
-
-                    if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) {
-                        $course_title = '<a href="' . $course_info['course_public_url'] . '?id_session=0&autoreg=1">' . $course_info['title'] . '</a>';
-                    } else {
-                        $course_title = $course_info['title'] . " " . Display::tag('span', get_lang('CourseClosed'),
-                                array('class' => 'item_closed'));
-                    }
-
+                        $params['edit_actions'] .= api_get_path(WEB_CODE_PATH) . 'course_info/infocours.php?cidReq=' . $course['code'];
+                    } 
+                    $params['visibility'] = $course_info['visibility'];
+                    $params['status'] = $course['status'];
+                    $params['icon'] = Display::return_icon('drawing-pin.png',null, null, ICON_SIZE_LARGE, null);
+                    
                     if (api_get_setting('display_coursecode_in_courselist') == 'true') {
-                        $course_title .= ' (' . $course_info['visual_code'] . ') ';
-                    }
-                    if (api_get_setting('display_teacher_in_courselist') == 'true') {
-                        $params['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string(
-                            $course['code'],
-                            self::USER_SEPARATOR,
-                            true
-                        );
+                        $params['status']  = $course_info['visual_code'];
                     }
-                    $course_title .= '&nbsp;';
-                    $course_title .= Display::return_icon('klipper.png', get_lang('CourseAutoRegister'));
 
-                    $params['title'] = $course_title;
+                    $params['title'] = $course_info['title'];
                     $params['link'] = $course_info['course_public_url'].'?id_session=0&autoreg=1';
+                    if (api_get_setting('display_teacher_in_courselist') == 'true') {
+                        $params['teachers'] = CourseManager::getTeacheCourseCode($course['code']);
+                    }
+                    
+                    $thumbnails = null;
+                    $image = null;
+                    $iconName = basename($course_info['course_image']);
+                    if ($showCustomIcon === 'true' && $iconName != 'course.png') {
+                        $thumbnails = $course_info['course_image'];
+                        $image = $course_info['course_image_large'];
+                    }
+                    
+                    $params['thumbnails'] = $thumbnails;
+                    $params['image'] = $image;
 
                     if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
                         $params['notifications'] = $show_notification;
                     }
-
-                    $html .= self::course_item_html($params, false);
                     $key++;
+                    
+                    $listCourse[$key] = $params;
+                    
                 }
             }
         }
-
-        return [
-            'html' => $html,
-            'course_count' => $courseCount
-        ];
+        return $listCourse;
     }
 
     /**

+ 10 - 0
main/inc/lib/display.lib.php

@@ -2481,4 +2481,14 @@ HTML;
         }
         return $html;
     }
+    /**
+     * @param string $string
+     * @return null|string
+     */
+     
+    public static function shortName($string){
+        $ispace = strpos($string," ");
+        $text = substr($string, 0, $ispace);
+        return $text;
+    }
 }

+ 3 - 5
main/inc/lib/userportal.lib.php

@@ -1039,26 +1039,24 @@ class IndexManager
                 $html .= get_lang('YouDoNotHaveAnySessionInItsHistory');
             }
         }
-
-        $listCourse = '';
-        $special_courses = '';
+        
         $sessionCount = 0;
         $courseCount = 0;
 
         // If we're not in the history view...
         if (!isset($_GET['history'])) {
             // Display special courses.
-            $specialCourses = CourseManager::display_special_courses(
+            $specialCourses = CourseManager::returnSpecialCourses(
                 $user_id,
                 $this->load_directories_preview
             );
-            $special_courses = $specialCourses['html'];
             // Display courses.
             $courses = CourseManager::returnCourses(
                 $user_id,
                 $this->load_directories_preview
             );
             
+            $this->tpl->assign('special_courses', $specialCourses);
             $this->tpl->assign('courses', $courses);
             $listCourse = $this->tpl->fetch(
             $this->tpl->get_template('/user_portal/main_courses.tpl'));

+ 112 - 4
main/template/default/user_portal/main_courses.tpl

@@ -1,4 +1,107 @@
-
+<!-- view classic -->
+{% for course in courses %}
+<div class="classic-courses">
+    {% for item in course %}
+        <div class="panel panel-default">
+            <div class="panel-body">
+                <div class="row">
+                    <div class="col-md-2">
+                        <a class="thumbnail">
+                            {% if item.thumbnails != '' %}
+                                <img src="{{ item.thumbnails }}" title="{{ item.title }}" alt="{{ item.title }}"/>
+                            {% else %}
+                                {{ 'blackboard.png' | img(48, item.title ) }}
+                            {% endif %}
+                        </a>
+                    </div>
+                    <div class="col-md-10">
+                        {% if item.edit_actions != '' %}
+                            <div class="pull-right"><a class="btn btn-default btn-sm" href="{{ item.edit_actions }}"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
+                        {% endif %}
+                        <h4 class="course-items-title">
+                            {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
+                                {{ item.title }}
+                            {% else %}
+                                <a href="{{ item.link }}">
+                                    {{ item.title }}
+                                </a>
+                                {{ item.notifications }}
+                            {% endif %}
+                        </h4>
+                        <div class="course-items-session">
+                            {{ 'teacher.png' | img(16, 'Professor'|get_lang ) }}
+                            <ul class="teachers">
+                                {% for teacher in item.teachers %}
+                                <li>
+                                    {% set counter = counter + 1 %}
+                                    {% if counter > 1 %} | {% endif %}
+                                    <a href="{{ teacher.url }}" class="ajax" data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
+                                        {{ teacher.firstname }} {{ teacher.lastname }}
+                                    </a>
+                                </li>
+                                {% endfor %}
+                            </ul>  
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    {% endfor %}
+</div>
+{% endfor %}
+<!-- new view course special -->
+<div class="grid-courses">
+<div class="row">
+    {% for item in special_courses %}
+    <div class="col-md-4 col-sm-4 col-xs-6">
+        <div class="items">
+            <div class="image">
+                <div class="pin">{{ item.icon }}</div>
+                <img src="{{ item.image }}" class="img-responsive">
+                {% if item.category != '' %}
+                <span class="category">{{ item.category }}</span>
+                <div class="cribbon"></div>
+                {% endif %}
+                <div class="black_shadow">
+                    <div class="author-card">  
+                    {% for teacher in item.teachers %}
+                        {% set counter = counter + 1 %}
+                        {% if counter <= 3 %}
+                        <a href="{{ teacher.url }}" class="ajax" data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
+                            <img src="{{ teacher.avatar }}"/>
+                        </a>
+                        <div class="teachers-details">
+                             <h5>
+                                <a href="{{ teacher.url }}" class="ajax" data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
+                                    {{ teacher.firstname }} {{ teacher.lastname }}
+                                </a>
+                             </h5>
+                        </div>       
+                        {% endif %}
+                    {% endfor %}
+                    </div>
+                </div>
+                {% if item.edit_actions != '' %}
+                    <div class="admin-actions"><a class="btn btn-default btn-sm" href="{{ item.edit_actions }}"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
+                {% endif %}
+            </div>
+            <div class="description">
+                <h4 class="title">
+                    {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
+                        {{ item.title }}
+                    {% else %}
+                        <a href="{{ item.link }}">{{ item.title }}</a>
+                    {% endif %}
+                </h4>
+                <div class="notifications">{{ item.notifications }}</div>
+                
+            </div>
+        </div>
+    </div>
+    {% endfor %}
+    </div>
+</div>
+<!-- new view course list -->
 {% for course in courses %}
 <div class="grid-courses">
 <div class="row">
@@ -15,7 +118,7 @@
                     <div class="author-card">  
                     {% for teacher in item.teachers %}
                         {% set counter = counter + 1 %}
-                        {% if counter <= 5 %}
+                        {% if counter <= 3 %}
                         <a href="{{ teacher.url }}" class="ajax" data-title="{{ teacher.firstname }} {{ teacher.lastname }}">
                             <img src="{{ teacher.avatar }}"/>
                         </a>
@@ -35,7 +138,13 @@
                 {% endif %}
             </div>
             <div class="description">
-                <h4 class="title"><a href="{{ item.link }}">{{ item.title }}</a></h4>
+                <h4 class="title">
+                    {% if item.visibility == constant('COURSE_VISIBILITY_CLOSED') %}
+                        {{ item.title }}
+                    {% else %}
+                        <a href="{{ item.link }}">{{ item.title }}</a>
+                    {% endif %}
+                </h4>
                 <div class="notifications">{{ item.notifications }}</div>
                 
             </div>
@@ -45,4 +154,3 @@
     </div>
 </div>
 {% endfor %}
-