From 271fea974fb5ea227be74b7860ad24afa6e3abfd Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 16 May 2005 22:41:19 +0000 Subject: [PATCH] Tabs are out. (all the module was using them, please change your editor settings to 4 spaces) --- mod/lesson/action/addbranchtable.php | 158 +-- mod/lesson/action/addendofbranch.php | 116 +- mod/lesson/action/addpage.php | 468 ++++---- mod/lesson/action/confirmdelete.php | 46 +- mod/lesson/action/continue.php | 1530 +++++++++++++------------- mod/lesson/action/delete.php | 104 +- mod/lesson/action/editpage.php | 922 ++++++++-------- mod/lesson/action/insertpage.php | 12 +- mod/lesson/action/updatepage.php | 12 +- mod/lesson/lesson.php | 14 +- mod/lesson/lib.php | 18 +- mod/lesson/locallib.php | 25 +- mod/lesson/report.php | 32 +- mod/lesson/timer.js | 24 +- mod/lesson/view.php | 137 ++- 15 files changed, 1808 insertions(+), 1810 deletions(-) diff --git a/mod/lesson/action/addbranchtable.php b/mod/lesson/action/addbranchtable.php index 5218edf90cf..b1769260e6a 100644 --- a/mod/lesson/action/addbranchtable.php +++ b/mod/lesson/action/addbranchtable.php @@ -1,83 +1,83 @@ id)) { - error("Only teachers can look at this page"); - } + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } - // first get the preceeding page - $pageid = required_param('pageid', PARAM_INT); + // first get the preceeding page + $pageid = required_param('pageid', PARAM_INT); - // set of jump array - $jump = array(); - $jump[0] = get_string("thispage", "lesson"); - $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); - //// CDC-FLAG ///// - $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson"); - if (!isset($_GET['firstpage'])) { - $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); - if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { - error("Add page: first page not found"); - } - while (true) { - if ($apageid) { - $title = get_field("lesson_pages", "title", "id", $apageid); - $jump[$apageid] = $title; - $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid); - } else { - // last page reached - break; - } - } - } - //// CDC-FLAG ///// - // give teacher a blank proforma - print_heading_with_help(get_string("addabranchtable", "lesson"), "overview", "lesson"); - ?> -
- - - - - -
- - - \n"; - /// CDC-FLAG /// 6/16/04 - echo "\n"; - /// CDC-FLAG /// - for ($i = 0; $i < $lesson->maxanswers; $i++) { - $iplus1 = $i + 1; - echo "\n"; - echo "\n"; - } - // close table and form - ?> -
:
-
"; - echo get_string("pagecontents", "lesson").":
\n"; - print_textarea($usehtmleditor, 25,70, 630, 400, "contents"); - use_html_editor("contents"); - echo "
\n"; - echo "
"; - echo get_string("arrangebuttonshorizontally", "lesson")."\n"; - echo "
"; - echo get_string("displayinleftmenu", "lesson"); - echo "
\n"; - echo "
".get_string("description", "lesson")." $iplus1:
\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 - echo "
".get_string("jump", "lesson")." $iplus1: \n"; - if ($i) { - // answers 2, 3, 4... jumpto this page - lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); - } else { - // answer 1 jumpto next page - lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); - } - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - echo "

- " /> - " /> -
-
\ No newline at end of file + // set of jump array + $jump = array(); + $jump[0] = get_string("thispage", "lesson"); + $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); + //// CDC-FLAG ///// + $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson"); + if (!isset($_GET['firstpage'])) { + $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); + if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { + error("Add page: first page not found"); + } + while (true) { + if ($apageid) { + $title = get_field("lesson_pages", "title", "id", $apageid); + $jump[$apageid] = $title; + $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid); + } else { + // last page reached + break; + } + } + } + //// CDC-FLAG ///// + // give teacher a blank proforma + print_heading_with_help(get_string("addabranchtable", "lesson"), "overview", "lesson"); + ?> +
+ + + + + +
+ + + \n"; + /// CDC-FLAG /// 6/16/04 + echo "\n"; + /// CDC-FLAG /// + for ($i = 0; $i < $lesson->maxanswers; $i++) { + $iplus1 = $i + 1; + echo "\n"; + echo "\n"; + } + // close table and form + ?> +
:
+
"; + echo get_string("pagecontents", "lesson").":
\n"; + print_textarea($usehtmleditor, 25,70, 630, 400, "contents"); + use_html_editor("contents"); + echo "
\n"; + echo "
"; + echo get_string("arrangebuttonshorizontally", "lesson")."\n"; + echo "
"; + echo get_string("displayinleftmenu", "lesson"); + echo "
\n"; + echo "
".get_string("description", "lesson")." $iplus1:
\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 + echo "
".get_string("jump", "lesson")." $iplus1: \n"; + if ($i) { + // answers 2, 3, 4... jumpto this page + lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); + } else { + // answer 1 jumpto next page + lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); + } + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + echo "

+ " /> + " /> +
+
diff --git a/mod/lesson/action/addendofbranch.php b/mod/lesson/action/addendofbranch.php index 8266eb9030a..da248dcbd71 100644 --- a/mod/lesson/action/addendofbranch.php +++ b/mod/lesson/action/addendofbranch.php @@ -2,65 +2,65 @@ /************** add end of branch ************************************/ - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } - confirm_sesskey(); + confirm_sesskey(); - // first get the preceeding page - $pageid = required_param('pageid', PARAM_INT); + // first get the preceeding page + $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) - if (!$page = get_record("lesson_pages", "id", $pageid)) { - error("Add end of branch: page record not found"); - } - // chain back up to find the (nearest branch table) - $btpageid = $pageid; - if (!$btpage = get_record("lesson_pages", "id", $btpageid)) { - error("Add end of branch: btpage record not found"); - } - while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) { - $btpageid = $btpage->prevpageid; - if (!$btpage = get_record("lesson_pages", "id", $btpageid)) { - error("Add end of branch: btpage record not found"); - } - } - if ($btpage->qtype == LESSON_BRANCHTABLE) { - $newpage = new stdClass; - $newpage->lessonid = $lesson->id; - $newpage->prevpageid = $pageid; - $newpage->nextpageid = $page->nextpageid; - $newpage->qtype = LESSON_ENDOFBRANCH; - $newpage->timecreated = $timenow; - $newpage->title = get_string("endofbranch", "lesson"); - $newpage->contents = get_string("endofbranch", "lesson"); - if (!$newpageid = insert_record("lesson_pages", $newpage)) { - error("Insert page: new page not inserted"); - } - // update the linked list... - if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) { - error("Add end of branch: unable to update link"); - } - if ($page->nextpageid) { - // the new page is not the last page - if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) { - error("Insert page: unable to update previous link"); - } - } - // ..and the single "answer" - $newanswer = new stdClass; - $newanswer->lessonid = $lesson->id; - $newanswer->pageid = $newpageid; - $newanswer->timecreated = $timenow; - $newanswer->jumpto = $btpageid; - if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { - error("Add end of branch: answer record not inserted"); - } - redirect("view.php?id=$cm->id", get_string('addedanendofbranch', 'lesson')); - } else { - notice(get_string("nobranchtablefound", "lesson"), "view.php?id=$cm->id"); - } -?> \ No newline at end of file + // the new page is not the first page (end of branch always comes after an existing page) + if (!$page = get_record("lesson_pages", "id", $pageid)) { + error("Add end of branch: page record not found"); + } + // chain back up to find the (nearest branch table) + $btpageid = $pageid; + if (!$btpage = get_record("lesson_pages", "id", $btpageid)) { + error("Add end of branch: btpage record not found"); + } + while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) { + $btpageid = $btpage->prevpageid; + if (!$btpage = get_record("lesson_pages", "id", $btpageid)) { + error("Add end of branch: btpage record not found"); + } + } + if ($btpage->qtype == LESSON_BRANCHTABLE) { + $newpage = new stdClass; + $newpage->lessonid = $lesson->id; + $newpage->prevpageid = $pageid; + $newpage->nextpageid = $page->nextpageid; + $newpage->qtype = LESSON_ENDOFBRANCH; + $newpage->timecreated = $timenow; + $newpage->title = get_string("endofbranch", "lesson"); + $newpage->contents = get_string("endofbranch", "lesson"); + if (!$newpageid = insert_record("lesson_pages", $newpage)) { + error("Insert page: new page not inserted"); + } + // update the linked list... + if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) { + error("Add end of branch: unable to update link"); + } + if ($page->nextpageid) { + // the new page is not the last page + if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) { + error("Insert page: unable to update previous link"); + } + } + // ..and the single "answer" + $newanswer = new stdClass; + $newanswer->lessonid = $lesson->id; + $newanswer->pageid = $newpageid; + $newanswer->timecreated = $timenow; + $newanswer->jumpto = $btpageid; + if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { + error("Add end of branch: answer record not inserted"); + } + redirect("view.php?id=$cm->id", get_string('addedanendofbranch', 'lesson')); + } else { + notice(get_string("nobranchtablefound", "lesson"), "view.php?id=$cm->id"); + } +?> diff --git a/mod/lesson/action/addpage.php b/mod/lesson/action/addpage.php index b4c491ac0f4..232a276632e 100644 --- a/mod/lesson/action/addpage.php +++ b/mod/lesson/action/addpage.php @@ -2,240 +2,240 @@ /************** add page ************************************/ - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } - // first get the preceeding page - $pageid = required_param('pageid', PARAM_INT); + // first get the preceeding page + $pageid = required_param('pageid', PARAM_INT); - // set of jump array - $jump = array(); - $jump[0] = get_string("thispage", "lesson"); - $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); - //// CDC-FLAG 6/18/04 ///// - $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson"); - if(lesson_display_branch_jumps($lesson->id, $pageid)) { - $jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson"); - $jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson"); - } - if(lesson_display_cluster_jump($lesson->id, $pageid)) { - $jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson"); - } - /// CDC-FLAG /// - if (!isset($_GET['firstpage'])) { - $linkadd = ""; - $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); - if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { - error("Add page: first page not found"); - } - while (true) { - if ($apageid) { - $title = get_field("lesson_pages", "title", "id", $apageid); - $jump[$apageid] = strip_tags(format_string($title,true)); - $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid); - } else { - // last page reached - break; - } - } - } else { - $linkadd = "&firstpage=1"; - } + // set of jump array + $jump = array(); + $jump[0] = get_string("thispage", "lesson"); + $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); + //// CDC-FLAG 6/18/04 ///// + $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson"); + if(lesson_display_branch_jumps($lesson->id, $pageid)) { + $jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson"); + $jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson"); + } + if(lesson_display_cluster_jump($lesson->id, $pageid)) { + $jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson"); + } + /// CDC-FLAG /// + if (!isset($_GET['firstpage'])) { + $linkadd = ""; + $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); + if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { + error("Add page: first page not found"); + } + while (true) { + if ($apageid) { + $title = get_field("lesson_pages", "title", "id", $apageid); + $jump[$apageid] = strip_tags(format_string($title,true)); + $apageid = get_field("lesson_pages", "nextpageid", "id", $apageid); + } else { + // last page reached + break; + } + } + } else { + $linkadd = "&firstpage=1"; + } - // give teacher a blank proforma - print_heading_with_help(get_string("addaquestionpage", "lesson"), "overview", "lesson"); - ?> -
- - - - -
- '.get_string("questiontype", "lesson").": \n"; - echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."
"; - if (isset($_GET['qtype'])) { - $qtype = clean_param($_GET['qtype'], PARAM_INT); - lesson_qtype_menu($LESSON_QUESTION_TYPE, $qtype, - "lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd); - // NoticeFix rearraged - if ( $qtype == LESSON_SHORTANSWER || $qtype == LESSON_MULTICHOICE ) { // only display this option for Multichoice and shortanswer - echo '

'; - if ($qtype == LESSON_SHORTANSWER) { - echo "".get_string("casesensitive", "lesson").": \n"; - } else { - echo "".get_string("multianswer", "lesson").": \n"; - } - echo " "; //CDC hidden label added. - helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); - echo '

'; - } - } else { - lesson_qtype_menu($LESSON_QUESTION_TYPE, LESSON_MULTICHOICE, - "lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd); - echo "

