77ROLL_CALL_CSV = (
88 "~/Downloads/attendance_reports_attendance-264e4d14-1765-4396-b311-4d927b59566d.csv"
99)
10+ # get by clicking into the Assignment and getting from the URL
11+ ASSIGNMENT_ID = 1405957
12+ GRADEBOOK_FILE = "attendance.csv"
1013STUDENT_UNIQUE_COLS = ["Student ID" , "Student Name" , "Section Name" , "Section" ]
1114
1215
@@ -74,6 +77,28 @@ def compute_scores(entries: pd.DataFrame):
7477 return scores
7578
7679
80+ def write_canvas_csv (scores : pd .Series ):
81+ """https://community.canvaslms.com/t5/Instructor-Guide/How-do-I-import-grades-in-the-Gradebook/ta-p/807"""
82+
83+ attendance_col = f"Attendance ({ ASSIGNMENT_ID } )"
84+
85+ gradebook = (
86+ scores .reset_index (name = attendance_col )
87+ .drop (columns = ["Section" ])
88+ .rename (
89+ columns = {
90+ # Roll Call has `FIRST LAST`, gradebook has `LAST, FIRST`. Shouldn't matter.
91+ "Student Name" : "Student" ,
92+ "Student ID" : "ID" ,
93+ "Section Name" : "Section" ,
94+ }
95+ )
96+ )
97+ gradebook .to_csv (GRADEBOOK_FILE , index = False )
98+
99+ print (f"Now upload { GRADEBOOK_FILE } to CourseWorks Gradebook." )
100+
101+
77102def run ():
78103 entries = get_entries (ROLL_CALL_CSV )
79104 validate (entries )
@@ -82,12 +107,11 @@ def run():
82107 print_heading ("Scores" )
83108 print_students (scores )
84109
85- # TODO write to CSV
86- # https://community.canvaslms.com/t5/Instructor-Guide/How-do-I-import-grades-in-the-Gradebook/ta-p/807
87-
88110 lowered_scores = scores [scores < TOP_SCORE ]
89111 print_heading (f"Scores for students who missed more than { FREEBIES } class(es)" )
90112 print_students (lowered_scores .sort_values ())
91113
114+ write_canvas_csv (scores )
115+
92116
93117run ()
0 commit comments