]> git.mjollnir.org Git - moodle.git/commitdiff
Added $Id$ to files
authormark-nielsen <mark-nielsen>
Wed, 6 Sep 2006 04:04:42 +0000 (04:04 +0000)
committermark-nielsen <mark-nielsen>
Wed, 6 Sep 2006 04:04:42 +0000 (04:04 +0000)
Header is not printed for all actions.  Related to MDL-5403
Some redundant code removed
First attempt at separating logic and presentation in action continue (continue.html)

15 files changed:
mod/lesson/action/addbranchtable.php
mod/lesson/action/addcluster.php
mod/lesson/action/addendofbranch.php
mod/lesson/action/addendofcluster.php
mod/lesson/action/addpage.php
mod/lesson/action/confirmdelete.php
mod/lesson/action/continue.html [new file with mode: 0644]
mod/lesson/action/continue.php
mod/lesson/action/delete.php
mod/lesson/action/editpage.php
mod/lesson/action/insertpage.php
mod/lesson/action/move.php
mod/lesson/action/moveit.php
mod/lesson/action/updatepage.php
mod/lesson/lesson.php

index e9218305e3c59b2f51023f0e5aeaf4316930c448..2d96d0f8764bac9493b7e5d505ad32dd753a087f 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php // $Id$
 /************** add branch table ************************************/
     $CFG->pagepath = 'mod/lesson/addbranchtable';
     
-    if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     // first get the preceeding page
     $pageid = required_param('pageid', PARAM_INT);
     
index 887b5f8eee148f2881d35a601ec8e5f5abbdbb8e..2c4384025a9d8a58bb7d02a7f979add82ef123d3 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php // $Id$
 
 /************** add cluster ************************************/
 
-    if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-    
     confirm_sesskey();
 
     // first get the preceeding page
index da248dcbd716a3a7e4e77ad6a7364c6b5bac4895..330413fc348d5649acb28bfe2851c3a6a970d1f5 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php // $Id$
 
 /************** add end of branch ************************************/
 
-    if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     confirm_sesskey();
 
     // first get the preceeding page
index a949edf3853a15076069f274e4e927b5ad4fb419..20b3bf00c5e5beb662810cd61986f76f3898a936 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php // $Id$
 
 /************** add end of cluster ************************************/
 
-       if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     confirm_sesskey();
 
     // first get the preceeding page
index be77ccc5c3b2989527648e8b69261af6261b2931..395204d054e89c37dfb21fb0d24409bf2db6351a 100644 (file)
@@ -1,12 +1,8 @@
-<?php
+<?php // $Id$
 
 /************** add page ************************************/
     $CFG->pagepath = 'mod/lesson/addpage';
     
-    if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     // first get the preceeding page
     $pageid = required_param('pageid', PARAM_INT);
     $qtype = optional_param('qtype', LESSON_MULTICHOICE, PARAM_INT);
index a0225767b2457833f52fcce8348c024c3c2ef4ac..38c737e35f852f7a57b3069d5fccf6a71675852a 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php // $Id$
 
 /******************* confirm delete ************************************/
 
-    if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     confirm_sesskey();
 
     $pageid = required_param('pageid', PARAM_INT);
