1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Renderer. 19 * 20 * @package report_insights 21 * @copyright 2016 David Monllao {@link http://www.davidmonllao.com} 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 namespace report_insights\output; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 use plugin_renderer_base; 30 use templatable; 31 use renderable; 32 33 /** 34 * Renderer class. 35 * 36 * @package report_insights 37 * @copyright 2016 David Monllao {@link http://www.davidmonllao.com} 38 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 39 */ 40 class renderer extends plugin_renderer_base { 41 42 /** 43 * Renders the list of insights 44 * 45 * @param renderable $renderable 46 * @return string HTML 47 */ 48 protected function render_insights_list(renderable $renderable) { 49 $data = $renderable->export_for_template($this); 50 return parent::render_from_template('report_insights/insights_list', $data); 51 } 52 53 /** 54 * Renders an insight 55 * 56 * @param renderable $renderable 57 * @return string HTML 58 */ 59 protected function render_insight(renderable $renderable) { 60 $data = $renderable->export_for_template($this); 61 $renderable->get_model()->get_target()->add_bulk_actions_js(); 62 return parent::render_from_template('report_insights/insight_details', $data); 63 } 64 65 /** 66 * Model disabled info. 67 * 68 * @param \stdClass $insightinfo 69 * @return string HTML 70 */ 71 public function render_model_disabled($insightinfo) { 72 73 // We don't want to disclose the name of the model if it has not been enabled. 74 $this->page->set_title($insightinfo->contextname); 75 $this->page->set_heading($insightinfo->contextname); 76 77 $output = $this->output->header(); 78 $output .= $this->output->notification(get_string('disabledmodel', 'report_insights'), 79 \core\output\notification::NOTIFY_INFO); 80 $output .= $this->output->footer(); 81 82 return $output; 83 } 84 85 /** 86 * Model without insights info. 87 * 88 * @param \context $context 89 * @return string HTML 90 */ 91 public function render_no_insights(\context $context) { 92 93 // We don't want to disclose the name of the model if it has not been enabled. 94 $this->page->set_title($context->get_context_name()); 95 $this->page->set_heading($context->get_context_name()); 96 97 $output = $this->output->header(); 98 $output .= $this->output->notification(get_string('noinsights', 'analytics'), 99 \core\output\notification::NOTIFY_INFO); 100 $output .= $this->output->footer(); 101 102 return $output; 103 } 104 105 /** 106 * Model which target does not generate insights. 107 * 108 * @param \context $context 109 * @return string HTML 110 */ 111 public function render_no_insights_model(\context $context) { 112 113 // We don't want to disclose the name of the model if it has not been enabled. 114 $this->page->set_title($context->get_context_name()); 115 $this->page->set_heading($context->get_context_name()); 116 117 $output = $this->output->header(); 118 $output .= $this->output->notification(get_string('noinsightsmodel', 'analytics'), 119 \core\output\notification::NOTIFY_INFO); 120 $output .= $this->output->footer(); 121 122 return $output; 123 } 124 125 /** 126 * Renders an analytics disabled notification. 127 * 128 * @return string HTML 129 */ 130 public function render_analytics_disabled() { 131 global $FULLME; 132 133 $this->page->set_url($FULLME); 134 $this->page->set_title(get_string('pluginname', 'report_insights')); 135 $this->page->set_heading(get_string('pluginname', 'report_insights')); 136 137 $output = $this->output->header(); 138 $output .= $this->output->notification(get_string('analyticsdisabled', 'analytics'), 139 \core\output\notification::NOTIFY_INFO); 140 $output .= \html_writer::tag('a', get_string('continue'), ['class' => 'btn btn-primary', 141 'href' => (new \moodle_url('/'))->out()]); 142 $output .= $this->output->footer(); 143 144 return $output; 145 } 146 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body