".get_string("multianswer", "lesson").": \n"; - echo " "; //CDC hidden label added. - helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); - } - ?> - - - - \n"; - if (isset($_GET['qtype'])) { - switch ($_GET['qtype']) { - case LESSON_TRUEFALSE : - for ($i = 0; $i < 2; $i++) { - $iplus1 = $i + 1; - echo "\n"; - echo "\n"; - echo "\n"; - } - break; - case LESSON_ESSAY : - echo "\n"; - break; - case LESSON_MATCHING : - for ($i = 0; $i < $lesson->maxanswers+2; $i++) { - $icorrected = $i - 1; - if ($i == 0) { - echo "\n"; - } elseif ($i == 1) { - echo "\n"; - } else { - echo "\n"; - echo "\n"; - } - if ($i == 2) { - echo "\n"; - } elseif ($i == 3) { - echo "\n"; - } - } - break; - case LESSON_SHORTANSWER : - case LESSON_NUMERICAL : - case LESSON_MULTICHOICE : - // default code - for ($i = 0; $i < $lesson->maxanswers; $i++) { - $iplus1 = $i + 1; - echo "\n"; - echo "\n"; - echo "\n"; - } - break; - } - } else { - for ($i = 0; $i < $lesson->maxanswers; $i++) { - $iplus1 = $i + 1; - echo "\n"; - echo "\n"; - echo "\n"; - } - } - // close table and form - ?> -
:
-
"; - echo get_string("pagecontents", "lesson").":
\n"; - print_textarea($usehtmleditor, 25,70, 630, 400, "contents"); - use_html_editor("contents"); - echo "
".get_string("answer", "lesson")." $iplus1:
\n"; - print_textarea(false, 6, 70, 630, 300, "answer[$i]"); - echo "
".get_string("response", "lesson")." $iplus1:
\n"; - print_textarea(false, 6, 70, 630, 300, "response[$i]"); - echo "
".get_string("jump", "lesson")." $iplus1: \n"; - if ($i) { - // answers 2, 3, 4... jumpto this page - lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); - } else { - // answer 1 jumpto next page - lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); - } - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - /// CDC-FLAG /// - if($lesson->custom) { - if ($i) { - echo get_string("score", "lesson")." $iplus1: "; - } else { - echo get_string("score", "lesson")." $iplus1: "; - } - } - /// CDC-FLAG /// - echo "
".get_string("jump", "lesson").": \n"; - lesson_choose_from_menu($jump, "jumpto[0]", LESSON_NEXTPAGE, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if ($lesson->custom) { - echo get_string("score", "lesson").": "; - } - echo "
".get_string("correctresponse", "lesson").":
\n"; - print_textarea(false, 6, 70, 630, 300, "answer[$i]"); - echo "
".get_string("wrongresponse", "lesson").":
\n"; - print_textarea(false, 6, 70, 630, 300, "answer[$i]"); - echo "
".get_string("answer", "lesson")." $icorrected:
\n"; - print_textarea(false, 6, 70, 630, 300, "answer[$i]"); - echo "
".get_string("matchesanswer", "lesson")." $icorrected:
\n"; - print_textarea(false, 6, 70, 630, 300, "response[$i]"); - echo "
".get_string("correctanswerjump", "lesson").": \n"; - lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if($lesson->custom) { - echo get_string("correctanswerscore", "lesson").": "; - } - echo "
".get_string("wronganswerjump", "lesson").": \n"; - lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if($lesson->custom) { - echo get_string("wronganswerscore", "lesson").": "; - } - echo "
".get_string("answer", "lesson")." $iplus1:
\n"; - print_textarea(false, 6, 70, 630, 300, "answer[$i]"); - echo "
".get_string("response", "lesson")." $iplus1:
\n"; - print_textarea(false, 6, 70, 630, 300, "response[$i]"); - echo "
".get_string("jump", "lesson")." $iplus1: \n"; - if ($i) { - // answers 2, 3, 4... jumpto this page - lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); - } else { - // answer 1 jumpto next page - lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); - } - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - /// CDC-FLAG /// - if($lesson->custom) { - if ($i) { - echo get_string("score", "lesson")." $iplus1: "; - } else { - echo get_string("score", "lesson")." $iplus1: "; - } - } - /// CDC-FLAG /// - echo "
".get_string("answer", "lesson")." $iplus1:
\n"; - print_textarea(false, 6, 70, 630, 300, "answer[$i]"); - echo "
".get_string("response", "lesson")." $iplus1:
\n"; - print_textarea(false, 6, 70, 630, 300, "response[$i]"); - echo "
".get_string("jump", "lesson")." $iplus1: \n"; - if ($i) { - // answers 2, 3, 4... jumpto this page - lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); - } else { - // answer 1 jumpto next page - lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); - } - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - /// CDC-FLAG /// - if($lesson->custom) { - if ($i) { - echo get_string("score", "lesson")." $iplus1: "; - } else { - echo get_string("score", "lesson")." $iplus1: "; - } - } - /// CDC-FLAG /// - echo "

- "> - "> -
-
+ // give teacher a blank proforma + print_heading_with_help(get_string("addaquestionpage", "lesson"), "overview", "lesson"); + ?> +
+ + + + +
+ '.get_string("questiontype", "lesson").": \n"; + echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."
"; + if (isset($_GET['qtype'])) { + $qtype = clean_param($_GET['qtype'], PARAM_INT); + lesson_qtype_menu($LESSON_QUESTION_TYPE, $qtype, + "lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd); + // NoticeFix rearraged + if ( $qtype == LESSON_SHORTANSWER || $qtype == LESSON_MULTICHOICE ) { // only display this option for Multichoice and shortanswer + echo '

'; + if ($qtype == LESSON_SHORTANSWER) { + echo "".get_string("casesensitive", "lesson").": \n"; + } else { + echo "".get_string("multianswer", "lesson").": \n"; + } + echo " "; //CDC hidden label added. + helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); + echo '

'; + } + } else { + lesson_qtype_menu($LESSON_QUESTION_TYPE, LESSON_MULTICHOICE, + "lesson.php?id=$cm->id&action=addpage&pageid=".$pageid.$linkadd); + echo "

".get_string("multianswer", "lesson").": \n"; + echo " "; //CDC hidden label added. + helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); + } + ?> + + + + \n"; + if (isset($_GET['qtype'])) { + switch ($_GET['qtype']) { + case LESSON_TRUEFALSE : + for ($i = 0; $i < 2; $i++) { + $iplus1 = $i + 1; + echo "\n"; + echo "\n"; + echo "\n"; + } + break; + case LESSON_ESSAY : + echo "\n"; + break; + case LESSON_MATCHING : + for ($i = 0; $i < $lesson->maxanswers+2; $i++) { + $icorrected = $i - 1; + if ($i == 0) { + echo "\n"; + } elseif ($i == 1) { + echo "\n"; + } else { + echo "\n"; + echo "\n"; + } + if ($i == 2) { + echo "\n"; + } elseif ($i == 3) { + echo "\n"; + } + } + break; + case LESSON_SHORTANSWER : + case LESSON_NUMERICAL : + case LESSON_MULTICHOICE : + // default code + for ($i = 0; $i < $lesson->maxanswers; $i++) { + $iplus1 = $i + 1; + echo "\n"; + echo "\n"; + echo "\n"; + } + break; + } + } else { + for ($i = 0; $i < $lesson->maxanswers; $i++) { + $iplus1 = $i + 1; + echo "\n"; + echo "\n"; + echo "\n"; + } + } + // close table and form + ?> +
:
+
"; + echo get_string("pagecontents", "lesson").":
\n"; + print_textarea($usehtmleditor, 25,70, 630, 400, "contents"); + use_html_editor("contents"); + echo "
".get_string("answer", "lesson")." $iplus1:
\n"; + print_textarea(false, 6, 70, 630, 300, "answer[$i]"); + echo "
".get_string("response", "lesson")." $iplus1:
\n"; + print_textarea(false, 6, 70, 630, 300, "response[$i]"); + echo "
".get_string("jump", "lesson")." $iplus1: \n"; + if ($i) { + // answers 2, 3, 4... jumpto this page + lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); + } else { + // answer 1 jumpto next page + lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); + } + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + /// CDC-FLAG /// + if($lesson->custom) { + if ($i) { + echo get_string("score", "lesson")." $iplus1: "; + } else { + echo get_string("score", "lesson")." $iplus1: "; + } + } + /// CDC-FLAG /// + echo "
".get_string("jump", "lesson").": \n"; + lesson_choose_from_menu($jump, "jumpto[0]", LESSON_NEXTPAGE, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if ($lesson->custom) { + echo get_string("score", "lesson").": "; + } + echo "
".get_string("correctresponse", "lesson").":
\n"; + print_textarea(false, 6, 70, 630, 300, "answer[$i]"); + echo "
".get_string("wrongresponse", "lesson").":
\n"; + print_textarea(false, 6, 70, 630, 300, "answer[$i]"); + echo "
".get_string("answer", "lesson")." $icorrected:
\n"; + print_textarea(false, 6, 70, 630, 300, "answer[$i]"); + echo "
".get_string("matchesanswer", "lesson")." $icorrected:
\n"; + print_textarea(false, 6, 70, 630, 300, "response[$i]"); + echo "
".get_string("correctanswerjump", "lesson").": \n"; + lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if($lesson->custom) { + echo get_string("correctanswerscore", "lesson").": "; + } + echo "
".get_string("wronganswerjump", "lesson").": \n"; + lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if($lesson->custom) { + echo get_string("wronganswerscore", "lesson").": "; + } + echo "
".get_string("answer", "lesson")." $iplus1:
\n"; + print_textarea(false, 6, 70, 630, 300, "answer[$i]"); + echo "
".get_string("response", "lesson")." $iplus1:
\n"; + print_textarea(false, 6, 70, 630, 300, "response[$i]"); + echo "
".get_string("jump", "lesson")." $iplus1: \n"; + if ($i) { + // answers 2, 3, 4... jumpto this page + lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); + } else { + // answer 1 jumpto next page + lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); + } + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + /// CDC-FLAG /// + if($lesson->custom) { + if ($i) { + echo get_string("score", "lesson")." $iplus1: "; + } else { + echo get_string("score", "lesson")." $iplus1: "; + } + } + /// CDC-FLAG /// + echo "
".get_string("answer", "lesson")." $iplus1:
\n"; + print_textarea(false, 6, 70, 630, 300, "answer[$i]"); + echo "
".get_string("response", "lesson")." $iplus1:
\n"; + print_textarea(false, 6, 70, 630, 300, "response[$i]"); + echo "
".get_string("jump", "lesson")." $iplus1: \n"; + if ($i) { + // answers 2, 3, 4... jumpto this page + lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); + } else { + // answer 1 jumpto next page + lesson_choose_from_menu($jump, "jumpto[$i]", LESSON_NEXTPAGE, ""); + } + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + /// CDC-FLAG /// + if($lesson->custom) { + if ($i) { + echo get_string("score", "lesson")." $iplus1: "; + } else { + echo get_string("score", "lesson")." $iplus1: "; + } + } + /// CDC-FLAG /// + echo "

+ "> + "> +
+
diff --git a/mod/lesson/action/confirmdelete.php b/mod/lesson/action/confirmdelete.php index 4e7625f3400..a0225767b24 100644 --- a/mod/lesson/action/confirmdelete.php +++ b/mod/lesson/action/confirmdelete.php @@ -2,30 +2,30 @@ /******************* confirm delete ************************************/ - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } - confirm_sesskey(); + confirm_sesskey(); - $pageid = required_param('pageid', PARAM_INT); - if (!$thispage = get_record("lesson_pages", "id", $pageid)) { - error("Confirm delete: the page record not found"); - } - print_heading(get_string("deletingpage", "lesson", format_string($thispage->title))); - // print the jumps to this page - if ($answers = get_records_select("lesson_answers", "lessonid = $lesson->id AND jumpto = $pageid + 1")) { - print_heading(get_string("thefollowingpagesjumptothispage", "lesson")); - echo "

\n"; - foreach ($answers as $answer) { - if (!$title = get_field("lesson_pages", "title", "id", $answer->pageid)) { - error("Confirm delete: page title not found"); - } - echo $title."
\n"; - } - } - notice_yesno(get_string("confirmdeletionofthispage","lesson"), - "lesson.php?action=delete&id=$cm->id&pageid=$pageid&sesskey=".$USER->sesskey, - "view.php?id=$cm->id"); + $pageid = required_param('pageid', PARAM_INT); + if (!$thispage = get_record("lesson_pages", "id", $pageid)) { + error("Confirm delete: the page record not found"); + } + print_heading(get_string("deletingpage", "lesson", format_string($thispage->title))); + // print the jumps to this page + if ($answers = get_records_select("lesson_answers", "lessonid = $lesson->id AND jumpto = $pageid + 1")) { + print_heading(get_string("thefollowingpagesjumptothispage", "lesson")); + echo "

\n"; + foreach ($answers as $answer) { + if (!$title = get_field("lesson_pages", "title", "id", $answer->pageid)) { + error("Confirm delete: page title not found"); + } + echo $title."
\n"; + } + } + notice_yesno(get_string("confirmdeletionofthispage","lesson"), + "lesson.php?action=delete&id=$cm->id&pageid=$pageid&sesskey=".$USER->sesskey, + "view.php?id=$cm->id"); ?> diff --git a/mod/lesson/action/continue.php b/mod/lesson/action/continue.php index 2a78ae5c3f4..3ec604f8f71 100644 --- a/mod/lesson/action/continue.php +++ b/mod/lesson/action/continue.php @@ -1,798 +1,798 @@ displayleft) { - if($firstpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) { - echo '
'; - // print the pages - echo '
'; - echo ''; - echo ''; - echo ''; - echo "
"; - echo "
".get_string('lessonmenu', 'lesson')."
"; - echo ""; - echo '
'; - lesson_print_tree_menu($lesson->id, $firstpageid, $cm->id); - echo '
'; //close lmlinks - echo '
'; - echo '
'; - } - } + // left menu code + if ($lesson->displayleft) { + if($firstpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) { + echo '
'; + // print the pages + echo '
'; + echo ''; + echo ''; + echo ''; + echo "
"; + echo "
".get_string('lessonmenu', 'lesson')."
"; + echo ""; + echo '
'; + lesson_print_tree_menu($lesson->id, $firstpageid, $cm->id); + echo '
'; //close lmlinks + echo '
'; + echo '
'; + } + } - /// CDC-FLAG /// 6/21/04 This is the warning msg for teachers to inform them that cluster and unseen does not work while logged in as a teacher - if(isteacher($course->id)) { - if (execute_teacherwarning($lesson->id)) { - $warningvars->cluster = get_string("clusterjump", "lesson"); - $warningvars->unseen = get_string("unseenpageinbranch", "lesson"); - echo "

".get_string("teacherjumpwarning", "lesson", $warningvars)."

"; - } - } - /// CDC-FLAG /// + /// CDC-FLAG /// 6/21/04 This is the warning msg for teachers to inform them that cluster and unseen does not work while logged in as a teacher + if(isteacher($course->id)) { + if (execute_teacherwarning($lesson->id)) { + $warningvars->cluster = get_string("clusterjump", "lesson"); + $warningvars->unseen = get_string("unseenpageinbranch", "lesson"); + echo "

".get_string("teacherjumpwarning", "lesson", $warningvars)."

"; + } + } + /// CDC-FLAG /// - /// CDC-FLAG /// 6/14/04 -- This is the code updates the lesson time for a timed test - // get time information for this user - if (!isteacher($course->id)) { - if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) { - error('Error: could not find records'); - } else { - $timer = array_pop($timer); // this will get the latest start time record - } - } - $outoftime = false; - if($lesson->timed) { - if(isteacher($course->id)) { - echo "

".get_string("teachertimerwarning", "lesson")."

"; - } else { - if ((($timer->starttime + $lesson->maxtime * 60) - time()) > 0) { - // code for the clock - print_simple_box_start("right", "150px", "#ffffff", 0); - echo "". - "
".get_string("timeremaining", "lesson"). - "
"; - echo "\n"; - echo "
"; - print_simple_box_end(); - echo "



"; - } else { - redirect("view.php?id=$cm->id&action=navigation&pageid=".LESSON_EOL."&outoftime=normal", get_string("outoftime", "lesson")); - } - if ((($timer->starttime + $lesson->maxtime * 60) - time()) < 60 && !((($timer->starttime + $lesson->maxtime * 60) - time()) < 0)) { - echo "

".get_string("studentoneminwarning", "lesson")."

"; - } elseif (($timer->starttime + $lesson->maxtime * 60) < time()) { - echo "

".get_string("studentoutoftime", "lesson")."

"; - $outoftime = true; - } - } - } - // update the clock - if (!isteacher($course->id)) { - $timer->lessontime = time(); - if (!update_record("lesson_timer", $timer)) { - error("Error: could not update lesson_timer table"); - } - } - /// CDC-FLAG /// + /// CDC-FLAG /// 6/14/04 -- This is the code updates the lesson time for a timed test + // get time information for this user + if (!isteacher($course->id)) { + if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) { + error('Error: could not find records'); + } else { + $timer = array_pop($timer); // this will get the latest start time record + } + } + $outoftime = false; + if($lesson->timed) { + if(isteacher($course->id)) { + echo "

".get_string("teachertimerwarning", "lesson")."

"; + } else { + if ((($timer->starttime + $lesson->maxtime * 60) - time()) > 0) { + // code for the clock + print_simple_box_start("right", "150px", "#ffffff", 0); + echo "". + "
".get_string("timeremaining", "lesson"). + "
"; + echo "\n"; + echo "
"; + print_simple_box_end(); + echo "



"; + } else { + redirect("view.php?id=$cm->id&action=navigation&pageid=".LESSON_EOL."&outoftime=normal", get_string("outoftime", "lesson")); + } + if ((($timer->starttime + $lesson->maxtime * 60) - time()) < 60 && !((($timer->starttime + $lesson->maxtime * 60) - time()) < 0)) { + echo "

".get_string("studentoneminwarning", "lesson")."

"; + } elseif (($timer->starttime + $lesson->maxtime * 60) < time()) { + echo "

".get_string("studentoutoftime", "lesson")."

"; + $outoftime = true; + } + } + } + // update the clock + if (!isteacher($course->id)) { + $timer->lessontime = time(); + if (!update_record("lesson_timer", $timer)) { + error("Error: could not update lesson_timer table"); + } + } + /// CDC-FLAG /// - // record answer (if necessary) and show response (if none say if answer is correct or not) - if (empty($_POST['pageid'])) { - error("Continue: pageid missing"); - } - $pageid = required_param('pageid', PARAM_INT); - if (!$page = get_record("lesson_pages", "id", $pageid)) { - error("Continue: Page record not found"); - } - // set up some defaults - $answerid = 0; - $noanswer = false; - $correctanswer = false; - $isessayquestion = false; // use this to turn off review button on essay questions - $newpageid = 0; // stay on the page - switch ($page->qtype) { - /// CDC-FLAG /// - case LESSON_ESSAY : - $isessayquestion = true; - if (!$useranswer = $_POST['answer']) { - $noanswer = true; - break; - } - $useranswer = clean_param($useranswer, PARAM_CLEAN); + // record answer (if necessary) and show response (if none say if answer is correct or not) + if (empty($_POST['pageid'])) { + error("Continue: pageid missing"); + } + $pageid = required_param('pageid', PARAM_INT); + if (!$page = get_record("lesson_pages", "id", $pageid)) { + error("Continue: Page record not found"); + } + // set up some defaults + $answerid = 0; + $noanswer = false; + $correctanswer = false; + $isessayquestion = false; // use this to turn off review button on essay questions + $newpageid = 0; // stay on the page + switch ($page->qtype) { + /// CDC-FLAG /// + case LESSON_ESSAY : + $isessayquestion = true; + if (!$useranswer = $_POST['answer']) { + $noanswer = true; + break; + } + $useranswer = clean_param($useranswer, PARAM_CLEAN); - if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { - error("Continue: No answers found"); - } - $correctanswer = false; - $response = "Your essay will be graded by the course instructor."; - foreach ($answers as $answer) { - $answerid = $answer->id; - $newpageid = $answer->jumpto; - } - /// 6/29/04 // - $userresponse->sent=0; - $userresponse->graded = 0; - $userresponse->score = 0; - $userresponse->answer = $useranswer; - $userresponse->response = ""; - $userresponse = addslashes(serialize($userresponse)); + if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { + error("Continue: No answers found"); + } + $correctanswer = false; + $response = "Your essay will be graded by the course instructor."; + foreach ($answers as $answer) { + $answerid = $answer->id; + $newpageid = $answer->jumpto; + } + /// 6/29/04 // + $userresponse->sent=0; + $userresponse->graded = 0; + $userresponse->score = 0; + $userresponse->answer = $useranswer; + $userresponse->response = ""; + $userresponse = addslashes(serialize($userresponse)); - break; - /// CDC-FLAG /// - case LESSON_SHORTANSWER : - if (!$useranswer = $_POST['answer']) { - $noanswer = true; - break; - } - $useranswer = clean_param($useranswer, PARAM_CLEAN); - $userresponse = addslashes($useranswer); + break; + /// CDC-FLAG /// + case LESSON_SHORTANSWER : + if (!$useranswer = $_POST['answer']) { + $noanswer = true; + break; + } + $useranswer = clean_param($useranswer, PARAM_CLEAN); + $userresponse = addslashes($useranswer); - if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { - error("Continue: No answers found"); - } - foreach ($answers as $answer) { - /// CDC-FLAG /// - if ($lesson->custom && $answer->score > 0) { - if ($page->qoption) { - // case sensitive - if ($answer->answer == $useranswer) { - $correctanswer = true; - $answerid = $answer->id; - $newpageid = $answer->jumpto; - if (trim(strip_tags($answer->response))) { - $response = $answer->response; - } - } - } else { - // case insensitive - if (strcasecmp($answer->answer, $useranswer) == 0) { - $correctanswer = true; - $answerid = $answer->id; - $newpageid = $answer->jumpto; - if (trim(strip_tags($answer->response))) { - $response = $answer->response; - } - } - } - } elseif (lesson_iscorrect($pageid, $answer->jumpto) && !$lesson->custom) { /// CDC-FLAG 6/21/04 /// - if ($page->qoption) { - // case sensitive - if ($answer->answer == $useranswer) { - $correctanswer = true; - $newpageid = $answer->jumpto; - if (trim(strip_tags($answer->response))) { - $response = $answer->response; - } - } - } else { - // case insensitive - if (strcasecmp($answer->answer, $useranswer) == 0) { - $correctanswer = true; - $newpageid = $answer->jumpto; - if (trim(strip_tags($answer->response))) { - $response = $answer->response; - } - } - } - } else { - // see if user typed in any of the wrong answers - // don't worry about case - if (strcasecmp($answer->answer, $useranswer) == 0) { - $newpageid = $answer->jumpto; - $answerid = $answer->id; - if (trim(strip_tags($answer->response))) { - $response = $answer->response; - } - } - } - } - if (!isset($response)) { - if ($correctanswer) { - $response = get_string("thatsthecorrectanswer", "lesson"); - } else { - $response = get_string("thatsthewronganswer", "lesson"); - } - } - break; + if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { + error("Continue: No answers found"); + } + foreach ($answers as $answer) { + /// CDC-FLAG /// + if ($lesson->custom && $answer->score > 0) { + if ($page->qoption) { + // case sensitive + if ($answer->answer == $useranswer) { + $correctanswer = true; + $answerid = $answer->id; + $newpageid = $answer->jumpto; + if (trim(strip_tags($answer->response))) { + $response = $answer->response; + } + } + } else { + // case insensitive + if (strcasecmp($answer->answer, $useranswer) == 0) { + $correctanswer = true; + $answerid = $answer->id; + $newpageid = $answer->jumpto; + if (trim(strip_tags($answer->response))) { + $response = $answer->response; + } + } + } + } elseif (lesson_iscorrect($pageid, $answer->jumpto) && !$lesson->custom) { /// CDC-FLAG 6/21/04 /// + if ($page->qoption) { + // case sensitive + if ($answer->answer == $useranswer) { + $correctanswer = true; + $newpageid = $answer->jumpto; + if (trim(strip_tags($answer->response))) { + $response = $answer->response; + } + } + } else { + // case insensitive + if (strcasecmp($answer->answer, $useranswer) == 0) { + $correctanswer = true; + $newpageid = $answer->jumpto; + if (trim(strip_tags($answer->response))) { + $response = $answer->response; + } + } + } + } else { + // see if user typed in any of the wrong answers + // don't worry about case + if (strcasecmp($answer->answer, $useranswer) == 0) { + $newpageid = $answer->jumpto; + $answerid = $answer->id; + if (trim(strip_tags($answer->response))) { + $response = $answer->response; + } + } + } + } + if (!isset($response)) { + if ($correctanswer) { + $response = get_string("thatsthecorrectanswer", "lesson"); + } else { + $response = get_string("thatsthewronganswer", "lesson"); + } + } + break; - case LESSON_TRUEFALSE : - if (empty($_POST['answerid'])) { - $noanswer = true; - break; - } - $answerid = required_param('answerid', PARAM_INT); - if (!$answer = get_record("lesson_answers", "id", $answerid)) { - error("Continue: answer record not found"); - } - if (lesson_iscorrect($pageid, $answer->jumpto)) { - $correctanswer = true; - } - /* CDC-FLAG */ - if ($lesson->custom) { - if ($answer->score > 0) { - $correctanswer = true; - } else { - $correctanswer = false; - } - } - /// CDC-FLAG 6/21/04 /// - $newpageid = $answer->jumpto; - if (!$response = trim($answer->response)) { - if ($correctanswer) { - $response = get_string("thatsthecorrectanswer", "lesson"); - } else { - $response = get_string("thatsthewronganswer", "lesson"); - } - } - break; + case LESSON_TRUEFALSE : + if (empty($_POST['answerid'])) { + $noanswer = true; + break; + } + $answerid = required_param('answerid', PARAM_INT); + if (!$answer = get_record("lesson_answers", "id", $answerid)) { + error("Continue: answer record not found"); + } + if (lesson_iscorrect($pageid, $answer->jumpto)) { + $correctanswer = true; + } + /* CDC-FLAG */ + if ($lesson->custom) { + if ($answer->score > 0) { + $correctanswer = true; + } else { + $correctanswer = false; + } + } + /// CDC-FLAG 6/21/04 /// + $newpageid = $answer->jumpto; + if (!$response = trim($answer->response)) { + if ($correctanswer) { + $response = get_string("thatsthecorrectanswer", "lesson"); + } else { + $response = get_string("thatsthewronganswer", "lesson"); + } + } + break; - case LESSON_MULTICHOICE : - if ($page->qoption) { - // MULTIANSWER allowed, user's answer is an array - if (isset($_POST['answer'])) { - $useranswers = $_POST['answer']; - foreach ($useranswers as $key => $useranswer) { - $useranswers[$key] = clean_param($useranswer, PARAM_INT); - } - } else { - $noanswer = true; - break; - } - // get what the user answered - $userresponse = implode(",", $useranswers); - // get the answers in a set order, the id order - if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { - error("Continue: No answers found"); - } - $ncorrect = 0; - $nhits = 0; - $correctresponse = ''; - $wrongresponse = ''; - /// CDC-FLAG /// 6/11/04 this is for custom scores. If score on answer is positive, it is correct - if ($lesson->custom) { - $ncorrect = 0; - $nhits = 0; - foreach ($answers as $answer) { - if ($answer->score > 0) { - $ncorrect++; + case LESSON_MULTICHOICE : + if ($page->qoption) { + // MULTIANSWER allowed, user's answer is an array + if (isset($_POST['answer'])) { + $useranswers = $_POST['answer']; + foreach ($useranswers as $key => $useranswer) { + $useranswers[$key] = clean_param($useranswer, PARAM_INT); + } + } else { + $noanswer = true; + break; + } + // get what the user answered + $userresponse = implode(",", $useranswers); + // get the answers in a set order, the id order + if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { + error("Continue: No answers found"); + } + $ncorrect = 0; + $nhits = 0; + $correctresponse = ''; + $wrongresponse = ''; + /// CDC-FLAG /// 6/11/04 this is for custom scores. If score on answer is positive, it is correct + if ($lesson->custom) { + $ncorrect = 0; + $nhits = 0; + foreach ($answers as $answer) { + if ($answer->score > 0) { + $ncorrect++; - foreach ($useranswers as $key => $answerid) { - if ($answerid == $answer->id) { - $nhits++; - } - } - // save the first jumpto page id, may be needed!... - if (!isset($correctpageid)) { - // leave in its "raw" state - will converted into a proper page id later - $correctpageid = $answer->jumpto; - } - // ...also save any response from the correct answers... - if (trim(strip_tags($answer->response))) { - $correctresponse = $answer->response; - } - } else { - // save the first jumpto page id, may be needed!... - if (!isset($wrongpageid)) { - // leave in its "raw" state - will converted into a proper page id later - $wrongpageid = $answer->jumpto; - } - // ...and from the incorrect ones, don't know which to use at this stage - if (trim(strip_tags($answer->response))) { - $wrongresponse = $answer->response; - } - } - } - } else { - foreach ($answers as $answer) { - if (lesson_iscorrect($pageid, $answer->jumpto)) { - $ncorrect++; - foreach ($useranswers as $key => $answerid) { - if ($answerid == $answer->id) { - $nhits++; - } - } - // save the first jumpto page id, may be needed!... - if (!isset($correctpageid)) { - // leave in its "raw" state - will converted into a proper page id later - $correctpageid = $answer->jumpto; - } - // ...also save any response from the correct answers... - if (trim(strip_tags($answer->response))) { - $correctresponse = $answer->response; - } - } else { - // save the first jumpto page id, may be needed!... - if (!isset($wrongpageid)) { - // leave in its "raw" state - will converted into a proper page id later - $wrongpageid = $answer->jumpto; - } - // ...and from the incorrect ones, don't know which to use at this stage - if (trim(strip_tags($answer->response))) { - $wrongresponse = $answer->response; - } - } - } - } - /// CDC-FLAG /// - if ((count($useranswers) == $ncorrect) and ($nhits == $ncorrect)) { - $correctanswer = true; - if (!$response = $correctresponse) { - $response = get_string("thatsthecorrectanswer", "lesson"); - } - $newpageid = $correctpageid; - } else { - if (!$response = $wrongresponse) { - $response = get_string("thatsthewronganswer", "lesson"); - } - $newpageid = $wrongpageid; - } - } else { - // only one answer allowed - if (empty($_POST['answerid'])) { - $noanswer = true; - break; - } - $answerid = required_param('answerid', PARAM_INT); - if (!$answer = get_record("lesson_answers", "id", $answerid)) { - error("Continue: answer record not found"); - } - if (lesson_iscorrect($pageid, $answer->jumpto)) { - $correctanswer = true; - } - /* CDC-FLAG */ - if ($lesson->custom) { - if ($answer->score > 0) { - $correctanswer = true; - } else { - $correctanswer = false; - } - } - /// CDC-FLAG /// - $newpageid = $answer->jumpto; - if (!$response = trim($answer->response)) { - if ($correctanswer) { - $response = get_string("thatsthecorrectanswer", "lesson"); - } else { - $response = get_string("thatsthewronganswer", "lesson"); - } - } - } - break; + foreach ($useranswers as $key => $answerid) { + if ($answerid == $answer->id) { + $nhits++; + } + } + // save the first jumpto page id, may be needed!... + if (!isset($correctpageid)) { + // leave in its "raw" state - will converted into a proper page id later + $correctpageid = $answer->jumpto; + } + // ...also save any response from the correct answers... + if (trim(strip_tags($answer->response))) { + $correctresponse = $answer->response; + } + } else { + // save the first jumpto page id, may be needed!... + if (!isset($wrongpageid)) { + // leave in its "raw" state - will converted into a proper page id later + $wrongpageid = $answer->jumpto; + } + // ...and from the incorrect ones, don't know which to use at this stage + if (trim(strip_tags($answer->response))) { + $wrongresponse = $answer->response; + } + } + } + } else { + foreach ($answers as $answer) { + if (lesson_iscorrect($pageid, $answer->jumpto)) { + $ncorrect++; + foreach ($useranswers as $key => $answerid) { + if ($answerid == $answer->id) { + $nhits++; + } + } + // save the first jumpto page id, may be needed!... + if (!isset($correctpageid)) { + // leave in its "raw" state - will converted into a proper page id later + $correctpageid = $answer->jumpto; + } + // ...also save any response from the correct answers... + if (trim(strip_tags($answer->response))) { + $correctresponse = $answer->response; + } + } else { + // save the first jumpto page id, may be needed!... + if (!isset($wrongpageid)) { + // leave in its "raw" state - will converted into a proper page id later + $wrongpageid = $answer->jumpto; + } + // ...and from the incorrect ones, don't know which to use at this stage + if (trim(strip_tags($answer->response))) { + $wrongresponse = $answer->response; + } + } + } + } + /// CDC-FLAG /// + if ((count($useranswers) == $ncorrect) and ($nhits == $ncorrect)) { + $correctanswer = true; + if (!$response = $correctresponse) { + $response = get_string("thatsthecorrectanswer", "lesson"); + } + $newpageid = $correctpageid; + } else { + if (!$response = $wrongresponse) { + $response = get_string("thatsthewronganswer", "lesson"); + } + $newpageid = $wrongpageid; + } + } else { + // only one answer allowed + if (empty($_POST['answerid'])) { + $noanswer = true; + break; + } + $answerid = required_param('answerid', PARAM_INT); + if (!$answer = get_record("lesson_answers", "id", $answerid)) { + error("Continue: answer record not found"); + } + if (lesson_iscorrect($pageid, $answer->jumpto)) { + $correctanswer = true; + } + /* CDC-FLAG */ + if ($lesson->custom) { + if ($answer->score > 0) { + $correctanswer = true; + } else { + $correctanswer = false; + } + } + /// CDC-FLAG /// + $newpageid = $answer->jumpto; + if (!$response = trim($answer->response)) { + if ($correctanswer) { + $response = get_string("thatsthecorrectanswer", "lesson"); + } else { + $response = get_string("thatsthewronganswer", "lesson"); + } + } + } + break; - /// CDC-FLAG /// 6/14/04 -- added responses - case LESSON_MATCHING : - if (isset($_POST['response']) && is_array($_POST['response'])) { // only arrays should be submitted - $response = array(); - foreach ($_POST['response'] as $key => $value) { - $response[$key] = stripslashes($value); - } - } else { - $noanswer = true; - break; - } + /// CDC-FLAG /// 6/14/04 -- added responses + case LESSON_MATCHING : + if (isset($_POST['response']) && is_array($_POST['response'])) { // only arrays should be submitted + $response = array(); + foreach ($_POST['response'] as $key => $value) { + $response[$key] = stripslashes($value); + } + } else { + $noanswer = true; + break; + } - if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { - error("Continue: No answers found"); - } + if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { + error("Continue: No answers found"); + } - $ncorrect = 0; - $i = 0; - foreach ($answers as $answer) { - if ($i == 0 || $i == 1) { - // ignore first two answers, they are correct response - // and wrong response - $i++; - continue; - } - if ($answer->response == $response[$answer->id]) { - $ncorrect++; - } - if ($i == 2) { - $correctpageid = $answer->jumpto; - $correctanswerid = $answer->id; - } - if ($i == 3) { - $wrongpageid = $answer->jumpto; - $wronganswerid = $answer->id; - } - $i++; - } - // get he users exact responses for record keeping - foreach ($response as $value) { - foreach($answers as $answer) { - if ($value == $answer->response) { - $userresponse[] = $answer->id; - } - } - } - $userresponse = implode(",", $userresponse); + $ncorrect = 0; + $i = 0; + foreach ($answers as $answer) { + if ($i == 0 || $i == 1) { + // ignore first two answers, they are correct response + // and wrong response + $i++; + continue; + } + if ($answer->response == $response[$answer->id]) { + $ncorrect++; + } + if ($i == 2) { + $correctpageid = $answer->jumpto; + $correctanswerid = $answer->id; + } + if ($i == 3) { + $wrongpageid = $answer->jumpto; + $wronganswerid = $answer->id; + } + $i++; + } + // get he users exact responses for record keeping + foreach ($response as $value) { + foreach($answers as $answer) { + if ($value == $answer->response) { + $userresponse[] = $answer->id; + } + } + } + $userresponse = implode(",", $userresponse); - if ($ncorrect == count($answers)-2) { // dont count correct/wrong responses in the total. - $response = get_string("thatsthecorrectanswer", "lesson"); - foreach ($answers as $answer) { - if ($answer->response == NULL && $answer->answer != NULL) { - $response = $answer->answer; - break; - } - } - // NoticeFix - if (isset($correctpageid)) { - $newpageid = $correctpageid; - } - if (isset($correctanswerid)) { - $answerid = $correctanswerid; - } - $correctanswer = true; - } else { - $response = get_string("thatsthewronganswer", "lesson"); - $t = 0; - foreach ($answers as $answer) { - if ($answer->response == NULL && $answer->answer != NULL) { - if ($t == 1) { - $response = $answer->answer; - break; - } - $t++; - } - } - $newpageid = $wrongpageid; - $answerid = $wronganswerid; - } - break; - /// CDC-FLAG /// + if ($ncorrect == count($answers)-2) { // dont count correct/wrong responses in the total. + $response = get_string("thatsthecorrectanswer", "lesson"); + foreach ($answers as $answer) { + if ($answer->response == NULL && $answer->answer != NULL) { + $response = $answer->answer; + break; + } + } + // NoticeFix + if (isset($correctpageid)) { + $newpageid = $correctpageid; + } + if (isset($correctanswerid)) { + $answerid = $correctanswerid; + } + $correctanswer = true; + } else { + $response = get_string("thatsthewronganswer", "lesson"); + $t = 0; + foreach ($answers as $answer) { + if ($answer->response == NULL && $answer->answer != NULL) { + if ($t == 1) { + $response = $answer->answer; + break; + } + $t++; + } + } + $newpageid = $wrongpageid; + $answerid = $wronganswerid; + } + break; + /// CDC-FLAG /// - case LESSON_NUMERICAL : - // set defaults - $response = ''; - $newpageid = 0; + case LESSON_NUMERICAL : + // set defaults + $response = ''; + $newpageid = 0; - if (isset($_POST['answer'])) { - $useranswer = (float) optional_param('answer'); // just doing default PARAM_CLEAN, not doing PARAM_INT because it could be a float - } else { - $noanswer = true; - break; - } - $userresponse = $useranswer; - if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { - error("Continue: No answers found"); - } - foreach ($answers as $answer) { - if (strpos($answer->answer, ':')) { - // there's a pairs of values - list($min, $max) = explode(':', $answer->answer); - $minimum = (float) $min; - $maximum = (float) $max; - } else { - // there's only one value - $minimum = (float) $answer->answer; - $maximum = $minimum; - } - if (($useranswer >= $minimum) and ($useranswer <= $maximum)) { - $newpageid = $answer->jumpto; - $response = trim($answer->response); - if (lesson_iscorrect($pageid, $newpageid)) { - $correctanswer = true; - } - /// CDC-FLAG /// - if ($lesson->custom) { - if ($answer->score > 0) { - $correctanswer = true; - $answerid = $answer->id; - } else { - $correctanswer = false; - } - } - /// CDC-FLAG /// - break; - } - } - if ($correctanswer) { - if (!$response) { - $response = get_string("thatsthecorrectanswer", "lesson"); - } - } else { - if (!$response) { - $response = get_string("thatsthewronganswer", "lesson"); - } - } - break; + if (isset($_POST['answer'])) { + $useranswer = (float) optional_param('answer'); // just doing default PARAM_CLEAN, not doing PARAM_INT because it could be a float + } else { + $noanswer = true; + break; + } + $userresponse = $useranswer; + if (!$answers = get_records("lesson_answers", "pageid", $pageid, "id")) { + error("Continue: No answers found"); + } + foreach ($answers as $answer) { + if (strpos($answer->answer, ':')) { + // there's a pairs of values + list($min, $max) = explode(':', $answer->answer); + $minimum = (float) $min; + $maximum = (float) $max; + } else { + // there's only one value + $minimum = (float) $answer->answer; + $maximum = $minimum; + } + if (($useranswer >= $minimum) and ($useranswer <= $maximum)) { + $newpageid = $answer->jumpto; + $response = trim($answer->response); + if (lesson_iscorrect($pageid, $newpageid)) { + $correctanswer = true; + } + /// CDC-FLAG /// + if ($lesson->custom) { + if ($answer->score > 0) { + $correctanswer = true; + $answerid = $answer->id; + } else { + $correctanswer = false; + } + } + /// CDC-FLAG /// + break; + } + } + if ($correctanswer) { + if (!$response) { + $response = get_string("thatsthecorrectanswer", "lesson"); + } + } else { + if (!$response) { + $response = get_string("thatsthewronganswer", "lesson"); + } + } + break; - case LESSON_BRANCHTABLE: - $noanswer = false; - $newpageid = optional_param('jumpto', NULL, PARAM_INT); - /// CDC-FLAG /// 6/15/04 going to insert into lesson_branch - if ($newpageid == LESSON_RANDOMBRANCH) { - $branchflag = 1; - } else { - $branchflag = 0; - } - if ($grades = get_records_select("lesson_grades", "lessonid = $lesson->id AND userid = $USER->id", - "grade DESC")) { - $retries = count($grades); - } else { - $retries = 0; - } - $branch = new stdClass; - $branch->lessonid = $lesson->id; - $branch->userid = $USER->id; - $branch->pageid = $pageid; - $branch->retry = $retries; - $branch->flag = $branchflag; - $branch->timeseen = time(); + case LESSON_BRANCHTABLE: + $noanswer = false; + $newpageid = optional_param('jumpto', NULL, PARAM_INT); + /// CDC-FLAG /// 6/15/04 going to insert into lesson_branch + if ($newpageid == LESSON_RANDOMBRANCH) { + $branchflag = 1; + } else { + $branchflag = 0; + } + if ($grades = get_records_select("lesson_grades", "lessonid = $lesson->id AND userid = $USER->id", + "grade DESC")) { + $retries = count($grades); + } else { + $retries = 0; + } + $branch = new stdClass; + $branch->lessonid = $lesson->id; + $branch->userid = $USER->id; + $branch->pageid = $pageid; + $branch->retry = $retries; + $branch->flag = $branchflag; + $branch->timeseen = time(); - if (!insert_record("lesson_branch", $branch)) { - error("Error: could not insert row into lesson_branch table"); - } - /// CDC-FLAG /// + if (!insert_record("lesson_branch", $branch)) { + error("Error: could not insert row into lesson_branch table"); + } + /// CDC-FLAG /// - /// CDC-FLAG /// this is called when jumping to random from a branch table - if($newpageid == LESSON_UNSEENBRANCHPAGE) { - if (isteacher($course->id)) { - $newpageid = LESSON_NEXTPAGE; - } else { - $newpageid = lesson_unseen_question_jump($lesson->id, $USER->id, $pageid); // this may return 0 //CDC Chris Berri.....this is where it sets the next page id for unseen? - } - } - /// CDC-FLAG 6/15/04 /// - // convert jumpto page into a proper page id - if ($newpageid == 0) { - $newpageid = $pageid; - } elseif ($newpageid == LESSON_NEXTPAGE) { - if (!$newpageid = $page->nextpageid) { - // no nextpage go to end of lesson - $newpageid = LESSON_EOL; - } - /* CDC-FLAG */ } elseif ($newpageid == LESSON_PREVIOUSPAGE) { - $newpageid = $page->prevpageid; - } elseif ($newpageid == LESSON_RANDOMPAGE) { - $newpageid = lesson_random_question_jump($lesson->id, $pageid); - } elseif ($newpageid == LESSON_RANDOMBRANCH) { // 6/15/04 - $newpageid = lesson_unseen_branch_jump($lesson->id, $USER->id); - } - /// CDC-FLAG /// - // no need to record anything in lesson_attempts - redirect("view.php?id=$cm->id&action=navigation&pageid=$newpageid"); - print_footer($course); - exit(); - break; + /// CDC-FLAG /// this is called when jumping to random from a branch table + if($newpageid == LESSON_UNSEENBRANCHPAGE) { + if (isteacher($course->id)) { + $newpageid = LESSON_NEXTPAGE; + } else { + $newpageid = lesson_unseen_question_jump($lesson->id, $USER->id, $pageid); // this may return 0 //CDC Chris Berri.....this is where it sets the next page id for unseen? + } + } + /// CDC-FLAG 6/15/04 /// + // convert jumpto page into a proper page id + if ($newpageid == 0) { + $newpageid = $pageid; + } elseif ($newpageid == LESSON_NEXTPAGE) { + if (!$newpageid = $page->nextpageid) { + // no nextpage go to end of lesson + $newpageid = LESSON_EOL; + } + /* CDC-FLAG */ } elseif ($newpageid == LESSON_PREVIOUSPAGE) { + $newpageid = $page->prevpageid; + } elseif ($newpageid == LESSON_RANDOMPAGE) { + $newpageid = lesson_random_question_jump($lesson->id, $pageid); + } elseif ($newpageid == LESSON_RANDOMBRANCH) { // 6/15/04 + $newpageid = lesson_unseen_branch_jump($lesson->id, $USER->id); + } + /// CDC-FLAG /// + // no need to record anything in lesson_attempts + redirect("view.php?id=$cm->id&action=navigation&pageid=$newpageid"); + print_footer($course); + exit(); + break; - } - if ($noanswer) { - $newpageid = $pageid; // display same page again - print_simple_box(get_string("noanswer", "lesson"), "center"); - } else { - $nretakes = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id); - if (isstudent($course->id)) { - // record student's attempt - $attempt = new stdClass; - $attempt->lessonid = $lesson->id; - $attempt->pageid = $pageid; - $attempt->userid = $USER->id; - $attempt->answerid = $answerid; - $attempt->retry = $nretakes; - $attempt->correct = $correctanswer; - if(isset($userresponse)) { - $attempt->useranswer = $userresponse; - } - $attempt->timeseen = time(); - /// CDC-FLAG /// -- dont want to insert the attempt if they ran out of time - if (!$outoftime) { - // if allow modattempts, then update the old attempt record, otherwise, insert new answer record - if (isset($USER->modattempts[$lesson->id])) { - $attempt->retry = $nretakes - 1; // they are going through on review, $nretakes will be too high - } - if (!$newattemptid = insert_record("lesson_attempts", $attempt)) { - error("Continue: attempt not inserted"); - } - } - /// CDC-FLAG /// - if (!$correctanswer and ($newpageid == 0)) { - // wrong answer and student is stuck on this page - check how many attempts - // the student has had at this page/question - $nattempts = count_records("lesson_attempts", "pageid", $pageid, "userid", $USER->id, - "retry", $nretakes); + } + if ($noanswer) { + $newpageid = $pageid; // display same page again + print_simple_box(get_string("noanswer", "lesson"), "center"); + } else { + $nretakes = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id); + if (isstudent($course->id)) { + // record student's attempt + $attempt = new stdClass; + $attempt->lessonid = $lesson->id; + $attempt->pageid = $pageid; + $attempt->userid = $USER->id; + $attempt->answerid = $answerid; + $attempt->retry = $nretakes; + $attempt->correct = $correctanswer; + if(isset($userresponse)) { + $attempt->useranswer = $userresponse; + } + $attempt->timeseen = time(); + /// CDC-FLAG /// -- dont want to insert the attempt if they ran out of time + if (!$outoftime) { + // if allow modattempts, then update the old attempt record, otherwise, insert new answer record + if (isset($USER->modattempts[$lesson->id])) { + $attempt->retry = $nretakes - 1; // they are going through on review, $nretakes will be too high + } + if (!$newattemptid = insert_record("lesson_attempts", $attempt)) { + error("Continue: attempt not inserted"); + } + } + /// CDC-FLAG /// + if (!$correctanswer and ($newpageid == 0)) { + // wrong answer and student is stuck on this page - check how many attempts + // the student has had at this page/question + $nattempts = count_records("lesson_attempts", "pageid", $pageid, "userid", $USER->id, + "retry", $nretakes); - if ($nattempts >= $lesson->maxattempts) { - if ($lesson->maxattempts > 1) { // don't bother with message if only one attempt - echo "

(".get_string("maximumnumberofattempts", "lesson"). - " ".get_string("reached", "lesson")." - ". - get_string("movingtonextpage", "lesson").")

\n"; - } - $newpageid = LESSON_NEXTPAGE; - } - } - } - // convert jumpto page into a proper page id - if ($newpageid == 0) { - $newpageid = $pageid; - } elseif ($newpageid == LESSON_NEXTPAGE) { - if ($lesson->nextpagedefault) { - // in Flash Card mode... - // ... first get the page ids (lessonid the 5th param is needed to make get_records play) - $allpages = get_records("lesson_pages", "lessonid", $lesson->id, "id", "id,lessonid,qtype"); - shuffle ($allpages); - $found = false; - if ($lesson->nextpagedefault == LESSON_UNSEENPAGE) { - foreach ($allpages as $thispage) { - if (!count_records("lesson_attempts", "pageid", $thispage->id, "userid", - $USER->id, "retry", $nretakes)) { - $found = true; - break; - } - } - } elseif ($lesson->nextpagedefault == LESSON_UNANSWEREDPAGE) { - foreach ($allpages as $thispage) { - if ($thispage->qtype == LESSON_ESSAY) { - if (!count_records_select("lesson_attempts", "pageid = $thispage->id AND - userid = $USER->id AND retry = $nretakes")) { - $found = true; - break; - } - } else { - if (!count_records_select("lesson_attempts", "pageid = $thispage->id AND - userid = $USER->id AND correct = 1 AND retry = $nretakes")) { - $found = true; - break; - } - } - } - } - if ($found) { - $newpageid = $thispage->id; - if ($lesson->maxpages) { - // check number of pages viewed (in the lesson) - if (count_records("lesson_attempts", "lessonid", $lesson->id, "userid", $USER->id, - "retry", $nretakes) >= $lesson->maxpages) { - $newpageid = LESSON_EOL; - } - } - } else { - $newpageid = LESSON_EOL; - } - } elseif (!$newpageid = $page->nextpageid) { - // no nextpage go to end of lesson - $newpageid = LESSON_EOL; - } - } + if ($nattempts >= $lesson->maxattempts) { + if ($lesson->maxattempts > 1) { // don't bother with message if only one attempt + echo "

(".get_string("maximumnumberofattempts", "lesson"). + " ".get_string("reached", "lesson")." - ". + get_string("movingtonextpage", "lesson").")

\n"; + } + $newpageid = LESSON_NEXTPAGE; + } + } + } + // convert jumpto page into a proper page id + if ($newpageid == 0) { + $newpageid = $pageid; + } elseif ($newpageid == LESSON_NEXTPAGE) { + if ($lesson->nextpagedefault) { + // in Flash Card mode... + // ... first get the page ids (lessonid the 5th param is needed to make get_records play) + $allpages = get_records("lesson_pages", "lessonid", $lesson->id, "id", "id,lessonid,qtype"); + shuffle ($allpages); + $found = false; + if ($lesson->nextpagedefault == LESSON_UNSEENPAGE) { + foreach ($allpages as $thispage) { + if (!count_records("lesson_attempts", "pageid", $thispage->id, "userid", + $USER->id, "retry", $nretakes)) { + $found = true; + break; + } + } + } elseif ($lesson->nextpagedefault == LESSON_UNANSWEREDPAGE) { + foreach ($allpages as $thispage) { + if ($thispage->qtype == LESSON_ESSAY) { + if (!count_records_select("lesson_attempts", "pageid = $thispage->id AND + userid = $USER->id AND retry = $nretakes")) { + $found = true; + break; + } + } else { + if (!count_records_select("lesson_attempts", "pageid = $thispage->id AND + userid = $USER->id AND correct = 1 AND retry = $nretakes")) { + $found = true; + break; + } + } + } + } + if ($found) { + $newpageid = $thispage->id; + if ($lesson->maxpages) { + // check number of pages viewed (in the lesson) + if (count_records("lesson_attempts", "lessonid", $lesson->id, "userid", $USER->id, + "retry", $nretakes) >= $lesson->maxpages) { + $newpageid = LESSON_EOL; + } + } + } else { + $newpageid = LESSON_EOL; + } + } elseif (!$newpageid = $page->nextpageid) { + // no nextpage go to end of lesson + $newpageid = LESSON_EOL; + } + } - /// CDC-FLAG 6/21/04 /// this calculates the ongoing score - if ($lesson->ongoing) { - if (isteacher($course->id)) { - echo "
".get_string("teacherongoingwarning", "lesson")."

"; - } else { - $ntries = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id); - if (isset($USER->modattempts[$lesson->id])) { - $ntries--; - } - lesson_calculate_ongoing_score($lesson, $USER->id, $ntries); - } - } - /// CDC-FLAG /// + /// CDC-FLAG 6/21/04 /// this calculates the ongoing score + if ($lesson->ongoing) { + if (isteacher($course->id)) { + echo "
".get_string("teacherongoingwarning", "lesson")."

"; + } else { + $ntries = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id); + if (isset($USER->modattempts[$lesson->id])) { + $ntries--; + } + lesson_calculate_ongoing_score($lesson, $USER->id, $ntries); + } + } + /// CDC-FLAG /// - // display response (if there is one - there should be!) - if ($response) { - //$title = get_field("lesson_pages", "title", "id", $pageid); - //print_heading($title); - echo "
\n"; - if ($lesson->review && !$correctanswer && !$isessayquestion) { - $nretakes = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id); - $qattempts = count_records("lesson_attempts", "userid", $USER->id, "retry", $nretakes, "pageid", $pageid); - echo "

"; - if ($qattempts == 1) { - print_simple_box(get_string("firstwrong", "lesson"), "center"); - } else { - print_simple_box(get_string("secondpluswrong", "lesson"), "center"); - } - } else { - print_simple_box(format_text($response), 'center'); - } - echo "
\n"; - } - } + // display response (if there is one - there should be!) + if ($response) { + //$title = get_field("lesson_pages", "title", "id", $pageid); + //print_heading($title); + echo "
\n"; + if ($lesson->review && !$correctanswer && !$isessayquestion) { + $nretakes = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id); + $qattempts = count_records("lesson_attempts", "userid", $USER->id, "retry", $nretakes, "pageid", $pageid); + echo "

"; + if ($qattempts == 1) { + print_simple_box(get_string("firstwrong", "lesson"), "center"); + } else { + print_simple_box(get_string("secondpluswrong", "lesson"), "center"); + } + } else { + print_simple_box(format_text($response), 'center'); + } + echo "
\n"; + } + } - /// CDC-FLAG 6/18/04 /// - this is where some jump numbers are interpreted - if($outoftime) { - $newpageid = LESSON_EOL; // ran out of time for the test, so go to eol - } elseif (isset($USER->modattempts[$lesson->id])) { - // make sure if the student is reviewing, that he/she sees the same pages/page path that he/she saw the first time - if ($USER->modattempts[$lesson->id] == $pageid) { // remember, this session variable holds the pageid of the last page that the user saw - $newpageid = LESSON_EOL; - } else { - $nretakes--; // make sure we are looking at the right try. - $attempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND userid = $USER->id AND retry = $nretakes", "timeseen", "id, pageid"); - $found = false; - $temppageid = 0; - foreach($attempts as $attempt) { - if ($found && $temppageid != $attempt->pageid) { // now try to find the next page, make sure next few attempts do no belong to current page - $newpageid = $attempt->pageid; - break; - } - if ($attempt->pageid == $pageid) { - $found = true; // if found current page - $temppageid = $attempt->pageid; - } - } - } - } elseif ($newpageid != LESSON_CLUSTERJUMP && $pageid != 0 && $newpageid > 0) { // going to check to see if the page that the user is going to view next, is a cluster page. If so, dont display, go into the cluster. The $newpageid > 0 is used to filter out all of the negative code jumps. - if (!$page = get_record("lesson_pages", "id", $newpageid)) { - error("Error: could not find page"); - } - if ($page->qtype == LESSON_CLUSTER) { - $newpageid = LESSON_CLUSTERJUMP; - } elseif ($page->qtype == LESSON_ENDOFCLUSTER) { - $jump = get_field("lesson_answers", "jumpto", "pageid", $page->id, "lessonid", $lesson->id); - if ($jump == LESSON_NEXTPAGE) { - if ($page->nextpageid == 0) { - $newpageid = LESSON_EOL; - } else { - $newpageid = $page->nextpageid; - } - } else { - $newpageid = $jump; - } - } - } elseif ($newpageid == LESSON_UNSEENBRANCHPAGE) { - if (isteacher($course->id)) { - if ($page->nextpageid == 0) { - $newpageid = LESSON_EOL; - } else { - $newpageid = $page->nextpageid; - } - } else { - $newpageid = lesson_unseen_question_jump($lesson->id, $USER->id, $pageid); - } - } elseif ($newpageid == LESSON_PREVIOUSPAGE) { - $newpageid = $page->prevpageid; - } elseif ($newpageid == LESSON_RANDOMPAGE) { - $newpageid = lesson_random_question_jump($lesson->id, $pageid); - } elseif ($newpageid == LESSON_CLUSTERJUMP) { - if (isteacher($course->id)) { - if ($page->nextpageid == 0) { // if teacher, go to next page - $newpageid = LESSON_EOL; - } else { - $newpageid = $page->nextpageid; - } - } else { - $newpageid = lesson_cluster_jump($lesson->id, $USER->id, $pageid); - } - } + /// CDC-FLAG 6/18/04 /// - this is where some jump numbers are interpreted + if($outoftime) { + $newpageid = LESSON_EOL; // ran out of time for the test, so go to eol + } elseif (isset($USER->modattempts[$lesson->id])) { + // make sure if the student is reviewing, that he/she sees the same pages/page path that he/she saw the first time + if ($USER->modattempts[$lesson->id] == $pageid) { // remember, this session variable holds the pageid of the last page that the user saw + $newpageid = LESSON_EOL; + } else { + $nretakes--; // make sure we are looking at the right try. + $attempts = get_records_select("lesson_attempts", "lessonid = $lesson->id AND userid = $USER->id AND retry = $nretakes", "timeseen", "id, pageid"); + $found = false; + $temppageid = 0; + foreach($attempts as $attempt) { + if ($found && $temppageid != $attempt->pageid) { // now try to find the next page, make sure next few attempts do no belong to current page + $newpageid = $attempt->pageid; + break; + } + if ($attempt->pageid == $pageid) { + $found = true; // if found current page + $temppageid = $attempt->pageid; + } + } + } + } elseif ($newpageid != LESSON_CLUSTERJUMP && $pageid != 0 && $newpageid > 0) { // going to check to see if the page that the user is going to view next, is a cluster page. If so, dont display, go into the cluster. The $newpageid > 0 is used to filter out all of the negative code jumps. + if (!$page = get_record("lesson_pages", "id", $newpageid)) { + error("Error: could not find page"); + } + if ($page->qtype == LESSON_CLUSTER) { + $newpageid = LESSON_CLUSTERJUMP; + } elseif ($page->qtype == LESSON_ENDOFCLUSTER) { + $jump = get_field("lesson_answers", "jumpto", "pageid", $page->id, "lessonid", $lesson->id); + if ($jump == LESSON_NEXTPAGE) { + if ($page->nextpageid == 0) { + $newpageid = LESSON_EOL; + } else { + $newpageid = $page->nextpageid; + } + } else { + $newpageid = $jump; + } + } + } elseif ($newpageid == LESSON_UNSEENBRANCHPAGE) { + if (isteacher($course->id)) { + if ($page->nextpageid == 0) { + $newpageid = LESSON_EOL; + } else { + $newpageid = $page->nextpageid; + } + } else { + $newpageid = lesson_unseen_question_jump($lesson->id, $USER->id, $pageid); + } + } elseif ($newpageid == LESSON_PREVIOUSPAGE) { + $newpageid = $page->prevpageid; + } elseif ($newpageid == LESSON_RANDOMPAGE) { + $newpageid = lesson_random_question_jump($lesson->id, $pageid); + } elseif ($newpageid == LESSON_CLUSTERJUMP) { + if (isteacher($course->id)) { + if ($page->nextpageid == 0) { // if teacher, go to next page + $newpageid = LESSON_EOL; + } else { + $newpageid = $page->nextpageid; + } + } else { + $newpageid = lesson_cluster_jump($lesson->id, $USER->id, $pageid); + } + } - echo "
\n"; - echo "id\">\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "id\">\n"; + echo "\n"; + echo "\n"; - if (isset($USER->modattempts[$lesson->id])) { - echo "

". - get_string("savechangesandeol", "lesson")."

". - "

\n"; - echo "

".get_string("or", "lesson")."

". - get_string("continuetoanswer", "lesson")."

\n"; - } + if (isset($USER->modattempts[$lesson->id])) { + echo "

". + get_string("savechangesandeol", "lesson")."

". + "

\n"; + echo "

".get_string("or", "lesson")."

". + get_string("continuetoanswer", "lesson")."

\n"; + } - if ($lesson->review && !$correctanswer && !$noanswer && !$isessayquestion) { - echo "

\n"; - echo "

\n"; - } else { - echo "

\n"; - } - echo "
\n"; + if ($lesson->review && !$correctanswer && !$noanswer && !$isessayquestion) { + echo "

\n"; + echo "

\n"; + } else { + echo "

\n"; + } + echo "\n"; - if ($lesson->displayleft) { - echo "
"; - } + if ($lesson->displayleft) { + echo "
"; + } -?> \ No newline at end of file +?> diff --git a/mod/lesson/action/delete.php b/mod/lesson/action/delete.php index f977a077969..9d3d9021936 100644 --- a/mod/lesson/action/delete.php +++ b/mod/lesson/action/delete.php @@ -2,59 +2,59 @@ /******************* delete ************************************/ - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } - confirm_sesskey(); + confirm_sesskey(); - if (empty($_GET['pageid'])) { - error("Delete: pageid missing"); - } - $pageid = required_param('pageid', PARAM_INT); - if (!$thispage = get_record("lesson_pages", "id", $pageid)) { - error("Delete: page record not found"); - } + if (empty($_GET['pageid'])) { + error("Delete: pageid missing"); + } + $pageid = required_param('pageid', PARAM_INT); + if (!$thispage = get_record("lesson_pages", "id", $pageid)) { + error("Delete: page record not found"); + } - print_string("deleting", "lesson"); - // first delete all the associated records... - delete_records("lesson_attempts", "pageid", $pageid); - // ...now delete the answers... - delete_records("lesson_answers", "pageid", $pageid); - // ..and the page itself - delete_records("lesson_pages", "id", $pageid); + print_string("deleting", "lesson"); + // first delete all the associated records... + delete_records("lesson_attempts", "pageid", $pageid); + // ...now delete the answers... + delete_records("lesson_answers", "pageid", $pageid); + // ..and the page itself + delete_records("lesson_pages", "id", $pageid); - // repair the hole in the linkage - if (!$thispage->prevpageid) { - // this is the first page... - if (!$page = get_record("lesson_pages", "id", $thispage->nextpageid)) { - error("Delete: next page not found"); - } - if (!set_field("lesson_pages", "prevpageid", 0, "id", $page->id)) { - error("Delete: unable to set prevpage link"); - } - } elseif (!$thispage->nextpageid) { - // this is the last page... - if (!$page = get_record("lesson_pages", "id", $thispage->prevpageid)) { - error("Delete: prev page not found"); - } - if (!set_field("lesson_pages", "nextpageid", 0, "id", $page->id)) { - error("Delete: unable to set nextpage link"); - } - } else { - // page is in the middle... - if (!$prevpage = get_record("lesson_pages", "id", $thispage->prevpageid)) { - error("Delete: prev page not found"); - } - if (!$nextpage = get_record("lesson_pages", "id", $thispage->nextpageid)) { - error("Delete: next page not found"); - } - if (!set_field("lesson_pages", "nextpageid", $nextpage->id, "id", $prevpage->id)) { - error("Delete: unable to set next link"); - } - if (!set_field("lesson_pages", "prevpageid", $prevpage->id, "id", $nextpage->id)) { - error("Delete: unable to set prev link"); - } - } - redirect("view.php?id=$cm->id", get_string('deletedpage', 'lesson')); -?> \ No newline at end of file + // repair the hole in the linkage + if (!$thispage->prevpageid) { + // this is the first page... + if (!$page = get_record("lesson_pages", "id", $thispage->nextpageid)) { + error("Delete: next page not found"); + } + if (!set_field("lesson_pages", "prevpageid", 0, "id", $page->id)) { + error("Delete: unable to set prevpage link"); + } + } elseif (!$thispage->nextpageid) { + // this is the last page... + if (!$page = get_record("lesson_pages", "id", $thispage->prevpageid)) { + error("Delete: prev page not found"); + } + if (!set_field("lesson_pages", "nextpageid", 0, "id", $page->id)) { + error("Delete: unable to set nextpage link"); + } + } else { + // page is in the middle... + if (!$prevpage = get_record("lesson_pages", "id", $thispage->prevpageid)) { + error("Delete: prev page not found"); + } + if (!$nextpage = get_record("lesson_pages", "id", $thispage->nextpageid)) { + error("Delete: next page not found"); + } + if (!set_field("lesson_pages", "nextpageid", $nextpage->id, "id", $prevpage->id)) { + error("Delete: unable to set next link"); + } + if (!set_field("lesson_pages", "prevpageid", $prevpage->id, "id", $nextpage->id)) { + error("Delete: unable to set prev link"); + } + } + redirect("view.php?id=$cm->id", get_string('deletedpage', 'lesson')); +?> diff --git a/mod/lesson/action/editpage.php b/mod/lesson/action/editpage.php index 710a50f0200..63fa777504c 100644 --- a/mod/lesson/action/editpage.php +++ b/mod/lesson/action/editpage.php @@ -2,468 +2,468 @@ /************** edit page ************************************/ - if (!isteacher($course->id)) { - error("Only teachers can look at this page"); - } + if (!isteacher($course->id)) { + error("Only teachers can look at this page"); + } - // get the page - $pageid = required_param('pageid', PARAM_INT); - if (!$page = get_record("lesson_pages", "id", $pageid)) { - error("Edit page: page record not found"); - } + // get the page + $pageid = required_param('pageid', PARAM_INT); + if (!$page = get_record("lesson_pages", "id", $pageid)) { + error("Edit page: page record not found"); + } - if (isset($_GET['qtype'])) { - $page->qtype = required_param('qtype', PARAM_INT); - } + if (isset($_GET['qtype'])) { + $page->qtype = required_param('qtype', PARAM_INT); + } - // set of jump array - $jump = array(); - $jump[0] = get_string("thispage", "lesson"); - $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); - //// CDC-FLAG 6/18/04 ///// - $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson"); - if(lesson_display_branch_jumps($lesson->id, $page->id)) { - $jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson"); - $jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson"); - } - if ($page->qtype == LESSON_ENDOFBRANCH || $page->qtype == LESSON_BRANCHTABLE) { - $jump[LESSON_RANDOMBRANCH] = get_string("randombranch", "lesson"); - } - if(lesson_display_cluster_jump($lesson->id, $page->id) && $page->qtype != LESSON_BRANCHTABLE && $page->qtype != LESSON_ENDOFCLUSTER) { - $jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson"); - } - //// CDC-FLAG ///// - $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); - if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { - error("Edit page: first page not found"); - } - while (true) { - if ($apageid) { - if (!$apage = get_record("lesson_pages", "id", $apageid)) { - error("Edit page: apage record not found"); - } - /// CDC-FLAG /// 6/15/04 removed != LESSON_ENDOFBRANCH... - if (trim($page->title)) { // ...nor nuffin pages - $jump[$apageid] = strip_tags(format_string($apage->title,true)); - } - $apageid = $apage->nextpageid; - } else { - // last page reached - break; - } - } - // give teacher a proforma - ?> -

- - - - - -
- qtype) { - case LESSON_MULTICHOICE : - echo ''.get_string("questiontype", "lesson").": \n"; - echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."
"; - lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, - "lesson.php?id=$cm->id&action=editpage&pageid=$page->id", - "document.editpage.redisplay.value=1;document.editpage.submit();"); - echo "

".get_string("multianswer", "lesson").": \n"; - if ($page->qoption) { - echo ""; //CDC hidden label added. - } else { - echo ""; //CDC hidden label added. - } - helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); - echo "

\n"; - break; - case LESSON_SHORTANSWER : - echo ''.get_string("questiontype", "lesson").": \n"; - echo helpbutton("questiontype", get_string("questiontype", "lesson"), "lesson")."
"; - lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, - "lesson.php?id=$cm->id&action=editpage&pageid=$page->id", - "document.editpage.redisplay.value=1;document.editpage.submit();"); - echo "

".get_string("casesensitive", "lesson").": \n"; - if ($page->qoption) { - echo ""; //CDC hidden label added. - } else { - echo ""; //CDC hidden label added. - } - helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); - echo "

\n"; - break; - case LESSON_TRUEFALSE : - case LESSON_ESSAY : - case LESSON_MATCHING : - case LESSON_NUMERICAL : - echo ''.get_string("questiontype", "lesson").": \n"; - echo helpbutton("questiontype", get_string("questiontype", "lesson"), "lesson")."
"; - lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, - "lesson.php?id=$cm->id&action=editpage&pageid=$page->id", - "document.editpage.redisplay.value=1;document.editpage.submit();"); - break; - } - ?> - - - - - \n"; - $n = 0; - switch ($page->qtype) { - case LESSON_BRANCHTABLE : - echo "qtype\">\n"; - /// CDC-FLAG /// 6/16/04 - echo "\n"; - /// CDC-FLAG /// - echo "\n"; - // get the answers in a set order, the id order - if ($answers = get_records("lesson_answers", "pageid", $page->id, "id")) { - foreach ($answers as $answer) { - $flags = intval($answer->flags); // force into an integer - $nplus1 = $n + 1; - echo "id\">\n"; - switch ($page->qtype) { - case LESSON_MATCHING: - if ($n == 0) { - echo "\n"; - echo "\n"; - break; - case LESSON_TRUEFALSE: - case LESSON_MULTICHOICE: - case LESSON_SHORTANSWER: - case LESSON_NUMERICAL: - echo "\n"; - echo "\n"; - break; - case LESSON_BRANCHTABLE: - echo "\n"; - break; - } - switch ($page->qtype) { - case LESSON_MATCHING : - if ($n == 2) { - echo "\n"; - break; - case LESSON_ESSAY : - echo "\n"; - break; - case LESSON_TRUEFALSE: - case LESSON_MULTICHOICE: - case LESSON_SHORTANSWER: - case LESSON_NUMERICAL: - echo "\n"; - break; - case LESSON_BRANCHTABLE: - case LESSON_CLUSTER: - case LESSON_ENDOFCLUSTER: - case LESSON_ENDOFBRANCH: - echo "\n"; - break; - } - $n++; - if ($page->qtype == LESSON_ESSAY) { - 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_MATCHING) { - $maxanswers = $lesson->maxanswers + 2; - } else { - $maxanswers = $lesson->maxanswers; - } - for ($i = $n; $i < $maxanswers; $i++) { - if ($page->qtype == LESSON_TRUEFALSE && $i > 1) { - break; // stop printing answers... only need two for true/false - } - $iplus1 = $i + 1; - echo "\n"; - switch ($page->qtype) { - case LESSON_MATCHING: - $icorrected = $i - 1; - echo "\n"; - echo "\n"; - break; - case LESSON_TRUEFALSE: - case LESSON_MULTICHOICE: - case LESSON_SHORTANSWER: - case LESSON_NUMERICAL: - echo "\n"; - echo "\n"; - break; - case LESSON_BRANCHTABLE: - echo "\n"; - break; - } - switch ($page->qtype) { - case LESSON_ESSAY : - if ($i < 1) { - echo "\n"; - } - break; - case LESSON_MATCHING : - if ($i == 2) { - echo "\n"; + break; + case LESSON_TRUEFALSE: + case LESSON_MULTICHOICE: + case LESSON_SHORTANSWER: + case LESSON_NUMERICAL: + echo "\n"; + break; + case LESSON_BRANCHTABLE : + echo "\n"; + break; + } + } + } + // close table and form + ?> +
:
-
"; - echo get_string("pagecontents", "lesson").":
\n"; - print_textarea($usehtmleditor, 25, 70, 630, 400, "contents", $page->contents); - use_html_editor("contents"); // always the editor - echo "
\n"; - echo "
"; - if ($page->layout) { - echo ""; - } else { - echo ""; - } - echo get_string("arrangebuttonshorizontally", "lesson")."
\n"; - echo "
"; - if ($page->display) { - echo "
"; - } else { - echo "
"; - } - echo get_string("displayinleftmenu", "lesson")."
\n"; - echo "
".get_string("branchtable", "lesson")." \n"; - break; - case LESSON_CLUSTER : - echo "qtype\">\n"; - echo "
".get_string("clustertitle", "lesson")." \n"; - break; - case LESSON_ENDOFCLUSTER : - echo "qtype\">\n"; - echo "
".get_string("endofclustertitle", "lesson")." \n"; - break; - case LESSON_ENDOFBRANCH : - echo "qtype\">\n"; - echo "
".get_string("endofbranch", "lesson")." \n"; - break; - } - echo "
".get_string("correctresponse", "lesson").":\n"; - if ($flags & LESSON_ANSWER_EDITOR) { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label added. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); - use_html_editor("answer[$n]"); // switch on the editor - } else { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); - } - } elseif ($n == 1) { - echo "
".get_string("wrongresponse", "lesson").":\n"; - if ($flags & LESSON_ANSWER_EDITOR) { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label added. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); - use_html_editor("answer[$n]"); // switch on the editor - } else { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); - } - } else { - $ncorrected = $n - 1; - echo "
".get_string("answer", "lesson")." $ncorrected:\n"; - if ($flags & LESSON_ANSWER_EDITOR) { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label added. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); - use_html_editor("answer[$n]"); // switch on the editor - } else { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); - } - echo "
".get_string("matchesanswer", "lesson")." $ncorrected:\n"; - if ($flags & LESSON_RESPONSE_EDITOR) { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label added. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response); - use_html_editor("response[$n]"); // switch on the editor - } else { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label added. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 6, 70, 630, 300, "response[$n]", $answer->response); - } - } - echo "
".get_string("answer", "lesson")." $nplus1:\n"; - if ($flags & LESSON_ANSWER_EDITOR) { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label added. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); - use_html_editor("answer[$n]"); // switch on the editor - } else { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); - } - echo "
".get_string("response", "lesson")." $nplus1:\n"; - if ($flags & LESSON_RESPONSE_EDITOR) { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label added. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response); - use_html_editor("response[$n]"); // switch on the editor - } else { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label added. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 6, 70, 630, 300, "response[$n]", $answer->response); - } - echo "
".get_string("description", "lesson")." $nplus1:\n"; - if ($flags & LESSON_ANSWER_EDITOR) { - echo " [".get_string("useeditor", "lesson").": ". - ""; //CDC hidden label added. - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - 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 - } else { - echo " [".get_string("useeditor", "lesson").": ". - ""; - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 10, 70, 630, 300, "answer[$n]", $answer->answer); - } - echo "
".get_string("correctanswerjump", "lesson").": \n"; - lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if($lesson->custom) - echo get_string("correctanswerscore", "lesson").": score\" size=\"5\">"; - } - if ($n == 3) { - echo "
".get_string("wronganswerjump", "lesson").": \n"; - lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if($lesson->custom) - echo get_string("wronganswerscore", "lesson").": score\" size=\"5\">"; - } - echo "
".get_string("jump", "lesson").": \n"; - lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if($lesson->custom) { - echo get_string("score", "lesson").": score\" size=\"5\">"; - } - echo "
".get_string("jump", "lesson")." $nplus1: \n"; - lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if($lesson->custom) { - echo get_string("score", "lesson")." $nplus1: score\" size=\"5\">"; - } - echo "
".get_string("jump", "lesson")." $nplus1: \n"; - lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - echo "
".get_string("answer", "lesson")." $icorrected:\n"; - echo " [".get_string("useeditor", "lesson").": ". - ""; - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 10, 70, 630, 300, "answer[$i]"); - echo "
".get_string("matchesanswer", "lesson")." $icorrected:\n"; - echo " [".get_string("useeditor", "lesson").": ". - ""; - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 10, 70, 630, 300, "response[$i]"); - echo "
".get_string("answer", "lesson")." $iplus1:\n"; - echo " [".get_string("useeditor", "lesson").": ". - ""; - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 10, 70, 630, 300, "answer[$i]"); - echo "
".get_string("response", "lesson")." $iplus1:\n"; - echo " [".get_string("useeditor", "lesson").": ". - ""; - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 10, 70, 630, 300, "response[$i]"); - echo "
".get_string("description", "lesson")." $iplus1:\n"; - echo " [".get_string("useeditor", "lesson").": ". - ""; - helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); - echo "]
\n"; - print_textarea(false, 10, 70, 630, 300, "answer[$i]"); - echo "
".get_string("jump", "lesson").": \n"; - lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if($lesson->custom) { - echo get_string("score", "lesson").": "; - } - echo "
".get_string("correctanswerjump", "lesson").": \n"; - lesson_choose_from_menu($jump, "jumpto[$i]", $answer->jumpto, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if($lesson->custom) - echo get_string("correctanswerscore", "lesson").": score\" size=\"5\">"; - } - if ($i == 3) { - echo "
".get_string("wronganswerjump", "lesson").": \n"; - lesson_choose_from_menu($jump, "jumpto[$i]", $answer->jumpto, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if($lesson->custom) - echo get_string("wronganswerscore", "lesson").": score\" size=\"5\">"; - } + // set of jump array + $jump = array(); + $jump[0] = get_string("thispage", "lesson"); + $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); + //// CDC-FLAG 6/18/04 ///// + $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson"); + if(lesson_display_branch_jumps($lesson->id, $page->id)) { + $jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson"); + $jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson"); + } + if ($page->qtype == LESSON_ENDOFBRANCH || $page->qtype == LESSON_BRANCHTABLE) { + $jump[LESSON_RANDOMBRANCH] = get_string("randombranch", "lesson"); + } + if(lesson_display_cluster_jump($lesson->id, $page->id) && $page->qtype != LESSON_BRANCHTABLE && $page->qtype != LESSON_ENDOFCLUSTER) { + $jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson"); + } + //// CDC-FLAG ///// + $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); + if (!$apageid = get_field("lesson_pages", "id", "lessonid", $lesson->id, "prevpageid", 0)) { + error("Edit page: first page not found"); + } + while (true) { + if ($apageid) { + if (!$apage = get_record("lesson_pages", "id", $apageid)) { + error("Edit page: apage record not found"); + } + /// CDC-FLAG /// 6/15/04 removed != LESSON_ENDOFBRANCH... + if (trim($page->title)) { // ...nor nuffin pages + $jump[$apageid] = strip_tags(format_string($apage->title,true)); + } + $apageid = $apage->nextpageid; + } else { + // last page reached + break; + } + } + // give teacher a proforma + ?> + + + + + + +
+ qtype) { + case LESSON_MULTICHOICE : + echo ''.get_string("questiontype", "lesson").": \n"; + echo helpbutton("questiontypes", get_string("questiontype", "lesson"), "lesson")."
"; + lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, + "lesson.php?id=$cm->id&action=editpage&pageid=$page->id", + "document.editpage.redisplay.value=1;document.editpage.submit();"); + echo "

".get_string("multianswer", "lesson").": \n"; + if ($page->qoption) { + echo ""; //CDC hidden label added. + } else { + echo ""; //CDC hidden label added. + } + helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); + echo "

\n"; + break; + case LESSON_SHORTANSWER : + echo ''.get_string("questiontype", "lesson").": \n"; + echo helpbutton("questiontype", get_string("questiontype", "lesson"), "lesson")."
"; + lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, + "lesson.php?id=$cm->id&action=editpage&pageid=$page->id", + "document.editpage.redisplay.value=1;document.editpage.submit();"); + echo "

".get_string("casesensitive", "lesson").": \n"; + if ($page->qoption) { + echo ""; //CDC hidden label added. + } else { + echo ""; //CDC hidden label added. + } + helpbutton("questionoption", get_string("questionoption", "lesson"), "lesson"); + echo "

\n"; + break; + case LESSON_TRUEFALSE : + case LESSON_ESSAY : + case LESSON_MATCHING : + case LESSON_NUMERICAL : + echo ''.get_string("questiontype", "lesson").": \n"; + echo helpbutton("questiontype", get_string("questiontype", "lesson"), "lesson")."
"; + lesson_qtype_menu($LESSON_QUESTION_TYPE, $page->qtype, + "lesson.php?id=$cm->id&action=editpage&pageid=$page->id", + "document.editpage.redisplay.value=1;document.editpage.submit();"); + break; + } + ?> + + + + + \n"; + $n = 0; + switch ($page->qtype) { + case LESSON_BRANCHTABLE : + echo "qtype\">\n"; + /// CDC-FLAG /// 6/16/04 + echo "\n"; + /// CDC-FLAG /// + echo "\n"; + // get the answers in a set order, the id order + if ($answers = get_records("lesson_answers", "pageid", $page->id, "id")) { + foreach ($answers as $answer) { + $flags = intval($answer->flags); // force into an integer + $nplus1 = $n + 1; + echo "id\">\n"; + switch ($page->qtype) { + case LESSON_MATCHING: + if ($n == 0) { + echo "\n"; + echo "\n"; + break; + case LESSON_TRUEFALSE: + case LESSON_MULTICHOICE: + case LESSON_SHORTANSWER: + case LESSON_NUMERICAL: + echo "\n"; + echo "\n"; + break; + case LESSON_BRANCHTABLE: + echo "\n"; + break; + } + switch ($page->qtype) { + case LESSON_MATCHING : + if ($n == 2) { + echo "\n"; + break; + case LESSON_ESSAY : + echo "\n"; + break; + case LESSON_TRUEFALSE: + case LESSON_MULTICHOICE: + case LESSON_SHORTANSWER: + case LESSON_NUMERICAL: + echo "\n"; + break; + case LESSON_BRANCHTABLE: + case LESSON_CLUSTER: + case LESSON_ENDOFCLUSTER: + case LESSON_ENDOFBRANCH: + echo "\n"; + break; + } + $n++; + if ($page->qtype == LESSON_ESSAY) { + 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_MATCHING) { + $maxanswers = $lesson->maxanswers + 2; + } else { + $maxanswers = $lesson->maxanswers; + } + for ($i = $n; $i < $maxanswers; $i++) { + if ($page->qtype == LESSON_TRUEFALSE && $i > 1) { + break; // stop printing answers... only need two for true/false + } + $iplus1 = $i + 1; + echo "\n"; + switch ($page->qtype) { + case LESSON_MATCHING: + $icorrected = $i - 1; + echo "\n"; + echo "\n"; + break; + case LESSON_TRUEFALSE: + case LESSON_MULTICHOICE: + case LESSON_SHORTANSWER: + case LESSON_NUMERICAL: + echo "\n"; + echo "\n"; + break; + case LESSON_BRANCHTABLE: + echo "\n"; + break; + } + switch ($page->qtype) { + case LESSON_ESSAY : + if ($i < 1) { + echo "\n"; + } + break; + case LESSON_MATCHING : + if ($i == 2) { + echo "\n"; - break; - case LESSON_TRUEFALSE: - case LESSON_MULTICHOICE: - case LESSON_SHORTANSWER: - case LESSON_NUMERICAL: - echo "\n"; - break; - case LESSON_BRANCHTABLE : - echo "\n"; - break; - } - } - } - // close table and form - ?> -
:
+
"; + echo get_string("pagecontents", "lesson").":
\n"; + print_textarea($usehtmleditor, 25, 70, 630, 400, "contents", $page->contents); + use_html_editor("contents"); // always the editor + echo "
\n"; + echo "
"; + if ($page->layout) { + echo ""; + } else { + echo ""; + } + echo get_string("arrangebuttonshorizontally", "lesson")."
\n"; + echo "
"; + if ($page->display) { + echo "
"; + } else { + echo "
"; + } + echo get_string("displayinleftmenu", "lesson")."
\n"; + echo "
".get_string("branchtable", "lesson")." \n"; + break; + case LESSON_CLUSTER : + echo "qtype\">\n"; + echo "
".get_string("clustertitle", "lesson")." \n"; + break; + case LESSON_ENDOFCLUSTER : + echo "qtype\">\n"; + echo "
".get_string("endofclustertitle", "lesson")." \n"; + break; + case LESSON_ENDOFBRANCH : + echo "qtype\">\n"; + echo "
".get_string("endofbranch", "lesson")." \n"; + break; + } + echo "
".get_string("correctresponse", "lesson").":\n"; + if ($flags & LESSON_ANSWER_EDITOR) { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label added. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); + use_html_editor("answer[$n]"); // switch on the editor + } else { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); + } + } elseif ($n == 1) { + echo "
".get_string("wrongresponse", "lesson").":\n"; + if ($flags & LESSON_ANSWER_EDITOR) { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label added. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); + use_html_editor("answer[$n]"); // switch on the editor + } else { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); + } + } else { + $ncorrected = $n - 1; + echo "
".get_string("answer", "lesson")." $ncorrected:\n"; + if ($flags & LESSON_ANSWER_EDITOR) { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label added. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); + use_html_editor("answer[$n]"); // switch on the editor + } else { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); + } + echo "
".get_string("matchesanswer", "lesson")." $ncorrected:\n"; + if ($flags & LESSON_RESPONSE_EDITOR) { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label added. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response); + use_html_editor("response[$n]"); // switch on the editor + } else { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label added. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 6, 70, 630, 300, "response[$n]", $answer->response); + } + } + echo "
".get_string("answer", "lesson")." $nplus1:\n"; + if ($flags & LESSON_ANSWER_EDITOR) { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label added. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea($usehtmleditor, 20, 70, 630, 300, "answer[$n]", $answer->answer); + use_html_editor("answer[$n]"); // switch on the editor + } else { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 6, 70, 630, 300, "answer[$n]", $answer->answer); + } + echo "
".get_string("response", "lesson")." $nplus1:\n"; + if ($flags & LESSON_RESPONSE_EDITOR) { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label added. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea($usehtmleditor, 20, 70, 630, 300, "response[$n]", $answer->response); + use_html_editor("response[$n]"); // switch on the editor + } else { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label added. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 6, 70, 630, 300, "response[$n]", $answer->response); + } + echo "
".get_string("description", "lesson")." $nplus1:\n"; + if ($flags & LESSON_ANSWER_EDITOR) { + echo " [".get_string("useeditor", "lesson").": ". + ""; //CDC hidden label added. + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + 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 + } else { + echo " [".get_string("useeditor", "lesson").": ". + ""; + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 10, 70, 630, 300, "answer[$n]", $answer->answer); + } + echo "
".get_string("correctanswerjump", "lesson").": \n"; + lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if($lesson->custom) + echo get_string("correctanswerscore", "lesson").": score\" size=\"5\">"; + } + if ($n == 3) { + echo "
".get_string("wronganswerjump", "lesson").": \n"; + lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if($lesson->custom) + echo get_string("wronganswerscore", "lesson").": score\" size=\"5\">"; + } + echo "
".get_string("jump", "lesson").": \n"; + lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if($lesson->custom) { + echo get_string("score", "lesson").": score\" size=\"5\">"; + } + echo "
".get_string("jump", "lesson")." $nplus1: \n"; + lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if($lesson->custom) { + echo get_string("score", "lesson")." $nplus1: score\" size=\"5\">"; + } + echo "
".get_string("jump", "lesson")." $nplus1: \n"; + lesson_choose_from_menu($jump, "jumpto[$n]", $answer->jumpto, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + echo "
".get_string("answer", "lesson")." $icorrected:\n"; + echo " [".get_string("useeditor", "lesson").": ". + ""; + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 10, 70, 630, 300, "answer[$i]"); + echo "
".get_string("matchesanswer", "lesson")." $icorrected:\n"; + echo " [".get_string("useeditor", "lesson").": ". + ""; + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 10, 70, 630, 300, "response[$i]"); + echo "
".get_string("answer", "lesson")." $iplus1:\n"; + echo " [".get_string("useeditor", "lesson").": ". + ""; + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 10, 70, 630, 300, "answer[$i]"); + echo "
".get_string("response", "lesson")." $iplus1:\n"; + echo " [".get_string("useeditor", "lesson").": ". + ""; + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 10, 70, 630, 300, "response[$i]"); + echo "
".get_string("description", "lesson")." $iplus1:\n"; + echo " [".get_string("useeditor", "lesson").": ". + ""; + helpbutton("useeditor", get_string("useeditor", "lesson"), "lesson"); + echo "]
\n"; + print_textarea(false, 10, 70, 630, 300, "answer[$i]"); + echo "
".get_string("jump", "lesson").": \n"; + lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if($lesson->custom) { + echo get_string("score", "lesson").": "; + } + echo "
".get_string("correctanswerjump", "lesson").": \n"; + lesson_choose_from_menu($jump, "jumpto[$i]", $answer->jumpto, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if($lesson->custom) + echo get_string("correctanswerscore", "lesson").": score\" size=\"5\">"; + } + if ($i == 3) { + echo "
".get_string("wronganswerjump", "lesson").": \n"; + lesson_choose_from_menu($jump, "jumpto[$i]", $answer->jumpto, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if($lesson->custom) + echo get_string("wronganswerscore", "lesson").": score\" size=\"5\">"; + } - echo "
".get_string("jump", "lesson")." $iplus1: \n"; - lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - if($lesson->custom) { - echo get_string("score", "lesson")." $iplus1: "; - } - echo "
".get_string("jump", "lesson")." $iplus1: \n"; - lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); - helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); - echo "

- " - onClick="document.editpage.redisplay.value=1;document.editpage.submit();" /> - " /> - " /> -
- + echo "
".get_string("jump", "lesson")." $iplus1: \n"; + lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + if($lesson->custom) { + echo get_string("score", "lesson")." $iplus1: "; + } + echo "
".get_string("jump", "lesson")." $iplus1: \n"; + lesson_choose_from_menu($jump, "jumpto[$i]", 0, ""); + helpbutton("jumpto", get_string("jump", "lesson"), "lesson"); + echo "

+ " + onClick="document.editpage.redisplay.value=1;document.editpage.submit();" /> + " /> + " /> +
+ diff --git a/mod/lesson/action/insertpage.php b/mod/lesson/action/insertpage.php index 6b47f34eeaa..14baa017d8b 100644 --- a/mod/lesson/action/insertpage.php +++ b/mod/lesson/action/insertpage.php @@ -42,8 +42,8 @@ /// CDC-FLAG /// $newpage->title = clean_param($form->title, PARAM_CLEANHTML); $newpage->contents = clean_param(trim($form->contents), PARAM_CLEANHTML); - $newpage->title = addslashes($newpage->title); - $newpage->contents = addslashes($newpage->contents); + $newpage->title = addslashes($newpage->title); + $newpage->contents = addslashes($newpage->contents); $newpageid = insert_record("lesson_pages", $newpage); if (!$newpageid) { error("Insert page: new page not inserted"); @@ -88,7 +88,7 @@ $newpage->title = clean_param($form->title, PARAM_CLEANHTML); $newpage->contents = clean_param(trim($form->contents), PARAM_CLEANHTML); $newpage->title = addslashes($newpage->title); - $newpage->contents = addslashes($newpage->contents); + $newpage->contents = addslashes($newpage->contents); $newpageid = insert_record("lesson_pages", $newpage); if (!$newpageid) { error("Insert page: new first page not inserted"); @@ -120,7 +120,7 @@ $newpage->title = clean_param($form->title, PARAM_CLEANHTML); $newpage->contents = clean_param(trim($form->contents), PARAM_CLEANHTML); $newpage->title = addslashes($newpage->title); - $newpage->contents = addslashes($newpage->contents); + $newpage->contents = addslashes($newpage->contents); $newpageid = insert_record("lesson_pages", $newpage); if (!$newpageid) { error("Insert page: first page not inserted"); @@ -158,10 +158,10 @@ $newanswer->pageid = $newpageid; $newanswer->timecreated = $timenow; $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])) { $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])) { $newanswer->jumpto = clean_param($form->jumpto[$i], PARAM_INT); diff --git a/mod/lesson/action/updatepage.php b/mod/lesson/action/updatepage.php index 2bd671e08c9..f2127884b89 100644 --- a/mod/lesson/action/updatepage.php +++ b/mod/lesson/action/updatepage.php @@ -34,8 +34,8 @@ /// CDC-FLAG /// $page->title = clean_param($form->title, PARAM_CLEANHTML); $page->contents = clean_param(trim($form->contents), PARAM_CLEANHTML); - $page->title = addslashes($page->title); - $page->contents = addslashes($page->contents); + $page->title = addslashes($page->title); + $page->contents = addslashes($page->contents); if (!update_record("lesson_pages", $page)) { error("Update page: page not updated"); } @@ -80,10 +80,10 @@ clean_param($form->responseeditor[$i], PARAM_INT) * LESSON_RESPONSE_EDITOR; $oldanswer->timemodified = $timenow; $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])) { $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); /// CDC-FLAG /// @@ -103,10 +103,10 @@ clean_param($form->responseeditor[$i], PARAM_INT) * LESSON_RESPONSE_EDITOR; $newanswer->timecreated = $timenow; $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])) { $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); /// CDC-FLAG /// diff --git a/mod/lesson/lesson.php b/mod/lesson/lesson.php index d64d6c3d53c..8b0a228c446 100644 --- a/mod/lesson/lesson.php +++ b/mod/lesson/lesson.php @@ -57,13 +57,13 @@ "$navigation id>$strlessons -> id\">".format_string($lesson->name,true)."", "", "", true); - // include the appropriate action (check to make sure the file is there first) - if (file_exists($CFG->dirroot.'/mod/lesson/action/'.$action.'.php')) { - include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php'); - } else { - error("Fatal Error: Unknown action\n"); - } - + // include the appropriate action (check to make sure the file is there first) + if (file_exists($CFG->dirroot.'/mod/lesson/action/'.$action.'.php')) { + include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php'); + } else { + error("Fatal Error: Unknown action\n"); + } + print_footer($course); ?> diff --git a/mod/lesson/lib.php b/mod/lesson/lib.php index 6834287dbbb..614719df5be 100644 --- a/mod/lesson/lib.php +++ b/mod/lesson/lib.php @@ -35,10 +35,10 @@ function lesson_add_instance($lesson) { unset($lesson->password); } /// CDC-FLAG /// - if (!$lesson->id = insert_record("lesson", $lesson)) { - return false; // bad - } - + if (!$lesson->id = insert_record("lesson", $lesson)) { + return false; // bad + } + if ($lesson->lessondefault) { $lessondefault = $lesson; unset($lessondefault->lessondefault); @@ -130,8 +130,8 @@ function lesson_update_instance($lesson) { unset($lesson->lessondefault); } - // update the calendar events (credit goes to quiz module) - if ($events = get_records_select('event', "modulename = 'lesson' and instance = '$lesson->id'")) { + // update the calendar events (credit goes to quiz module) + if ($events = get_records_select('event', "modulename = 'lesson' and instance = '$lesson->id'")) { foreach($events as $event) { delete_event($event->id); } @@ -249,13 +249,13 @@ function lesson_delete_instance($id) { if (! delete_records("lesson_high_scores", "lessonid", "$lesson->id")) { $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) { delete_event($event->id); } - } + } - return $result; + return $result; } /*******************************************************************/ diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index 494f1d9b7c5..a51507a25b5 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -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 - if ($nviewed != 0) { - $thegrade = intval(100 * $ncorrect / $nviewed); - } else { - $thegrade = 0; - } - + if ($nviewed != 0) { + $thegrade = intval(100 * $ncorrect / $nviewed); + } else { + $thegrade = 0; + } if ($return) { return $thegrade; @@ -1113,15 +1112,15 @@ function lesson_calculate_ongoing_score($lesson, $userid, $retries, $return=fals /*******************************************************************/ function lesson_qtype_menu($qtypes, $selected="", $link="", $onclick="") { // prints the question types for when editing and adding a page - $tabs = array(); - $tabrows = array(); - + $tabs = array(); + $tabrows = array(); + foreach ($qtypes as $qtype => $qtypename) { - $tabrows[] = new tabobject($qtype, "$link&qtype=$qtype\" onClick=\"$onclick\"", $qtypename); + $tabrows[] = new tabobject($qtype, "$link&qtype=$qtype\" onClick=\"$onclick\"", $qtypename); } - $tabs[] = $tabrows; - print_tabs($tabs, $selected); - echo " \n"; + $tabs[] = $tabrows; + print_tabs($tabs, $selected); + echo " \n"; } diff --git a/mod/lesson/report.php b/mod/lesson/report.php index 1267857d8af..530a2ed4a61 100644 --- a/mod/lesson/report.php +++ b/mod/lesson/report.php @@ -163,8 +163,8 @@ $tries = $studentdata[$student->id]; $studentname = "{$student->lastname}, $student->firstname"; foreach ($tries as $try) { - // start to build up the link - $temp = "id&action=detail&userid=".$try["userid"]."&try=".$try["try"]."\">"; + // start to build up the link + $temp = "id&action=detail&userid=".$try["userid"]."&try=".$try["try"]."\">"; if ($try["grade"] != NULL) { // if NULL then not done yet // this is what the link does when the user has completed the try $timetotake = $try["timeend"] - $try["timestart"]; @@ -210,7 +210,7 @@ $table->data[] = array($studentname, $attempts, $bestgrade."%"); } } - // print it all out ! + // print it all out ! print_table($table); // some stat calculations @@ -783,7 +783,7 @@ } $answerpages[] = $answerpage; } - $pageid = $page->nextpageid; + $pageid = $page->nextpageid; } /// actually start printing something @@ -798,18 +798,18 @@ $table->align = array("right", "left"); $table->size = array("*", "*"); - if (!$grades = get_records_select("lesson_grades", "lessonid = $lesson->id and userid = $userid", "completed", "*", $try, 1)) { - $grade = -1; - } else { - $grade = current($grades); - $grade = $grade->grade; - } - if (!$times = get_records_select("lesson_timer", "lessonid = $lesson->id and userid = $userid", "starttime", "*", $try, 1)) { - $timetotake = -1; - } else { - $timetotake = current($times); - $timetotake = $timetotake->lessontime - $timetotake->starttime; - } + if (!$grades = get_records_select("lesson_grades", "lessonid = $lesson->id and userid = $userid", "completed", "*", $try, 1)) { + $grade = -1; + } else { + $grade = current($grades); + $grade = $grade->grade; + } + if (!$times = get_records_select("lesson_timer", "lessonid = $lesson->id and userid = $userid", "starttime", "*", $try, 1)) { + $timetotake = -1; + } else { + $timetotake = current($times); + $timetotake = $timetotake->lessontime - $timetotake->starttime; + } if ($timetotake == -1 || $completed == -1 || $grade == -1) { $table->align = array("center"); diff --git a/mod/lesson/timer.js b/mod/lesson/timer.js index 454ced24b5b..1cbff841cea 100644 --- a/mod/lesson/timer.js +++ b/mod/lesson/timer.js @@ -26,7 +26,7 @@ var my12_hour = 1; var stopclock = 0; var myclock = ''; - var timeleft, hours, minutes, secs; + var timeleft, hours, minutes, secs; var javatimeDate = new Date(); var javatime = javatimeDate.getTime(); javatime = Math.floor(javatime/1000); @@ -35,15 +35,15 @@ starttime = starttime + difference; var dn = ""; - var old = ""; + var old = ""; if (document.all||document.getElementById) { - document.write(''); - } else if (document.layers) { - document.write(''); - } else { - old = "true"; show_clock(); - } + document.write(''); + } else if (document.layers) { + document.write(''); + } else { + old = "true"; show_clock(); + } /*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'); @@ -69,10 +69,10 @@ stopclock = 1; } else { timeleft = starttime + testlength - current; - hours = Math.floor(timeleft/3600); - timeleft = timeleft - (hours * 3600); - minutes = Math.floor(timeleft/60); - secs = timeleft - (minutes * 60); + hours = Math.floor(timeleft/3600); + timeleft = timeleft - (hours * 3600); + minutes = Math.floor(timeleft/60); + secs = timeleft - (minutes * 60); if (secs < 10) { secs = "0"+secs; diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 520ac52e6dc..db015ee4856 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -182,31 +182,30 @@ } break; // only look at the latest correct attempt } - } else { - $attempts = NULL; - } + } else { + $attempts = NULL; + } - if ($branchtables = get_records_select('lesson_branch', - "lessonid = $lesson->id AND userid = $USER->id AND retry = $retries", 'timeseen DESC')) { - // in here, user has viewed a branch table - $lastbranchtable = current($branchtables); - if ($attempts != NULL) { - foreach($attempts as $attempt) { - if ($lastbranchtable->timeseen > $attempt->timeseen) { - // branch table was viewed later than the last attempt - $lastpageseen = $lastbranchtable->pageid; - } - break; - } - } else { - // hasnt answered any questions but has viewed a branch table - $lastpageseen = $lastbranchtable->pageid; - } - - } + if ($branchtables = get_records_select('lesson_branch', + "lessonid = $lesson->id AND userid = $USER->id AND retry = $retries", 'timeseen DESC')) { + // in here, user has viewed a branch table + $lastbranchtable = current($branchtables); + if ($attempts != NULL) { + foreach($attempts as $attempt) { + if ($lastbranchtable->timeseen > $attempt->timeseen) { + // branch table was viewed later than the last attempt + $lastpageseen = $lastbranchtable->pageid; + } + break; + } + } else { + // hasnt answered any questions but has viewed a branch table + $lastpageseen = $lastbranchtable->pageid; + } + } //if ($lastpageseen != $firstpageid) { 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, 'prevpageid', 0)) { error('Navigation: first page not found'); @@ -223,7 +222,7 @@ echo '

\n"; /// CDC-FLAG added document.queryform.startlastseen.value='yes' echo '' . "\n"; - echo '';///CDC Chris Berri added close div tag + echo '';///CDC Chris Berri added close div tag } else { print_simple_box_start('center'); echo '
'; @@ -247,7 +246,7 @@ echo "\n"; echo "
";///CDC Chris Berri added close div tag } print_footer($course); - exit(); + exit(); } if ($grades) { @@ -1065,7 +1064,7 @@ // after all the grade processing, check to see if "Show Grades" is off for the course // if yes, redirect to the course page 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 @@ -1133,54 +1132,54 @@ elseif ($action == 'teacherview') { /// 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. - $usercount = array(); - foreach ($userattempts as $userattempts) { - $usercount[$userattempts->userid] = 0; - } - $a = new stdClass; - $a->users = count($usercount); - $a->usersname = $course->students; - echo "
id\">".get_string("viewlessonstats", "lesson", $a)."
"; - } + $usercount = array(); + foreach ($userattempts as $userattempts) { + $usercount[$userattempts->userid] = 0; + } + $a = new stdClass; + $a->users = count($usercount); + $a->usersname = $course->students; + echo "
id\">".get_string("viewlessonstats", "lesson", $a)."
"; + } 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 - $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)")) { - $studentessays = array(); - // makes an array that organizes essayattempts by grouping userid, then pageid, then try count - foreach ($essayattempts as $essayattempt) { - $studentessays[$essayattempt->userid][$essayattempt->pageid][$essayattempt->retry][] = $essayattempt; - } - $a = new stdClass; - $a->notgradedcount = 0; - $a->notsentcount = 0; - foreach ($studentessays as $pages) { // students - foreach ($pages as $tries) { // pages - // go through each essay per page - foreach($tries as $try) { // actual attempts - // make sure they didn't answer it more than the max number of attmepts - if (count($try) > $lesson->maxattempts) { - $essay = $try[$lesson->maxattempts-1]; - } else { - $essay = end($try); - } - $essayinfo = unserialize($essay->useranswer); - if ($essayinfo->graded == 0) { - $a->notgradedcount++; - } - if ($essayinfo->sent == 0) { - $a->notsentcount++; - } - } - } - } - echo "
id&action=essayview\">".get_string("gradeessay", "lesson", $a)."

"; - } - } + // get only the attempts that are in response to essay questions + $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)")) { + $studentessays = array(); + // makes an array that organizes essayattempts by grouping userid, then pageid, then try count + foreach ($essayattempts as $essayattempt) { + $studentessays[$essayattempt->userid][$essayattempt->pageid][$essayattempt->retry][] = $essayattempt; + } + $a = new stdClass; + $a->notgradedcount = 0; + $a->notsentcount = 0; + foreach ($studentessays as $pages) { // students + foreach ($pages as $tries) { // pages + // go through each essay per page + foreach($tries as $try) { // actual attempts + // make sure they didn't answer it more than the max number of attmepts + if (count($try) > $lesson->maxattempts) { + $essay = $try[$lesson->maxattempts-1]; + } else { + $essay = end($try); + } + $essayinfo = unserialize($essay->useranswer); + if ($essayinfo->graded == 0) { + $a->notgradedcount++; + } + if ($essayinfo->sent == 0) { + $a->notsentcount++; + } + } + } + } + echo "
id&action=essayview\">".get_string("gradeessay", "lesson", $a)."

"; + } + } 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")) { $npages = 1; while (true) {