]> git.mjollnir.org Git - moodle.git/commitdiff
lesson: MDL-19890 Fix block-printing code in lesson (I hope)
authortjhunt <tjhunt>
Thu, 23 Jul 2009 10:01:19 +0000 (10:01 +0000)
committertjhunt <tjhunt>
Thu, 23 Jul 2009 10:01:19 +0000 (10:01 +0000)
This got broken by one of the commits for MDL-19077 & MDL-19010

lib/ajax/ajaxlib.php
mod/lesson/action/continue.html
mod/lesson/action/continue.php
mod/lesson/locallib.php
mod/lesson/view.php
mod/lesson/viewend.html [deleted file]
mod/lesson/viewstart.html [deleted file]

index 6e85b521fcc2242fabe65d8f4ada0a30c547caf7..00d7f87b265bf0319db74b177ac7f25b019aaa62 100644 (file)
@@ -616,12 +616,27 @@ class required_js extends linked_requirement {
      * is responsible for outputting this HTML promptly.
      */
     public function asap() {
-        if ($this->is_done()) {
-            return;
-        }
         if (!$this->manager->is_head_done()) {
             $this->in_head();
             return '';
+        } else {
+            return $this->now();
+        }
+    }
+
+    /**
+     * Return the required JavaScript immediately, so it can be included in some
+     * HTML that is being built.
+     *
+     * This is not really recommeneded. But is necessary in some legacy code that
+     * includes a .js files that does document.write.
+     *
+     * @return string The HTML for the script tag. The caller
+     * is responsible for making sure it is output.
+     */
+    public function now() {
+        if ($this->is_done()) {
+            return '';
         }
         $output = $this->get_html();
         $this->mark_done();
index 8fd055055a66252396924e2cf5f0d8cee22f7fbc..1f78ba6d903ba67770fa9e68add0130768b59afd 100644 (file)
@@ -7,26 +7,6 @@
  **/
 ?>
 
-<!-- Primary layout table -->
-<table id="layout-table" cellpadding="0" cellspacing="0">
-    <tr>
-        <!-- First Column -->
-        <?php if (lesson_blocks_have_content($lesson, $pageblocks, BLOCK_POS_LEFT)) { ?>
-        <td id="left-column" style="width: <?php echo $leftcolumnwidth; ?>px;">
-            <?php
-                lesson_print_menu_block($cm->id, $lesson);
-
-                if (!empty($CFG->showblocksonmodpages)) {
-                    if ((blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
-                        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-                    }
-                }
-            ?>
-        </td>
-        <?php } ?>
-        <!-- Start Primary column -->
-        <td id="middle-column">
-    
 <?php if ($lesson->displayleft) { // Skip navigation anchor ?>
         
         <a name="maincontent" id="maincontent" title="<?php print_string('anchortitle', 'lesson') ?>"></a>
 <?php } ?>
 
             </form>
-        </td>
-        <!-- End primary column -->
-        <?php if (lesson_blocks_have_content($lesson, $pageblocks, BLOCK_POS_RIGHT)) { ?>
-        <td id="right-column" style="width: <?php echo $rightcolumnwidth; ?>px;">
-            <!-- Third column -->
-            <?php
-                lesson_print_clock_block($cm->id, $lesson, $timer);
-                lesson_print_mediafile_block($cm->id, $lesson);
-
-                if (!empty($CFG->showblocksonmodpages)) {
-                    if ((blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing())) {
-                        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-                    }
-                }
-            ?>
-        </td>
-        <?php } ?>
-    </tr>
-</table>
-<!-- End primary layout table -->
\ No newline at end of file
index afa2ed2e01a1ebc9c6513a01b27e97a58505196a..6bfe5d63024ee15d09d4242f0c17039e4019dc85 100644 (file)
                 $options = new stdClass;
                 $options->noclean = true;
                 $options->para = true;
-                $feedback = print_simple_box(format_text($page->contents, FORMAT_MOODLE, $options), 'center', '', '', 5, 'generalbox', '', true);
+                $feedback = print_box(format_text($page->contents, FORMAT_MOODLE, $options), 'generalbox boxaligncenter', '', true);
                 $feedback .= '<em>'.get_string("youranswer", "lesson").'</em> : '.format_text($studentanswer, FORMAT_MOODLE, $options).
                                  "<div class=\"$class\">".format_text($response, FORMAT_MOODLE, $options).'</div>';
             }
 
     $PAGE->set_url('mod/lesson/view.php', array('id' => $cm->id, 'pageid' => $page->id));
     $PAGE->set_subpage($page->id);
-    $pageblocks = blocks_setup($PAGE);
-
-    $leftcolumnwidth  = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), 210);
-    $rightcolumnwidth = bounded_number(180, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), 210);
 
 /// Print the header, heading and tabs
