{ "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", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
useridcontentsidoperationnamepagenomarkermemo_lengthdevicecodeeventtime
0A_U1C1PREV10NaN0tablet2018-04-09 10:57:15
1A_U1C1PREV9NaN0tablet2018-04-09 11:00:59
2A_U1C1PREV8NaN0tablet2018-04-09 11:03:31
3A_U1C1PREV30NaN0tablet2018-04-10 10:14:12
4A_U1C1PREV29NaN0tablet2018-04-10 10:27:24
...........................
263279A_U99C8NEXT3NaN0pc2018-06-05 16:16:18
263280A_U99C8ADD MARKER4difficult0pc2018-06-05 16:18:34
263281A_U99C8NEXT4NaN0pc2018-06-05 16:19:24
263282A_U99C8NEXT5NaN0pc2018-06-05 16:20:45
263283A_U99C8PREV6NaN0pc2018-06-05 16:21:03
\n", "

263284 rows × 8 columns

\n", "
" ], "text/plain": [ " userid contentsid operationname pageno marker memo_length \\\n", "0 A_U1 C1 PREV 10 NaN 0 \n", "1 A_U1 C1 PREV 9 NaN 0 \n", "2 A_U1 C1 PREV 8 NaN 0 \n", "3 A_U1 C1 PREV 30 NaN 0 \n", "4 A_U1 C1 PREV 29 NaN 0 \n", "... ... ... ... ... ... ... \n", "263279 A_U99 C8 NEXT 3 NaN 0 \n", "263280 A_U99 C8 ADD MARKER 4 difficult 0 \n", "263281 A_U99 C8 NEXT 4 NaN 0 \n", "263282 A_U99 C8 NEXT 5 NaN 0 \n", "263283 A_U99 C8 PREV 6 NaN 0 \n", "\n", " devicecode eventtime \n", "0 tablet 2018-04-09 10:57:15 \n", "1 tablet 2018-04-09 11:00:59 \n", "2 tablet 2018-04-09 11:03:31 \n", "3 tablet 2018-04-10 10:14:12 \n", "4 tablet 2018-04-10 10:27:24 \n", "... ... ... \n", "263279 pc 2018-06-05 16:16:18 \n", "263280 pc 2018-06-05 16:18:34 \n", "263281 pc 2018-06-05 16:19:24 \n", "263282 pc 2018-06-05 16:20:45 \n", "263283 pc 2018-06-05 16:21:03 \n", "\n", "[263284 rows x 8 columns]" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "event_stream.df" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Course information and event stream can be got simultaneously" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "course_info, event_stream = la.start_analysis(files_dir=\"dataset_sample\", course_id=\"A\")\n", "\n", "course_info2, event_stream2 = la.start_analysis(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\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.3" }, "pycharm": { "stem_cell": { "cell_type": "raw", "metadata": { "collapsed": false }, "source": [] } } }, "nbformat": 4, "nbformat_minor": 4 }