Tabs are out.

(all the module was using them, please change your editor settings to 4 spaces)
This commit is contained in:
stronk7 2005-05-16 22:41:19 +00:00
parent 894ff63f8f
commit 271fea974f
15 changed files with 1808 additions and 1810 deletions

View file

@ -1,83 +1,83 @@
<?php <?php
/************** add branch table ************************************/ /************** add branch table ************************************/
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
// first get the preceeding page // first get the preceeding page
$pageid = required_param('pageid', PARAM_INT); $pageid = required_param('pageid', PARAM_INT);
// set of jump array // set of jump array
$jump = array(); $jump = array();
$jump[0] = get_string("thispage", "lesson"); $jump[0] = get_string("thispage", "lesson");
$jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
//// CDC-FLAG ///// //// CDC-FLAG /////
$jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson"); $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson");
if (!isset($_GET['firstpage'])) { if (!isset($_GET['firstpage'])) {
$jump[LESSON_EOL] = get_string("endoflesson", "lesson"); $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
error("Add page: first page not found"); error("Add page: first page not found");
} }
while (true) { while (true) {
if ($apageid) { if ($apageid) {
$title = get_field("lesson_pages", "title", "id", $apageid); $title = get_field("lesson_pages", "title", "id", $apageid);
$jump[$apageid] = $title; $jump[$apageid] = $title;
$apageid = get_field("lesson_pages", "nextpageid", "id", $apageid); $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid);
} else { } else {
// last page reached // last page reached
break; break;
} }
} }
} }
//// CDC-FLAG ///// //// CDC-FLAG /////
// give teacher a blank proforma // give teacher a blank proforma
print_heading_with_help(get_string("addabranchtable", "lesson"), "overview", "lesson"); print_heading_with_help(get_string("addabranchtable", "lesson"), "overview", "lesson");
?> ?>
<form name="form" method="post" action="lesson.php" /> <form name="form" method="post" action="lesson.php" />
<input type="hidden" name="id" value="<?PHP echo $cm->id ?>" /> <input type="hidden" name="id" value="<?PHP echo $cm->id ?>" />
<input type="hidden" name="action" value="insertpage"> <input type="hidden" name="action" value="insertpage">
<input type="hidden" name="pageid" value="<?PHP echo $pageid ?>" /> <input type="hidden" name="pageid" value="<?PHP echo $pageid ?>" />
<input type="hidden" name="qtype" value="<?PHP echo LESSON_BRANCHTABLE ?>" /> <input type="hidden" name="qtype" value="<?PHP echo LESSON_BRANCHTABLE ?>" />
<input type="hidden" name="sesskey" value="<?PHP echo $USER->sesskey ?>" /> <input type="hidden" name="sesskey" value="<?PHP echo $USER->sesskey ?>" />
<center><table class="generalbox" cellpadding=5 border=1> <center><table class="generalbox" cellpadding=5 border=1>
<tr valign="top"> <tr valign="top">
<td><b><?php print_string("pagetitle", "lesson"); ?>:</b><br /> <td><b><?php print_string("pagetitle", "lesson"); ?>:</b><br />
<!-- //CDC hidden-label added.--><label for="title" class="hidden-label">Title</label><input type="text" id="title" name="title" size="80" maxsize="255" value="" /></td></tr> <!-- //CDC hidden-label added.--><label for="title" class="hidden-label">Title</label><input type="text" id="title" name="title" size="80" maxsize="255" value="" /></td></tr>
<?PHP <?PHP
echo "<tr><td><b>"; echo "<tr><td><b>";
echo get_string("pagecontents", "lesson").":</b><br />\n"; echo get_string("pagecontents", "lesson").":</b><br />\n";
print_textarea($usehtmleditor, 25,70, 630, 400, "contents"); print_textarea($usehtmleditor, 25,70, 630, 400, "contents");
use_html_editor("contents"); use_html_editor("contents");
echo "</td></tr>\n"; echo "</td></tr>\n";
/// CDC-FLAG /// 6/16/04 /// CDC-FLAG /// 6/16/04
echo "<tr><td>\n"; echo "<tr><td>\n";
echo "<center><input name=\"layout\" type=\"checkbox\" value=\"1\" checked=\"checked\" />"; echo "<center><input name=\"layout\" type=\"checkbox\" value=\"1\" checked=\"checked\" />";
echo get_string("arrangebuttonshorizontally", "lesson")."\n"; echo get_string("arrangebuttonshorizontally", "lesson")."\n";
echo "<br><input name=\"display\" type=\"checkbox\" value=\"1\" checked=\"checked\" />"; echo "<br><input name=\"display\" type=\"checkbox\" value=\"1\" checked=\"checked\" />";
echo get_string("displayinleftmenu", "lesson"); echo get_string("displayinleftmenu", "lesson");
echo "</center>\n"; echo "</center>\n";
echo "</td></tr>\n"; echo "</td></tr>\n";
/// CDC-FLAG /// /// CDC-FLAG ///
for ($i = 0; $i < $lesson->maxanswers; $i++) { for ($i = 0; $i < $lesson->maxanswers; $i++) {
$iplus1 = $i + 1; $iplus1 = $i + 1;
echo "<tr><td><b>".get_string("description", "lesson")." $iplus1:</b><br />\n"; echo "<tr><td><b>".get_string("description", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 10, 70, 630, 300, "answer[$i]"); // made the default set to off also removed use_html_editor(); line from down below, which made all textareas turn into html editors print_textarea(false, 10, 70, 630, 300, "answer[$i]"); // made the default set to off also removed use_html_editor(); line from down below, which made all textareas turn into html editors
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n"; echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
if ($i) { if ($i) {
// answers 2, 3, 4... jumpto this page // answers 2, 3, 4... jumpto this page
lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
} else { } else {
// answer 1 jumpto next page // answer 1 jumpto next page
lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
} }
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
echo "</td></tr>\n"; echo "</td></tr>\n";
} }
// close table and form // close table and form
?> ?>
</table><br /> </table><br />
<input type="submit" value="<?php print_string("addabranchtable", "lesson") ?>" /> <input type="submit" value="<?php print_string("addabranchtable", "lesson") ?>" />
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" /> <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
</center> </center>
</form> </form>

View file

@ -2,65 +2,65 @@
/************** add end of branch ************************************/ /************** add end of branch ************************************/
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
confirm_sesskey(); confirm_sesskey();
// first get the preceeding page // first get the preceeding page
$pageid = required_param('pageid', PARAM_INT); $pageid = required_param('pageid', PARAM_INT);
$timenow = time(); $timenow = time();
// the new page is not the first page (end of branch always comes after an existing page) // 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)) { if (!$page = get_record("lesson_pages", "id", $pageid)) {
error("Add end of branch: page record not found"); error("Add end of branch: page record not found");
} }
// chain back up to find the (nearest branch table) // chain back up to find the (nearest branch table)
$btpageid = $pageid; $btpageid = $pageid;
if (!$btpage = get_record("lesson_pages", "id", $btpageid)) { if (!$btpage = get_record("lesson_pages", "id", $btpageid)) {
error("Add end of branch: btpage record not found"); error("Add end of branch: btpage record not found");
} }
while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) { while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) {
$btpageid = $btpage->prevpageid; $btpageid = $btpage->prevpageid;
if (!$btpage = get_record("lesson_pages", "id", $btpageid)) { if (!$btpage = get_record("lesson_pages", "id", $btpageid)) {
error("Add end of branch: btpage record not found"); error("Add end of branch: btpage record not found");
} }
} }
if ($btpage->qtype == LESSON_BRANCHTABLE) { if ($btpage->qtype == LESSON_BRANCHTABLE) {
$newpage = new stdClass; $newpage = new stdClass;
$newpage->lessonid = $lesson->id; $newpage->lessonid = $lesson->id;
$newpage->prevpageid = $pageid; $newpage->prevpageid = $pageid;
$newpage->nextpageid = $page->nextpageid; $newpage->nextpageid = $page->nextpageid;
$newpage->qtype = LESSON_ENDOFBRANCH; $newpage->qtype = LESSON_ENDOFBRANCH;
$newpage->timecreated = $timenow; $newpage->timecreated = $timenow;
$newpage->title = get_string("endofbranch", "lesson"); $newpage->title = get_string("endofbranch", "lesson");
$newpage->contents = get_string("endofbranch", "lesson"); $newpage->contents = get_string("endofbranch", "lesson");
if (!$newpageid = insert_record("lesson_pages", $newpage)) { if (!$newpageid = insert_record("lesson_pages", $newpage)) {
error("Insert page: new page not inserted"); error("Insert page: new page not inserted");
} }
// update the linked list... // update the linked list...
if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) { if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) {
error("Add end of branch: unable to update link"); error("Add end of branch: unable to update link");
} }
if ($page->nextpageid) { if ($page->nextpageid) {
// the new page is not the last page // the new page is not the last page
if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) { if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) {
error("Insert page: unable to update previous link"); error("Insert page: unable to update previous link");
} }
} }
// ..and the single "answer" // ..and the single "answer"
$newanswer = new stdClass; $newanswer = new stdClass;
$newanswer->lessonid = $lesson->id; $newanswer->lessonid = $lesson->id;
$newanswer->pageid = $newpageid; $newanswer->pageid = $newpageid;
$newanswer->timecreated = $timenow; $newanswer->timecreated = $timenow;
$newanswer->jumpto = $btpageid; $newanswer->jumpto = $btpageid;
if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { if(!$newanswerid = insert_record("lesson_answers", $newanswer)) {
error("Add end of branch: answer record not inserted"); error("Add end of branch: answer record not inserted");
} }
redirect("view.php?id=$cm->id", get_string('addedanendofbranch', 'lesson')); redirect("view.php?id=$cm->id", get_string('addedanendofbranch', 'lesson'));
} else { } else {
notice(get_string("nobranchtablefound", "lesson"), "view.php?id=$cm->id"); notice(get_string("nobranchtablefound", "lesson"), "view.php?id=$cm->id");
} }
?> ?>

View file

