From af904bd75b26eae540ae2fccb4202182b74d26f8 Mon Sep 17 00:00:00 2001 From: Henning Bostelmann Date: Mon, 24 Mar 2014 15:39:25 +0000 Subject: [PATCH] MDL-44629 Assignment: add facility for displaying plugin-specific headers --- mod/assign/assignmentplugin.php | 10 ++++++++++ mod/assign/locallib.php | 8 ++++++++ mod/assign/renderable.php | 20 ++++++++++++++++++++ mod/assign/renderer.php | 11 +++++++++++ 4 files changed, 49 insertions(+) diff --git a/mod/assign/assignmentplugin.php b/mod/assign/assignmentplugin.php index d128a26ecdf..69eb14e7e2a 100644 --- a/mod/assign/assignmentplugin.php +++ b/mod/assign/assignmentplugin.php @@ -628,6 +628,16 @@ abstract class assign_plugin { return ''; } + /** + * This allows a plugin to render an introductory section which is displayed + * right below the activity's "intro" section on the main assignment page. + * + * @return string + */ + public function view_header() { + return ''; + } + /** * If this plugin should not include a column in the grading table or a row on the summary page * then return false diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 65c4d4777a2..344d965b595 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -3972,6 +3972,14 @@ class assign { $this->show_intro(), $this->get_course_module()->id)); + // Display plugin specific headers. + $plugins = array_merge($this->get_submission_plugins(), $this->get_feedback_plugins()); + foreach ($plugins as $plugin) { + if ($plugin->is_enabled() && $plugin->is_visible()) { + $o .= $this->get_renderer()->render(new assign_plugin_header($plugin)); + } + } + if ($this->can_view_grades()) { $draft = ASSIGN_SUBMISSION_STATUS_DRAFT; $submitted = ASSIGN_SUBMISSION_STATUS_SUBMITTED; diff --git a/mod/assign/renderable.php b/mod/assign/renderable.php index 72d5b96084f..c4e2598a768 100644 --- a/mod/assign/renderable.php +++ b/mod/assign/renderable.php @@ -579,6 +579,26 @@ class assign_header implements renderable { } } +/** + * Renderable header related to an individual subplugin + * @package mod_assign + * @copyright 2014 Henning Bostelmann + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class assign_plugin_header implements renderable { + /** @var assign_plugin $plugin */ + public $plugin = null; + + /** + * Header for a single plugin + * + * @param assign_plugin $plugin + */ + public function __construct(assign_plugin $plugin) { + $this->plugin = $plugin; + } +} + /** * Renderable grading summary * @package mod_assign diff --git a/mod/assign/renderer.php b/mod/assign/renderer.php index 8633c819fed..593494ec0c5 100644 --- a/mod/assign/renderer.php +++ b/mod/assign/renderer.php @@ -239,6 +239,17 @@ class mod_assign_renderer extends plugin_renderer_base { return $o; } + /** + * Render the header for an individual plugin. + * + * @param assign_plugin_header $header + * @return string + */ + public function render_assign_plugin_header(assign_plugin_header $header) { + $o = $header->plugin->view_header(); + return $o; + } + /** * Render a table containing the current status of the grading process. *