2017-02-01 10:23:15 +00:00
|
|
|
<?php
|
|
|
|
// This file is part of Moodle - http://moodle.org/
|
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Contains class used to prepare a verification result for display.
|
|
|
|
*
|
2021-11-24 07:29:43 +00:00
|
|
|
* @package mod_htmlcert
|
2017-02-01 10:23:15 +00:00
|
|
|
* @copyright 2017 Mark Nelson <markn@moodle.com>
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
2021-11-24 07:29:43 +00:00
|
|
|
namespace mod_htmlcert\output;
|
2017-02-01 10:23:15 +00:00
|
|
|
|
|
|
|
defined('MOODLE_INTERNAL') || die();
|
|
|
|
|
|
|
|
use renderable;
|
|
|
|
use templatable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class to prepare a verification result for display.
|
|
|
|
*
|
2021-11-24 07:29:43 +00:00
|
|
|
* @package mod_htmlcert
|
2017-02-01 10:23:15 +00:00
|
|
|
* @copyright 2017 Mark Nelson <markn@moodle.com>
|
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
class verify_certificate_result implements templatable, renderable {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string The URL to the user's profile.
|
|
|
|
*/
|
|
|
|
public $userprofileurl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string The user's fullname.
|
|
|
|
*/
|
|
|
|
public $userfullname;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string The URL to the course page.
|
|
|
|
*/
|
|
|
|
public $courseurl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string The course's fullname.
|
|
|
|
*/
|
|
|
|
public $coursefullname;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string The certificate's name.
|
|
|
|
*/
|
|
|
|
public $certificatename;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
|
|
|
* @param \stdClass $result
|
|
|
|
*/
|
|
|
|
public function __construct($result) {
|
2021-11-24 07:29:43 +00:00
|
|
|
$cm = get_coursemodule_from_instance('htmlcert', $result->certificateid);
|
2018-06-12 08:42:27 +00:00
|
|
|
$context = \context_module::instance($cm->id);
|
|
|
|
|
2017-02-01 10:23:15 +00:00
|
|
|
$this->userprofileurl = new \moodle_url('/user/view.php', array('id' => $result->userid,
|
|
|
|
'course' => $result->courseid));
|
|
|
|
$this->userfullname = fullname($result);
|
|
|
|
$this->courseurl = new \moodle_url('/course/view.php', array('id' => $result->courseid));
|
2018-06-12 08:42:27 +00:00
|
|
|
$this->coursefullname = format_string($result->coursefullname, true, ['context' => $context]);
|
|
|
|
$this->certificatename = format_string($result->certificatename, true, ['context' => $context]);
|
2017-02-01 10:23:15 +00:00
|
|
|
}
|
|
|
|
|
2017-02-16 12:12:19 +00:00
|
|
|
/**
|
|
|
|
* Function to export the renderer data in a format that is suitable for a mustache template.
|
|
|
|
*
|
|
|
|
* @param \renderer_base $output Used to do a final render of any components that need to be rendered for export.
|
|
|
|
* @return \stdClass|array
|
|
|
|
*/
|
2017-02-01 10:23:15 +00:00
|
|
|
public function export_for_template(\renderer_base $output) {
|
|
|
|
$result = new \stdClass();
|
|
|
|
$result->userprofileurl = $this->userprofileurl;
|
|
|
|
$result->userfullname = $this->userfullname;
|
|
|
|
$result->coursefullname = $this->coursefullname;
|
|
|
|
$result->courseurl = $this->courseurl;
|
|
|
|
$result->certificatename = $this->certificatename;
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|