Proyectos de Subversion Moodle

Rev

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

Rev 1300 Rev 1301
Línea 12... Línea 12...
12
// GNU General Public License for more details.
12
// GNU General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU General Public License
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea 16... Línea 16...
16
 
16
 
Línea 17... Línea 17...
17
namespace theme_universe\output;
17
namespace theme_universe_child\output;
18
 
18
 
19
use html_writer;
19
use html_writer;
20
use stdClass;
20
use stdClass;
Línea 29... Línea 29...
29
use action_link;
29
use action_link;
30
use core_text;
30
use core_text;
31
use coding_exception;
31
use coding_exception;
32
use navigation_node;
32
use navigation_node;
33
use context_header;
33
use context_header;
-
 
34
use core\oauth2\rest;
34
use pix_icon;
35
use pix_icon;
35
use renderer_base;
36
use renderer_base;
36
use theme_config;
37
use theme_config;
37
use get_string;
38
use get_string;
38
use core_course_category;
39
use core_course_category;
39
use theme_universe\util\user;
40
use theme_universe\util\user;
40
use theme_universe\util\course;
41
use theme_universe\util\course;
-
 
42
use core_completion\progress;
Línea 41... Línea 43...
41
 
43
 
Línea 42... Línea 44...
42
require_once($CFG->dirroot . '/cesa/statics_blocks.php'); // Incluimos StaticsBlocks
44
require_once($CFG->dirroot . '/cesa/statics_blocks.php'); // Incluimos StaticsBlocks
Línea 817... Línea 819...
817
        if ($position < ($nummods - 1)) {
819
        if ($position < ($nummods - 1)) {
818
            $nextmod = $mods[$modids[$position + 1]];
820
            $nextmod = $mods[$modids[$position + 1]];
819
        }
821
        }
820
        $activitynav = new \core_course\output\activity_navigation($prevmod, $nextmod, $activitylist);
822
        $activitynav = new \core_course\output\activity_navigation($prevmod, $nextmod, $activitylist);
821
        $renderer = $this->page->get_renderer('core', 'course');
823
        $renderer = $this->page->get_renderer('core', 'course');
-
 
824
        if ($this->cesa_navigation_course_completion() == '') {
822
        return $renderer->render($activitynav);
825
            return $renderer->render($activitynav);
-
 
826
        }
-
 
827
        return '';
823
    }
828
    }
Línea -... Línea 829...
-
 
829
 
824
 
830
 
825
 
831
 
