From d59094539e4a057b4ce68e7c46b950af35499fac Mon Sep 17 00:00:00 2001 From: Thomas Fradet <t.fradet8@gmail.com> Date: Mon, 27 May 2019 13:13:50 +0200 Subject: [PATCH] minor improvement --- CHANGELOG.md | 31 ++++++++++++++++++++++++++++++- block_career.php | 2 +- entity/block_career_ressource.php | 2 +- entity/block_career_section.php | 2 +- view/view_career_setting.php | 23 ++++++++++++----------- 5 files changed, 45 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c7eedd..843b925 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,32 @@ -# 19/02/19 +# 27/05/2019 + +## Bugs divers + +### Vue du block + +#### 1 + +[x] Notice PHP propriété non définie pour la génération de l'interface du block. + +#### 2 + +Notice: Undefined variable: content in /Applications/MAMP/htdocs/moodle37/blocks/career/view/view_career_setting.php on line 66 + +[x] Instantiation de $content avant une concaténation. + +### Vue settings + +#### 3 + +Deprecated: Non-static method block_career_section::get_sections_by_id_course() should not be called statically in /Applications/MAMP/htdocs/moodle37/blocks/career/view/view_career_setting.php on line 89 + +[x] La méthode est déclarée static + +#### 4 + +Deprecated: Non-static method block_career_ressource::get_ressources_by_id_section() should not be called statically in /Applications/MAMP/htdocs/moodle37/blocks/career/view/view_career_setting.php on line 95 + +[x] La méthode est déclarée static + diff --git a/block_career.php b/block_career.php index f839e5b..845f6c7 100644 --- a/block_career.php +++ b/block_career.php @@ -69,7 +69,7 @@ class block_career extends block_base $active = ""; $this->content = new stdClass; - $this->content->text .= '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $COURSE->id . '" class="btn btn-success btn-career-block mb-3">Accueil du cours</a>'; + $this->content->text = '<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $COURSE->id . '" class="btn btn-success btn-career-block mb-3">Accueil du cours</a>'; // $image = ""; diff --git a/entity/block_career_ressource.php b/entity/block_career_ressource.php index 3a20667..773a714 100644 --- a/entity/block_career_ressource.php +++ b/entity/block_career_ressource.php @@ -76,7 +76,7 @@ * * @return array<block_career_ressource> $ressources */ - public function get_ressources_by_id_section($id_section) + public static function get_ressources_by_id_section($id_section) { global $DB; $requete = $DB->get_records_sql('SELECT id FROM {course_modules} WHERE section = ? AND deletioninprogress = 0', array($id_section)); diff --git a/entity/block_career_section.php b/entity/block_career_section.php index a230abb..c0fc1b2 100644 --- a/entity/block_career_section.php +++ b/entity/block_career_section.php @@ -58,7 +58,7 @@ * * @return array<block_career_section> $sections */ - public function get_sections_by_id_course($id_course) + public static function get_sections_by_id_course($id_course) { global $DB; diff --git a/view/view_career_setting.php b/view/view_career_setting.php index 26d06de..796ff15 100644 --- a/view/view_career_setting.php +++ b/view/view_career_setting.php @@ -63,6 +63,7 @@ class view_career_setting extends moodleform // $content = "<h1>" . get_string('title_plugin', 'block_career') . "</h1>"; + $content = ""; $content .= "<div class='alert alert-info'>" . get_string('heading_plugin', 'block_career') . "</div>"; $temp = $mform->toHtml(); @@ -70,6 +71,9 @@ class view_career_setting extends moodleform $temp = substr($temp,(strpos($temp,'>')+1)); $temp = substr($temp,0, -7); + + $sections = block_career_section::get_sections_by_id_course($course); + $content .= '<div class="row"><form class="col-12" action="career_setting.php?course=' . $course . '" method="post" enctype="multipart/form-data">'; $content .= $temp; @@ -85,10 +89,6 @@ class view_career_setting extends moodleform <div class="subject-info-box-1"> <select multiple="multiple" id="lstBox1" class="form-control">'; - $sections = block_career_section::get_sections_by_id_course($course); - - // var_dump($sections); - foreach ($sections as $section) { $section->ressources = block_career_ressource::get_ressources_by_id_section($section->id); @@ -122,14 +122,15 @@ class view_career_setting extends moodleform <div class="subject-info-box-2"> <select multiple="multiple" id="lstBox2" name="ressource[]" class="form-control" required>'; + if ($ressourcesId != "") { + foreach ($ressourcesId as $value) + { + $res = new block_career_ressource(); + $res->get_ressource_by_id($value); - foreach ($ressourcesId as $value) - { - $res = new block_career_ressource(); - $res->get_ressource_by_id($value); - - if ($careerId != 0) - $content .= '<option label="'.$res->name.'" value ="'.$res->id.'">'; + if ($careerId != 0) + $content .= '<option label="'.$res->name.'" value ="'.$res->id.'">'; + } } -- GitLab