-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmastery-progress.R
95 lines (86 loc) · 4.31 KB
/
mastery-progress.R
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
# mastery-progress.R
# A script that takes an exported Learning Mastery outcome report CSV file
# generated by Canvas and creates a simple, readable text-based mastery report.
# By D Brian Walton, February 1, 2020
# Released to the public domain. Feel free to use this in any way that helps you.
# Modify file names, groups and outcomes to match your use case.
# Objectives for Math 234 are organized in outcome groups.
# Here is information about the groups that will be used in the report.
# The short codes are used in the script for grouping.
outcome.groups=c("G1","G2","G3","G4","G5","G6")
# The names are used in formatted text.
group.names = list(G1="Cross-Over",
G2="Derivatives",
G3="Limits",
G4="Applications",
G5="Trigonometry",
G6="Integration"
)
# This is a list of all possible outcomes, organized by groups and sorted
# into the order that I wish to use. I only use short codes. The full title
# does appear in the CSV file that will be imported. These codes appear at the
# start of the relevant title in the Canvas outcome.
all.outcomes = list(G1=c("CO1","CO2a","CO2b","CO3","CO4"),
G2=c("D1","D2","D3a","D3b","D4a","D4b","D5","D6","D7a","D7b","D7c","D7d","D7e","D7f","D7g","D7h","D8a","D8b","D8c","D9"),
G3=c("L1","L2","L3","L4","L5","L6","L7"),
G4=c("A1","A2","A3","A4","A5"),
G5=c("T1","T2","T3","T4"),
G6=c("I1","I2a","I2b","I2c","I2d","I2e","I2f","I3","I4","I5","I6","I7","I8")
)
# When I generate the report, I only include some of the outcomes.
# As the semester progresses, more and more of the outcomes will be included.
active.groups = c("G1","G2")
active.outcomes = list(G1=c("CO1","CO2a","CO2b","CO3","CO4"),
G2=c("D1","D2","D3a","D3b")
)
# Now I import the CSV file that Canvas provided.
# The as.is flag is to prevent text from being cast as a factor.
Math234.outcomes = read.csv("~/Downloads/Outcomes-Calculus_with_Modeling_II.csv",
as.is=TRUE
)
# We will need to find the outcomes based on the header entries for the columns.
header.names = names(Math234.outcomes)
# Find the columns belonging to outcomes of interest.
# This is done in a pre-processing step so that we don't have to do the
# work repeatedly for every student. The outcome.lookup list is being
# treated like a Python dictionary or a hash table so that I can find
# the column belonging to a particular outcome based on the group and
# outcome codes.
outcome.lookup = list()
for (group in active.groups) {
for (outcome in active.outcomes[[group]]) {
# We find the column by doing a grep (regex) search on the headers.
# The column ending in ".result" is the one with scores.
column = grep(sprintf("%s.*%s.*.result", group, outcome), header.names)
# Store the relevant column number in our hash table list.
outcome.lookup[sprintf("%s.%s",group,outcome)] = column
}
}
# The column with student names is not sorted.
# It is also a single entry "FirstName LastName"
# I want to sort by last name. (I don't worry about repeat names)
students = Math234.outcomes$Student.name
last.names = sapply(strsplit(students, " "), tail, 1)
# This essentially sorts just the index of students rather than the list itself.
alpha = order(last.names)
# Now we are going to go through the students in the sorted order.
# This generates a short text block for each student.
for (i in alpha) {
# First, create a line identifying the student's name
name = Math234.outcomes$Student.name[i]
cat("\n\n\n", name, "\n\n", sep="")
# For each student, look up their current progress in outcomes
for (group in active.groups) {
for (outcome in active.outcomes[[group]]) {
# Find the outcome's column from our earlier hash table.
column = outcome.lookup[[sprintf("%s.%s",group,outcome)]]
# My format choice is to show a blank on unmastered outcomes.
mastery = ""
if (!is.na(Math234.outcomes[i,column])) {
mastery = "Mastery Shown"
}
cat(group.names[[group]], " ", outcome, ": ", mastery, "\n", sep="")
}
cat("\n")
}
}