826
    /**
832
    /**
827
     * This is an optional menu that can be added to a layout by a theme. It contains the
833
     * This is an optional menu that can be added to a layout by a theme. It contains the
828
     * menu for the course administration, only on the course main page.
834
     * menu for the course administration, only on the course main page.
Línea 1352... Línea 1358...
1352
                    $am->add($divider);
1358
                    $am->add($divider);
1353
                }
1359
                }
1354
            }
1360
            }
1355
        }
1361
        }
Línea -... Línea 1362...
-
 
1362
 
-
 
1363
 
1356
 
1364
 
1357
        return html_writer::div(
1365
        return html_writer::div(
1358
            $this->render($am),
1366
            $this->render($am),
1359
            $usermenuclasses
1367
            $usermenuclasses
1360
        );
1368
        );
Línea 1743... Línea 1751...
1743
    public function header()
1751
    public function header()
1744
    {
1752
    {
1745
        global $USER, $COURSE;
1753
        global $USER, $COURSE;
1746
        $theme = theme_config::load('universe');
1754
        $theme = theme_config::load('universe');
Línea -... Línea 1755...
-
 
1755
 
-
 
1756
        // Verificar si el curso está definido
-
 
1757
        if (!isset($COURSE) || empty($COURSE->id)) {
-
 
1758
            debugging('Error: No se pudo obtener el contexto del curso.', DEBUG_DEVELOPER);
-
 
1759
            return parent::header();
-
 
1760
        }
-
 
1761
 
-
 
1762
        // Verificar si el usuario está autenticado
-
 
1763
        if (!isset($USER->id)) {
-
 
1764
            debugging('Error: Usuario no autenticado.', DEBUG_DEVELOPER);
-
 
1765
            return parent::header();
-
 
1766
        }
-
 
1767
 
1747
 
1768
        // Obtener contexto del curso
1748
        $context = context_course::instance($COURSE->id);
1769
        $context = context_course::instance($COURSE->id);
Línea -... Línea 1770...
-
 
1770
        $roles = get_user_roles($context, $USER->id, true) ?: [];
1749
        $roles = get_user_roles($context, $USER->id, true);
1771
 
1750
 
1772
        // Agregar clases según los roles del usuario
1751
        if (is_array($roles) && !empty($roles)) {
1773
        if (!empty($roles)) {
1752
            foreach ($roles as $role) {
1774
            foreach ($roles as $role) {
1753
                $this->page->add_body_class('role-' . $role->shortname);
1775
                $this->page->add_body_class('role-' . $role->shortname);
1754
            }
1776
            }
1755
        } else {
1777
        } else {
Línea -... Línea 1778...
-
 
1778
            $this->page->add_body_class('role-none');
1756
            $this->page->add_body_class('role-none');
1779
        }
1757
        }
1780
 
1758
 
1781
        // Verificar configuración de edición
1759
        if ($theme->settings->topbareditmode == '1') {
1782
        if (!empty($theme->settings->topbareditmode) && $theme->settings->topbareditmode == '1') {
1760
            $this->page->add_body_class('rui-editmode--top');
1783
            $this->page->add_body_class('rui-editmode--top');
Línea 1761... Línea 1784...
1761
        } else {
1784
        } else {
1762
            $this->page->add_body_class('rui-editmode--footer');
1785
            $this->page->add_body_class('rui-editmode--footer');
Línea -... Línea 1786...
-
 
1786
        }
1763
        }
1787
 
1764
 
1788
        return parent::header();
1765
        return parent::header();
1789
    }
1766
    }
1790
 
1767
 
1791
 
Línea 1830... Línea 1854...
1830
        }
1854
        }
Línea 1831... Línea 1855...
1831
 
1855
 
1832
        return $html;
1856
        return $html;
Línea -... Línea 1857...
-
 
1857
    }
-
 
1858
 
-
 
1859
    public function render_statics_blocks($userid = null)
-
 
1860
    {
-
 
1861
        global $USER;
-
 
1862
 
-
 
1863
        if (!$userid) {
-
 
1864
            $userid = $USER->id;
-
 
1865
        }
-
 
1866
 
-
 
1867
        // Instanciamos StaticsBlocks para renderizar los bloques
-
 
1868
        $statics_blocks = new \StaticsBlocks(
-
 
1869
            'side-pre',
-
 
1870
            ['messageteacher', 'comments', 'cesa_course_rating', 'cesa_notes']
-
 
1871
        );
-
 
1872
 
-
 
1873
        $blocks = $statics_blocks->renderBlocks();
-
 
1874
 
-
 
1875
        return $blocks;
Línea 1833... Línea 1876...
1833
    }
1876
    }
1834
 
1877
 
1835
 
1878
 
1836
    /**
1879
    /**
Línea 2156... Línea 2199...
2156
                return $html;
2199
                return $html;
2157
            }
2200
            }
2158
        }
2201
        }
2159
    }
2202
    }
Línea -... Línea 2203...
-
 
2203
 
-
 
2204
 
-
 
2205
    public function cesa_navigation_course_completion()
-
 
2206
    {
-
 
2207
        global $COURSE, $PAGE, $USER, $CFG;
-
 
2208
 
-
 
2209
        if (empty($PAGE->cm->id) || empty($COURSE->enablecompletion)) {
-
 
2210
            return '';
-
 
2211
        }
-
 
2212
 
-
 
2213
        $course_context = context_course::instance($COURSE->id);
-
 
2214
        $roles = get_user_roles($course_context, $USER->id, true);
-
 
2215
 
-
 
2216
        $completion_visible = true;
-
 
2217
        foreach ($roles as $role) {
-
 
2218
            if ($role->shortname != 'student') {
-
 
2219
                $completion_visible  = false;
-
 
2220
            }
-
 
2221
        }
-
 
2222
 
-
 
2223
        if (!$completion_visible) {
-
 
2224
            return '';
-
 
2225
        }
-
 
2226
        $PAGE->requires->js(new \moodle_url($CFG->wwwroot . '/local/cesanavigation/javascript/terminacion.js'));
-
 
2227
 
-
 
2228
        $page_context = $PAGE->cm;
-
 
2229
 
-
 
2230
        $modules = get_fast_modinfo($COURSE->id)->get_cms();
-
 
2231
 
-
 
2232
        $mods = [];
-
 
2233
        foreach ($modules as $module) {
-
 
2234
            if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
-
 
2235
                continue;
-
 
2236
            }
-
 
2237
            $mods[$module->id] = $module;
-
 
2238
        }
-
 
2239
 
-
 
2240
 
-
 
2241
 
-
 
2242
        $nummods = count($mods);
-
 
2243
 
-
 
2244
        // If there is only one mod then do nothing.
-
 
2245
        if ($nummods == 1) {
-
 
2246
            return '';
-
 
2247
        }
-
 
2248
 
-
 
2249
        $modids = array_keys($mods);
-
 
2250
        $position = array_search($page_context->id, $modids);   //array_search($this->page->cm->id, $modids);
-
 
2251
 
-
 
2252
        $currentmod = $mods[$modids[$position]];
-
 
2253
 
-
 
2254
        /*if(!$currentmod->completion) {
-
 
2255
            return '';
-
 
2256
        }*/
-
 
2257
 
-
 
2258
        $completioninfo = new \completion_info($COURSE);