diff --git a/mod/lesson/action/continue.html b/mod/lesson/action/continue.html
new file mode 100644 (file)
index 0000000..e503a4e
--- /dev/null
@@ -0,0 +1,107 @@
+<?php // $Id$
+/**
+ * HTML template for continue.php
+ *
+ * @version $Id$
+ * @package lesson
+ **/
+?>
+
+<?php
+if ($lesson->displayleft) {
+   if($firstpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) {
+?>
+<table>
+    <tr valign="top">
+        <td>
+            <a href="#maincontent" class="skip"><?php print_string('skip', 'lesson') ?></a>
+            <div class="leftmenu_container">
+            <div class="leftmenu_title"><?php print_string('lessonmenu', 'lesson') ?></div>
+            <div class="leftmenu_courselink">
+            <a href="<?php echo "$CFG->wwwroot/course/view.php?id=$course->id"; ?>"><?php print_string("mainmenu", "lesson") ?></a>
+            </div>
+            <div class="leftmenu_links">
+            <?php lesson_print_tree_menu($lesson->id, $firstpageid, $cm->id) ?>
+            </div>
+            </div>
+        </td>
+        <td align="center" width="100%">';
+        <a name="maincontent" id="maincontent" title="<?php print_string('anchortitle', 'lesson') ?>"></a>
+<?php 
+    }  // End if($firstpageid = get...
+} // End if ($lesson->displayleft)
+?>
+
+<?php if($lesson->timed and !isteacher($course->id)) {
+        // code for the clock
+        print_simple_box_start("right", "150px", "#ffffff", 0);
+?>
+        <table border="0" valign="top" align="center" class="generaltable" width="100%" cellspacing="0">
+            <tr>
+                <th valign="top" class="generaltableheader"><?php print_string("timeremaining", "lesson") ?></th>
+            </tr>
+            <tr>
+                <td align="center" class="generaltablecell">
+                    <script language="javascript">
+                        var starttime  = "<?php echo $timer->starttime ?>";
+                        var servertime = "<?php echo time()?>";
+                        var testlength = "<?php echo $lesson->maxtime * 60 ?>";
+                        document.write('<SCRIPT LANGUAGE="JavaScript" SRC="timer.js"></SCRIPT>');
+                        window.onload = function () { show_clock(); }
+                    </script>
+                </td>
+            </tr>
+        </table>";
+        <?php print_simple_box_end(); ?>
+        <br /><br /><br /><br />
+<?php } //end if($lesson->timed) {
+
+// This calculates and prints the ongoing score message
+if ($lesson->ongoing) {
+    lesson_print_ongoing_score($lesson);
+}
+?>
+<table border="0" align="center">
+    <tr>
+        <td><?php echo $feedback ?></td>
+    </tr>
+</table>
+<form name="pageform" method ="post" action="view.php">
+<input type="hidden" name="id" value="<?php echo $cm->id ?>" />
+<input type="hidden" name="action" value="navigation" />
+<input type="hidden" name="pageid" value="<?php $newpageid ?>" />
+
+<?php if (isset($USER->modattempts[$lesson->id])) { ?>
+<p align="center"><?php print_string("savechangesandeol", "lesson") ?> <br /><br />
+    <div align="center" class="lessonbutton standardbutton">
+        <a href="javascript:document.pageform.pageid.value=<?php echo LESSON_EOL ?>;document.pageform.submit();"><?php print_string("savechanges", "lesson") ?></a>
+    </div>
+</p>
+<p align="center">
+    <?php print_string("or", "lesson") ?>
+    <br /><br />
+    <?php print_string("continuetoanswer", "lesson") ?>
+</p>
+<?php }
+    if ($lesson->review && !$correctanswer && !$noanswer && !$isessayquestion) { ?>
+        <p>
+            <div align="center" class="lessonbutton standardbutton">
+                <a href="javascript:document.pageform.pageid.value=<?php echo $pageid ?>;document.pageform.submit();"><?php print_string("reviewquestionback", "lesson") ?></a>
+            </div>
+        </p>
+        <p><div align="center" class="lessonbutton standardbutton">
+            <a href="javascript:document.pageform.submit();"><?php print_string("reviewquestioncontinue", "lesson") ?></a>
+            </div>
+        </p>
+<?php } else { ?>
+<p>
+    <div align="center" class="lessonbutton standardbutton">
+        <a href="javascript:document.pageform.submit();"><?php print_string("continue", "lesson") ?></a>
+    </div>
+</p>
+<?php } ?>
+</form>
+
+<?php if ($lesson->displayleft) { ?>
+</td></tr></table>
+<?php } ?>
\ No newline at end of file
index 2cfaae70e44a1da710703ac76e40ced93f7beb28..7517373fb87e7131afd65409795b404ea2b303f0 100644 (file)
@@ -4,89 +4,54 @@
 
     confirm_sesskey();
 
