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
defined('MOODLE_INTERNAL') || die();
18
 
19
 
20
// Lesson.
21
require_once($CFG->dirroot . "/mod/lesson/renderer.php");
22
class theme_monocolor_mod_lesson_renderer extends mod_lesson_renderer {
23
 
24
    /**
25
     * Returns HTML for a lesson inaccessible message
26
     *
27
     * @param string $message
28
     * @return <type>
29
     */
30
    public function lesson_inaccessible($message) {
31
        global $CFG;
32
        $output = $this->output->box_start('generalbox boxaligncenter my-2 w-100');
33
        $output .= $this->output->box_start('center my-2 w-100');
34
        $output .= $message;
35
        $output .= $this->output->box('<a class="btn btn-sm btn-secondary" href="' .
36
            $CFG->wwwroot .
37
            '/course/view.php?id=' .
38
            $this->page->course->id .
39
            '">' .
40
            get_string('returnto', 'lesson', format_string($this->page->course->fullname, true)) .
41
            '</a>', ' btn btn-sm btn-secondary');
42
        $output .= $this->output->box_end();
43
        $output .= $this->output->box_end();
44
        return $output;
45
    }
46
 
47
    /**
48
     * Returns HTML to prompt the user to log in
49
     * @param lesson $lesson
50
     * @param bool $failedattempt
51
     * @return string
52
     */
53
    public function login_prompt(lesson $lesson, $failedattempt = false) {
54
        global $CFG;
55
        $output = $this->output->box_start('password-form');
56
        $output .= $this->output->box_start('generalbox boxaligncenter my-2 w-100');
57
        $output .= '<form id="password" method="post" action="' .
58
            $CFG->wwwroot .
59
            '/mod/lesson/view.php" autocomplete="off">';
60
        $output .= '<fieldset class="invisiblefieldset center">';
61
        $output .= '<input type="hidden" name="id" value="' .
62
            $this->page->cm->id .
63
            '" />';
64
        $output .= '<input type="hidden" name="sesskey" value="' .
65
            sesskey() .
66
            '" />';
67
        if ($failedattempt) {
68
            $output .= $this->output->notification(get_string('loginfail', 'lesson'));
69
        }
70
        $output .= get_string('passwordprotectedlesson', 'lesson', format_string($lesson->name)) . '<br /><br />';
71
        $output .= get_string('enterpassword', 'lesson') .
72
            " <input type=\"password\" name=\"userpassword\" /><br /><br />";
73
        $output .= "<input class='btn btn-sm btn-primary' type='submit' value='" .
74
            get_string('continue', 'lesson') .
75
            "' />";
76
        $output .= "<input class='btn btn-sm btn-danger' type='submit' name='backtocourse' value='" .
77
            get_string('cancel', 'lesson') . "' />";
78
        $output .= '</fieldset></form>';
79
        $output .= $this->output->box_end();
80
        $output .= $this->output->box_end();
81
        return $output;
82
    }
83
 
84
    /**
85
     * Returns HTML to display a continue button
86
     * @param lesson $lesson
87
     * @param int $lastpageseen
88
     * @return string
89
     */
90
    public function continue_links(lesson $lesson, $lastpageseenid) {
91
        global $CFG;
92
        $output = $this->output->box(get_string('youhaveseen', 'lesson'), 'generalbox boxaligncenter m-0 p-0 w-100');
93
 
94
        $yeslink = html_writer::link(new moodle_url('/mod/lesson/view.php', array(
95
            'id' => $this->page->cm->id,
96
            'pageid' => $lastpageseenid, 'startlastseen' => 'yes'
97
        )), get_string('yes'), array('class' => 'btn btn-sm btn-primary'));
98
        $output .= html_writer::tag('span', $yeslink, array('class' => 'lessonbutton'));
99
        $output .= '&nbsp;';
100
 
101
        $nolink = html_writer::link(new moodle_url('/mod/lesson/view.php', array(
102
            'id' => $this->page->cm->id,
103
            'pageid' => $lesson->firstpageid, 'startlastseen' => 'no'
104
        )), get_string('no'), array('class' => 'btn btn-sm btn-secondary'));
105
        $output .= html_writer::tag('span', $nolink, array('class' => 'lessonbutton'));
106
 
107
        return $output;
108
    }
109
 
110
 
111
    /**
112
     * Returns HTML to display a message
113
     * @param string $message
114
     * @param single_button $button
115
     * @return string
116
     */
117
    public function message($message, single_button $button = null) {
118
        $output = $this->output->box_start('generalbox boxaligncenter wrapper-fw');
119
        $output .= $message;
120
        if ($button !== null) {
121
            $output .= $this->output->box($this->output->render($button), 'lessonbutton');
122
        }
123
        $output .= $this->output->box_end();
124
        return $output;
125
    }
126
 
127
 
128
    /**
129
     * Returns the HTML for displaying the end of lesson page.
130
     *
131
     * @param  lesson $lesson lesson instance
132
     * @param  stdclass $data lesson data to be rendered
133
     * @return string         HTML contents
134
     */
135
    public function display_eol_page(lesson $lesson, $data) {
136
 
137
        $output = '';
138
        $canmanage = $lesson->can_manage();
139
        $course = $lesson->courserecord;
140
 
141
        if ($lesson->custom && !$canmanage && (($data->gradeinfo->nquestions < $lesson->minquestions))) {
142
            $output .= $this->box_start('generalbox boxaligncenter wrapper-fw');
143
        }
144
 
145
        if ($data->gradelesson) {
146
            // We are using level 3 header because the page title is a sub-heading of lesson title (MDL-30911).
147
            $output .= $this->heading(get_string("congratulations", "lesson"), 3);
148
            $output .= $this->box_start('generalbox boxaligncenter wrapper-fw');
149
        }
150
 
151
        if ($data->notenoughtimespent !== false) {
152
            $output .= $this->paragraph(
153
                    get_string("notenoughtimespent", "lesson", $data->notenoughtimespent),
154
                    'center wrapper-fw');
155
        }
156
 
157
        if ($data->numberofpagesviewed !== false) {
158
            $output .= $this->paragraph(
159
                    get_string("numberofpagesviewed", "lesson", $data->numberofpagesviewed),
160
                    'center wrapper-fw');
161
        }
162
        if ($data->youshouldview !== false) {
163
            $output .= $this->paragraph(
164
                get_string("youshouldview", "lesson", $data->youshouldview),
165
                'center wrapper-fw');
166
        }
167
        if ($data->numberofcorrectanswers !== false) {
168
            $output .= $this->paragraph(
169
                get_string("numberofcorrectanswers", "lesson", $data->numberofcorrectanswers),
170
                'center wrapper-fw');
171
        }
172
 
173
        if ($data->displayscorewithessays !== false) {
174
            $output .= $this->box(
175
                get_string("displayscorewithessays", "lesson", $data->displayscorewithessays),
176
                'center wrapper-fw');
177
        } else if ($data->displayscorewithoutessays !== false) {
178
            $output .= $this->box(
179
                get_string("displayscorewithoutessays", "lesson", $data->displayscorewithoutessays),
180
                'center wrapper-fw');
181
        }
182
 
183
        if ($data->yourcurrentgradeisoutof !== false) {
184
            $output .= $this->paragraph(
185
                get_string("yourcurrentgradeisoutof", "lesson", $data->yourcurrentgradeisoutof),
186
                'center wrapper-fw');
187
        }
188
        if ($data->eolstudentoutoftimenoanswers !== false) {
189
            $output .= $this->paragraph(get_string("eolstudentoutoftimenoanswers", "lesson"));
190
        }
191
        if ($data->welldone !== false) {
192
            $output .= $this->paragraph(get_string("welldone", "lesson"));
193
        }
194
 
195
        if ($data->progresscompleted !== false) {
196
            $output .= $this->progress_bar($lesson, $data->progresscompleted);
197
        }
198
 
199
        if ($data->displayofgrade !== false) {
200
            $output .= $this->paragraph(get_string("displayofgrade", "lesson"), 'alert alert-warning');
201
        }
202
 
203
        $output .= $this->box_end(); // End. of Lesson button to Continue.
204
 
205
        if ($data->reviewlesson !== false) {
206
            $output .= '<div class="my-2 w-100">' . html_writer::link(
207
                $data->reviewlesson,
208
                get_string('reviewlesson', 'lesson'),
209
                array('class' => 'btn btn-sm btn-primary')
210
            ) . '</div>';
211
        }
212
        if ($data->modattemptsnoteacher !== false) {
213
            $output .= $this->paragraph(get_string("modattemptsnoteacher", "lesson"), 'centerpadded alert alert-warning');
214
        }
215
 
216
        if ($data->activitylink !== false) {
217
            $output .= $data->activitylink;
218
        }
219
 
220
        $url = new moodle_url('/course/view.php', array('id' => $course->id));
221
        $output .= html_writer::link(
222
            $url,
223
            get_string('returnto', 'lesson', format_string($course->fullname, true)),
224
            array('class' => 'btn btn-sm btn-secondary'));
225
 
226
        if (
227
            has_capability('gradereport/user:view', context_course::instance($course->id))
228
            && $course->showgrades && $lesson->grade != 0 && !$lesson->practice
229
        ) {
230
            $url = new moodle_url('/grade/index.php', array('id' => $course->id));
231
            $output .= '<div class="wrapper-fw mt-2">' . html_writer::link(
232
                $url,
233
                get_string('viewgrades', 'lesson'),
234
                array('class' => 'btn btn-sm btn-outline-primary')
235
            ) . '</div>';
236
        }
237
        return $output;
238
    }
239
}