Custom Notification On SubmitAndFinish Quiz With Third Party Interaction

Custom Notification On SubmitAndFinish Quiz With Third Party Interaction

by Sumeen Kaur -
Number of replies: 0

Hi There


I am beginner in using Moodle and have a question regarding how to show a custom pop up or notification once the student submits the attempt on the quiz. But before I ask the details, let me explain the business use case.

We have a course which is divided into 5 chapters, each chapter can have 1-2 lessons. On the completion of chapter 5, and once the quiz set up on that chapter is attempted, the system needs to interact with a third party (Transport Canada - TC) to grab the a test url (to take external test with TC). The Test URL needs to be communicated to the student once the interaction between moodle and TC is over.

I am able to achieve this.  This is how I implemented it.

I used 

'eventname' => '\mod_quiz\event\attempt_submitted'
 in a localplugin with my custom handler from which I do interaction with TC and grab the user information from them with the test url and update the custom tables in moodle. 

So once the student clicks "Submit and Finish" button, all interaction works and I get the URL. The user is redirected to summary.php. 

http://<domain>/mod/quiz/summary.php?attempt=26&cmid=82

But the part I am struggling with is how to communicate this external test url to the user in the on summary.php (either as notification or pop up or I tried message_send too). I tried redirection using Moodle redirect() which worked, however I get an error that the transaction started in processfinish() in attemptlib.php is not over and hence my db changes are rolled back. So redirection is not going to work. 

I can try changing moodle mod quiz code directly but I am trying to avoid that and trying to implement in the form of a plugin in local folder, so that we can do future upgrades. 

I am beginner in  moodle. I have spent many days now in researching in moodle docs or forum but I could not find a solution to this. 

Any ideas or help is appreciated. If we anybody has ideas on a different approach that would work too.


Thanks

Sumeen

 

Average of ratings: -