Skip to content

Commit

Permalink
Fix various grade-related bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jpahm committed Oct 9, 2024
1 parent c246087 commit a8cd16c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion grade-data/24S.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Subject,Catalog Nbr,Section,A+,A,A-,B+,B,B-,C+,C,C-,D+,D,D-,F,CR,I,NC,W,P,Instructor 1,Instructor 2,Instructor 3,Instructor 4,Instructor 5,Instructor 6
Subject,Catalog Nbr,Section,A+,A,A-,B+,B,B-,C+,C,C-,D+,D,D-,F,CR,I,NC,W,P,Instructor 1,Instructor 2,Instructor 3,Instructor 4,Instructor 5,Instructor 6
ACCT,2301,001,4,6,11,7,7,2,8,6,6,,4,,3,,,,3,,"Zhang, Jieying","Ozel, Naim Bugra","Gu, Dongdi","Zhang, Yang",,
ACCT,2301,002,6,9,16,7,11,1,7,4,3,,1,,,,,,2,,"Ozel, Naim Bugra","Zhang, Jieying","Gu, Dongdi","Zhang, Yang",,
ACCT,2301,003,8,11,18,6,6,,2,3,5,,3,,1,,,,4,,"Ozel, Naim Bugra","Zhang, Jieying","Gu, Dongdi","Zhang, Yang",,
Expand Down
12 changes: 5 additions & 7 deletions parser/gradeLoader.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"os"
"path/filepath"
"strconv"
"strings"
)

Expand Down Expand Up @@ -126,22 +127,19 @@ func csvToMap(csvFile *os.File, logFile *os.File) map[string][]int {

for _, record := range records {
// convert grade distribution from string to int
intSlice := make([]int, 0, 13)
var tempInt int
intSlice := [14]int{}

for j := 0; j < 13; j++ {
fmt.Sscan(record[aPlusCol+j], &tempInt)
intSlice = append(intSlice, tempInt)
intSlice[j], _ = strconv.Atoi(record[aPlusCol+j])
}
// add w number to the grade_distribution slice
if wCol != -1 {
fmt.Sscan(record[wCol], &tempInt)
intSlice[13], _ = strconv.Atoi(record[wCol])
}
intSlice = append(intSlice, tempInt)

// add new grade distribution to map, keyed by SUBJECT + NUMBER + SECTION
distroKey := record[subjectCol] + record[catalogNumberCol] + record[sectionCol]
distroMap[distroKey] = intSlice
distroMap[distroKey] = intSlice[:]
}
return distroMap
}
4 changes: 3 additions & 1 deletion parser/sectionParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ func parseSection(courseRef *schema.Course, classNum string, syllabusURI string,

semesterGrades, exists := GradeMap[session.Name]
if exists {
sectionGrades, exists := semesterGrades[courseRef.Subject_prefix+courseRef.Course_number+section.Section_number]
// We have to trim leading zeroes from the section number in order to match properly, since the grade data does not use leading zeroes
trimmedSectionNumber := strings.TrimLeft(section.Section_number, "0")
sectionGrades, exists := semesterGrades[courseRef.Subject_prefix+courseRef.Course_number+trimmedSectionNumber]
if exists {
section.Grade_distribution = sectionGrades
}
Expand Down

0 comments on commit a8cd16c

Please sign in to comment.