I would like to display the course summary text underneath the course title within the Course Overview block. How would I go about accessing and displaying this information?

有帮助吗?

解决方案

Doesn't look like there is an option to display the summary.

The code to display the course name and link is in

function course_overview() in /blocks/course_overview/renderer.php

If you look for $coursefullname, you should see something like this

$coursefullname = format_string($course->fullname, true, $course->id);
$link = html_writer::link($courseurl, $coursefullname, $attributes);
$html .= $this->output->heading($link, 2, 'title');

So you'll need to add something like this

$html .= $course->summary;

The $course->summary normally contains a lot of html, if you want to remove that then use this instead

$html .= format_string($course->summary);

其他提示

If the previous doesn't work, try this:

global $DB;
$result = $DB->get_field("course", "summary", array("id"=>$course->id));
$html .= $result;

Found here in the Moodle Forums: https://moodle.org/mod/forum/discuss.php?d=148324#p1002697

I put this code in line (moodle 2.9.1) after line 112 (/moodle/blocks/course_overview/renderer.php) can you try?

$link = html_writer::link($courseurl, $coursefullname, $attributes);
$html .= $this->output->heading($link, 2, 'title');

//start new code

global $DB;
                $result = $DB->get_field("course", "summary", array("id"=>$course->id));
                $modinfo = get_fast_modinfo(1);
                $context = context_course::instance($course->id);
                $section = $modinfo->get_section_info(1);
                $summarytext = file_rewrite_pluginfile_urls($result,
                            'pluginfile.php',
                            $context->id,
                            'course',
                            'summary','');              
               
                $html .= $summarytext;
   //end new code
            } else {               

                    $html .= $this->output->heading(html_writer::link(
                    new moodle_url('/auth/mnet/jump.php', array('hostid' => $course->hostid, 'wantsurl' => '/course/view.php?id='.$course->remoteid)),
                    format_string($course->shortname, true), $attributes) . ' (' . format_string($course->hostname) . ')', 2, 'title');
            }


    

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top