Moodle core_course_create_courses - 从特定模板创建课程

发布于 01-15 14:08 字数 671 浏览 5 评论 0原文

我正在尝试使用 Moodle API 从模板创建新课程,但没有成功。 下面的代码确实创建了包含所有详细信息但不包含模板课程内容的课程。 知道如何实现这一目标吗?

我有一个 ID = 9 或 ShortCourseName = TEMPLATE 的模板课程

这是让我头晕的最后一块拼图。

https://DOMAIN/webservice/rest/server.php?wstoken=TOKEN&wsfunction=core_course_create_courses
&courses[0][fullname]=Test Full name
&courses[0][shortname]=testshortname
&courses[0][categoryid]=1
&courses[0][idnumber]=41-11
&courses[0][courseformatoptions][0][name]=TEMPLATE
&courses[0][courseformatoptions][0][value]=9
&courses[0][format]=tiles
&courses[0][startdate]=1641013490
&courses[0][enddate]=1647839103
&moodlewsrestformat=jsoncode

I am trying to use Moodle API to create a new course from a TEMPLATE, but no luck.
Below is a code that does create a course with all the detials but no content from the TEMPLATE course.
Any idea how to achieve this?

I have a template course with ID = 9 or ShortCourseName = TEMPLATE

This is the last piece of the puzzle that makes my head spin.

https://DOMAIN/webservice/rest/server.php?wstoken=TOKEN&wsfunction=core_course_create_courses
&courses[0][fullname]=Test Full name
&courses[0][shortname]=testshortname
&courses[0][categoryid]=1
&courses[0][idnumber]=41-11
&courses[0][courseformatoptions][0][name]=TEMPLATE
&courses[0][courseformatoptions][0][value]=9
&courses[0][format]=tiles
&courses[0][startdate]=1641013490
&courses[0][enddate]=1647839103
&moodlewsrestformat=jsoncode

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

冬天旳寂寞2025-01-22 14:08:23

根据 https://docs.moodle.org/311/en/Adding_a_new_course#Course_templates< /a> - 您可以使用管理设置中的“上传课程”功能(站点管理 > 课程 > 上传)从模板创建课程课程),通过上传的 CSV 创建一门或多门课程。

Web 服务函数 core_course_create_courses 的代码不包含对从模板创建课程的任何支持 - 如果您需要此类功能,那么您需要聘请开发人员来编写自定义 Web 服务函数。或者,您可以尝试寻找开发人员来扩展现有的核心代码并提供回 Moodle 核心的补丁,以允许在 Moodle 的未来版本中支持此功能 - 有一个请求此功能的开放票证:https://tracker.moodle.org/browse/MDL-69219(可能还有其他重复项)票,但那是我找到的)。

According to https://docs.moodle.org/311/en/Adding_a_new_course#Course_templates - you can create a course from a template by using the "Upload courses" feature in the admin settings (Site admin > Courses > Upload coures), to create one or more courses via an uploaded CSV.

The code for the webservice function core_course_create_courses does not include any support for creating courses from templates - if you want such functionality, then you'll need to hire a developer to write a custom webservice function. Alternatively, you could try to find a developer to extend the existing core code and provide a patch back to Moodle core, to allow this to be supported in future versions of Moodle - there is an open ticket requesting this feature at: https://tracker.moodle.org/browse/MDL-69219 (there may be other duplicate tickets, but that's the one I found).

司马昭之心2025-01-22 14:08:23

使用 core_course_duplicate_course 函数

Use the core_course_duplicate_course function

柳絮泡泡2025-01-22 14:08:23

作为一种替代方法,您可以分两步完成此操作:

  1. 使用一个 Web 服务调用(使用 core_course_create_courses 或 mudle_course_create_courses)创建课程。
  2. 使用对 core_course_import_course 的第二个 Web 服务调用从模板导入您想要的课程内容。

As an alternative, you can do this in two steps:

  1. Create the course using one web service call (using core_course_create_courses or moodle_course_create_courses).
  2. Import the course content you want from your template(s) using a second web services call to core_course_import_course.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文