-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetSubmissionDataframes.py
96 lines (71 loc) · 3.2 KB
/
getSubmissionDataframes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import pandas as pd
def getFileInStudentSubmission(df, student, assignment, fileName):
'''
Returns a dataframe that shows all submission data for a single file on a given assignment, for a given student
df - a dataframe of keystroke data
student - a string representing the SubjectID to filter by
assignment - a strinng representing the filename to filter by
fileName - the name of the file to filter by
Returns a COPY of the dataframe, containing only the selected student, assignment, and file
'''
f = df[
(df.SubjectID == student)
& (df.AssignmentID == assignment)
& (df.CodeStateSection == fileName)
].copy()
return f
def getStudentSubmission(df, student, assignment):
'''
Returns a dataframe that shows all submission data for all files on a given assignment, for a given student
df - a dataframe of keystroke data
student - a string representing the SubjectID to filter by
assignment - a string representing the filename to filter by
Returns a COPY of the dataframe, containing only the selected student and assignment
'''
f = df[
(df.SubjectID == student)
& (df.AssignmentID == assignment)
].copy()
return f
def filterDownToRunAndEdits(df):
'''
Filter down a dataframe to just have Edit and Run events
df must be a dataframe of keystroke data. Usually, this dataframe will
already be filtered down to be representing a single students
submission
Return a view of a dataframe with just the run and edit events
'''
return df[(
(df.EventType == 'File.Edit')
| (df.EventType == 'Run.Program')
)]
def filterDownToRunAndEditsAndPastes(df):
'''
Filter down a dataframe to just have Edit, Run, and Paste events
df must be a dataframe of keystroke data. Usually, this dataframe will
already be filtered down to be representing a single students
submission
Return a view of a dataframe with just the run, edit, and paste events
'''
return df[(
(df.EventType == 'File.Edit')
| (df.EventType == 'Run.Program')
| (df.EventType == 'X-Paste')
)]
def getStudentSubmissionRunsAndEdits(df, student, assignment):
'''
Returns a dataframe that shows all submission data for a given assignment, for a given student, with only run and edit events
df - a dataframe of keystroke data
student - a string representing the SubjectID to filter by
assignment - a strinng representing the filename to filter by
'''
return filterDownToRunAndEdits(getStudentSubmission(df, student, assignment))
def getFileInStudentSubmissionRunsAndEdits(df, student, assignment, fileName):
'''
Returns a dataframe that shows all submission data for a single file on a given assignment, for a given student, with only run and edit events
df - a dataframe of keystroke data
student - a string representing the SubjectID to filter by
assignment - a strinng representing the filename to filter by
fileName - the name of the file to filter by
'''
return filterDownToRunAndEdits(getFileInStudentSubmission(df, student, assignment, fileName))