course)) { error("Course is misconfigured"); } if (! $lesson = get_record("lesson", "id", $cm->instance)) { error("Course module is incorrect"); } require_login($course->id); // set up some general variables $usehtmleditor = can_use_html_editor(); $navigation = ""; if ($course->category) { $navigation = "id\">$course->shortname ->"; } $strlessons = get_string("modulenameplural", "lesson"); $strlesson = get_string("modulename", "lesson"); $strlessonname = $lesson->name; // ... print the header and... print_header("$course->shortname: $lesson->name", "$course->fullname", "$navigation id>$strlessons -> id\">$lesson->name", "", "", true); //...get the action require_variable($action); /************** add branch table ************************************/ if ($action == 'addbranchtable' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); } // first get the preceeding page $pageid = $_GET['pageid']; // set of jump array $jump[0] = get_string("thispage", "lesson"); $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); //// 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"); ?>
id)) { error("Only teachers can look at this page"); } // first get the preceeding page $pageid = $_GET['pageid']; $timenow = time(); // the new page is not the first page (end of branch always comes after an existing page) if (!$page = get_record("lesson_pages", "id", $pageid)) { error("Add end of branch: page record not found"); } // chain back up to find the (nearest branch table) $btpageid = $pageid; if (!$btpage = get_record("lesson_pages", "id", $btpageid)) { error("Add end of branch: btpage record not found"); } while (($btpage->qtype != LESSON_BRANCHTABLE) AND ($btpage->prevpageid > 0)) { $btpageid = $btpage->prevpageid; if (!$btpage = get_record("lesson_pages", "id", $btpageid)) { error("Add end of branch: btpage record not found"); } } if ($btpage->qtype == LESSON_BRANCHTABLE) { $newpage->lessonid = $lesson->id; $newpage->prevpageid = $pageid; $newpage->nextpageid = $page->nextpageid; $newpage->qtype = LESSON_ENDOFBRANCH; $newpage->timecreated = $timenow; $newpage->title = get_string("endofbranch", "lesson"); $newpage->contents = get_string("endofbranch", "lesson"); if (!$newpageid = insert_record("lesson_pages", $newpage)) { error("Insert page: new page not inserted"); } // update the linked list... if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) { error("Add end of branch: unable to update link"); } if ($page->nextpageid) { // the new page is not the last page if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) { error("Insert page: unable to update previous link"); } } // ..and the single "answer" $newanswer->lessonid = $lesson->id; $newanswer->pageid = $newpageid; $newanswer->timecreated = $timenow; $newanswer->jumpto = $btpageid; if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { error("Add end of branch: answer record not inserted"); } redirect("view.php?id=$cm->id", get_string("ok")); } else { notice(get_string("nobranchtablefound", "lesson"), "view.php?id=$cm->id"); } } /// CDC-FLAG 6/17/04 /// /************** add cluster ************************************/ elseif ($action == 'addcluster' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); } // first get the preceeding page // if $pageid = 0, then we are inserting a new page at the beginning of the lesson $pageid = $_GET['pageid']; $timenow = time(); if ($pageid == 0) { if (!$page = get_record("lesson_pages", "prevpageid", 0, "lessonid", $lesson->id)) { error("Error: Add cluster: page record not found"); } } else { if (!$page = get_record("lesson_pages", "id", $pageid)) { error("Error: Add cluster: page record not found"); } } $newpage->lessonid = $lesson->id; $newpage->prevpageid = $pageid; if ($pageid != 0) { $newpage->nextpageid = $page->nextpageid; } else { $newpage->nextpageid = $page->id; } $newpage->qtype = LESSON_CLUSTER; $newpage->timecreated = $timenow; $newpage->title = get_string("clustertitle", "lesson"); $newpage->contents = get_string("clustertitle", "lesson"); if (!$newpageid = insert_record("lesson_pages", $newpage)) { error("Insert page: new page not inserted"); } // update the linked list... if ($pageid != 0) { if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) { error("Add cluster: unable to update link"); } } if ($pageid == 0) { $page->nextpageid = $page->id; } if ($page->nextpageid) { // the new page is not the last page if (!set_field("lesson_pages", "prevpageid", $newpageid, "id", $page->nextpageid)) { error("Insert page: unable to update previous link"); } } // ..and the single "answer" $newanswer->lessonid = $lesson->id; $newanswer->pageid = $newpageid; $newanswer->timecreated = $timenow; $newanswer->jumpto = LESSON_CLUSTERJUMP; if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { error("Add cluster: answer record not inserted"); } redirect("view.php?id=$cm->id", get_string("ok")); } /// CDC-FLAG /// /// CDC-FLAG 6/17/04 /// /************** add end of cluster ************************************/ elseif ($action == 'addendofcluster' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); } // first get the preceeding page $pageid = $_GET['pageid']; $timenow = time(); // the new page is not the first page (end of cluster always comes after an existing page) if (!$page = get_record("lesson_pages", "id", $pageid)) { error("Error: Could not find page"); } // could put code in here to check if the user really can insert an end of cluster $newpage->lessonid = $lesson->id; $newpage->prevpageid = $pageid; $newpage->nextpageid = $page->nextpageid; $newpage->qtype = LESSON_ENDOFCLUSTER; $newpage->timecreated = $timenow; $newpage->title = get_string("endofclustertitle", "lesson"); $newpage->contents = get_string("endofclustertitle", "lesson"); if (!$newpageid = insert_record("lesson_pages", $newpage)) { error("Insert page: end of cluster page not inserted"); } // update the linked list... if (!set_field("lesson_pages", "nextpageid", $newpageid, "id", $pageid)) { error("Add end of cluster: 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 end of cluster: unable to update previous link"); } } // ..and the single "answer" $newanswer->lessonid = $lesson->id; $newanswer->pageid = $newpageid; $newanswer->timecreated = $timenow; $newanswer->jumpto = LESSON_NEXTPAGE; if(!$newanswerid = insert_record("lesson_answers", $newanswer)) { error("Add end of cluster: answer record not inserted"); } redirect("view.php?id=$cm->id", get_string("ok")); } /// CDC-FLAG /// /************** add page ************************************/ elseif ($action == 'addpage' ) { if (!isteacher($course->id)) { error("Only teachers can look at this page"); } // first get the preceeding page $pageid = $_GET['pageid']; // set of jump array $jump[0] = get_string("thispage", "lesson"); $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); //// 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] = $title; $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"); ?> id)) { error("Only teachers can look at this page"); } if (empty($_GET['pageid'])) { error("Confirm delete: pageid missing"); } $pageid = $_GET['pageid']; if (!$thispage = get_record("lesson_pages", "id", $pageid)) { error("Confirm delete: the page record not found"); } print_heading(get_string("deletingpage", "lesson", $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",
"view.php?id=$cm->id");
}
/****************** continue ************************************/
elseif ($action == 'continue' ) {
//CDC Chris Berri added this echo call for left menu. must match that in view.php for styles
if ($lesson->displayleft) {
echo '