diff options
Diffstat (limited to 'blackboard2gradebook.tcl')
-rwxr-xr-x | blackboard2gradebook.tcl | 70 |
1 files changed, 49 insertions, 21 deletions
diff --git a/blackboard2gradebook.tcl b/blackboard2gradebook.tcl index 84c7a4c..3686645 100755 --- a/blackboard2gradebook.tcl +++ b/blackboard2gradebook.tcl @@ -113,25 +113,58 @@ proc trimColName { col } { return [list $shortCol $category $maxScore $type] } +proc veval {script} { + # verbose eval + global dryrun + set cmd "" + foreach line [split $script \n] { + if {$line eq ""} {continue} + append cmd $line\n + if { [info complete $cmd] } { + if { [info exists dryrun] && $dryrun} { + puts -nonewline "DRYRUN: $cmd" + } else { + puts -nonewline "Executing: $cmd" + uplevel 1 $cmd + } + set cmd "" + } + } +} + +## adding students if they do not exist +proc addStudentsFromDB { db } { + # blackboard does not provide the following info + set id unknownID + set section unknownSection + puts "Blackboard does not provide Student ID and Section number, skipping user addition" + return + + set fname [list First Name] + set lname [list Last Name] + set eval_str [concat SELECT * FROM 'export_table'] + set err [catch { + $db eval $eval_str v { + set email $v(Username)@email.wm.edu + veval [list AddUserNonWeb $v($fname) $v($lname) $email student $id $section] + } + } errStat ] + iferror $err $errStat +} + +proc foreignUsername2local { uname } { + return "$uname@email.wm.edu" +} + +######################### START of the execution ######################### +set dryrun true set commonInfoCol {{First Name} {Last Name} {Student ID} {Last Access} Username Availability } set infoColumsMarkers {{ - Lateness \(H:M:S\)} { - Max Points} { - Submission Time} {Total Lateness \(H:M:S\)} {Current Weighted} {Total \[} } set skipCreationCol [concat $commonInfoCol $infoColumsMarkers] -## adding students if they do not exist -set fname [list First Name] -set lname [list Last Name] -set idnum [list Student ID] -set eval_str [concat SELECT * FROM 'export_table'] -set err [catch { - bdb eval $eval_str v { - set email $v(Username)@email.wm.edu - puts [list "Skipping " AddUserNonWeb $v($fname) $v($lname) $email student $v($idnum) 1] - #AddUserNonWeb $v($fname) $v($lname) $email student $v($idnum) 1 - } - } errStat ] -iferror $err $errStat +addStudentsFromDB bdb # now for every user add their grades set username_list [getBlackboardUsernames bdb] @@ -150,23 +183,18 @@ foreach col [getColListFromAnyTable bdb export_table] { continue } if { ![doesColumnExists $shortCol GradesTable] } { - AddColumnNonWeb $shortCol $category $maxScore - #puts [list AddColumnNonWeb $shortCol $category $maxScore] + veval [list AddColumnNonWeb $shortCol $category $maxScore] } foreach uname $username_list { - set locUname $uname@email.wm.edu + set locUname [foreignUsername2local $uname] set grade [getBlackboardUserGrade bdb $uname $col ] if { "" ne $grade } { if { $scoreType eq "Percentage" } { # change percentage to score set grade [ expr {$grade/100*$maxScore} ] } - UpdateColValue4UserNameNonWeb $shortCol $locUname $grade - #puts [list UpdateColValue4UserNameNonWeb $shortCol $locUname $grade] + veval [list UpdateColValue4UserNameNonWeb $shortCol $locUname $grade] } } } - - - |