Proyectos de Subversion Moodle

Rev

Rev 367 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 367 Rev 369
Línea 591... Línea 591...
591
        }
591
        }
592
        return $html;
592
        return $html;
593
    }
593
    }
Línea 594... Línea -...
594
 
-
 
595
 
-
 
596
    public function cesa_navigation_course_completion()
-
 
Línea 597... Línea -...
597
    {
-
 
598
        global $COURSE, $PAGE, $USER, $CFG;
-
 
599
 
-
 
600
        if (empty($PAGE->cm->id) || empty($COURSE->enablecompletion)) {
-
 
601
            return '';
-
 
602
        }
-
 
603
 
-
 
604
        $course_context = context_course::instance($COURSE->id);
-
 
605
        $roles = get_user_roles($course_context, $USER->id, true);
-
 
606
 
-
 
607
        $completion_visible = true;
-
 
608
        foreach ($roles as $role) {
-
 
609
            if ($role->shortname != 'student') {
-
 
610
                $completion_visible  = false;
-
 
611
            }
-
 
612
        }
-
 
613
 
-
 
614
        if (!$completion_visible) {
-
 
615
            return '';
-
 
616
        }
-
 
617
        $PAGE->requires->js(new \moodle_url($CFG->wwwroot . '/local/cesanavigation/javascript/terminacion.js'));
-
 
618
 
-
 
619
        $page_context = $PAGE->cm;
-
 
620
 
-
 
621
        $modules = get_fast_modinfo($COURSE->id)->get_cms();
-
 
622
 
-
 
623
        $mods = [];
-
 
624
        foreach ($modules as $module) {
-
 
625
            if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
-
 
626
                continue;
-
 
627
            }
-
 
628
            $mods[$module->id] = $module;
-
 
629
        }
-
 
630
 
-
 
631
 
-
 
632
 
-
 
633
        $nummods = count($mods);
-
 
634
 
-
 
635
        // If there is only one mod then do nothing.
-
 
636
        if ($nummods == 1) {
-
 
637
            return '';
-
 
638
        }
-
 
639
 
-
 
640
        $modids = array_keys($mods);
-
 
641
        $position = array_search($page_context->id, $modids);   //array_search($this->page->cm->id, $modids);
-
 
642
 
-
 
643
        $currentmod = $mods[$modids[$position]];
-
 
644
 
-
 
645
        /*if(!$currentmod->completion) {
-
 
646
            return '';
-
 
647
        }*/
-
 
648
 
-
 
649
        $completioninfo = new \completion_info($COURSE);
-
 
650
        $completiondata = $completioninfo->get_data($currentmod, true);
-
 
651
        if ($completiondata->completionstate != COMPLETION_COMPLETE && $completiondata->completionstate != COMPLETION_COMPLETE_PASS) {
-
 
652
            $url = new \moodle_url($CFG->wwwroot . '/local/cesanavigation/terminacion.php', ['courseid' => $COURSE->id, 'modid' =>  $currentmod->id]);
-
 
653
 
-
 
654
 
-
 
655
            return '<div class="containerr">
-
 
656
                        <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">
-
 
657
                    </div>';
-
 
658
        }
-
 
Línea 659... Línea 594...
659
 
594
 
660
        return '';
595
 
661
    }
596
 
662
 
597