-
 
2259
        $completiondata = $completioninfo->get_data($currentmod, true);
-
 
2260
        if ($completiondata->completionstate != COMPLETION_COMPLETE && $completiondata->completionstate != COMPLETION_COMPLETE_PASS) {
-
 
2261
            $url = new \moodle_url($CFG->wwwroot . '/local/cesanavigation/terminacion.php', ['courseid' => $COURSE->id, 'modid' =>  $currentmod->id]);
-
 
2262
 
-
 
2263
 
-
 
2264
            return '<div class="containerr">
-
 
2265
                        <input type="button" class="btn btn-primary d-block mx-auto btn-cesa-course-completion button-cesa vertical-center center" data-url="' . $url . '" value="Completar y continuar">
-
 
2266
                    </div>';
-
 
2267
        }
-
 
2268
 
-
 
2269
        return '';
-
 
2270
    }
2160
 
2271
 
2161
    public function moremenu_custom_items()
2272
    public function moremenu_custom_items()
2162
    {
2273
    {
Línea 2163... Línea 2274...
2163
        global $CFG, $COURSE, $USER;
2274
        global $CFG, $COURSE, $USER;
Línea 2207... Línea 2318...
2207
            }
2318
            }
2208
        }
2319
        }
2209
        return $html;
2320
        return $html;
2210
    }
2321
    }
Línea 2211... Línea 2322...
2211
 
2322
 
2212
    public function render_statics_blocks($userid = null)
2323
    public function get_navbar_image_courses()
