Просмотр исходного кода

Pagination of results user summary - refs #7683

Alex Aragón 6 лет назад
Родитель
Сommit
076d6e3aba

+ 9 - 1
app/Resources/public/css/base.css

@@ -9797,13 +9797,21 @@ ul.dropdown-menu.inner > li > a {
     position: relative;
 }
 
+.table-transparent>tbody>tr>td,
+.table-transparent>tbody>tr>th,
+.table-transparent>tfoot>tr>td,
+.table-transparent>tfoot>tr>th,
+.table-transparent>thead>tr>td,
+.table-transparent>thead>tr>th{
+    border: none;
+}
 .summary-height{
     height: calc(100% - 20px);
     display: flex;
     flex-grow: 1;
     flex-direction: column;
     box-shadow: 0 0 13px 0 rgba(82,63,105,0.05);
-    margin-bottom: 20px;
+    margin-bottom: 0;
     border-radius: 4px;
     border: 1px solid #cdcdcd;
     background-color: #f9f9fc;

+ 44 - 104
main/inc/lib/myspace.lib.php

@@ -316,7 +316,7 @@ class MySpace
      * @return array List course
      */
 
-    public static function returnCourseTrackingFilter($user_id){
+    public static function returnCourseTracking($user_id){
 
         $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
         // getting all the courses of the user
@@ -374,33 +374,33 @@ class MySpace
      * reporting progress of all users and all courses the user is subscribed to.
      *
      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+     *          Alex Aragon <alex.aragon@beeznest.com>, BeezNest, Perú
      *
-     * @version Chamilo 1.8.6
+     * @version Chamilo 1.11.8
      *
-     * @since October 2008
+     * @since April 2019
      */
 
-    public static function returnTrackingUserOverview(){
+    public static function returnTrackingUserOverviewFilter($user_id){
 
         $tpl = new Template('', false, false,false,false,false,false);
-        $dataUser = self::get_user_data_tracking_overview(null,10,1,'ASC');
+        $userInfo = api_get_user_info($user_id);
+
+        $avatar = UserManager::getUserPicture($user_id,USER_IMAGE_SIZE_SMALL);
+        $user =  [
+            'id' => $user_id,
+            'code_user' => $userInfo['official_code'],
+            'complete_name' => $userInfo['complete_name'],
+            'username' => $userInfo['username'],
+            'course' => self::returnCourseTracking($user_id),
+            'avatar' => $avatar
+        ];
 
-        $list = [];
-        foreach ($dataUser as $item){
-            $avatar = UserManager::getUserPicture($item['col4'],USER_IMAGE_SIZE_SMALL);
-            $listUser =  [
-                'id' => $item['col4'],
-                'code_user' => $item['col0'],
-                'complete_name' => $item['col1'] . ' ' . $item['col2'],
-                'username' => $item['col3'],
-                'course' => self::returnCourseTrackingFilter($item['col4']),
-                'avatar' => $avatar
-            ];
-            $list [] = $listUser;
-        }
-        $tpl->assign('data', $list);
-        $templateName = $tpl->get_template('my_space/tracking_user_overview.tpl');
-        $tpl->display($templateName);
+        $tpl->assign('item', $user);
+        $templateName = $tpl->get_template('my_space/partials/tracking_user_overview.tpl');
+        $content = $tpl->fetch($templateName);
+
+        return $content;
 
     }
 
@@ -409,88 +409,36 @@ class MySpace
      * reporting progress of all users and all courses the user is subscribed to.
      *
      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+     *         Alex Aragon <alex.aragon@beeznest.com>, BeezNest, Perú
      *
-     * @version Dokeos 1.8.6
+     * @version Chamilo 1.11.8
      *
-     * @since October 2008
+     * @since October 2008, Update April 2019
      */
     public static function display_tracking_user_overview()
     {
         self::display_user_overview_export_options();
-        $t_head = '<table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
-        $t_head .= '<tr>';
-        $t_head .= '<th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>';
-        $t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
-        $t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>';
-        $t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgCourseScore'), 6, true).'</span></th>';
-        $t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('TotalNumberOfMessages'), 6, true).'</span></th>';
-        $t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('TotalNumberOfAssignments'), 6, true).'</span></th>';
-        $t_head .= '<th width="105px" style="border-bottom:0"><span>'.get_lang('TotalExercisesScoreObtained').'</span></th>';
-        $t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('TotalExercisesAnswered'), 6, true).'</span></th>';
-        $t_head .= '<th style="padding:0;border-bottom:0;border-right:0;"><span>'.get_lang('LatestLogin').'</span></th>';
-        $t_head .= '</tr></table>';
+
         $addparams = ['view' => 'admin', 'display' => 'user'];
         $table = new SortableTable(
             'tracking_user_overview',
             ['MySpace', 'get_number_of_users_tracking_overview'],
             ['MySpace', 'get_user_data_tracking_overview'],
-            0
-        );
-        $table->additional_parameters = $addparams;
-        $table->set_header(
             0,
-            get_lang('OfficialCode'),
-            true,
-            ['style' => 'font-size:8pt'],
-            ['style' => 'font-size:8pt']
-        );
-        if (api_is_western_name_order()) {
-            $table->set_header(
-                1,
-                get_lang('FirstName'),
-                true,
-                ['style' => 'font-size:8pt'],
-                ['style' => 'font-size:8pt']
-            );
-            $table->set_header(
-                2,
-                get_lang('LastName'),
-                true,
-                ['style' => 'font-size:8pt'],
-                ['style' => 'font-size:8pt']
-            );
-        } else {
-            $table->set_header(
-                1,
-                get_lang('LastName'),
-                true,
-                ['style' => 'font-size:8pt'],
-                ['style' => 'font-size:8pt']
-            );
-            $table->set_header(
-                2,
-                get_lang('FirstName'),
-                true,
-                ['style' => 'font-size:8pt'],
-                ['style' => 'font-size:8pt']
-            );
-        }
-        $table->set_header(
-            3,
-            get_lang('LoginName'),
-            true,
-            ['style' => 'font-size:8pt'],
-            ['style' => 'font-size:8pt']
-        );
-        $table->set_header(
-            4,
-            $t_head,
-            false,
-            ['style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'],
-            ['style' => 'width:90%;padding:0;font-size:7.5pt;']
+            20,
+            'ASC',
+            null,[
+                'class' => 'table table-transparent'
+            ]
         );
-        $table->set_column_filter(4, ['MySpace', 'course_info_tracking_filter']);
-        $table->display();
+        $table->additional_parameters = $addparams;
+
+        $table->set_column_filter(0, ['MySpace', 'returnTrackingUserOverviewFilter']);
+        $tableContent = $table->return_table();
+        $tpl = new Template('', false, false,false,false,false,false);
+        $tpl->assign('table', $tableContent);
+        $templateName = $tpl->get_template('my_space/user_summary.tpl');
+        $tpl->display($templateName);
     }
 
     /**
@@ -2283,23 +2231,15 @@ class MySpace
         $userList = UserManager::get_user_list([], $order, $from, $numberItems);
         $return = [];
         foreach ($userList as $user) {
-            $firstPosition = $user['lastname'];
-            $secondPosition = $user['firstname'];
-            if ($isWestern) {
+            //$firstPosition = $user['lastname'];
+            //$secondPosition = $user['firstname'];
+            /*if ($isWestern) {
                 $firstPosition = $user['firstname'];
                 $secondPosition = $user['lastname'];
-            }
+            }*/
             $return[] = [
-                '0' => $user['official_code'],
-                'col0' => $user['official_code'],
-                '1' => $firstPosition,
-                'col1' => $firstPosition,
-                '2' => $secondPosition,
-                'col2' => $secondPosition,
-                '3' => $user['username'],
-                'col3' => $user['username'],
-                '4' => $user['user_id'],
-                'col4' => $user['user_id'],
+                '0' => $user['user_id'],
+                'col0' => $user['user_id']
             ];
         }
 

