aboutsummaryrefslogtreecommitdiff
path: root/blackboard2gradebook.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'blackboard2gradebook.tcl')
-rwxr-xr-xblackboard2gradebook.tcl48
1 files changed, 36 insertions, 12 deletions
diff --git a/blackboard2gradebook.tcl b/blackboard2gradebook.tcl
index 81e2be4..5bce8e2 100755
--- a/blackboard2gradebook.tcl
+++ b/blackboard2gradebook.tcl
@@ -4,15 +4,50 @@
exec tclsh "$0" "$@"
package require Tcl 8.5
+package require try ;# Tcllib.
+package require cmdline 1.5 ;# First version with proper error-codes.
package require json::write
package require sqlite3
package require md5
source ./GradeBook_lib.tcl
-################# Config ############################################
+set options {
+ {w "Write to database, disabled by default"}
+}
+set usage "
+Usage:
+ $argv0 \[options] gradebook.sqlitedb blackboard.sqlitedb
+
+ Expect both DB files to be sqilte tables.
+ Exported DB should have a single table 'export_table'
+
+Example:
+ $argv0 2020_Fall_Phys251 blackboard.db
+
+Options:"
+
+try {
+ array set params [::cmdline::getoptions argv $options $usage]
+ #parray params
+
+ # Note: argv is modified now. The recognized options are
+ # removed from it, leaving the non-option arguments behind.
+ if { [llength $argv] < 2 } {
+ throw {CMDLINE USAGE} [::cmdline::usage $options $usage]
+ }
+} trap {CMDLINE USAGE} {msg o} {
+ # Trap the usage signal, print the message, and exit the application.
+ # Note: Other errors are not caught and passed through to higher levels!
+ puts $msg
+ exit 1
+}
+
# if DRYRUN is true the database will not be modified
set DRYRUN true
+set DRYRUN [expr {!$params(w)}]
+
+################# Config ############################################
#set categories2export [list FinalExam HomeWork LabReport]
set categories2export [list FinalExam]
@@ -22,17 +57,6 @@ set infoColumsMarkers {{ - Lateness \(H:M:S\)} { - Max Points} { - Submission Ti
set skipCreationCol [concat $commonInfoCol $infoColumsMarkers]
######################################################################
-if { $argc < 2 } {
- puts {Usage:}
- puts " $argv0 gradebook.sqlitedb blackboard.sqlitedb"
- puts {}
- puts { expect both files to be sqilte tables:}
- puts { blackboard should have a single table 'export_table':}
- puts {Example:}
- puts [concat " $argv0" { 2020_Fall_Phys251 blackboard.db}]
- exit
-}
-
set classDB [lindex $argv 0]
set blackboardDB [lindex $argv 1]