AnsweredAssumed Answered

How to get a history of all reports of a quiz

Question asked by Fabio Cunha on May 22, 2020
Latest reply on May 25, 2020 by Fabio Cunha

Hi,

I have a quiz that allows students to write their answers on it.

Now, I want to get all those answers using the API.

I generate a report using the command below:

 

print ( "curso: "+str(course.id)+" - quiz: "+str(quiz.id) )
        headers = {'Content-Type''application/json','Authorization''Bearer {}'.format(API_KEY)}
        url = API_URL+'/api/v1/courses/'+str(course.id)+'/quizzes/'+str(quiz.id)+'/reports?quiz_report[report_type]=student_analysis&quiz_report[includes_all_versions]=1'.format(course.id, quiz.id)
        response = requests.post(url, headers=headers)
        r = json.loads(response.content.decode('utf-8'))
        url2 = r.get('url')
        print('URL Atualizado:', url2, sep = '\t')

 

This generates the report for me.

After that, I use the following URL to get the report

https://mycompany.instructure.com/api/v1/courses/:course_id/quizzes/:quiz_id/reports/?includes_all_versions=true

I get the following answer:

https://www.npoint.io/docs/4c28ce994cd95ac7b8e4  ( please click to see the JSON answer)

In the JSON answer, it got a parameter file, inside the file parameter, there is a URL parameter, I use this parameter to download to extract the CSV file and read the results from it.

But on the next day, I try to get CSV again, but I got an answer like this:

https://www.npoint.io/docs/6b8e4da433d1a024240a ( please click to see the JSON answer)

There are other students reports that are generated that overwrite the most recent response?

Is it possible to get only the most recent report that contains the file['url'] parameter?

 

Outcomes