diff options
-rwxr-xr-x | importGrades2gradebook.tcl | 81 |
1 files changed, 76 insertions, 5 deletions
diff --git a/importGrades2gradebook.tcl b/importGrades2gradebook.tcl index e89bfd5..ed17a6b 100755 --- a/importGrades2gradebook.tcl +++ b/importGrades2gradebook.tcl @@ -117,6 +117,20 @@ proc getColListFromAnyTable {db table} { return $all_column_names } +proc getColValuesFromAnyTable {db table col} { + set values {} + set eval_str [concat SELECT $col FROM $table] + puts $eval_str + set err [catch { + $db eval $eval_str v { + lappend values $v($col) + } + } errStat ] + iferror $err $errStat + if { $err } { return false } + return $values +} + proc getBlackboardUsernames { db } { set username_list {} set eval_str [concat SELECT Username FROM export_table] @@ -156,6 +170,10 @@ proc getWebassignUsernames { db } { return $username_list } +proc getTheExperTAUsernames { db } { + return [getColValuesFromAnyTable $db export_table UserName] +} + proc getBlackboardUserGrade { db uname col } { set eval_str [concat SELECT \"$col\" FROM export_table where Username=='$uname'] @@ -175,6 +193,12 @@ proc getWebassignUserGrade { db uname col } { return $val } +proc getTheExperTAUserGrade { db uname col } { + set eval_str [concat SELECT \"$col\" FROM export_table where UserName=='$uname'] + set val [$db onecolumn $eval_str] + return $val +} + proc isInList { col listCol} { foreach sCol $listCol { set result [regexp $sCol $col match] @@ -341,6 +365,19 @@ proc parseWebassignColName { col } { return [list $shortCol $category $maxScore $type] } +proc parseTheExperTAColName { col db } { + set shortCol $col + set category ColumnInfo + set maxScore 0 + set type Score + + global username_list + + set maxScore [getTheExperTAUserGrade $db _Max_Points_ $col] + set category [getTheExperTAUserGrade $db _Col_Category_ $col] + + return [list $shortCol $category $maxScore $type] +} proc dbRequest {script} { # verbose evaluation of dbRequest with dry run capability @@ -413,6 +450,30 @@ proc addStudentsFromWebassignDB { db } { # adding students from WebAssign is not implemented } +proc addStudentsFromTheExperTADB { db } { + # blackboard does not provide the following info + set section unknownSection + global ADDSTUDENT + if { ! $ADDSTUDENT } { + puts "Skipping user addition: Gradescope does not provide Section number" + return + } + + set fname [list FirstName] + set lname [list LastName] + 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 $v($idnum) $section] + } + } errStat ] + iferror $err $errStat +} + + proc blackboardUsername2local { uname } { #return "$uname@email.wm.edu" # since 2022 @@ -425,7 +486,9 @@ proc noTransformationNeededUsername2local { uname } { proc updateGrade { col locUname grade } { if { ! [isThereUserNameInTheGradesTable $locUname] } { - dbg [list "GradesDB does not have user" $locUname] + set foreignFirstName [getForeignDBUserGrade foreignDB $locUname FirstName] + set foreignLastName [getForeignDBUserGrade foreignDB $locUname LastName] + dbg [list "GradesDB does not have user" $locUname "-->" $foreignFirstName $foreignLastName] return } set oldGrade [SelectColValue4User $col $locUname ] @@ -444,7 +507,7 @@ proc updateGrade { col locUname grade } { } } -proc pickCols2import { cols2import skipCreationCol categories2import } { +proc pickCols2import { cols2import skipCreationCol categories2import db} { set reduced_list {} foreach col $cols2import { if { "$col" eq "" } { @@ -455,7 +518,7 @@ proc pickCols2import { cols2import skipCreationCol categories2import } { dbg "skipping column $col, it is in $skipCreationCol list" continue } - set colInfo [parseColName $col] + set colInfo [parseColName $col $db] set category [lindex $colInfo 1] if { $category ni $categories2import } { dbg [list skipping $col in $category, permitted categories: $categories2import] @@ -551,6 +614,14 @@ switch $dbOrigin { alias normilizeGrade normilizeGradescopeGrade alias parseColName parseWebassignColName } + TheExpertTA { + alias foreignUsername2local noTransformationNeededUsername2local + alias addStudentsFromForeignDB addStudentsFromTheExperTADB + alias getForeignDBUsernames getTheExperTAUsernames + alias getForeignDBUserGrade getTheExperTAUserGrade + alias normilizeGrade normilizeGradescopeGrade + alias parseColName parseTheExperTAColName + } default { puts "Unknown DB origin, exiting" exit 1 @@ -563,10 +634,10 @@ addStudentsFromForeignDB foreignDB set username_list [getForeignDBUsernames foreignDB]; # important, will be used as global set cols2import [getColListFromAnyTable foreignDB export_table] -set cols2import [ pickCols2import $cols2import $skipCreationCol $categories2import] +set cols2import [ pickCols2import $cols2import $skipCreationCol $categories2import foreignDB] foreach col $cols2import { - set colInfo [parseColName $col] + set colInfo [parseColName $col foreignDB] set shortCol [lindex $colInfo 0] set category [lindex $colInfo 1] set maxScore [lindex $colInfo 2] |