From c4102d468a5148c9f78f3fc1a2adc90bff4242fb Mon Sep 17 00:00:00 2001 From: Lea <lea.marais57@gmail.com> Date: Tue, 6 Jul 2021 10:58:35 +0200 Subject: [PATCH] add function gat_all_path_list --- block_career.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/block_career.php b/block_career.php index 78d0772..e941b1a 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) { -- GitLab