В ответе Moodle REST API отсутствуют поля - PullRequest
0 голосов
/ 03 октября 2019

Я звоню core_course_get_courses_by_field со следующими параметрами: &field=shortname&value=test

Ответ не содержит параметр Visible (который мне нужен), который показан в примере ответа по умолчанию документации Moodle(сразу видно, что ответ Moodle по умолчанию содержит гораздо больше данных):

Мой ответ

{
courses: [
{
id: 12112,
fullname: "Test course",
displayname: "Test course",
shortname: "test",
categoryid: 91,
categoryname: "2019-3",
sortorder: 320557,
summary: "",
summaryformat: 1,
summaryfiles: [ ],
overviewfiles: [ ],
contacts: [
{
id: 1111,
fullname: "John Doe"
}
],
enrollmentmethods: [
"manual",
"imsenterprise"
]
}
],
warnings: [ ]
}

Пример ответа Moodle

object {
courses   //Course
list of ( 
object {
id int   //course id
fullname string   //course full name
displayname string   //course display name
shortname string   //course short name
categoryid int   //category id
categoryname string   //category name
sortorder int  Optional //Sort order in the category
summary string   //summary
summaryformat int   //summary format (1 = HTML, 0 = MOODLE, 2 = PLAIN or 4 = MARKDOWN)
summaryfiles  Optional //summary files in the summary field
list of ( 
  //File.
object {
filename string  Optional //File name.
filepath string  Optional //File path.
filesize int  Optional //File size.
fileurl string  Optional //Downloadable file url.
timemodified int  Optional //Time modified.
mimetype string  Optional //File mime type.
isexternalfile int  Optional //Whether is an external file.
repositorytype string  Optional //The repository type for external files.
} 
)overviewfiles   //additional overview files attached to this course
list of ( 
  //File.
object {
filename string  Optional //File name.
filepath string  Optional //File path.
filesize int  Optional //File size.
fileurl string  Optional //Downloadable file url.
timemodified int  Optional //Time modified.
mimetype string  Optional //File mime type.
isexternalfile int  Optional //Whether is an external file.
repositorytype string  Optional //The repository type for external files.
} 
)contacts   //contact users
list of ( 
object {
id int   //contact user id
fullname string   //contact user fullname
} 
)enrollmentmethods   //enrollment methods list
list of ( 
string   //enrollment method
)idnumber string  Optional //Id number
format string  Optional //Course format: weeks, topics, social, site,..
showgrades int  Optional //1 if grades are shown, otherwise 0
newsitems int  Optional //Number of recent items appearing on the course page
startdate int  Optional //Timestamp when the course start
enddate int  Optional //Timestamp when the course end
maxbytes int  Optional //Largest size of file that can be uploaded into
showreports int  Optional //Are activity report shown (yes = 1, no =0)
visible int  Optional //1: available to student, 0:not available
groupmode int  Optional //no group, separate, visible
groupmodeforce int  Optional //1: yes, 0: no
defaultgroupingid int  Optional //default grouping id
enablecompletion int  Optional //Completion enabled? 1: yes 0: no
completionnotify int  Optional //1: yes 0: no
lang string  Optional //Forced course language
theme string  Optional //Fame of the forced theme
marker int  Optional //Current course marker
legacyfiles int  Optional //If legacy files are enabled
calendartype string  Optional //Calendar type
timecreated int  Optional //Time when the course was created
timemodified int  Optional //Last time  the course was updated
requested int  Optional //If is a requested course
cacherev int  Optional //Cache revision number
filters  Optional //Course filters
list of ( 
object {
filter string   //Filter plugin name
localstate int   //Filter state: 1 for on, -1 for off, 0 if inherit
inheritedstate int   //1 or 0 to use when localstate is set to inherit
} 
)courseformatoptions  Optional //Additional options for particular course format.
list of ( 
object {
name string   //Course format option name.
value string   //Course format option value.
} 
)} 
)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
} 
)} 

Я создал системную роль для управления пользовательскими разрешениями API, пользователи с этой ролью - это пользователи, для которых сгенерированы токены API для этих вызовов.

Вот их разрешение:

отчет / курс, обзор: просмотр

мод / посещаемость: viewsummaryreports

moodle / курс: reviewotherusers

moodle / курс: viewhiddencourses

Moodle / курс: viewhiddensections

Moodle / курс: viewhiddenuserfields

Moodle / курс: видимость

Moodle / курс: активность видимости

Moodle / курс: viewhiddenactivities

Я определенно что-то здесь упускаю ... почему я не вижу все поля в ответе? Существуют ли определенные разрешения для API? Я не могу найти соответствующую документацию по этому вопросу.

...