From 6566d3d7cbc021e109ba534d2e67a8a9cc8ad988 Mon Sep 17 00:00:00 2001 From: "Eugeniy E. Mikhailov" Date: Wed, 12 May 2021 23:52:53 -0400 Subject: added DB detection heuristic --- blackboard2gradebook.tcl | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/blackboard2gradebook.tcl b/blackboard2gradebook.tcl index a616a0f..16da2d4 100755 --- a/blackboard2gradebook.tcl +++ b/blackboard2gradebook.tcl @@ -294,12 +294,26 @@ proc alias {alias target} { ######################### START of the execution ######################### -alias foreignUsername2local blackboardUsername2local -alias addStudentsFromForeignDB addStudentsFromBlackboardDB -alias getForeignDBUsernames getBlackboardUsernames -alias getForeignDBUserGrade getBlackboardUserGrade -alias normilizeGrade normilizeBlackboardGrade -alias parseColName parseBlackboardColName +# using heuristic to detect foreign DB origin +set allForeignCols [getColListFromAnyTable foreignDB export_table] +set dbOrigin Blackboard; # default +if { {SID} in $allForeignCols } { set dbOrigin Gradescope } +puts [list Detected foreign DB origin: $dbOrigin] + +switch $dbOrigin { + Blackboard { + alias foreignUsername2local blackboardUsername2local + alias addStudentsFromForeignDB addStudentsFromBlackboardDB + alias getForeignDBUsernames getBlackboardUsernames + alias getForeignDBUserGrade getBlackboardUserGrade + alias normilizeGrade normilizeBlackboardGrade + alias parseColName parseBlackboardColName + } + default { + puts "Unknown DB origin, exiting" + exit 1 + } +} addStudentsFromForeignDB foreignDB -- cgit v1.2.3