+ 13 - 7
main/inc/lib/sortable_table.class.php

@@ -104,18 +104,19 @@ class SortableTable extends HTML_Table
     /**
      * Create a new SortableTable.
      *
-     * @param string $table_name                A name for the table (default = 'table')
+     * @param string $table_name A name for the table (default = 'table')
      * @param string $get_total_number_function A user defined function to get
      *                                          the total number of items in the table
-     * @param string $get_data_function         A function to get the data to display on
+     * @param string $get_data_function A function to get the data to display on
      *                                          the current page
-     * @param int    $default_column            The default column on which the data should be
+     * @param int $default_column The default column on which the data should be
      *                                          sorted
-     * @param int    $default_items_per_page    The default number of items to show
+     * @param int $default_items_per_page The default number of items to show
      *                                          on one page
-     * @param string $default_order_direction   The default order direction;
+     * @param string $default_order_direction The default order direction;
      *                                          either the constant 'ASC' or 'DESC'
      * @param string $table_id
+     * @param array $parameters         They are custom attributes of the table
      */
     public function __construct(
         $table_name = 'table',
@@ -124,13 +125,18 @@ class SortableTable extends HTML_Table
         $default_column = 1,
         $default_items_per_page = 20,
         $default_order_direction = 'ASC',
-        $table_id = null
+        $table_id = null,
+        $parameters = []
     ) {
         if (empty($table_id)) {
             $table_id = $table_name.uniqid();
         }
+        if(isset($parameters) && empty($parameters)){
+            $parameters = ['class' => 'table table-bordered data_table', 'id' => $table_id];
+        }
+
         $this->table_id = $table_id;
-        parent::__construct(['class' => 'table table-bordered data_table', 'id' => $table_id]);
+        parent::__construct($parameters);
         $this->table_name = $table_name;
         $this->additional_parameters = [];
         $this->param_prefix = $table_name.'_';

+ 1 - 2
main/mySpace/admin_view.php

@@ -46,8 +46,7 @@ switch ($display) {
         MySpace::display_tracking_coach_overview($exportCSV);
         break;
     case 'user':
-        echo MySpace::returnTrackingUserOverview();
-        /*MySpace::display_tracking_user_overview();*/
+        MySpace::display_tracking_user_overview();
         break;
     case 'session':
         MySpace::display_tracking_session_overview();

+ 1 - 42
main/template/default/my_space/tracking_user_overview.tpl → main/template/default/my_space/partials/tracking_user_overview.tpl

@@ -1,44 +1,3 @@
-<div class="summary-legend">
-    <ul class="list-legend">
-        <li>
-            <span class="cube student-progress">
-            </span>
-            {{ 'AvgStudentsProgress'|get_lang }}
-        </li>
-        <li>
-            <span class="cube student-score">
-            </span>
-            {{ 'AvgCourseScore'|get_lang }}
-        </li>
-        <li>
-            <span class="cube student-message">
-            </span>
-            {{ 'TotalNumberOfMessages'|get_lang }}
-        </li>
-        <li>
-            <span class="cube student-assignments">
-            </span>
-            {{ 'TotalNumberOfAssignments'|get_lang }}
-        </li>
-        <li>
-            <span class="cube student-exercises">
-            </span>
-            {{ 'TotalExercisesScoreObtained'|get_lang }}
-        </li>
-        <li>
-            <span class="cube questions-answered">
-            </span>
-            {{ 'TotalExercisesAnswered'|get_lang }}
-        </li>
-        <li>
-            <span class="cube last-connection">
-            </span>
-            {{ 'LatestLogin'|get_lang }}
-        </li>
-    </ul>
-</div>
-
-{% for item in data %}
 <div class="summary-height">
     <div class="summary">
         <div class="summary-body">
@@ -115,4 +74,4 @@
         </div>
     </div>
 </div>
-{% endfor %}
+

+ 41 - 0
main/template/default/my_space/user_summary.tpl

@@ -0,0 +1,41 @@
+<div class="summary-legend">
+    <ul class="list-legend">
+        <li>
+            <span class="cube student-progress">
+            </span>
+            {{ 'AvgStudentsProgress'|get_lang }}
+        </li>
+        <li>
+            <span class="cube student-score">
+            </span>
+            {{ 'AvgCourseScore'|get_lang }}
+        </li>
+        <li>
+            <span class="cube student-message">
+            </span>
+            {{ 'TotalNumberOfMessages'|get_lang }}
+        </li>
+        <li>
+            <span class="cube student-assignments">
+            </span>
+            {{ 'TotalNumberOfAssignments'|get_lang }}
+        </li>
+        <li>
+            <span class="cube student-exercises">
+            </span>
+            {{ 'TotalExercisesScoreObtained'|get_lang }}
+        </li>
+        <li>
+            <span class="cube questions-answered">
+            </span>
+            {{ 'TotalExercisesAnswered'|get_lang }}
+        </li>
+        <li>
+            <span class="cube last-connection">
+            </span>
+            {{ 'LatestLogin'|get_lang }}
+        </li>
+    </ul>
+</div>
+
+{{ table }}