aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy E. Mikhailov <evgmik@gmail.com>2021-05-12 18:23:31 -0400
committerEugeniy E. Mikhailov <evgmik@gmail.com>2021-05-12 18:23:31 -0400
commit9b97a80105f893c1c96dc46748354e69fe2379de (patch)
tree829739bd5467fb8ac0fde75afa09a675030527f9
parent5fd3fc9ef138d5011a198f5f060050ababe90acb (diff)
downloadGradeBook-9b97a80105f893c1c96dc46748354e69fe2379de.tar.gz
GradeBook-9b97a80105f893c1c96dc46748354e69fe2379de.zip
moved configurable variables forward
-rwxr-xr-xblackboard2gradebook.tcl57
1 files changed, 36 insertions, 21 deletions
diff --git a/blackboard2gradebook.tcl b/blackboard2gradebook.tcl
index 1ddd55a..ddf20a5 100755
--- a/blackboard2gradebook.tcl
+++ b/blackboard2gradebook.tcl
@@ -9,6 +9,19 @@ package require sqlite3
package require md5
source ./GradeBook_lib.tcl
+################# Config ############################################
+# if dryrun is true the database will not be modified
+set dryrun true
+
+#set categories2export [list FinalExam HomeWork LabReport]
+set categories2export [list FinalExam]
+
+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]
+######################################################################
+
if { $argc < 2 } {
puts {Usage:}
puts " $argv0 gradebook.sqlitedb blackboard.sqlitedb"
@@ -179,25 +192,39 @@ proc updateGrade { col locUname grade } {
}
}
-proc pickCols2import { cols2import skipCreationCol } {
+proc pickCols2import { cols2import skipCreationCol categories2export } {
set reduced_list {}
foreach col $cols2import {
if { [isInList $col $skipCreationCol] } {
puts "skipping column $col"
continue
}
+ set colInfo [trimColName $col]
+ set category [lindex $colInfo 1]
+ if { $category ni $categories2export } {
+ puts [list skipping $col in $category permitted categories are $categories2export]
+ continue
+ }
lappend reduced_list $col
}
return $reduced_list
}
-######################### 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 \[} }
+proc normilizeGrade { grade colInfo } {
+ set shortCol [lindex $colInfo 0]
+ set category [lindex $colInfo 1]
+ set maxScore [lindex $colInfo 2]
+ set scoreType [lindex $colInfo 3]
+ if { "" ne $grade } {
+ if { $scoreType eq "Percentage" } {
+ # change percentage to score
+ set grade [ expr {$grade/100*$maxScore} ]
+ }
+ }
+ return $grade
+}
-set skipCreationCol [concat $commonInfoCol $infoColumsMarkers]
+######################### START of the execution #########################
addStudentsFromDB bdb
@@ -205,30 +232,18 @@ addStudentsFromDB bdb
set username_list [getBlackboardUsernames bdb]
set cols2import [getColListFromAnyTable bdb export_table]
-set cols2import [ pickCols2import $cols2import $skipCreationCol ]
+set cols2import [ pickCols2import $cols2import $skipCreationCol $categories2export]
foreach col $cols2import {
set colInfo [trimColName $col]
set shortCol [lindex $colInfo 0]
- set category [lindex $colInfo 1]
- set maxScore [lindex $colInfo 2]
- set scoreType [lindex $colInfo 3]
- #if { $category ne "FinalExam" } {
- #puts "skipping non FinalExam column: $col"
- #continue
- #}
if { ![doesColumnExists $shortCol GradesTable] } {
dbRequest [list AddColumnNonWeb $shortCol $category $maxScore]
}
foreach uname $username_list {
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} ]
- }
- }
+ set grade [normilizeGrade $grade $colInfo]
updateGrade $shortCol $locUname $grade
}
}