Quantcast
Channel: Web services
Viewing all articles
Browse latest Browse all 2361

Saving files as submission to assignment

$
0
0
by Jozef K.  

Hello, i have problem to save file as submissions to assignment through web services.
I cannot save submission for specific user. I can only save submission for user, that call webservices. How can i rework web service chain below? It is even possible?

I have used with this specific order:
1, core_files_upload (this will save draft of file to moodle)
mymoodle/webservice/rest/server.php?component=user&filearea=draft&itemid=0&filepath=/&contextlevel=user&instanceid=9280&wstoken=xxxxxxxxxxxxxxxxxxx&wsfunction=core_files_upload&moodlewsrestformat=json&filename=aa.txt&filecontent=ZHNhZGE=

2, mod_assign_get_assignments (this will get id of assigments for courses for user)
mymoodle/webservice/rest/server.php?wstoken=xxxxxxxxxxxxxxxxxxx&wsfunction=mod_assign_get_assignments&moodlewsrestformat=json

3,mod_assign_save_submission (this will save submission as i want)
mymoodle/webservice/rest/server.php?wstoken=xxxxxxxxxxxxxxxxxxx&wsfunction=mod_assign_save_submission&moodlewsrestformat=json&assignmentid=8&plugindata[onlinetext_editor][text]=aaa&plugindata[onlinetext_editor][format]=1&plugindata[onlinetext_editor][itemid]=889967549&plugindata[files_filemanager]=889967549

4, file is uploaded and saved in submission


I have found that i can create for every user ws token (but i dont have passwords and dont want to, cause it is not practical).
P.S. Im not .php dev, so i'll hope i can use only ws.

Thanks for help!!
Jozef K.

Moodle 3.7 (for now)


Viewing all articles
Browse latest Browse all 2361

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>