+    $messages = array();
+
     // left menu code
     // check to see if the user can see the left menu
     if (!isteacher($course->id)) {
         $lesson->displayleft = lesson_displayleftif($lesson);
     }
-    if ($lesson->displayleft) {
-       if($firstpageid = get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) {
-            // print the pages
-            echo '<table><tr valign="top"><td>';
-            // skip navigation link
-            echo '<a href="#maincontent" class="skip">'.get_string('skip', 'lesson').'</a>';
-            echo "<div class=\"leftmenu_container\">\n";
-                echo '<div class="leftmenu_title">'.get_string('lessonmenu', 'lesson')."</div>\n";
-                echo "<div class=\"leftmenu_courselink\">\n";
-                echo "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">".get_string("mainmenu", "lesson")."</a>\n";
-                echo "</div>\n";
-                echo "<div class=\"leftmenu_links\">\n";
-                lesson_print_tree_menu($lesson->id, $firstpageid, $cm->id);
-                echo "</div>\n";
-            echo "</div>\n";
-            echo '</td><td align="center" width="100%">';
-            // skip to anchor
-            echo '<a name="maincontent" id="maincontent" title="'.get_string('anchortitle', 'lesson').'"></a>';
-        }
-    }
-
+    
     // 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 (lesson_display_teacher_warning($lesson->id)) {
-            $warningvars->cluster = get_string("clusterjump", "lesson");
-            $warningvars->unseen = get_string("unseenpageinbranch", "lesson");
-            echo "<p align=\"center\">".get_string("teacherjumpwarning", "lesson", $warningvars)."</p>";
-        }
-    }        
+    if(isteacher($course->id) and lesson_display_teacher_warning($lesson->id)) {
+        $warningvars->cluster = get_string("clusterjump", "lesson");
+        $warningvars->unseen = get_string("unseenpageinbranch", "lesson");
+        $messages[] = get_string("teacherjumpwarning", "lesson", $warningvars);
+    }
 
     // This is the code updates the lesson time for a timed test
     // get time information for this user
+    $outoftime = false;
     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 "<p align=\"center\">".get_string("teachertimerwarning", "lesson")."</p>";
-        } else {
-            if ((($timer->starttime + $lesson->maxtime * 60) - time()) > 0) {
-                // code for the clock
-                print_simple_box_start("right", "150px", "#ffffff", 0);
-                echo "<table border=\"0\" valign=\"top\" align=\"center\" class=\"generaltable\" width=\"100%\" cellspacing=\"0\">".
-                    "<tr><th valign=\"top\" class=\"generaltableheader\">".get_string("timeremaining", "lesson").
-                    "</th></tr><tr><td align=\"center\" class=\"generaltablecell\">";
-                echo "<script language=\"javascript\">\n";
-                    echo "var starttime = ". $timer->starttime . ";\n";
-                    echo "var servertime = ". time() . ";\n";
-                    echo "var testlength = ". $lesson->maxtime * 60 .";\n";
-                    echo "document.write('<SCRIPT LANGUAGE=\"JavaScript\" SRC=\"timer.js\"><\/SCRIPT>');\n";
-                    echo "window.onload = function () { show_clock(); }\n";
-                echo "</script>\n";
-                echo "</td></tr></table>";
-                print_simple_box_end();
-                echo "<br /><br /><br /><br />";
-            } else {
-                redirect("view.php?id=$cm->id&action=navigation&pageid=".LESSON_EOL."&outoftime=normal", get_string("outoftime", "lesson"));
-            }
+        
+        if ($lesson->timed) {
             if ((($timer->starttime + $lesson->maxtime * 60) - time()) < 60 && !((($timer->starttime + $lesson->maxtime * 60) - time()) < 0)) {
-                echo "<p align=\"center\">".get_string("studentoneminwarning", "lesson")."</p>";
-            } elseif (($timer->starttime + $lesson->maxtime * 60) < time()) {
-                echo "<p align=\"center\">".get_string("studentoutoftime", "lesson")."</p>";
+                $messages[] = get_string("studentoneminwarning", "lesson");
+            } else if (($timer->starttime + $lesson->maxtime * 60) < time()) {
+                $messages[] = get_string("studentoutoftime", "lesson");
                 $outoftime = true;
             }
+            if ((($timer->starttime + $lesson->maxtime * 60) - time()) <= 0) {
+                // Out of time
+                redirect("view.php?id=$cm->id&action=navigation&pageid=".LESSON_EOL."&outoftime=normal", get_string("outoftime", "lesson"));
+            }
         }
-    }
-    // update the clock
-    if (!isteacher($course->id)) {
+        
         $timer->lessontime = time();
         if (!update_record("lesson_timer", $timer)) {
             error("Error: could not update lesson_timer table");
         }
     }
