使用网络服务获取课程内容 [英] Get course contents using webservice

查看:59
本文介绍了使用网络服务获取课程内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Moodle 3.1+.我正在尝试使用网络服务获取课程内容.我创建了一个带有活动课程"的课程.现在,当我尝试使用网络服务core_course_get_contents"获取课程内容时,得到以下响应.

I am using Moodle 3.1+. I am trying to get the course contents using webservice. I have created a course with activity 'lesson'. Now when I try to get the contents of the course using webservice 'core_course_get_contents', I am getting the following response.

[{"id":36,"name":" 0","visible":1,"summary":"","summaryformat":1,"modules":[{"id":18,"url":"http:\/\/localhost\/moodle\/mod\/lesson\/view.php?id=18","name":"Lesson1","instance":1,"visible":1,"modicon":"http:\/\/localhost\/moodle\/theme\/image.php\/mentornetz\/lesson\/1483338014\/icon","modname":"lesson","modplural":"Lessons","indent":0}]}]

但响应不包含课程详细信息.

But the response doesn't contain the lesson details.

Moodle API 文档说响应包含以下详细信息,而我的响应中缺少这些详细信息.

Moodle API documentation says that response contains below details which is missing in my response.

contents list of ( 
object {
type string   //a file or a folder or external link
filename string   //filename
filepath string   //filepath
filesize int   //filesize
fileurl string  Optional //downloadable file url
content string  Optional //Raw content, will be used when type is content
timecreated int   //Time created
timemodified int   //Time modified
sortorder int   //Content sort order
userid int   //User who added this content to moodle
author string   //Content owner
license string   //Content license
} 

以下是对 webservice core_course_get_course_module 的响应

Below is the response for the webservice core_course_get_course_module

object {
cm object {
id int   //The course module id
course int   //The course id
module int   //The module type id
name string   //The activity name
modname string   //The module component name (forum, assign, etc..)
instance int   //The activity instance id
section int   //The module section id
sectionnum int   //The module section number
groupmode int   //Group mode
groupingid int   //Grouping id
completion int   //If completion is enabled
idnumber string  Optional //Module id number
added int  Optional //Time added
score int  Optional //Score
indent int  Optional //Indentation
visible int  Optional //If visible
visibleold int  Optional //Visible old
completiongradeitemnumber int  Optional //Completion grade item
completionview int  Optional //Completion view setting
completionexpected int  Optional //Completion time expected
showdescription int  Optional //If the description is showed
availability string  Optional //Availability settings
} 
warnings  Optional //list of warnings
list of ( 
  //warning
object {
item string  Optional //item
itemid int  Optional //item id
warningcode string   //the warning code can be used by the client app to implement specific behaviour
message string   //untranslated english message to explain the warning
} 
)} 

如何获取课程内容?请帮忙.

How can I get the contents of the course? Please help.

推荐答案

并非所有模块都支持导出其内容.根据快速 grep,我发现它主要限于资源:book、page、file、url、...

Not all modules support exporting their contents. According to a quick grep, I found that it's mostly limited to resources: book, page, file, url, ...

如果您向课程添加 URL 资源,网络服务应返回其内容.

If you add a URL resource to your course the webservice should return its content.

这篇关于使用网络服务获取课程内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