Get the content via REST protocol

Get the content via REST protocol

by John Smith -
Number of replies: 16

Hi everybody,

I explain my issue:

I've to get the content of a moodle website, and right now I try to do it using an API, the Web services API.

I use the REST protocol, and so I downloaded the Java library Moodle Rest.

Using the classes of MoodleRest, I wrote a small program who uses the core_course_get_contents function, and it works.

But I need definitely the url of each content, and the API only give me the url of the resources, while the url of the activities (in a moodle course) have the value "null".

May I find a mean to have the url of the activities (workshop, lesson, quizz...) or not?

Thanks for helping me

Average of ratings: -
In reply to John Smith

Re: Get the content via REST protocol

by Bill Antonia -

One for me I think.

Are you using the library downloaded from SourceForge or the one downloaded from www.beaconhillcott.net?

I'll get back to you as I have to go and sort out something right this moment!

In reply to John Smith

Re: Get the content via REST protocol

by Jérôme Mouneyrac -
Hi Martin,
if I remember well core_course_get_contents only return files url for resource yet.
Cheers,
Jerome
In reply to Jérôme Mouneyrac

Re: Get the content via REST protocol

by Bill Antonia -

Checking a course on our site, the MoodleCourseContent[] object returned from getCourseContent in the library is composed of an array of topics within the course, including the first which is named as "general". Within each of those is a Hashtable of the parts within each topic, which does include activities. However the subsequent "content", which is an ArrayList of MoodleModuleContent currently has only file resources. If there are no file resources then content will be "null". This is not a problem with the library, currently only content elements for file resources are returned by Moodle.

Probably not what you wanted to hear, sorry.

I expect at sometime I will have to make MoodleModuleContent abstract when different types of content is returned.

Hmmmmmmmm....... that might not be a bad idea for the next release.

Jerome, is there going to be additional types of content returned by this call in a future Moodle release at some stage? Just planning ahead.

Average of ratings: Useful (1)
In reply to Bill Antonia

Re: Get the content via REST protocol

by John Smith -

Thanks for the answer, now I'm fixed smile

In reply to John Smith

Re: Get the content via REST protocol

by John Smith -

Maybe I have an other way...

If Moodle provides the possibility to move the activities as files, I may use the function "core_files_get_files".

It's an hypothesis

In reply to John Smith

Re: Get the content via REST protocol

by roc mehra -

Hi Smith,

I want to get contents via web service. Please help me.

 

In reply to Bill Antonia

Re: Get the content via REST protocol

by Jérôme Mouneyrac -
Hi Bill,
it is planned than the My Mobile app will display all activity contents. So the web service functions making it possible should be created/updated. However no date has been decided for implementing it. I recommend to create an issue or vote for it if it already exists.
Cheers,
Jerome
In reply to Jérôme Mouneyrac

Re: Get the content via REST protocol

by John Smith -

Also about the MoodleRest code, is there a way to get the list of each user of a moodle website? Or at least the number of user?

I was looking for these stuff today, and I don't reach anything...

In reply to John Smith

Re: Get the content via REST protocol

by Bill Antonia -

Hi Martin,

I would like that too but currently there is no webservice offered by Moodle to retrieve this data. The library only reflects those wsfunctions which are available via the standard install. Thinking on it, you could retrieve all the courses then iterate through each course retrieving the enrolled users. Obviously you may get duplicates but if you store the information in a Hashtable the duplicates can be gradually filtered out by checking to see if the key exists before adding a user to the Hashtable. Note though this will only work if all your users are attached to courses. The response you will get will depend on the number courses and users you have.

By the way, I think you have the version for Moodle 2.2, the one on www.beaconhillcott.net is the one I'm currently adding updates which will be for Moodle 2.3. Obviously there are more wsfunctions hoping to be released, if you look at the tracker.

Regards

Bill

In reply to Bill Antonia

Re: Get the content via REST protocol

by John Smith -

Thank you,

I had the same idea about the Hashtable,

I look forward to hearing from Moodle next release smile

Goodbye

In reply to John Smith

Re: Get the content via REST protocol

by John Smith -

Otherwise, I need at least the url of the glossary.

Is there a way to move glossary as a "resource" ?

In reply to John Smith

Re: Get the content via REST protocol

by Jérôme Mouneyrac -
Hi guys,
Fabio is working on a web service get_users function, I mentioned your request: http://tracker.moodle.org/browse/MDL-29938?focusedCommentId=155884&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-155884

Cheers,
Jerome
In reply to Jérôme Mouneyrac

Re: Get the content via REST protocol

by John Smith -

Thanks, I'll follow it

In reply to John Smith

Re: Get the content via REST protocol

by roc mehra -

Hi All, I have used web service

http://localhost/webservice/rest/server.php?wstoken=dcf912ca225093f616f3e93186bbc0a9&wsfunction=core_course_get_contents&courseid=102

It gives me response news forum and all the topics. But i need only topic 1 data.

How can i use desired data from it

In reply to roc mehra

Re: Get the content via REST protocol

by roc mehra -

Hi Jerome,

I have used core_course_get_contents to get the contents of activity and also of resource but when i tried to get through fileurl which i got from response of my web service.

It gives me

{"error":"Sorry, the requested file could not be found","stacktrace":null,"debuginfo":null,"reproductionlink":null}

Thanks in Advance