See Release Notes
Long Term Support Release
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 namespace mod_scorm\output; 18 19 use renderable; 20 use renderer_base; 21 use templatable; 22 use moodle_url; 23 use url_select; 24 25 /** 26 * Render HTML elements for reports page on tertiary nav. 27 * 28 * @package mod_scorm 29 * @copyright 2021 Sujith Haridasan <sujith@moodle.com> 30 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 31 */ 32 class userreportsactionbar implements renderable, templatable { 33 /** @var int */ 34 private $id; 35 36 /** @var int */ 37 private $userid; 38 39 /** @var int */ 40 private $attempt; 41 42 /** @var string */ 43 private $reporttype; 44 45 /** @var string */ 46 private $mode; 47 48 /** @var int */ 49 private $scoid; 50 51 /** 52 * userreportsactionbar constructor 53 * 54 * @param int $id Course module id. 55 * @param int $userid User id. 56 * @param int $attempt Number of attempts. 57 * @param string $reporttype The report type can be either learning/interact. 58 * @param string $mode The mode view to set the back button. 59 * @param int|null $scoid The scorm id. 60 */ 61 public function __construct(int $id, int $userid, int $attempt, string $reporttype, string $mode, ?int $scoid = null) { 62 $this->id = $id; 63 $this->userid = $userid; 64 $this->attempt = $attempt; 65 $this->reporttype = $reporttype; 66 $this->mode = $mode; 67 $this->scoid = $scoid; 68 } 69 70 /** 71 * Provide data for the template 72 * 73 * @param renderer_base $output renderer_base object. 74 * @return array data for the template. 75 */ 76 public function export_for_template(renderer_base $output): array { 77 $data = [ 78 'backurl' => (new moodle_url('/mod/scorm/report.php', ['id' => $this->id, 'mode' => $this->mode]))->out(false) 79 ]; 80 81 if (!$this->scoid) { 82 $learnobjects = new moodle_url('/mod/scorm/report/userreport.php', 83 ['id' => $this->id, 'user' => $this->userid, 'attempt' => $this->attempt, 'mode' => $this->mode]); 84 $interactions = new moodle_url('/mod/scorm/report/userreportinteractions.php', 85 ['id' => $this->id, 'user' => $this->userid, 'attempt' => $this->attempt, 'mode' => $this->mode]); 86 87 $reportmenu[$learnobjects->out(false)] = get_string('scoes', 'scorm'); 88 $reportmenu[$interactions->out(false)] = get_string('interactions', 'scorm'); 89 90 if ($this->reporttype === 'learning') { 91 $userreporturl = $learnobjects->out(false); 92 } else { 93 $userreporturl = $interactions->out(false); 94 } 95 $urlselect = new url_select($reportmenu, $userreporturl, [], 'userscormreport'); 96 $data ['userreport'] = $urlselect->export_for_template($output); 97 $data ['heading'] = $reportmenu[$userreporturl] ?? null; 98 } 99 100 return $data; 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body