From: tjhunt
Date: Thu, 23 Jul 2009 10:01:19 +0000 (+0000)
Subject: lesson: MDL-19890 Fix block-printing code in lesson (I hope)
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=4262a2f8062c557e41d8cc5f2116cf64e2c3364c;p=moodle.git
lesson: MDL-19890 Fix block-printing code in lesson (I hope)
This got broken by one of the commits for MDL-19077 & MDL-19010
---
diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php
index 6e85b521fc..00d7f87b26 100644
--- a/lib/ajax/ajaxlib.php
+++ b/lib/ajax/ajaxlib.php
@@ -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();
diff --git a/mod/lesson/action/continue.html b/mod/lesson/action/continue.html
index 8fd055055a..1f78ba6d90 100644
--- a/mod/lesson/action/continue.html
+++ b/mod/lesson/action/continue.html
@@ -7,26 +7,6 @@
**/
?>
-
-
\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 = ''.get_string('skip', 'lesson')."\n
\n
\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 .= '
\n";
print_footer($course);
exit();
@@ -147,10 +147,10 @@
if (!empty($errors)) { // print out the errors if any
lesson_print_header($cm, $course, $lesson);
echo '
';
- print_simple_box_end();
+ print_box_end();
lesson_print_submit_link(get_string('pleaseenteryouranswerinthebox', 'lesson'), 'answerform');
break;
default: // close the tags MDL-7861
echo ('');
- print_simple_box_end();
+ print_box_end();
break;
}
if ($page->qtype != LESSON_BRANCHTABLE) { // To fix XHTML problem (BT have their own forms)
@@ -813,7 +821,7 @@
// 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
@@ -833,12 +841,13 @@
$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 :)
@@ -920,7 +929,7 @@
// display for teacher
echo "
".get_string("displayofgrade", "lesson")."
\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
index f2760960a2..0000000000
--- a/mod/lesson/viewend.html
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-