From 563e97b8b920d9b7008b380335ba84d32c737f2b Mon Sep 17 00:00:00 2001 From: sam marshall Date: Mon, 10 Jan 2011 13:04:54 +0000 Subject: [PATCH 1/2] completion MDL-25927 Change print_help_icon to display_help_icon (returns html instead of printing) --- course/format/topics/format.php | 2 +- course/format/weeks/format.php | 2 +- lib/completionlib.php | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/course/format/topics/format.php b/course/format/topics/format.php index 12611df72ff..905892d598c 100644 --- a/course/format/topics/format.php +++ b/course/format/topics/format.php @@ -69,7 +69,7 @@ if ($editing) { // Print the Your progress icon if the track completion is enabled $completioninfo = new completion_info($course); -$completioninfo->print_help_icon(); +echo $completioninfo->display_help_icon(); echo $OUTPUT->heading(get_string('topicoutline'), 2, 'headingblock header outline'); diff --git a/course/format/weeks/format.php b/course/format/weeks/format.php index 9b9886ae3c1..99c7e9a863a 100644 --- a/course/format/weeks/format.php +++ b/course/format/weeks/format.php @@ -61,7 +61,7 @@ defined('MOODLE_INTERNAL') || die(); //Print the Your progress icon if the track completion is enabled $completioninfo = new completion_info($course); - $completioninfo->print_help_icon(); + echo $completioninfo->display_help_icon(); echo $OUTPUT->heading(get_string('weeklyoutline'), 2, 'headingblock header outline'); diff --git a/lib/completionlib.php b/lib/completionlib.php index f0482dbac4c..f3fe8c20d80 100644 --- a/lib/completionlib.php +++ b/lib/completionlib.php @@ -207,17 +207,19 @@ class completion_info { } /** - * Print the Your progress help icon if the completion tracking is enabled. + * Returns the 'Your progress' help icon, if completion tracking is enabled. * @global object - * @return void + * @return string HTML code for help icon, or blank if not needed */ - public function print_help_icon() { + public function display_help_icon() { global $PAGE, $OUTPUT; + $result = ''; if ($this->is_enabled() && !$PAGE->user_is_editing() && isloggedin() && !isguestuser()) { - echo ''.get_string('yourprogress','completion').' '; - echo $OUTPUT->help_icon('completionicons', 'completion'); - echo ''; + $result .= ''.get_string('yourprogress','completion').' '; + $result .= $OUTPUT->help_icon('completionicons', 'completion'); + $result .= ''; } + return $result; } /** From 2af26b123d4594c6b1d319f0e16a1c7131898875 Mon Sep 17 00:00:00 2001 From: sam marshall Date: Mon, 10 Jan 2011 14:08:10 +0000 Subject: [PATCH 2/2] completion MDL-25927 Added old function back as deprecated, to preserve API compatibility --- lib/completionlib.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/completionlib.php b/lib/completionlib.php index f3fe8c20d80..b020d329433 100644 --- a/lib/completionlib.php +++ b/lib/completionlib.php @@ -206,6 +206,16 @@ class completion_info { return $cm->completion; } + /** + * Displays the 'Your progress' help icon, if completion tracking is enabled. + * Just prints the result of display_help_icon(). + * @deprecated Use display_help_icon instead. + * @return void + */ + public function print_help_icon() { + print $this->display_help_icon(); + } + /** * Returns the 'Your progress' help icon, if completion tracking is enabled. * @global object