2017-01-03 91 views
1

我正在使用Moodle 3.1+。我正在尝试使用webservice获取课程内容。我创建了一门课程,内容是“课程”。现在,当我尝试使用webservice'core_course_get_contents'获取课程的内容时,我收到以下回复。使用webservice获取课程内容

[{"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}]}] 

但是,回复没有包含课程内容。

Moodle API文档说,响应中包含以下详细信息,这些信息在我的响应中缺失。

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 
} 

下面是web服务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 
} 
)} 

我怎样才能获得该课程的内容回应?请帮忙。

+0

那么,他们的API文档说明了如何做到这一点? – arkascha

+0

@arkascha没有足够的文档可用。 – user1690835

+2

该文档说'core_course_get_contents'提供课程模块,包括他们的URL。那么你可能需要对'core_course_get_course_module'进行后续调用,以获得关于该课程中特定模块的更多详细信息。我认为这很明显从文档https://docs.moodle.org/dev/Web_service_API_functions – arkascha

回答

0

并非所有模块都支持导出其内容。根据一个快速的grep,我发现,这主要是限于资源:如果添加URL资源你当然WebService应返回其内容的书,网页,文件,链接,...