Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 3 update

  • Loading branch information...
commit 9e93d4d03f8c88f9d0a3e9bc203163dd85459aff 1 parent 44cbe38
rkingdon authored
View
25 lang/en/lesson.php
@@ -3,31 +3,40 @@
$string['actionaftercorrectanswer'] = "Action after Correct Answer";
-$string['addanewpage'] = "Add a new page";
-$string['addpagehere'] = "Add page Here";
+$string['addabranchtable'] = "Add a Branch Table";
+$string['addanendofbranch'] = "Add an End of Branch";
+$string['addaquestionpage'] = "Add a Question Page";
$string['answer'] = "Answer";
$string['answersfornumerical'] = "Answers for Numerical questions should be matched pairs of Minimum and Maximum values";
$string['attempt'] = "Attempt: \$a";
$string['attempts'] = "Attempts";
$string['available'] = "Available from";
-$string['canretake'] = "\$a can re-take";
+$string['branchtable'] = "Branch Table";
+$string['canretake'] = "\$a can Re-take";
$string['casesensitive'] = "Case Sensitive";
$string['checknavigation'] = "Check navigation";
+$string['checkbranchtable'] = "Check Branch Table";
$string['checkquestion'] = "Check Question";
$string['confirmdeletionofthispage'] = "Confirm deletion of this page";
$string['congratulations'] = "Congratulations - end of lesson reached";
$string['continue'] = "Continue";
$string['deadline'] = "Deadline";
+$string['deleting'] = "Deleting";
$string['deletingpage'] = "Deleting page: \$a";
+$string['description'] = "Description";
$string['displayofgrade'] = "Display of grade (for students only)";
+$string['endofbranch'] = "End of Branch";
$string['endoflesson'] = "End of lesson";
$string['fileformat'] = "File Format";
$string['firstanswershould'] = "First Answer should Jump to the "Correct&quot Page";
$string['gradeis'] = "Grade is \$a";
+$string['handlingofretakes'] = "Handling of Re-takes";
+$string['here'] = "here";
$string['importquestions'] = "Import Questions";
$string['jumpto'] = "Jump to";
-$string['maximumnumberofanswers'] = "Maximum number of answers";
+$string['maximumnumberofanswersbranches'] = "Maximum number of answers/branches";
$string['maximumnumberofattempts'] = "Maximum number of Attempts";
+$string['minimumnumberofquestions'] = "Minimum number of Questions";
$string['modulename'] = "Lesson";
$string['modulenameplural'] = "Lessons";
$string['multianswer'] = "Multianswer";
@@ -39,6 +48,8 @@
$string['noanswer'] = "No answer given";
$string['noattemptrecordsfound'] = "No Attempt Records Found: No Grade given";
$string['normal'] = "Normal - follow Lesson Path";
+$string['notdefined'] = "Not Defined";
+$string['notitle'] = "No Title";
$string['numberofcorrectanswers'] = "Number of correct answers: \$a";
$string['numberofcorrectmatches'] = "Number of Correct Matches: \$a";
$string['numberofpagesviewed'] = "Number of pages viewed: \$a";
@@ -48,6 +59,7 @@
$string['questiontype'] = "Question Type";
$string['questionoption'] = "Question Option";
$string['page'] = "Page: \$a";
+$string['pages'] = "Pages";
$string['pagecontents'] = "Page contents";
$string['pagetitle'] = "Page title";
$string['pleasecheckoneanswer'] = "Please check one Answer";
@@ -62,8 +74,13 @@
$string['showanunansweredpage'] = "Show an unanswered Page";
$string['thatsthecorrectanswer'] = "That's the Correct Answer";
$string['thatsthewronganswer'] = "That's the Wrong Answer";
+$string['thefollowingpagesjumptothispage'] = "The following Pages jump to this Page";
$string['thispage'] = "This page";
+$string['usemaximum'] = "Use Maximum";
+$string['usemean'] = "Use Mean";
$string['youhaveseen'] = "You have seen more than one page of this lesson already.<br />Do you want to start at the last page you saw?";
$string['youranswer'] = "Your Answer";
+$string['yourcurrentgradeis'] = "Your current Grade is \$a";
+$string['youshouldview'] = "You should view at least: \$a";
?>
View
4 mod/lesson/backuplib.php
@@ -49,9 +49,11 @@ function lesson_backup_mods($bf, $preferences) {
fwrite ($bf,full_tag("MODTYPE",4,false,"lesson"));
fwrite ($bf,full_tag("NAME",4,false,$lesson->name));
fwrite ($bf,full_tag("GRADE",4,false,$lesson->grade));
+ fwrite ($bf,full_tag("USEMAXGRADE",4,false,$lesson->usemaxgrade));
fwrite ($bf,full_tag("MAXANSWERS",4,false,$lesson->maxanswers));
fwrite ($bf,full_tag("MAXATTEMPTS",4,false,$lesson->maxattempts));
fwrite ($bf,full_tag("NEXTPAGEDEFAULT",4,false,$lesson->nextpagedefault));
+ fwrite ($bf,full_tag("MINQUESTIONS",4,false,$lesson->minquestions));
fwrite ($bf,full_tag("MAXPAGES",4,false,$lesson->maxpages));
fwrite ($bf,full_tag("RETAKE",4,false,$lesson->retake));
fwrite ($bf,full_tag("AVAILABLE",4,false,$lesson->available));
@@ -171,9 +173,9 @@ function backup_lesson_attempts ($bf,$preferences,$answerid) {
$status =fwrite ($bf,start_tag("ATTEMPT",5,true));
//Print attempt contents
fwrite ($bf,full_tag("USERID",6,false,$attempt->userid));
+ fwrite ($bf,full_tag("RETRY",6,false,$attempt->retry));
fwrite ($bf,full_tag("CORRECT",6,false,$attempt->correct));
fwrite ($bf,full_tag("TIMESEEN",6,false,$attempt->timeseen));
- fwrite ($bf,full_tag("RETRY",6,false,$attempt->retry));
//End attempt
$status =fwrite ($bf,end_tag("ATTEMPT",5,true));
}
View
7 mod/lesson/db/mysql.php
@@ -30,7 +30,12 @@ function lesson_upgrade($oldversion) {
if ($oldversion < 2004032000) { // Upgrade some old beta lessons
execute_sql(" UPDATE `{$CFG->prefix}lesson_pages` SET qtype = 3 WHERE qtype = 0");
}
-
+
+ if ($oldversion < 2004032400) {
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `usegrademax` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER grade");
+ execute_sql(" ALTER TABLE `{$CFG->prefix}lesson` ADD `minquestions` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' AFTER nextpagedefault");
+ }
+
return true;
}
View
2  mod/lesson/db/mysql.sql
@@ -9,9 +9,11 @@ CREATE TABLE `prefix_lesson` (
`course` int(10) unsigned NOT NULL default '0',
`name` varchar(255) NOT NULL default '',
`grade` tinyint(3) NOT NULL default '0',
+ `usemaxgrade` tinyint(3) NOT NULL default '0',
`maxanswers` int(3) unsigned NOT NULL default '4',
`maxattempts` int(3) unsigned NOT NULL default '5',
`nextpagedefault` int(3) unsigned NOT NULL default '0',
+ `minquestions` int(3) unsigned NOT NULL default '0',
`maxpages` int(3) unsigned NOT NULL default '0',
`retake` int(3) unsigned NOT NULL default '1',
`available` int(10) unsigned NOT NULL default '0',
View
1  mod/lesson/import.php
@@ -106,7 +106,6 @@
print_string("fileformat", "lesson");
echo ":</td><td>";
choose_from_menu($fileformatnames, "format", "gift", "");
- helpbutton("import", $strimportquestions, "lesson");
echo "</tr>";
echo "<tr><td align=right>";
View
19 mod/lesson/index.php
@@ -76,14 +76,17 @@
if (isteacher($course->id)) {
$grade_value = $lesson->grade;
} else {
- // it's a student, show their maximum grade
- if ($grades = get_records_select("lesson_grades", "lessonid = $lesson->id AND
- userid = $USER->id", "grade DESC")) {
- foreach ($grades as $grade) {
- // grades are stored as percentages
- $grade_value = number_format($grade->grade * $lesson->grade / 100, 1);
- break; // only the first (largest) grade needed
- }
+ // it's a student, show their mean or maximum grade
+ if ($lesson->usemaxgrade) {
+ $grade = get_record_sql("SELECT MAX(grade) as grade FROM {$CFG->prefix}lesson_grades
+ WHERE lessonid = $lesson->id AND userid = $USER->id GROUP BY userid");
+ } else {
+ $grade = get_record_sql("SELECT AVG(grade) as grade FROM {$CFG->prefix}lesson_grades
+ WHERE lessonid = $lesson->id AND userid = $USER->id GROUP BY userid");
+ }
+ if ($grade) {
+ // grades are stored as percentages
+ $grade_value = number_format($grade->grade * $lesson->grade / 100, 1);
} else {
$grade_value = 0;
}
View
357 mod/lesson/lesson.php
@@ -3,7 +3,9 @@
/*************************************************
ACTIONS handled are:
- addpage
+ addbranchtable
+ addendofbranch
+ addpage
confirmdelete
continue
delete
@@ -57,8 +59,145 @@
require_variable($action);
+ /************** add branch table ************************************/
+ if ($action == 'addbranchtable' ) {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ // first get the preceeding page
+ $pageid = $_GET['pageid'];
+
+ // set of jump array
+ $jump[0] = get_string("thispage", "lesson");
+ $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
+ $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
+ if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
+ error("Add page: first page not found");
+ }
+ while (true) {
+ if ($apageid) {
+ $title = get_field("lesson_pages", "title", "id", $apageid);
+ $jump[$apageid] = $title;
+ $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid);
+ } else {
+ // last page reached
+ break;
+ }
+ }
+
+ // give teacher a blank proforma
+ print_heading_with_help(get_string("addabranchtable", "lesson"), "overview", "lesson");
+ ?>
+ <form name="form" method="post" action="lesson.php">
+ <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 $_GET['pageid'] ?>">
+ <input type="hidden" name="qtype" value="<?PHP echo LESSON_BRANCHTABLE ?>">
+ <center><table cellpadding=5 border=1>
+ <tr><td align="center">
+ <tr valign="top">
+ <td><b><?php print_string("pagetitle", "lesson"); ?>:</b><br />
+ <input type="text" name="title" size="80" maxsize="255" 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";
+ for ($i = 0; $i < $lesson->maxanswers; $i++) {
+ $iplus1 = $i + 1;
+ echo "<tr><td><b>".get_string("description", "lesson")." $iplus1:</b><br />\n";
+ print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$i]");
+ echo "</td></tr>\n";
+ echo "<tr><td><B>".get_string("jumpto", "lesson").":</b> \n";
+ if ($i) {
+ // answers 2, 3, 4... jumpto this page
+ lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
+ } else {
+ // answer 1 jumpto next page
+ lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
+ }
+ helpbutton("jumpto", get_string("jumpto", "lesson"), "lesson");
+ echo "</td></tr>\n";
+ }
+ use_html_editor();
+ // 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") ?>">
+ </center>
+ </form>
+ <?PHP
+ }
+
+
+ /************** add end of branch ************************************/
+ elseif ($action == 'addendofbranch' ) {
+
+ if (!isteacher($course->id)) {
+ error("Only teachers can look at this page");
+ }
+
+ // first get the preceeding page
+ $pageid = $_GET['pageid'];
+
+ $timenow = time();
+
+ // the new page is not the first page (end of branch always comes after an existing page)
+ if (!$page = get_record("lesson_pages", "id", $pageid)) {
+ error("Add end of branch: page record not found");
+ }
+ // chain back up to find the (nearest branch table)
+ $btpageid = $pageid;
+ if (!$btpage = get_record("lesson_pages", "id", $btpageid)) {
+ error("Add end of branch: btpage record not found");
+ }
+ while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) {
+ $btpageid = $btpage->prevpageid;
+ if (!$btpage = get_record("lesson_pages", "id", $btpageid)) {
+ error("Add end of branch: btpage record not found");
+ }
+ }
+ if ($btpage->qtype == LESSON_BRANCHTABLE) {
+ $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");
+ if (!$newpageid = insert_record("lesson_pages", $newpage)) {
+ error("Insert page: new page not inserted");
+ }
+ // update the linked list...
+ if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) {
+ error("Add end of branch: unable to update link");
+ }
+ if ($page->nextpageid) {
+ // the new page is not the last page
+ if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) {
+ error("Insert page: unable to update previous link");
+ }
+ }
+ // ..and the single "answer"
+ $newanswer->lessonid = $lesson->id;
+ $newanswer->pageid = $newpageid;
+ $newanswer->timecreated = $timenow;
+ $newanswer->jumpto = $btpageid;
+ if(!$newanswerid = insert_record("lesson_answers", $newanswer)) {
+ error("Add end of branch: answer record not inserted");
+ }
+ redirect("view.php?id=$cm->id", get_string("ok"));
+ } else {
+ notice(get_string("nobranchtablefound", "lesson"), "view.php?id=$cm->id");
+ }
+ }
+
+
/************** add page ************************************/
- if ($action == 'addpage' ) {
+ elseif ($action == 'addpage' ) {
if (!isteacher($course->id)) {
error("Only teachers can look at this page");
@@ -86,7 +225,7 @@
}
// give teacher a blank proforma
- print_heading_with_help(get_string("addanewpage", "lesson"), "overview", "lesson");
+ print_heading_with_help(get_string("addaquestionpage", "lesson"), "overview", "lesson");
?>
<form name="form" method="post" action="lesson.php">
<input type="hidden" name="id" value="<?PHP echo $cm->id ?>">
@@ -132,7 +271,7 @@
// close table and form
?>
</table><br />
- <input type="submit" value="<?php print_string("addanewpage", "lesson") ?>">
+ <input type="submit" value="<?php print_string("addaquestionpage", "lesson") ?>">
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>">
</center>
</form>
@@ -419,6 +558,25 @@
}
}
break;
+
+ case LESSON_BRANCHTABLE:
+ $noanswer = false;
+ $newpageid = $_POST['jumpto'];
+ // convert jumpto page into a proper page id
+ if ($newpageid == 0) {
+ $newpageid = $pageid;
+ } elseif ($newpageid == LESSON_NEXTPAGE) {
+ if (!$newpageid = $page->nextpageid) {
+ // no nextpage go to end of lesson
+ $newpageid = LESSON_EOL;
+ }
+ }
+ // no need to record anything in lesson_attempts
+ redirect("view.php?id=$cm->id&action=navigation&pageid=$newpageid");
+ print_footer($course);
+ exit();
+ break;
+
}
if ($noanswer) {
$newpageid = $pageid; // display same page again
@@ -595,9 +753,16 @@
}
while (true) {
if ($apageid) {
- $title = get_field("lesson_pages", "title", "id", $apageid);
- $jump[$apageid] = $title;
- $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid);
+ if (!$apage = get_record("lesson_pages", "id", $apageid)) {
+ error("Edit page: apage record not found");
+ }
+ if ($apage->qtype != LESSON_ENDOFBRANCH) {
+ // don't include EOB's in the list...
+ if (trim($page->title)) { // ...nor nuffin pages
+ $jump[$apageid] = $apage->title;
+ }
+ }
+ $apageid = $apage->nextpageid;
} else {
// last page reached
break;
@@ -622,10 +787,10 @@
print_textarea($usehtmleditor, 25, 70, 630, 400, "contents", $page->contents);
echo "</td></tr>\n";
$n = 0;
- echo "<tr><td><b>".get_string("questiontype", "lesson").":</b> \n";
- choose_from_menu($LESSON_QUESTION_TYPE, "qtype", $page->qtype, "");
switch ($page->qtype) {
case LESSON_SHORTANSWER :
+ echo "<tr><td><b>".get_string("questiontype", "lesson").":</b> \n";
+ choose_from_menu($LESSON_QUESTION_TYPE, "qtype", $page->qtype, "");
echo "&nbsp;&nbsp;";
if ($page->qoption) {
echo "<input type=\"checkbox\" name=\"qoption\" value=\"1\" checked=\"checked\"/>";
@@ -633,8 +798,11 @@
echo "<input type=\"checkbox\" name=\"qoption\" value=\"1\"/>";
}
echo " <b>".get_string("casesensitive", "lesson")."</b>\n";
+ helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson");
break;
case LESSON_MULTICHOICE :
+ echo "<tr><td><b>".get_string("questiontype", "lesson").":</b> \n";
+ choose_from_menu($LESSON_QUESTION_TYPE, "qtype", $page->qtype, "");
echo "&nbsp;&nbsp;";
if ($page->qoption) {
echo "<input type=\"checkbox\" name=\"qoption\" value=\"1\" checked=\"checked\"/>";
@@ -642,20 +810,48 @@
echo "<input type=\"checkbox\" name=\"qoption\" value=\"1\"/>";
}
echo " <b>".get_string("multianswer", "lesson")."</b>\n";
+ helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson");
+ break;
+ case LESSON_TRUEFALSE :
+ case LESSON_MATCHING :
+ case LESSON_NUMERICAL :
+ echo "<tr><td><b>".get_string("questiontype", "lesson").":</b> \n";
+ choose_from_menu($LESSON_QUESTION_TYPE, "qtype", $page->qtype, "");
+ helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson");
+ break;
+ case LESSON_BRANCHTABLE :
+ echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n";
+ echo "<tr><td><b>".get_string("branchtable", "lesson")."</b> \n";
break;
+ case LESSON_ENDOFBRANCH :
+ echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n";
+ echo "<tr><td><b>".get_string("endofbranch", "lesson")."</b> \n";
+ break;
}
- helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson");
echo "</td></tr>\n";
if ($answers = get_records("lesson_answers", "pageid", $page->id, "id")) {
foreach ($answers as $answer) {
$nplus1 = $n + 1;
echo "<input type=\"hidden\" name=\"answerid[$n]\" value=\"$answer->id\">\n";
- echo "<tr><td><b>".get_string("answer", "lesson")." $nplus1:</b><br />\n";
- print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
- echo "</td></tr>\n";
- echo "<tr><td><b>".get_string("response", "lesson")." $nplus1:</b><br />\n";
- print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response);
- echo "</td></tr>\n";
+ switch ($page->qtype) {
+ case LESSON_MULTICHOICE:
+ case LESSON_TRUEFALSE:
+ case LESSON_SHORTANSWER:
+ case LESSON_NUMERICAL:
+ case LESSON_MATCHING:
+ echo "<tr><td><b>".get_string("answer", "lesson")." $nplus1:</b><br />\n";
+ print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
+ echo "</td></tr>\n";
+ echo "<tr><td><b>".get_string("response", "lesson")." $nplus1:</b><br />\n";
+ print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response);
+ echo "</td></tr>\n";
+ break;
+ case LESSON_BRANCHTABLE:
+ echo "<tr><td><b>".get_string("description", "lesson")." $nplus1:</b><br />\n";
+ print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
+ echo "</td></tr>\n";
+ break;
+ }
echo "<tr><td><b>".get_string("jumpto", "lesson").":</b> \n";
lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
helpbutton("jumpto", get_string("jumpto", "lesson"), "lesson");
@@ -663,19 +859,34 @@
$n++;
}
}
- for ($i = $n; $i < $lesson->maxanswers; $i++) {
- $iplus1 = $i + 1;
- echo "<input type=\"hidden\" name=\"answerid[$i]\" value=\"0\">\n";
- echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
- print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$i]");
- echo "</td></tr>\n";
- echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
- print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$i]");
- echo "</td></tr>\n";
- echo "<tr><td><B>".get_string("jumpto", "lesson").":</b> \n";
- lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
- helpbutton("jumpto", get_string("jumpto", "lesson"), "lesson");
- echo "</td></tr>\n";
+ if ($page->qtype != LESSON_ENDOFBRANCH) {
+ for ($i = $n; $i < $lesson->maxanswers; $i++) {
+ $iplus1 = $i + 1;
+ echo "<input type=\"hidden\" name=\"answerid[$i]\" value=\"0\">\n";
+ switch ($page->qtype) {
+ case LESSON_MULTICHOICE:
+ case LESSON_TRUEFALSE:
+ case LESSON_SHORTANSWER:
+ case LESSON_NUMERICAL:
+ case LESSON_MATCHING:
+ echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
+ print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$i]");
+ echo "</td></tr>\n";
+ echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
+ print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$i]");
+ echo "</td></tr>\n";
+ break;
+ case LESSON_BRANCHTABLE:
+ echo "<tr><td><b>".get_string("description", "lesson")." $iplus1:</b><br />\n";
+ print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$i]");
+ echo "</td></tr>\n";
+ break;
+ }
+ echo "<tr><td><B>".get_string("jumpto", "lesson").":</b> \n";
+ lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
+ helpbutton("jumpto", get_string("jumpto", "lesson"), "lesson");
+ echo "</td></tr>\n";
+ }
}
use_html_editor();
// close table and form
@@ -722,7 +933,13 @@
}
// update the linked list
if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $form->pageid)) {
- error("Insert page: unable to update link");
+ error("Insert page: unable to update next link");
+ }
+ if ($page->nextpageid) {
+ // new page is not the last page
+ if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) {
+ error("Insert page: unable to update previous link");
+ }
}
} else {
// new page is the first page
@@ -776,7 +993,9 @@
$newanswer->pageid = $newpageid;
$newanswer->timecreated = $timenow;
$newanswer->answer = trim($form->answer[$i]);
- $newanswer->response = trim($form->response[$i]);
+ if (isset($form->response[$i])) {
+ $newanswer->response = trim($form->response[$i]);
+ }
if (isset($form->jumpto[$i])) {
$newanswer->jumpto = $form->jumpto[$i];
}
@@ -812,7 +1031,10 @@
get_string("movepagehere", "lesson")."</small></a></td></tr>\n";
while (true) {
if ($page->id != $pageid) {
- echo "<tr><td bgcolor=\"$THEME->cellheading2\"><b>$page->title</b></td></tr>\n";
+ if (!$title = trim($page->title)) {
+ $title = "<< ".get_string("notitle", "lesson")." >>";
+ }
+ echo "<tr><td bgcolor=\"$THEME->cellheading2\"><b>$title</b></td></tr>\n";
echo "<tr><td><a href=\"lesson.php?id=$cm->id&action=moveit&pageid=$pageid&after={$page->id}\"><small>".
get_string("movepagehere", "lesson")."</small></a></td></tr>\n";
}
@@ -953,36 +1175,51 @@
if (!update_record("lesson_pages", $page)) {
error("Update page: page not updated");
}
- for ($i = 0; $i < $lesson->maxanswers; $i++) {
- if (trim(strip_tags($form->answer[$i]))) { // strip_tags because the HTML gives <p><br />...
- if ($form->answerid[$i]) {
- $oldanswer->id = $form->answerid[$i];
- $oldanswer->timemodified = $timenow;
- $oldanswer->answer = trim($form->answer[$i]);
- $oldanswer->response = trim($form->response[$i]);
- $oldanswer->jumpto = $form->jumpto[$i];
- if (!update_record("lesson_answers", $oldanswer)) {
- error("Update page: answer $i not updated");
+ if ($page->qtype == LESSON_ENDOFBRANCH) {
+ // there's just a single answer with a jump
+ $oldanswer->id = $form->answerid[0];
+ $oldanswer->timemodified = $timenow;
+ $oldanswer->jumpto = $form->jumpto[0];
+ if (!update_record("lesson_answers", $oldanswer)) {
+ error("Update page: EOB not updated");
+ }
+ } else {
+ // it's an "ordinary" page
+ for ($i = 0; $i < $lesson->maxanswers; $i++) {
+ if (trim(strip_tags($form->answer[$i]))) { // strip_tags because the HTML gives <p><br />...
+ if ($form->answerid[$i]) {
+ $oldanswer->id = $form->answerid[$i];
+ $oldanswer->timemodified = $timenow;
+ $oldanswer->answer = trim($form->answer[$i]);
+ if (isset($form->response[$i])) {
+ $oldanswer->response = trim($form->response[$i]);
+ }
+ $oldanswer->jumpto = $form->jumpto[$i];
+ if (!update_record("lesson_answers", $oldanswer)) {
+ error("Update page: answer $i not updated");
+ }
+ } else {
+ // it's a new answer
+ unset($newanswer); // need to clear id if more than one new answer is ben added
+ $newanswer->lessonid = $lesson->id;
+ $newanswer->pageid = $page->id;
+ $newanswer->timecreated = $timenow;
+ $newanswer->answer = trim($form->answer[$i]);
+ if (isset($form->response[$i])) {
+ $newanswer->response = trim($form->response[$i]);
+ }
+ $newanswer->jumpto = $form->jumpto[$i];
+ $newanswerid = insert_record("lesson_answers", $newanswer);
+ if (!$newanswerid) {
+ error("Update page: answer record not inserted");
+ }
}
} else {
- // it's a new answer
- unset($newanswer); // need to clear id if more than one new answer is ben added
- $newanswer->lessonid = $lesson->id;
- $newanswer->pageid = $page->id;
- $newanswer->timecreated = $timenow;
- $newanswer->answer = trim($form->answer[$i]);
- $newanswer->response = trim($form->response[$i]);
- $newanswer->jumpto = $form->jumpto[$i];
- $newanswerid = insert_record("lesson_answers", $newanswer);
- if (!$newanswerid) {
- error("Update page: answer record not inserted");
- }
- }
- } else {
- if ($form->answerid[$i]) {
- // need to delete blanked out answer
- if (!delete_records("lesson_answers", "id", $form->answerid[$i])) {
- error("Update page: unable to delete answer record");
+ if ($form->answerid[$i]) {
+ // need to delete blanked out answer
+ if (!delete_records("lesson_answers", "id", $form->answerid[$i])) {
+ error("Update page: unable to delete answer record");
+ }
}
}
}
View
19 mod/lesson/lib.php
@@ -53,15 +53,21 @@
if (!defined("LESSON_MULTIANSWER")) {
define("LESSON_MULTIANSWER", "9");
}
-$LESSON_QUESTION_TYPE = array ( LESSON_MULTICHOICE => get_string("multichoice", "quiz"),
+if (!defined("LESSON_BRANCHTABLE")) {
+ define("LESSON_BRANCHTABLE", "20");
+}
+if (!defined("LESSON_ENDOFBRANCH")) {
+ define("LESSON_ENDOFBRANCH", "21");
+}
+$LESSON_QUESTION_TYPE = array ( LESSON_MULTICHOICE => get_string("multichoice", "quiz"),
LESSON_TRUEFALSE => get_string("truefalse", "quiz"),
LESSON_SHORTANSWER => get_string("shortanswer", "quiz"),
LESSON_NUMERICAL => get_string("numerical", "quiz"),
- LESSON_MATCHING => get_string("match", "quiz")
+ LESSON_MATCHING => get_string("match", "quiz")
// LESSON_DESCRIPTION => get_string("description", "quiz"),
// LESSON_RANDOM => get_string("random", "quiz"),
// LESSON_RANDOMSAMATCH => get_string("randomsamatch", "quiz"),
-// LESSON_MULTIANSWER => get_string("multianswer", "quiz")
+// LESSON_MULTIANSWER => get_string("multianswer", "quiz"),
);
@@ -308,8 +314,13 @@ function lesson_grades($lessonid) {
if (!$lesson = get_record("lesson", "id", $lessonid)) {
error("Lesson record not found");
}
- $grades = get_records_sql_menu("SELECT userid,MAX(grade) FROM {$CFG->prefix}lesson_grades WHERE
+ if ($lesson->usemaxgrade) {
+ $grades = get_records_sql_menu("SELECT userid,MAX(grade) FROM {$CFG->prefix}lesson_grades WHERE
+ lessonid = $lessonid GROUP BY userid");
+ } else {
+ $grades = get_records_sql_menu("SELECT userid,AVG(grade) FROM {$CFG->prefix}lesson_grades WHERE
lessonid = $lessonid GROUP BY userid");
+ }
// convert grades from percentages and tidy the numbers
if ($grades) {
View
35 mod/lesson/mod.html
@@ -11,6 +11,9 @@
if (!isset($form->grade)) {
$form->grade = 0;
}
+ if (!isset($form->usemaxgrade)) {
+ $form->usemaxgrade = 0;
+ }
if (!isset($form->maxanswers)) {
$form->maxanswers = 4;
}
@@ -20,6 +23,9 @@
if (!isset($form->nextpagedefault)) {
$form->nextpagedefault = 0;
}
+ if (!isset($form->minquestions)) {
+ $form->minquestions = 0;
+ }
if (!isset($form->maxpages)) {
$form->maxpages = 0;
}
@@ -58,14 +64,14 @@
</tr>
<tr valign=top>
- <td align=right><P><B><?php print_string("maximumnumberofanswers", "lesson") ?>:</B></P></TD>
+ <td align=right><P><B><?php print_string("maximumnumberofanswersbranches", "lesson") ?>:</B></P></TD>
<td>
<?php
for ($i=10; $i>1; $i--) {
$numbers[$i] = $i;
}
choose_from_menu($numbers, "maxanswers", "$form->maxanswers", "");
- helpbutton("maxanswers", get_string("maximumnumberofanswers", "lesson"), "lesson");
+ helpbutton("maxanswers", get_string("maximumnumberofanswersbranches", "lesson"), "lesson");
?>
</td>
</tr>
@@ -95,6 +101,20 @@
</tr>
<tr valign=top>
+ <td align=right><P><B><?php print_string("minimumnumberofquestions", "lesson") ?>:</B></P></TD>
+ <td>
+ <?php
+ unset($numbers);
+ for ($i=100; $i>=0; $i--) {
+ $numbers[$i] = $i;
+ }
+ choose_from_menu($numbers, "minquestions", "$form->minquestions", "");
+ helpbutton("minquestions", get_string("minimumnumberofquestions", "lesson"), "lesson");
+ ?>
+ </td>
+</tr>
+
+<tr valign=top>
<td align=right><P><B><?php print_string("numberofpagestoshow", "lesson") ?>:</B></P></TD>
<td>
<?php
@@ -119,6 +139,17 @@
</td>
</tr>
+<tr>
+ <td align=right><P><B><?php print_string("handlingofretakes", "lesson") ?>:</B></P></TD>
+ <td>
+ <?PHP
+ $options[0] = get_string("usemean", "lesson"); $options[1] = get_string("usemaximum", "lesson");
+ choose_from_menu($options, "usemaxgrade", $form->usemaxgrade, "");
+ helpbutton("handlingofretakes", get_string("handlingofretakes", "lesson"), "lesson");
+ ?>
+ </td>
+</tr>
+
<tr valign=top>
<td align=right><P><B><?php print_string("available", "lesson") ?>:</B></td>
<td><?php
View
4 mod/lesson/restorelib.php
@@ -52,9 +52,11 @@ function lesson_restore_mods($mod,$restore) {
$lesson->course = $restore->course_id;
$lesson->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
$lesson->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
+ $lesson->usemaxgrade = backup_todb($info['MOD']['#']['USEMAXGRADE']['0']['#']);
$lesson->maxanswers = backup_todb($info['MOD']['#']['MAXANSWERS']['0']['#']);
$lesson->maxattempts = backup_todb($info['MOD']['#']['MAXATTEMPTS']['0']['#']);
$lesson->nextpagedefault = backup_todb($info['MOD']['#']['NEXTPAGEDEFAULT']['0']['#']);
+ $lesson->minquestions = backup_todb($info['MOD']['#']['MINQUESTIONS']['0']['#']);
$lesson->maxpages = backup_todb($info['MOD']['#']['MAXPAGES']['0']['#']);
$lesson->retake = backup_todb($info['MOD']['#']['RETAKE']['0']['#']);
$lesson->available = backup_todb($info['MOD']['#']['AVAILABLE']['0']['#']);
@@ -254,9 +256,9 @@ function lesson_attempts_restore($lessonid, $pageid, $answerid, $info, $restore)
$attempt->pageid = $pageid;
$attempt->answerid = $answerid;
$attempt->userid = backup_todb($attempt_info['#']['USERID']['0']['#']);
+ $attempt->retry = backup_todb($attempt_info['#']['RETRY']['0']['#']);
$attempt->correct = backup_todb($attempt_info['#']['CORRECT']['0']['#']);
$attempt->timeseen = backup_todb($attempt_info['#']['TIMESEEN']['0']['#']);
- $attempt->retry = backup_todb($attempt_info['#']['RETRY']['0']['#']);
//We have to recode the userid field
$user = backup_getid($restore->backup_unique_code,"user",$olduserid);
View
2  mod/lesson/version.php
@@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2004032000; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2004032400; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2004013101; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
View
271 mod/lesson/view.php
@@ -60,7 +60,7 @@
// display individual pages and their sets of answers
// if pageid is EOL then the end of the lesson has been reached
print_heading($lesson->name);
- if (empty($pageid)) {
+ if (empty($pageid)) {
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
if ($grades = get_records_select("lesson_grades", "lessonid = $lesson->id AND userid = $USER->id",
@@ -135,7 +135,55 @@
if (!$page = get_record("lesson_pages", "id", $pageid)) {
error("Navigation: the page record not found");
}
+ // before we output everything check to see if the page is a EOB, if so jump directly
+ // to it's associated branch table
+ if ($page->qtype == LESSON_ENDOFBRANCH) {
+ if ($answers = get_records("lesson_answers", "pageid", $page->id, "id")) {
+ // print_heading(get_string("endofbranch", "lesson"));
+ foreach ($answers as $answer) {
+ // just need the first answer
+ redirect("view.php?id=$cm->id&action=navigation&pageid=$answer->jumpto",
+ get_string("endofbranch", "lesson"));
+ break;
+ }
+ print_footer($course);
+ exit();
+ } else {
+ error("Navigation: No answers on EOB");
+ }
+ }
+ // it's not a EOB process it...
echo "<table align=\"center\" width=\"80%\" border=\"0\"><tr><td>\n";
+ if ($page->qtype == LESSON_BRANCHTABLE) {
+ if ($lesson->minquestions and isstudent($course->id)) {
+ // tell student how many questions they have seen, how many are required and their grade
+ $ntries = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id);
+ $nviewed = count_records("lesson_attempts", "lessonid", $lesson->id, "userid",
+ $USER->id, "retry", $ntries);
+ if ($nviewed) {
+ echo "<p align=\"center\">".get_string("numberofpagesviewed", "lesson", $nviewed).
+ "; (".get_string("youshouldview", "lesson", $lesson->minquestions).")<br />";
+ // count the number of distinct correct pages
+ if ($correctpages = get_records_select("lesson_attempts", "lessonid = $lesson->id
+ AND userid = $USER->id AND retry = $ntries AND correct = 1")) {
+ foreach ($correctpages as $correctpage) {
+ $temp[$correctpage->pageid] = 1;
+ }
+ $ncorrect = count($temp);
+ } else {
+ $nccorrect = 0;
+ }
+ if ($nviewed < $lesson->minquestions) {
+ $nviewed = $lesson->minquestions;
+ }
+ echo get_string("numberofcorrectanswers", "lesson", $ncorrect)."<br />\n";
+ $thegrade = intval(100 * $ncorrect / $nviewed);
+ echo get_string("yourcurrentgradeis", "lesson",
+ number_format($thegrade * $lesson->grade / 100, 1)).
+ " (".get_string("outof", "lesson", $lesson->grade).")</p>\n";
+ }
+ }
+ }
print_heading($page->title);
print_simple_box(format_text($page->contents), 'center');
echo "<br />\n";
@@ -224,6 +272,21 @@
echo "<p align=\"center\"><input type=\"submit\" name=\"continue\" value=\"".
get_string("pleasematchtheabovepairs", "lesson")."\"></p>\n";
break;
+
+ case LESSON_BRANCHTABLE :
+ echo "<tr><td><table width=\"100%\">";
+ echo "<input type=\"hidden\" name=\"jumpto\">";
+ // don't suffle answers
+ foreach ($answers as $answer) {
+ echo "<tr><td align=\"center\">";
+ echo "<input type=\"button\" value=\"$answer->answer\"";
+ echo "onclick=\"document.answerform.jumpto.value=$answer->jumpto;document.answerform.submit();\">";
+ echo "</td></tr>";
+ }
+ echo '</table></table>';
+ print_simple_box_end();
+ break;
+
}
echo "</form>\n";
} else {
@@ -248,74 +311,44 @@
print_simple_box_start("center");
$ntries = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id);
if (isstudent($course->id)) {
- // do a sanity check on the user's path through a normal lesson (not a Flash Card lesson)
- if ($attempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND
- userid = $USER->id AND retry = $ntries", "timeseen ASC")) {
- $check = true;
- if ($lesson->nextpagedefault == 0) {
- if (!$thispageid = get_field("lesson_pages", "id", "lessonid", $lesson->id,
- "prevpageid", 0)) {
- error("Navigation Check: first page not found");
- }
- foreach ($attempts as $attempt) {
- // skip any page without answers
- while (!$answers = get_records("lesson_answers", "pageid", $thispageid)) {
- if (!$thispageid = get_field("lesson_pages", "nextpageid", "id", $thispageid)) {
- error("Navigation Check: nextpageid not found");
- }
- }
- if ($attempt->pageid != $thispageid) {
- // something odd
- // echo "<p>\$thispageid: $thispageid; \$attempt->pageid: $attempt->pageid</p>\n";
- $check = false;
- break;
- }
- if (!$answer = get_record("lesson_answers", "id", $attempt->answerid)) {
- error("Navigation Check: answer not found");
- }
- if ($answer->jumpto) {
- if ($answer->jumpto == LESSON_NEXTPAGE) {
- if (!$thispageid = get_field("lesson_pages", "nextpageid", "id",
- $thispageid)) {
- $thispageid = LESSON_EOL; // end of foreach loop should have been reached
- }
- } else {
- $thispageid = $answer->jumpto;
- }
- }
+ if ($nviewed = count_records("lesson_attempts", "lessonid", $lesson->id, "userid",
+ $USER->id, "retry", $ntries)) {
+ // count the number of distinct correct pages
+ if ($correctpages = get_records_select("lesson_attempts", "lessonid = $lesson->id AND
+ userid = $USER->id AND retry = $ntries AND correct = 1")) {
+ foreach ($correctpages as $correctpage) {
+ $temp[$correctpage->pageid] = 1;
}
+ $ncorrect = count($temp);
+ } else {
+ $ncorrect = 0;
}
- if ($check) {
- $ncorrect = count_records_select("lesson_attempts", "lessonid = $lesson->id AND
- userid = $USER->id AND retry = $ntries AND correct = 1");
- $nviewed = count_records("lesson_attempts", "lessonid", $lesson->id, "userid",
- $USER->id, "retry", $ntries);
- if ($nviewed) {
- $thegrade = intval(100 * $ncorrect / $nviewed);
- } else {
- $thegrade = 0;
- }
- echo "<p align=\"center\">".get_string("numberofpagesviewed", "lesson", $nviewed).
- "</p>\n";
- echo "<p align=\"center\">".get_string("numberofcorrectanswers", "lesson", $ncorrect).
- "</p>\n";
- echo "<p align=\"center\">".get_string("gradeis", "lesson",
- number_format($thegrade * $lesson->grade / 100, 1)).
- " (".get_string("outof", "lesson", $lesson->grade).")</p>\n";
- $grade->lessonid = $lesson->id;
- $grade->userid = $USER->id;
- $grade->grade = $thegrade;
- $grade->completed = time();
- if (!$newgradeid = insert_record("lesson_grades", $grade)) {
- error("Navigation: grade not inserted");
+ echo "<p align=\"center\">".get_string("numberofpagesviewed", "lesson", $nviewed).
+ "</p>\n";
+ if ($lesson->minquestions) {
+ if ($nviewed < $lesson->minquestions) {
+ // print a warning and set nviewed to minquestions
+ echo "<p align=\"center\">".get_string("youshouldview", "lesson",
+ $lesson->minquestions)." ".get_string("pages", "lesson")."</p>\n";
+ $nviewed = $lesson->minquestions;
}
- } else {
- print_string("sanitycheckfailed", "lesson");
- delete_records("lesson_attempts", "lessonid", $lesson->id, "userid", $USER->id,
- "retry", $ntries);
+ }
+ echo "<p align=\"center\">".get_string("numberofcorrectanswers", "lesson", $ncorrect).
+ "</p>\n";
+ $thegrade = intval(100 * $ncorrect / $nviewed);
+ echo "<p align=\"center\">".get_string("gradeis", "lesson",
+ number_format($thegrade * $lesson->grade / 100, 1)).
+ " (".get_string("outof", "lesson", $lesson->grade).")</p>\n";
+ $grade->lessonid = $lesson->id;
+ $grade->userid = $USER->id;
+ $grade->grade = $thegrade;
+ $grade->completed = time();
+ if (!$newgradeid = insert_record("lesson_grades", $grade)) {
+ error("Navigation: grade not inserted");
}
} else {
print_string("noattemptrecordsfound", "lesson");
+ $thegrade = 0;
}
} else {
// display for teacher
@@ -409,8 +442,11 @@
if (isteacheredit($course->id)) {
echo "<tr><td align=\"right\"><small><a href=\"import.php?id=$cm->id&pageid=0\">".
get_string("importquestions", "lesson")."</a> | ".
- "<a href=\"lesson.php?id=$cm->id&action=addpage&pageid=0\">".
- get_string("addpagehere", "lesson")."</a></small></td></tr>\n";
+ "<a href=\"lesson.php?id=$cm->id&action=addbranchtable&pageid=0\">".
+ get_string("addabranchtable", "lesson")."</a> | ".
+ "<a href=\"lesson.php?id=$cm->id&action=addendofbranch&pageid=0\">".
+ get_string("addaquestionpage", "lesson")." ".get_string("here","lesson").
+ "</a></small></td></tr>\n";
}
echo "<tr><td>\n";
while (true) {
@@ -434,42 +470,69 @@
foreach ($answers as $answer) {
echo "<tr><td bgcolor=\"$THEME->cellheading2\" colspan=\"2\" align=\"center\"><b>\n";
if ($i == 1) {
- echo $LESSON_QUESTION_TYPE[$page->qtype];
switch ($page->qtype) {
case LESSON_SHORTANSWER :
+ echo $LESSON_QUESTION_TYPE[$page->qtype];
if ($page->qoption) {
echo " - ".get_string("casesensitive", "lesson");
}
break;
case LESSON_MULTICHOICE :
+ echo $LESSON_QUESTION_TYPE[$page->qtype];
if ($page->qoption) {
echo " - ".get_string("multianswer", "lesson");
}
break;
case LESSON_MATCHING :
+ echo $LESSON_QUESTION_TYPE[$page->qtype];
if (!lesson_iscorrect($page->id, $answer->jumpto)) {
echo " - ".get_string("firstanswershould", "lesson");
}
break;
+ case LESSON_TRUEFALSE :
+ case LESSON_NUMERICAL :
+ echo $LESSON_QUESTION_TYPE[$page->qtype];
+ break;
+ case LESSON_BRANCHTABLE :
+ echo get_string("branchtable", "lesson");
+ break;
+ case LESSON_ENDOFBRANCH :
+ echo get_string("endofbranch", "lesson");
+ break;
}
} else {
echo "&nbsp;";
}
echo "</b></td></tr>\n";
- echo "<tr><td align=\"right\" valign=\"top\" width=\"20%\">\n";
- if (lesson_iscorrect($page->id, $answer->jumpto)) {
- // underline correct answers
- echo "<b><u>".get_string("answer", "lesson")." $i:</u></b> \n";
- } else {
- echo "<b>".get_string("answer", "lesson")." $i:</b> \n";
+ switch ($page->qtype) {
+ case LESSON_MULTICHOICE:
+ case LESSON_TRUEFALSE:
+ case LESSON_SHORTANSWER:
+ case LESSON_NUMERICAL:
+ case LESSON_MATCHING:
+ echo "<tr><td align=\"right\" valign=\"top\" width=\"20%\">\n";
+ if (lesson_iscorrect($page->id, $answer->jumpto)) {
+ // underline correct answers
+ echo "<b><u>".get_string("answer", "lesson")." $i:</u></b> \n";
+ } else {
+ echo "<b>".get_string("answer", "lesson")." $i:</b> \n";
+ }
+ echo "</td><td width=\"80%\">\n";
+ echo format_text($answer->answer);
+ echo "</td></tr>\n";
+ echo "<tr><td align=\"right\" valign=\"top\"><b>".get_string("response", "lesson")." $i:</b> \n";
+ echo "</td><td>\n";
+ echo format_text($answer->response);
+ echo "</td></tr>\n";
+ break;
+ case LESSON_BRANCHTABLE:
+ echo "<tr><td align=\"right\" valign=\"top\" width=\"20%\">\n";
+ echo "<b>".get_string("description", "lesson")." $i:</b> \n";
+ echo "</td><td width=\"80%\">\n";
+ echo format_text($answer->answer);
+ echo "</td></tr>\n";
+ break;
}
- echo "</td><td width=\"80%\">\n";
- echo format_text($answer->answer);
- echo "</td></tr>\n";
- echo "<tr><td align=\"right\" valign=\"top\"><b>".get_string("response", "lesson")." $i:</b> \n";
- echo "</td><td>\n";
- echo format_text($answer->response);
- echo "</td></tr>\n";
if ($answer->jumpto == 0) {
$jumptitle = get_string("thispage", "lesson");
} elseif ($answer->jumpto == LESSON_NEXTPAGE) {
@@ -481,25 +544,59 @@
$jumptitle = "<b>".get_string("notdefined", "lesson")."</b>";
}
}
- echo "<tr><td align=\"right\"><b>".get_string("jumpto", "lesson").": </b>\n";
- echo "</td><td>\n";
+ echo "<tr><td align=\"right\" width=\"20%\"><b>".get_string("jumpto", "lesson").": ";
+ echo "</b></td><td width=\"80%\">\n";
echo "$jumptitle</td></tr>\n";
$i++;
}
// print_simple_box_end();
- echo "<tr><td bgcolor=\"$THEME->cellheading2\" colspan=\"2\" align=\"center\">".
- "<input type=\"button\" value=\"".get_string("checkquestion", "lesson")."\" ".
- "onclick=\"document.lessonpages.pageid.value=$page->id;".
- "document.lessonpages.submit();\"></td></tr>\n";
+ echo "<tr><td bgcolor=\"$THEME->cellheading2\" colspan=\"2\" align=\"center\">";
+ if ($page->qtype != LESSON_ENDOFBRANCH) {
+ echo "<input type=\"button\" value=\"";
+ if ($page->qtype == LESSON_BRANCHTABLE) {
+ echo get_string("checkbranchtable", "lesson");
+ } else {
+ echo get_string("checkquestion", "lesson");
+ }
+ echo "\" onclick=\"document.lessonpages.pageid.value=$page->id;".
+ "document.lessonpages.submit();\">";
+ }
+ echo "&nbsp;</td></tr>\n";
}
echo "</td></tr></table></td></tr>\n";
if (isteacheredit($course->id)) {
echo "<tr><td align=\"right\"><small><a href=\"import.php?id=$cm->id&pageid=$page->id\">".
get_string("importquestions", "lesson")."</a> | ".
- "<a href=\"lesson.php?id=$cm->id&action=addpage&pageid=$page->id\">".
- get_string("addpagehere", "lesson")."</a></small></td></tr>\n";
+ "<a href=\"lesson.php?id=$cm->id&action=addbranchtable&pageid=$page->id\">".
+ get_string("addabranchtable", "lesson")."</a> | ";
+ // the current page or the next page is an end of branch don't show EOB link
+ $nextqtype = 0; // set to anything else EOB
+ if ($page->nextpageid) {
+ $nextqtype = get_field("lesson_pages", "qtype", "id", $page->nextpageid);
+ }
+ if (($page->qtype != LESSON_ENDOFBRANCH) and ($nextqtype != LESSON_ENDOFBRANCH)) {
+ echo "<a href=\"lesson.php?id=$cm->id&action=addendofbranch&pageid=$page->id\">".
+ get_string("addanendofbranch", "lesson")."</a> | ";
+ }
+ echo "<a href=\"lesson.php?id=$cm->id&action=addpage&pageid=$page->id\">".
+ get_string("addaquestionpage", "lesson")." ".get_string("here","lesson").
+ "</a></small></td></tr>\n";
}
echo "<tr><td>\n";
+ // check the prev links - fix (silently) if necessary - there was a bug in
+ // versions 1 and 2 when add new pages. Not serious then as the backwards
+ // links were not used in those versions
+ if (isset($prevpageid)) {
+ if ($page->prevpageid != $prevpageid) {
+ // fix it
+ set_field("lesson_pages", "prevpageid", $prevpageid, "id", $page->id);
+ if ($CFG->debug) {
+ echo "<p>***prevpageid of page $page->id set to $prevpageid***";
+ }
+ }
+ }
+ $prevpageid = $page->id;
+ // move to next page
if ($page->nextpageid) {
if (!$page = get_record("lesson_pages", "id", $page->nextpageid)) {
error("Teacher view: Next page not found!");
Please sign in to comment.
Something went wrong with that request. Please try again.