]> code.communitydata.science - coldcallbot-discord.git/blob - data/case_grades/compute_final_case_grades.R
updated with final participation grades (
[coldcallbot-discord.git] / data / case_grades / compute_final_case_grades.R
1 ## load in the data
2 #################################
3
4 case.sessions  <- 15
5 myuw <- read.csv("../myuw-COM_482_A_autumn_2020_students.csv", stringsAsFactors=FALSE)
6
7 ## class-level variables
8 question.grades <- c("GOOD"=100, "FAIR"=100-(50/3.3), "BAD"=100-(50/(3.3)*2))
9 missed.question.penalty <- (50/3.3) * 0.2 ## 1/5 of a full point on the GPA scale
10
11 setwd("../")
12 source("track_participation.R")
13 setwd("case_grades")
14
15 rownames(d) <- d$discord.name
16
17 ## show the distribution of assessments
18 table(call.list.full$assessment)
19 prop.table(table(call.list.full$assessment))
20 table(call.list.full$answered)
21 prop.table(table(call.list.full$answered))
22
23 total.questions.asked <- nrow(call.list.full)
24
25 ## create new column with number of questions present
26 d$prop.asked <- d$num.calls / d$num.present
27
28 ## generate statistics using these new variables
29 prop.asks.quantiles <- quantile(d$prop.asked, probs=seq(0,1, 0.01))
30 prop.asks.quantiles <- prop.asks.quantiles[!duplicated(prop.asks.quantiles)]
31
32 ## this is generating broken stuff but it's not used for anything
33 d$prop.asked.quant <- cut(d$prop.asked, breaks=prop.asks.quantiles,
34     labels=names(prop.asks.quantiles)[1:(length(prop.asks.quantiles)-1)])
35
36 ## generate grades
37 ##########################################################
38
39 d$part.grade <- NA
40
41 ## print the median number of questions for (a) everybody and (b)
42 ## people that have been present 75% of the time
43 median(d$num.calls[d$days.absent < 0.25*case.sessions])
44 median(d$num.calls)
45
46 questions.cutoff <- median(d$num.calls)
47
48 ## helper function to generate average grade minus number of missing
49 gen.part.grade <- function (x.discord.name) {
50     q.scores <- question.grades[call.list$assessment[call.list$discord.name == x.discord.name]]
51     base.score <- mean(q.scores, na.rm=TRUE)
52
53     ## number of missing days
54     missing.days <- nrow(missing.in.class[missing.in.class$discord.name == x.discord.name,])
55
56     ## return the final score
57     data.frame(discord.name=x.discord.name,
58                part.grade=(base.score - missing.days * missed.question.penalty))
59 }
60
61 tmp <- do.call("rbind", lapply(d$discord.name[d$num.calls >= questions.cutoff], gen.part.grade))
62
63 d[as.character(tmp$discord.name), "part.grade"] <- tmp$part.grade
64
65 ## next handle the folks *under* the median
66
67 ## first we handle the zeros
68 ## step 1: first double check the people who have zeros and ensure that they didn't "just" get unlucky"
69 d[d$num.calls == 0,]
70
71 ## set those people to 0 :(
72 d$part.grade[d$num.calls == 0] <- 0
73
74 ## step 2 is to handle folks who got unlucky in the normal way
75 tmp <- do.call("rbind", lapply(d$discord.name[is.na(d$part.grade) & d$prop.asked <= median(d$prop.asked)], gen.part.grade))
76 d[as.character(tmp$discord.name), "part.grade"] <- tmp$part.grade
77
78 ## the people who are left are lucky and still undercounted so we'll penalize them
79 d[is.na(d$part.grade),]
80 penalized.discord.names <- d$discord.name[is.na(d$part.grade)]
81
82 ## generate the baseline participation grades as per the process above
83 tmp <- do.call("rbind", lapply(penalized.discord.names, gen.part.grade))
84 d[as.character(tmp$discord.name), "part.grade"] <- tmp$part.grade
85
86 ## now add "zeros" for every questions that is below the normal
87 d[as.character(penalized.discord.names),"part.grade"] <- ((
88     (questions.cutoff - d[as.character(penalized.discord.names),"num.calls"] * 0) +
89     (d[as.character(penalized.discord.names),"num.calls"] * d[as.character(penalized.discord.names),"part.grade"]) )
90     / questions.cutoff)
91
92 d[as.character(penalized.discord.names),]
93
94 ## map part grades back to 4.0 letter scale and points
95 d$part.4point <-round((d$part.grade / (50/3.3)) - 2.6, 2)
96
97 d[sort.list(d$prop.asked), c("discord.name", "num.calls", "num.present",
98                              "prop.asked", "prop.asked.quant", "part.grade", "part.4point",
99                              "days.absent")]
100
101 d[sort.list(d$part.4point), c("discord.name", "num.calls", "num.present",
102                              "prop.asked", "prop.asked.quant", "part.grade", "part.4point",
103                              "days.absent")]
104
105
106 ## writing out data
107 quantile(d$num.calls, probs=(0:100*0.01))
108 d.print <- merge(d, myuw[,c("StudentNo", "FirstName", "LastName", "UWNetID")],
109            by.x="student.num", by.y="StudentNo")
110 write.csv(d.print, file="final_participation_grades.csv")
111
112 library(rmarkdown)
113
114 for (x.discord.name in d$discord.name) {
115     render(input="student_report_template.Rmd",
116            output_format="html_document",
117            output_file=paste("student_reports/",
118                              d.print$UWNetID[d.print$discord.name == x.discord.name],
119                              sep=""))
120 }

Community Data Science Collective || Want to submit a patch?