<jupyter_start><jupyter_text>Get Data from CanvasCanvas has a RESTful API. I'm going to use it to pull down the responses to the homework assignments.By the way, you can also use the Canvas API to access your data.The cell below contains the code I used to get the data from Canvas.<jupyter_code>import os
import json
with open(os.path.join(os.path.expanduser("~"), ".canvaslms", "quiz_token")) as f:
    token = f.read()
    
from canvasapi import Canvas
from bs4 import BeautifulSoup
import unicodedata
from collections import defaultdict

API_URL = "https://canvas.lms.unimelb.edu.au/"
canvas = Canvas(API_URL, token)
bec = canvas.get_user(canvas.get_current_user().id)
ehealth = canvas.get_course(110024)
import pandas as pd
import hvplot.pandas 
import holoviews as hv
hv.extension('bokeh')

for q in ehealth.get_quizzes():
    print(q)
quiz = ehealth.get_quiz(76171)
qdata = pd.DataFrame([{"id":i, 
                       "time_spent":s.time_spent, 
                       "grade":(s.kept_score/s.quiz_points_possible)} 
                          for i,s in enumerate(quiz.get_submissions())])
qdata
qdata.hvplot.hist("time_spent", bin_range=(0,2000), bins=50)
qdata.time_spent.corr(qdata.grade)
qdata.hvplot.scatter(x="time_spent", y="grade")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1125879593432369, 'fraction_numerical': 0.014855355746677092, 'mean_word_length': 4.099601593625498, 'pattern_counts': {'":': 3, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '59186', 'license': 'MIT', 'n_tokens_mistral': 469, 'n_tokens_neox': 442, 'n_words': 115, 'path': 'code/canvas/examine_quiz_scores.ipynb', 'repo_name': 'Melbourne-BMDS/student_data', 'size': '1279'}