+    
+    // Inform teacher that s/he will not see the timer
+    if ($lesson->timed and isteacher($course->id)) {
+        $messages[] = get_string("teachertimerwarning", "lesson");
+    }
 
     // record answer (if necessary) and show response (if none say if answer is correct or not)
     $pageid = required_param('pageid', PARAM_INT);
             }
             // no need to record anything in lesson_attempts            
             redirect("view.php?id=$cm->id&amp;action=navigation&amp;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)) {
                 $newpageid = LESSON_EOL;
             }
         }
-    
-        // This calculates and prints the ongoing score message
-        if ($lesson->ongoing) {
-            lesson_print_ongoing_score($lesson);
-        }
 
         // display response (if there is one - there should be!)
         // display: lesson title, page title, question text, student's answer(s) before feedback message
-        if ($response) {
+        
+        if ($noanswer) {
+            $feedback = get_string("noanswer", "lesson");
+        } else if ($response) {
             //optionally display question page title
             //if ($title = get_field("lesson_pages", "title", "id", $pageid)) {
             //    print_heading($title);
             //}
-            echo "<table width=\"80%\" border=\"0\" align=\"center\"><tr><td>\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 "<br /><br />";
                 if ($qattempts == 1) {
-                    print_simple_box(get_string("firstwrong", "lesson"), "center");
+                    $feedback = get_string("firstwrong", "lesson");
                 } else {
-                    print_simple_box(get_string("secondpluswrong", "lesson"), "center");
+                    $feedback = get_string("secondpluswrong", "lesson");
                 }
             } else {
                 if ($correctanswer) {
                 $options = new stdClass;
                 $options->noclean = true;
                 $options->para = false;
-                print_simple_box(format_text($page->contents, FORMAT_MOODLE, $options), 'center');
-                echo '<br />';
-                print_simple_box('<em>'.get_string("youranswer", "lesson").'</em> : '.format_text($studentanswer, FORMAT_MOODLE, $options).
-                                 "<div class=\"$class\">".format_text($response, FORMAT_MOODLE, $options), 'center').'</div>';
+                $feedback = format_text($page->contents, FORMAT_MOODLE, $options);
+                $feedback .= '<em>'.get_string("youranswer", "lesson").'</em> : '.format_text($studentanswer, FORMAT_MOODLE, $options).
+                                 "<div class=\"$class\">".format_text($response, FORMAT_MOODLE, $options).'</div>';
             }
-            echo "</td></tr></table>\n";
         }
     }
 
             $newpageid = lesson_cluster_jump($lesson->id, $USER->id, $pageid);
         }
     }
