Commit 0a4abb73 authored by Sam Hemelryk's avatar Sam Hemelryk
Browse files

mod-lesson MDL-21006 Huge refactoring of the lesson code

The following are notable changes made in this commit
* Lesson page type are now class based and extend an abstract class. This includes a class for the page type and a class for the creating/editing a instance of this page.
* Converted all forms to mforms
* Action script located in mod/action/* were worked into the above so far less switch statements and the action directory will be removed.
* Implements a custom renderer
* Converted everything to use page, output, and custom renderer methods
* Replaced all deprecated methods incl. print_textarea conversions
* Tried to cut down on excessive DB calls.
Things worth noting:
* The focus of this patch was on cleaning up the module not rewriting it, as such I have organized NOT rewritten. There are still many areas in the module where the code could be greatly improved however to do so would require a rethink/rewrite
parent fb1ee4d5
<h1>Display left menu: grade condition</h1>
<p>By specifying a grade greater than 0, the user taking the lesson must have a grade equal to
or greater than the grade set in order to view the Left Menu.</p>
<p>This allows Lesson designers to force users to go through the entire lesson during the user's first attempt.
Then, if a user retakes the Lesson after meeting the required grade they can see the left menu to help with review.</p>
\ No newline at end of file
......@@ -9,6 +9,7 @@ $string['activitylinkname'] = 'Go to: $a';
$string['addabranchtable'] = 'Add a Branch Table';
$string['addbranchtable'] = 'Add a Branch Table';
$string['addanendofbranch'] = 'Add an End of Branch';
$string['addanewpage'] = 'Add a new page';
$string['addaquestionpage'] = 'Add a Question Page';
$string['addaquestionpagehere'] = 'Add a question page here';
$string['addcluster'] = 'Add a Cluster';
......@@ -33,6 +34,7 @@ $string['available'] = 'Available from';
$string['averagescore'] = 'Average score';
$string['averagetime'] = 'Average time';
$string['branchtable'] = 'Branch Table';
$string['branch'] = 'Branch';
$string['cannotfindanswer'] = 'Cannot find answer';
$string['cannotfindattempt'] = 'Error: could not find attempt';
$string['cannotfindessay'] = 'Error: could not find essay';
......@@ -61,6 +63,7 @@ $string['checkquestion'] = 'Check question';
$string['classstats'] = 'Class statistics';
$string['clicktodownload'] = 'Click on the following link to download the file.';
$string['clicktopost'] = 'Click here to post your grade on the High Scores list.';
$string['cluster'] = 'Cluster';
$string['clusterjump'] = 'Unseen question within a cluster';
$string['clustertitle'] = 'Cluster';
$string['collapsed'] = 'Collapsed';
......@@ -69,6 +72,15 @@ $string['completed'] = 'Completed';
$string['completederror'] = 'Complete the lesson';
$string['completethefollowingconditions'] = 'You must complete the following condition(s) in <b>$a</b> lesson before you can proceed.';
$string['conditionsfordependency'] = 'Condition(s) for the dependency';
$string['configactionaftercorrectanswer']= 'The default action to take after a correct answer';
$string['configmaxanswers']= 'Default maximum number of answers/branches per page';
$string['configmaxhighscores']= 'Number of high scores displayed';
$string['configmediaclose']= 'Displays a close button as part of the popup generated for a linked media file';
$string['configmediaheight']= 'Sets the height of the popup displayed for a linked media file';
$string['configmediawidth']= 'Sets the width of the popup displayed for a linked media file';
$string['configslideshowbgcolor']= 'Background color to for the slideshow if it is enabled';
$string['configslideshowheight']= 'Sets the height of the slideshow if it is enabled';
$string['configslideshowwidth']= 'Sets the width of the slideshow if it is enabled';
$string['confirmdelete']= 'Delete page';
$string['confirmdeletionofthispage'] = 'Confirm deletion of this page';
$string['congratulations'] = 'Congratulations - end of lesson reached';
......@@ -95,19 +107,22 @@ $string['displayhighscores'] = 'Display high scores';
$string['displayinleftmenu'] = 'Display in left menu?';
$string['displayleftif'] = 'Display left menu only if grade greater than:';
$string['displayleftmenu'] = 'Display left menu';
$string['displayleftmenuif'] = 'Display left menu: grade condition';
$string['displayofgrade'] = 'Display of grade (for students only)';
$string['displayreview'] = 'Display review button';
$string['displayscorewithessays'] = 'You earned $a->score out of $a->tempmaxgrade for the automatically graded questions.<br />Your $a->essayquestions essay question(s) will be graded and added<br />into your final score at a later date.<br /><br />Your current grade without the essay question(s) is $a->score out of $a->grade';
$string['displayscorewithoutessays'] = 'Your score is $a->score (out of $a->grade).';
$string['edit'] = 'Edit';
$string['editingquestionpage'] = 'Editing $a question page';
$string['editpage'] = 'Edit page contents';
$string['editlessonsettings'] = 'Edit lesson settings';
$string['editpagecontent'] = 'Edit page contents';
$string['email'] = 'Email';
$string['emailallgradedessays'] = 'Email ALL<br />graded essays';
$string['emailallgradedessays'] = 'Email ALL graded essays';
$string['emailgradedessays'] = 'Email graded essays';
$string['emailsuccess'] = 'Emails sent successfully';
$string['endofbranch'] = 'End of branch';
$string['endofcluster'] = 'End of cluster';
$string['endofclustertitle'] = 'End of cluster';
$string['endoflesson'] = 'End of lesson';
$string['enteredthis'] = 'entered this.';
......@@ -144,6 +159,7 @@ $string['importppt'] = 'Import PowerPoint';
$string['importquestions'] = 'Import questions';
$string['insertedpage'] = 'Inserted page';
$string['invalidpageid'] = 'Invalid lesson page ID';
$string['invalidfile'] = 'Invalid file';
$string['invalidid'] = 'No course module ID or lesson ID were passed';
$string['invalidlessonid'] = 'lesson ID was incorrect';
$string['invalidpageid'] = 'Invalid Page ID';
......@@ -174,6 +190,8 @@ $string['lowscore'] = 'Low score';
$string['lowtime'] = 'Low time';
$string['manualgrading'] = 'Grade Essays';
$string['matchesanswer'] = 'Matches with answer';
$string['matching'] = 'Matching';
$string['matchingpair'] = 'Matching pair $a';
$string['maxhighscores'] = 'Number of high scores displayed';
$string['maximumnumberofanswersbranches'] = 'Maximum number of answers/branches';
$string['maximumnumberofattempts'] = 'Maximum number of attempts';
......@@ -183,8 +201,8 @@ $string['maxtimewarning'] = 'You have $a minute(s) to finish the lesson.';
$string['mediaclose'] = 'Show close button:';
$string['mediafile'] = 'Pop-up to file or web page';
$string['mediafilepopup'] = 'Click here to view';
$string['mediaheight'] = 'Window height:';
$string['mediawidth'] = 'width:';
$string['mediaheight'] = 'Popup window height:';
$string['mediawidth'] = 'Popup window width:';
$string['minimumnumberofquestions'] = 'Minimum number of questions';
$string['missingname'] = 'Please enter a nickname';
$string['modattempts'] = 'Allow student review';
......@@ -196,9 +214,11 @@ $string['movedpage'] = 'Moved page';
$string['movepagehere'] = 'Move page to here';
$string['moving'] = 'Moving page: $a';
$string['multianswer'] = 'Multianswer';
$string['multichoice'] = 'Multichoice';
$string['multipleanswer'] = 'Multiple Answer';
$string['nameapproved'] = 'Name approved';
$string['namereject'] = 'Sorry, your name has been rejected by the filter.<br />Please try another name.';
$string['new'] = 'new';
$string['nextpage'] = 'Next page';
$string['noanswer'] = 'No answer given. Please go back and submit an answer.';
$string['noattemptrecordsfound'] = 'No attempt records found: no grade given';
......@@ -226,10 +246,12 @@ $string['numberofcorrectmatches'] = 'Number of correct matches: $a';
$string['numberofpagestoshow'] = 'Number of pages (cards) to show';
$string['numberofpagesviewed'] = 'Number of questions answered: $a';
$string['numberofpagesviewednotice'] = 'Number of questions answered: $a->nquestions; (You should answer at least: $a->minquestions)';
$string['numerical'] = 'Numerical';
$string['onpostperpage'] = 'Only one posting per grade';
$string['ongoing'] = 'Display ongoing score';
$string['ongoingcustom'] = 'You have earned $a->score point(s) out of $a->currenthigh point(s) thus far.';
$string['ongoingnormal'] = 'You have answered $a->correct correctly out of $a->viewed attempts.';
$string['options'] = 'Options';
$string['or'] = 'OR';
$string['ordered'] = 'Ordered';
$string['other'] = 'Other';
......@@ -247,6 +269,7 @@ $string['pleaseenteryouranswerinthebox'] = 'Please enter your answer in the box'
$string['pleasematchtheabovepairs'] = 'Please match the above pairs';
$string['pointsearned'] = 'Points earned';
$string['postsuccess'] = 'Post successful';
$string['pptsuccessfullimport'] = 'Successfully imported pages from the uploaded PowerPoint Presentation';
$string['practice'] = 'Practice lesson';
$string['preprocesserror'] = 'Error occurred during pre-processing!';
$string['processerror'] = 'Error occurred during processing!';
......@@ -285,8 +308,10 @@ $string['savepage'] = 'Save page';
$string['score'] = 'Score';
$string['scores'] = 'Scores';
$string['secondpluswrong'] = 'Not quite. Would you like to try again?';
$string['selectaqtype'] = 'Select a question type';
$string['showanunansweredpage'] = 'Show an unanswered Page';
$string['showanunseenpage'] = 'Show an Unseen Page';
$string['shortanswer'] = 'Short answer';
$string['singleanswer'] = 'Single Answer';
$string['skip'] = 'Skip navigation';
$string['slideshow'] = 'Slide Show';
......@@ -312,6 +337,9 @@ $string['timespenterror'] = 'Spend at least $a minutes in the lesson';
$string['timespentminutes'] = 'Time Spent (minutes)';
$string['timetaken'] = 'Time taken';
$string['topscorestitle'] = 'Top $a High Scores';
$string['truefalse'] = 'True/False';
$string['unabledtosavefile'] = 'The file you uploaded could not be saved';
$string['unknownqtypesnotimported'] = '$a questions with unsupported question types were not imported';
$string['unseenpageinbranch'] = 'Unseen question within a branch';
$string['unsupportedqtype'] = 'Unsupported question type ($a)!';
$string['updatedpage'] = 'Updated page';
......
<?php
/**
* Action for adding a branch table. Prints an HTML form.
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson
**/
// first get the preceeding page
$pageid = required_param('pageid', PARAM_INT);
// set of jump array
$jump = array();
$jump[0] = get_string("thispage", "lesson");
$jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
$jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson");
$jump[LESSON_EOL] = get_string("endoflesson", "lesson");
if (!optional_param('firstpage', 0, PARAM_INT)) {
if (!$apageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0))) {
print_error('cannotfindfirstpage', 'lesson');
}
while (true) {
if ($apageid) {
$title = $DB->get_field("lesson_pages", "title", array("id" => $apageid));
$jump[$apageid] = $title;
$apageid = $DB->get_field("lesson_pages", "nextpageid", array("id" => $apageid));
} else {
// last page reached
break;
}
}
}
// give teacher a blank proforma
$helpicon = new moodle_help_icon();
$helpicon->text = get_string("addabranchtable", "lesson");
$helpicon->page = "overview";
$helpicon->module = "lesson";
echo $OUTPUT->heading_with_help($helpicon);
?>
<form id="form" method="post" action="lesson.php" class="addform">
<fieldset class="invisiblefieldset fieldsetfix">
<input type="hidden" name="id" value="<?PHP echo $cm->id ?>" />
<input type="hidden" name="action" value="insertpage" />
<input type="hidden" name="pageid" value="<?PHP echo $pageid ?>" />
<input type="hidden" name="qtype" value="<?PHP echo LESSON_BRANCHTABLE ?>" />
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
<table class="generalbox boxaligncenter" cellpadding="5" border="1">
<tr valign="top">
<td><strong><label for="title"><?php print_string("pagetitle", "lesson"); ?>:</label></strong><br />
<input type="text" id="title" name="title" size="80" value="" /></td></tr>
<?php
echo "<tr><td><strong>";
echo get_string("pagecontents", "lesson").":</strong><br />\n";
print_textarea($usehtmleditor, 25,70, 0, 0, "contents");
echo "</td></tr>\n";
echo "<tr><td>\n";
echo "<div class=\"boxaligncenter addform\"><input name=\"layout\" type=\"checkbox\" value=\"1\" checked=\"checked\" />";
echo get_string("arrangebuttonshorizontally", "lesson")."\n";
echo "<br /><input name=\"display\" type=\"checkbox\" value=\"1\" checked=\"checked\" />";
echo get_string("displayinleftmenu", "lesson");
echo "</div>\n";
echo "</td></tr>\n";
for ($i = 0; $i < $lesson->maxanswers; $i++) {
$iplus1 = $i + 1;
echo "<tr><td><strong>".get_string("description", "lesson")." $iplus1:</strong><br />\n";
print_textarea(false, 10, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n";
echo "<tr><td><strong>".get_string("jump", "lesson")." $iplus1:</strong> \n";
if ($i) {
// answers 2, 3, 4... jumpto this page
echo $OUTPUT->select(html_select::make($jump, "jumpto[$i]", 0, false));
} else {
// answer 1 jumpto next page
echo $OUTPUT->select(html_select::make($jump, "jumpto[$i]", LESSON_NEXTPAGE, false));
}
echo $OUTPUT->help_icon(moodle_help_icon::make("jumpto", get_string("jump", "lesson"), "lesson"));
echo "</td></tr>\n";
}
// close table and form
?>
</table><br />
<input type="submit" value="<?php print_string("addabranchtable", "lesson") ?>" />
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
</fieldset>
</form>
<?php
/**
* Action for adding a cluster page
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson
**/
require_sesskey();
// first get the preceeding page
// if $pageid = 0, then we are inserting a new page at the beginning of the lesson
$pageid = required_param('pageid', PARAM_INT);
$timenow = time();
if ($pageid == 0) {
if (!$page = $DB->get_record("lesson_pages", array("prevpageid" => 0, "lessonid" => $lesson->id))) {
print_error('cannotfindpagerecord', 'lesson');
}
} else {
if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) {
print_error('cannotfindpagerecord', 'lesson');
}
}
$newpage = new stdClass;
$newpage->lessonid = $lesson->id;
$newpage->prevpageid = $pageid;
if ($pageid != 0) {
$newpage->nextpageid = $page->nextpageid;
} else {
$newpage->nextpageid = $page->id;
}
$newpage->qtype = LESSON_CLUSTER;
$newpage->timecreated = $timenow;
$newpage->title = get_string("clustertitle", "lesson");
$newpage->contents = get_string("clustertitle", "lesson");
$newpageid = $DB->insert_record("lesson_pages", $newpage);
// update the linked list...
if ($pageid != 0) {
$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid));
}
if ($pageid == 0) {
$page->nextpageid = $page->id;
}
if ($page->nextpageid) {
// the new page is not the last page
$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid));
}
// ..and the single "answer"
$newanswer = new stdClass;
$newanswer->lessonid = $lesson->id;
$newanswer->pageid = $newpageid;
$newanswer->timecreated = $timenow;
$newanswer->jumpto = LESSON_CLUSTERJUMP;
$newanswerid = $DB->insert_record("lesson_answers", $newanswer);
lesson_set_message(get_string('addedcluster', 'lesson'), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
<?php
/**
* Action for adding an end of branch page
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson
**/
require_sesskey();
// first get the preceeding page
$pageid = required_param('pageid', PARAM_INT);
$timenow = time();
// the new page is not the first page (end of branch always comes after an existing page)
if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) {
print_error('cannotfindpagerecord', 'lesson');
}
// chain back up to find the (nearest branch table)
$btpageid = $pageid;
if (!$btpage = $DB->get_record("lesson_pages", array("id" => $btpageid))) {
print_error('cannotfindpagerecord', 'lesson');
}
while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) {
$btpageid = $btpage->prevpageid;
if (!$btpage = $DB->get_record("lesson_pages", array("id" => $btpageid))) {
print_error('cannotfindpagerecord', 'lesson');
}
}
if ($btpage->qtype == LESSON_BRANCHTABLE) {
$newpage = new stdClass;
$newpage->lessonid = $lesson->id;
$newpage->prevpageid = $pageid;
$newpage->nextpageid = $page->nextpageid;
$newpage->qtype = LESSON_ENDOFBRANCH;
$newpage->timecreated = $timenow;
$newpage->title = get_string("endofbranch", "lesson");
$newpage->contents = get_string("endofbranch", "lesson");
$newpageid = $DB->insert_record("lesson_pages", $newpage);
// update the linked list...
$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid));
if ($page->nextpageid) {
// the new page is not the last page
$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid));
}
// ..and the single "answer"
$newanswer = new stdClass;
$newanswer->lessonid = $lesson->id;
$newanswer->pageid = $newpageid;
$newanswer->timecreated = $timenow;
$newanswer->jumpto = $btpageid;
$newanswerid = $DB->insert_record("lesson_answers", $newanswer);
lesson_set_message(get_string('addedanendofbranch', 'lesson'), 'notifysuccess');
} else {
lesson_set_message(get_string('nobranchtablefound', 'lesson'));
}
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
<?php
/**
* Action for adding an end of cluster page
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson
**/
require_sesskey();
// first get the preceeding page
$pageid = required_param('pageid', PARAM_INT);
$timenow = time();
// the new page is not the first page (end of cluster always comes after an existing page)
if (!$page = $DB->get_record("lesson_pages", array("id" => $pageid))) {
print_error('cannotfindpages', 'lesson');
}
// could put code in here to check if the user really can insert an end of cluster
$newpage = new stdClass;
$newpage->lessonid = $lesson->id;
$newpage->prevpageid = $pageid;
$newpage->nextpageid = $page->nextpageid;
$newpage->qtype = LESSON_ENDOFCLUSTER;
$newpage->timecreated = $timenow;
$newpage->title = get_string("endofclustertitle", "lesson");
$newpage->contents = get_string("endofclustertitle", "lesson");
$newpageid = $DB->insert_record("lesson_pages", $newpage);
// update the linked list...
$DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid));
if ($page->nextpageid) {
// the new page is not the last page
$DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid));
}
// ..and the single "answer"
$newanswer = new stdClass;
$newanswer->lessonid = $lesson->id;
$newanswer->pageid = $newpageid;
$newanswer->timecreated = $timenow;
$newanswer->jumpto = LESSON_NEXTPAGE;
$newanswerid = $DB->insert_record("lesson_answers", $newanswer);
lesson_set_message(get_string('addedendofcluster', 'lesson'), 'notifysuccess');
redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id");
<?php
/**
* Action for adding a question page. Prints an HTML form.
*
* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package lesson
**/
// first get the preceeding page
$pageid = required_param('pageid', PARAM_INT);
$qtype = optional_param('qtype', LESSON_MULTICHOICE, PARAM_INT);
// set of jump array
$jump = array();
$jump[0] = get_string("thispage", "lesson");
$jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
$jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson");
$jump[LESSON_EOL] = get_string("endoflesson", "lesson");
if(lesson_display_branch_jumps($lesson->id, $pageid)) {
$jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson");
$jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson");
}
if(lesson_display_cluster_jump($lesson->id, $pageid)) {
$jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson");
}
if (!optional_param('firstpage', 0, PARAM_INT)) {
$linkadd = "";
$apageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0));
while (true) {
if ($apageid) {
$title = $DB->get_field("lesson_pages", "title", array("id" => $apageid));
$jump[$apageid] = strip_tags(format_string($title,true));
$apageid = $DB->get_field("lesson_pages", "nextpageid", array("id" => $apageid));
} else {
// last page reached
break;
}
}
} else {
$linkadd = "&amp;firstpage=1";
}
// give teacher a blank proforma
$helpicon = new moodle_help_icon();
$helpicon->text = get_string("addaquestionpage", "lesson");
$helpicon->page = "overview";
$helpicon->module = "lesson";
echo $OUTPUT->heading_with_help($helpicon);
?>
<form id="form" method="post" action="lesson.php" class="addform">
<fieldset class="invisiblefieldset fieldsetfix">
<input type="hidden" name="id" value="<?php echo $cm->id ?>" />
<input type="hidden" name="action" value="insertpage" />
<input type="hidden" name="pageid" value="<?php echo $pageid ?>" />
<input type="hidden" name="sesskey" value="<?php echo sesskey() ?>" />
<?php
echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
echo $OUTPUT->help_icon(moodle_help_icon::make("questiontypes", get_string("questiontype", "lesson"), "lesson"))."<br />";
lesson_qtype_menu($LESSON_QUESTION_TYPE, $qtype,
"lesson.php?id=$cm->id&amp;action=addpage&amp;pageid=".$pageid.$linkadd);
if ( $qtype == LESSON_SHORTANSWER || $qtype == LESSON_MULTICHOICE ) { // only display this option for Multichoice and shortanswer
echo '<p>';
if ($qtype == LESSON_SHORTANSWER) {
$qoptionstr = get_string('casesensitive', 'lesson');
} else {
$qoptionstr = get_string('multianswer', 'lesson');
}
echo "<label for=\"qoption\"><strong>$qoptionstr</strong></label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>";
echo $OUTPUT->help_icon(moodle_help_icon::make("questionoption", get_string("questionoption", "lesson"), "lesson"));
echo '</p>';
}
?>
<table cellpadding="5" class="generalbox boxaligncenter" border="1">
<tr valign="top">
<td><b><label for="title"><?php print_string("pagetitle", "lesson"); ?>:</label></b><br />
<input type="text" id="title" name="title" size="80" value="" /></td></tr>
<?php
echo "<tr><td><b>";
echo get_string("pagecontents", "lesson").":</b><br />\n";
print_textarea($usehtmleditor, 25,70, 630, 400, "contents");
echo "</td></tr>\n";
switch ($qtype) {
case LESSON_TRUEFALSE :
for ($i = 0; $i < 2; $i++) {
$iplus1 = $i + 1;
echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n";
echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "response[$i]");
echo "</td></tr>\n";
echo "<tr><td><b>".get_string("jump", "lesson")." $iplus1:</b> \n";
if ($i) {
// answers 2, 3, 4... jumpto this page
echo $OUTPUT->select(html_select::make($jump, "jumpto[$i]", 0, false));
} else {
// answer 1 jumpto next page
echo $OUTPUT->select(html_select::make($jump, "jumpto[$i]", LESSON_NEXTPAGE, false));
}
echo $OUTPUT->help_icon(moodle_help_icon::make("jumpto", get_string("jump", "lesson"), "lesson"));
if($lesson->custom) {
if ($i) {
echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\" />";
} else {
echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\" />";
}
}
echo "</td></tr>\n";
}
break;
case LESSON_ESSAY :
echo "<tr><td><b>".get_string("jump", "lesson").":</b> \n";
echo $OUTPUT->select(html_select::make($jump, "jumpto[0]", LESSON_NEXTPAGE, false));
echo $OUTPUT->help_icon(moodle_help_icon::make("jumpto", get_string("jump", "lesson"), "lesson"));
if ($lesson->custom) {
echo get_string("score", "lesson").": <input type=\"text\" name=\"score[0]\" value=\"1\" size=\"5\" />";
}
echo "</td></tr>\n";
break;
case LESSON_MATCHING :
for ($i = 0; $i < $lesson->maxanswers+2; $i++) {
$icorrected = $i - 1;
if ($i == 0) {
echo "<tr><td><b>".get_string("correctresponse", "lesson").":</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n";
} elseif ($i == 1) {
echo "<tr><td><b>".get_string("wrongresponse", "lesson").":</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n";
} else {
echo "<tr><td><b>".get_string("answer", "lesson")." $icorrected:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n";
echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $icorrected:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "response[$i]");
echo "</td></tr>\n";
}
if ($i == 2) {
echo "<tr><td><b>".get_string("correctanswerjump", "lesson").":</b> \n";
echo $OUTPUT->select(html_select::make($jump, "jumpto[$i]", LESSON_NEXTPAGE, false));
echo $OUTPUT->help_icon(moodle_help_icon::make("jumpto", get_string("jump", "lesson"), "lesson"));
if($lesson->custom) {
echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\" />";
}
echo "</td></tr>\n";
} elseif ($i == 3) {
echo "<tr><td><b>".get_string("wronganswerjump", "lesson").":</b> \n";
echo $OUTPUT->select(html_select::make($jump, "jumpto[$i]", 0, false));
echo $OUTPUT->help_icon(moodle_help_icon::make("jumpto", get_string("jump", "lesson"), "lesson"));
if($lesson->custom) {
echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\" />";
}
echo "</td></tr>\n";
}
}
break;
case LESSON_SHORTANSWER :
case LESSON_NUMERICAL :
case LESSON_MULTICHOICE :
// default code
for ($i = 0; $i < $lesson->maxanswers; $i++) {
$iplus1 = $i + 1;
echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n";
echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "response[$i]");
echo "</td></tr>\n";
echo "<tr><td><b>".get_string("jump", "lesson")." $iplus1:</b> \n";
if ($i) {
// answers 2, 3, 4... jumpto this page
echo $OUTPUT->select(html_select::make($jump, "jumpto[$i]", 0, false));
} else {
// answer 1 jumpto next page
echo $OUTPUT->select(html_select::make($jump, "jumpto[$i]", LESSON_NEXTPAGE, false));
}
echo $OUTPUT->help_icon(moodle_help_icon::make("jumpto", get_string("jump", "lesson"), "lesson"));
if($lesson->custom) {
if ($i) {
echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\" />";