3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
19 * This page prints a particular instance of lesson
23 * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late
27 require_once(dirname(__FILE__) . '/../../config.php');
28 require_once($CFG->dirroot.'/mod/lesson/locallib.php');
29 require_once($CFG->dirroot.'/mod/lesson/view_form.php');
30 require_once($CFG->libdir . '/completionlib.php');
32 $id = required_param('id', PARAM_INT); // Course Module ID
33 $pageid = optional_param('pageid', null, PARAM_INT); // Lesson Page ID
34 $edit = optional_param('edit', -1, PARAM_BOOL);
35 $userpassword = optional_param('userpassword','',PARAM_RAW);
36 $backtocourse = optional_param('backtocourse', false, PARAM_RAW);
38 $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);
39 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
40 $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST));
42 require_login($course, false, $cm);
45 redirect(new moodle_url('/course/view.php', array('id'=>$course->id)));
49 $completion = new completion_info($course);
50 $completion->set_module_viewed($cm);
52 $url = new moodle_url('/mod/lesson/view.php', array('id'=>$id));
53 if ($pageid !== null) {
54 $url->param('pageid', $pageid);
58 $context = context_module::instance($cm->id);
59 $canmanage = has_capability('mod/lesson:manage', $context);
61 $lessonoutput = $PAGE->get_renderer('mod_lesson');
64 $userhasgrade = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
65 if ($userhasgrade && !$lesson->retake) {
69 /// Check these for students only TODO: Find a better method for doing this!
70 /// Check lesson availability
71 /// Check for password
72 /// Check dependencies
73 /// Check for high scores
75 if (!$lesson->is_accessible()) { // Deadline restrictions
76 echo $lessonoutput->header($lesson, $cm, '', false, null, get_string('notavailable'));
77 if ($lesson->deadline != 0 && time() > $lesson->deadline) {
78 echo $lessonoutput->lesson_inaccessible(get_string('lessonclosed', 'lesson', userdate($lesson->deadline)));
80 echo $lessonoutput->lesson_inaccessible(get_string('lessonopen', 'lesson', userdate($lesson->available)));
82 echo $lessonoutput->footer();
84 } else if ($lesson->usepassword && empty($USER->lessonloggedin[$lesson->id])) { // Password protected lesson code
86 if (!empty($userpassword) && (($lesson->password == md5(trim($userpassword))) || ($lesson->password == trim($userpassword)))) {
87 // with or without md5 for backward compatibility (MDL-11090)
88 $USER->lessonloggedin[$lesson->id] = true;
89 if ($lesson->highscores) {
90 // Logged in - redirect so we go through all of these checks before starting the lesson.
91 redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id");
94 echo $lessonoutput->header($lesson, $cm, '', false, null, get_string('passwordprotectedlesson', 'lesson', format_string($lesson->name)));
95 echo $lessonoutput->login_prompt($lesson, $userpassword !== '');
96 echo $lessonoutput->footer();
99 } else if ($lesson->dependency) { // check for dependencies
100 if ($dependentlesson = $DB->get_record('lesson', array('id' => $lesson->dependency))) {
101 // lesson exists, so we can proceed
102 $conditions = unserialize($lesson->conditions);
103 // assume false for all
106 // check for the timespent condition
107 if ($conditions->timespent) {
109 if ($attempttimes = $DB->get_records('lesson_timer', array("userid"=>$USER->id, "lessonid"=>$dependentlesson->id))) {
110 // go through all the times and test to see if any of them satisfy the condition
111 foreach($attempttimes as $attempttime) {
112 $duration = $attempttime->lessontime - $attempttime->starttime;
113 if ($conditions->timespent < $duration/60) {
119 $errors[] = get_string('timespenterror', 'lesson', $conditions->timespent);
123 // check for the gradebetterthan condition
124 if($conditions->gradebetterthan) {
125 $gradebetterthan = false;
126 if ($studentgrades = $DB->get_records('lesson_grades', array("userid"=>$USER->id, "lessonid"=>$dependentlesson->id))) {
127 // go through all the grades and test to see if any of them satisfy the condition
128 foreach($studentgrades as $studentgrade) {
129 if ($studentgrade->grade >= $conditions->gradebetterthan) {
130 $gradebetterthan = true;
134 if (!$gradebetterthan) {
135 $errors[] = get_string('gradebetterthanerror', 'lesson', $conditions->gradebetterthan);
139 // check for the completed condition
140 if ($conditions->completed) {
141 if (!$DB->count_records('lesson_grades', array('userid'=>$USER->id, 'lessonid'=>$dependentlesson->id))) {
142 $errors[] = get_string('completederror', 'lesson');
146 if (!empty($errors)) { // print out the errors if any
147 echo $lessonoutput->header($lesson, $cm, '', false, null, get_string('completethefollowingconditions', 'lesson', format_string($lesson->name)));
148 echo $lessonoutput->dependancy_errors($dependentlesson, $errors);
149 echo $lessonoutput->footer();
153 } else if ($lesson->highscores && !$lesson->practice && !optional_param('viewed', 0, PARAM_INT) && empty($pageid)) {
154 // Display high scores before starting lesson
155 redirect(new moodle_url('/mod/lesson/highscores.php', array("id"=>$cm->id)));
159 // this is called if a student leaves during a lesson
160 if ($pageid == LESSON_UNSEENBRANCHPAGE) {
161 $pageid = lesson_unseen_question_jump($lesson, $USER->id, $pageid);
164 // display individual pages and their sets of answers
165 // if pageid is EOL then the end of the lesson has been reached
166 // for flow, changed to simple echo for flow styles, michaelp, moved lesson name and page title down
167 $attemptflag = false;
168 if (empty($pageid)) {
169 // make sure there are pages to view
170 if (!$DB->get_field('lesson_pages', 'id', array('lessonid' => $lesson->id, 'prevpageid' => 0))) {
172 $lesson->add_message(get_string('lessonnotready2', 'lesson')); // a nice message to the student
174 if (!$DB->count_records('lesson_pages', array('lessonid'=>$lesson->id))) {
175 redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); // no pages - redirect to add pages
177 $lesson->add_message(get_string('lessonpagelinkingbroken', 'lesson')); // ok, bad mojo
182 add_to_log($course->id, 'lesson', 'start', 'view.php?id='. $cm->id, $lesson->id, $cm->id);
184 // if no pageid given see if the lesson has been started
185 $retries = $DB->count_records('lesson_grades', array("lessonid" => $lesson->id, "userid" => $USER->id));
190 if (isset($USER->modattempts[$lesson->id])) {
191 unset($USER->modattempts[$lesson->id]); // if no pageid, then student is NOT reviewing
194 // If there are any questions that have been answered correctly (or not) in this attempt.
195 $allattempts = $lesson->get_attempts($retries);
196 if (!empty($allattempts)) {
197 $attempt = end($allattempts);
198 $attemptpage = $lesson->load_page($attempt->pageid);
199 $jumpto = $DB->get_field('lesson_answers', 'jumpto', array('id' => $attempt->answerid));
200 // convert the jumpto to a proper page id
202 // Check if a question has been incorrectly answered AND no more attempts at it are left.
203 $nattempts = $lesson->get_attempts($attempt->retry, false, $attempt->pageid, $USER->id);
204 if (count($nattempts) >= $lesson->maxattempts) {
205 $lastpageseen = $lesson->get_next_page($attemptpage->nextpageid);
207 $lastpageseen = $attempt->pageid;
209 } elseif ($jumpto == LESSON_NEXTPAGE) {
210 $lastpageseen = $lesson->get_next_page($attemptpage->nextpageid);
212 $lastpageseen = $jumpto;
216 if ($branchtables = $DB->get_records('lesson_branch', array("lessonid" => $lesson->id, "userid" => $USER->id, "retry" => $retries), 'timeseen DESC')) {
217 // in here, user has viewed a branch table
218 $lastbranchtable = current($branchtables);
219 if (count($allattempts) > 0) {
220 foreach($allattempts as $attempt) {
221 if ($lastbranchtable->timeseen > $attempt->timeseen) {
222 // branch table was viewed later than the last attempt
223 $lastpageseen = $lastbranchtable->pageid;
228 // hasnt answered any questions but has viewed a branch table
229 $lastpageseen = $lastbranchtable->pageid;
232 if (isset($lastpageseen) && $DB->count_records('lesson_attempts', array('lessonid'=>$lesson->id, 'userid'=>$USER->id, 'retry'=>$retries)) > 0) {
233 echo $lessonoutput->header($lesson, $cm, '', false, null, get_string('leftduringtimedsession', 'lesson'));
234 if ($lesson->timed) {
235 if ($lesson->retake) {
236 $continuelink = new single_button(new moodle_url('/mod/lesson/view.php', array('id'=>$cm->id, 'pageid'=>$lesson->firstpageid, 'startlastseen'=>'no')), get_string('continue', 'lesson'), 'get');
237 echo '<div class="center leftduring">'.$lessonoutput->message(get_string('leftduringtimed', 'lesson'), $continuelink).'</div>';
239 $courselink = new single_button(new moodle_url('/course/view.php', array('id'=>$PAGE->course->id)), get_string('returntocourse', 'lesson'), 'get');
240 echo '<div class="center leftduring">'.$lessonoutput->message(get_string('leftduringtimednoretake', 'lesson'), $courselink).'</div>';
243 echo $lessonoutput->continue_links($lesson, $lastpageseen);
245 echo $lessonoutput->footer();
250 if (!$lesson->retake) {
251 echo $lessonoutput->header($lesson, $cm, 'view', '', null, get_string("noretake", "lesson"));
252 $courselink = new single_button(new moodle_url('/course/view.php', array('id'=>$PAGE->course->id)), get_string('returntocourse', 'lesson'), 'get');
253 echo $lessonoutput->message(get_string("noretake", "lesson"), $courselink);
254 echo $lessonoutput->footer();
258 // start at the first page
259 if (!$pageid = $DB->get_field('lesson_pages', 'id', array('lessonid' => $lesson->id, 'prevpageid' => 0))) {
260 print_error('cannotfindfirstpage', 'lesson');
262 /// This is the code for starting a timed test
263 if(!isset($USER->startlesson[$lesson->id]) && !$canmanage) {
264 $lesson->start_timer();
268 $currenttab = 'view';
269 $extraeditbuttons = false;
270 $lessonpageid = null;
273 if ($pageid != LESSON_EOL) {
274 /// This is the code updates the lessontime for a timed test
275 $startlastseen = optional_param('startlastseen', '', PARAM_ALPHA);
276 if ($startlastseen == 'no') {
277 // this deletes old records not totally sure if this is necessary anymore
278 $retries = $DB->count_records('lesson_grades', array('lessonid'=>$lesson->id, 'userid'=>$USER->id));
279 $DB->delete_records('lesson_attempts', array('userid' => $USER->id, 'lessonid' => $lesson->id, 'retry' => $retries));
280 $DB->delete_records('lesson_branch', array('userid' => $USER->id, 'lessonid' => $lesson->id, 'retry' => $retries));
283 $page = $lesson->load_page($pageid);
284 // Check if the page is of a special type and if so take any nessecary action
285 $newpageid = $page->callback_on_view($canmanage);
286 if (is_numeric($newpageid)) {
287 $page = $lesson->load_page($newpageid);
290 add_to_log($PAGE->course->id, 'lesson', 'view', 'view.php?id='. $PAGE->cm->id, $page->id, $PAGE->cm->id);
292 // This is where several messages (usually warnings) are displayed
293 // all of this is displayed above the actual page
295 // check to see if the user can see the left menu
297 $lesson->displayleft = lesson_displayleftif($lesson);
299 $continue = ($startlastseen !== '');
300 $restart = ($continue && $startlastseen == 'yes');
301 $timer = $lesson->update_timer($continue, $restart);
303 if ($lesson->timed) {
304 $timeleft = ($timer->starttime + $lesson->maxtime * 60) - time();
305 if ($timeleft <= 0) {
307 $lesson->add_message(get_string('eolstudentoutoftime', 'lesson'));
308 redirect(new moodle_url('/mod/lesson/view.php', array('id'=>$cm->id,'pageid'=>LESSON_EOL, 'outoftime'=>'normal')));
309 die; // Shouldn't be reached, but make sure
310 } else if ($timeleft < 60) {
311 // One minute warning
312 $lesson->add_message(get_string('studentoneminwarning', 'lesson'));
316 if ($page->qtype == LESSON_PAGE_BRANCHTABLE && $lesson->minquestions) {
317 // tell student how many questions they have seen, how many are required and their grade
318 $ntries = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
319 $gradeinfo = lesson_grade($lesson, $ntries);
320 if ($gradeinfo->attempts) {
321 if ($gradeinfo->nquestions < $lesson->minquestions) {
323 $a->nquestions = $gradeinfo->nquestions;
324 $a->minquestions = $lesson->minquestions;
325 $lesson->add_message(get_string('numberofpagesviewednotice', 'lesson', $a));
329 $a->grade = number_format($gradeinfo->grade * $lesson->grade / 100, 1);
330 $a->total = $lesson->grade;
331 if (!$reviewmode && !$lesson->retake){
332 $lesson->add_message(get_string("numberofcorrectanswers", "lesson", $gradeinfo->earned), 'notify');
333 $lesson->add_message(get_string('yourcurrentgradeisoutof', 'lesson', $a), 'notify');
339 if ($lesson->timed) {
340 $lesson->add_message(get_string('teachertimerwarning', 'lesson'));
342 if (lesson_display_teacher_warning($lesson)) {
343 // This is the warning msg for teachers to inform them that cluster
344 // and unseen does not work while logged in as a teacher
345 $warningvars = new stdClass();
346 $warningvars->cluster = get_string('clusterjump', 'lesson');
347 $warningvars->unseen = get_string('unseenpageinbranch', 'lesson');
348 $lesson->add_message(get_string('teacherjumpwarning', 'lesson', $warningvars));
352 $PAGE->set_url('/mod/lesson/view.php', array('id' => $cm->id, 'pageid' => $page->id));
353 $PAGE->set_subpage($page->id);
354 $currenttab = 'view';
355 $extraeditbuttons = true;
356 $lessonpageid = $page->id;
357 $extrapagetitle = $page->title;
359 if (($edit != -1) && $PAGE->user_allowed_editing()) {
360 $USER->editing = $edit;
363 if (is_array($page->answers) && count($page->answers)>0) {
364 // this is for modattempts option. Find the users previous answer to this page,
365 // and then display it below in answer processing
366 if (isset($USER->modattempts[$lesson->id])) {
367 $retries = $DB->count_records('lesson_grades', array("lessonid"=>$lesson->id, "userid"=>$USER->id));
368 if (!$attempts = $lesson->get_attempts($retries-1, false, $page->id)) {
369 print_error('cannotfindpreattempt', 'lesson');
371 $attempt = end($attempts);
372 $USER->modattempts[$lesson->id] = $attempt;
376 $lessoncontent = $lessonoutput->display_page($lesson, $page, $attempt);
378 $data = new stdClass;
379 $data->id = $PAGE->cm->id;
380 $data->pageid = $page->id;
381 $data->newpageid = $lesson->get_next_page($page->nextpageid);
384 'title' => $page->title,
385 'contents' => $page->get_contents()
387 $mform = new lesson_page_without_answers($CFG->wwwroot.'/mod/lesson/continue.php', $customdata);
388 $mform->set_data($data);
391 $lessoncontent = ob_get_contents();
395 lesson_add_fake_blocks($PAGE, $cm, $lesson, $timer);
396 echo $lessonoutput->header($lesson, $cm, $currenttab, $extraeditbuttons, $lessonpageid, $extrapagetitle);
398 // We are using level 3 header because attempt heading is a sub-heading of lesson title (MDL-30911).
399 echo $OUTPUT->heading(get_string('attempt', 'lesson', $retries), 3);
401 /// This calculates and prints the ongoing score
402 if ($lesson->ongoing && !empty($pageid) && !$reviewmode) {
403 echo $lessonoutput->ongoing_score($lesson);
405 if ($lesson->displayleft) {
406 echo '<a name="maincontent" id="maincontent" title="' . get_string('anchortitle', 'lesson') . '"></a>';
409 echo $lessonoutput->slideshow_end();
410 echo $lessonoutput->progress_bar($lesson);
411 echo $lessonoutput->footer();
416 // end of lesson reached work out grade
417 // Used to check to see if the student ran out of time
418 $outoftime = optional_param('outoftime', '', PARAM_ALPHA);
420 // Update the clock / get time information for this user
421 add_to_log($course->id, "lesson", "end", "view.php?id=".$PAGE->cm->id, "$lesson->id", $PAGE->cm->id);
423 // We are using level 3 header because the page title is a sub-heading of lesson title (MDL-30911).
424 $lessoncontent .= $OUTPUT->heading(get_string("congratulations", "lesson"), 3);
425 $lessoncontent .= $OUTPUT->box_start('generalbox boxaligncenter');
426 $ntries = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
427 if (isset($USER->modattempts[$lesson->id])) {
428 $ntries--; // need to look at the old attempts :)
431 $lesson->stop_timer();
432 $gradeinfo = lesson_grade($lesson, $ntries);
434 if ($gradeinfo->attempts) {
435 if (!$lesson->custom) {
436 $lessoncontent .= $lessonoutput->paragraph(get_string("numberofpagesviewed", "lesson", $gradeinfo->nquestions), 'center');
437 if ($lesson->minquestions) {
438 if ($gradeinfo->nquestions < $lesson->minquestions) {
439 // print a warning and set nviewed to minquestions
440 $lessoncontent .= $lessonoutput->paragraph(get_string("youshouldview", "lesson", $lesson->minquestions), 'center');
443 $lessoncontent .= $lessonoutput->paragraph(get_string("numberofcorrectanswers", "lesson", $gradeinfo->earned), 'center');
446 $a->score = $gradeinfo->earned;
447 $a->grade = $gradeinfo->total;
448 if ($gradeinfo->nmanual) {
449 $a->tempmaxgrade = $gradeinfo->total - $gradeinfo->manualpoints;
450 $a->essayquestions = $gradeinfo->nmanual;
451 $lessoncontent .= $OUTPUT->box(get_string("displayscorewithessays", "lesson", $a), 'center');
453 $lessoncontent .= $OUTPUT->box(get_string("displayscorewithoutessays", "lesson", $a), 'center');
456 $a->grade = number_format($gradeinfo->grade * $lesson->grade / 100, 1);
457 $a->total = $lesson->grade;
458 $lessoncontent .= $lessonoutput->paragraph(get_string("yourcurrentgradeisoutof", "lesson", $a), 'center');
460 $grade = new stdClass();
461 $grade->lessonid = $lesson->id;
462 $grade->userid = $USER->id;
463 $grade->grade = $gradeinfo->grade;
464 $grade->completed = time();
465 if (!$lesson->practice) {
466 if (isset($USER->modattempts[$lesson->id])) { // if reviewing, make sure update old grade record
467 if (!$grades = $DB->get_records("lesson_grades", array("lessonid" => $lesson->id, "userid" => $USER->id), "completed DESC", '*', 0, 1)) {
468 print_error('cannotfindgrade', 'lesson');
470 $oldgrade = array_shift($grades);
471 $grade->id = $oldgrade->id;
472 $DB->update_record("lesson_grades", $grade);
474 $newgradeid = $DB->insert_record("lesson_grades", $grade);
477 $DB->delete_records("lesson_attempts", array("lessonid" => $lesson->id, "userid" => $USER->id, "retry" => $ntries));
480 if ($lesson->timed) {
481 if ($outoftime == 'normal') {
482 $grade = new stdClass();
483 $grade->lessonid = $lesson->id;
484 $grade->userid = $USER->id;
486 $grade->completed = time();
487 if (!$lesson->practice) {
488 $newgradeid = $DB->insert_record("lesson_grades", $grade);
490 $lessoncontent .= get_string("eolstudentoutoftimenoanswers", "lesson");
493 $lessoncontent .= get_string("welldone", "lesson");
497 // update central gradebook
498 lesson_update_grades($lesson, $USER->id);
501 // display for teacher
502 $lessoncontent .= $lessonoutput->paragraph(get_string("displayofgrade", "lesson"), 'center');
504 $lessoncontent .= $OUTPUT->box_end(); //End of Lesson button to Continue.
506 // after all the grade processing, check to see if "Show Grades" is off for the course
507 // if yes, redirect to the course page
508 if (!$course->showgrades) {
509 redirect(new moodle_url('/course/view.php', array('id'=>$course->id)));
513 if ($lesson->highscores && !$canmanage && !$lesson->practice) {
514 $lessoncontent .= $OUTPUT->box_start('center');
515 if ($grades = $DB->get_records("lesson_grades", array("lessonid" => $lesson->id), "completed")) {
517 if ($highscores = $DB->get_records("lesson_high_scores", array("lessonid" => $lesson->id))) {
518 // get all the high scores into an array
519 $topscores = array();
520 $uniquescores = array();
521 foreach ($highscores as $highscore) {
522 $grade = $grades[$highscore->gradeid]->grade;
523 $topscores[] = $grade;
524 $uniquescores[$grade] = 1;
526 // sort to find the lowest score
528 $lowscore = $topscores[0];
530 if ($gradeinfo->grade >= $lowscore || count($uniquescores) <= $lesson->maxhighscores) {
534 if (!$highscores or $madeit) {
535 $lessoncontent .= $lessonoutput->paragraph(get_string("youmadehighscore", "lesson", $lesson->maxhighscores), 'center');
536 $aurl = new moodle_url('/mod/lesson/highscores.php', array('id'=>$PAGE->cm->id, 'sesskey'=>sesskey()));
537 $lessoncontent .= $OUTPUT->single_button($aurl, get_string('clicktopost', 'lesson'));
539 $lessoncontent .= get_string("nothighscore", "lesson", $lesson->maxhighscores)."<br />";
542 $url = new moodle_url('/mod/lesson/highscores.php', array('id'=>$PAGE->cm->id, 'link'=>'1'));
543 $lessoncontent .= html_writer::link($url, get_string('viewhighscores', 'lesson'), array('class'=>'centerpadded lessonbutton standardbutton'));
544 $lessoncontent .= $OUTPUT->box_end();
547 if ($lesson->modattempts && !$canmanage) {
548 // make sure if the student is reviewing, that he/she sees the same pages/page path that he/she saw the first time
549 // look at the attempt records to find the first QUESTION page that the user answered, then use that page id
550 // to pass to view again. This is slick cause it wont call the empty($pageid) code
551 // $ntries is decremented above
552 if (!$attempts = $lesson->get_attempts($ntries)) {
554 $url = new moodle_url('/mod/lesson/view.php', array('id'=>$PAGE->cm->id));
556 $firstattempt = current($attempts);
557 $pageid = $firstattempt->pageid;
558 // IF the student wishes to review, need to know the last question page that the student answered. This will help to make
559 // sure that the student can leave the lesson via pushing the continue button.
560 $lastattempt = end($attempts);
561 $USER->modattempts[$lesson->id] = $lastattempt->pageid;
563 $url = new moodle_url('/mod/lesson/view.php', array('id'=>$PAGE->cm->id, 'pageid'=>$pageid));
565 $lessoncontent .= html_writer::link($url, get_string('reviewlesson', 'lesson'), array('class' => 'centerpadded lessonbutton standardbutton'));
566 } elseif ($lesson->modattempts && $canmanage) {
567 $lessoncontent .= $lessonoutput->paragraph(get_string("modattemptsnoteacher", "lesson"), 'centerpadded');
570 if ($lesson->activitylink) {
571 $lessoncontent .= $lesson->link_for_activitylink();
574 $url = new moodle_url('/course/view.php', array('id'=>$course->id));
575 $lessoncontent .= html_writer::link($url, get_string('returnto', 'lesson', format_string($course->fullname, true)), array('class'=>'centerpadded lessonbutton standardbutton'));
577 $url = new moodle_url('/grade/index.php', array('id'=>$course->id));
578 $lessoncontent .= html_writer::link($url, get_string('viewgrades', 'lesson'), array('class'=>'centerpadded lessonbutton standardbutton'));
580 lesson_add_fake_blocks($PAGE, $cm, $lesson, $timer);
581 echo $lessonoutput->header($lesson, $cm, $currenttab, $extraeditbuttons, $lessonpageid, get_string("congratulations", "lesson"));
583 echo $lessonoutput->footer();