Kaynağa Gözat

Merge pull request #1 from chamilo/1.11.x

1.11.x update
mk111 8 yıl önce
ebeveyn
işleme
bcca5354c6

+ 27 - 1
app/Resources/public/css/editor.css

@@ -6,9 +6,35 @@
         alex.aragon@beeznest.com
     Version: 1.0
 */
-@import url(//fonts.googleapis.com/css?family=Open+Sans:400,300,600,300italic,400italic);
+
 @import url(../assets/fontawesome/css/font-awesome.min.css);
 
+@font-face {
+  font-family: 'Open Sans';
+  font-style: normal;
+  font-weight: 300;
+  src: local('Open Sans Light'), local('OpenSans-Light'), url(themes/chamilo/fonts/OpenSans-Light.woff2) format('woff2'), url(fonts/OpenSans-Light.woff) format('woff');
+}
+@font-face {
+  font-family: 'Open Sans';
+  font-style: normal;
+  font-weight: 400;
+  src: local('Open Sans'), local('OpenSans'), url(themes/chamilo/fonts/OpenSans.woff2) format('woff2'), url(fonts/OpenSans.woff) format('woff');
+}
+@font-face {
+  font-family: 'Open Sans';
+  font-style: normal;
+  font-weight: 600;
+  src: local('Open Sans Semibold'), local('OpenSans-Semibold'), url(themes/chamilo/fonts/OpenSans-Semibold.woff2) format('woff2'), url(fonts/OpenSans-Semibold.woff) format('woff');
+}
+@font-face {
+  font-family: 'Open Sans';
+  font-style: normal;
+  font-weight: 700;
+  src: local('Open Sans Bold'), local('OpenSans-Bold'), url(themes/chamilo/fonts/OpenSans-Bold.woff2) format('woff2'), url(fonts/OpenSans-Bold.woff) format('woff');
+}
+
+
 body{
     color: #666;
     font-family: 'Open Sans', sans-serif;

+ 8 - 0
main/admin/course_export.php

@@ -54,6 +54,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
             'Code',
             'Title',
             'CourseCategory',
+            'CourseCategoryName',
             'Teacher',
             'Language',
             'Users',
@@ -61,10 +62,17 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
         ];
 
         $dataToExport = [];
+
         foreach ($courses as $course) {
             $dataToExport['code'] = str_replace(';',',',$course['code']);
             $dataToExport['title'] = str_replace(';',',',$course['title']);
             $dataToExport['category_code'] = str_replace(';',',',$course['category_code']);
+            $categoryInfo = CourseCategory::getCategory($course['category_code']);
+            if ($categoryInfo) {
+                $dataToExport['category_name'] = str_replace(';',',',$categoryInfo['name']);
+            } else {
+                $dataToExport['category_name'] = '';
+            }
             $dataToExport['tutor_name'] = str_replace(';',',',$course['tutor_name']);
             $dataToExport['course_language'] = str_replace(';',',',$course['course_language']);
 

+ 18 - 11
main/admin/course_import.php

@@ -9,6 +9,9 @@
 
 /**
  * Validates imported data.
+ *
+ * @param array $courses
+ * @return array $errors
  */
 function validate_data($courses)
 {
@@ -20,14 +23,14 @@ function validate_data($courses)
         // 1. Check whether mandatory fields are set.
         $mandatory_fields = array ('Code', 'Title', 'CourseCategory');
         foreach ($mandatory_fields as $field) {
-            if (!isset($course[$field]) || strlen($course[$field]) == 0) {
+            if (empty($course[$field])) {
                 $course['error'] = get_lang($field.'Mandatory');
                 $errors[] = $course;
             }
         }
 
         // 2. Check current course code.
-        if (isset ($course['Code']) && strlen($course['Code']) != 0) {
+        if (!empty($course['Code'])) {
             // 2.1 Check whether code has been already used by this CVS-file.
             if (isset($coursecodes[$course['Code']])) {
                 $course['error'] = get_lang('CodeTwiceInFile');
@@ -61,12 +64,14 @@ function validate_data($courses)
             }
         }
 
-        // 4. Check whether course category exists.
-        if (isset($course['CourseCategory']) && strlen($course['CourseCategory']) != 0) {
+        if(!empty($course['CourseCategory'])) {
             $categoryInfo = CourseCategory::getCategory($course['CourseCategory']);
             if (empty($categoryInfo)) {
-                CourseCategory::addNode($course['CourseCategory'], $course['CourseCategory'], 'TRUE', null);
+                CourseCategory::addNode($course['CourseCategory'], $course['CourseCategoryName'] ? $course['CourseCategoryName'] : $course['CourseCategory'], 'TRUE', null);
             }
+        } else {
+            $course['error'] = get_lang('NoCourseCategorySupplied');
+            $errors[] = $course;
         }
     }
 
@@ -74,8 +79,9 @@ function validate_data($courses)
 }
 
 /**
- * @param array $teachers
+ * Get the teacher list
  *
+ * @param array $teachers
  * @return array
  */
 function getTeacherListInArray($teachers)
@@ -149,7 +155,7 @@ function save_data($courses)
  */
 function parse_csv_data($file)
 {
-    $courses = Import::csvToArray($file);
+    $courses = Import::csv_reader($file);
     return $courses;
 }
 
@@ -186,6 +192,7 @@ if (isset($_POST['formSent']) && $_POST['formSent']) {
             Display :: display_error_message(get_lang('YouMustImportAFileAccordingToSelectedOption'));
         } else {
             $courses = parse_csv_data($_FILES['import_file']['tmp_name']);
+
             $errors = validate_data($courses);
             if (count($errors) == 0) {
                 save_data($courses);
@@ -219,10 +226,10 @@ $form->display();
 
 <blockquote>
 <pre>
-<strong>Code</strong>;<strong>Title</strong>;<strong>CourseCategory</strong>;Teacher;Language
-BIO0015;Biology;BIO;teacher1;english
-BIO0016;Maths;MATH;teacher2|teacher3;english
-BIO0017;Language;LANG;;english
+<strong>Code</strong>;<strong>Title</strong>;<strong>CourseCategory</strong>;<strong>CourseCategoryName</strong>;Teacher;Language
+BIO0015;Biology;BIO;Science;teacher1;english
+BIO0016;Maths;MATH;Engineerng;teacher2|teacher3;english
+BIO0017;Language;LANG;;;english
 </pre>
 </blockquote>
 

+ 1 - 1
main/inc/lib/add_course.lib.inc.php

@@ -693,7 +693,7 @@ class AddCourse
                 'category' =>'certificates'
             ],
             'documents_default_visibility' => ['default' =>'visible', 'category' =>'document'],
-            'show_course_in_user_language' => ['default' => 2],
+            'show_course_in_user_language' => ['default' => 2, 'category' => null],
         ];
 
         $counter = 1;

+ 18 - 3
main/inc/lib/course.lib.php

@@ -286,7 +286,15 @@ class CourseManager
             $sql .= ' OFFSET 0';
         }
 
-        return Database::store_result(Database::query($sql));
+        $data = [];
+        $res = Database::query($sql);
+        if (Database::num_rows($res) > 0) {
+            while ($row = Database::fetch_array($res, 'ASSOC')) {
+                $data[] = $row;
+            }
+        }
+
+        return $data;
     }
 
     /**
@@ -3980,12 +3988,19 @@ class CourseManager
             $session_title = $course_info['name'];
         }
         
+        $thumbnails = null;
+        $image = null;
         $showCustomIcon = api_get_setting('course_images_in_courses_list');
         $iconName = basename($course_info['course_image']);
+        
         if ($showCustomIcon === 'true' && $iconName != 'course.png') {
-            $params['icon'] = $course_info['course_image_large'];
+            $thumbnails = $course_info['course_image'];
+            $image = $course_info['course_image_large'];
+        }else{
+            $image = Display::return_icon('session_default.png', null, null, null,null, true);
         }
-
+        $params['thumbnails'] = $thumbnails;
+        $params['image'] = $image;
         $params['link'] = $session_url;
         $params['title'] = $session_title;
         $params['edit_actions'] = '';

+ 2 - 0
main/inc/lib/export.lib.inc.php

@@ -37,6 +37,8 @@ class Export
      * Export tabular data to CSV-file
      * @param array $data
      * @param string $filename
+     *
+     * @return mixed csv file | false if no data to export
      */
     public static function arrayToCsv($data, $filename = 'export')
     {

+ 1 - 0
main/inc/lib/import.lib.php

@@ -16,6 +16,7 @@ class Import
 {
     /**
      * @param string $path
+     * @param bool $setFirstRowAsHeader
      * @return CsvReader
      */
     public static function csv_reader($path, $setFirstRowAsHeader = true)

+ 2 - 2
main/inc/lib/userportal.lib.php

@@ -1258,7 +1258,7 @@ class IndexManager
                                 );
                             } else {
                                 $sessions_with_no_category = $this->tpl->fetch(
-                                    $this->tpl->get_template('/user_portal/session.tpl')
+                                    $this->tpl->get_template('/user_portal/classic_session.tpl')
                                 );
                             }
                             $sessionCount++;
@@ -1357,7 +1357,7 @@ class IndexManager
 
                                 $this->tpl->assign('session', $sessionParams);
                                 $html_sessions .= $this->tpl->fetch(
-                                    $this->tpl->get_template('user_portal/session.tpl')
+                                    $this->tpl->get_template('user_portal/classic_session.tpl')
                                 );
 
                                 $sessionCount++;

+ 10 - 6
main/template/default/user_portal/session.tpl → main/template/default/user_portal/classic_session.tpl

@@ -40,9 +40,11 @@
                     {{ row.description }}
                 {% endif %}
                 <div class="info-session">
-                    <span><i class="fa fa-user" aria-hidden="true"></i>
-                    {{ row.coach_name }}
-                    </span>
+                    {% if row.coach_name  != '' %}
+                        <span><i class="fa fa-user" aria-hidden="true"></i>
+                        {{ row.coach_name }}
+                        </span>
+                    {% endif %}
                     <span><i class="fa fa-calendar" aria-hidden="true"></i>
                     {{ row.date }}
                     </span>
@@ -68,9 +70,11 @@
                     {{ row.description }}
                 {% endif %}
                 <div class="info-session">
-                    <span><i class="fa fa-user" aria-hidden="true"></i>
-                    {{ row.coach_name }}
-                    </span>
+                    {% if row.coach_name  != '' %}
+                        <span><i class="fa fa-user" aria-hidden="true"></i>
+                        {{ row.coach_name }}
+                        </span>
+                    {% endif %}
                     <span><i class="fa fa-calendar" aria-hidden="true"></i>
                     {{ row.date }}
                     </span>

+ 6 - 3
main/template/default/user_portal/grid_session.tpl

@@ -16,8 +16,11 @@
             {{ row.description }}
         {% endif %}
         <div class="info-session">
-            <span><i class="fa fa-user" aria-hidden="true"></i>
-            {{ row.coach_name }}
+            {% if row.coach_name  != '' %}
+                <span><i class="fa fa-user" aria-hidden="true"></i>
+                    {{ row.coach_name }}
+                </span>
+            {% endif %}
             </span>
             <span><i class="fa fa-calendar" aria-hidden="true"></i>
             {{ row.date }}
@@ -29,7 +32,7 @@
             <div class="col-md-4 col-sm-4 col-xs-6">
                 <div class="items">
                     <div class="image">
-                        <img src="{{ item.icon }}" class="img-responsive">
+                        <img src="{{ item.image }}" class="img-responsive">
                         {% if item.category != '' %}
                         <span class="category">{{ item.category }}</span>
                         <div class="cribbon"></div>