MDL-66722 forum: Add the grading component information
authorAndrew Nicols <andrew@nicols.co.uk>
Thu, 26 Sep 2019 04:12:53 +0000 (12:12 +0800)
committerMathew May <mathewm@hotmail.co.nz>
Wed, 30 Oct 2019 02:23:40 +0000 (10:23 +0800)
Part of MDL-66074

mod/forum/classes/local/factories/renderer.php
mod/forum/classes/local/renderers/discussion_list.php
mod/forum/templates/discussion_list.mustache

index 1f44bc6..d341a70 100644 (file)
@@ -26,6 +26,7 @@ namespace mod_forum\local\factories;
 
 defined('MOODLE_INTERNAL') || die();
 
+use mod_forum\grades\forum_gradeitem;
 use mod_forum\local\entities\discussion as discussion_entity;
 use mod_forum\local\entities\forum as forum_entity;
 use mod_forum\local\factories\vault as vault_factory;
@@ -455,6 +456,7 @@ class renderer {
             $this->builderfactory,
             $capabilitymanager,
             $this->urlfactory,
+            forum_gradeitem::load_from_forum_entity($forum),
             $template,
             $notifications,
             function($discussions, $user, $forum) {
@@ -494,6 +496,7 @@ class renderer {
             $this->builderfactory,
             $capabilitymanager,
             $this->urlfactory,
+            forum_gradeitem::load_from_forum_entity($forum),
             $template,
             $notifications,
             function($discussions, $user, $forum) use ($capabilitymanager) {
index ae01085..3fd846b 100644 (file)
@@ -26,6 +26,7 @@ namespace mod_forum\local\renderers;
 
 defined('MOODLE_INTERNAL') || die();
 
+use mod_forum\grades\forum_gradeitem;
 use mod_forum\local\entities\forum as forum_entity;
 use mod_forum\local\factories\legacy_data_mapper as legacy_data_mapper_factory;
 use mod_forum\local\factories\exporter as exporter_factory;
@@ -84,6 +85,9 @@ class discussion_list {
     /** @var string $template The template to use when displaying */
     private $template;
 
+    /** @var gradeitem The gradeitem instance associated with this forum */
+    private $forumgradeitem;
+
     /**
      * Constructor for a new discussion list renderer.
      *
@@ -108,6 +112,7 @@ class discussion_list {
         builder_factory $builderfactory,
         capability_manager $capabilitymanager,
         url_factory $urlfactory,
+        forum_gradeitem $forumgradeitem,
         string $template,
         array $notifications = [],
         callable $postprocessfortemplate = null
@@ -124,6 +129,7 @@ class discussion_list {
         $this->notifications = $notifications;
         $this->postprocessfortemplate = $postprocessfortemplate;
         $this->template = $template;
+        $this->forumgradeitem = $forumgradeitem;
 
         $forumdatamapper = $this->legacydatamapperfactory->get_forum_data_mapper();
         $this->forumrecord = $forumdatamapper->to_legacy_object($forum);
@@ -168,7 +174,10 @@ class discussion_list {
 
         $forumview = [
             'forum' => (array) $forumexporter->export($this->renderer),
+            'contextid' => $forum->get_context()->id,
             'cmid' => $cm->id,
+            'gradingcomponent' => $this->forumgradeitem->get_grading_component_name(),
+            'gradingcomponentsubtype' => $this->forumgradeitem->get_grading_component_subtype(),
             'hasanyactions' => $hasanyactions,
             'groupchangemenu' => groups_print_activity_menu(
                 $cm,
index e0298f2..5697117 100644 (file)
     }
 }}
 <div id="discussion-list-{{uniqid}}" {{!
+    }}data-contextid="{{contextid}}" {{!
     }}data-cmid="{{cmid}}" {{!
     }}data-group="{{forum.groupid}}" {{!
+    }}data-grading-component="{{gradingcomponent}}" {{!
+    }}data-grading-component-subtype="{{gradingcomponentsubtype}}" {{!
     }}data-gradable-itemtype="forum" {{!
     }}{{#firstgradeduserid}}data-initialuserid="{{firstgradeduserid}}" {{/firstgradeduserid}}{{!
     }}>