3 * Action for processing page answers by users
6 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
11 require_once($CFG->dirroot
.'/mod/lesson/pagelib.php');
12 require_once($CFG->libdir
.'/blocklib.php');
15 // check to see if the user can see the left menu
16 if (!has_capability('mod/lesson:manage', $context)) {
17 $lesson->displayleft
= lesson_displayleftif($lesson);
20 // This is the code updates the lesson time for a timed test
21 // get time information for this user
23 $timer = new stdClass
;
24 if (!has_capability('mod/lesson:manage', $context)) {
25 if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) {
26 error('Error: could not find records');
28 $timer = array_pop($timer); // this will get the latest start time record
32 if ((($timer->starttime +
$lesson->maxtime
* 60) - time()) < 60 && !((($timer->starttime +
$lesson->maxtime
* 60) - time()) < 0)) {
33 lesson_set_message(get_string("studentoneminwarning", "lesson"));
34 } else if (($timer->starttime +
$lesson->maxtime
* 60) < time()) {
35 lesson_set_message(get_string("studentoutoftime", "lesson"));
38 if ((($timer->starttime +
$lesson->maxtime
* 60) - time()) <= 0) {
40 lesson_set_message(get_string('eolstudentoutoftime', 'lesson'));
41 redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=".LESSON_EOL
."&outoftime=normal", get_string("outoftime", "lesson"));
45 $timer->lessontime
= time();
46 if (!update_record("lesson_timer", $timer)) {
47 error("Error: could not update lesson_timer table");
51 // record answer (if necessary) and show response (if none say if answer is correct or not)
52 $pageid = required_param('pageid', PARAM_INT
);
53 if (!$page = get_record("lesson_pages", "id", $pageid)) {
54 error("Continue: Page record not found");
56 // set up some defaults
59 $correctanswer = false;
60 $isessayquestion = false; // use this to turn off review button on essay questions
61 $newpageid = 0; // stay on the page
62 $studentanswer = ''; // use this to store student's answer(s) in order to display it on feedback page
63 switch ($page->qtype
) {
65 $isessayquestion = true;
66 if (!$useranswer = $_POST['answer']) {
70 $useranswer = clean_param($useranswer, PARAM_RAW
);
72 if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
73 error("Continue: No answers found");
75 $correctanswer = false;
76 foreach ($answers as $answer) {
77 $answerid = $answer->id
;
78 $newpageid = $answer->jumpto
;
81 $userresponse->sent
=0;
82 $userresponse->graded
= 0;
83 $userresponse->score
= 0;
84 $userresponse->answer
= $useranswer;
85 $userresponse->response
= "";
86 $userresponse = addslashes(serialize($userresponse));
88 $studentanswer = s(stripslashes_safe($useranswer));
90 case LESSON_SHORTANSWER
:
91 if (!$useranswer = $_POST['answer']) {
95 $useranswer = stripslashes(clean_param($useranswer, PARAM_RAW
));
96 $userresponse = addslashes($useranswer);
97 if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
98 error("Continue: No answers found");
101 foreach ($answers as $answer) {
103 $expectedanswer = $answer->answer
; // for easier handling of $answer->answer
108 if ($page->qoption
) {
112 if ($useregexp) { //we are using 'normal analysis', which ignores case
114 if ( substr($expectedanswer,strlen($expectedanswer) - 2, 2) == '/i') {
115 $expectedanswer = substr($expectedanswer,0,strlen($expectedanswer) - 2);
119 $expectedanswer = str_replace('*', '#####', $expectedanswer);
120 $expectedanswer = preg_quote($expectedanswer, '/');
121 $expectedanswer = str_replace('#####', '.*', $expectedanswer);
123 // see if user typed in any of the correct answers
124 if (lesson_iscorrect($pageid, $answer->jumpto
) or ($lesson->custom
&& $answer->score
> 0) ) {
125 if (!$useregexp) { // we are using 'normal analysis', which ignores case
126 if (preg_match('/^'.$expectedanswer.'$/i',$useranswer)) {
130 if (preg_match('/^'.$expectedanswer.'$/'.$ignorecase,$useranswer)) {
134 if ($ismatch == true) {
135 $correctanswer = true;
138 if (!$useregexp) { //we are using 'normal analysis'
139 // see if user typed in any of the wrong answers; don't worry about case
140 if (preg_match('/^'.$expectedanswer.'$/i',$useranswer)) {
143 } else { // we are using regular expressions analysis
144 $startcode = substr($expectedanswer,0,2);
146 //1- check for absence of required string in $useranswer (coded by initial '--')
148 $expectedanswer = substr($expectedanswer,2);
149 if (!preg_match('/^'.$expectedanswer.'$/'.$ignorecase,$useranswer)) {
153 //2- check for code for marking wrong strings (coded by initial '++')
155 $expectedanswer=substr($expectedanswer,2);
157 //check for one or several matches
158 if (preg_match_all('/'.$expectedanswer.'/'.$ignorecase,$useranswer, $matches)) {
160 $nb = count($matches[0]);
163 $fontStart = '<span class="incorrect matches">';
164 $fontEnd = '</span>';
165 for ($i = 0; $i < $nb; $i++
) {
166 array_push($original,$matches[0][$i]);
167 array_push($marked,$fontStart.$matches[0][$i].$fontEnd);
169 $useranswer = str_replace($original, $marked, $useranswer);
172 //3- check for wrong answers belonging neither to -- nor to ++ categories
174 if (preg_match('/^'.$expectedanswer.'$/'.$ignorecase,$useranswer, $matches)) {
179 $correctanswer = false;
183 $newpageid = $answer->jumpto
;
184 if (trim(strip_tags($answer->response
))) {
185 $response = $answer->response
;
187 $answerid = $answer->id
;
188 break; // quit answer analysis immediately after a match has been found
191 $studentanswer = s($useranswer);
194 case LESSON_TRUEFALSE
:
195 if (empty($_POST['answerid'])) {
199 $answerid = required_param('answerid', PARAM_INT
);
200 if (!$answer = get_record("lesson_answers", "id", $answerid)) {
201 error("Continue: answer record not found");
203 if (lesson_iscorrect($pageid, $answer->jumpto
)) {
204 $correctanswer = true;
206 if ($lesson->custom
) {
207 if ($answer->score
> 0) {
208 $correctanswer = true;
210 $correctanswer = false;
213 $newpageid = $answer->jumpto
;
214 $response = trim($answer->response
);
215 $studentanswer = $answer->answer
;
218 case LESSON_MULTICHOICE
:
219 if ($page->qoption
) {
220 // MULTIANSWER allowed, user's answer is an array
221 if (isset($_POST['answer'])) {
222 $useranswers = $_POST['answer'];
223 foreach ($useranswers as $key => $useranswer) {
224 $useranswers[$key] = clean_param($useranswer, PARAM_INT
);
230 // get what the user answered
231 $userresponse = implode(",", $useranswers);
232 // get the answers in a set order, the id order
233 if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
234 error("Continue: No answers found");
238 $correctresponse = '';
240 // store student's answers for displaying on feedback page
241 foreach ($answers as $answer) {
242 foreach ($useranswers as $key => $answerid) {
243 if ($answerid == $answer->id
) {
244 $studentanswer .= '<br />'.$answer->answer
;
248 // this is for custom scores. If score on answer is positive, it is correct
249 if ($lesson->custom
) {
252 foreach ($answers as $answer) {
253 if ($answer->score
> 0) {
256 foreach ($useranswers as $key => $answerid) {
257 if ($answerid == $answer->id
) {
261 // save the first jumpto page id, may be needed!...
262 if (!isset($correctpageid)) {
263 // leave in its "raw" state - will converted into a proper page id later
264 $correctpageid = $answer->jumpto
;
266 // ...also save any response from the correct answers...
267 if (trim(strip_tags($answer->response
))) {
268 $correctresponse = $answer->response
;
271 // save the first jumpto page id, may be needed!...
272 if (!isset($wrongpageid)) {
273 // leave in its "raw" state - will converted into a proper page id later
274 $wrongpageid = $answer->jumpto
;
276 // ...and from the incorrect ones, don't know which to use at this stage
277 if (trim(strip_tags($answer->response
))) {
278 $wrongresponse = $answer->response
;
283 foreach ($answers as $answer) {
284 if (lesson_iscorrect($pageid, $answer->jumpto
)) {
286 foreach ($useranswers as $key => $answerid) {
287 if ($answerid == $answer->id
) {
291 // save the first jumpto page id, may be needed!...
292 if (!isset($correctpageid)) {
293 // leave in its "raw" state - will converted into a proper page id later
294 $correctpageid = $answer->jumpto
;
296 // ...also save any response from the correct answers...
297 if (trim(strip_tags($answer->response
))) {
298 $correctresponse = $answer->response
;
301 // save the first jumpto page id, may be needed!...
302 if (!isset($wrongpageid)) {
303 // leave in its "raw" state - will converted into a proper page id later
304 $wrongpageid = $answer->jumpto
;
306 // ...and from the incorrect ones, don't know which to use at this stage
307 if (trim(strip_tags($answer->response
))) {
308 $wrongresponse = $answer->response
;
313 if ((count($useranswers) == $ncorrect) and ($nhits == $ncorrect)) {
314 $correctanswer = true;
315 $response = $correctresponse;
316 $newpageid = $correctpageid;
318 $response = $wrongresponse;
319 $newpageid = $wrongpageid;
322 // only one answer allowed
323 if (empty($_POST['answerid'])) {
327 $answerid = required_param('answerid', PARAM_INT
);
328 if (!$answer = get_record("lesson_answers", "id", $answerid)) {
329 error("Continue: answer record not found");
331 if (lesson_iscorrect($pageid, $answer->jumpto
)) {
332 $correctanswer = true;
334 if ($lesson->custom
) {
335 if ($answer->score
> 0) {
336 $correctanswer = true;
338 $correctanswer = false;
341 $newpageid = $answer->jumpto
;
342 $response = trim($answer->response
);
343 $studentanswer = $answer->answer
;
346 case LESSON_MATCHING
:
347 if (isset($_POST['response']) && is_array($_POST['response'])) { // only arrays should be submitted
349 foreach ($_POST['response'] as $key => $value) {
350 $response[$key] = stripslashes($value);
357 if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
358 error("Continue: No answers found");
363 foreach ($answers as $answer) {
364 if ($i == 0 ||
$i == 1) {
365 // ignore first two answers, they are correct response
366 // and wrong response
370 if ($answer->response
== $response[$answer->id
]) {
374 $correctpageid = $answer->jumpto
;
375 $correctanswerid = $answer->id
;
378 $wrongpageid = $answer->jumpto
;
379 $wronganswerid = $answer->id
;
383 // get he users exact responses for record keeping
384 $userresponse = array();
385 foreach ($response as $key => $value) {
386 foreach($answers as $answer) {
387 if ($value == $answer->response
) {
388 $userresponse[] = $answer->id
;
391 $studentanswer .= '<br />'.$answers[$key]->answer
.' = '.$value;
393 $userresponse = implode(",", $userresponse);
395 if ($ncorrect == count($answers)-2) { // dont count correct/wrong responses in the total.
396 foreach ($answers as $answer) {
397 if ($answer->response
== NULL && $answer->answer
!= NULL) {
398 $response = $answer->answer
;
402 if (isset($correctpageid)) {
403 $newpageid = $correctpageid;
405 if (isset($correctanswerid)) {
406 $answerid = $correctanswerid;
408 $correctanswer = true;
411 foreach ($answers as $answer) {
412 if ($answer->response
== NULL && $answer->answer
!= NULL) {
414 $response = $answer->answer
;
420 $newpageid = $wrongpageid;
421 $answerid = $wronganswerid;
425 case LESSON_NUMERICAL
:
430 if (isset($_POST['answer'])) {
431 $useranswer = (float) optional_param('answer'); // just doing default PARAM_CLEAN, not doing PARAM_INT because it could be a float
436 $studentanswer = $userresponse = $useranswer;
437 if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) {
438 error("Continue: No answers found");
440 foreach ($answers as $answer) {
441 if (strpos($answer->answer
, ':')) {
442 // there's a pairs of values
443 list($min, $max) = explode(':', $answer->answer
);
444 $minimum = (float) $min;
445 $maximum = (float) $max;
447 // there's only one value
448 $minimum = (float) $answer->answer
;
451 if (($useranswer >= $minimum) and ($useranswer <= $maximum)) {
452 $newpageid = $answer->jumpto
;
453 $response = trim($answer->response
);
454 if (lesson_iscorrect($pageid, $newpageid)) {
455 $correctanswer = true;
457 if ($lesson->custom
) {
458 if ($answer->score
> 0) {
459 $correctanswer = true;
461 $correctanswer = false;
464 $answerid = $answer->id
;
470 case LESSON_BRANCHTABLE
:
472 $newpageid = optional_param('jumpto', NULL, PARAM_INT
);
473 // going to insert into lesson_branch
474 if ($newpageid == LESSON_RANDOMBRANCH
) {
479 if ($grades = get_records_select("lesson_grades", "lessonid = $lesson->id AND userid = $USER->id",
481 $retries = count($grades);
485 $branch = new stdClass
;
486 $branch->lessonid
= $lesson->id
;
487 $branch->userid
= $USER->id
;
488 $branch->pageid
= $pageid;
489 $branch->retry
= $retries;
490 $branch->flag
= $branchflag;
491 $branch->timeseen
= time();
493 if (!insert_record("lesson_branch", $branch)) {
494 error("Error: could not insert row into lesson_branch table");
497 // this is called when jumping to random from a branch table
498 if($newpageid == LESSON_UNSEENBRANCHPAGE
) {
499 if (has_capability('mod/lesson:manage', $context)) {
500 $newpageid = LESSON_NEXTPAGE
;
502 $newpageid = lesson_unseen_question_jump($lesson->id
, $USER->id
, $pageid); // this may return 0
505 // convert jumpto page into a proper page id
506 if ($newpageid == 0) {
507 $newpageid = $pageid;
508 } elseif ($newpageid == LESSON_NEXTPAGE
) {
509 if (!$newpageid = $page->nextpageid
) {
510 // no nextpage go to end of lesson
511 $newpageid = LESSON_EOL
;
513 } elseif ($newpageid == LESSON_PREVIOUSPAGE
) {
514 $newpageid = $page->prevpageid
;
515 } elseif ($newpageid == LESSON_RANDOMPAGE
) {
516 $newpageid = lesson_random_question_jump($lesson->id
, $pageid);
517 } elseif ($newpageid == LESSON_RANDOMBRANCH
) {
518 $newpageid = lesson_unseen_branch_jump($lesson->id
, $USER->id
);
520 // no need to record anything in lesson_attempts
521 redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=$newpageid");
526 $attemptsremaining = 0;
527 $maxattemptsreached = 0;
530 $newpageid = $pageid; // display same page again
532 $nretakes = count_records("lesson_grades", "lessonid", $lesson->id
, "userid", $USER->id
);
533 if (!has_capability('mod/lesson:manage', $context)) {
534 // record student's attempt
535 $attempt = new stdClass
;
536 $attempt->lessonid
= $lesson->id
;
537 $attempt->pageid
= $pageid;
538 $attempt->userid
= $USER->id
;
539 $attempt->answerid
= $answerid;
540 $attempt->retry
= $nretakes;
541 $attempt->correct
= $correctanswer;
542 if(isset($userresponse)) {
543 $attempt->useranswer
= $userresponse;
546 $attempt->timeseen
= time();
547 // dont want to insert the attempt if they ran out of time
549 // if allow modattempts, then update the old attempt record, otherwise, insert new answer record
550 if (isset($USER->modattempts
[$lesson->id
])) {
551 $attempt->retry
= $nretakes - 1; // they are going through on review, $nretakes will be too high
553 if (!$newattemptid = insert_record("lesson_attempts", $attempt)) {
554 error("Continue: attempt not inserted");
557 // "number of attempts remaining" message if $lesson->maxattempts > 1
558 // displaying of message(s) is at the end of page for more ergonomic display
559 if (!$correctanswer and ($newpageid == 0)) {
560 // wrong answer and student is stuck on this page - check how many attempts
561 // the student has had at this page/question
562 $nattempts = count_records("lesson_attempts", "pageid", $pageid, "userid", $USER->id
,
565 // retreive the number of attempts left counter for displaying at bottom of feedback page
566 if ($nattempts >= $lesson->maxattempts
) {
567 if ($lesson->maxattempts
> 1) { // don't bother with message if only one attempt
568 $maxattemptsreached = 1;
570 $newpageid = LESSON_NEXTPAGE
;
571 } else if ($lesson->maxattempts
> 1) { // don't bother with message if only one attempt
572 $attemptsremaining = $lesson->maxattempts
- $nattempts;
576 // TODO: merge this code with the jump code below. Convert jumpto page into a proper page id
577 if ($newpageid == 0) {
578 $newpageid = $pageid;
579 } elseif ($newpageid == LESSON_NEXTPAGE
) {
580 if ($lesson->nextpagedefault
) {
581 // in Flash Card mode...
582 // ... first get the page ids (lessonid the 5th param is needed to make get_records play)
583 $allpages = get_records("lesson_pages", "lessonid", $lesson->id
, "id", "id,lessonid,qtype");
586 if ($lesson->nextpagedefault
== LESSON_UNSEENPAGE
) {
587 foreach ($allpages as $thispage) {
588 if (!count_records("lesson_attempts", "pageid", $thispage->id
, "userid",
589 $USER->id
, "retry", $nretakes)) {
594 } elseif ($lesson->nextpagedefault
== LESSON_UNANSWEREDPAGE
) {
595 foreach ($allpages as $thispage) {
596 if ($thispage->qtype
== LESSON_ESSAY
) {
597 if (!count_records_select("lesson_attempts", "pageid = $thispage->id AND
598 userid = $USER->id AND retry = $nretakes")) {
603 if (!count_records_select("lesson_attempts", "pageid = $thispage->id AND
604 userid = $USER->id AND correct = 1 AND retry = $nretakes")) {
612 $newpageid = $thispage->id
;
613 if ($lesson->maxpages
) {
614 // check number of pages viewed (in the lesson)
615 if (count_records("lesson_attempts", "lessonid", $lesson->id
, "userid", $USER->id
,
616 "retry", $nretakes) >= $lesson->maxpages
) {
617 $newpageid = LESSON_EOL
;
621 $newpageid = LESSON_EOL
;
623 } elseif (!$newpageid = $page->nextpageid
) {
624 // no nextpage go to end of lesson
625 $newpageid = LESSON_EOL
;
629 // Determine default feedback if necessary
630 $nodefaultresponse = false; // Flag for redirecting when default feedback is turned off
631 if (empty($response)) {
632 if (!$lesson->feedback
and !$noanswer and !($lesson->review
and !$correctanswer and !$isessayquestion)) {
633 // These conditions have been met:
634 // 1. The lesson manager has not supplied feedback to the student
635 // 2. Not displaying default feedback
636 // 3. The user did provide an answer
637 // 4. We are not reviewing with an incorrect answer (and not reviewing an essay question)
639 $nodefaultresponse = true; // This will cause a redirect below
640 } else if ($isessayquestion) {
641 $response = get_string('defaultessayresponse', 'lesson');
642 } else if ($correctanswer) {
643 $response = get_string('thatsthecorrectanswer', 'lesson');
645 $response = get_string('thatsthewronganswer', 'lesson');
649 // display response (if there is one - there should be!)
650 // display: lesson title, page title, question text, student's answer(s) before feedback message
653 $feedback = get_string('noanswer', 'lesson');
654 } else if ($response) {
655 //optionally display question page title
656 //if ($title = get_field("lesson_pages", "title", "id", $pageid)) {
657 // print_heading($title);
659 if ($lesson->review
and !$correctanswer and !$isessayquestion) {
660 $nretakes = count_records("lesson_grades", "lessonid", $lesson->id
, "userid", $USER->id
);
661 $qattempts = count_records("lesson_attempts", "userid", $USER->id
, "retry", $nretakes, "pageid", $pageid);
662 if ($qattempts == 1) {
663 $feedback = get_string("firstwrong", "lesson");
665 $feedback = get_string("secondpluswrong", "lesson");
668 if ($correctanswer) {
669 $class = 'response correct'; //CSS over-ride this if they exist (!important)
670 } else if ($isessayquestion) {
673 $class = 'response incorrect';
675 $options = new stdClass
;
676 $options->noclean
= true;
677 $options->para
= true;
678 $feedback = print_simple_box(format_text($page->contents
, FORMAT_MOODLE
, $options), 'center', '', '', 5, 'generalbox', '', true);
679 $feedback .= '<em>'.get_string("youranswer", "lesson").'</em> : '.format_text($studentanswer, FORMAT_MOODLE
, $options).
680 "<div class=\"$class\">".format_text($response, FORMAT_MOODLE
, $options).'</div>';
685 // TODO: merge with the jump code above. This is where some jump numbers are interpreted
687 $newpageid = LESSON_EOL
; // ran out of time for the test, so go to eol
688 } elseif (isset($USER->modattempts
[$lesson->id
])) {
689 // make sure if the student is reviewing, that he/she sees the same pages/page path that he/she saw the first time
690 if ($USER->modattempts
[$lesson->id
] == $pageid) { // remember, this session variable holds the pageid of the last page that the user saw
691 $newpageid = LESSON_EOL
;
693 $nretakes--; // make sure we are looking at the right try.
694 $attempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND userid = $USER->id AND retry = $nretakes", "timeseen", "id, pageid");
697 foreach($attempts as $attempt) {
698 if ($found && $temppageid != $attempt->pageid
) { // now try to find the next page, make sure next few attempts do no belong to current page
699 $newpageid = $attempt->pageid
;
702 if ($attempt->pageid
== $pageid) {
703 $found = true; // if found current page
704 $temppageid = $attempt->pageid
;
708 } elseif ($newpageid != LESSON_CLUSTERJUMP
&& $pageid != 0 && $newpageid > 0) { // going to check to see if the page that the user is going to view next, is a cluster page. If so, dont display, go into the cluster. The $newpageid > 0 is used to filter out all of the negative code jumps.
709 if (!$page = get_record("lesson_pages", "id", $newpageid)) {
710 error("Error: could not find page");
712 if ($page->qtype
== LESSON_CLUSTER
) {
713 $newpageid = lesson_cluster_jump($lesson->id
, $USER->id
, $page->id
);
714 } elseif ($page->qtype
== LESSON_ENDOFCLUSTER
) {
715 $jump = get_field("lesson_answers", "jumpto", "pageid", $page->id
, "lessonid", $lesson->id
);
716 if ($jump == LESSON_NEXTPAGE
) {
717 if ($page->nextpageid
== 0) {
718 $newpageid = LESSON_EOL
;
720 $newpageid = $page->nextpageid
;
726 } elseif ($newpageid == LESSON_UNSEENBRANCHPAGE
) {
727 if (has_capability('mod/lesson:manage', $context)) {
728 if ($page->nextpageid
== 0) {
729 $newpageid = LESSON_EOL
;
731 $newpageid = $page->nextpageid
;
734 $newpageid = lesson_unseen_question_jump($lesson->id
, $USER->id
, $pageid);
736 } elseif ($newpageid == LESSON_PREVIOUSPAGE
) {
737 $newpageid = $page->prevpageid
;
738 } elseif ($newpageid == LESSON_RANDOMPAGE
) {
739 $newpageid = lesson_random_question_jump($lesson->id
, $pageid);
740 } elseif ($newpageid == LESSON_CLUSTERJUMP
) {
741 if (has_capability('mod/lesson:manage', $context)) {
742 if ($page->nextpageid
== 0) { // if teacher, go to next page
743 $newpageid = LESSON_EOL
;
745 $newpageid = $page->nextpageid
;
748 $newpageid = lesson_cluster_jump($lesson->id
, $USER->id
, $pageid);
752 if ($nodefaultresponse) {
753 // Don't display feedback
754 redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=$newpageid");
759 // This is the warning msg for teachers to inform them that cluster and unseen does not work while logged in as a teacher
760 if(has_capability('mod/lesson:manage', $context) and lesson_display_teacher_warning($lesson->id
)) {
761 $warningvars->cluster
= get_string("clusterjump", "lesson");
762 $warningvars->unseen
= get_string("unseenpageinbranch", "lesson");
763 lesson_set_message(get_string("teacherjumpwarning", "lesson", $warningvars));
765 // Inform teacher that s/he will not see the timer
766 if ($lesson->timed
and has_capability('mod/lesson:manage', $context)) {
767 lesson_set_message(get_string("teachertimerwarning", "lesson"));
769 // Report attempts remaining
770 if ($attemptsremaining != 0) {
771 lesson_set_message(get_string('attemptsremaining', 'lesson', $attemptsremaining));
773 // Report if max attempts reached
774 if ($maxattemptsreached != 0) {
775 lesson_set_message('('.get_string("maximumnumberofattemptsreached", "lesson").')');
778 $PAGE = page_create_object('mod-lesson-view', $lesson->id
);
779 $PAGE->set_lessonpageid($page->id
);
780 $pageblocks = blocks_setup($PAGE);
782 $leftcolumnwidth = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT
]), 210);
783 $rightcolumnwidth = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT
]), 210);
785 /// Print the header, heading and tabs
786 $PAGE->print_header();
788 include(dirname(__FILE__
).'/continue.html');