2017-01-03 89 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應返回其內容的書,網頁,文件,鏈接,...