From: nicolasconnault
Date: Mon, 10 Aug 2009 05:00:11 +0000 (+0000)
Subject: MDL-19812 Converted print_box* to $OUTPUT->box*
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=fe75e76b8fd771604d3569b8724f58fdd211bfc4;p=moodle.git
MDL-19812 Converted print_box* to $OUTPUT->box*
---
diff --git a/mod/lesson/action/continue.php b/mod/lesson/action/continue.php
index 6bfe5d6302..ba84035d50 100644
--- a/mod/lesson/action/continue.php
+++ b/mod/lesson/action/continue.php
@@ -24,7 +24,7 @@
} else {
$timer = array_pop($timer); // this will get the latest start time record
}
-
+
if ($lesson->timed) {
$timeleft = ($timer->starttime + $lesson->maxtime * 60) - time();
@@ -38,7 +38,7 @@
lesson_set_message(get_string("studentoneminwarning", "lesson"));
}
}
-
+
$timer->lessontime = time();
$DB->update_record("lesson_timer", $timer);
}
@@ -63,7 +63,7 @@
break;
}
$useranswer = clean_param($useranswer, PARAM_RAW);
-
+
if (!$answers = $DB->get_records("lesson_answers", array("pageid" => $pageid), "id")) {
print_error("Continue: No answers found");
}
@@ -79,7 +79,7 @@
$userresponse->answer = $useranswer;
$userresponse->response = "";
$userresponse = serialize($userresponse);
-
+
$studentanswer = s($useranswer);
break;
case LESSON_SHORTANSWER :
@@ -88,7 +88,7 @@
} else {
$noanswer = true;
break;
- }
+ }
$useranswer = s(clean_param($useranswer, PARAM_RAW));
if (!$answers = $DB->get_records("lesson_answers", array("pageid" => $pageid), "id")) {
print_error("Continue: No answers found");
@@ -97,14 +97,14 @@
foreach ($answers as $answer) {
$i += 1;
$expectedanswer = $answer->answer; // for easier handling of $answer->answer
- $ismatch = false;
- $markit = false;
+ $ismatch = false;
+ $markit = false;
$useregexp = false;
if ($page->qoption) {
$useregexp = true;
}
-
+
if ($useregexp) { //we are using 'normal analysis', which ignores case
$ignorecase = '';
if ( substr($expectedanswer,strlen($expectedanswer) - 2, 2) == '/i') {
@@ -145,7 +145,7 @@
if (!preg_match('/^'.$expectedanswer.'$/'.$ignorecase,$useranswer)) {
$ismatch = true;
}
- break;
+ break;
//2- check for code for marking wrong strings (coded by initial '++')
case "++":
$expectedanswer=substr($expectedanswer,2);
@@ -154,7 +154,7 @@
if (preg_match_all('/'.$expectedanswer.'/'.$ignorecase,$useranswer, $matches)) {
$ismatch = true;
$nb = count($matches[0]);
- $original = array();
+ $original = array();
$marked = array();
$fontStart = '';
$fontEnd = ' ';
@@ -165,7 +165,7 @@
$useranswer = str_replace($original, $marked, $useranswer);
}
break;
- //3- check for wrong answers belonging neither to -- nor to ++ categories
+ //3- check for wrong answers belonging neither to -- nor to ++ categories
default:
if (preg_match('/^'.$expectedanswer.'$/'.$ignorecase,$useranswer, $matches)) {
$ismatch = true;
@@ -186,16 +186,16 @@
}
$studentanswer = $useranswer;
break;
-
+
case LESSON_TRUEFALSE :
if (empty($_POST['answerid'])) {
$noanswer = true;
break;
}
- $answerid = required_param('answerid', PARAM_INT);
+ $answerid = required_param('answerid', PARAM_INT);
if (!$answer = $DB->get_record("lesson_answers", array("id" => $answerid))) {
print_error("Continue: answer record not found");
- }
+ }
if (lesson_iscorrect($pageid, $answer->jumpto)) {
$correctanswer = true;
}
@@ -210,7 +210,7 @@
$response = trim($answer->response);
$studentanswer = $answer->answer;
break;
-
+
case LESSON_MULTICHOICE :
if ($page->qoption) {
// MULTIANSWER allowed, user's answer is an array
@@ -243,21 +243,21 @@
}
}
}
- // this is for custom scores. If score on answer is positive, it is correct
+ // this is for custom scores. If score on answer is positive, it is correct
if ($lesson->custom) {
$ncorrect = 0;
$nhits = 0;
foreach ($answers as $answer) {
if ($answer->score > 0) {
$ncorrect++;
-
+
foreach ($useranswers as $key => $answerid) {
if ($answerid == $answer->id) {
$nhits++;
}
}
// save the first jumpto page id, may be needed!...
- if (!isset($correctpageid)) {
+ if (!isset($correctpageid)) {
// leave in its "raw" state - will converted into a proper page id later
$correctpageid = $answer->jumpto;
}
@@ -271,7 +271,7 @@
}
} else {
// save the first jumpto page id, may be needed!...
- if (!isset($wrongpageid)) {
+ if (!isset($wrongpageid)) {
// leave in its "raw" state - will converted into a proper page id later
$wrongpageid = $answer->jumpto;
}
@@ -284,7 +284,7 @@
$wrongresponse = $answer->response;
}
}
- }
+ }
} else {
foreach ($answers as $answer) {
if (lesson_iscorrect($pageid, $answer->jumpto)) {
@@ -295,7 +295,7 @@
}
}
// save the first jumpto page id, may be needed!...
- if (!isset($correctpageid)) {
+ if (!isset($correctpageid)) {
// leave in its "raw" state - will converted into a proper page id later
$correctpageid = $answer->jumpto;
}
@@ -309,7 +309,7 @@
}
} else {
// save the first jumpto page id, may be needed!...
- if (!isset($wrongpageid)) {
+ if (!isset($wrongpageid)) {
// leave in its "raw" state - will converted into a proper page id later
$wrongpageid = $answer->jumpto;
}
@@ -340,7 +340,7 @@
$noanswer = true;
break;
}
- $answerid = required_param('answerid', PARAM_INT);
+ $answerid = required_param('answerid', PARAM_INT);
if (!$answer = $DB->get_record("lesson_answers", array("id" => $answerid))) {
print_error("Continue: answer record not found");
}
@@ -392,7 +392,7 @@
}
if ($i == 3) {
$wrongpageid = $answer->jumpto;
- $wronganswerid = $answer->id;
+ $wronganswerid = $answer->id;
}
$i++;
}
@@ -487,7 +487,7 @@
case LESSON_BRANCHTABLE:
$noanswer = false;
$newpageid = optional_param('jumpto', NULL, PARAM_INT);
- // going to insert into lesson_branch
+ // going to insert into lesson_branch
if ($newpageid == LESSON_RANDOMBRANCH) {
$branchflag = 1;
} else {
@@ -507,7 +507,7 @@
$branch->retry = $retries;
$branch->flag = $branchflag;
$branch->timeseen = time();
-
+
$DB->insert_record("lesson_branch", $branch);
// this is called when jumping to random from a branch table
@@ -533,10 +533,10 @@
} elseif ($newpageid == LESSON_RANDOMBRANCH) {
$newpageid = lesson_unseen_branch_jump($lesson->id, $USER->id);
}
- // no need to record anything in lesson_attempts
+ // no need to record anything in lesson_attempts
redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=$newpageid");
break;
-
+
}
$attemptsremaining = 0;
@@ -547,7 +547,7 @@
$newpageid = $pageid; // display same page again
$feedback = get_string('noanswer', 'lesson');
} else {
- $nretakes = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
+ $nretakes = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
if (!has_capability('mod/lesson:manage', $context)) {
// record student's attempt
$attempt = new stdClass;
@@ -560,7 +560,7 @@
if(isset($userresponse)) {
$attempt->useranswer = $userresponse;
}
-
+
$attempt->timeseen = time();
// if allow modattempts, then update the old attempt record, otherwise, insert new answer record
if (isset($USER->modattempts[$lesson->id])) {
@@ -570,11 +570,11 @@
// "number of attempts remaining" message if $lesson->maxattempts > 1
// displaying of message(s) is at the end of page for more ergonomic display
if (!$correctanswer and ($newpageid == 0)) {
- // wrong answer and student is stuck on this page - check how many attempts
+ // wrong answer and student is stuck on this page - check how many attempts
// the student has had at this page/question
$nattempts = $DB->count_records("lesson_attempts", array("pageid"=>$pageid, "userid"=>$USER->id),
"retry", $nretakes);
-
+
// retreive the number of attempts left counter for displaying at bottom of feedback page
if ($nattempts >= $lesson->maxattempts) {
if ($lesson->maxattempts > 1) { // don't bother with message if only one attempt
@@ -610,7 +610,7 @@
$found = true;
break;
}
- } else {
+ } else {
if (!$DB->count_records("lesson_attempts", array('pageid'=>$thispage->id, 'userid'=>$USER->id, 'correct'=>1, 'retry'=>$nretakes))) {
$found = true;
break;
@@ -644,7 +644,7 @@
// 2. Not displaying default feedback
// 3. The user did provide an answer
// 4. We are not reviewing with an incorrect answer (and not reviewing an essay question)
-
+
$nodefaultresponse = true; // This will cause a redirect below
} else if ($isessayquestion) {
$response = get_string('defaultessayresponse', 'lesson');
@@ -657,14 +657,14 @@
// display response (if there is one - there should be!)
// display: lesson title, page title, question text, student's answer(s) before feedback message
-
+
if ($response) {
//optionally display question page title
//if ($title = $DB->get_field("lesson_pages", "title", array("id" => $pageid))) {
// print_heading($title);
//}
if ($lesson->review and !$correctanswer and !$isessayquestion) {
- $nretakes = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
+ $nretakes = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
$qattempts = $DB->count_records("lesson_attempts", array("userid"=>$USER->id, "retry"=>$nretakes, "pageid"=>$pageid));
if ($qattempts == 1) {
$feedback = get_string("firstwrong", "lesson");
@@ -677,12 +677,12 @@
} else if ($isessayquestion) {
$class = 'response';
} else {
- $class = 'response incorrect';
+ $class = 'response incorrect';
}
$options = new stdClass;
$options->noclean = true;
$options->para = true;
- $feedback = print_box(format_text($page->contents, FORMAT_MOODLE, $options), 'generalbox boxaligncenter', '', true);
+ $feedback = $OUTPUT->box(format_text($page->contents, FORMAT_MOODLE, $options), 'generalbox boxaligncenter');
$feedback .= ''.get_string("youranswer", "lesson").' : '.format_text($studentanswer, FORMAT_MOODLE, $options).
"".format_text($response, FORMAT_MOODLE, $options).'
';
}
@@ -738,7 +738,7 @@
}
} else {
$newpageid = lesson_unseen_question_jump($lesson->id, $USER->id, $pageid);
- }
+ }
} elseif ($newpageid == LESSON_PREVIOUSPAGE) {
$newpageid = $page->prevpageid;
} elseif ($newpageid == LESSON_RANDOMPAGE) {
@@ -749,17 +749,17 @@
$newpageid = LESSON_EOL;
} else {
$newpageid = $page->nextpageid;
- }
+ }
} else {
$newpageid = lesson_cluster_jump($lesson->id, $USER->id, $pageid);
}
}
-
+
if ($nodefaultresponse) {
// Don't display feedback
redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=$newpageid");
}
-
+
/// Set Messages
// This is the warning msg for teachers to inform them that cluster and unseen does not work while logged in as a teacher
@@ -777,7 +777,7 @@
lesson_set_message(get_string('attemptsremaining', 'lesson', $attemptsremaining));
}
// Report if max attempts reached
- if ($maxattemptsreached != 0) {
+ if ($maxattemptsreached != 0) {
lesson_set_message('('.get_string("maximumnumberofattemptsreached", "lesson").')');
}
diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php
index 58349af0e9..4fb86ffd0c 100644
--- a/mod/lesson/lib.php
+++ b/mod/lesson/lib.php
@@ -27,7 +27,7 @@
require_once($CFG->libdir.'/eventslib.php');
/** LESSON_MAX_EVENT_LENGTH = 432000 ; 5 days maximum */
-define("LESSON_MAX_EVENT_LENGTH", "432000");
+define("LESSON_MAX_EVENT_LENGTH", "432000");
/**
* Given an object containing all the necessary data,
@@ -180,7 +180,7 @@ function lesson_delete_course($course, $feedback=true) {
*/
function lesson_user_outline($course, $user, $mod, $lesson) {
global $DB;
-
+
$params = array ("lessonid" => $lesson->id, "userid" => $user->id);
if ($grades = $DB->get_records_select("lesson_grades", "lessonid = :lessonid AND userid = :userid", $params,
"grade DESC")) {
@@ -214,7 +214,7 @@ function lesson_user_outline($course, $user, $mod, $lesson) {
*/
function lesson_user_complete($course, $user, $mod, $lesson) {
global $DB;
-
+
$params = array ("lessonid" => $lesson->id, "userid" => $user->id);
if ($attempts = $DB->get_records_select("lesson_attempts", "lessonid = :lessonid AND userid = :userid", $params,
"retry, timeseen")) {
@@ -293,7 +293,7 @@ function lesson_user_complete($course, $user, $mod, $lesson) {
* @return void
*/
function lesson_print_overview($courses, &$htmlarray) {
- global $USER, $CFG, $DB;
+ global $USER, $CFG, $DB, $OUTPUT;
if (!$lessons = get_all_instances_in_courses('lesson', $courses)) {
return;
@@ -316,26 +316,26 @@ function lesson_print_overview($courses, &$htmlarray) {
} else {
$class = '';
}
- $str = print_box("$strlesson: wwwroot/mod/lesson/view.php?id=$lesson->coursemodule\">".
- format_string($lesson->name).' ', 'name', '', true);
+ $str = $OUTPUT->box("$strlesson: wwwroot/mod/lesson/view.php?id=$lesson->coursemodule\">".
+ format_string($lesson->name).' ', 'name');
// Deadline
- $str .= print_box(get_string('lessoncloseson', 'lesson', userdate($lesson->deadline)), 'info', '', true);
+ $str .= $OUTPUT->box(get_string('lessoncloseson', 'lesson', userdate($lesson->deadline)), 'info');
// Attempt information
if (has_capability('mod/lesson:manage', get_context_instance(CONTEXT_MODULE, $lesson->coursemodule))) {
// Number of user attempts
$attempts = $DB->count_records('lesson_attempts', array('lessonid'=>$lesson->id));
- $str .= print_box(get_string('xattempts', 'lesson', $attempts), 'info', '', true);
+ $str .= $OUTPUT->box(get_string('xattempts', 'lesson', $attempts), 'info');
} else {
// Determine if the user has attempted the lesson or not
if ($DB->count_records('lesson_attempts', array('lessonid'=>$lesson->id, 'userid'=>$USER->id))) {
- $str .= print_box($strattempted, 'info', '', true);
+ $str .= $OUTPUT->box($strattempted, 'info');
} else {
- $str .= print_box($strnotattempted, 'info', '', true);
+ $str .= $OUTPUT->box($strnotattempted, 'info');
}
}
- $str = print_box($str, 'lesson overview', '', true);
+ $str = $OUTPUT->box($str, 'lesson overview');
if (empty($htmlarray[$lesson->course]['lesson'])) {
$htmlarray[$lesson->course]['lesson'] = $str;
@@ -372,7 +372,7 @@ function lesson_get_user_grades($lesson, $userid=0) {
global $CFG, $DB;
$params = array("lessonid" => $lesson->id,"lessonid2" => $lesson->id);
-
+
if (isset($userid)) {
$params["userid"] = $userid;
$params["userid2"] = $userid;
@@ -383,7 +383,7 @@ function lesson_get_user_grades($lesson, $userid=0) {
$user="";
$fuser="";
}
-
+
if ($lesson->retake) {
if ($lesson->usemaxgrade) {
$sql = "SELECT u.id, u.id AS userid, MAX(g.grade) AS rawgrade
@@ -593,7 +593,7 @@ function lesson_get_post_actions() {
**/
function lesson_process_pre_save(&$lesson) {
global $DB;
-
+
$lesson->timemodified = time();
if (empty($lesson->timed)) {
@@ -667,9 +667,9 @@ function lesson_process_post_save(&$lesson) {
$event->instance = $lesson->id;
$event->eventtype = 'open';
$event->timestart = $lesson->available;
-
+
$event->visible = instance_is_visible('lesson', $lesson);
-
+
$event->timeduration = ($lesson->deadline - $lesson->available);
if ($lesson->deadline and $lesson->available and $event->timeduration <= LESSON_MAX_EVENT_LENGTH) {
@@ -697,7 +697,7 @@ function lesson_process_post_save(&$lesson) {
/**
* Implementation of the function for printing the form elements that control
* whether the course reset functionality affects the lesson.
- *
+ *
* @param $mform form passed by reference
*/
function lesson_reset_course_form_definition(&$mform) {
diff --git a/mod/lesson/view.php b/mod/lesson/view.php
index edf4aca81d..6f605198ed 100644
--- a/mod/lesson/view.php
+++ b/mod/lesson/view.php
@@ -16,11 +16,11 @@
$pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID
$edit = optional_param('edit', -1, PARAM_BOOL);
$userpassword = optional_param('userpassword','',PARAM_CLEAN);
-
+
list($cm, $course, $lesson) = lesson_get_basics($id);
require_login($course->id, false, $cm);
-
+
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// Check these for students only TODO: Find a better method for doing this!
@@ -37,17 +37,17 @@
} else {
$message = get_string('lessonopen', 'lesson', userdate($lesson->available));
}
-
+
lesson_print_header($cm, $course, $lesson);
- print_box_start('generalbox boxaligncenter');
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
echo '';
echo '
'.$message.'
';
echo '
';
echo '
';
- print_box_end();
+ echo $OUTPUT->box_end();
echo $OUTPUT->footer();
exit();
-
+
} else if ($lesson->usepassword and empty($USER->lessonloggedin[$lesson->id])) { // Password protected lesson code
$correctpass = false;
if (!empty($userpassword)) {
@@ -65,7 +65,7 @@
if (!$correctpass) {
lesson_print_header($cm, $course, $lesson);
echo "\n";
- print_box_start('generalbox boxaligncenter');
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
echo '';
- print_box_end();
+ echo $OUTPUT->box_end();
echo "
\n";
echo $OUTPUT->footer();
exit();
}
-
+
} else if ($lesson->dependency) { // check for dependencies
if ($dependentlesson = $DB->get_record('lesson', array('id' => $lesson->dependency))) {
- // lesson exists, so we can proceed
+ // lesson exists, so we can proceed
$conditions = unserialize($lesson->conditions);
// assume false for all
$timespent = false;
@@ -104,7 +104,7 @@
$timespent = true;
}
}
- }
+ }
} else {
$timespent = true; // there isn't one set
}
@@ -147,22 +147,22 @@
if (!empty($errors)) { // print out the errors if any
lesson_print_header($cm, $course, $lesson);
echo '';
- print_box_start('generalbox boxaligncenter');
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
print_string('completethefollowingconditions', 'lesson', $dependentlesson->name);
echo '
'.implode(' '.get_string('and', 'lesson').' ', $errors).'
';
- print_box_end();
+ echo $OUTPUT->box_end();
echo '
';
echo $OUTPUT->footer();
exit();
- }
+ }
}
-
+
} else if ($lesson->highscores and !$lesson->practice and !optional_param('viewed', 0) and empty($pageid)) {
// Display high scores before starting lesson
redirect("$CFG->wwwroot/mod/lesson/highscores.php?id=$cm->id");
}
}
-
+
// set up some general variables
$path = $CFG->wwwroot .'/course';
@@ -170,7 +170,7 @@
if($pageid == LESSON_UNSEENBRANCHPAGE) {
$pageid = lesson_unseen_question_jump($lesson->id, $USER->id, $pageid);
}
-
+
// display individual pages and their sets of answers
// if pageid is EOL then the end of the lesson has been reached
// for flow, changed to simple echo for flow styles, michaelp, moved lesson name and page title down
@@ -188,9 +188,9 @@
}
}
}
-
+
add_to_log($course->id, 'lesson', 'start', 'view.php?id='. $cm->id, $lesson->id, $cm->id);
-
+
// if no pageid given see if the lesson has been started
$params = array ("lessonid" => $lesson->id, "userid" => $USER->id);
if ($grades = $DB->get_records_select('lesson_grades', 'lessonid = :lessonid AND userid = :userid', $params,
@@ -202,17 +202,17 @@
if ($retries) {
$attemptflag = true;
}
-
- if (isset($USER->modattempts[$lesson->id])) {
+
+ if (isset($USER->modattempts[$lesson->id])) {
unset($USER->modattempts[$lesson->id]); // if no pageid, then student is NOT reviewing
}
-
+
// if there are any questions have been answered correctly in this attempt
$params = array ("lessonid" => $lesson->id, "userid" => $USER->id, "retry" => $retries);
- if ($attempts = $DB->get_records_select('lesson_attempts',
- "lessonid = :lessonid AND userid = :userid AND retry = :retry AND
+ if ($attempts = $DB->get_records_select('lesson_attempts',
+ "lessonid = :lessonid AND userid = :userid AND retry = :retry AND
correct = 1", $params, 'timeseen DESC')) {
-
+
foreach ($attempts as $attempt) {
$jumpto = $DB->get_field('lesson_answers', 'jumpto', array('id' => $attempt->answerid));
// convert the jumpto to a proper page id
@@ -226,14 +226,14 @@
} else {
$lastpageseen = $jumpto;
}
- break; // only look at the latest correct attempt
+ break; // only look at the latest correct attempt
}
} else {
$attempts = NULL;
}
$params = array ("lessonid" => $lesson->id, "userid" => $USER->id, "retry" => $retries);
- if ($branchtables = $DB->get_records_select('lesson_branch',
+ if ($branchtables = $DB->get_records_select('lesson_branch',
"lessonid = :lessonid AND userid = :userid AND retry = :retry", $params, 'timeseen DESC')) {
// in here, user has viewed a branch table
$lastbranchtable = current($branchtables);
@@ -260,23 +260,23 @@
lesson_print_header($cm, $course, $lesson);
if ($lesson->timed) {
if ($lesson->retake) {
- print_box(''. get_string('leftduringtimed', 'lesson') .'
', 'generalbox boxaligncenter');
+ echo $OUTPUT->box(''. get_string('leftduringtimed', 'lesson') .'
', 'generalbox boxaligncenter');
echo '';
} else {
- print_box_start('generalbox boxaligncenter');
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
echo '';
echo get_string('leftduringtimednoretake', 'lesson');
echo '
';
echo '
';
- print_box_end();
+ echo $OUTPUT->box_end();
}
-
+
} else {
- print_box("".get_string('youhaveseen','lesson').'
',
+ echo $OUTPUT->box("".get_string('youhaveseen','lesson').'
',
'generalbox boxaligncenter');
-
+
echo '';
echo '
'.
''.
@@ -289,7 +289,7 @@
echo $OUTPUT->footer();
exit();
}
-
+
if ($grades) {
foreach ($grades as $grade) {
$bestgrade = $grade->grade;
@@ -297,12 +297,12 @@
}
if (!$lesson->retake) {
lesson_print_header($cm, $course, $lesson, 'view');
- print_box_start('generalbox boxaligncenter');
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
echo "";
echo get_string("noretake", "lesson");
echo "
';
echo "
";
- print_box_end();
+ echo $OUTPUT->box_end();
echo $OUTPUT->footer();
exit();
//redirect("../../course/view.php?id=$course->id", get_string("alreadytaken", "lesson"));
@@ -324,7 +324,7 @@
$startlesson->userid = $USER->id;
$startlesson->starttime = time();
$startlesson->lessontime = time();
-
+
$DB->insert_record('lesson_timer', $startlesson);
if ($lesson->timed) {
lesson_set_message(get_string('maxtimewarning', 'lesson', $lesson->maxtime), 'center');
@@ -346,9 +346,9 @@
$DB->delete_records('lesson_branch', array('userid' => $USER->id, 'lessonid' => $lesson->id, 'retry' => $retries));
}
}
-
+
add_to_log($course->id, 'lesson', 'view', 'view.php?id='. $cm->id, $pageid, $cm->id);
-
+
if (!$page = $DB->get_record('lesson_pages', array('id' => $pageid))) {
print_error('cannotfindpages', 'lesson');
}
@@ -387,14 +387,14 @@
if (!has_capability('mod/lesson:manage', $context)) {
$answer->jumpto = lesson_cluster_jump($lesson->id, $USER->id, $pageid);
} else {
- if ($page->nextpageid == 0) {
+ if ($page->nextpageid == 0) {
$answer->jumpto = LESSON_EOL;
} else {
$answer->jumpto = $page->nextpageid;
}
}
} else if ($answer->jumpto == LESSON_NEXTPAGE) {
- if ($page->nextpageid == 0) {
+ if ($page->nextpageid == 0) {
$answer->jumpto = LESSON_EOL;
} else {
$answer->jumpto = $page->nextpageid;
@@ -402,24 +402,24 @@
} else if ($answer->jumpto == 0) {
$answer->jumpto = $page->id;
} else if ($answer->jumpto == LESSON_PREVIOUSPAGE) {
- $answer->jumpto = $page->prevpageid;
+ $answer->jumpto = $page->prevpageid;
}
redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&pageid=$answer->jumpto");
break;
- }
+ }
} else {
print_error('cannotfindanswer', 'lesson');
}
}
-
+
// check to see if the user can see the left menu
if (!has_capability('mod/lesson:manage', $context)) {
$lesson->displayleft = lesson_displayleftif($lesson);
}
-
+
// This is where several messages (usually warnings) are displayed
// all of this is displayed above the actual page
-
+
// clock code
// get time information for this user
$timer = new stdClass;
@@ -441,7 +441,7 @@
$timer->starttime = time();
$timer->lessontime = time();
}
-
+
// for timed lessons, display clock
if ($lesson->timed) {
if(has_capability('mod/lesson:manage', $context)) {
@@ -475,14 +475,14 @@
lesson_set_message(get_string('teacherjumpwarning', 'lesson', $warningvars));
}
}
-
+
if ($page->qtype == LESSON_BRANCHTABLE) {
if ($lesson->minquestions and !has_capability('mod/lesson:manage', $context)) {
// tell student how many questions they have seen, how many are required and their grade
$ntries = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
-
+
$gradeinfo = lesson_grade($lesson, $ntries);
-
+
if ($gradeinfo->attempts) {
if ($gradeinfo->nquestions < $lesson->minquestions) {
$a = new stdClass;
@@ -528,24 +528,24 @@
'; height: ' . $lesson->height . 'px; width: ' . $lesson->width . 'px;">';
}
- // now starting to print the page's contents
+ // now starting to print the page's contents
if ($page->qtype == LESSON_BRANCHTABLE) {
echo $OUTPUT->heading(format_string($page->title));
} else {
$lesson->slideshow = false; // turn off slide show for all pages other than LESSON_BRANTCHTABLE
}
-
+
if (!$lesson->slideshow) {
$options = new stdClass;
$options->noclean = true;
- print_box(''.
+ echo $OUTPUT->box('
'.
format_text($page->contents, FORMAT_MOODLE, $options).
'
', 'generalbox boxaligncenter');
}
-
+
// this is for modattempts option. Find the users previous answer to this page,
// and then display it below in answer processing
- if (isset($USER->modattempts[$lesson->id])) {
+ if (isset($USER->modattempts[$lesson->id])) {
$retries = $DB->count_records('lesson_grades', array("lessonid"=>$lesson->id, "userid"=>$USER->id));
$retries--;
$params = array ("lessonid" => $lesson->id, "userid" => $USER->id, "pageid" => $page->id, "retry" => $retries);
@@ -554,7 +554,7 @@
}
$attempt = end($attempts);
}
-
+
// get the answers in a set order, the id order
if ($answers = $DB->get_records("lesson_answers", array("pageid" => $page->id), "id")) {
if ($page->qtype != LESSON_BRANCHTABLE) { // To fix XHTML problem (BT have their own forms)
@@ -564,7 +564,7 @@
echo "
";
echo "
";
echo "
";
- print_box_start('generalbox boxaligncenter');
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
echo '
';
- print_box_end();
+ echo $OUTPUT->box_end();
lesson_print_submit_link(get_string('pleaseenteryouranswerinthebox', 'lesson'), 'answerform');
break;
case LESSON_TRUEFALSE :
@@ -595,18 +595,18 @@
$checked = 'checked="checked"';
} else {
$checked = '';
- }
+ }
echo "
id}\" $checked />";
echo "
";
echo "".format_text(trim($answer->answer), FORMAT_MOODLE, $options).' ';
echo ' ';
if ($answer != end($answers)) {
- echo "
";
+ echo "
";
}
$i++;
}
echo '';
- print_box_end();
+ echo $OUTPUT->box_end();
lesson_print_submit_link(get_string('pleasecheckoneanswer', 'lesson'), 'answerform');
break;
case LESSON_MULTICHOICE :
@@ -625,27 +625,27 @@
$checked = '';
}
}
- // more than one answer allowed
+ // more than one answer allowed
echo "
id}\"$checked />";
} else {
if (isset($USER->modattempts[$lesson->id]) && $answer->id == $attempt->answerid) {
$checked = ' checked="checked"';
} else {
$checked = '';
- }
+ }
// only one answer allowed
echo "
id}\"$checked />";
}
echo '
';
- echo "".format_text(trim($answer->answer), FORMAT_MOODLE, $options).' ';
+ echo "".format_text(trim($answer->answer), FORMAT_MOODLE, $options).' ';
echo ' ';
if ($answer != end($answers)) {
echo '
';
- }
+ }
$i++;
}
echo '';
- print_box_end();
+ echo $OUTPUT->box_end();
if ($page->qoption) {
$linkname = get_string('pleasecheckoneormoreanswers', 'lesson');
} else {
@@ -653,7 +653,7 @@
}
lesson_print_submit_link($linkname, 'answerform');
break;
-
+
case LESSON_MATCHING :
// don't suffle answers (could be an option??)
foreach ($answers as $answer) {
@@ -662,11 +662,11 @@
$responses[] = trim($answer->response);
}
}
-
+
$responseoptions = array();
if (!empty($responses)) {
shuffle($responses);
- $responses = array_unique($responses);
+ $responses = array_unique($responses);
foreach ($responses as $response) {
$responseoptions[htmlspecialchars(trim($response))] = $response;
}
@@ -692,14 +692,14 @@
echo '';
if ($answer != end($answers)) {
echo '
';
- }
+ }
}
}
echo '';
- print_box_end();
+ echo $OUTPUT->box_end();
lesson_print_submit_link(get_string('pleasematchtheabovepairs', 'lesson'), 'answerform');
break;
- case LESSON_BRANCHTABLE :
+ case LESSON_BRANCHTABLE :
$options = new stdClass;
$options->para = false;
$buttons = array();
@@ -716,22 +716,22 @@
lesson_print_submit_link(strip_tags(format_text($answer->answer, FORMAT_MOODLE, $options)), "answerform$i", '', '', '', '', true).
'
'.
'';
-
+
$buttons[] = $button;
$i++;
}
-
+
/// Set the orientation
if ($page->layout) {
$orientation = 'horizontal';
} else {
$orientation = 'vertical';
}
-
+
$fullbuttonhtml = "\n\n" .
implode("\n", $buttons).
"\n
\n";
-
+
if ($lesson->slideshow) {
$options = new stdClass;
$options->noclean = true;
@@ -741,7 +741,7 @@
} else {
echo $fullbuttonhtml;
}
-
+
break;
case LESSON_ESSAY :
if (isset($USER->modattempts[$lesson->id])) {
@@ -753,17 +753,17 @@
echo ''.get_string("youranswer", "lesson").' :'.
'\n";
echo ' ';
- print_box_end();
+ echo $OUTPUT->box_end();
lesson_print_submit_link(get_string('pleaseenteryouranswerinthebox', 'lesson'), 'answerform');
break;
default: // close the tags MDL-7861
echo ('');
- print_box_end();
+ echo $OUTPUT->box_end();
break;
}
if ($page->qtype != LESSON_BRANCHTABLE) { // To fix XHTML problem (BT have their own forms)
echo '';
- echo "\n";
+ echo "\n";
}
} else {
// a page without answers - find the next (logical) page
@@ -773,7 +773,7 @@
if ($lesson->nextpagedefault) {
// in Flash Card mode...
// ...first get number of retakes
- $nretakes = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
+ $nretakes = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
// ...then get the page ids (lessonid the 5th param is needed to make $DB->get_records play)
$allpages = $DB->get_records("lesson_pages", array("lessonid" => $lesson->id), "id", "id,lessonid");
shuffle ($allpages);
@@ -818,13 +818,13 @@
echo ' ';
echo "\n";
}
-
+
// Finish of the page
lesson_print_progress_bar($lesson, $course);
} else {
// end of lesson reached work out grade
-
+
// Used to check to see if the student ran out of time
$outoftime = optional_param('outoftime', '', PARAM_ALPHA);
@@ -838,7 +838,7 @@
$timer = array_pop($timer); // this will get the latest start time record
}
$timer->lessontime = time();
-
+
$DB->update_record("lesson_timer", $timer);
}
@@ -847,15 +847,15 @@
lesson_add_pretend_blocks($PAGE, $cm, $lesson, $timer);
lesson_print_header($cm, $course, $lesson, 'view');
echo $OUTPUT->heading(get_string("congratulations", "lesson"));
- print_box_start('generalbox boxaligncenter');
+ echo $OUTPUT->box_start('generalbox boxaligncenter');
$ntries = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
if (isset($USER->modattempts[$lesson->id])) {
$ntries--; // need to look at the old attempts :)
}
if (!has_capability('mod/lesson:manage', $context)) {
-
+
$gradeinfo = lesson_grade($lesson, $ntries);
-
+
if ($gradeinfo->attempts) {
if (!$lesson->custom) {
echo "".get_string("numberofpagesviewed", "lesson", $gradeinfo->nquestions).
@@ -863,7 +863,7 @@
if ($lesson->minquestions) {
if ($gradeinfo->nquestions < $lesson->minquestions) {
// print a warning and set nviewed to minquestions
- echo "
".get_string("youshouldview", "lesson",
+ echo "
".get_string("youshouldview", "lesson",
$lesson->minquestions)."
\n";
}
}
@@ -878,13 +878,13 @@
$a->essayquestions = $gradeinfo->nmanual;
echo "".get_string("displayscorewithessays", "lesson", $a)."
";
} else {
- echo "".get_string("displayscorewithoutessays", "lesson", $a)."
";
+ echo "".get_string("displayscorewithoutessays", "lesson", $a)."
";
}
$a = new stdClass;
$a->grade = number_format($gradeinfo->grade * $lesson->grade / 100, 1);
$a->total = $lesson->grade;
echo "".get_string('yourcurrentgradeisoutof', 'lesson', $a)."
\n";
-
+
$grade->lessonid = $lesson->id;
$grade->userid = $USER->id;
$grade->grade = $gradeinfo->grade;
@@ -925,11 +925,11 @@
// update central gradebook
lesson_update_grades($lesson, $USER->id);
- } else {
+ } else {
// display for teacher
echo "".get_string("displayofgrade", "lesson")."
\n";
}
- print_box_end(); //End of Lesson button to Continue.
+ echo $OUTPUT->box_end(); //End of Lesson button to Continue.
// after all the grade processing, check to see if "Show Grades" is off for the course
// if yes, redirect to the course page
@@ -955,7 +955,7 @@
// sort to find the lowest score
sort($topscores);
$lowscore = $topscores[0];
-
+
if ($gradeinfo->grade >= $lowscore || count($uniquescores) <= $lesson->maxhighscores) {
$madeit = true;
}
@@ -978,7 +978,7 @@
}
}
echo " ';
- echo "";
+ echo "";
}
if ($lesson->modattempts && !has_capability('mod/lesson:manage', $context)) {
@@ -996,11 +996,11 @@
// sure that the student can leave the lesson via pushing the continue button.
$lastattempt = end($attempts);
$USER->modattempts[$lesson->id] = $lastattempt->pageid;
- echo "\n";
+ echo "\n";
} elseif ($lesson->modattempts && has_capability('mod/lesson:manage', $context)) {
- echo "".get_string("modattemptsnoteacher", "lesson")."
";
+ echo "".get_string("modattemptsnoteacher", "lesson")."
";
}
-
+
if ($lesson->activitylink) {
if ($module = $DB->get_record('course_modules', array('id' => $lesson->activitylink))) {
if ($modname = $DB->get_field('modules', 'name', array('id' => $module->module)))