-
-    // NOTE:  Should this code be coverted from form/javascript to just longer links with the variables in the url?
-    echo "<form name=\"pageform\" method =\"post\" action=\"view.php\">\n";
-    echo "<input type=\"hidden\" name=\"id\" value=\"$cm->id\">\n";
-    echo "<input type=\"hidden\" name=\"action\" value=\"navigation\">\n";
-    echo "<input type=\"hidden\" name=\"pageid\" value=\"$newpageid\">\n";
-
-    if (isset($USER->modattempts[$lesson->id])) {
-        echo "<p align=\"center\">".
-            get_string("savechangesandeol", "lesson")."<br /><br />".
-            "<div align=\"center\" class=\"lessonbutton standardbutton\"><a href=\"javascript:document.pageform.pageid.value=".LESSON_EOL.";document.pageform.submit();\">".
-            get_string("savechanges", "lesson")."</a></div></p>\n";
-        echo "<p align=\"center\">".get_string("or", "lesson")."<br /><br />".
-            get_string("continuetoanswer", "lesson")."</p>\n";
-    }
-
-    if ($lesson->review && !$correctanswer && !$noanswer && !$isessayquestion) {
-        echo "<p><div align=\"center\" class=\"lessonbutton standardbutton\"><a href=\"javascript:document.pageform.pageid.value=$pageid;document.pageform.submit();\">".
-            get_string("reviewquestionback", "lesson")."</a></div></p>\n";
-        echo "<p><div align=\"center\" class=\"lessonbutton standardbutton\"><a href=\"javascript:document.pageform.submit();\">".
-            get_string("reviewquestioncontinue", "lesson")."</a></div></p>\n";
-    } else {
-        echo "<p><div align=\"center\" class=\"lessonbutton standardbutton\"><a href=\"javascript:document.pageform.submit();\">".
-            get_string("continue", "lesson")."</a></div></p>\n";
-    }
-    echo "</form>\n";
     
-/// Report attempts remaining
+    // Report attempts remaining
     if ($attemptsremaining != 0) {
-        echo "<p align=\"center\">".get_string('attemptsremaining', 'lesson', $attemptsremaining);
-    }
-/// Report if max attempts reached
-    if ($maxattemptsreached != 0) {
-        echo "<p align=\"center\">(".get_string("maximumnumberofattemptsreached", "lesson").")</p>\n";
+        $messages[] = get_string('attemptsremaining', 'lesson', $attemptsremaining);
     }
-
-    if ($lesson->displayleft) {
-        echo "</td></tr></table>";
+    // Report if max attempts reached
+    if ($maxattemptsreached != 0) { 
+        $messages[] = '('.get_string("maximumnumberofattemptsreached", "lesson").')';
     }
     
+    lesson_print_header($cm, $course, $lesson, 'navigation', false);
+    
+    include($CFG->wwwroot.'/mod/lesson/action/continue.html');
 ?>
index 23fa1b84bd98e62b578fdce1b11e2dfef8d10356..2e29da39ce1389e6ad0c6a62561138675c5f8324 100644 (file)
@@ -1,11 +1,6 @@
-<?php
+<?php // $Id$
 
 /******************* delete ************************************/
-
-     if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     confirm_sesskey();
 
     $pageid = required_param('pageid', PARAM_INT);
@@ -13,7 +8,6 @@
         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...
index 5cb772fc67d44131980bcec7af733ed3378c07e2..9344c1360a4d41479ee1761758819bc4d4f6b443 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php // $Id$
 
 /************** edit page ************************************/
 
-    if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     // get the page
     $pageid = required_param('pageid', PARAM_INT);
     $redirect = optional_param('redirect', '', PARAM_ALPHA);
index 9643b80b69644b3fb3a70aa518a0182eed6e2391..af9e2464bbc018aec081184716f2f3e774a5e1d1 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php // $Id$
 
 /****************** insert page ************************************/
         
-    if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     confirm_sesskey();
 
     // check to see if the cancel button was pushed
index 270ac8cb9e7882fec965ff3e5bf039e07ba62690..832ef2d3f36c0b4b176169bba808dc41ffa4f2fa 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php // $Id$
 
 /****************** move ************************************/
    
-    if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     $pageid = required_param('pageid', PARAM_INT);
     $title = get_field("lesson_pages", "title", "id", $pageid);
     print_heading(get_string("moving", "lesson", format_string($title)));
index 7b0a67d8371159008263995f357b156d652f67ac..2eaf851725f42574ff84f345a18f5cc4b5b99914 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php // $Id$
 
 /****************** moveit ************************************/
    
-    if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     confirm_sesskey();
 
     $pageid = required_param('pageid', PARAM_INT); //  page to move
@@ -14,8 +10,6 @@
     }
     $after = required_param('after', PARAM_INT); // target page
 
