Created
March 25, 2024 15:36
-
-
Save adamcrown/7894daec058120fdc0a313b2406bf1ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We save a series of custom events when a student takes a quiz. These events | |
# give us interesting insights into quiz-taking behavior. | |
# | |
# We want to write code that uses these events to answer questions | |
# about a particular quiz attempt. | |
# | |
## The Events | |
# We store the events in a series of records stored as JSON. There are | |
# six different types of events: | |
# - `start_quiz`: The student started taking the quiz | |
# - `view_question`: The student viewed a question in the browser | |
# - `answer_question`: The student answered a question | |
# - `page_blurred`: The student exited the browser window | |
# - `page_focused`: The student reentered the browser window | |
# - `submit_quiz`: The student submitted the quiz | |
# The question: What was the overall average time for all the question to be finally answered? "MM:SS" | |
# Example statement we want to make at the end: "On average, it took this student 2 minutes to answer a question" | |
input_data = <<END | |
[ | |
{ "id": 1, "event_type": "start_quiz", "created_at": "2021-03-02T13:35:40-07:00", "event_data": {} }, | |
{ "id": 2, "event_type": "view_question", "created_at": "2021-03-02T13:35:42-07:00", "event_data": { "question_id": 1 } }, | |
{ "id": 3, "event_type": "answer_question", "created_at": "2021-03-02T13:36:12-07:00", "event_data": { "question_id": 1, "answer": { "option_id": "584" } } }, | |
{ "id": 4, "event_type": "view_question", "created_at": "2021-03-02T13:36:14-07:00", "event_data": { "question_id": 2 } }, | |
{ "id": 5, "event_type": "answer_question", "created_at": "2021-03-02T13:37:24-07:00", "event_data": { "question_id": 2, "answer": { "option_id": "824" } } }, | |
{ "id": 6, "event_type": "view_question", "created_at": "2021-03-02T13:37:29-07:00", "event_data": { "question_id": 3 } }, | |
{ "id": 7, "event_type": "view_question", "created_at": "2021-03-02T13:37:30-07:00", "event_data": { "question_id": 4 } }, | |
{ "id": 8, "event_type": "view_question", "created_at": "2021-03-02T13:37:31-07:00", "event_data": { "question_id": 5 } }, | |
{ "id": 9, "event_type": "view_question", "created_at": "2021-03-02T13:37:34-07:00", "event_data": { "question_id": 4 } }, | |
{ "id": 10, "event_type": "view_question", "created_at": "2021-03-02T13:37:35-07:00", "event_data": { "question_id": 3 } }, | |
{ "id": 11, "event_type": "answer_question", "created_at": "2021-03-02T13:40:55-07:00", "event_data": { "question_id": 3, "answer": { "option_id": "427" } } }, | |
{ "id": 12, "event_type": "view_question", "created_at": "2021-03-02T13:40:56-07:00", "event_data": { "question_id": 4 } }, | |
{ "id": 13, "event_type": "answer_question", "created_at": "2021-03-02T13:42:55-07:00", "event_data": { "question_id": 4, "answer": { "option_id": "602" } } }, | |
{ "id": 14, "event_type": "view_question", "created_at": "2021-03-02T13:42:59-07:00", "event_data": { "question_id": 4 } }, | |
{ "id": 15, "event_type": "view_question", "created_at": "2021-03-02T13:43:00-07:00", "event_data": { "question_id": 3 } }, | |
{ "id": 16, "event_type": "page_blurred", "created_at": "2021-03-02T13:43:08-07:00", "event_data": {} }, | |
{ "id": 17, "event_type": "page_focused", "created_at": "2021-03-02T13:47:29-07:00", "event_data": {} }, | |
{ "id": 18, "event_type": "answer_question", "created_at": "2021-03-02T13:47:33-07:00", "event_data": { "question_id": 2, "answer": { "option_id": "276" } } }, | |
{ "id": 19, "event_type": "view_question", "created_at": "2021-03-02T13:47:36-07:00", "event_data": { "question_id": 3 } }, | |
{ "id": 20, "event_type": "view_question", "created_at": "2021-03-02T13:47:37-07:00", "event_data": { "question_id": 4 } }, | |
{ "id": 21, "event_type": "view_question", "created_at": "2021-03-02T13:47:38-07:00", "event_data": { "question_id": 5 } }, | |
{ "id": 22, "event_type": "answer_question", "created_at": "2021-03-02T13:50:24-07:00", "event_data": { "question_id": 5, "answer": { "option_id": "486" } } }, | |
{ "id": 23, "event_type": "view_question", "created_at": "2021-03-02T13:50:26-07:00", "event_data": { "question_id": 4 } }, | |
{ "id": 24, "event_type": "page_blurred", "created_at": "2021-03-02T13:50:30-07:00", "event_data": {} }, | |
{ "id": 25, "event_type": "page_focused", "created_at": "2021-03-02T13:56:08-07:00", "event_data": {} }, | |
{ "id": 26, "event_type": "answer_question", "created_at": "2021-03-02T13:56:17-07:00", "event_data": { "question_id": 4, "answer": { "option_id": "343" } } }, | |
{ "id": 27, "event_type": "view_question", "created_at": "2021-03-02T13:56:20-07:00", "event_data": { "question_id": 5 } }, | |
{ "id": 28, "event_type": "submit_quiz", "created_at": "2021-03-02T13:56:25-07:00", "event_data": {} } | |
] | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment