{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example of Course Information" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Import OpenLA" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# import openLA as la\n", "import OpenLA as la" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load course information from dataset." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# If all files are named \"Course_{course_id}_{file_name}\" and they are in same directory, \n", "# e.g. \"dataset_sample/Course_A_EventStream.csv\", \"dataset_sample/Course_A_LectureMaterial.csv\", and so on,\n", "# you can indicate them by the course id and directory path.\n", "course_info = la.CourseInformation(files_dir=\"dataset_sample\", course_id=\"A\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "# If the names of the files or the directories they are in are different, you can indicate them individually.\n", "course_info2 = la.CourseInformation(event_stream_file =\"dataset_sample2/EventStream.csv\",\n", " lecture_material_file=\"dataset_sample2/LectureMaterial.csv\",\n", " lecture_time_file =\"dataset_sample3/Course_B_LectureTime.csv\",\n", " quiz_score_file =\"dataset_sample3/Course_B_QuizScore.csv\",\n", " grade_point_file =\"dataset_sample3/Course_B_GradePoint.csv\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get course id from member variable" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'A'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "course_info.course_id" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "None\n" ] } ], "source": [ "# If the course id was not indicated, None is returned\n", "print(course_info2.course_id)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get basic information about the course" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "users = course_info.user_id()\n", "contents = course_info.contents_id()\n", "lectures = course_info.lecture_week()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['A_U1', 'A_U10', 'A_U100', 'A_U101']" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "users[:4]" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "['C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7', 'C8']" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "contents" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[1, 2, 3, 4, 5, 6, 7, 8]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lectures" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Contents id and the week of lecture using the contents are convertible" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[2, 8]" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "course_info.contents_id_to_lecture_week(contents_id=['C2', 'C8'])" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'C3'" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "course_info.lecture_week_to_contents_id(lecture_week=3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get the final score of user(s)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [], "source": [ "user_score = course_info.user_score(users[0])\n", "users_score = course_info.user_score(users[0:5])" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "72.0" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "user_score" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[72.0, 72.0, 82.0, 75.0, 91.0]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "users_score" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "user_grade = course_info.user_grade(users[0])\n", "users_grade = course_info.user_grade(users[0:5])" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'C'" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "user_grade" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['C', 'C', 'B', 'C', 'A']" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "users_grade" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Extract users who get selected final scores/grades" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "high_score_users = course_info.users_in_selected_score(users, top=100, bottom=90)\n", "low_grade_users = course_info.users_in_selected_grade(users, grade=\"F\")" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['A_U102', 'A_U24', 'A_U86', 'A_U67']" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "high_score_users" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['A_U115', 'A_U70', 'A_U117']" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "low_grade_users" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get lecture start and end time of lecture" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "first_lecture_start_time = course_info.lecture_start_time(lectures[0])\n", "first_lecture_end_time = course_info.lecture_end_time(lectures[0])" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Timestamp('2018-04-10 14:50:00')" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "first_lecture_start_time" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Timestamp('2018-04-10 16:20:00')" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "first_lecture_end_time" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load event stream data" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "event_stream = course_info.load_eventstream()" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | userid | \n", "contentsid | \n", "operationname | \n", "pageno | \n", "marker | \n", "memo_length | \n", "devicecode | \n", "eventtime | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "A_U1 | \n", "C1 | \n", "PREV | \n", "10 | \n", "NaN | \n", "0 | \n", "tablet | \n", "2018-04-09 10:57:15 | \n", "
1 | \n", "A_U1 | \n", "C1 | \n", "PREV | \n", "9 | \n", "NaN | \n", "0 | \n", "tablet | \n", "2018-04-09 11:00:59 | \n", "
2 | \n", "A_U1 | \n", "C1 | \n", "PREV | \n", "8 | \n", "NaN | \n", "0 | \n", "tablet | \n", "2018-04-09 11:03:31 | \n", "
3 | \n", "A_U1 | \n", "C1 | \n", "PREV | \n", "30 | \n", "NaN | \n", "0 | \n", "tablet | \n", "2018-04-10 10:14:12 | \n", "
4 | \n", "A_U1 | \n", "C1 | \n", "PREV | \n", "29 | \n", "NaN | \n", "0 | \n", "tablet | \n", "2018-04-10 10:27:24 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
263279 | \n", "A_U99 | \n", "C8 | \n", "NEXT | \n", "3 | \n", "NaN | \n", "0 | \n", "pc | \n", "2018-06-05 16:16:18 | \n", "
263280 | \n", "A_U99 | \n", "C8 | \n", "ADD MARKER | \n", "4 | \n", "difficult | \n", "0 | \n", "pc | \n", "2018-06-05 16:18:34 | \n", "
263281 | \n", "A_U99 | \n", "C8 | \n", "NEXT | \n", "4 | \n", "NaN | \n", "0 | \n", "pc | \n", "2018-06-05 16:19:24 | \n", "
263282 | \n", "A_U99 | \n", "C8 | \n", "NEXT | \n", "5 | \n", "NaN | \n", "0 | \n", "pc | \n", "2018-06-05 16:20:45 | \n", "
263283 | \n", "A_U99 | \n", "C8 | \n", "PREV | \n", "6 | \n", "NaN | \n", "0 | \n", "pc | \n", "2018-06-05 16:21:03 | \n", "
263284 rows × 8 columns
\n", "