From: mark-nielsen Date: Sun, 10 Sep 2006 02:09:14 +0000 (+0000) Subject: Moved teacherview (lesson editing) out of view.php into edit.php X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=15f3d44ae72f6d45d34d2c7df95ef61ac2f5959e;p=moodle.git Moved teacherview (lesson editing) out of view.php into edit.php No code improvements in edit.php as of now. Just works ;) --- diff --git a/mod/lesson/action/addcluster.php b/mod/lesson/action/addcluster.php index 2c4384025a..ae547b4826 100644 --- a/mod/lesson/action/addcluster.php +++ b/mod/lesson/action/addcluster.php @@ -59,5 +59,5 @@ if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { error("Add cluster: answer record not inserted"); } - redirect("view.php?id=$cm->id", get_string('addedcluster', 'lesson')); + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('addedcluster', 'lesson')); ?> \ No newline at end of file diff --git a/mod/lesson/action/addendofbranch.php b/mod/lesson/action/addendofbranch.php index 330413fc34..bf72e4a654 100644 --- a/mod/lesson/action/addendofbranch.php +++ b/mod/lesson/action/addendofbranch.php @@ -55,7 +55,7 @@ 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')); + redirect("$CFG->wwwroot/mod/lesson/edit.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/addendofcluster.php b/mod/lesson/action/addendofcluster.php index 20b3bf00c5..dd379c3420 100644 --- a/mod/lesson/action/addendofcluster.php +++ b/mod/lesson/action/addendofcluster.php @@ -46,4 +46,4 @@ if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { error("Add end of cluster: answer record not inserted"); } - redirect("view.php?id=$cm->id", get_string('addedendofcluster', 'lesson')); \ No newline at end of file + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('addedendofcluster', 'lesson')); \ No newline at end of file diff --git a/mod/lesson/action/delete.php b/mod/lesson/action/delete.php index 2e29da39ce..18cd78f13a 100644 --- a/mod/lesson/action/delete.php +++ b/mod/lesson/action/delete.php @@ -47,5 +47,5 @@ error("Delete: unable to set prev link"); } } - redirect("view.php?id=$cm->id", get_string('deletedpage', 'lesson')); + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('deletedpage', 'lesson')); ?> diff --git a/mod/lesson/action/insertpage.php b/mod/lesson/action/insertpage.php index af9e2464bb..0fb374e6fc 100644 --- a/mod/lesson/action/insertpage.php +++ b/mod/lesson/action/insertpage.php @@ -6,7 +6,7 @@ // check to see if the cancel button was pushed if (optional_param('cancel', '', PARAM_ALPHA)) { - redirect("view.php?id=$cm->id"); + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); } $timenow = time(); @@ -182,5 +182,5 @@ } } - redirect("view.php?id=$cm->id", get_string('insertedpage', 'lesson')); + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('insertedpage', 'lesson')); ?> diff --git a/mod/lesson/action/moveit.php b/mod/lesson/action/moveit.php index 2eaf851725..32d9e73504 100644 --- a/mod/lesson/action/moveit.php +++ b/mod/lesson/action/moveit.php @@ -92,5 +92,5 @@ if (!set_field("lesson_pages", "nextpageid", 0, "id", $newlastpageid)) { error("Moveit: unable to update link"); } - redirect("view.php?id=$cm->id", get_string('movedpage', 'lesson')); + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('movedpage', 'lesson')); ?> diff --git a/mod/lesson/action/updatepage.php b/mod/lesson/action/updatepage.php index 2a7da3c582..3bc8c59940 100644 --- a/mod/lesson/action/updatepage.php +++ b/mod/lesson/action/updatepage.php @@ -16,9 +16,9 @@ if (optional_param('cancel', '', PARAM_ALPHA)) { if ($redirect == 'navigation') { // redirect to viewing the page - redirect("view.php?id=$cm->id&action=navigation&pageid=$page->id"); + redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=navigation&pageid=$page->id"); } else { - redirect("view.php?id=$cm->id"); + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); } } @@ -169,11 +169,11 @@ } if ($form->redisplay) { - redirect("lesson.php?id=$cm->id&action=editpage&pageid=$page->id&redirect=$redirect"); + redirect("$CFG->wwwroot/mod/lesson/lesson.php?id=$cm->id&action=editpage&pageid=$page->id&redirect=$redirect"); } else if ($redirect == 'navigation') { // takes us back to viewing the page - redirect("view.php?id=$cm->id&action=navigation&pageid=$page->id", get_string('updatedpage', 'lesson')); + redirect("$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=navigation&pageid=$page->id", get_string('updatedpage', 'lesson')); } else { - redirect("view.php?id=$cm->id", get_string('updatedpage', 'lesson')); + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('updatedpage', 'lesson')); } ?> diff --git a/mod/lesson/edit.php b/mod/lesson/edit.php new file mode 100644 index 0000000000..1949797476 --- /dev/null +++ b/mod/lesson/edit.php @@ -0,0 +1,394 @@ +id, false, $cm); + + $context = get_context_instance(CONTEXT_MODULE, $cm->id); + + require_capability('mod/lesson:manage'); + + lesson_print_header($cm, $course, $lesson, $mode); + + // get number of pages + $npages = count_records('lesson_pages', 'lessonid', $lesson->id); + + if (!$page = get_record_select("lesson_pages", "lessonid = $lesson->id AND prevpageid = 0")) { + // if there are no pages give teacher the option to create a new page or a new branch table + echo "
"; + if (has_capability('mod/lesson:edit', $context)) { + print_simple_box( "\n
".get_string("whatdofirst", "lesson")."
". + "id&pageid=0\">". + get_string("importquestions", "lesson")."
". + "id&pageid=0\">". + get_string("importppt", "lesson")."
". + "id&action=addbranchtable&pageid=0&firstpage=1\">". + get_string("addabranchtable", "lesson")."
". + "id&action=addpage&pageid=0&firstpage=1\">". + get_string("addaquestionpage", "lesson")." ".get_string("here","lesson"). + "
\n"); + } + echo '
'; + } else { + // print the pages + echo "
\n"; + echo "id\" />\n"; + echo "\n"; + echo "\n"; + $branch = false; + $singlePage = false; + if($collapsed and !$display) { + echo "
\n"; + echo "
\n"; + lesson_print_tree($page->id, $lesson, $cm->id); + echo "
\n"; + echo "
\n"; + } else { + if($display) { + while(true) + { + if($page->id == $display && $page->qtype == LESSON_BRANCHTABLE) { + $branch = true; + $singlePage = false; + break; + } elseif($page->id == $display) { + $branch = false; + $singlePage = true; + break; + } elseif ($page->nextpageid) { + if (!$page = get_record("lesson_pages", "id", $page->nextpageid)) { + error("Teacher view: Next page not found!"); + } + } else { + // last page reached + break; + } + } + echo "\n"; + if (has_capability('mod/lesson:edit', $context)) { + echo "\n"; + } + } else { + echo "
id&pageid=$page->prevpageid\">". + get_string("importquestions", "lesson")." | ". + "id&sesskey=".$USER->sesskey."&action=addcluster&pageid=$page->prevpageid\">". + get_string("addcluster", "lesson")." | ". + "id&sesskey=".$USER->sesskey."&action=addendofcluster&pageid=$page->prevpageid\">". + get_string("addendofcluster", "lesson")." | ". + "id&action=addbranchtable&pageid=$page->prevpageid\">". + get_string("addabranchtable", "lesson")." | ". + "id&action=addpage&pageid=$page->prevpageid\">". + get_string("addaquestionpage", "lesson")." ".get_string("here","lesson"). + "
\n"; + if (has_capability('mod/lesson:edit', $context)) { + echo "\n"; + } + } + /// end collapsed code (note, there is an "}" below for an else above) + while (true) { + echo "\n"; + if (has_capability('mod/lesson:edit', $context)) { + echo "\n"; + } +// echo "
id&pageid=0\">". + get_string("importquestions", "lesson")." | ". + "id&sesskey=".$USER->sesskey."&action=addcluster&pageid=0\">". + get_string("addcluster", "lesson")." | ". + "id&action=addbranchtable&pageid=0\">". + get_string("addabranchtable", "lesson")." | ". + "id&action=addpage&pageid=0\">". + get_string("addaquestionpage", "lesson")." ".get_string("here","lesson"). + "
\n"; + echo "\n"; + echo "\n"; + // get the answers in a set order, the id order + if ($answers = get_records("lesson_answers", "pageid", $page->id, "id")) { + echo "\n"; + $i = 1; + $n = 0; + foreach ($answers as $answer) { + switch ($page->qtype) { + case LESSON_MULTICHOICE: + case LESSON_TRUEFALSE: + case LESSON_SHORTANSWER: + case LESSON_NUMERICAL: + echo "\n"; + echo "\n"; + break; + case LESSON_MATCHING: + $options = new stdClass; + $options->noclean = true; + if ($n < 2) { + if ($answer->answer != NULL) { + if ($n == 0) { + echo "\n"; + } else { + echo "\n"; + } + } + $n++; + $i--; + } else { + echo "\n"; + echo "\n"; + } + break; + case LESSON_BRANCHTABLE: + $options = new stdClass; + $options->noclean = true; + echo "\n"; + break; + } + if ($answer->jumpto == 0) { + $jumptitle = get_string("thispage", "lesson"); + } elseif ($answer->jumpto == LESSON_NEXTPAGE) { + $jumptitle = get_string("nextpage", "lesson"); + } elseif ($answer->jumpto == LESSON_EOL) { + $jumptitle = get_string("endoflesson", "lesson"); + } elseif ($answer->jumpto == LESSON_UNSEENBRANCHPAGE) { + $jumptitle = get_string("unseenpageinbranch", "lesson"); + } elseif ($answer->jumpto == LESSON_PREVIOUSPAGE) { + $jumptitle = get_string("previouspage", "lesson"); + } elseif ($answer->jumpto == LESSON_RANDOMPAGE) { + $jumptitle = get_string("randompageinbranch", "lesson"); + } elseif ($answer->jumpto == LESSON_RANDOMBRANCH) { + $jumptitle = get_string("randombranch", "lesson"); + } elseif ($answer->jumpto == LESSON_CLUSTERJUMP) { + $jumptitle = get_string("clusterjump", "lesson"); + } else { + if (!$jumptitle = get_field("lesson_pages", "title", "id", $answer->jumpto)) { + $jumptitle = "".get_string("notdefined", "lesson").""; + } + } + $jumptitle = format_string($jumptitle,true); + if ($page->qtype == LESSON_MATCHING) { + if ($i == 1) { + echo "\n"; + echo "\n"; + } elseif ($i == 2) { + echo "\n"; + echo "\n"; + } + } else { + if ($lesson->custom and + $page->qtype != LESSON_BRANCHTABLE and + $page->qtype != LESSON_ENDOFBRANCH and + $page->qtype != LESSON_CLUSTER and + $page->qtype != LESSON_ENDOFCLUSTER) { + echo "\n"; + } + echo "\n"; + } + $i++; + } + // print_simple_box_end(); // not sure if i commented this out... hehe + echo "\n"; + } + echo "
".format_string($page->title)."  \n"; + if (has_capability('mod/lesson:edit', $context)) { + if ($npages > 1) { + echo "id&action=move&pageid=$page->id\">\n". + "pixpath/t/move.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"move\" />\n"; + } + echo "id&action=editpage&pageid=$page->id\">\n". + "pixpath/t/edit.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"edit\" />\n". + "id&sesskey=".$USER->sesskey."&action=confirmdelete&pageid=$page->id\">\n". + "pixpath/t/delete.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"delete\" />\n"; + } + echo "
\n"; + $options = new stdClass; + $options->noclean = true; + print_simple_box(format_text($page->contents, FORMAT_MOODLE, $options), "center"); + echo "
\n"; + switch ($page->qtype) { + case LESSON_ESSAY : + echo $LESSON_QUESTION_TYPE[$page->qtype]; + break; + case LESSON_SHORTANSWER : + echo $LESSON_QUESTION_TYPE[$page->qtype]; + if ($page->qoption) { + echo " - ".get_string("casesensitive", "lesson"); + } + break; + case LESSON_MULTICHOICE : + echo $LESSON_QUESTION_TYPE[$page->qtype]; + if ($page->qoption) { + echo " - ".get_string("multianswer", "lesson"); + } + break; + case LESSON_MATCHING : + echo $LESSON_QUESTION_TYPE[$page->qtype]; + echo get_string("firstanswershould", "lesson"); + break; + case LESSON_TRUEFALSE : + case LESSON_NUMERICAL : + echo $LESSON_QUESTION_TYPE[$page->qtype]; + break; + case LESSON_BRANCHTABLE : + echo get_string("branchtable", "lesson"); + break; + case LESSON_ENDOFBRANCH : + echo get_string("endofbranch", "lesson"); + break; + case LESSON_CLUSTER : + echo get_string("clustertitle", "lesson"); + break; + case LESSON_ENDOFCLUSTER : + echo get_string("endofclustertitle", "lesson"); + break; + } + echo "
\n"; + if ($lesson->custom) { + // if the score is > 0, then it is correct + if ($answer->score > 0) { + echo "".get_string("answer", "lesson")." $i: \n"; + } else { + echo "".get_string("answer", "lesson")." $i: \n"; + } + } else { + if (lesson_iscorrect($page->id, $answer->jumpto)) { + // underline correct answers + echo "".get_string("answer", "lesson")." $i: \n"; + } else { + echo "".get_string("answer", "lesson")." $i: \n"; + } + } + $options = new stdClass; + $options->noclean = true; + echo "\n"; + echo format_text($answer->answer, FORMAT_MOODLE, $options); + echo "
".get_string("response", "lesson")." $i: \n"; + echo "\n"; + echo format_text($answer->response, FORMAT_MOODLE, $options); + echo "
".get_string("correctresponse", "lesson").": \n"; + echo "\n"; + echo format_text($answer->answer, FORMAT_MOODLE, $options); + echo "
".get_string("wrongresponse", "lesson").": \n"; + echo "\n"; + echo format_text($answer->answer, FORMAT_MOODLE, $options); + echo "
\n"; + if ($lesson->custom) { + // if the score is > 0, then it is correct + if ($answer->score > 0) { + echo "".get_string("answer", "lesson")." $i: \n"; + } else { + echo "".get_string("answer", "lesson")." $i: \n"; + } + } else { + if (lesson_iscorrect($page->id, $answer->jumpto)) { + // underline correct answers + echo "".get_string("answer", "lesson")." $i: \n"; + } else { + echo "".get_string("answer", "lesson")." $i: \n"; + } + } + echo "\n"; + echo format_text($answer->answer, FORMAT_MOODLE, $options); + echo "
".get_string("matchesanswer", "lesson")." $i: \n"; + echo "\n"; + echo format_text($answer->response, FORMAT_MOODLE, $options); + echo "
\n"; + echo "".get_string("description", "lesson")." $i: \n"; + echo "\n"; + echo format_text($answer->answer, FORMAT_MOODLE, $options); + echo "
".get_string("correctanswerscore", "lesson").":"; + echo "\n"; + echo "$answer->score
".get_string("correctanswerjump", "lesson").":"; + echo "\n"; + echo "$jumptitle
".get_string("wronganswerscore", "lesson").":"; + echo "\n"; + echo "$answer->score
".get_string("wronganswerjump", "lesson").":"; + echo "\n"; + echo "$jumptitle
".get_string("score", "lesson")." $i:"; + echo "\n"; + echo "$answer->score
".get_string("jump", "lesson")." $i:"; + echo "\n"; + echo "$jumptitle
"; + if ($page->qtype != LESSON_ENDOFBRANCH) { + echo "qtype == LESSON_BRANCHTABLE) { + echo get_string("checkbranchtable", "lesson"); + } else { + echo get_string("checkquestion", "lesson"); + } + echo "\" onclick=\"document.lessonpages.pageid.value=$page->id;". + "document.lessonpages.submit();\" />"; + } + echo " 
id&pageid=$page->id\">". + get_string("importquestions", "lesson")." | ". + "id&sesskey=".$USER->sesskey."&action=addcluster&pageid=$page->id\">". + get_string("addcluster", "lesson")." | ". + "id&sesskey=".$USER->sesskey."&action=addendofcluster&pageid=$page->id\">". + get_string("addendofcluster", "lesson")." | ". + "id&action=addbranchtable&pageid=$page->id\">". + get_string("addabranchtable", "lesson")."
"; + // the current page or the next page is an end of branch don't show EOB link + $nextqtype = 0; // set to anything else EOB + if ($page->nextpageid) { + $nextqtype = get_field("lesson_pages", "qtype", "id", $page->nextpageid); + } + if (($page->qtype != LESSON_ENDOFBRANCH) and ($nextqtype != LESSON_ENDOFBRANCH)) { + echo "id&sesskey=".$USER->sesskey."&action=addendofbranch&pageid=$page->id\">". + get_string("addanendofbranch", "lesson")." | "; + } + echo "id&action=addpage&pageid=$page->id\">". + get_string("addaquestionpage", "lesson")." ".get_string("here","lesson"). + "
\n"; + // check the prev links - fix (silently) if necessary - there was a bug in + // versions 1 and 2 when add new pages. Not serious then as the backwards + // links were not used in those versions + if (isset($prevpageid)) { + if ($page->prevpageid != $prevpageid) { + // fix it + set_field("lesson_pages", "prevpageid", $prevpageid, "id", $page->id); + if ($CFG->debug) { + echo "

***prevpageid of page $page->id set to $prevpageid***"; + } + } + } + $prevpageid = $page->id; + // move to next page + if($singlePage) { // this will make sure only one page is displayed if needed + break; + } elseif($branch && $page->qtype == LESSON_ENDOFBRANCH) { // this will display a branch table and its contents + break; + } elseif ($page->nextpageid) { + if (!$page = get_record("lesson_pages", "id", $page->nextpageid)) { + error("Teacher view: Next page not found!"); + } + } else { + // last page reached + break; + } + } + } // end of else from above collapsed code!!! + + echo "

\n"; + } + + print_footer($course); +?> \ No newline at end of file diff --git a/mod/lesson/locallib.php b/mod/lesson/locallib.php index aa75be66d1..78f89523dc 100644 --- a/mod/lesson/locallib.php +++ b/mod/lesson/locallib.php @@ -1352,9 +1352,9 @@ function lesson_print_tree($pageid, $lesson, $cmid) { while ($pageid != 0) { echo ""; if(($pages[$pageid]->qtype != LESSON_BRANCHTABLE) && ($pages[$pageid]->qtype != LESSON_ENDOFBRANCH)) { - $output = "id."\">".format_string($pages[$pageid]->title,true)."\n"; + $output = "wwwroot/mod/lesson/edit.php?id=$cmid&display=".$pages[$pageid]->id."\">".format_string($pages[$pageid]->title,true)."\n"; } else { - $output = "id."\">".format_string($pages[$pageid]->title,true)."\n"; + $output = "wwwroot/mod/lesson/edit.php?id=$cmid&display=".$pages[$pageid]->id."\">".format_string($pages[$pageid]->title,true)."\n"; if($answers = get_records_select("lesson_answers", "lessonid = $lesson->id and pageid = $pageid")) { $output .= "Jumps to: "; diff --git a/mod/lesson/tabs.php b/mod/lesson/tabs.php index 6a5c09ea09..b1cf2f1aee 100644 --- a/mod/lesson/tabs.php +++ b/mod/lesson/tabs.php @@ -36,7 +36,7 @@ $counts->student = $course->student; - $row[] = new tabobject('teacherview', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id", get_string('edit'), get_string('editlesson', 'lesson', format_string($lesson->name))); + $row[] = new tabobject('edit', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id", get_string('edit'), get_string('editlesson', 'lesson', format_string($lesson->name))); $row[] = new tabobject('navigation', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=navigation", get_string('preview', 'lesson'), get_string('previewlesson', 'lesson', format_string($lesson->name))); $row[] = new tabobject('reports', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id", get_string('reports', 'lesson'), get_string('viewreports', 'lesson', $counts)); if (has_capability('mod/lesson:edit', $context)) { @@ -48,10 +48,11 @@ $tabs[] = $row; -/// sub tabs for reports (overview and detail) + switch ($currenttab) { case 'reportoverview': case 'reportdetail': + /// sub tabs for reports (overview and detail) $inactive[] = 'reports'; $row = array(); @@ -59,24 +60,16 @@ $row[] = new tabobject('reportdetail', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id&action=reportdetail", get_string('detailedstats', 'lesson')); $tabs[] = $row; break; - } - -/// sub tabs for teacher view (collapsed and expanded aka full) - if ($currenttab == 'teacherview') { - // use user preferences to remember which edit mode the user has selected - if (empty($mode)) { - $mode = get_user_preferences('lesson_view', 'collapsed'); - } else { - set_user_preference('lesson_view', $mode); - } - - $inactive[] = 'teacherview'; - $currenttab = $mode; - - $row = array(); - $row[] = new tabobject('collapsed', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=teacherview&mode=collapsed", get_string('collapsed', 'lesson')); - $row[] = new tabobject('full', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&=teacherview&mode=full", get_string('full', 'lesson')); - $tabs[] = $row; + case 'collapsed': + case 'full': + /// sub tabs for edit view (collapsed and expanded aka full) + $inactive[] = 'edit'; + + $row = array(); + $row[] = new tabobject('collapsed', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&mode=collapsed", get_string('collapsed', 'lesson')); + $row[] = new tabobject('full', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id&mode=full", get_string('full', 'lesson')); + $tabs[] = $row; + break; } print_tabs($tabs, $currenttab, $inactive); diff --git a/mod/lesson/view.php b/mod/lesson/view.php index 701f4a3a5f..1492db51f1 100644 --- a/mod/lesson/view.php +++ b/mod/lesson/view.php @@ -10,8 +10,7 @@ $id = required_param('id', PARAM_INT); // Course Module ID $pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID $action = optional_param('action', '', PARAM_ALPHA); - $display = optional_param('display', 0, PARAM_INT); // for teacherview action - $mode = optional_param('mode', '', PARAM_ALPHA); // for eacherview action todo use user pref + if (! $cm = get_coursemodule_from_id('lesson', $id)) { @@ -45,7 +44,7 @@ // moved the action up because I needed to know what the action will be before the header is printed if (empty($action)) { if (has_capability('mod/lesson:manage', $context)) { - $action = 'teacherview'; + redirect("$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); } elseif (time() < $lesson->available) { print_header($course->shortname .': '. format_string($lesson->name), $course->fullname, $navigation .''. $strlessons .' -> '. @@ -1172,375 +1171,6 @@ } } - - /*******************teacher view **************************************/ - elseif ($action == 'teacherview') { - // set collapsed flag - if ($mode == 'collapsed') { - $collapsed = true; - } else { - $collapsed = false; - } - - print_heading_with_help(format_string($lesson->name,true), "overview", "lesson"); - - // get number of pages - $npages = count_records('lesson_pages', 'lessonid', $lesson->id); - - if (!$page = get_record_select("lesson_pages", "lessonid = $lesson->id AND prevpageid = 0")) { - // if there are no pages give teacher the option to create a new page or a new branch table - echo "
"; - if (has_capability('mod/lesson:edit', $context)) { - print_simple_box( "\n
".get_string("whatdofirst", "lesson")."
". - "id&pageid=0\">". - get_string("importquestions", "lesson")."
". - "id&pageid=0\">". - get_string("importppt", "lesson")."
". - "id&action=addbranchtable&pageid=0&firstpage=1\">". - get_string("addabranchtable", "lesson")."
". - "id&action=addpage&pageid=0&firstpage=1\">". - get_string("addaquestionpage", "lesson")." ".get_string("here","lesson"). - "
\n"); - } - echo '
'; - } else { - // print the pages - echo "
\n"; - echo "id\" />\n"; - echo "\n"; - echo "\n"; - $branch = false; - $singlePage = false; - if($collapsed and !$display) { - echo "
\n"; - echo "
\n"; - lesson_print_tree($page->id, $lesson, $cm->id); - echo "
\n"; - echo "
\n"; - } else { - if($display) { - while(true) - { - if($page->id == $display && $page->qtype == LESSON_BRANCHTABLE) { - $branch = true; - $singlePage = false; - break; - } elseif($page->id == $display) { - $branch = false; - $singlePage = true; - break; - } elseif ($page->nextpageid) { - if (!$page = get_record("lesson_pages", "id", $page->nextpageid)) { - error("Teacher view: Next page not found!"); - } - } else { - // last page reached - break; - } - } - echo "\n"; - if (has_capability('mod/lesson:edit', $context)) { - echo "\n"; - } - } else { - echo "
id&pageid=$page->prevpageid\">". - get_string("importquestions", "lesson")." | ". - "id&sesskey=".$USER->sesskey."&action=addcluster&pageid=$page->prevpageid\">". - get_string("addcluster", "lesson")." | ". - "id&sesskey=".$USER->sesskey."&action=addendofcluster&pageid=$page->prevpageid\">". - get_string("addendofcluster", "lesson")." | ". - "id&action=addbranchtable&pageid=$page->prevpageid\">". - get_string("addabranchtable", "lesson")." | ". - "id&action=addpage&pageid=$page->prevpageid\">". - get_string("addaquestionpage", "lesson")." ".get_string("here","lesson"). - "
\n"; - if (has_capability('mod/lesson:edit', $context)) { - echo "\n"; - } - } - /// end collapsed code (note, there is an "}" below for an else above) - while (true) { - echo "\n"; - if (has_capability('mod/lesson:edit', $context)) { - echo "\n"; - } -// echo "
id&pageid=0\">". - get_string("importquestions", "lesson")." | ". - "id&sesskey=".$USER->sesskey."&action=addcluster&pageid=0\">". - get_string("addcluster", "lesson")." | ". - "id&action=addbranchtable&pageid=0\">". - get_string("addabranchtable", "lesson")." | ". - "id&action=addpage&pageid=0\">". - get_string("addaquestionpage", "lesson")." ".get_string("here","lesson"). - "
\n"; - echo "\n"; - echo "\n"; - // get the answers in a set order, the id order - if ($answers = get_records("lesson_answers", "pageid", $page->id, "id")) { - echo "\n"; - $i = 1; - $n = 0; - foreach ($answers as $answer) { - switch ($page->qtype) { - case LESSON_MULTICHOICE: - case LESSON_TRUEFALSE: - case LESSON_SHORTANSWER: - case LESSON_NUMERICAL: - echo "\n"; - echo "\n"; - break; - case LESSON_MATCHING: - $options = new stdClass; - $options->noclean = true; - if ($n < 2) { - if ($answer->answer != NULL) { - if ($n == 0) { - echo "\n"; - } else { - echo "\n"; - } - } - $n++; - $i--; - } else { - echo "\n"; - echo "\n"; - } - break; - case LESSON_BRANCHTABLE: - $options = new stdClass; - $options->noclean = true; - echo "\n"; - break; - } - if ($answer->jumpto == 0) { - $jumptitle = get_string("thispage", "lesson"); - } elseif ($answer->jumpto == LESSON_NEXTPAGE) { - $jumptitle = get_string("nextpage", "lesson"); - } elseif ($answer->jumpto == LESSON_EOL) { - $jumptitle = get_string("endoflesson", "lesson"); - } elseif ($answer->jumpto == LESSON_UNSEENBRANCHPAGE) { - $jumptitle = get_string("unseenpageinbranch", "lesson"); - } elseif ($answer->jumpto == LESSON_PREVIOUSPAGE) { - $jumptitle = get_string("previouspage", "lesson"); - } elseif ($answer->jumpto == LESSON_RANDOMPAGE) { - $jumptitle = get_string("randompageinbranch", "lesson"); - } elseif ($answer->jumpto == LESSON_RANDOMBRANCH) { - $jumptitle = get_string("randombranch", "lesson"); - } elseif ($answer->jumpto == LESSON_CLUSTERJUMP) { - $jumptitle = get_string("clusterjump", "lesson"); - } else { - if (!$jumptitle = get_field("lesson_pages", "title", "id", $answer->jumpto)) { - $jumptitle = "".get_string("notdefined", "lesson").""; - } - } - $jumptitle = format_string($jumptitle,true); - if ($page->qtype == LESSON_MATCHING) { - if ($i == 1) { - echo "\n"; - echo "\n"; - } elseif ($i == 2) { - echo "\n"; - echo "\n"; - } - } else { - if ($lesson->custom and - $page->qtype != LESSON_BRANCHTABLE and - $page->qtype != LESSON_ENDOFBRANCH and - $page->qtype != LESSON_CLUSTER and - $page->qtype != LESSON_ENDOFCLUSTER) { - echo "\n"; - } - echo "\n"; - } - $i++; - } - // print_simple_box_end(); // not sure if i commented this out... hehe - echo "\n"; - } - echo "
".format_string($page->title)."  \n"; - if (has_capability('mod/lesson:edit', $context)) { - if ($npages > 1) { - echo "id&action=move&pageid=$page->id\">\n". - "pixpath/t/move.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"move\" />\n"; - } - echo "id&action=editpage&pageid=$page->id\">\n". - "pixpath/t/edit.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"edit\" />\n". - "id&sesskey=".$USER->sesskey."&action=confirmdelete&pageid=$page->id\">\n". - "pixpath/t/delete.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"delete\" />\n"; - } - echo "
\n"; - $options = new stdClass; - $options->noclean = true; - print_simple_box(format_text($page->contents, FORMAT_MOODLE, $options), "center"); - echo "
\n"; - switch ($page->qtype) { - case LESSON_ESSAY : - echo $LESSON_QUESTION_TYPE[$page->qtype]; - break; - case LESSON_SHORTANSWER : - echo $LESSON_QUESTION_TYPE[$page->qtype]; - if ($page->qoption) { - echo " - ".get_string("casesensitive", "lesson"); - } - break; - case LESSON_MULTICHOICE : - echo $LESSON_QUESTION_TYPE[$page->qtype]; - if ($page->qoption) { - echo " - ".get_string("multianswer", "lesson"); - } - break; - case LESSON_MATCHING : - echo $LESSON_QUESTION_TYPE[$page->qtype]; - echo get_string("firstanswershould", "lesson"); - break; - case LESSON_TRUEFALSE : - case LESSON_NUMERICAL : - echo $LESSON_QUESTION_TYPE[$page->qtype]; - break; - case LESSON_BRANCHTABLE : - echo get_string("branchtable", "lesson"); - break; - case LESSON_ENDOFBRANCH : - echo get_string("endofbranch", "lesson"); - break; - case LESSON_CLUSTER : - echo get_string("clustertitle", "lesson"); - break; - case LESSON_ENDOFCLUSTER : - echo get_string("endofclustertitle", "lesson"); - break; - } - echo "
\n"; - if ($lesson->custom) { - // if the score is > 0, then it is correct - if ($answer->score > 0) { - echo "".get_string("answer", "lesson")." $i: \n"; - } else { - echo "".get_string("answer", "lesson")." $i: \n"; - } - } else { - if (lesson_iscorrect($page->id, $answer->jumpto)) { - // underline correct answers - echo "".get_string("answer", "lesson")." $i: \n"; - } else { - echo "".get_string("answer", "lesson")." $i: \n"; - } - } - $options = new stdClass; - $options->noclean = true; - echo "\n"; - echo format_text($answer->answer, FORMAT_MOODLE, $options); - echo "
".get_string("response", "lesson")." $i: \n"; - echo "\n"; - echo format_text($answer->response, FORMAT_MOODLE, $options); - echo "
".get_string("correctresponse", "lesson").": \n"; - echo "\n"; - echo format_text($answer->answer, FORMAT_MOODLE, $options); - echo "
".get_string("wrongresponse", "lesson").": \n"; - echo "\n"; - echo format_text($answer->answer, FORMAT_MOODLE, $options); - echo "
\n"; - if ($lesson->custom) { - // if the score is > 0, then it is correct - if ($answer->score > 0) { - echo "".get_string("answer", "lesson")." $i: \n"; - } else { - echo "".get_string("answer", "lesson")." $i: \n"; - } - } else { - if (lesson_iscorrect($page->id, $answer->jumpto)) { - // underline correct answers - echo "".get_string("answer", "lesson")." $i: \n"; - } else { - echo "".get_string("answer", "lesson")." $i: \n"; - } - } - echo "\n"; - echo format_text($answer->answer, FORMAT_MOODLE, $options); - echo "
".get_string("matchesanswer", "lesson")." $i: \n"; - echo "\n"; - echo format_text($answer->response, FORMAT_MOODLE, $options); - echo "
\n"; - echo "".get_string("description", "lesson")." $i: \n"; - echo "\n"; - echo format_text($answer->answer, FORMAT_MOODLE, $options); - echo "
".get_string("correctanswerscore", "lesson").":"; - echo "\n"; - echo "$answer->score
".get_string("correctanswerjump", "lesson").":"; - echo "\n"; - echo "$jumptitle
".get_string("wronganswerscore", "lesson").":"; - echo "\n"; - echo "$answer->score
".get_string("wronganswerjump", "lesson").":"; - echo "\n"; - echo "$jumptitle
".get_string("score", "lesson")." $i:"; - echo "\n"; - echo "$answer->score
".get_string("jump", "lesson")." $i:"; - echo "\n"; - echo "$jumptitle
"; - if ($page->qtype != LESSON_ENDOFBRANCH) { - echo "qtype == LESSON_BRANCHTABLE) { - echo get_string("checkbranchtable", "lesson"); - } else { - echo get_string("checkquestion", "lesson"); - } - echo "\" onclick=\"document.lessonpages.pageid.value=$page->id;". - "document.lessonpages.submit();\" />"; - } - echo " 
id&pageid=$page->id\">". - get_string("importquestions", "lesson")." | ". - "id&sesskey=".$USER->sesskey."&action=addcluster&pageid=$page->id\">". - get_string("addcluster", "lesson")." | ". - "id&sesskey=".$USER->sesskey."&action=addendofcluster&pageid=$page->id\">". - get_string("addendofcluster", "lesson")." | ". - "id&action=addbranchtable&pageid=$page->id\">". - get_string("addabranchtable", "lesson")."
"; - // the current page or the next page is an end of branch don't show EOB link - $nextqtype = 0; // set to anything else EOB - if ($page->nextpageid) { - $nextqtype = get_field("lesson_pages", "qtype", "id", $page->nextpageid); - } - if (($page->qtype != LESSON_ENDOFBRANCH) and ($nextqtype != LESSON_ENDOFBRANCH)) { - echo "id&sesskey=".$USER->sesskey."&action=addendofbranch&pageid=$page->id\">". - get_string("addanendofbranch", "lesson")." | "; - } - echo "id&action=addpage&pageid=$page->id\">". - get_string("addaquestionpage", "lesson")." ".get_string("here","lesson"). - "
\n"; - // check the prev links - fix (silently) if necessary - there was a bug in - // versions 1 and 2 when add new pages. Not serious then as the backwards - // links were not used in those versions - if (isset($prevpageid)) { - if ($page->prevpageid != $prevpageid) { - // fix it - set_field("lesson_pages", "prevpageid", $prevpageid, "id", $page->id); - if ($CFG->debug) { - echo "

***prevpageid of page $page->id set to $prevpageid***"; - } - } - } - $prevpageid = $page->id; - // move to next page - if($singlePage) { // this will make sure only one page is displayed if needed - break; - } elseif($branch && $page->qtype == LESSON_ENDOFBRANCH) { // this will display a branch table and its contents - break; - } elseif ($page->nextpageid) { - if (!$page = get_record("lesson_pages", "id", $page->nextpageid)) { - error("Teacher view: Next page not found!"); - } - } else { - // last page reached - break; - } - } - } // end of else from above collapsed code!!! - - echo "

\n"; - } - } - /*************** no man's land **************************************/ else { error("Fatal Error: Unknown Action: ".$action."\n");