【问题标题】:Moodle set module sequence grammaticallyMoodle 语法上设置模块序列
【发布时间】:2018-05-10 16:07:29
【问题描述】:

在设法以编程方式将模块添加到 Moodle 之后(请参阅我的旧问题 here),我现在还需要在特定位置添加模块。

让我们以 Moodle 中的示例课程为例,我有:

Section 0
 - Module 1
 - --> ADD NEW MODULE HERE <--
 - Module 2
Section 1
 - Module 1
 - Module 2
Section 2

所以我需要在第 0 节的模块 1 和 2 之间添加我以编程方式创建的新模块。

我知道模块的顺序来自表 mdl_course_sections 并在 sequence 列中指定,其中模块的 id 以逗号分隔值存在

Moodle 中有这样的功能吗?设置部分的顺序?我不想直接弄乱数据库。

【问题讨论】:

    标签: module moodle


    【解决方案1】:

    在我从 Moodle 社区获得一些帮助后(感谢 Sam Chaffee),这里是解决方案

    //...Do stuff to create module object...
    // ...
    
    $moduleinfo = add_moduleinfo($newlabel, $section);
    
    //lets get all sections and modules of the course
    $coursemodinfo = get_fast_modinfo($course->id, 0, false);
    
    //get all sections of the course
    $coursesections = $coursemodinfo->get_sections();
    
    //get the first section, get_section will return an array of sections so I get position 0 to get section 1
    $section01 = $coursesections[0];
    
    //get the first module in the section so we can add on top of it
    $firstmodid = $section01[0];
    
    //We need to get cm_info for the specific mod
    $mod = $coursemodinfo->get_cm($moduleinfo->coursemodule);
    
    //we also need section_info for the section we want to move to
    $sectioninfo = $coursemodinfo->get_section_info(0);
    
    //move the newly created module to section 01 but before $firstmodid
    moveto_module($mod, $sectioninfo, $firstmodid);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-11
      • 1970-01-01
      • 2015-10-14
      • 1970-01-01
      • 1970-01-01
      • 2017-01-06
      • 1970-01-01
      相关资源
      最近更新 更多