Run a script after user submits a quiz

I want to extract the questions and its answers from an open-ended quiz, so i have written a script to do it, but i am not able to run it automatically when a user submits their quiz.

i have tried the method in the image but its not working

You will need to provide more information as to what is not working.
Also, for what purpose are you fetching the latest document? You can access the current document object using the “doc” keyword.

eg:

for row in doc.results:
    pass

well the code was not being executed automatically, i found out it was because i gave the event as after submit which should have been after insert.

I want to fetch the question and answer of the latest submitted quiz by a student, i want to make it such that after students submits his quest i cant send the question and answer to a llm for grading.

Right. So don’t you want the details of the record which has been “Inserted” at the moment? So the method you are running for is when an event occurs on a record. If you want to send the data from that record then you can simply use the “doc” object.