@ -2,240 +2,240 @@
/************** add page ************************************/ /************** add page ************************************/
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
// first get the preceeding page // first get the preceeding page
$pageid = required_param('pageid', PARAM_INT); $pageid = required_param('pageid', PARAM_INT);
// set of jump array // set of jump array
$jump = array(); $jump = array();
$jump[0] = get_string("thispage", "lesson"); $jump[0] = get_string("thispage", "lesson");
$jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
//// CDC-FLAG 6/18/04 ///// //// CDC-FLAG 6/18/04 /////
$jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson"); $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson");
if(lesson_display_branch_jumps($lesson->id, $pageid)) { if(lesson_display_branch_jumps($lesson->id, $pageid)) {
$jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson"); $jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson");
$jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson"); $jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson");
} }
if(lesson_display_cluster_jump($lesson->id, $pageid)) { if(lesson_display_cluster_jump($lesson->id, $pageid)) {
$jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson"); $jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson");
} }
/// CDC-FLAG /// /// CDC-FLAG ///
if (!isset($_GET['firstpage'])) { if (!isset($_GET['firstpage'])) {
$linkadd = ""; $linkadd = "";
$jump[LESSON_EOL] = get_string("endoflesson", "lesson"); $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
error("Add page: first page not found"); error("Add page: first page not found");
} }
while (true) { while (true) {
if ($apageid) { if ($apageid) {
$title = get_field("lesson_pages", "title", "id", $apageid); $title = get_field("lesson_pages", "title", "id", $apageid);
$jump[$apageid] = strip_tags(format_string($title,true)); $jump[$apageid] = strip_tags(format_string($title,true));
$apageid = get_field("lesson_pages", "nextpageid", "id", $apageid); $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid);
} else { } else {
// last page reached // last page reached
break; break;
} }
} }
} else { } else {
$linkadd = "&firstpage=1"; $linkadd = "&firstpage=1";
} }
// give teacher a blank proforma // give teacher a blank proforma
print_heading_with_help(get_string("addaquestionpage", "lesson"), "overview", "lesson"); print_heading_with_help(get_string("addaquestionpage", "lesson"), "overview", "lesson");
?> ?>
<form name="form" method="post" action="lesson.php"> <form name="form" method="post" action="lesson.php">
<input type="hidden" name="id" value="<?PHP echo $cm->id ?>"> <input type="hidden" name="id" value="<?PHP echo $cm->id ?>">
<input type="hidden" name="action" value="insertpage"> <input type="hidden" name="action" value="insertpage">
<input type="hidden" name="pageid" value="<?PHP echo $pageid ?>"> <input type="hidden" name="pageid" value="<?PHP echo $pageid ?>">
<input type="hidden" name="sesskey" value="<?PHP echo $USER->sesskey ?>"> <input type="hidden" name="sesskey" value="<?PHP echo $USER->sesskey ?>">
<center> <center>
<?php <?php
echo '<b>'.get_string("questiontype", "lesson").":</b> \n"; echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."<br>"; echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."<br>";
if (isset($_GET['qtype'])) { if (isset($_GET['qtype'])) {
$qtype = clean_param($_GET['qtype'], PARAM_INT); $qtype = clean_param($_GET['qtype'], PARAM_INT);
lesson_qtype_menu($LESSON_QUESTION_TYPE, $qtype, lesson_qtype_menu($LESSON_QUESTION_TYPE, $qtype,
"lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd); "lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd);
// NoticeFix rearraged // NoticeFix rearraged
if ( $qtype == LESSON_SHORTANSWER || $qtype == LESSON_MULTICHOICE ) { // only display this option for Multichoice and shortanswer if ( $qtype == LESSON_SHORTANSWER || $qtype == LESSON_MULTICHOICE ) { // only display this option for Multichoice and shortanswer
echo '<p>'; echo '<p>';
if ($qtype == LESSON_SHORTANSWER) { if ($qtype == LESSON_SHORTANSWER) {
echo "<b>".get_string("casesensitive", "lesson").":</b> \n"; echo "<b>".get_string("casesensitive", "lesson").":</b> \n";
} else { } else {
echo "<b>".get_string("multianswer", "lesson").":</b> \n"; echo "<b>".get_string("multianswer", "lesson").":</b> \n";
} }
echo " <label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added. echo " <label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added.
helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson");
echo '</p>'; echo '</p>';
} }
} else { } else {
lesson_qtype_menu($LESSON_QUESTION_TYPE, LESSON_MULTICHOICE, lesson_qtype_menu($LESSON_QUESTION_TYPE, LESSON_MULTICHOICE,
"lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd); "lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd);
echo "<br><br><b>".get_string("multianswer", "lesson").":</b> \n"; echo "<br><br><b>".get_string("multianswer", "lesson").":</b> \n";
echo " <label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added. echo " <label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added.
helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson");
} }
?> ?>
<table cellpadding="5" class="generalbox" border="1"> <table cellpadding="5" class="generalbox" border="1">
<tr valign="top"> <tr valign="top">
<td><b><?php print_string("pagetitle", "lesson"); ?>:</b><br /> <td><b><?php print_string("pagetitle", "lesson"); ?>:</b><br />
<!-- //CDC hidden-label added.--><label for="title" class="hidden-label">Title</label><input type="text" id="title" name="title" size="80" maxsize="255" value=""></td></tr> <!-- //CDC hidden-label added.--><label for="title" class="hidden-label">Title</label><input type="text" id="title" name="title" size="80" maxsize="255" value=""></td></tr>
<?PHP <?PHP
echo "<tr><td><b>"; echo "<tr><td><b>";
echo get_string("pagecontents", "lesson").":</b><br />\n"; echo get_string("pagecontents", "lesson").":</b><br />\n";
print_textarea($usehtmleditor, 25,70, 630, 400, "contents"); print_textarea($usehtmleditor, 25,70, 630, 400, "contents");
use_html_editor("contents"); use_html_editor("contents");
echo "</td></tr>\n"; echo "</td></tr>\n";
if (isset($_GET['qtype'])) { if (isset($_GET['qtype'])) {
switch ($_GET['qtype']) { switch ($_GET['qtype']) {
case LESSON_TRUEFALSE : case LESSON_TRUEFALSE :
for ($i = 0; $i < 2; $i++) { for ($i = 0; $i < 2; $i++) {
$iplus1 = $i + 1; $iplus1 = $i + 1;
echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n"; echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]"); print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n"; echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "response[$i]"); print_textarea(false, 6, 70, 630, 300, "response[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n"; echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
if ($i) { if ($i) {
// answers 2, 3, 4... jumpto this page // answers 2, 3, 4... jumpto this page
lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
} else { } else {
// answer 1 jumpto next page // answer 1 jumpto next page
lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
} }
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
/// CDC-FLAG /// /// CDC-FLAG ///
if($lesson->custom) { if($lesson->custom) {
if ($i) { if ($i) {
echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">"; echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
} else { } else {
echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">"; echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
} }
} }
/// CDC-FLAG /// /// CDC-FLAG ///
echo "</td></tr>\n"; echo "</td></tr>\n";
} }
break; break;
case LESSON_ESSAY : case LESSON_ESSAY :
echo "<tr><td><B>".get_string("jump", "lesson").":</b> \n"; echo "<tr><td><B>".get_string("jump", "lesson").":</b> \n";
lesson_choose_from_menu($jump, "jumpto[0]", LESSON_NEXTPAGE, ""); lesson_choose_from_menu($jump, "jumpto[0]", LESSON_NEXTPAGE, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if ($lesson->custom) { if ($lesson->custom) {
echo get_string("score", "lesson").": <input type=\"text\" name=\"score[0]\" value=\"1\" size=\"5\">"; echo get_string("score", "lesson").": <input type=\"text\" name=\"score[0]\" value=\"1\" size=\"5\">";
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
case LESSON_MATCHING : case LESSON_MATCHING :
for ($i = 0; $i < $lesson->maxanswers+2; $i++) { for ($i = 0; $i < $lesson->maxanswers+2; $i++) {
$icorrected = $i - 1; $icorrected = $i - 1;
if ($i == 0) { if ($i == 0) {
echo "<tr><td><b>".get_string("correctresponse", "lesson").":</b><br />\n"; echo "<tr><td><b>".get_string("correctresponse", "lesson").":</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]"); print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
} elseif ($i == 1) { } elseif ($i == 1) {
echo "<tr><td><b>".get_string("wrongresponse", "lesson").":</b><br />\n"; echo "<tr><td><b>".get_string("wrongresponse", "lesson").":</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]"); print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
} else { } else {
echo "<tr><td><b>".get_string("answer", "lesson")." $icorrected:</b><br />\n"; echo "<tr><td><b>".get_string("answer", "lesson")." $icorrected:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]"); print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $icorrected:</b><br />\n"; echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $icorrected:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "response[$i]"); print_textarea(false, 6, 70, 630, 300, "response[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
} }
if ($i == 2) { if ($i == 2) {
echo "<tr><td><B>".get_string("correctanswerjump", "lesson").":</b> \n"; echo "<tr><td><B>".get_string("correctanswerjump", "lesson").":</b> \n";
lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) { if($lesson->custom) {
echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">"; echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
} elseif ($i == 3) { } elseif ($i == 3) {
echo "<tr><td><B>".get_string("wronganswerjump", "lesson").":</b> \n"; echo "<tr><td><B>".get_string("wronganswerjump", "lesson").":</b> \n";
lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) { if($lesson->custom) {
echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">"; echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
} }
} }
break; break;
case LESSON_SHORTANSWER : case LESSON_SHORTANSWER :
case LESSON_NUMERICAL : case LESSON_NUMERICAL :
case LESSON_MULTICHOICE : case LESSON_MULTICHOICE :
// default code // default code
for ($i = 0; $i < $lesson->maxanswers; $i++) { for ($i = 0; $i < $lesson->maxanswers; $i++) {
$iplus1 = $i + 1; $iplus1 = $i + 1;
echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n"; echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]"); print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n"; echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "response[$i]"); print_textarea(false, 6, 70, 630, 300, "response[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n"; echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
if ($i) { if ($i) {
// answers 2, 3, 4... jumpto this page // answers 2, 3, 4... jumpto this page
lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
} else { } else {
// answer 1 jumpto next page // answer 1 jumpto next page
lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
} }
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
/// CDC-FLAG /// /// CDC-FLAG ///
if($lesson->custom) { if($lesson->custom) {
if ($i) { if ($i) {
echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">"; echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
} else { } else {
echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">"; echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
} }
} }
/// CDC-FLAG /// /// CDC-FLAG ///
echo "</td></tr>\n"; echo "</td></tr>\n";
} }
break; break;
} }
} else { } else {
for ($i = 0; $i < $lesson->maxanswers; $i++) { for ($i = 0; $i < $lesson->maxanswers; $i++) {
$iplus1 = $i + 1; $iplus1 = $i + 1;
echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n"; echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$i]"); print_textarea(false, 6, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n"; echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b><br />\n";
print_textarea(false, 6, 70, 630, 300, "response[$i]"); print_textarea(false, 6, 70, 630, 300, "response[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n"; echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
if ($i) { if ($i) {
// answers 2, 3, 4... jumpto this page // answers 2, 3, 4... jumpto this page
lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
} else { } else {
// answer 1 jumpto next page // answer 1 jumpto next page
lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, "");
} }
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
/// CDC-FLAG /// /// CDC-FLAG ///
if($lesson->custom) { if($lesson->custom) {
if ($i) { if ($i) {
echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">"; echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
} else { } else {
echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">"; echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
} }
} }
/// CDC-FLAG /// /// CDC-FLAG ///
echo "</td></tr>\n"; echo "</td></tr>\n";
} }
} }
// close table and form // close table and form
?> ?>
</table><br /> </table><br />
<input type="submit" value="<?php print_string("addaquestionpage", "lesson") ?>"> <input type="submit" value="<?php print_string("addaquestionpage", "lesson") ?>">
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>"> <input type="submit" name="cancel" value="<?php print_string("cancel") ?>">
</center> </center>
</form> </form>

View file

@ -2,30 +2,30 @@
/******************* confirm delete ************************************/ /******************* confirm delete ************************************/
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
confirm_sesskey(); confirm_sesskey();
$pageid = required_param('pageid', PARAM_INT); $pageid = required_param('pageid', PARAM_INT);
if (!$thispage = get_record("lesson_pages", "id", $pageid)) { if (!$thispage = get_record("lesson_pages", "id", $pageid)) {
error("Confirm delete: the page record not found"); error("Confirm delete: the page record not found");
} }
print_heading(get_string("deletingpage", "lesson", format_string($thispage->title))); print_heading(get_string("deletingpage", "lesson", format_string($thispage->title)));
// print the jumps to this page // print the jumps to this page
if ($answers = get_records_select("lesson_answers", "lessonid = $lesson->id AND jumpto = $pageid + 1")) { if ($answers = get_records_select("lesson_answers", "lessonid = $lesson->id AND jumpto = $pageid + 1")) {
print_heading(get_string("thefollowingpagesjumptothispage", "lesson")); print_heading(get_string("thefollowingpagesjumptothispage", "lesson"));
echo "<p align=\"center\">\n"; echo "<p align=\"center\">\n";
foreach ($answers as $answer) { foreach ($answers as $answer) {
if (!$title = get_field("lesson_pages", "title", "id", $answer->pageid)) { if (!$title = get_field("lesson_pages", "title", "id", $answer->pageid)) {
error("Confirm delete: page title not found"); error("Confirm delete: page title not found");
} }
echo $title."<br />\n"; echo $title."<br />\n";
} }
} }
notice_yesno(get_string("confirmdeletionofthispage","lesson"), notice_yesno(get_string("confirmdeletionofthispage","lesson"),
"lesson.php?action=delete&amp;id=$cm->id&amp;pageid=$pageid&amp;sesskey=".$USER->sesskey, "lesson.php?action=delete&amp;id=$cm->id&amp;pageid=$pageid&amp;sesskey=".$USER->sesskey,
"view.php?id=$cm->id"); "view.php?id=$cm->id");
?> ?>

File diff suppressed because it is too large Load diff

View file

@ -2,59 +2,59 @@
/******************* delete ************************************/ /******************* delete ************************************/
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
confirm_sesskey(); confirm_sesskey();
if (empty($_GET['pageid'])) { if (empty($_GET['pageid'])) {
error("Delete: pageid missing"); error("Delete: pageid missing");
} }
$pageid = required_param('pageid', PARAM_INT); $pageid = required_param('pageid', PARAM_INT);
if (!$thispage = get_record("lesson_pages", "id", $pageid)) { if (!$thispage = get_record("lesson_pages", "id", $pageid)) {
error("Delete: page record not found"); error("Delete: page record not found");
} }
print_string("deleting", "lesson"); print_string("deleting", "lesson");
// first delete all the associated records... // first delete all the associated records...
delete_records("lesson_attempts", "pageid", $pageid); delete_records("lesson_attempts", "pageid", $pageid);
// ...now delete the answers... // ...now delete the answers...
delete_records("lesson_answers", "pageid", $pageid); delete_records("lesson_answers", "pageid", $pageid);
// ..and the page itself // ..and the page itself
delete_records("lesson_pages", "id", $pageid); delete_records("lesson_pages", "id", $pageid);
// repair the hole in the linkage // repair the hole in the linkage
if (!$thispage->prevpageid) { if (!$thispage->prevpageid) {
// this is the first page... // this is the first page...
if (!$page = get_record("lesson_pages", "id", $thispage->nextpageid)) { if (!$page = get_record("lesson_pages", "id", $thispage->nextpageid)) {
error("Delete: next page not found"); error("Delete: next page not found");
} }
if (!set_field("lesson_pages", "prevpageid", 0, "id", $page->id)) { if (!set_field("lesson_pages", "prevpageid", 0, "id", $page->id)) {
error("Delete: unable to set prevpage link"); error("Delete: unable to set prevpage link");
} }
} elseif (!$thispage->nextpageid) { } elseif (!$thispage->nextpageid) {
// this is the last page... // this is the last page...
if (!$page = get_record("lesson_pages", "id", $thispage->prevpageid)) { if (!$page = get_record("lesson_pages", "id", $thispage->prevpageid)) {
error("Delete: prev page not found"); error("Delete: prev page not found");
} }
if (!set_field("lesson_pages", "nextpageid", 0, "id", $page->id)) { if (!set_field("lesson_pages", "nextpageid", 0, "id", $page->id)) {
error("Delete: unable to set nextpage link"); error("Delete: unable to set nextpage link");
} }
} else { } else {
// page is in the middle... // page is in the middle...
if (!$prevpage = get_record("lesson_pages", "id", $thispage->prevpageid)) { if (!$prevpage = get_record("lesson_pages", "id", $thispage->prevpageid)) {
error("Delete: prev page not found"); error("Delete: prev page not found");
} }
if (!$nextpage = get_record("lesson_pages", "id", $thispage->nextpageid)) { if (!$nextpage = get_record("lesson_pages", "id", $thispage->nextpageid)) {
error("Delete: next page not found"); error("Delete: next page not found");
} }
if (!set_field("lesson_pages", "nextpageid", $nextpage->id, "id", $prevpage->id)) { if (!set_field("lesson_pages", "nextpageid", $nextpage->id, "id", $prevpage->id)) {
error("Delete: unable to set next link"); error("Delete: unable to set next link");
} }
if (!set_field("lesson_pages", "prevpageid", $prevpage->id, "id", $nextpage->id)) { if (!set_field("lesson_pages", "prevpageid", $prevpage->id, "id", $nextpage->id)) {
error("Delete: unable to set prev link"); error("Delete: unable to set prev link");
} }
} }
redirect("view.php?id=$cm->id", get_string('deletedpage', 'lesson')); redirect("view.php?id=$cm->id", get_string('deletedpage', 'lesson'));
?> ?>

View file

@ -2,468 +2,468 @@
/************** edit page ************************************/ /************** edit page ************************************/
if (!isteacher($course->id)) { if (!isteacher($course->id)) {
error("Only teachers can look at this page"); error("Only teachers can look at this page");
} }
// get the page // get the page
$pageid = required_param('pageid', PARAM_INT); $pageid = required_param('pageid', PARAM_INT);
if (!$page = get_record("lesson_pages", "id", $pageid)) { if (!$page = get_record("lesson_pages", "id", $pageid)) {
error("Edit page: page record not found"); error("Edit page: page record not found");
} }
if (isset($_GET['qtype'])) { if (isset($_GET['qtype'])) {
$page->qtype = required_param('qtype', PARAM_INT); $page->qtype = required_param('qtype', PARAM_INT);
} }
// set of jump array // set of jump array
$jump = array(); $jump = array();
$jump[0] = get_string("thispage", "lesson"); $jump[0] = get_string("thispage", "lesson");
$jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson");
//// CDC-FLAG 6/18/04 ///// //// CDC-FLAG 6/18/04 /////
$jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson"); $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson");
if(lesson_display_branch_jumps($lesson->id, $page->id)) { if(lesson_display_branch_jumps($lesson->id, $page->id)) {
$jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson"); $jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson");
$jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson"); $jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson");
} }
if ($page->qtype == LESSON_ENDOFBRANCH || $page->qtype == LESSON_BRANCHTABLE) { if ($page->qtype == LESSON_ENDOFBRANCH || $page->qtype == LESSON_BRANCHTABLE) {
$jump[LESSON_RANDOMBRANCH] = get_string("randombranch", "lesson"); $jump[LESSON_RANDOMBRANCH] = get_string("randombranch", "lesson");
} }
if(lesson_display_cluster_jump($lesson->id, $page->id) && $page->qtype != LESSON_BRANCHTABLE && $page->qtype != LESSON_ENDOFCLUSTER) { if(lesson_display_cluster_jump($lesson->id, $page->id) && $page->qtype != LESSON_BRANCHTABLE && $page->qtype != LESSON_ENDOFCLUSTER) {
$jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson"); $jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson");
} }
//// CDC-FLAG ///// //// CDC-FLAG /////
$jump[LESSON_EOL] = get_string("endoflesson", "lesson"); $jump[LESSON_EOL] = get_string("endoflesson", "lesson");
if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) {
error("Edit page: first page not found"); error("Edit page: first page not found");
} }
while (true) { while (true) {
if ($apageid) { if ($apageid) {
if (!$apage = get_record("lesson_pages", "id", $apageid)) { if (!$apage = get_record("lesson_pages", "id", $apageid)) {
error("Edit page: apage record not found"); error("Edit page: apage record not found");
} }
/// CDC-FLAG /// 6/15/04 removed != LESSON_ENDOFBRANCH... /// CDC-FLAG /// 6/15/04 removed != LESSON_ENDOFBRANCH...
if (trim($page->title)) { // ...nor nuffin pages if (trim($page->title)) { // ...nor nuffin pages
$jump[$apageid] = strip_tags(format_string($apage->title,true)); $jump[$apageid] = strip_tags(format_string($apage->title,true));
} }
$apageid = $apage->nextpageid; $apageid = $apage->nextpageid;
} else { } else {
// last page reached // last page reached
break; break;
} }
} }
// give teacher a proforma // give teacher a proforma
?> ?>
<form name="editpage" method="post" action="lesson.php"> <form name="editpage" method="post" action="lesson.php">
<input type="hidden" name="id" value="<?PHP echo $cm->id ?>"> <input type="hidden" name="id" value="<?PHP echo $cm->id ?>">
<input type="hidden" name="action" value="updatepage"> <input type="hidden" name="action" value="updatepage">
<input type="hidden" name="pageid" value="<?PHP echo $pageid ?>"> <input type="hidden" name="pageid" value="<?PHP echo $pageid ?>">
<input type="hidden" name="sesskey" value="<?PHP echo $USER->sesskey ?>"> <input type="hidden" name="sesskey" value="<?PHP echo $USER->sesskey ?>">
<input type="hidden" name="redisplay" value="0"> <input type="hidden" name="redisplay" value="0">
<center> <center>
<?php <?php
switch ($page->qtype) { switch ($page->qtype) {
case LESSON_MULTICHOICE : case LESSON_MULTICHOICE :
echo '<b>'.get_string("questiontype", "lesson").":</b> \n"; echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."<br>"; echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."<br>";
lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype,
"lesson.php?id=$cm->id&action=editpage&pageid=$page->id", "lesson.php?id=$cm->id&action=editpage&pageid=$page->id",
"document.editpage.redisplay.value=1;document.editpage.submit();"); "document.editpage.redisplay.value=1;document.editpage.submit();");
echo "<p><b>".get_string("multianswer", "lesson").":</b> \n"; echo "<p><b>".get_string("multianswer", "lesson").":</b> \n";
if ($page->qoption) { if ($page->qoption) {
echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\" checked=\"checked\"/>"; //CDC hidden label added. echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\" checked=\"checked\"/>"; //CDC hidden label added.
} else { } else {
echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added. echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added.
} }
helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson");
echo "</p>\n"; echo "</p>\n";
break; break;
case LESSON_SHORTANSWER : case LESSON_SHORTANSWER :
echo '<b>'.get_string("questiontype", "lesson").":</b> \n"; echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
echo helpbutton("questiontype", get_string("questiontype", "lesson"), "lesson")."<br>"; echo helpbutton("questiontype", get_string("questiontype", "lesson"), "lesson")."<br>";
lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype,
"lesson.php?id=$cm->id&action=editpage&pageid=$page->id", "lesson.php?id=$cm->id&action=editpage&pageid=$page->id",
"document.editpage.redisplay.value=1;document.editpage.submit();"); "document.editpage.redisplay.value=1;document.editpage.submit();");
echo "<p><b>".get_string("casesensitive", "lesson").":</b> \n"; echo "<p><b>".get_string("casesensitive", "lesson").":</b> \n";
if ($page->qoption) { if ($page->qoption) {
echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\" checked=\"checked\"/>"; //CDC hidden label added. echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\" checked=\"checked\"/>"; //CDC hidden label added.
} else { } else {
echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added. echo "<label for=\"qoption\" class=\"hidden-label\">Question Option</label><input type=\"checkbox\" id=\"qoption\" name=\"qoption\" value=\"1\"/>"; //CDC hidden label added.
} }
helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson");
echo "</p>\n"; echo "</p>\n";
break; break;
case LESSON_TRUEFALSE : case LESSON_TRUEFALSE :
case LESSON_ESSAY : case LESSON_ESSAY :
case LESSON_MATCHING : case LESSON_MATCHING :
case LESSON_NUMERICAL : case LESSON_NUMERICAL :
echo '<b>'.get_string("questiontype", "lesson").":</b> \n"; echo '<b>'.get_string("questiontype", "lesson").":</b> \n";
echo helpbutton("questiontype", get_string("questiontype", "lesson"), "lesson")."<br>"; echo helpbutton("questiontype", get_string("questiontype", "lesson"), "lesson")."<br>";
lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype,
"lesson.php?id=$cm->id&action=editpage&pageid=$page->id", "lesson.php?id=$cm->id&action=editpage&pageid=$page->id",
"document.editpage.redisplay.value=1;document.editpage.submit();"); "document.editpage.redisplay.value=1;document.editpage.submit();");
break; break;
} }
?> ?>
<table cellpadding="5" class="generalbox" border="1"> <table cellpadding="5" class="generalbox" border="1">
<tr valign="top"> <tr valign="top">
<td><b><?php print_string("pagetitle", "lesson"); ?>:</b><br /> <td><b><?php print_string("pagetitle", "lesson"); ?>:</b><br />
<!-- //CDC hidden-label added.--><label for="title" class="hidden-label">Title</label><input type="text" id="title" name="title" size="80" maxsize="255" value="<?php p($page->title) ?>"></td> <!-- //CDC hidden-label added.--><label for="title" class="hidden-label">Title</label><input type="text" id="title" name="title" size="80" maxsize="255" value="<?php p($page->title) ?>"></td>
</tr> </tr>
<?PHP <?PHP
echo "<tr><td><b>"; echo "<tr><td><b>";
echo get_string("pagecontents", "lesson").":</b><br />\n"; echo get_string("pagecontents", "lesson").":</b><br />\n";
print_textarea($usehtmleditor, 25, 70, 630, 400, "contents", $page->contents); print_textarea($usehtmleditor, 25, 70, 630, 400, "contents", $page->contents);
use_html_editor("contents"); // always the editor use_html_editor("contents"); // always the editor
echo "</td></tr>\n"; echo "</td></tr>\n";
$n = 0; $n = 0;
switch ($page->qtype) { switch ($page->qtype) {
case LESSON_BRANCHTABLE : case LESSON_BRANCHTABLE :
echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n"; echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n";
/// CDC-FLAG /// 6/16/04 /// CDC-FLAG /// 6/16/04
echo "<tr><td>\n"; echo "<tr><td>\n";
echo "<center>"; echo "<center>";
if ($page->layout) { if ($page->layout) {
echo "<input checked=\"checked\" name=\"layout\" type=\"checkbox\" value=\"1\">"; echo "<input checked=\"checked\" name=\"layout\" type=\"checkbox\" value=\"1\">";
} else { } else {
echo "<input name=\"layout\" type=\"checkbox\" value=\"1\">"; echo "<input name=\"layout\" type=\"checkbox\" value=\"1\">";
} }
echo get_string("arrangebuttonshorizontally", "lesson")."<center>\n"; echo get_string("arrangebuttonshorizontally", "lesson")."<center>\n";
echo "<br>"; echo "<br>";
if ($page->display) { if ($page->display) {
echo "<center><input name=\"display\" type=\"checkbox\" value=\"1\" checked=\"checked\">"; echo "<center><input name=\"display\" type=\"checkbox\" value=\"1\" checked=\"checked\">";
} else { } else {
echo "<center><input name=\"display\" type=\"checkbox\" value=\"1\">"; echo "<center><input name=\"display\" type=\"checkbox\" value=\"1\">";
} }
echo get_string("displayinleftmenu", "lesson")."<center>\n"; echo get_string("displayinleftmenu", "lesson")."<center>\n";
echo "</td></tr>\n"; echo "</td></tr>\n";
/// CDC-FLAG /// /// CDC-FLAG ///
echo "<tr><td><b>".get_string("branchtable", "lesson")."</b> \n"; echo "<tr><td><b>".get_string("branchtable", "lesson")."</b> \n";
break; break;
case LESSON_CLUSTER : case LESSON_CLUSTER :
echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n"; echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n";
echo "<tr><td><b>".get_string("clustertitle", "lesson")."</b> \n"; echo "<tr><td><b>".get_string("clustertitle", "lesson")."</b> \n";
break; break;
case LESSON_ENDOFCLUSTER : case LESSON_ENDOFCLUSTER :
echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n"; echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n";
echo "<tr><td><b>".get_string("endofclustertitle", "lesson")."</b> \n"; echo "<tr><td><b>".get_string("endofclustertitle", "lesson")."</b> \n";
break; break;
case LESSON_ENDOFBRANCH : case LESSON_ENDOFBRANCH :
echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n"; echo "<input type=\"hidden\" name=\"qtype\" value=\"$page->qtype\">\n";
echo "<tr><td><b>".get_string("endofbranch", "lesson")."</b> \n"; echo "<tr><td><b>".get_string("endofbranch", "lesson")."</b> \n";
break; break;
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
// get the answers in a set order, the id order // get the answers in a set order, the id order
if ($answers = get_records("lesson_answers", "pageid", $page->id, "id")) { if ($answers = get_records("lesson_answers", "pageid", $page->id, "id")) {
foreach ($answers as $answer) { foreach ($answers as $answer) {
$flags = intval($answer->flags); // force into an integer $flags = intval($answer->flags); // force into an integer
$nplus1 = $n + 1; $nplus1 = $n + 1;
echo "<input type=\"hidden\" name=\"answerid[$n]\" value=\"$answer->id\">\n"; echo "<input type=\"hidden\" name=\"answerid[$n]\" value=\"$answer->id\">\n";
switch ($page->qtype) { switch ($page->qtype) {
case LESSON_MATCHING: case LESSON_MATCHING:
if ($n == 0) { if ($n == 0) {
echo "<tr><td><b>".get_string("correctresponse", "lesson").":</b>\n"; echo "<tr><td><b>".get_string("correctresponse", "lesson").":</b>\n";
if ($flags & LESSON_ANSWER_EDITOR) { if ($flags & LESSON_ANSWER_EDITOR) {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\"
checked=\"checked\">"; //CDC hidden label added. checked=\"checked\">"; //CDC hidden label added.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
use_html_editor("answer[$n]"); // switch on the editor use_html_editor("answer[$n]"); // switch on the editor
} else { } else {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">"; //CDC hidden label. "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">"; //CDC hidden label.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
} }
} elseif ($n == 1) { } elseif ($n == 1) {
echo "<tr><td><b>".get_string("wrongresponse", "lesson").":</b>\n"; echo "<tr><td><b>".get_string("wrongresponse", "lesson").":</b>\n";
if ($flags & LESSON_ANSWER_EDITOR) { if ($flags & LESSON_ANSWER_EDITOR) {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\"
checked=\"checked\">"; //CDC hidden label added. checked=\"checked\">"; //CDC hidden label added.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
use_html_editor("answer[$n]"); // switch on the editor use_html_editor("answer[$n]"); // switch on the editor
} else { } else {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">"; //CDC hidden label. "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">"; //CDC hidden label.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
} }
} else { } else {
$ncorrected = $n - 1; $ncorrected = $n - 1;
echo "<tr><td><b>".get_string("answer", "lesson")." $ncorrected:</b>\n"; echo "<tr><td><b>".get_string("answer", "lesson")." $ncorrected:</b>\n";
if ($flags & LESSON_ANSWER_EDITOR) { if ($flags & LESSON_ANSWER_EDITOR) {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\"
checked=\"checked\">"; //CDC hidden label added. checked=\"checked\">"; //CDC hidden label added.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
use_html_editor("answer[$n]"); // switch on the editor use_html_editor("answer[$n]"); // switch on the editor
} else { } else {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">"; //CDC hidden label. "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">"; //CDC hidden label.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $ncorrected:</b>\n"; echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $ncorrected:</b>\n";
if ($flags & LESSON_RESPONSE_EDITOR) { if ($flags & LESSON_RESPONSE_EDITOR) {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\" "<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\"
checked=\"checked\">"; //CDC hidden label added. checked=\"checked\">"; //CDC hidden label added.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response); print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response);
use_html_editor("response[$n]"); // switch on the editor use_html_editor("response[$n]"); // switch on the editor
} else { } else {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\">"; //CDC hidden label added. "<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\">"; //CDC hidden label added.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 6, 70, 630, 300, "response[$n]", $answer->response); print_textarea(false, 6, 70, 630, 300, "response[$n]", $answer->response);
} }
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
case LESSON_TRUEFALSE: case LESSON_TRUEFALSE:
case LESSON_MULTICHOICE: case LESSON_MULTICHOICE:
case LESSON_SHORTANSWER: case LESSON_SHORTANSWER:
case LESSON_NUMERICAL: case LESSON_NUMERICAL:
echo "<tr><td><b>".get_string("answer", "lesson")." $nplus1:</b>\n"; echo "<tr><td><b>".get_string("answer", "lesson")." $nplus1:</b>\n";
if ($flags & LESSON_ANSWER_EDITOR) { if ($flags & LESSON_ANSWER_EDITOR) {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\" "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\"answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\"
checked=\"checked\">"; //CDC hidden label added. checked=\"checked\">"; //CDC hidden label added.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
use_html_editor("answer[$n]"); // switch on the editor use_html_editor("answer[$n]"); // switch on the editor
} else { } else {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">"; //CDC hidden label. "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" id=\answereditor[$n]\" name=\"answereditor[$n]\" value=\"1\">"; //CDC hidden label.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer);
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><b>".get_string("response", "lesson")." $nplus1:</b>\n"; echo "<tr><td><b>".get_string("response", "lesson")." $nplus1:</b>\n";
if ($flags & LESSON_RESPONSE_EDITOR) { if ($flags & LESSON_RESPONSE_EDITOR) {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\" "<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\"
checked=\"checked\">"; //CDC hidden label added. checked=\"checked\">"; //CDC hidden label added.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response); print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response);
use_html_editor("response[$n]"); // switch on the editor use_html_editor("response[$n]"); // switch on the editor
} else { } else {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\">"; //CDC hidden label added. "<label for=\"responseeditor[$n]\" class=\"hidden-label\">responseeditor[$n]</label><input type=\"checkbox\" id=\"responseeditor[$n]\" name=\"responseeditor[$n]\" value=\"1\">"; //CDC hidden label added.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 6, 70, 630, 300, "response[$n]", $answer->response); print_textarea(false, 6, 70, 630, 300, "response[$n]", $answer->response);
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
case LESSON_BRANCHTABLE: case LESSON_BRANCHTABLE:
echo "<tr><td><b>".get_string("description", "lesson")." $nplus1:</b>\n"; echo "<tr><td><b>".get_string("description", "lesson")." $nplus1:</b>\n";
if ($flags & LESSON_ANSWER_EDITOR) { if ($flags & LESSON_ANSWER_EDITOR) {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" name=\"answereditor[$n]\" value=\"1\" "<label for=\"answereditor[$n]\" class=\"hidden-label\">answereditor[$n]</label><input type=\"checkbox\" name=\"answereditor[$n]\" value=\"1\"
checked=\"checked\">"; //CDC hidden label added. checked=\"checked\">"; //CDC hidden label added.
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer);
use_html_editor("answer[$n]"); // switch on the editor CDC-FLAG added in this line... editor would not turn on w/o it use_html_editor("answer[$n]"); // switch on the editor CDC-FLAG added in this line... editor would not turn on w/o it
} else { } else {
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<input type=\"checkbox\" name=\"answereditor[$n]\" value=\"1\">"; "<input type=\"checkbox\" name=\"answereditor[$n]\" value=\"1\">";
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 10, 70, 630, 300, "answer[$n]", $answer->answer); print_textarea(false, 10, 70, 630, 300, "answer[$n]", $answer->answer);
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
} }
switch ($page->qtype) { switch ($page->qtype) {
case LESSON_MATCHING : case LESSON_MATCHING :
if ($n == 2) { if ($n == 2) {
echo "<tr><td><b>".get_string("correctanswerjump", "lesson").":</b> \n"; echo "<tr><td><b>".get_string("correctanswerjump", "lesson").":</b> \n";
lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) if($lesson->custom)
echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">"; echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">";
} }
if ($n == 3) { if ($n == 3) {
echo "<tr><td><b>".get_string("wronganswerjump", "lesson").":</b> \n"; echo "<tr><td><b>".get_string("wronganswerjump", "lesson").":</b> \n";
lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) if($lesson->custom)
echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">"; echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">";
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
case LESSON_ESSAY : case LESSON_ESSAY :
echo "<tr><td><b>".get_string("jump", "lesson").":</b> \n"; echo "<tr><td><b>".get_string("jump", "lesson").":</b> \n";
lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) { if($lesson->custom) {
echo get_string("score", "lesson").": <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">"; echo get_string("score", "lesson").": <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">";
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
case LESSON_TRUEFALSE: case LESSON_TRUEFALSE:
case LESSON_MULTICHOICE: case LESSON_MULTICHOICE:
case LESSON_SHORTANSWER: case LESSON_SHORTANSWER:
case LESSON_NUMERICAL: case LESSON_NUMERICAL:
echo "<tr><td><b>".get_string("jump", "lesson")." $nplus1:</b> \n"; echo "<tr><td><b>".get_string("jump", "lesson")." $nplus1:</b> \n";
lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) { if($lesson->custom) {
echo get_string("score", "lesson")." $nplus1: <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">"; echo get_string("score", "lesson")." $nplus1: <input type=\"text\" name=\"score[$n]\" value=\"$answer->score\" size=\"5\">";
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
case LESSON_BRANCHTABLE: case LESSON_BRANCHTABLE:
case LESSON_CLUSTER: case LESSON_CLUSTER:
case LESSON_ENDOFCLUSTER: case LESSON_ENDOFCLUSTER:
case LESSON_ENDOFBRANCH: case LESSON_ENDOFBRANCH:
echo "<tr><td><b>".get_string("jump", "lesson")." $nplus1:</b> \n"; echo "<tr><td><b>".get_string("jump", "lesson")." $nplus1:</b> \n";
lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
} }
$n++; $n++;
if ($page->qtype == LESSON_ESSAY) { if ($page->qtype == LESSON_ESSAY) {
break; // only one answer for essays break; // only one answer for essays
} }
} }
} }
if ($page->qtype != LESSON_ENDOFBRANCH && $page->qtype != LESSON_CLUSTER && $page->qtype != LESSON_ENDOFCLUSTER) { /// CDC-FLAG 6/17/04 added to the condition /// if ($page->qtype != LESSON_ENDOFBRANCH && $page->qtype != LESSON_CLUSTER && $page->qtype != LESSON_ENDOFCLUSTER) { /// CDC-FLAG 6/17/04 added to the condition ///
if ($page->qtype == LESSON_MATCHING) { if ($page->qtype == LESSON_MATCHING) {
$maxanswers = $lesson->maxanswers + 2; $maxanswers = $lesson->maxanswers + 2;
} else { } else {
$maxanswers = $lesson->maxanswers; $maxanswers = $lesson->maxanswers;
} }
for ($i = $n; $i < $maxanswers; $i++) { for ($i = $n; $i < $maxanswers; $i++) {
if ($page->qtype == LESSON_TRUEFALSE && $i > 1) { if ($page->qtype == LESSON_TRUEFALSE && $i > 1) {
break; // stop printing answers... only need two for true/false break; // stop printing answers... only need two for true/false
} }
$iplus1 = $i + 1; $iplus1 = $i + 1;
echo "<input type=\"hidden\" name=\"answerid[$i]\" value=\"0\">\n"; echo "<input type=\"hidden\" name=\"answerid[$i]\" value=\"0\">\n";
switch ($page->qtype) { switch ($page->qtype) {
case LESSON_MATCHING: case LESSON_MATCHING:
$icorrected = $i - 1; $icorrected = $i - 1;
echo "<tr><td><b>".get_string("answer", "lesson")." $icorrected:</b>\n"; echo "<tr><td><b>".get_string("answer", "lesson")." $icorrected:</b>\n";
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">"; "<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">";
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 10, 70, 630, 300, "answer[$i]"); print_textarea(false, 10, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $icorrected:</b>\n"; echo "<tr><td><b>".get_string("matchesanswer", "lesson")." $icorrected:</b>\n";
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<input type=\"checkbox\" name=\"responseeditor[$i]\" value=\"1\">"; "<input type=\"checkbox\" name=\"responseeditor[$i]\" value=\"1\">";
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 10, 70, 630, 300, "response[$i]"); print_textarea(false, 10, 70, 630, 300, "response[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
case LESSON_TRUEFALSE: case LESSON_TRUEFALSE:
case LESSON_MULTICHOICE: case LESSON_MULTICHOICE:
case LESSON_SHORTANSWER: case LESSON_SHORTANSWER:
case LESSON_NUMERICAL: case LESSON_NUMERICAL:
echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b>\n"; echo "<tr><td><b>".get_string("answer", "lesson")." $iplus1:</b>\n";
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">"; "<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">";
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 10, 70, 630, 300, "answer[$i]"); print_textarea(false, 10, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b>\n"; echo "<tr><td><b>".get_string("response", "lesson")." $iplus1:</b>\n";
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<input type=\"checkbox\" name=\"responseeditor[$i]\" value=\"1\">"; "<input type=\"checkbox\" name=\"responseeditor[$i]\" value=\"1\">";
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 10, 70, 630, 300, "response[$i]"); print_textarea(false, 10, 70, 630, 300, "response[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
case LESSON_BRANCHTABLE: case LESSON_BRANCHTABLE:
echo "<tr><td><b>".get_string("description", "lesson")." $iplus1:</b>\n"; echo "<tr><td><b>".get_string("description", "lesson")." $iplus1:</b>\n";
echo " [".get_string("useeditor", "lesson").": ". echo " [".get_string("useeditor", "lesson").": ".
"<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">"; "<input type=\"checkbox\" name=\"answereditor[$i]\" value=\"1\">";
helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson");
echo "]<br />\n"; echo "]<br />\n";
print_textarea(false, 10, 70, 630, 300, "answer[$i]"); print_textarea(false, 10, 70, 630, 300, "answer[$i]");
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
} }
switch ($page->qtype) { switch ($page->qtype) {
case LESSON_ESSAY : case LESSON_ESSAY :
if ($i < 1) { if ($i < 1) {
echo "<tr><td><B>".get_string("jump", "lesson").":</b> \n"; echo "<tr><td><B>".get_string("jump", "lesson").":</b> \n";
lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) { if($lesson->custom) {
echo get_string("score", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">"; echo get_string("score", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"1\" size=\"5\">";
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
} }
break; break;
case LESSON_MATCHING : case LESSON_MATCHING :
if ($i == 2) { if ($i == 2) {
echo "<tr><td><b>".get_string("correctanswerjump", "lesson").":</b> \n"; echo "<tr><td><b>".get_string("correctanswerjump", "lesson").":</b> \n";
lesson_choose_from_menu($jump, "jumpto[$i]", $answer->jumpto, ""); lesson_choose_from_menu($jump, "jumpto[$i]", $answer->jumpto, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) if($lesson->custom)
echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"$answer->score\" size=\"5\">"; echo get_string("correctanswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"$answer->score\" size=\"5\">";
} }
if ($i == 3) { if ($i == 3) {
echo "<tr><td><b>".get_string("wronganswerjump", "lesson").":</b> \n"; echo "<tr><td><b>".get_string("wronganswerjump", "lesson").":</b> \n";
lesson_choose_from_menu($jump, "jumpto[$i]", $answer->jumpto, ""); lesson_choose_from_menu($jump, "jumpto[$i]", $answer->jumpto, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) if($lesson->custom)
echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"$answer->score\" size=\"5\">"; echo get_string("wronganswerscore", "lesson").": <input type=\"text\" name=\"score[$i]\" value=\"$answer->score\" size=\"5\">";
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
case LESSON_TRUEFALSE: case LESSON_TRUEFALSE:
case LESSON_MULTICHOICE: case LESSON_MULTICHOICE:
case LESSON_SHORTANSWER: case LESSON_SHORTANSWER:
case LESSON_NUMERICAL: case LESSON_NUMERICAL:
echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n"; echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
if($lesson->custom) { if($lesson->custom) {
echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">"; echo get_string("score", "lesson")." $iplus1: <input type=\"text\" name=\"score[$i]\" value=\"0\" size=\"5\">";
} }
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
case LESSON_BRANCHTABLE : case LESSON_BRANCHTABLE :
echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n"; echo "<tr><td><B>".get_string("jump", "lesson")." $iplus1:</b> \n";
lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); lesson_choose_from_menu($jump, "jumpto[$i]", 0, "");
helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); helpbutton("jumpto", get_string("jump", "lesson"), "lesson");
echo "</td></tr>\n"; echo "</td></tr>\n";
break; break;
} }
} }
} }
// close table and form // close table and form
?> ?>
</table><br /> </table><br />
<input type="button" value="<?php print_string("redisplaypage", "lesson") ?>" <input type="button" value="<?php print_string("redisplaypage", "lesson") ?>"
onClick="document.editpage.redisplay.value=1;document.editpage.submit();" /> onClick="document.editpage.redisplay.value=1;document.editpage.submit();" />
<input type="submit" value="<?php print_string("savepage", "lesson") ?>" /> <input type="submit" value="<?php print_string("savepage", "lesson") ?>" />
<input type="submit" name="cancel" value="<?php print_string("cancel") ?>" /> <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
</center> </center>
</form> </form>

View file

@ -42,8 +42,8 @@
/// CDC-FLAG /// /// CDC-FLAG ///
$newpage->title = clean_param($form->title, PARAM_CLEANHTML); $newpage->title = clean_param($form->title, PARAM_CLEANHTML);
$newpage->contents = clean_param(trim($form->contents), PARAM_CLEANHTML); $newpage->contents = clean_param(trim($form->contents), PARAM_CLEANHTML);
$newpage->title = addslashes($newpage->title); $newpage->title = addslashes($newpage->title);
$newpage->contents = addslashes($newpage->contents); $newpage->contents = addslashes($newpage->contents);
$newpageid = insert_record("lesson_pages", $newpage); $newpageid = insert_record("lesson_pages", $newpage);
if (!$newpageid) { if (!$newpageid) {
error("Insert page: new page not inserted"); error("Insert page: new page not inserted");
@ -88,7 +88,7 @@
$newpage->title = clean_param($form->title, PARAM_CLEANHTML); $newpage->title = clean_param($form->title, PARAM_CLEANHTML);
$newpage->contents = clean_param(trim($form->contents), PARAM_CLEANHTML); $newpage->contents = clean_param(trim($form->contents), PARAM_CLEANHTML);
$newpage->title = addslashes($newpage->title); $newpage->title = addslashes($newpage->title);
$newpage->contents = addslashes($newpage->contents); $newpage->contents = addslashes($newpage->contents);
$newpageid = insert_record("lesson_pages", $newpage); $newpageid = insert_record("lesson_pages", $newpage);
if (!$newpageid) { if (!$newpageid) {
error("Insert page: new first page not inserted"); error("Insert page: new first page not inserted");
@ -120,7 +120,7 @@
$newpage->title = clean_param($form->title, PARAM_CLEANHTML); $newpage->title = clean_param($form->title, PARAM_CLEANHTML);
$newpage->contents = clean_param(trim($form->contents), PARAM_CLEANHTML); $newpage->contents = clean_param(trim($form->contents), PARAM_CLEANHTML);
$newpage->title = addslashes($newpage->title); $newpage->title = addslashes($newpage->title);
$newpage->contents = addslashes($newpage->contents); $newpage->contents = addslashes($newpage->contents);
$newpageid = insert_record("lesson_pages", $newpage); $newpageid = insert_record("lesson_pages", $newpage);
if (!$newpageid) { if (!$newpageid) {
error("Insert page: first page not inserted"); error("Insert page: first page not inserted");
@ -158,10 +158,10 @@
$newanswer->pageid = $newpageid; $newanswer->pageid = $newpageid;
$newanswer->timecreated = $timenow; $newanswer->timecreated = $timenow;
$newanswer->answer = clean_param(trim($form->answer[$i]), PARAM_CLEANHTML); $newanswer->answer = clean_param(trim($form->answer[$i]), PARAM_CLEANHTML);
$newanswer->answer = addslashes($newanswer->answer); $newanswer->answer = addslashes($newanswer->answer);
if (isset($form->response[$i])) { if (isset($form->response[$i])) {
$newanswer->response = clean_param(trim($form->response[$i]), PARAM_CLEANHTML); $newanswer->response = clean_param(trim($form->response[$i]), PARAM_CLEANHTML);
$newanswer->response = addslashes($newanswer->response); $newanswer->response = addslashes($newanswer->response);
} }
if (isset($form->jumpto[$i])) { if (isset($form->jumpto[$i])) {
$newanswer->jumpto = clean_param($form->jumpto[$i], PARAM_INT); $newanswer->jumpto = clean_param($form->jumpto[$i], PARAM_INT);

View file

@ -34,8 +34,8 @@
/// CDC-FLAG /// /// CDC-FLAG ///
$page->title = clean_param($form->title, PARAM_CLEANHTML); $page->title = clean_param($form->title, PARAM_CLEANHTML);
$page->contents = clean_param(trim($form->contents), PARAM_CLEANHTML); $page->contents = clean_param(trim($form->contents), PARAM_CLEANHTML);
$page->title = addslashes($page->title); $page->title = addslashes($page->title);
$page->contents = addslashes($page->contents); $page->contents = addslashes($page->contents);
if (!update_record("lesson_pages", $page)) { if (!update_record("lesson_pages", $page)) {
error("Update page: page not updated"); error("Update page: page not updated");
} }
@ -80,10 +80,10 @@
clean_param($form->responseeditor[$i], PARAM_INT) * LESSON_RESPONSE_EDITOR; clean_param($form->responseeditor[$i], PARAM_INT) * LESSON_RESPONSE_EDITOR;
$oldanswer->timemodified = $timenow; $oldanswer->timemodified = $timenow;
$oldanswer->answer = clean_param(trim($form->answer[$i]), PARAM_CLEANHTML); $oldanswer->answer = clean_param(trim($form->answer[$i]), PARAM_CLEANHTML);
$oldanswer->answer = addslashes($oldanswer->answer); $oldanswer->answer = addslashes($oldanswer->answer);
if (isset($form->response[$i])) { if (isset($form->response[$i])) {
$oldanswer->response = clean_param(trim($form->response[$i]), PARAM_CLEANHTML); $oldanswer->response = clean_param(trim($form->response[$i]), PARAM_CLEANHTML);
$oldanswer->response = addslashes($oldanswer->response); $oldanswer->response = addslashes($oldanswer->response);
} }
$oldanswer->jumpto = clean_param($form->jumpto[$i], PARAM_INT); $oldanswer->jumpto = clean_param($form->jumpto[$i], PARAM_INT);
/// CDC-FLAG /// /// CDC-FLAG ///
@ -103,10 +103,10 @@
clean_param($form->responseeditor[$i], PARAM_INT) * LESSON_RESPONSE_EDITOR; clean_param($form->responseeditor[$i], PARAM_INT) * LESSON_RESPONSE_EDITOR;
$newanswer->timecreated = $timenow; $newanswer->timecreated = $timenow;
$newanswer->answer = clean_param(trim($form->answer[$i]), PARAM_CLEANHTML); $newanswer->answer = clean_param(trim($form->answer[$i]), PARAM_CLEANHTML);
$newanswer->answer = addslashes($newanswer->answer); $newanswer->answer = addslashes($newanswer->answer);
if (isset($form->response[$i])) { if (isset($form->response[$i])) {
$newanswer->response = clean_param(trim($form->response[$i]), PARAM_CLEANHTML); $newanswer->response = clean_param(trim($form->response[$i]), PARAM_CLEANHTML);
$newanswer->answer = addslashes($newanswer->answer); $newanswer->answer = addslashes($newanswer->answer);
} }
$newanswer->jumpto = clean_param($form->jumpto[$i], PARAM_INT); $newanswer->jumpto = clean_param($form->jumpto[$i], PARAM_INT);
/// CDC-FLAG /// /// CDC-FLAG ///

View file

@ -57,13 +57,13 @@
"$navigation <a href=index.php?id=$course->id>$strlessons</a> -> "$navigation <a href=index.php?id=$course->id>$strlessons</a> ->
<a href=\"view.php?id=$cm->id\">".format_string($lesson->name,true)."</a>", "", "", true); <a href=\"view.php?id=$cm->id\">".format_string($lesson->name,true)."</a>", "", "", true);
// include the appropriate action (check to make sure the file is there first) // include the appropriate action (check to make sure the file is there first)
if (file_exists($CFG->dirroot.'/mod/lesson/action/'.$action.'.php')) { if (file_exists($CFG->dirroot.'/mod/lesson/action/'.$action.'.php')) {
include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php'); include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php');
} else { } else {
error("Fatal Error: Unknown action\n"); error("Fatal Error: Unknown action\n");
} }
print_footer($course); print_footer($course);
?> ?>

View file

@ -35,10 +35,10 @@ function lesson_add_instance($lesson) {
unset($lesson->password); unset($lesson->password);
} }
/// CDC-FLAG /// /// CDC-FLAG ///
if (!$lesson->id = insert_record("lesson", $lesson)) { if (!$lesson->id = insert_record("lesson", $lesson)) {
return false; // bad return false; // bad
} }
if ($lesson->lessondefault) { if ($lesson->lessondefault) {
$lessondefault = $lesson; $lessondefault = $lesson;
unset($lessondefault->lessondefault); unset($lessondefault->lessondefault);
@ -130,8 +130,8 @@ function lesson_update_instance($lesson) {
unset($lesson->lessondefault); unset($lesson->lessondefault);
} }
// update the calendar events (credit goes to quiz module) // update the calendar events (credit goes to quiz module)
if ($events = get_records_select('event', "modulename = 'lesson' and instance = '$lesson->id'")) { if ($events = get_records_select('event', "modulename = 'lesson' and instance = '$lesson->id'")) {
foreach($events as $event) { foreach($events as $event) {
delete_event($event->id); delete_event($event->id);
} }
@ -249,13 +249,13 @@ function lesson_delete_instance($id) {
if (! delete_records("lesson_high_scores", "lessonid", "$lesson->id")) { if (! delete_records("lesson_high_scores", "lessonid", "$lesson->id")) {
$result = false; $result = false;
} }
if ($events = get_records_select('event', "modulename = 'lesson' and instance = '$lesson->id'")) { if ($events = get_records_select('event', "modulename = 'lesson' and instance = '$lesson->id'")) {
foreach($events as $event) { foreach($events as $event) {
delete_event($event->id); delete_event($event->id);
} }
} }
return $result; return $result;
} }
/*******************************************************************/ /*******************************************************************/

View file

@ -1027,12 +1027,11 @@ function lesson_calculate_ongoing_score($lesson, $userid, $retries, $return=fals
} }
} }
$nviewed = count($temp); // this counts number of Questions the user viewed $nviewed = count($temp); // this counts number of Questions the user viewed
if ($nviewed != 0) { if ($nviewed != 0) {
$thegrade = intval(100 * $ncorrect / $nviewed); $thegrade = intval(100 * $ncorrect / $nviewed);
} else { } else {
$thegrade = 0; $thegrade = 0;
} }
if ($return) { if ($return) {
return $thegrade; return $thegrade;
@ -1113,15 +1112,15 @@ function lesson_calculate_ongoing_score($lesson, $userid, $retries, $return=fals
/*******************************************************************/ /*******************************************************************/
function lesson_qtype_menu($qtypes, $selected="", $link="", $onclick="") { function lesson_qtype_menu($qtypes, $selected="", $link="", $onclick="") {
// prints the question types for when editing and adding a page // prints the question types for when editing and adding a page
$tabs = array(); $tabs = array();
$tabrows = array(); $tabrows = array();
foreach ($qtypes as $qtype => $qtypename) { foreach ($qtypes as $qtype => $qtypename) {
$tabrows[] = new tabobject($qtype, "$link&amp;qtype=$qtype\" onClick=\"$onclick\"", $qtypename); $tabrows[] = new tabobject($qtype, "$link&amp;qtype=$qtype\" onClick=\"$onclick\"", $qtypename);
} }
$tabs[] = $tabrows; $tabs[] = $tabrows;
print_tabs($tabs, $selected); print_tabs($tabs, $selected);
echo "<input type=\"hidden\" name=\"qtype\" value=\"$selected\" /> \n"; echo "<input type=\"hidden\" name=\"qtype\" value=\"$selected\" /> \n";
} }

View file

@ -163,8 +163,8 @@
$tries = $studentdata[$student->id]; $tries = $studentdata[$student->id];
$studentname = "{$student->lastname},&nbsp;$student->firstname"; $studentname = "{$student->lastname},&nbsp;$student->firstname";
foreach ($tries as $try) { foreach ($tries as $try) {
// start to build up the link // start to build up the link
$temp = "<a href=\"report.php?id=$cm->id&amp;action=detail&amp;userid=".$try["userid"]."&amp;try=".$try["try"]."\">"; $temp = "<a href=\"report.php?id=$cm->id&amp;action=detail&amp;userid=".$try["userid"]."&amp;try=".$try["try"]."\">";
if ($try["grade"] != NULL) { // if NULL then not done yet if ($try["grade"] != NULL) { // if NULL then not done yet
// this is what the link does when the user has completed the try // this is what the link does when the user has completed the try
$timetotake = $try["timeend"] - $try["timestart"]; $timetotake = $try["timeend"] - $try["timestart"];
@ -210,7 +210,7 @@
$table->data[] = array($studentname, $attempts, $bestgrade."%"); $table->data[] = array($studentname, $attempts, $bestgrade."%");
} }
} }
// print it all out ! // print it all out !
print_table($table); print_table($table);
// some stat calculations // some stat calculations
@ -783,7 +783,7 @@
} }
$answerpages[] = $answerpage; $answerpages[] = $answerpage;
} }
$pageid = $page->nextpageid; $pageid = $page->nextpageid;
} }
/// actually start printing something /// actually start printing something
@ -798,18 +798,18 @@
$table->align = array("right", "left"); $table->align = array("right", "left");
$table->size = array("*", "*"); $table->size = array("*", "*");
if (!$grades = get_records_select("lesson_grades", "lessonid = $lesson->id and userid = $userid", "completed", "*", $try, 1)) { if (!$grades = get_records_select("lesson_grades", "lessonid = $lesson->id and userid = $userid", "completed", "*", $try, 1)) {
$grade = -1; $grade = -1;
} else { } else {
$grade = current($grades); $grade = current($grades);
$grade = $grade->grade; $grade = $grade->grade;
} }
if (!$times = get_records_select("lesson_timer", "lessonid = $lesson->id and userid = $userid", "starttime", "*", $try, 1)) { if (!$times = get_records_select("lesson_timer", "lessonid = $lesson->id and userid = $userid", "starttime", "*", $try, 1)) {
$timetotake = -1; $timetotake = -1;
} else { } else {
$timetotake = current($times); $timetotake = current($times);
$timetotake = $timetotake->lessontime - $timetotake->starttime; $timetotake = $timetotake->lessontime - $timetotake->starttime;
} }
if ($timetotake == -1 || $completed == -1 || $grade == -1) { if ($timetotake == -1 || $completed == -1 || $grade == -1) {
$table->align = array("center"); $table->align = array("center");

View file

@ -26,7 +26,7 @@
var my12_hour = 1; var my12_hour = 1;
var stopclock = 0; var stopclock = 0;
var myclock = ''; var myclock = '';
var timeleft, hours, minutes, secs; var timeleft, hours, minutes, secs;
var javatimeDate = new Date(); var javatimeDate = new Date();
var javatime = javatimeDate.getTime(); var javatime = javatimeDate.getTime();
javatime = Math.floor(javatime/1000); javatime = Math.floor(javatime/1000);
@ -35,15 +35,15 @@
starttime = starttime + difference; starttime = starttime + difference;
var dn = ""; var dn = "";
var old = ""; var old = "";
if (document.all||document.getElementById) { if (document.all||document.getElementById) {
document.write('<span id="LiveClockIE" style="width:'+mywidth+'px;"></span>'); document.write('<span id="LiveClockIE" style="width:'+mywidth+'px;"></span>');
} else if (document.layers) { } else if (document.layers) {
document.write('<ilayer id="ClockPosNS"><layer width="'+mywidth+'" id="LiveClockNS"></layer></ilayer>'); document.write('<ilayer id="ClockPosNS"><layer width="'+mywidth+'" id="LiveClockNS"></layer></ilayer>');
} else { } else {
old = "true"; show_clock(); old = "true"; show_clock();
} }
/*function leave() { // feable attempt to run a script when someone leaves a timed test early, failed so far /*function leave() { // feable attempt to run a script when someone leaves a timed test early, failed so far
window.onunload = window.open('http://www.google.com','','toolbar=no,menubar=no,location=no,height=500,width=500'); window.onunload = window.open('http://www.google.com','','toolbar=no,menubar=no,location=no,height=500,width=500');
@ -69,10 +69,10 @@
stopclock = 1; stopclock = 1;
} else { } else {
timeleft = starttime + testlength - current; timeleft = starttime + testlength - current;
hours = Math.floor(timeleft/3600); hours = Math.floor(timeleft/3600);
timeleft = timeleft - (hours * 3600); timeleft = timeleft - (hours * 3600);
minutes = Math.floor(timeleft/60); minutes = Math.floor(timeleft/60);
secs = timeleft - (minutes * 60); secs = timeleft - (minutes * 60);
if (secs < 10) { if (secs < 10) {
secs = "0"+secs; secs = "0"+secs;

View file

@ -182,31 +182,30 @@
} }
break; // only look at the latest correct attempt break; // only look at the latest correct attempt
} }
} else { } else {
$attempts = NULL; $attempts = NULL;
} }
if ($branchtables = get_records_select('lesson_branch', if ($branchtables = get_records_select('lesson_branch',
"lessonid = $lesson->id AND userid = $USER->id AND retry = $retries", 'timeseen DESC')) { "lessonid = $lesson->id AND userid = $USER->id AND retry = $retries", 'timeseen DESC')) {
// in here, user has viewed a branch table // in here, user has viewed a branch table
$lastbranchtable = current($branchtables); $lastbranchtable = current($branchtables);
if ($attempts != NULL) { if ($attempts != NULL) {
foreach($attempts as $attempt) { foreach($attempts as $attempt) {
if ($lastbranchtable->timeseen > $attempt->timeseen) { if ($lastbranchtable->timeseen > $attempt->timeseen) {
// branch table was viewed later than the last attempt // branch table was viewed later than the last attempt
$lastpageseen = $lastbranchtable->pageid; $lastpageseen = $lastbranchtable->pageid;
} }
break; break;
} }
} else { } else {
// hasnt answered any questions but has viewed a branch table // hasnt answered any questions but has viewed a branch table
$lastpageseen = $lastbranchtable->pageid; $lastpageseen = $lastbranchtable->pageid;
} }
}
}
//if ($lastpageseen != $firstpageid) { //if ($lastpageseen != $firstpageid) {
if (isset($lastpageseen) and count_records('lesson_attempts', 'lessonid', $lesson->id, 'userid', $USER->id, 'retry', $retries) > 0) { if (isset($lastpageseen) and count_records('lesson_attempts', 'lessonid', $lesson->id, 'userid', $USER->id, 'retry', $retries) > 0) {
// get the first page // get the first page
if (!$firstpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, if (!$firstpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id,
'prevpageid', 0)) { 'prevpageid', 0)) {
error('Navigation: first page not found'); error('Navigation: first page not found');
@ -223,7 +222,7 @@
echo '<p align="center"><input type="button" value="'. get_string('continue', 'lesson'). echo '<p align="center"><input type="button" value="'. get_string('continue', 'lesson').
"\" onclick=\"document.queryform.pageid.value='$firstpageid';document.queryform.startlastseen.value='no';document.queryform.submit();\" /></p>\n"; /// CDC-FLAG added document.queryform.startlastseen.value='yes' "\" onclick=\"document.queryform.pageid.value='$firstpageid';document.queryform.startlastseen.value='no';document.queryform.submit();\" /></p>\n"; /// CDC-FLAG added document.queryform.startlastseen.value='yes'
echo '</form>' . "\n"; echo '</form>' . "\n";
echo '</div></div>';///CDC Chris Berri added close div tag echo '</div></div>';///CDC Chris Berri added close div tag
} else { } else {
print_simple_box_start('center'); print_simple_box_start('center');
echo '<div align="center">'; echo '<div align="center">';
@ -247,7 +246,7 @@
echo "</form>\n"; echo "</div></div>";///CDC Chris Berri added close div tag echo "</form>\n"; echo "</div></div>";///CDC Chris Berri added close div tag
} }
print_footer($course); print_footer($course);
exit(); exit();
} }
if ($grades) { if ($grades) {
@ -1065,7 +1064,7 @@
// after all the grade processing, check to see if "Show Grades" is off for the course // after all the grade processing, check to see if "Show Grades" is off for the course
// if yes, redirect to the course page // if yes, redirect to the course page
if (!$course->showgrades) { if (!$course->showgrades) {
redirect($CFG->wwwroot.'/course/view.php?id='.$course->id); redirect($CFG->wwwroot.'/course/view.php?id='.$course->id);
} }
///CDC-FLAG /// high scores code ///CDC-FLAG /// high scores code
@ -1133,54 +1132,54 @@
elseif ($action == 'teacherview') { elseif ($action == 'teacherview') {
/// CDC-FLAG /// link to grade essay questions and to report /// CDC-FLAG /// link to grade essay questions and to report
if ($userattempts = get_records("lesson_attempts", "lessonid", $lesson->id)) { // just check to see if anyone has answered any questions. if ($userattempts = get_records("lesson_attempts", "lessonid", $lesson->id)) { // just check to see if anyone has answered any questions.
$usercount = array(); $usercount = array();
foreach ($userattempts as $userattempts) { foreach ($userattempts as $userattempts) {
$usercount[$userattempts->userid] = 0; $usercount[$userattempts->userid] = 0;
} }
$a = new stdClass; $a = new stdClass;
$a->users = count($usercount); $a->users = count($usercount);
$a->usersname = $course->students; $a->usersname = $course->students;
echo "<div align=\"right\"><a href=\"report.php?id=$cm->id\">".get_string("viewlessonstats", "lesson", $a)."</a></div>"; echo "<div align=\"right\"><a href=\"report.php?id=$cm->id\">".get_string("viewlessonstats", "lesson", $a)."</a></div>";
} }
if ($essaypages = get_records_select("lesson_pages", "lessonid = $lesson->id AND qtype = ".LESSON_ESSAY)) { // get pages that are essay if ($essaypages = get_records_select("lesson_pages", "lessonid = $lesson->id AND qtype = ".LESSON_ESSAY)) { // get pages that are essay
// get only the attempts that are in response to essay questions // get only the attempts that are in response to essay questions
$essaypageids = implode(",", array_keys($essaypages)); // all the pageids in comma seperated list $essaypageids = implode(",", array_keys($essaypages)); // all the pageids in comma seperated list
if ($essayattempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND pageid IN($essaypageids)")) { if ($essayattempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND pageid IN($essaypageids)")) {
$studentessays = array(); $studentessays = array();
// makes an array that organizes essayattempts by grouping userid, then pageid, then try count // makes an array that organizes essayattempts by grouping userid, then pageid, then try count
foreach ($essayattempts as $essayattempt) { foreach ($essayattempts as $essayattempt) {
$studentessays[$essayattempt->userid][$essayattempt->pageid][$essayattempt->retry][] = $essayattempt; $studentessays[$essayattempt->userid][$essayattempt->pageid][$essayattempt->retry][] = $essayattempt;
} }
$a = new stdClass; $a = new stdClass;
$a->notgradedcount = 0; $a->notgradedcount = 0;
$a->notsentcount = 0; $a->notsentcount = 0;
foreach ($studentessays as $pages) { // students foreach ($studentessays as $pages) { // students
foreach ($pages as $tries) { // pages foreach ($pages as $tries) { // pages
// go through each essay per page // go through each essay per page
foreach($tries as $try) { // actual attempts foreach($tries as $try) { // actual attempts
// make sure they didn't answer it more than the max number of attmepts // make sure they didn't answer it more than the max number of attmepts
if (count($try) > $lesson->maxattempts) { if (count($try) > $lesson->maxattempts) {
$essay = $try[$lesson->maxattempts-1]; $essay = $try[$lesson->maxattempts-1];
} else { } else {
$essay = end($try); $essay = end($try);
} }
$essayinfo = unserialize($essay->useranswer); $essayinfo = unserialize($essay->useranswer);
if ($essayinfo->graded == 0) { if ($essayinfo->graded == 0) {
$a->notgradedcount++; $a->notgradedcount++;
} }
if ($essayinfo->sent == 0) { if ($essayinfo->sent == 0) {
$a->notsentcount++; $a->notsentcount++;
} }
} }
} }
} }
echo "<div align=\"right\"><a href=\"view.php?id=$cm->id&amp;action=essayview\">".get_string("gradeessay", "lesson", $a)."</a></div><br />"; echo "<div align=\"right\"><a href=\"view.php?id=$cm->id&amp;action=essayview\">".get_string("gradeessay", "lesson", $a)."</a></div><br />";
} }
} }
print_heading_with_help(format_string($lesson->name,true), "overview", "lesson"); print_heading_with_help(format_string($lesson->name,true), "overview", "lesson");
// get number of pages // get number of pages
if ($page = get_record_select("lesson_pages", "lessonid = $lesson->id AND prevpageid = 0")) { if ($page = get_record_select("lesson_pages", "lessonid = $lesson->id AND prevpageid = 0")) {
$npages = 1; $npages = 1;
while (true) { while (true) {