douan2907 2018-07-10 09:35
浏览 110
已采纳

Moodle3.5 ::课程的课程模块

Get course modules for a course:

I was trying to get course modules for current courseid. Tried to pull out the array values with print_r and var_dump, not with exact string conversion.

I was looking for module instance or module id and module name (modname) from the array output.

I want the course modules from the course, displays coursename, modules on a custom page.

global $DB;
$course = $DB->get_record('course', array('id' => $courseid));
$info = get_fast_modinfo($course);
print_r($info);
//var_dump($info);
  • 写回答

1条回答 默认 最新

  • douduan9391 2018-07-10 12:35
    关注

    The code you need is as follows:

    $modinfo = get_fast_modinfo($courseid);
    foreach ($modinfo->get_cms() as $cminfo) {
        echo $cminfo->id.' ('.$cminfo->instance.'): '.$cminfo->get_formatted_name().'<br>';
    }
    

    Have a look at lib/modinfolib.php, class course_modinfo for details of the functions you can call on the object returned by get_fast_modinfo(). Look at the cm_info class in the same file for details for the object returned by get_cms() / get_cm($cmid).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作