Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
 * Contains class used to prepare a verification result for display.
19
 *
20
 * @package   mod_customcert
21
 * @copyright 2017 Mark Nelson <markn@moodle.com>
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace mod_customcert\output;
26
 
27
use renderable;
28
use templatable;
29
 
30
/**
31
 * Class to prepare a verification result for display.
32
 *
33
 * @package   mod_customcert
34
 * @copyright 2017 Mark Nelson <markn@moodle.com>
35
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 */
37
class verify_certificate_result implements templatable, renderable {
38
 
39
    /**
40
     * @var string The URL to the user's profile.
41
     */
42
    public $userprofileurl;
43
 
44
    /**
45
     * @var string The user's fullname.
46
     */
47
    public $userfullname;
48
 
49
    /**
50
     * @var string The URL to the course page.
51
     */
52
    public $courseurl;
53
 
54
    /**
55
     * @var string The course's fullname.
56
     */
57
    public $coursefullname;
58
 
59
    /**
60
     * @var string The certificate's name.
61
     */
62
    public $certificatename;
63
 
64
    /**
65
     * Constructor.
66
     *
67
     * @param \stdClass $result
68
     */
69
    public function __construct($result) {
70
        $cm = get_coursemodule_from_instance('customcert', $result->certificateid);
71
        $context = \context_module::instance($cm->id);
72
 
73
        $this->userprofileurl = new \moodle_url('/user/view.php', ['id' => $result->userid,
74
            'course' => $result->courseid]);
75
        $this->userfullname = fullname($result);
76
        $this->courseurl = new \moodle_url('/course/view.php', ['id' => $result->courseid]);
77
        $this->coursefullname = format_string($result->coursefullname, true, ['context' => $context]);
78
        $this->certificatename = format_string($result->certificatename, true, ['context' => $context]);
79
    }
80
 
81
    /**
82
     * Function to export the renderer data in a format that is suitable for a mustache template.
83
     *
84
     * @param \renderer_base $output Used to do a final render of any components that need to be rendered for export.
85
     * @return \stdClass|array
86
     */
87
    public function export_for_template(\renderer_base $output) {
88
        $result = new \stdClass();
89
        $result->userprofileurl = $this->userprofileurl;
90
        $result->userfullname = $this->userfullname;
91
        $result->coursefullname = $this->coursefullname;
92
        $result->courseurl = $this->courseurl;
93
        $result->certificatename = $this->certificatename;
94
 
95
        return $result;
96
    }
97
}