diff --git a/block_career.php b/block_career.php index 78d077261f00f2094fabf7f5d1fd1aee80bb879e..e941b1a3f9124f860c448570aa6ad3433ab31fb4 100644 --- a/block_career.php +++ b/block_career.php @@ -51,6 +51,15 @@ class block_career extends block_base { return true; } + function get_all_path_list($course_id){ + global $DB; + $list=array(); + $request = $DB->get_records_sql('SELECT * FROM {block_career} WHERE course = ?', array($course_id)); + foreach($request as $value){ + array_push($list,$value); + } + return $list; + } function get_path_list($course_id, $user_id){ global $DB; @@ -93,8 +102,15 @@ class block_career extends block_base $this->content->text .= '<div class="list-group career-list-group font-weight-light">'; $this->content->text .= '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $COURSE->id . '" class="list-group-item list-group-item-success list-group-item-action" style="border-top-left-radius: .15rem; border-top-right-radius: .15rem; border-top: none;">Accueil du cours</a>'; - $list=$this->get_path_list($COURSE->id,$USER->id); + $context = context_course::instance($COURSE->id); + + if (has_capability('moodle/course:update', $context)){ + $list=$this->get_all_path_list($COURSE->id); + } + else{ + $list=$this->get_path_list($COURSE->id,$USER->id); + } foreach ($list as $value) { // if (file_get_contents("$CFG->wwwroot/blocks/career/$value->image") != null) {