2213
    {
2324
    {
Línea -... Línea 2325...
-
 
2325
        global $CFG;
-
 
2326
 
2214
        global $USER;
2327
        if (!empty($this->page->theme->settings->navbar_icon_courses)) {
-
 
2328
            $url = $this->page->theme->setting_file_url('navbar_icon_courses', 'navbar_icon_courses');
-
 
2329
            // Get a URL suitable for moodle_url.
2215
 
2330
            $relativebaseurl = preg_replace('|^https?://|i', '//', $CFG->wwwroot);
2216
        if (!$userid) {
2331
            $url = str_replace($relativebaseurl, '', $url);
Línea 2217... Línea -...
2217
            $userid = $USER->id;
-
 
2218
        }
-
 
2219
 
-
 
2220
        // Instanciamos StaticsBlocks para renderizar los bloques
-
 
2221
        $statics_blocks = new \StaticsBlocks(
-
 
Línea 2222... Línea 2332...
2222
            'side-pre',
2332
            return new moodle_url($url);
-
 
2333
        }
Línea -... Línea 2334...
-
 
2334
 
-
 
2335
 
-
 
2336
        return $CFG->wwwroot . '/theme/universe_child/pix/icon-catalog-white.png';
-
 
2337
    }
-
 
2338
 
-
 
2339
    public function get_navbar_image_progress()
-
 
2340
    {
-
 
2341
        global $CFG;
-
 
2342
 
-
 
2343
        if (!empty($this->page->theme->settings->navbar_icon_progress)) {
-
 
2344
            $url = $this->page->theme->setting_file_url('navbar_icon_progress', 'navbar_icon_progress');
-
 
2345
            // Get a URL suitable for moodle_url.
-
 
2346
            $relativebaseurl = preg_replace('|^https?://|i', '//', $CFG->wwwroot);
-
 
2347
            $url = str_replace($relativebaseurl, '', $url);
-
 
2348
            return new moodle_url($url);
-
 
2349
        }
-
 
2350
 
-
 
2351
 
-
 
2352
 
-
 
2353
        return $CFG->wwwroot . '/theme/universe_child/pix/icon-progress-white.png';
-
 
2354
    }
-
 
2355
 
-
 
2356
    public function get_navbar_image_forums()
-
 
2357
    {
-
 
2358
        global $CFG;
-
 
2359
 
-
 
2360
 
-
 
2361
        if (!empty($this->page->theme->settings->navbar_icon_forums)) {
-
 
2362
            $url = $this->page->theme->setting_file_url('navbar_icon_forums', 'navbar_icon_forums');
-
 
2363
            // Get a URL suitable for moodle_url.
-
 
2364
            $relativebaseurl = preg_replace('|^https?://|i', '//', $CFG->wwwroot);
-
 
2365
            $url = str_replace($relativebaseurl, '', $url);
-
 
2366
            return new moodle_url($url);
-
 
2367
        }
-
 
2368
 
-
 
2369
        return $CFG->wwwroot . '/theme/universe_child/pix/icon-forum-white.png';
-
 
2370
    }
-
 
2371
 
-
 
2372
    public function get_navbar_image_calendar()
-
 
2373
    {
-
 
2374
        global $CFG;
-
 
2375
 
-
 
2376
 
-
 
2377
        if (!empty($this->page->theme->settings->navbar_icon_calendar)) {
-
 
2378
            $url = $this->page->theme->setting_file_url('navbar_icon_calendar', 'navbar_icon_calendar');
-
 
2379
            // Get a URL suitable for moodle_url.
-
 
2380
            $relativebaseurl = preg_replace('|^https?://|i', '//', $CFG->wwwroot);
-
 
2381
            $url = str_replace($relativebaseurl, '', $url);
-
 
2382
            return new moodle_url($url);
-
 
2383
        }
-
 
2384
 
-
 
2385
        return $CFG->wwwroot . '/theme/universe_child/pix/icon-calendar-white.png';
-
 
2386
    }
-
 
2387
 
-
 
2388
    public function get_theme_image_login_bg()
-
 
2389
    {
-
 
2390
        global  $DB, $CFG;
-
 
2391
 
-
 
2392
        if (!empty($this->page->theme->settings->loginimagebackground)) {
-
 
2393
            $url = $this->page->theme->setting_file_url('loginimagebackground', 'loginimagebackground');
-
 
2394
            $relativebaseurl = preg_replace('|^https?://|i', '//', $CFG->wwwroot);
-
 
2395
            $url = str_replace($relativebaseurl, '', $url);
-
 
2396
            return new moodle_url($url);
-
 
2397
        }
-
 
2398
 
-
 
2399
        return '';
-
 
2400
    }
-
 
2401
 
-
 
2402
    public function get_navbar_image_personal_area()
-
 
2403
    {
-
 
2404
        global $CFG;
-
 
2405
 
-
 
2406
 
-
 
2407
        if (!empty($this->page->theme->settings->navbar_icon_calendar)) {
-
 
2408
            $url = $this->page->theme->setting_file_url('navbar_icon_personal_area', 'navbar_icon_personal_area');
-
 
2409
            // Get a URL suitable for moodle_url.
-
 
2410
            $relativebaseurl = preg_replace('|^https?://|i', '//', $CFG->wwwroot);
-
 
2411
            $url = str_replace($relativebaseurl, '', $url);
-
 
2412
            return new moodle_url($url);
-
 
2413
        }
-
 
2414
 
-
 
2415
        return $CFG->wwwroot . '/theme/universe_child/pix/icon-personal-area-white.png';
-
 
2416
    }
-
 
2417
 
-
 
2418
    public function get_navbar_image_messages()
-
 
2419
    {
-
 
2420
        global $CFG;
-
 
2421
 
-
 
2422
 
-
 
2423
        if (!empty($this->page->theme->settings->navbar_icon_calendar)) {
-
 
2424
            $url = $this->page->theme->setting_file_url('navbar_icon_messages', 'navbar_icon_messages');
-
 
2425
            // Get a URL suitable for moodle_url.
-
 
2426
            $relativebaseurl = preg_replace('|^https?://|i', '//', $CFG->wwwroot);
-
 
2427
            $url = str_replace($relativebaseurl, '', $url);
-
 
2428
            return new moodle_url($url);
-
 
2429
        }
-
 
2430
 
-
 
2431
        return $CFG->wwwroot . '/theme/universe_child/pix/icon-messages-white.png';
-
 
2432
    }
-
 
2433
 
-
 
2434
    private function extractDurationFromVideo($record, $filename)
-
 
2435
    {
-
 
2436
        global $DB;
-
 
2437
 
-
 
2438
        $duration = 0;
-
 
2439
 
-
 
2440
        if (empty($record->duration)) {
-
 
2441
            $fs = get_file_storage();
-
 
2442
            $file = $fs->get_file($record->contextid, $record->component, $record->filearea, $record->itemid, $record->filepath, $record->filename);
-
 
2443
            if ($file) {
-
 
2444
 
-
 
2445
                $data = $file->get_content();
-
 
2446
 
-
 
2447
                $path_temp = __DIR__ . DIRECTORY_SEPARATOR . 'tmp';
-
 
2448
                if (!file_exists($path_temp)) {
-
 
2449
                    mkdir($path_temp, 0755);
-
 
2450
                }
-
 
2451
 
-
 
2452
                $full_filename = $path_temp . DIRECTORY_SEPARATOR . uniqid() . '_' . $filename;
-
 
2453
                file_put_contents($full_filename, $data);
-
 
2454
 
-
 
2455
                if (file_exists($full_filename)) {
-
 
2456
                    $cmd = "/usr/bin/ffprobe -i $full_filename -show_entries format=duration -v quiet -of csv=\"p=0\" ";
-
 
2457
                    $response = trim(shell_exec($cmd));
-
 
2458
                    @unlink($full_filename);
-
 
2459
 
-
 
2460
 
-
 
2461
                    $duration = $response;
-
 
2462
 
-
 
2463
 
-
 
2464
                    if ($response) {
-
 
2465
                        $response = floatval($response);
-
 
2466
 
-
 
2467
                        if ($response > 60) {
-
 
2468
 
-
 
2469
                            //echo 'response = ' . $response . '<br>';
-
 
2470
 
-
 
2471
                            $minutes = intval($response / 60);
-
 
2472
                            //echo 'minutes = ' . $minutes . '<br>';
-
 
2473
 
-
 
2474
                            $seconds = round(($response - ($minutes * 60)));
-
 
2475
                            //echo 'seconds = ' . $seconds . '<br>';
-
 
2476
 
-
 
2477
 
-
 
2478
                            if ($minutes < 10) {
-
 
2479
                                $duration = '0' . $minutes;
-
 
2480
                            } else {
-
 
2481
                                $duration = $minutes;
-
 
2482
                            }
-
 
2483
 
-
 
2484
                            if ($seconds) {
-
 
2485
                                if ($seconds < 10) {
-
 
2486
                                    $duration = $duration . ':0' . $seconds;
-
 
2487
                                } else {
-
 
2488
                                    $duration = $duration . ':' . $seconds;
-
 
2489
                                }
-
 
2490
                            } else {
-
 
2491
                                $duration = $duration . ':00';
-
 
2492
                            }
-
 
2493
                        } else {
-
 
2494
                            $duration = '00:' . intval($response);
-
 
2495
                        }
-
 
2496
 
-
 
2497
 
-
 
2498
 
-
 
2499
                        $dataobject = new \stdClass();
-
 
2500
                        $dataobject->id = $record->id;
-
 
2501
                        $dataobject->duration = $duration;
-
 
2502
 
-
 
2503
 
-
 
2504
 
-
 
2505
                        $DB->update_record('files', $dataobject);
-
 
2506
                    }
-
 
2507
                }
-
 
2508
            }
-
 
2509
        }
-
 
2510
        return $duration;
-
 
2511
    }
-
 
2512
 
-
 
2513
    private function substr_cesa_navigation_course_menu_name($s, $l = 50)
2223
            ['messageteacher', 'comments', 'cesa_course_rating', 'cesa_notes']
2514
    {
-
 
2515
        $s = trim($s);
-
 
2516
        if (strlen($s) > $l) {
-
 
2517
            $s = substr($s, 0, $l) . '...';
-
 
2518
        }
-
 
2519
        return $s;
-
 
2520
    }
-
 
2521
 
-
 
2522
    public function cesa_navigation_course_menu_lateral_output()
-
 
2523
    {
-
 
2524
 
-
 
2525
 
-
 
2526
 
-
 
2527
        global $CFG, $COURSE, $PAGE, $DB, $OUTPUT;
-
 
2528
 
-
 
2529
 
-
 
2530
 
-
 
2531
 
-
 
2532
        if (!$COURSE->id) {
-
 
2533
            return '';
-
 
2534
        }
-
 
2535
 
-
 
2536
        $course_id = $COURSE->id;
-
 
2537
 
-
 
2538
        $parent = optional_param('parent', 0, PARAM_INT); // Course module id
-
 
2539
        if (!$parent) {
-
 
2540
            $parent = optional_param('amp;parent', 0, PARAM_INT); // Course module id
-
 
2541
        }
-
 
2542
 
-
 
2543
        //$PAGE->requires->js('/theme/edumynew/javascript/menu-lateral.js');
-
 
2544
 
-
 
2545
 
-
 
2546
        if ($parent) {
-
 
2547
            $sql  = ' SELECT * FROM {subcourse} WHERE course = ' . $parent;
-
 
2548
            $sql .= ' AND refcourse = ' . $course_id;
-
 
2549
 
-
 
2550
            $recordParentRefCourse  = $DB->get_record_sql($sql);
-
 
2551
            if ($recordParentRefCourse) {
-
 
2552
                $course_id = $recordParentRefCourse->course;
-
 
2553
            }
-
 
2554
        }
-
 
2555
 
-
 
2556
 
-
 
2557
 
-
 
2558
        $course = get_course($course_id);
-
 
2559
        $course_context = context_course::instance($course->id);
-
 
2560
        $completioninfo = new \completion_info($course);
-
 
2561
 
-
 
2562
        // $course_context = !empty($PAGE->cm->id)  ? $PAGE->cm : \context_course::instance($COURSE->id);
-
 
2563
        // First we should check if we want to add navigation.
-
 
2564
        // Get a list of all the activities in the course.
-
 
2565
 
-
 
2566
 
-
 
2567
 
-
 
2568
        $menu = [];
-
 
2569
 
-
 
2570
        $currentServerLink = strtolower(trim($_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']));
-
 
2571
        $currentServerLink = html_entity_decode($currentServerLink);
-
 
2572
        $currentServerLink = htmlentities($currentServerLink);
-
 
2573
 
-
 
2574
        $parts = explode('&', $currentServerLink);
-
 
2575
        if (count($parts) > 1) {
-
 
2576
            $currentServerLink = $parts[0];
-
 
2577
        }
-
 
2578
 
-
 
2579
 
-
 
2580
 
-
 
2581
 
-
 
2582
        $modules = get_fast_modinfo($course->id)->get_cms();
-
 
2583
 
-
 
2584
        $prevmod = null;
-
 
2585
        $nextmod = null;
-
 
2586
        $currentmod = new stdClass();
-
 
2587
        $currentmod->name = "Sin Módulos";
-
 
2588
        $mods = [];
-
 
2589
        $menu = [];
-
 
2590
        $numberOfTemary = 1;
-
 
2591
        $prevlink = new \StdClass();
-
 
2592
        $nextlink = new \StdClass();
-
 
2593
        $prevlink->url = "#";
-
 
2594
        $nextlink->url = "#";
-
 
2595
 
-
 
2596
        $isACoursePage = $course->id !== "1" ? true : false;
-
 
2597
 
-
 
2598
 
-
 
2599
 
-
 
2600
 
-
 
2601
        $modules = get_fast_modinfo($COURSE->id)->get_cms();
-
 
2602
        /*
-
 
2603
            echo '<pre>';
-
 
2604
            print_r($modules);
-
 
2605
            echo '</pre>';
-
 
2606
            */
-
 
2607
 
-
 
2608
        if (!empty($modules)) {
-
 
2609
            // Put the modules into an array in order by the position they are shown in the course.
-
 
2610
            foreach ($modules as $module) {
-
 
2611
                if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
-
 
2612
                    continue;
-
 
2613
                }
-
 
2614
                $mods[$module->id] = $module;
-
 
2615
            }
-
 
2616
 
-
 
2617
 
-
 
2618
            $nummods = count($mods);
-
 
2619
 
-
 
2620
 
-
 
2621
            // If there is only one mod then do nothing.
-
 
2622
            if ($nummods == 1) {
-
 
2623
            }
-
 
2624
 
-
 
2625
            // Get an array of just the course module ids used to get the cmid value based on their position in the course.
-
 
2626
            $modids = array_keys($mods);
-
 
2627
 
-
 
2628
            // Get the position in the array of the course module we are viewing.
-
 
2629
            $position = array_search($course_context->id, $modids);   //array_search($this->page->cm->id, $modids);
-
 
2630
 
-
 
2631
            $currentmod = $mods[$modids[$position]];
-
 
2632
 
-
 
2633
 
-
 
2634
 
-
 
2635
            // Check if we have a previous mod to show.
-
 
2636
            if ($position > 0) {
-
 
2637
                $prevmod = $mods[$modids[$position - 1]];
-
 
2638
            }
-
 
2639
 
-
 
2640
            // Check if we have a next mod to show.
-
 
2641
            if ($position < ($nummods - 1)) {
-
 
2642
                $nextmod = $mods[$modids[$position + 1]];
-
 
2643
            }
-
 
2644
        }
-
 
2645
 
-
 
2646
 
-
 
2647
        //$sections = $DB->get_records('course_sections', ['course' => $COURSE->id], 'section ASC', 'id,name,section,sequence,visible');
-
 
2648
 
-
 
2649
 
-
 
2650
 
-
 
2651
 
-
 
2652
        $modinfo = get_fast_modinfo($course);
-
 
2653
        $records  =  $modinfo->get_section_info_all();
-
 
2654
        $sections = [];
-
 
2655
 
-
 
2656
        foreach ($records as $record) {
-
 
2657
            if (!$record->visible) {
-
 
2658
                continue;
-
 
2659
            }
-
 
2660
 
-
 
2661
            $section = new \stdClass();
-
 
2662
            $section->id = $record->id;
-
 
2663
            $section->section = $record->section;
-
 
2664
            $section->name = $record->name;
-
 
2665
            $section->parent = $record->parent;
-
 
2666
            $section->visible = 1;
-
 
2667
 
-
 
2668
 
-
 
2669
            array_push($sections, $section);
-
 
2670
        }
-
 
2671
 
-
 
2672
 
-
 
2673
 
-
 
2674
        $openParent = 0;
-
 
2675
        $maxSections = count($sections);
-
 
2676
        for ($i = 0; $i < $maxSections; $i++) {
-
 
2677
 
-
 
2678
 
-
 
2679
 
-
 
2680
            $j = $i + 1;
-
 
2681
            if ($j < $maxSections) {
-
 
2682
 
-
 
2683
                if ($sections[$j]->parent) {
-
 
2684
                    $openParent = true;
-
 
2685
                    $sections[$i]->close_section_parent = 0;
-
 
2686
                    $sections[$i]->close_section = 0;
-
 
2687
                } else {
-
 
2688
                    $sections[$i]->close_section_parent = $openParent ? 1 : 0;
-
 
2689
 
-
 
2690
                    $sections[$i]->close_section = 1;
-
 
2691
                }
-
 
2692
            } else {
-
 
2693
                $sections[$i]->close_section_parent = $openParent ? 1 : 0;
-
 
2694
                $sections[$i]->close_section = 1;
-
 
2695
            }
-
 
2696
 
-
 
2697
            // print_r($section);
-
 
2698
 
-
 
2699
 
-
 
2700
        }
-
 
2701
 
-
 
2702
        /*
-
 
2703
             echo '<pre>';
-
 
2704
           print_r($sections);
-
 
2705
           echo '</pre>';
-
 
2706
      
-
 
2707
      */
-
 
2708
 
-
 
2709
 
-
 
2710
 
-
 
2711
 
-
 
2712
        foreach ($sections as $key =>  $section) {
-
 
2713
 
-
 
2714
            if (!$section->visible) {
-
 
2715
                continue;
-
 
2716
            }
-
 
2717
 
-
 
2718
            $activities = [];
-
 
2719
            $section_active = false;
-
 
2720
 
-
 
2721
            foreach ($modules as $module) {
-
 
2722
 
-
 
2723
                if ($module->section  != $section->id) {
-
 
2724
                    continue;
-
 
2725
                }
-
 
2726
 
-
 
2727
                if (!$module->uservisible || $module->is_stealth()) {
-
 
2728
                    // if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
-
 
2729
                    continue;
-
 
2730
                }
-
 
2731
 
-
 
2732
                $mods[$module->id] = $module;
-
 
2733
 
-
 
2734
                $duration = '';
-
 
2735
                $type = '';
-
 
2736
                $filepath = '';
-
 
2737
 
-
 
2738
                $sql = 'SELECT md.name, cm.instance  FROM {modules} md  ' .
-
 
2739
                    ' JOIN {course_modules} cm ON cm.module = md.id ' .
-
 
2740
                    ' WHERE cm.id = '  . $module->id . ' LIMIT 1 ';
-
 
2741
 
-
 
2742
                $record = $DB->get_record_sql($sql);
-
 
2743
                if ($record) {
-
 
2744
 
-
 
2745
                    /*
-
 
2746
                        echo '<pre>';
-
 
2747
                        print_r($record);
-
 
2748
                        echo '<pre>';
-
 
2749
                        */
-
 
2750
 
-
 
2751
                    $type = $record->name;
-
 
2752
 
-
 
2753
                    if ($type == 'hvp') {
-
 
2754
                        $instance   = $record->instance;
-
 
2755
 
-
 
2756
                        $sql = 'SELECT json_content FROM {hvp} WHERE id = ' . $instance . ' LIMIT 1';
-
 
2757
                        $record = $DB->get_record_sql($sql);
-
 
2758
 
-
 
2759
                        if ($record) {
-
 
2760
                            $json_content = json_decode($record->json_content);
-
 
2761
 
-
 
2762
                            if (!empty($json_content->interactiveVideo->video->files[0]->path)) {
-
 
2763
                                $filepath = trim($json_content->interactiveVideo->video->files[0]->path);
-
 
2764
                                $filepath = trim(str_replace('#tmp', '', $filepath));
-
 
2765
 
-
 
2766
 
-
 
2767
                                $arr = explode('/', $filepath);
-
 
2768
                                if (count($arr) > 1) {
-
 
2769
                                    $filename = $arr[count($arr) - 1];
-
 
2770
                                } else {
-
 
2771
                                    $filename = $arr[0];
-
 
2772
                                }
-
 
2773
 
-
 
2774
                                $record = $DB->get_record('files', ['filename' => $filename]);
-
 
2775
                                if ($record) {
-
 
2776
                                    $duration = $this->extractDurationFromVideo($record, $filename);
-
 
2777
                                }
-
 
2778
                            }
-
 
2779
                        }
-
 
2780
                    }
-
 
2781
                }
-
 
2782
 
-
 
2783
                $modname = $module->get_formatted_name();
-
 
2784
                $modcontent = $module->get_formatted_content();
-
 
2785
 
-
 
2786
                if (empty($module->url)) {
-
 
2787
                    $linkurl = '';
-
 
2788
                    $currentLink = '';
-
 
2789
                } else {
-
 
2790
 
-
 
2791
                    $linkurl = new moodle_url($module->url, array('forceview' => 1));
-
 
2792
                    $linkurl = strtolower(trim($linkurl->__toString()));
-
 
2793
 
-
 
2794
                    $parts = explode('&', $linkurl);
-
 
2795
                    if (count($parts) > 1) {
-
 
2796
                        $currentLink = $parts[0];
-
 
2797
                    } else {
-
 
2798
                        $currentLink = $linkurl;
-
 
2799
                    }
-
 
2800
                }
-
 
2801
 
-
 
2802
                $completiondata = $completioninfo->get_data($module, true);
-
 
2803
 
-
 
2804
                if (strcasecmp($currentLink,  $currentServerLink) == 0) {
-
 
2805
                    $active = true;
-
 
2806
                    $section_active = true;
-
 
2807
                } else {
-
 
2808
                    $active = false;
-
 
2809
                }
-
 
2810
 
-
 
2811
                array_push($activities, [
-
 
2812
                    'active' => $active,
-
 
2813
                    'indexElement' => $key,
-
 
2814
                    'numberOfTemary' => $numberOfTemary,
-
 
2815
                    'activity' => true,
-
 
2816
                    'blank' => !empty($section->section),
-
 
2817
                    'name' => $this->substr_cesa_navigation_course_menu_name($modname),
-
 
2818
                    'content' => $modcontent,
-
 
2819
                    'duration' => $duration,
-
 
2820
                    'type' =>  $type,
-
 
2821
                    'completed' => $completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS,
-
 
2822
                    'failed' => $completiondata->completionstate == COMPLETION_COMPLETE_FAIL,
-
 
2823
                    'url' => $linkurl
-
 
2824
                ]);
-
 
2825
            }
-
 
2826
 
-
 
2827
 
-
 
2828
            if ($activities) {
-
 
2829
 
-
 
2830
                if ($section->section) {
-
 
2831
                    $sectionname = trim($section->name);
-
 
2832
                    $sectionname = $sectionname ? $sectionname : ' Tema ' . $section->section;
-
 
2833
                } else {
-
 
2834
                    $sectionname = 'Recursos';
-
 
2835
                }
-
 
2836
 
-
 
2837
                array_push($menu, [
-
 
2838
                    'active' => $section_active,
-
 
2839
                    'indexElement' => $key,
-
 
2840
                    'id' => $section->id,
-
 
2841
                    'numberOfTemary' => $numberOfTemary,
-
 
2842
                    'section' => true,
-
 
2843
                    'name' => $this->substr_cesa_navigation_course_menu_name($sectionname),
-
 
2844
                    'close_section_parent' => $section->close_section_parent,
-
 
2845
                    'close_section' => $section->close_section,
-
 
2846
                    'completed' => false,
-
 
2847
                    'url' => false,
-
 
2848
                    'activities' => $activities,
-
 
2849
 
-
 
2850
 
-
 
2851
                ]);
-
 
2852
            }
-
 
2853
 
-
 
2854
 
-
 
2855
            $numberOfTemary = ++$numberOfTemary;
-
 
2856
        }
-
 
2857
 
-
 
2858
        // Check if there is a previous module to display.
-
 
2859
        if ($prevmod) {
-
 
2860
            $linkurl = new \moodle_url($prevmod->url, array('forceview' => 1));
-
 
2861
            $attributes = [];
-
 
2862
            $prevlink = new \action_link($linkurl, $OUTPUT->larrow(), null, $attributes);
-
 
2863
        }
-
 
2864
 
-
 
2865
        // Check if there is a next module to display.
-
 
2866
        if ($nextmod) {
-
 
2867
            $linkurl = new \moodle_url($nextmod->url, array('forceview' => 1));
-
 
2868
            $attributes = [];
-
 
2869
            $nextlink = new \action_link($linkurl, $OUTPUT->rarrow(), null, $attributes);
-
 
2870
        }
-
 
2871
 
-
 
2872
 
-
 
2873
        //  echo '<pre>'; 
-
 
2874
        // print_r($activities);
-
 
2875
        // echo '</pre>';
-
 
2876
        // exit;
-
 
2877
 
2224
        );
2878
 
Línea 2225... Línea 2879...
2225
 
2879
        $progreso = number_format(progress::get_course_progress_percentage($course), 2); // Progreso por curso
2226
        $blocks = $statics_blocks->renderBlocks();
2880
 
2227
 
2881
        $course_navigation = new \theme_universe_child\output\custom_drawer($prevlink->url, $nextlink->url, $menu, $this->substr_cesa_navigation_course_menu_name($currentmod->name, 10), false, $isACoursePage,  $COURSE->summary, $progreso);
Línea 2253... Línea 2907...
2253
            return $this->render_from_template('theme_universe_child/courseindex/drawer', []);
2907
            return $this->render_from_template('theme_universe_child/courseindex/drawer', []);
2254
        }
2908
        }
Línea 2255... Línea 2909...
2255
 
2909
 
2256
        return '';
2910
        return '';
-
 
2911
    }
-
 
2912
 
-
 
2913
    /*
-
 
2914
    *
-
 
2915
    * Method to get reference to $CFG->themedir variable
-
 
2916
    *
-
 
2917
    */
-
 
2918
    function theme_universe_themedir()
-
 
2919
    {
-
 
2920
        global $CFG;
-
 
2921
 
-
 
2922
        $teme_dir = '/theme';
-
 
2923
 
-
 
2924
        if (isset($CFG->themedir)) {
-
 
2925
            $teme_dir = $CFG->themedir;
-
 
2926
            $teme_dir = str_replace($CFG->dirroot, '', $CFG->themedir);
-
 
2927
        }
-
 
2928
 
-
 
2929
        return $teme_dir;
2257
    }
2930
    }