diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-05-13 10:59:54 -0400 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2021-05-13 10:59:54 -0400 |
commit | 4687cf9534523f411649dd28aa30ee041845db3f (patch) | |
tree | 00a070f5c07ba3ef062baeb6fa689eeff7f6bb45 | |
parent | 77fa922a7c7949dfc62f8b075b627b00acda1855 (diff) | |
download | GradeBook-4687cf9534523f411649dd28aa30ee041845db3f.tar.gz GradeBook-4687cf9534523f411649dd28aa30ee041845db3f.zip |
added Blackboard import
-rwxr-xr-x | blackboard2gradebook.tcl | 97 |
1 files changed, 96 insertions, 1 deletions
diff --git a/blackboard2gradebook.tcl b/blackboard2gradebook.tcl index be8665b..a4944d6 100755 --- a/blackboard2gradebook.tcl +++ b/blackboard2gradebook.tcl @@ -123,12 +123,33 @@ proc getBlackboardUsernames { db } { return $username_list } +proc getGradescopeUsernames { db } { + set username_list {} + set eval_str [concat SELECT Email FROM export_table] + set err [catch { + $db eval $eval_str v { + lappend username_list $v(Email) + } + } errStat ] + iferror $err $errStat + if { $err } { return false } + return $username_list +} + + proc getBlackboardUserGrade { db uname col } { set eval_str [concat SELECT \"$col\" FROM export_table where Username=='$uname'] set val [$db onecolumn $eval_str] return $val } +proc getGradescopeUserGrade { db uname col } { + set eval_str [concat SELECT \"$col\" FROM export_table where Email=='$uname'] + set val [$db onecolumn $eval_str] + return $val +} + + proc isInList { col listCol} { foreach sCol $listCol { set result [regexp $sCol $col match] @@ -174,6 +195,37 @@ proc parseBlackboardColName { col } { return [list $shortCol $category $maxScore $type] } +proc parseGradescopeColName { col } { + set shortCol $col + set category ColumnInfo + set maxScore 0 + set type Score + + set infoColumsMarkers {{ - Lateness \(H:M:S\)} { - Max Points} { - Submission Time} {Total Lateness \(H:M:S\)}} + if { [isInList $col $infoColumsMarkers] } { + return [list $shortCol $category $maxScore $type] + } + + set number {} + set name $shortCol + set result [regexp -nocase {(\D+)(\d+)} $shortCol match name number] + set result [regexp -nocase {(\S+)\s+$} $name match name] + switch $name { + Homework { set name Homework ; set category HomeWork } + Lab { set name Lab ; set category LabReport} + "Final Project Design" { set category FinalExam } + "Final Project Report" { set category FinalExam } + default { } + } + if { $number eq "" } { + set shortCol "$name" + } else { + set shortCol "$name $number" + } + #puts [list $col "--->" $shortCol $category $maxScore $type] + return [list $shortCol $category $maxScore $type] +} + proc dbRequest {script} { # verbose evaluation of dbRequest with dry run capability global DRYRUN @@ -213,10 +265,35 @@ proc addStudentsFromBlackboardDB { db } { iferror $err $errStat } +proc addStudentsFromGradescopeDB { db } { + # blackboard does not provide the following info + set section unknownSection + puts "Gradescope does not provide Section number, skipping user addition" + return + + set fname [list First Name] + set lname [list Last Name] + set idnum [list SID] + set eval_str [concat SELECT * FROM 'export_table'] + set err [catch { + $db eval $eval_str v { + set username [gradescopeUsername2local $v(Email)] + set id $v($idnum) + dbRequest [list AddUserNonWeb $v($fname) $v($lname) $username student $id $section] + } + } errStat ] + iferror $err $errStat +} + proc blackboardUsername2local { uname } { return "$uname@email.wm.edu" } +proc gradescopeUsername2local { uname } { + return $uname +} + + proc updateGrade { col locUname grade } { set oldGrade [SelectColValue4User $col $locUname ] #puts "$locUname: $col oldGrade \{$oldGrade\} --> \{$grade\}" @@ -266,6 +343,16 @@ proc normilizeBlackboardGrade { grade colInfo } { return $grade } +proc normilizeGradescopeGrade { grade colInfo } { + set shortCol [lindex $colInfo 0] + set category [lindex $colInfo 1] + set maxScore [lindex $colInfo 2] + set scoreType [lindex $colInfo 3] + # Gradescope always provides absolute Score, no need to change it + return $grade +} + + proc alias {alias target} { # makes alias to a proc, borrowed from # https://wiki.tcl-lang.org/page/proc+alias @@ -295,7 +382,7 @@ proc alias {alias target} { ######################### START of the execution ######################### # using heuristic to detect foreign DB origin -set allForeignCols [getColListFromAnyTable foreignDB export_table] +set allForeignCols [getColListFromAnyTable foreignDB export_table]; # important global set dbOrigin Blackboard; # default if { {SID} in $allForeignCols } { set dbOrigin Gradescope } puts [list Detected foreign DB origin: $dbOrigin] @@ -309,6 +396,14 @@ switch $dbOrigin { alias normilizeGrade normilizeBlackboardGrade alias parseColName parseBlackboardColName } + Gradescope { + alias foreignUsername2local gradescopeUsername2local + alias addStudentsFromForeignDB addStudentsFromGradescopeDB + alias getForeignDBUsernames getGradescopeUsernames + alias getForeignDBUserGrade getGradescopeUserGrade + alias normilizeGrade normilizeGradescopeGrade + alias parseColName parseGradescopeColName + } default { puts "Unknown DB origin, exiting" exit 1 |