2 #################################
3 myuw <- read.csv("../data/2022_winter_COM_481_A_students.csv", stringsAsFactors=FALSE)
6 source("../assessment_and_tracking/track_participation.R")
9 rownames(d) <- d$unique.name
10 call.list$timestamp <- as.Date(call.list$timestamp)
12 ## class-level variables
13 gpa.point.value <- 50/(4 - 0.7)
14 question.grades <- c("PLUS"=100, "CHECK"=100-gpa.point.value, "MINUS"=100-(gpa.point.value*2))
15 missed.question.penalty <- gpa.point.value * 0.2 ## 1/5 of a full point on the GPA scale
17 ## inspect set the absence threashold
18 ggplot(d) + aes(x=absences) + geom_histogram(binwidth=1, fill="white",color="black")
19 absence.threshold <- median(d$absences)
22 ## inspect and set the questions cutoff
23 ## questions.cutoff <- median(d$num.calls)
24 ## median(d$num.calls)
25 ## questions.cutoff <- nrow(call.list) / nrow(d) ## TODO talk about this
26 ## this is the 95% percentile based on simulation in simulation.R
29 ## show the distribution of assessments
30 table(call.list$assessment)
31 prop.table(table(call.list$assessment))
33 table(call.list.full$answered)
34 prop.table(table(call.list.full$answered))
36 total.questions.asked <- nrow(call.list)
38 ## find out how man questions folks have present/absent for.
40 ## NOTE: this is currently only for informational purposes and is NOT
41 ## being used to compute grants in any way.
42 ########################################################################
43 calls.per.day <- data.frame(day=as.Date(names(table(call.list$timestamp))),
44 questions.asked=as.numeric(table(call.list$timestamp)))
46 ## function to return the numbers of calls present for or zero if they
48 calls.for.student.day <- function (day, student.id) {
49 if (any(absence$unique.name == student.id & absence$date.absent == day)) {
52 return(calls.per.day$questions.asked[calls.per.day$day == day])
56 compute.questions.present.for.student <- function (student.id) {
57 sum(unlist(lapply(unique(calls.per.day$day), calls.for.student.day, student.id)))
60 ## create new column with number of questions present
61 d$q.present <- unlist(lapply(d$unique.name, compute.questions.present.for.student))
62 d$prop.asked <- d$num.calls / d$q.present
64 ## generate statistics using these new variables
65 prop.asks.quantiles <- quantile(d$prop.asked, probs=seq(0,1, 0.01))
66 prop.asks.quantiles <- prop.asks.quantiles[!duplicated(prop.asks.quantiles)]
68 d$prop.asked.quant <- cut(d$prop.asked, right=FALSE, breaks=c(prop.asks.quantiles, 1),
69 labels=names(prop.asks.quantiles)[1:(length(prop.asks.quantiles))])
72 ########################################################################
74 ## print the median number of questions for (a) everybody and (b)
75 ## people that have been present 75% of the time
78 ## helper function to generate average grade minus number of missing
79 gen.part.grade <- function (x.unique.name) {
80 q.scores <- question.grades[call.list$assessment[call.list$unique.name == x.unique.name]]
81 base.score <- mean(q.scores, na.rm=TRUE)
83 ## number of missing days
84 missing.in.class.days <- nrow(missing.in.class[missing.in.class$unique.name == x.unique.name,])
86 ## return the final score
87 data.frame(unique.name=x.unique.name,
88 base.grade=base.score,
89 missing.in.class.days=missing.in.class.days)
93 ## create the base grades which do NOT include missing questions
94 tmp <- do.call("rbind", lapply(d$unique.name, gen.part.grade))
96 rownames(d) <- d$unique.name
97 d$part.grade <- d$base.grade
99 ## first we handle the zeros
100 ## step 1: first double check the people who have zeros and ensure that they didn't "just" get unlucky"
103 ## set those people to 0 :(
104 d$part.grade[d$num.calls == 0] <- 0
106 ## step 2: identify the people who were were not asked "enough"
107 ## questions but were unlucky/lucky
109 ## first this just prints out are the people were were not called
110 ## simply because they got unlucky
111 d[d$num.calls < questions.cutoff & d$absences < absence.threshold,]
113 ## these are the people were were not called simply unlucky (i.e.,
114 ## they were not in class very often)
115 penalized.unique.names <- d$unique.name[d$num.calls < questions.cutoff & d$absences > absence.threshold]
116 d[d$unique.name %in% penalized.unique.names,]
118 ## now add "zeros" for every questions that is below the normal
119 d[as.character(penalized.unique.names),"part.grade"] <- (
120 (d[as.character(penalized.unique.names),"num.calls"] * d[as.character(penalized.unique.names),"part.grade"])
123 d[as.character(penalized.unique.names),]
125 ## apply the penality for number of days we called on them and they were gone
126 d$part.grade <- d$part.grade - d$missing.in.class.days * missed.question.penalty
128 ## TODO ensure this is right. i think it is
129 ## map part grades back to 4.0 letter scale and points
130 d$part.4point <- round((d$part.grade / gpa.point.value) - ((100 / gpa.point.value) - 4), 2)
132 d[sort.list(d$part.4point, decreasing=TRUE),
133 c("unique.name", "short.name", "num.calls", "absences", "part.4point")]
135 ## writing out data to CSV
136 d.print <- merge(d, myuw[,c("StudentNo", "FirstName", "LastName", "UWNetID")],
137 by.x="unique.name", by.y="StudentNo")
138 write.csv(d.print, file="../data/final_participation_grades.csv")
142 for (id in d$unique.name) {
143 render(input="student_report_template.Rmd",
144 output_format="html_document",
145 output_file=paste("../data/case_grades/",
146 d.print$unique.name[d.print$unique.name == id],