+    lesson_add_pretend_blocks($PAGE, $cm, $lesson, $timer);
     lesson_print_header($cm, $course, $lesson, 'view', true, $page->id);
 
     include(dirname(__FILE__).'/continue.html');
index c133b47fe4115ecda4a5a19142c6ed38866f14be..bd3632225d10ab7dfcffe6d895024acc1bf3d142 100644 (file)
@@ -230,19 +230,16 @@ if (!defined("LESSON_RESPONSE_EDITOR")) {
 function lesson_print_header($cm, $course, $lesson, $currenttab = '', $extraeditbuttons = false, $lessonpageid = NULL) {
     global $CFG, $PAGE;
 
-    // Note: MDL-19010 there will be further changes to printing header and blocks.
-    // The code will be much nicer than this eventually.
-    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     $activityname = format_string($lesson->name, true, $course->id);
-    $strlesson = get_string('modulename', 'lesson');
 
     if (empty($title)) {
         $title = "{$course->shortname}: $activityname";
     }
 
 /// Build the buttons
+    $context = get_context_instance(CONTEXT_MODULE, $cm->id);
     if (has_capability('mod/lesson:edit', $context)) {
-        $buttons = update_module_button($cm->id, $course->id, $strlesson);
+        $buttons = update_module_button($cm->id, $course->id, get_string('modulename', 'lesson'));
         if ($extraeditbuttons) {
             if ($lessonpageid === NULL) {
                 print_error('invalidpageid', 'lesson');
@@ -255,20 +252,6 @@ function lesson_print_header($cm, $course, $lesson, $currenttab = '', $extraedit
                             '<input type="hidden" name="pageid" value="'.$lessonpageid.'" />'.
                             '<input type="submit" value="'.get_string('editpagecontent', 'lesson').'" />'.
                             '</form>';
-
-                if (!empty($CFG->showblocksonmodpages) and $PAGE->user_allowed_editing()) {
-                    if ($PAGE->user_is_editing()) {
-                        $onoff = 'off';
-                    } else {
-                        $onoff = 'on';
-                    }
-                    $buttons .= '<form '.$CFG->frametarget.' method="get" action="'.$CFG->wwwroot.'/mod/lesson/view.php">'.
-                                '<input type="hidden" name="id" value="'.$cm->id.'" />'.
-                                '<input type="hidden" name="pageid" value="'.$lessonpageid.'" />'.
-                                '<input type="hidden" name="edit" value="'.$onoff.'" />'.
-                                '<input type="submit" value="'.get_string("blocksedit$onoff").'" />
-                                </form>';
-                }
             }
             $buttons = '<span class="edit_buttons">' . $buttons  .'</span>';
         }
@@ -1734,54 +1717,93 @@ function lesson_displayleftif($lesson) {
     return $lesson->displayleft;
 }
 
+/**
+ * 
+ * @param $cm
+ * @param $lesson
+ * @param $page
+ * @return unknown_type
+ */
+function lesson_add_pretend_blocks($page, $cm, $lesson, $timer = null) {
+    $bc = lesson_menu_block_contents($cm->id, $lesson);
+    if (!empty($bc)) {
+        $regions = $page->blocks->get_regions();
+        $firstregion = reset($regions);
+        $page->blocks->add_pretend_block($bc, $firstregion);
+    }
+
+    $bc = lesson_mediafile_block_contents($cm->id, $lesson);
+    if (!empty($bc)) {
+        $page->blocks->add_pretend_block($bc, $page->blocks->get_default_region());
+    }
+
+    if (!empty($timer)) {
+        $bc = lesson_clock_block_contents($cm->id, $lesson, $timer, $page);
+        if (!empty($bc)) {
+            $page->blocks->add_pretend_block($bc, $page->blocks->get_default_region());
+        }
+    }
+}
+
 /**
  * If there is a media file associated with this 
- * lesson, then print it in a block.
+ * lesson, return a block_contents that displays it.
  *
  * @param int $cmid Course Module ID for this lesson
  * @param object $lesson Full lesson record object
- * @return void
+ * @return block_contents
  **/
-function lesson_print_mediafile_block($cmid, $lesson) {
-    if (!empty($lesson->mediafile)) {
-        $url      = '/mod/lesson/mediafile.php?id='.$cmid;
-        $options  = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. $lesson->mediawidth .',height='. $lesson->mediaheight;
-        $name     = 'lessonmediafile';
-
-        $content  = link_to_popup_window ($url, $name, get_string('mediafilepopup', 'lesson'), '', '', get_string('mediafilepopup', 'lesson'), $options, true);
-        $content .= helpbutton("mediafilestudent", get_string("mediafile", "lesson"), "lesson", true, false, '', true);
-        
-        print_side_block(get_string('linkedmedia', 'lesson'), $content, NULL, NULL, '', array('class' => 'mediafile'), get_string('linkedmedia', 'lesson'));
+function lesson_mediafile_block_contents($cmid, $lesson) {
+    if (empty($lesson->mediafile)) {
+        return null;
     }
+
+    $url      = '/mod/lesson/mediafile.php?id='.$cmid;
+    $options  = 'menubar=0,location=0,left=5,top=5,scrollbars,resizable,width='. $lesson->mediawidth .',height='. $lesson->mediaheight;
+    $name     = 'lessonmediafile';
+
+    $content  = link_to_popup_window ($url, $name, get_string('mediafilepopup', 'lesson'), '', '', get_string('mediafilepopup', 'lesson'), $options, true);
+    $content .= helpbutton("mediafilestudent", get_string("mediafile", "lesson"), "lesson", true, false, '', true);
+
+    $bc = new block_contents();
+    $bc->title = get_string('linkedmedia', 'lesson');
+    $bc->set_classes('mediafile');
+    $bc->content = $content;
+
+    return $bc;
 }
 
 /**
  * If a timed lesson and not a teacher, then
- * print the clock
+ * return a block_contents containing the clock.
  *
  * @param int $cmid Course Module ID for this lesson
  * @param object $lesson Full lesson record object
  * @param object $timer Full timer record object
- * @return void
+ * @return block_contents
  **/
-function lesson_print_clock_block($cmid, $lesson, $timer) {
-    global $CFG, $PAGE;
-
+function lesson_clock_block_contents($cmid, $lesson, $timer, $page) {
+    // Display for timed lessons and for students only
     $context = get_context_instance(CONTEXT_MODULE, $cmid);
+    if(!$lesson->timed || has_capability('mod/lesson:manage', $context)) {
+        return null;
+    }
 
-    // Display for timed lessons and for students only
-    if($lesson->timed and !has_capability('mod/lesson:manage', $context) and !empty($timer)) {
+    $content = '<div class="jshidewhenenabled">';
+    $content .= lesson_print_time_remaining($timer->starttime, $lesson->maxtime, true)."\n";
+    $content .= '</div>';
 
-        $clocksettings = Array('starttime'=>$timer->starttime, 'servertime'=>time(),'testlength'=>($lesson->maxtime * 60));
-        $content = $PAGE->requires->data_for_js('clocksettings', $clocksettings)->asap();
-        $content .= $PAGE->requires->js('mod/lesson/timer.js')->asap();
-        $content .= $PAGE->requires->js_function_call('show_clock')->asap();
-        $content .= '<div class="jshidewhenenabled">';
-        $content .= lesson_print_time_remaining($timer->starttime, $lesson->maxtime, true)."\n";
-        $content .= '</div>';
+    $clocksettings = array('starttime'=>$timer->starttime, 'servertime'=>time(),'testlength'=>($lesson->maxtime * 60));
+    $content .= $page->requires->data_for_js('clocksettings', $clocksettings)->now();
+    $content .= $page->requires->js('mod/lesson/timer.js')->now();
+    $content .= $page->requires->js_function_call('show_clock')->now();
 
-        print_side_block(get_string('timeremaining', 'lesson'), $content, NULL, NULL, '', array('class' => 'clock'), get_string('timeremaining', 'lesson'));
-    }
+    $bc = new block_contents();
+    $bc->title = get_string('timeremaining', 'lesson');
+    $bc->set_classes('clock');
+    $bc->content = $content;
+
+    return $bc;
 }
 
 /**
@@ -1792,77 +1814,44 @@ function lesson_print_clock_block($cmid, $lesson, $timer) {
  * @param object $lesson Full lesson record object
  * @return void
  **/
-function lesson_print_menu_block($cmid, $lesson) {
+function lesson_menu_block_contents($cmid, $lesson) {
     global $CFG, $DB;
 
-    if ($lesson->displayleft) {
-        $pageid = $DB->get_field('lesson_pages', 'id', array('lessonid' => $lesson->id, 'prevpageid' => 0));
-        $params = array ("lessonid" => $lesson->id);
-        $pages  = $DB->get_records_select('lesson_pages', "lessonid = :lessonid", $params);
-        $currentpageid = optional_param('pageid', $pageid, PARAM_INT);
-
-        if ($pageid and $pages) {
-            $content = '<a href="#maincontent" class="skip">'.get_string('skip', 'lesson')."</a>\n<div class=\"menuwrapper\">\n<ul>\n";
+    if (!$lesson->displayleft) {
+        return null;
+    }
 
-            while ($pageid != 0) {
-                $page = $pages[$pageid];
+    $pageid = $DB->get_field('lesson_pages', 'id', array('lessonid' => $lesson->id, 'prevpageid' => 0));
+    $params = array ("lessonid" => $lesson->id);
+    $pages  = $DB->get_records_select('lesson_pages', "lessonid = :lessonid", $params);
+    $currentpageid = optional_param('pageid', $pageid, PARAM_INT);
 
-                // Only process branch tables with display turned on
-                if ($page->qtype == LESSON_BRANCHTABLE and $page->display) {
-                    if ($page->id == $currentpageid) { 
-                        $content .= '<li class="selected">'.format_string($page->title,true)."</a></li>\n";
-                    } else {
-                        $content .= "<li class=\"notselected\"><a href=\"$CFG->wwwroot/mod/lesson/view.php?id=$cmid&amp;pageid=$page->id\">".format_string($page->title,true)."</a></li>\n";
-                    }
-                    
-                }
-                $pageid = $page->nextpageid;
-            }
-            $content .= "</ul>\n</div>\n";
-            print_side_block(get_string('lessonmenu', 'lesson'), $content, NULL, NULL, '', array('class' => 'menu'), get_string('lessonmenu', 'lesson'));
-        }
+    if (!$pageid || !$pages) {
+        return null;
     }
-}
 
-/**
- * This is not ideal, but checks to see if a
- * column has "block" content.
- *
- * In the future, it would be nice if the lesson
- * media file, timer and navigation were blocks
- * then this would be unnecessary.
- *
- * @uses $CFG
- * @uses $PAGE
- * @param object $lesson Full lesson record object
- * @param array $pageblocks An array of block instances organized by left and right columns
- * @param string $column Pass either BLOCK_POS_RIGHT or BLOCK_POS_LEFT constants
- * @return boolean
- **/
-function lesson_blocks_have_content($lesson, $pageblocks, $column) {
-    global $CFG, $PAGE;
+    $content = '<a href="#maincontent" class="skip">'.get_string('skip', 'lesson')."</a>\n<div class=\"menuwrapper\">\n<ul>\n";
 
-    // First check lesson conditions
-    if ($column == BLOCK_POS_RIGHT) {
-        $managecap = false;
-        if ($cm = get_coursemodule_from_instance('lesson', $lesson->id, $lesson->course)) {
-            $managecap = has_capability('mod/lesson:manage', get_context_instance(CONTEXT_MODULE, $cm->id));
-        }
-        if (($lesson->timed and !$managecap) or !empty($lesson->mediafile)) {
-            return true;
-        }
-    } else if ($column == BLOCK_POS_LEFT) {
-        if ($lesson->displayleft) {
-            return true;
-        }
-    }
-    if (!empty($CFG->showblocksonmodpages)) {
-        if ((blocks_have_content($pageblocks, $column) || $PAGE->user_is_editing())) {
-            return true;
+    while ($pageid != 0) {
+        $page = $pages[$pageid];
+
+        // Only process branch tables with display turned on
+        if ($page->qtype == LESSON_BRANCHTABLE and $page->display) {
+            if ($page->id == $currentpageid) { 
+                $content .= '<li class="selected">'.format_string($page->title,true)."</li>\n";
+            } else {
+                $content .= "<li class=\"notselected\"><a href=\"$CFG->wwwroot/mod/lesson/view.php?id=$cmid&amp;pageid=$page->id\">".format_string($page->title,true)."</a></li>\n";
+            }
+            
         }
+        $pageid = $page->nextpageid;
     }
+    $content .= "</ul>\n</div>\n";
 
-    return false;
-}
+    $bc = new block_contents();
+    $bc->title = get_string('lessonmenu', 'lesson');
+    $bc->set_classes('menu');
+    $bc->content = $content;
 
-?>
+    return $bc;
+}
index b882bf7a94f8fa952569b7a38adb0e1b1a06feaa..659ecf3422b1fa1fb94b7bb357a542eb54efaabe 100644 (file)
             }
             
             lesson_print_header($cm, $course, $lesson);
-            print_simple_box_start('center');
+            print_box_start('generalbox boxaligncenter');
             echo '<div style="text-align:center;">';
             echo '<p>'.$message.'</p>';
             echo '<div class="lessonbutton standardbutton" style="padding: 5px;"><a href="'.$CFG->wwwroot.'/course/view.php?id='. $course->id .'">'. get_string('returnto', 'lesson', format_string($course->fullname, true)) .'</a></div>';
             echo '</div>';
-            print_simple_box_end();
+            print_box_end();
             print_footer($course);
             exit();
         
@@ -65,7 +65,7 @@
             if (!$correctpass) {
                 lesson_print_header($cm, $course, $lesson);
                 echo "<div class=\"password-form\">\n";
-                print_simple_box_start('center');
+                print_box_start('generalbox boxaligncenter');
                 echo '<form id="password" method="post" action="'.$CFG->wwwroot.'/mod/lesson/view.php" autocomplete="off">' . "\n";
                 echo '<fieldset class="invisiblefieldset">';
                 echo '<input type="hidden" name="id" value="'. $cm->id .'" />' . "\n";
@@ -79,7 +79,7 @@
 
                 lesson_print_submit_link(get_string('continue', 'lesson'), 'password', 'center', 'standardbutton submitbutton');
                 echo '</fieldset></form>';
-                print_simple_box_end();
+                print_box_end();
                 echo "</div>\n";
                 print_footer($course);
                 exit();
                 if (!empty($errors)) {  // print out the errors if any
                     lesson_print_header($cm, $course, $lesson);
                     echo '<p>';
-                    print_simple_box_start('center');
+                    print_box_start('generalbox boxaligncenter');
                     print_string('completethefollowingconditions', 'lesson', $dependentlesson->name);
                     echo '<p style="text-align:center;">'.implode('<br />'.get_string('and', 'lesson').'<br />', $errors).'</p>';
-                    print_simple_box_end();
+                    print_box_end();
                     echo '</p>';
                     print_footer($course);
                     exit();
             lesson_print_header($cm, $course, $lesson);
             if ($lesson->timed) {
                 if ($lesson->retake) {
-                    print_simple_box('<p style="text-align:center;">'. get_string('leftduringtimed', 'lesson') .'</p>', 'center');
+                    print_box('<p style="text-align:center;">'. get_string('leftduringtimed', 'lesson') .'</p>', 'generalbox boxaligncenter');
                     echo '<div style="text-align:center;" class="lessonbutton standardbutton">'.
                               '<a href="view.php?id='.$cm->id.'&amp;pageid='.$firstpageid.'&amp;startlastseen=no">'.
                                 get_string('continue', 'lesson').'</a></div>';
                 } else {
-                    print_simple_box_start('center');
+                    print_box_start('generalbox boxaligncenter');
                     echo '<div style="text-align:center;">';
                     echo get_string('leftduringtimednoretake', 'lesson');
                     echo '<br /><br /><div class="lessonbutton standardbutton"><a href="../../course/view.php?id='. $course->id .'">'. get_string('returntocourse', 'lesson') .'</a></div>';
                     echo '</div>';
-                    print_simple_box_end();
+                    print_box_end();
                 }
                 
             } else {
-                print_simple_box("<p style=\"text-align:center;\">".get_string('youhaveseen','lesson').'</p>',
-                        "center");
+                print_box("<p style=\"text-align:center;\">".get_string('youhaveseen','lesson').'</p>',
+                        'generalbox boxaligncenter');
                 
                 echo '<div style="text-align:center;">';
                 echo '<span class="lessonbutton standardbutton">'.
             }
             if (!$lesson->retake) {
                 lesson_print_header($cm, $course, $lesson, 'view');
-                print_simple_box_start('center');
+                print_box_start('generalbox boxaligncenter');
                 echo "<div style=\"text-align:center;\">";
                 echo get_string("noretake", "lesson");
                 echo "<br /><br /><div class=\"lessonbutton standardbutton\"><a href=\"../../course/view.php?id=$course->id\">".get_string('returntocourse', 'lesson').'</a></div>';
                 echo "</div>";
-                print_simple_box_end();
+                print_box_end();
                 print_footer($course);
                 exit();
                   //redirect("../../course/view.php?id=$course->id", get_string("alreadytaken", "lesson"));
         }
 
     /// Print the page header, heading and tabs
+        lesson_add_pretend_blocks($PAGE, $cm, $lesson, $timer);
         lesson_print_header($cm, $course, $lesson, 'view', 'true', $page->id);
 
         if ($attemptflag) {
             lesson_print_ongoing_score($lesson);
         }
 
-        require($CFG->dirroot.'/mod/lesson/viewstart.html');
+        if ($lesson->displayleft) {
+            echo '<a name="maincontent" id="maincontent" title="' . get_string('anchortitle', 'lesson') . '"></a>';
+        }
+
+        if ($lesson->slideshow && $page->qtype == LESSON_BRANCHTABLE) { // Starts the slideshow div
+            echo '<div class="slideshow" style="background-color: ' . $lesson->bgcolor .
+                    '; height: ' . $lesson->height . 'px; width: ' . $lesson->width . 'px;">';
+        }
 
         // now starting to print the page's contents   
         if ($page->qtype == LESSON_BRANCHTABLE) {
         if (!$lesson->slideshow) {
             $options = new stdClass;
             $options->noclean = true;
-            print_simple_box('<div class="contents">'.
+            print_box('<div class="contents">'.
                             format_text($page->contents, FORMAT_MOODLE, $options).
-                            '</div>', 'center');
+                            '</div>', 'generalbox boxaligncenter');
         }
         
         // this is for modattempts option.  Find the users previous answer to this page,
                 echo "<input type=\"hidden\" name=\"action\" value=\"continue\" />";
                 echo "<input type=\"hidden\" name=\"pageid\" value=\"$pageid\" />";
                 echo "<input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />";
-                print_simple_box_start("center");
+                print_box_start('generalbox boxaligncenter');
                 echo '<table width="100%">';
             }
             // default format text options
                     echo '<tr><td style="text-align:center;"><label for="answer">'.get_string('youranswer', 'lesson').'</label>'.
                         ": <input type=\"text\" id=\"answer\" name=\"answer\" size=\"50\" maxlength=\"200\" $value />\n";
                     echo '</td></tr></table>';
-                    print_simple_box_end();
+                    print_box_end();
                     lesson_print_submit_link(get_string('pleaseenteryouranswerinthebox', 'lesson'), 'answerform');
                     break;
                 case LESSON_TRUEFALSE :
                         $i++;
                     }
                     echo '</table>';
-                    print_simple_box_end();
+                    print_box_end();
                     lesson_print_submit_link(get_string('pleasecheckoneanswer', 'lesson'), 'answerform');
                     break;
                 case LESSON_MULTICHOICE :
                         $i++;
                     }
                     echo '</table>';
-                    print_simple_box_end();
+                    print_box_end();
                     if ($page->qoption) {
                         $linkname = get_string('pleasecheckoneormoreanswers', 'lesson');
                     } else {
                         }
                     }
                     echo '</table>';
-                    print_simple_box_end();
+                    print_box_end();
                     lesson_print_submit_link(get_string('pleasematchtheabovepairs', 'lesson'), 'answerform');
                     break;
                 case LESSON_BRANCHTABLE :                  
                     echo '<tr><td style="text-align:center;" valign="top" nowrap="nowrap"><label for="answer">'.get_string("youranswer", "lesson").'</label>:</td><td>'.
                          '<textarea id="answer" name="answer" rows="15" cols="60">'.$value."</textarea>\n";
                     echo '</td></tr></table>';
-                    print_simple_box_end();
+                    print_box_end();
                     lesson_print_submit_link(get_string('pleaseenteryouranswerinthebox', 'lesson'), 'answerform');
                     break;
                 default: // close the tags MDL-7861
                     echo ('</table>');
-                    print_simple_box_end();
+                    print_box_end();
                 break;
             }
             if ($page->qtype != LESSON_BRANCHTABLE) {  // To fix XHTML problem (BT have their own forms)
         
         // Finish of the page
         lesson_print_progress_bar($lesson, $course);
-        require($CFG->dirroot.'/mod/lesson/viewend.html');
+
     } else {
         // end of lesson reached work out grade
         
             
             $DB->update_record("lesson_timer", $timer);
         }
-        
+
         add_to_log($course->id, "lesson", "end", "view.php?id=$cm->id", "$lesson->id", $cm->id);
-        
+
+        lesson_add_pretend_blocks($PAGE, $cm, $lesson, $timer);
         lesson_print_header($cm, $course, $lesson, 'view');
         print_heading(get_string("congratulations", "lesson"));
-        print_simple_box_start("center");
+        print_box_start('generalbox boxaligncenter');
         $ntries = $DB->count_records("lesson_grades", array("lessonid"=>$lesson->id, "userid"=>$USER->id));
         if (isset($USER->modattempts[$lesson->id])) {
             $ntries--;  // need to look at the old attempts :)
             // display for teacher
             echo "<p style=\"text-align:center;\">".get_string("displayofgrade", "lesson")."</p>\n";
         }
-        print_simple_box_end(); //End of Lesson button to Continue.
+        print_box_end(); //End of Lesson button to Continue.
 
         // after all the grade processing, check to see if "Show Grades" is off for the course
         // if yes, redirect to the course page
diff --git a/mod/lesson/viewend.html b/mod/lesson/viewend.html
deleted file mode 100644 (file)
index f276096..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php  // $Id$
-/**
- * End of the HTML template for viewing pages
- *
- * @version $Id$
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package lesson
- **/
-?>
-<!-- Start view end -->
-        </td>
-        <?php if (lesson_blocks_have_content($lesson, $pageblocks, BLOCK_POS_RIGHT)) { ?>
-        <td id="right-column" style="width: <?php echo $rightcolumnwidth; ?>px;">
-            <?php
-                lesson_print_clock_block($cm->id, $lesson, $timer);
-                lesson_print_mediafile_block($cm->id, $lesson);
-
-                if (!empty($CFG->showblocksonmodpages)) {
-                    if ((blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $PAGE->user_is_editing())) {
-                        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
-                    }
-                }
-            ?>
-        </td>
-        <?php } ?>
-    </tr>
-</table>
-<!-- End view end -->
\ No newline at end of file
diff --git a/mod/lesson/viewstart.html b/mod/lesson/viewstart.html
deleted file mode 100644 (file)
index d9286e9..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php  // $Id$
-/**
- * Start of the HTML template for viewing pages
- *
- * @version $Id$
- * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
- * @package lesson
- **/
-?>
-<!-- Start view start -->
-<table id="layout-table" cellpadding="0" cellspacing="0">
-    <tr>
-        <!-- First Column -->
-        <?php if (lesson_blocks_have_content($lesson, $pageblocks, BLOCK_POS_LEFT)) { ?>
-        <td id="left-column" style="width: <?php echo $leftcolumnwidth; ?>px;">
-            <?php
-                lesson_print_menu_block($cm->id, $lesson);
-
-                if (!empty($CFG->showblocksonmodpages)) {
-                    if ((blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing())) {
-                        blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
-                    }
-                }
-            ?>
-        </td>
-        <?php } ?>
-        <!-- Start main column -->
-        <td id="middle-column" align="center">
-
-            <?php if ($lesson->displayleft) { ?>
-
-            <a name="maincontent" id="maincontent" title="<?php print_string('anchortitle', 'lesson') ?>"></a>
-
-            <?php } ?>
-
-<?php if ($lesson->slideshow && $page->qtype == LESSON_BRANCHTABLE) { // Starts the slideshow div ?>
-
-            <div class="slideshow" style="background-color: <?php echo $lesson->bgcolor?>; height: <?php echo $lesson->height ?>px; width: <?php echo $lesson->width?>px;">
-
-<?php } ?>
-<!-- End view start -->
\ No newline at end of file