Php 使用webservice获取课程内容
我正在使用Moodle 3.1+。我正在尝试使用webservice获取课程内容。我创建了一个带有“课程”活动的课程。现在,当我尝试使用webservice“core\u course\u get\u contents”获取课程内容时,我得到了以下响应Php 使用webservice获取课程内容,php,moodle,moodle-api,Php,Moodle,Moodle Api,我正在使用Moodle 3.1+。我正在尝试使用webservice获取课程内容。我创建了一个带有“课程”活动的课程。现在,当我尝试使用webservice“core\u course\u get\u contents”获取课程内容时,我得到了以下响应 [{"id":36,"name":" 0","visible":1,"summary":"","summaryformat":1,"modules":[{"id":18,"url":"http:\/\/localhost\/moodle\/mod
[{"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}]}]
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
}
但是回复中没有包含课程的细节
MoodleAPI文档说,我的回复中缺少以下详细信息
[{"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}]}]
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核心课程获取课程模块的响应
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
}
)}
我怎样才能得到课程的内容?请提供帮助。并非所有模块都支持导出其内容。根据快速grep,我发现它主要局限于资源:书籍、页面、文件、url等等
如果您在课程中添加URL资源,Web服务应返回其内容。如果我理解正确,您指的是从课程中获取内容。
mod\u lesson\u get\u page\u data
功能在这里可能会有所帮助。它会返回一节课中某个页面的大量信息。来自Moodle文档(经过调整以突出显示更重要的信息):
返回给定页面的信息,包括其内容
论据
(必填)-课程实例idlessonid
(必填)-页面idpageid
(默认为“”)-如果我们必须在呈现后返回完整的页面内容returncontents
returncontents
应该是int
。可能是1
,但这没有文档记录
回应
对象{
页面可选//页面字段
反对{
id int//此课程页面的id
lessonid int//此页面所属课程的id
prevpageid int//此页之前的页的id
nextpageid int//页面序列中下一页的id
qtype int//标识此页面的页面类型
qoption int//用于记录特定于页面类型的选项
layout int//用于记录特定于页面的布局选择
display int//用于记录特定于页面的显示选择
timecreated int//创建页面时的时间戳
timemodified int//上次修改页面的时间戳
标题字符串可选//此页的标题
内容字符串可选//此页的内容
contentsformat int可选//内容格式(1=HTML、0=MOODLE、2=PLAIN或4=MARKDOWN)
displayinmenublock int//切换左侧菜单块中的显示
type int//页面的类型[问题|结构]
typeid int//页面类型的唯一标识符
typestring//描述此页面类型的字符串
}
newpageid int//New page id(如果进行了跳转)
页面内容字符串可选//页面html内容
ongoingscore字符串//正在进行的评分消息
进度int//课程中的进度百分比
contentfiles//文件列表。
名单(
//文件。
反对{
文件名字符串可选//文件名。
文件路径字符串可选//文件路径。
filesize int可选//文件大小。
fileurl字符串可选//可下载的文件url。
timemodified int可选//时间已修改。
mimetype字符串可选//文件mime类型。
isexternalfile int可选//是否为外部文件。
repositorytype字符串可选//外部文件的存储库类型。
}
)答案列表(
//这一页有答案
反对{
id int//数据库中此答案的id
应答文件//文件列表。
名单(
//文件。
反对{
文件名字符串可选//文件名。
文件路径字符串可选//文件路径。
filesize int可选//文件大小。
fileurl字符串可选//可下载的文件url。
timemodified int可选//时间已修改。
mimetype字符串可选//文件mime类型。
isexternalfile int可选//是否为外部文件。
repositorytype字符串可选//外部文件的存储库类型。
}
)responsefiles//文件列表。
名单(
//文件。
反对{
文件名字符串可选//文件名。
文件路径字符串可选//文件路径。
filesize int可选//文件大小。
fileurl字符串可选//可下载的文件url。
timemodified int可选//时间已修改。
mimetype字符串可选//文件mime类型。
isexternalfile int可选//是否为外部文件。
repositorytype字符串可选//外部文件的存储库类型。
}
)jumpto int可选//标识用户使用此答案完成页面时的位置
分数int可选//此答案的分值
score int可选//此答案将给出的分数
flags int Optional//用于存储答案的选项
timecreated int可选//创建答案的时间戳
timemodified int可选//修改答案的时间戳
答案字符串可选//可能的答案文本
answerformat int可选//回答格式(1=HTML、0=MOODLE、2=PLAIN或4=MARKDOWN)
响应字符串可选//回答的响应文本
responseformat int可选//响应格式(1=HTML、0=MOODLE、2=PLAIN或4=MARKDOWN)
}
)邮件列表(
//课程生成了一些消息
反对{
消息字符串//消息。
类型字符串//消息类型:通常是CSS标识符,如:
成功,信息,警告,错误,notifyproblem,notifyerror,notifytiny,notifysuccess
}
)displaymenu int//我们是否应该在此页面中显示菜单。
警告可选//警告列表
名单(
//警告
反对{
项目字符串可选//项目
itemid int可选//项目id
warningcode string//客户端应用程序可以使用该警告代码来实现特定行为
消息字符串//未翻译的英语消息,用于解释警告
}
)}
那么,他们的API文档说明了如何做到这一点吗?@arkascha没有足够的文档可用。文档说,核心课程获取内容
提供了课程模块,包括他们的URL。那么probab