-    print_heading(get_string("moving", "lesson", format_string($page->title)));
-    
     // first step. determine the new first page
     // (this is done first as the current first page will be lost in the next step)
     if (!$after) {
index e0376bb9e82ca80dc94f9a0f87f8f1ae88b33e16..2a7da3c58253f1bc8a5589f4fecb114e95f4952a 100644 (file)
@@ -1,11 +1,7 @@
-<?php
+<?php // $Id$
 
 /****************** update page ************************************/
     
-    if (!isteacher($course->id)) {
-        error("Only teachers can look at this page");
-    }
-
     confirm_sesskey();
     
     $redirect = optional_param('redirect', '', PARAM_ALPHA);
index c5bd8fae5e7cfd6ca15ddda821b64a8feb4d23c0..a930ef46bcad3e2bc12731c9fb958db90cb6434d 100644 (file)
     
     $id     = required_param('id', PARAM_INT);         // Course Module ID
     $action = required_param('action', PARAM_ALPHA);   // Action
-    // get some esential stuff...
-    if (! $cm = get_coursemodule_from_id('lesson', $id)) {
-        error("Course Module ID was incorrect");
-    }
-
-    if (! $course = get_record("course", "id", $cm->course)) {
-        error("Course is misconfigured");
-    }
-
-    if (! $lesson = get_record("lesson", "id", $cm->instance)) {
-        error("Course module is incorrect");
-    }
+    
+    list($cm, $course, $lesson) = lesson_get_basics($id);
 
     require_login($course->id);
     
-    if ($action != 'continue') {
-        // All pages except for continue.php require teacher editing privs
-        if (!isteacheredit($lesson->course)) {
-            error('You must be a teacher with editing privileges to access this page.');
-        }
-    }
-    
-    // set up some general variables
+/// Set up some general variables
     $usehtmleditor = can_use_html_editor();
     
-    $navigation = "";
-    if ($course->category) {
-        $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
-    }
-
-    $strlessons = get_string("modulenameplural", "lesson");
-    $strlesson  = get_string("modulename", "lesson");
-    $strlessonname = $lesson->name;
-    
-    // ... print the header and...
-    print_header("$course->shortname: ".format_string($lesson->name), "$course->fullname",
-                 "$navigation <a href=index.php?id=$course->id>$strlessons</a> -> 
-                  <a href=\"view.php?id=$cm->id\">".format_string($lesson->name,true)."</a>", "", "", true);
-
-    if ($action == 'continue' and isteacher($course->id)) {
-        $currenttab = 'navigation';
-        include('tabs.php');
-    }
-
-    // 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");
+/// Process the action
+    switch ($action) {
+        case 'addbranchtable':
+        case 'addpage':
+        case 'confirmdelete':
+        case 'editpage':
+        case 'move':
+            lesson_print_header($cm, $course, $lesson, '', false);
+        case 'addcluster':
+        case 'addendofbranch':
+        case 'addendofcluster':
+        case 'delete':
+        case 'insertpage':
+        case 'updatepage':
+        case 'moveit':
+            if (!isteacheredit($course->id)) {
+                error('You must be a teacher with editing privileges to access this page.');
+            }
+        case 'continue':
+            include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php');
+            break;
+        default:
+            error("Fatal Error: Unknown action\n");
     }
 
     print_footer($course);