dongpao1873
dongpao1873
2014-05-15 23:16

在课程概述块Moodle中显示课程摘要文本

已采纳

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?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

3条回答

  • dongqie8661 dongqie8661 7年前

    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);
    
    点赞 评论 复制链接分享
  • doushang8512 doushang8512 7年前

    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

    点赞 评论 复制链接分享
  • dongmeiran609914 dongmeiran609914 6年前

    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');
                }
    
    
        

    </div>
    
    点赞 评论 复制链接分享