From 7c4078cc22ebc75df26e76eb3464c63d35b9932c Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sun, 25 Jul 2010 09:56:21 +0000 Subject: [PATCH] MDL-23485 added missing handling of empty branches --- mod/lesson/pagetypes/branchtable.php | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/mod/lesson/pagetypes/branchtable.php b/mod/lesson/pagetypes/branchtable.php index 0ec8ae36ed2..ad55965b68a 100644 --- a/mod/lesson/pagetypes/branchtable.php +++ b/mod/lesson/pagetypes/branchtable.php @@ -45,6 +45,28 @@ class lesson_page_type_branchtable extends lesson_page { } return $this->string; } + + /** + * Gets an array of the jumps used by the answers of this page + * + * @return array + */ + public function get_jumps() { + global $DB; + $jumps = array(); + $params = array ("lessonid" => $this->lesson->id, "pageid" => $this->properties->id); + if ($answers = $this->get_answers()) { + foreach ($answers as $answer) { + if ($answer->answer === '') { + // show only jumps for real branches (==have description) + continue; + } + $jumps[] = $this->get_jump_name($answer->jumpto); + } + } + return $jumps; + } + public static function get_jumptooptions($firstpage, $lesson) { global $DB, $PAGE; $jump = array(); @@ -89,6 +111,10 @@ class lesson_page_type_branchtable extends lesson_page { $buttons = array(); $i = 0; foreach ($this->get_answers() as $answer) { + if ($answer->answer === '') { + // not a branch! + continue; + } $params = array(); $params['id'] = $PAGE->cm->id; $params['pageid'] = $this->properties->id; @@ -174,6 +200,10 @@ class lesson_page_type_branchtable extends lesson_page { $options->para = false; $i = 1; foreach ($answers as $answer) { + if ($answer->answer === '') { + // not a branch! + continue; + } $cells = array(); $cells[] = "".get_string("branch", "lesson")." $i: "; $cells[] = format_text($answer->answer, $answer->answerformat, $options);