-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstudent_step.Rmd
197 lines (129 loc) · 6.95 KB
/
student_step.Rmd
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
```{r}
library(lme4)
library(dplyr)
library(ggplot2)
```
```{r}
df <- read.csv("/Users/daniellaye/Desktop/regression/match_sai_by_student_fixed_repeat.csv")
df_stu <- data.frame(df, na.string = "", stringsAsFactors = FALSE)
```
```{r}
# For every student
# Make step slices, each step slice distinguished by sumCorrect
# might need to change how step slice is defined
all <- df_stu %>%
select(Anon.Student.Id, Time, Problem.Name, KC..Field., Outcome, error_type, KC_toward) %>%
group_by(Anon.Student.Id) %>%
mutate(correct = ifelse(Outcome == "CORRECT", 1, 0),
sumCorrect = cumsum(correct))
all[all$correct == 0, ]$sumCorrect <- all[all$correct == 0, ]$sumCorrect + 1
```
```{r}
# for each student, for each step slice
all <- all %>% group_by(Anon.Student.Id, sumCorrect) %>%
mutate(KC_name = KC..Field.[length(KC..Field.)], # KC_name is the KC student is working toward,
# KC of last row in step slice
first_error = error_type[1], # first error in the step slice
hint_used = ifelse("HINT" %in% Outcome, "hint", ""), # Whether stu has used hint in that step slice
# gen = ifelse( ( ("INCORRECT" %in% Outcome) | ("HINT" %in% Outcome) ), 1, 0),
gen = ifelse( (Outcome[1] == "INCORRECT" | Outcome[1] == "HINT"), 1, 0), # general error
# firstHint = ifelse("HINT" %in% Outcome, 1, 0),
firstHint = ifelse(Outcome[1] == "HINT", 1, 0),
totalCor = sum(Outcome == "CORRECT"), # Total number of CORRECT in step slice
totalIncorrect = sum(Outcome == "INCORRECT"), # Total number of INCORRECT
totalHint = sum(Outcome == "HINT"), # Total number of hints used
totalInc = sum(error_type == "incorrect"), # ...
totalOut = sum(error_type == "out of graph"),
totalWhen = sum(error_type == "when error"),
totalMis = sum(error_type == "misapplied"),
totalWhere = sum(error_type == "where error"),
totalWild = sum(error_type == "wild error"),
total = totalHint + totalInc + totalOut + totalWhen + totalMis + totalWhere + totalWild) %>%
distinct(all, .keep_all=TRUE) # Keep only first row for each step slice, so #row = #step slice
View(all)
```
```{r}
# Make a copy
all_ <- all
all_[all_$correct == 1, ]$first_error <- "correct"
all_ <- all_ %>% select(Anon.Student.Id, Time, sumCorrect, KC_name, gen, firstHint, first_error, hint_used, totalCor, totalIncorrect, totalHint, totalInc, totalOut, totalWhen, totalMis, totalWhere, totalWild, total)
View(all_)
```
```{r}
# Add new columns indicating which first error
all_ <- all_ %>% mutate(firstWhen = ifelse(first_error == "when error", 1, 0),
firstInc = ifelse(first_error == "incorrect", 1, 0),
firstOut = ifelse(first_error == "out of graph", 1, 0),
firstMis = ifelse(first_error == "misapplied", 1, 0),
firstWhere = ifelse(first_error == "where error", 1, 0),
firstWild = ifelse(first_error == "wild error", 1, 0)
)
View(all_)
```
```{r}
# Count opp for each student:
# For each student, for each KC being worked toward, count number of step slice(rows)
all_ <- all_ %>% group_by(Anon.Student.Id, KC_name) %>%
mutate(opp = seq.int(n())) %>% arrange(by_group = KC_name)
all_ <- all_[all_$KC_name != "", ]
all_$opp <- as.factor(all_$opp)
View(all_)
```
```{r}
#all_kc <- all_ %>% select(KC_name, gen, opp) # %>% arrange(by_group = opp)
#all_kc <- subset(all_, select = c(KC_name, gen, opp, first_error, firstHint))
#View(all_kc)
```
Aggregated across KC:
```{r}
# For opp = 1, 2...
all_kc <- all_ %>% group_by(opp) %>% summarise(n = n(),
sumGen = sum(gen), rate = sumGen/n,
sumHint = sum(firstHint), rateHint = sumHint/n,
sumWhen = sum(firstWhen), rateWhen = sumWhen/n,
sumWhere = sum(firstWhere), rateWhere = sumWhere/n,
sumInc = sum(firstInc), rateInc = sumInc/n,
sumOut= sum(firstOut), rateOut = sumOut/n,
sumMis = sum(firstMis), rateMis = sumMis/n,
sumWild = sum(firstWild), rateWild = sumWild/n
)
all_kc
```
```{r}
# Plot
all_kc$opp <- as.numeric(all_kc$opp)
ggplot(all_kc) + geom_line(aes(x = opp, y = rate), color = "black") +
geom_line(aes(x = opp, y = rateHint), color = "purple") +
geom_line(aes(x = opp, y = rateWhen), color = "pink") +
geom_line(aes(x = opp, y = rateWhere), color = "orange") +
geom_line(aes(x = opp, y = rateInc), color = "brown") +
geom_line(aes(x = opp, y = rateOut), color = "blue") +
geom_line(aes(x = opp, y = rateMis), color = "green") +
geom_line(aes(x = opp, y = rateWild), color = "lightblue") + xlim(1, 25) + ylim(0, 0.35) + theme(legend.position = "bottom")
```
```{r}
```
View this by individual KC:
```{r}
ind_kc <- all_ %>% group_by(KC_name, opp) %>% summarise(n = n(),
sumGen = sum(gen), rate = sumGen/n,
sumHint = sum(firstHint), rateHint = sumHint/n,
sumWhen = sum(firstWhen), rateWhen = sumWhen/n,
sumWhere = sum(firstWhere), rateWhere = sumWhere/n,
sumInc = sum(firstInc), rateInc = sumInc/n,
sumOut= sum(firstOut), rateOut = sumOut/n,
sumMis = sum(firstMis), rateMis = sumMis/n,
sumWild = sum(firstWild), rateWild = sumWild/n
)
ind_kc
#all_kc2$KC_name <- as.factor(KC_name)
ind_kc$opp <- as.numeric(ind_kc$opp)
ggplot(ind_kc) + #geom_line(aes(x = opp, y = rate), color = "black") +
geom_line(aes(x = opp, y = rateHint), color = "purple") +
geom_line(aes(x = opp, y = rateWhen), color = "pink") +
geom_line(aes(x = opp, y = rateWhere), color = "orange") +
geom_line(aes(x = opp, y = rateInc), color = "brown") +
geom_line(aes(x = opp, y = rateOut), color = "blue") +
geom_line(aes(x = opp, y = rateMis), color = "green") +
geom_line(aes(x = opp, y = rateWild), color = "lightblue") + xlim(1, 25) + ylim(0, 0.5) + facet_wrap( ~KC_name, nrow = 4)
```