Custom webservice for Quiz sync data from mobile app.

Custom webservice for Quiz sync data from mobile app.

by Baiju Sharma -
Number of replies: 1

Moodle version 3.3.1. I am not having deep knowledge on WS.

I have gone through the working existing web service of Moodle quiz which syncs data to Moodle.Below are the lists of WS.

  1. Start user attempt from service mod_quiz_start_attempt
  2. Get attempt data from service mod_quiz_get_attempt_data
  3. Parse essential data which received from step -2
  4. Get the user question answered value from App database and prepare question data to submit.
Finally, To submit user data need to call mod_quiz_save_attempt.
I have to write a single new custom web service which will sync all user quiz data into Moodle DB from our iOS mobile App.
I have data in JSON format: {
 "userid": 1,
 "quizid": 1,
 "response": [
   {
     "qtype": "",
     "qid": "",
     "answerid": "",
     "iscorrect": true
   },
Few question:
I have taken the quiz on the web and I found that if I take quiz through the web there are many tables in which user data get inserted. Few table names :question_attempt_step_data,quiz _attempts,question_attempt_steps and many other similar tables.Now my question is that from where I will get data for these tables to insert in table.I only get few data in JSON.Do I have to call existing function which will insert all these data for me?

Unable to understand how can I insert data into those columns for which  I don't have data.
Is it possible to achieve my requirement with only above JSON data?    

Just need initial guidance so that I can start working on my custom WS.

Average of ratings: -
In reply to Baiju Sharma

Re: Custom webservice for Quiz sync data from mobile app.

by Masoud Vafaei -

hi dear baiju

I have a question about number 3 in your post => "Parse essential data which received from step -2"
How do you parse and clean mod_quiz_get_attempt_data service response?