Saving files as submission to assignment

Saving files as submission to assignment

by Jey key -
Number of replies: 2

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)

Average of ratings: -
In reply to Jey key

Re: Saving files as submission to assignment

by Rigoberto Peña Cabrera -
Hi Jozef, I think you are the only one who made a full "save assignment" flow as developer. Now, answering your question, to chain all webservices using the same security token, you must store it in some place where all remaining calls can use it. That why a programming language makes the magic, so, if you are using only web services calls, can you explain which tools are you using, for example Postman? You said that you aren't a PHP developer, which language are you using?

PS: Using third point (mod_assign_save_submission) have you ever got this error: "Could not save submission, nothing was saved". I don't pass from this point, any idea?
In reply to Rigoberto Peña Cabrera

Re: Saving files as submission to assignment

by Jey key -

Hi Rigoberto, i dont exactly remember whole process, i was having multiple problems (your error sound similar) and in the end i dropped this idea of feature for now. I think moodle ws are great, but i am missing some features and i hope in future moodle will get this work better.
If ill have some time, i will do testing for your error, but i dont promise that (busy times).

For now we are thinking about making some .php code with moodle functions to maybe create own web service, or plugin with this - we will see.

And for personal info - im using Postman/ARC and im java dev... our company using moodle to some courses - mainly scorms and light administration. Whole logic is created in java - email notifications, display courses, additional administrations of users, ui for HR people and more - our internal system for employees and management. And here we want to have something like that, that people can save assignments from external app, as is ours.