Proyectos de Subversion Moodle

Rev

Rev 1 | Rev 1049 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 497
Línea 1... Línea 1...
1
<?php
1
<?php
-
 
2
 
2
use core_completion\progress;
3
use core_completion\progress;
-
 
4
 
3
require_once $CFG->libdir . '/badgeslib.php';
5
require_once $CFG->libdir . '/badgeslib.php';
Línea 4... Línea 6...
4
 
6
 
-
 
7
class block_progreso_detalles_renderer extends plugin_renderer_base
-
 
8
{
-
 
9
 
-
 
10
    public function procesar($instance_id)
Línea 5... Línea -...
5
class block_progreso_detalles_renderer extends plugin_renderer_base {
-
 
6
 
-
 
7
    public function procesar($instance_id) {
11
    {
8
        
12
 
9
        global $USER, $CFG, $DB, $PAGE, $OUTPUT;
13
        global $USER, $CFG, $DB, $PAGE, $OUTPUT;
10
        
14
 
11
        require_once $CFG->libdir . '/completionlib.php';
15
        require_once $CFG->libdir . '/completionlib.php';
12
        require_once $CFG->dirroot.'/completion/classes/progress.php';
16
        require_once $CFG->dirroot . '/completion/classes/progress.php';
13
        require_once $CFG->dirroot  . '/course/classes/category.php';
17
        require_once $CFG->dirroot  . '/course/classes/category.php';
14
        require_once $CFG->libdir . '/gradelib.php';
18
        require_once $CFG->libdir . '/gradelib.php';
15
        require_once $CFG->dirroot . '/grade/querylib.php';
19
        require_once $CFG->dirroot . '/grade/querylib.php';
16
        
20
 
17
        //require_once $CFG->libdir . '/coursecatlib.php';
21
        //require_once $CFG->libdir . '/coursecatlib.php';
18
        $url_noimage =  $CFG->wwwroot . '/theme/' . $PAGE->theme->name . '/pix/coursenoimage.jpg';
22
        $url_noimage =  $CFG->wwwroot . '/theme/' . $PAGE->theme->name . '/pix/coursenoimage.jpg';
19
        
23
 
20
        if (!file_exists($CFG->dirroot.'/cesa/progreso_detalles/')) {
24
        if (!file_exists($CFG->dirroot . '/cesa/progreso_detalles/')) {
21
            mkdir($CFG->dirroot.'/cesa/progreso_detalles/', 0755, true);
25
            mkdir($CFG->dirroot . '/cesa/progreso_detalles/', 0755, true);
22
        }
26
        }
23
        if (!file_exists($CFG->dirroot.'/cesa/progreso_detalles/'.$USER->id)) {
27
        if (!file_exists($CFG->dirroot . '/cesa/progreso_detalles/' . $USER->id)) {
24
            mkdir($CFG->dirroot.'/cesa/progreso_detalles/'.$USER->id, 0755, true);
28
            mkdir($CFG->dirroot . '/cesa/progreso_detalles/' . $USER->id, 0755, true);
25
        }
29
        }
26
        $oldfiles = glob($CFG->dirroot.'/cesa/progreso_detalles/'.$USER->id.'/*');
30
        $oldfiles = glob($CFG->dirroot . '/cesa/progreso_detalles/' . $USER->id . '/*');
27
        foreach ($oldfiles as $file) {
31
        foreach ($oldfiles as $file) {
28
            if (is_file($file)) {
32
            if (is_file($file)) {
29
                unlink($file);
33
                unlink($file);
Línea 36... Línea 40...
36
        $grades     = 0;
40
        $grades     = 0;
37
        $points     = 0;
41
        $points     = 0;
38
        $badges     = 0;
42
        $badges     = 0;
39
        $content    = '';
43
        $content    = '';
40
        /** Inicio de las variables para el area de */
44
        /** Inicio de las variables para el area de */
41
        
45
 
42
        $user       = $DB->get_record('user',array('id'=> $USER->id)); 
46
        $user       = $DB->get_record('user', array('id' => $USER->id));
43
        $mycourses  = enrol_get_users_courses($USER->id);
47
        $mycourses  = enrol_get_users_courses($USER->id);
44
        $max_time   = time();
48
        $max_time   = time();
45
        $min_time   = strtotime('-1 YEAR');
49
        $min_time   = strtotime('-1 YEAR');
46
        $limit      = 3600;
50
        $limit      = 3600;
Línea 47... Línea 51...
47
 
51
 
48
        $data = [
52
        $data = [
49
            'user_name'         => $user->firstname . ' ' . $user->lastname  ,
53
            'user_name'         => $user->firstname . ' ' . $user->lastname,
50
            'user_image'        => $OUTPUT->user_picture($user, array('size' => 100, 'link' => false, 'alttext' => false)),
54
            'user_image'        => $OUTPUT->user_picture($user, array('size' => 100, 'link' => false, 'alttext' => false)),
51
            'user_email'        => $user->email,
55
            'user_email'        => $user->email,
52
            'graph_dedication'  => '',
56
            'graph_dedication'  => '',
53
            'completed'         => 0,
57
            'completed'         => 0,
54
            'inprogress'        => 0,
58
            'inprogress'        => 0,
55
            'total_dedication'  => '',
59
            'total_dedication'  => '',
56
            'courses'           => []
60
            'courses'           => []
57
        ];
-
 
Línea -... Línea 61...
-
 
61
        ];
58
        
62
 
Línea 59... Línea 63...
59
 
63
 
60
        
64
 
61
 
65
 
62
        $graph_percentage = [];
66
        $graph_percentage = [];
63
        $graph_dedication = [];
67
        $graph_dedication = [];
64
        $graph_labels = [];
68
        $graph_labels = [];
65
        
69
 
66
        
70
 
67
        $completed = 0;
71
        $completed = 0;
Línea 68... Línea 72...
68
        $inprogress = 0;
72
        $inprogress = 0;
69
	$dedication = 0;
73
        $dedication = 0;
70
        $total_dedication = 0;
74
        $total_dedication = 0;
71
 
75
 
72
        
76
 
Línea 73... Línea 77...
73
        foreach($mycourses as $key => $val) {
77
        foreach ($mycourses as $key => $val) {
74
            $course = get_course($val->id);
78
            $course = get_course($val->id);
Línea 75... Línea 79...
75
            $modules = get_fast_modinfo($val->id)->get_cms();
79
            $modules = get_fast_modinfo($val->id)->get_cms();
76
            $linkurl = '';
-
 
77
 
80
            $linkurl = '';
78
            $first_section = 0;
81
 
79
            $sections = $DB->get_records('course_sections', ['course' => $course->id], 'section ASC', 'id,name,section,sequence,visible');
82
            $first_section = 0;
80
 
83
            $sections = $DB->get_records('course_sections', ['course' => $course->id], 'section ASC', 'id,name,section,sequence,visible');
81
            foreach($sections as $section) 
84
 
82
            {
85
            foreach ($sections as $section) {
83
				if(!empty($section->section)) {
86
                if (!empty($section->section)) {
84
					$first_section = $section->id;
-
 
85
					break;
87
                    $first_section = $section->id;
86
				}
88
                    break;
87
			}
89
                }
88
 
90
            }
89
            foreach ($modules as $module) 
91
 
90
			{
92
            foreach ($modules as $module) {
91
				if (!$module->uservisible || $module->is_stealth() || empty($module->url) || empty($module->section)) {
93
                if (!$module->uservisible || $module->is_stealth() || empty($module->url) || empty($module->section)) {
92
					continue;
94
                    continue;
93
				}
95
                }
94
			
96
 
Línea 95... Línea 97...
95
				if($module->section == $first_section) {
97
                if ($module->section == $first_section) {
96
					$linkurl =  new moodle_url($module->url, array('forceview' => 1));
98
                    $linkurl =  new moodle_url($module->url, array('forceview' => 1));
97
					
99
 
98
					break;
100
                    break;
99
            	}
101
                }
100
			}
-
 
101
 
102
            }
102
            if ($course instanceof stdClass) {
103
 
103
                $courseInList = new core_course_list_element($course);
104
            if ($course instanceof stdClass) {
104
            }
105
                $courseInList = new core_course_list_element($course);
105
            $image = $url_noimage;
106
            }
106
            foreach ($courseInList->get_course_overviewfiles() as $file)
107
            $image = $url_noimage;
107
            {
108
            foreach ($courseInList->get_course_overviewfiles() as $file) {
108
                $isimage = $file->is_valid_image();
109
                $isimage = $file->is_valid_image();
109
                $image = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
110
                $image = file_encode_url("{$CFG->wwwroot}/pluginfile.php", '/' . $file->get_contextid() . '/' . $file->get_component() . '/' . $file->get_filearea() . $file->get_filepath() . $file->get_filename(), !$isimage);
110
                if (!$isimage) {
111
                if (!$isimage) {
111
                    $image = $url_noimage;
112
                    $image = $url_noimage;
112
                }
113
                }
113
            }
114
            }
114
            
115
 
115
            $lastaccess = null;
116
            $lastaccess = null;
116
            $sql = "select timecreated  from {logstore_standard_log} where courseid  = :courseid and userid  = :userid " .
117
            $sql = "select timecreated  from {logstore_standard_log} where courseid  = :courseid and userid  = :userid " .
117
                "  and eventname  = '\\\\core\\\\event\\\\course_viewed' order by id desc limit 1 ";
118
                "  and eventname  = '\\\\core\\\\event\\\\course_viewed' order by id desc limit 1 ";
118
            
119
 
119
            $timecreated = $DB->get_field_sql($sql,  array('courseid' => $course->id, 'userid' => $USER->id));
120
            $timecreated = $DB->get_field_sql($sql,  array('courseid' => $course->id, 'userid' => $USER->id));
120
            if($timecreated) {
121
            if ($timecreated) {
121
                
122
 
122
                $lastaccess = date('d/m/Y h:i a', $timecreated);
123
                $lastaccess = date('d/m/Y h:i a', $timecreated);
123
            }
124
            }
124
            
125
 
125
            $category = $DB->get_record('course_categories',array('id'=>$course->category));
126
            $category = $DB->get_record('course_categories', array('id' => $course->category));
126
            
127
 
127
            
-
 
128
            $completion = new \completion_info($course);
128
 
129
            $percentage = progress::get_course_progress_percentage($course,$USER->id);
129
            $completion = new \completion_info($course);
130
            //             echo 'course->fullname = '.$course->fullname."% = [$percentage]<br>";
130
            $percentage = progress::get_course_progress_percentage($course, $USER->id);
131
            if ($completion->is_enabled()) {
131
            //             echo 'course->fullname = '.$course->fullname."% = [$percentage]<br>";
132
                $percentage = progress::get_course_progress_percentage($course);
132
            if ($completion->is_enabled()) {
133
                $percentage = floatval(!$percentage ? 0 :  $percentage);
133
                $percentage = progress::get_course_progress_percentage($course);
134
 
134
                $percentage = floatval(!$percentage ? 0 :  $percentage);
135
            } else {
135
            } else {
136
                $percentage = 0;
136
                $percentage = 0;
137
            }
137
            }
138
            
138
 
139
  
139
 
140
            if($percentage >= 100) {
140
            if ($percentage >= 100) {
141
                $completed++;
141
                $completed++;
142
            } else {
142
            } else {
143
                $inprogress++;
143
                $inprogress++;
144
            }
144
            }
145
            
145
 
146
            $resultkrb =  grade_get_course_grades($course->id, $USER->id);
146
            $resultkrb =  grade_get_course_grades($course->id, $USER->id);
147
            
147
 
148
            
148
 
149
            $grd = $resultkrb->grades[$USER->id];
149
            $grd = $resultkrb->grades[$USER->id];
150
            $dedication = $this->get_students_dedication($USER->id, $course->id, $min_time, $max_time, $limit);
150
            $dedication = $this->get_students_dedication($USER->id, $course->id, $min_time, $max_time, $limit);
151
            
151
 
152
            $total_dedication = $total_dedication + $dedication;
152
            $total_dedication = $total_dedication + $dedication;
153
            
153
 
154
            $graph_percentage[] = number_format($percentage, 2);
154
            $graph_percentage[] = number_format($percentage, 2);
155
            $graph_labels[] = $course->shortname;
155
            $graph_labels[] = $course->shortname;
156
            
156
 
157
            
157
 
Línea 182... Línea 182...
182
                'dedication' => $dedication,
182
                'dedication' => $dedication,
183
                'percentage' => number_format($percentage, 2),
183
                'percentage' => number_format($percentage, 2),
184
            ];
184
            ];
185
        }
185
        }
Línea 186... Línea 186...
186
 
186
 
187
	$dedication = 0;        
187
        $dedication = 0;
188
        for($i = 0, $max = count($data['courses']); $i < $max; $i++) 
-
 
189
        {
188
        for ($i = 0, $max = count($data['courses']); $i < $max; $i++) {
190
            $dedication = ($data['courses'][$i][ 'dedication'] * 100) / $total_dedication;
189
            $dedication = ($data['courses'][$i]['dedication'] * 100) / $total_dedication;
191
             
190
 
192
            $data['courses'][$i][ 'dedication']  = $this->format_dedication($data['courses'][$i][ 'dedication']);
191
            $data['courses'][$i]['dedication']  = $this->format_dedication($data['courses'][$i]['dedication']);
193
            array_push($graph_dedication, number_format($dedication, 2));
192
            array_push($graph_dedication, number_format($dedication, 2));
194
        }
-
 
Línea -... Línea 193...
-
 
193
        }
195
        
194
 
196
 
195
 
197
 
196
 
Línea 198... Línea 197...
198
        $serie_dedication = new core\chart_series('Dedicación', $graph_dedication);
197
        $serie_dedication = new core\chart_series('Dedicación', $graph_dedication);
Línea 199... Línea 198...
199
        $serie_percentage = new core\chart_series('Progreso', $graph_percentage);
198
        $serie_percentage = new core\chart_series('Progreso', $graph_percentage);
Línea 200... Línea 199...
200
 
199
 
201
        
200
 
202
 
201
 
203
        $chart = new core\chart_bar();
202
        $chart = new core\chart_bar();
204
 
203
 
205
       
204
 
206
        
205
 
Línea 207... Línea 206...
207
        $chart->set_title('Dedicación/Progreso en %');
206
        $chart->set_title('Dedicación/Progreso en %');
208
        $chart->set_horizontal(true); // Calling set_horizontal() passing true as parameter will display horizontal bar charts.
207
        $chart->set_horizontal(true); // Calling set_horizontal() passing true as parameter will display horizontal bar charts.
209
        $chart->add_series( $serie_dedication );
208
        $chart->add_series($serie_dedication);
210
        $chart->add_series( $serie_percentage);
209
        $chart->add_series($serie_percentage);
211
        $chart->set_labels($graph_labels);
210
        $chart->set_labels($graph_labels);
212
 
211
 
Línea 213... Línea 212...
213
        $data['graph_dedication'] = $OUTPUT->render_chart($chart, true); //true muesta tabla de datos, false no
212
        $data['graph_dedication'] = $OUTPUT->render_chart($chart, true); //true muesta tabla de datos, false no
214
        
213
 
215
        
214
 
216
        $data['completed']          = $completed;
215
        $data['completed']          = $completed;
217
        $data['inprogress']         = $inprogress;
216
        $data['inprogress']         = $inprogress;
218
        $data['total_dedication']   = $this->format_dedication($total_dedication);
217
        $data['total_dedication']   = $this->format_dedication($total_dedication);
219
 
218
 
220
        // Inicio de agregado de cuadro curso
219
        // Inicio de agregado de cuadro curso
221
        $records = badges_get_user_badges($USER->id,null, null, null, null, true);
220
        $records = badges_get_user_badges($USER->id, null, null, null, null, true);
222
        $badges = count($records);
221
        $badges = count($records);
223
        if(0 != $completed || 0 != $inprogress) {
222
        if (0 != $completed || 0 != $inprogress) {
224
            $points = (int) ($points / ($completed + $inprogress));
223
            $points = (int) ($points / ($completed + $inprogress));
225
        }
224
        }
226
        
225
 
227
        $data['dedication']   = $this->format_dedication($total_dedication);
226
        $data['dedication']   = $this->format_dedication($total_dedication);
228
        $data['grades']   = $badges;
227
        $data['grades']   = $badges;
229
        $data['points']   = $points;
228
        $data['points']   = $points;
230
        
229
 
231
        $imgUser = new moodle_url('/user/pix.php/'.$USER->id.'/f1.jpg');
230
        $imgUser = new moodle_url('/user/pix.php/' . $USER->id . '/f1.jpg');
232
        $data['user_username']   = $USER->username;
231
        $data['user_username']   = $USER->username;
233
        $data['user_profile_picture']   = $imgUser;
232
        $data['user_profile_picture']   = $imgUser;
234
        
233
 
235
        $div_cuadro_inf = $OUTPUT->render_from_template('block_progreso_sinopsis/full', $data); //true muesta tabla de datos, false no
234
        $div_cuadro_inf = $OUTPUT->render_from_template('block_progreso_sinopsis/full', $data); //true muesta tabla de datos, false no
236
        
235
 
237
        $data['div_cuadro_inf']   = $div_cuadro_inf;
236
        $data['div_cuadro_inf']   = $div_cuadro_inf;
238
        // Fin de agregado de cuadro curso
237
        // Fin de agregado de cuadro curso
239
        
238
 
240
        $content .= html_writer::start_tag('div', array('class' => 'container')); //'d-flex flex-row bd-highlight mb-3'));
239
        $content .= html_writer::start_tag('div', array('class' => 'container')); //'d-flex flex-row bd-highlight mb-3'));
241
        $content .= $this->render_from_template('block_progreso_detalles/full', $data); 
240
        $content .= $this->render_from_template('block_progreso_detalles/full', $data);
242
        $content .= html_writer::end_tag('div');    
241
        $content .= html_writer::end_tag('div');
243
        $content = str_replace('<!--USER-IMAGE-->', $data['user_image'], $content);
242
        $content = str_replace('<!--USER-IMAGE-->', $data['user_image'], $content);
-
 
243
        $content = str_replace('<!--GRAPH-DEDICATION-->', $data['graph_dedication'], $content);
244
        $content = str_replace('<!--GRAPH-DEDICATION-->', $data['graph_dedication'], $content);
244
 
245
        
245
 
246
        
246
        return $content;
247
        return $content;
247
    }
248
    }
248
 
249
    
249
    public static function format_dedication($totalsecs)
250
    public static function format_dedication($totalsecs) {
250
    {
251
        $totalsecs = abs($totalsecs);
251
        $totalsecs = abs($totalsecs);
252
        
252
 
253
        $str = new stdClass();
253
        $str = new stdClass();
254
        $str->hour = get_string('hour');
254
        $str->hour = get_string('hour');
255
        $str->hours = get_string('hours');
255
        $str->hours = get_string('hours');
256
        $str->min = get_string('min');
256
        $str->min = get_string('min');
257
        $str->mins = get_string('mins');
257
        $str->mins = get_string('mins');
258
        $str->sec = get_string('sec');
258
        $str->sec = get_string('sec');
259
        $str->secs = get_string('secs');
259
        $str->secs = get_string('secs');
260
        
260
 
261
        $hours = floor($totalsecs / HOURSECS);
261
        $hours = floor($totalsecs / HOURSECS);
262
        $remainder = $totalsecs - ($hours * HOURSECS);
262
        $remainder = $totalsecs - ($hours * HOURSECS);
263
        $mins = floor($remainder / MINSECS);
263
        $mins = floor($remainder / MINSECS);
264
        $secs = round($remainder - ($mins * MINSECS), 2);
264
        $secs = round($remainder - ($mins * MINSECS), 2);
265
        
265
 
266
        $ss = ($secs == 1) ? $str->sec : $str->secs;
266
        $ss = ($secs == 1) ? $str->sec : $str->secs;
267
        $sm = ($mins == 1) ? $str->min : $str->mins;
267
        $sm = ($mins == 1) ? $str->min : $str->mins;
268
        $sh = ($hours == 1) ? $str->hour : $str->hours;
268
        $sh = ($hours == 1) ? $str->hour : $str->hours;
269
        
269
 
270
        $ohours = '';
270
        $ohours = '';
271
        $omins = '';
271
        $omins = '';
272
        $osecs = '';
272
        $osecs = '';
273
        
273
 
274
        if ($hours) {
274
        if ($hours) {
275
            //             $ohours = $hours . ' ' . $sh;
275
            //             $ohours = $hours . ' ' . $sh;
276
                        $ohours = $hours . ' ' . 'h';
276
            $ohours = $hours . ' ' . 'h';
277
                    }
277
        }
278
                    if ($mins) {
278
        if ($mins) {
279
            //             $omins = $mins . ' ' . $sm;
279
            //             $omins = $mins . ' ' . $sm;
280
                        $omins = $mins . ' ' . 'm';
280
            $omins = $mins . ' ' . 'm';
281
                    }
281
        }
282
                    if ($secs) {
282
        if ($secs) {
283
            //             $osecs = $secs . ' ' . $ss;
283
            //             $osecs = $secs . ' ' . $ss;
284
                        $osecs = $secs . ' ' . 's';
284
            $osecs = $secs . ' ' . 's';
Línea 293... Línea 293...
293
        if ($secs) {
293
        if ($secs) {
294
            return $osecs;
294
            return $osecs;
295
        }
295
        }
296
        return get_string('none');
296
        return get_string('none');
297
    }
297
    }
298
    
298
 
299
    public function get_events_select($selectwhere, array $params)
299
    public function get_events_select($selectwhere, array $params)
300
    {
300
    {
301
        $logstores  = ['logstore_standard', 'logstore_legacy'];
301
        $logstores  = ['logstore_standard', 'logstore_legacy'];
302
        $return     = [];
302
        $return     = [];
303
        
303
 
304
        static $allreaders = null;
304
        static $allreaders = null;
305
        
305
 
306
        if (is_null($allreaders)) {
306
        if (is_null($allreaders)) {
307
            $allreaders = get_log_manager()->get_readers();
307
            $allreaders = get_log_manager()->get_readers();
308
        }
308
        }
309
        
309
 
310
        $processedreaders = 0;
310
        $processedreaders = 0;
311
        
311
 
312
        foreach ($logstores as $name) {
312
        foreach ($logstores as $name) {
313
            if (isset($allreaders[$name])) {
313
            if (isset($allreaders[$name])) {
314
                $reader = $allreaders[$name];
314
                $reader = $allreaders[$name];
315
                $events = $reader->get_events_select($selectwhere, $params, 'timecreated ASC', 0, 0);
315
                $events = $reader->get_events_select($selectwhere, $params, 'timecreated ASC', 0, 0);
316
                foreach ($events as $event) {
316
                foreach ($events as $event) {
Línea 323... Línea 323...
323
                if (!empty($events)) {
323
                if (!empty($events)) {
324
                    $processedreaders++;
324
                    $processedreaders++;
325
                }
325
                }
326
            }
326
            }
327
        }
327
        }
328
        
328
 
329
        // Sort mixed array by time ascending again only when more of a reader has added events to return array.
329
        // Sort mixed array by time ascending again only when more of a reader has added events to return array.
330
        if ($processedreaders > 1) {
330
        if ($processedreaders > 1) {
331
            usort($return, function($a, $b) {
331
            usort($return, function ($a, $b) {
332
                return $a->time > $b->time;
332
                return $a->time > $b->time;
333
            });
333
            });
334
        }
334
        }
335
        
335
 
336
        return $return;
336
        return $return;
337
    }
337
    }
338
    
338
 
339
    public function get_students_dedication($user_id, $course_id, $min_time, $max_time, $limit)
339
    public function get_students_dedication($user_id, $course_id, $min_time, $max_time, $limit)
340
    {
340
    {
341
        
341
 
342
        $where = 'courseid = :courseid AND userid = :userid AND timecreated >= :mintime AND timecreated <= :maxtime';
342
        $where = 'courseid = :courseid AND userid = :userid AND timecreated >= :mintime AND timecreated <= :maxtime';
343
        $params = array(
343
        $params = array(
344
            'courseid'  => $course_id,
344
            'courseid'  => $course_id,
345
            'userid'    => $user_id,
345
            'userid'    => $user_id,
346
            'mintime'   => $min_time,
346
            'mintime'   => $min_time,
347
            'maxtime'   => $max_time
347
            'maxtime'   => $max_time
348
        );
348
        );
349
        
349
 
350
        
350
 
351
        $logs = $this->get_events_select($where, $params);
351
        $logs = $this->get_events_select($where, $params);
352
        if ($logs) {
352
        if ($logs) {
353
            $previouslog = array_shift($logs);
353
            $previouslog = array_shift($logs);
354
            $previouslogtime = $previouslog->time;
354
            $previouslogtime = $previouslog->time;
355
            $sessionstart = $previouslog->time;
355
            $sessionstart = $previouslog->time;
356
            $dedication = 0;
356
            $dedication = 0;
357
            
357
 
358
            foreach ($logs as $log) {
358
            foreach ($logs as $log) {
359
                if (($log->time - $previouslogtime) > $limit) {
359
                if (($log->time - $previouslogtime) > $limit) {
360
                    $dedication += $previouslogtime - $sessionstart;
360
                    $dedication += $previouslogtime - $sessionstart;
361
                    $sessionstart = $log->time;
361
                    $sessionstart = $log->time;
362
                }
362
                }
Línea 365... Línea 365...
365
            $dedication += $previouslogtime - $sessionstart;
365
            $dedication += $previouslogtime - $sessionstart;
366
        } else {
366
        } else {
367
            $dedication = 0;
367
            $dedication = 0;
368
        }
368
        }
369
        return $dedication;
369
        return $dedication;
370
        
-
 
371
    }
370
    }
372
 
-
 
373
    
-
 
374
 
-
 
375
}
371
}