summaryrefslogtreecommitdiff
path: root/CreateCourseGradeBook.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'CreateCourseGradeBook.tcl')
-rwxr-xr-xCreateCourseGradeBook.tcl100
1 files changed, 1 insertions, 99 deletions
diff --git a/CreateCourseGradeBook.tcl b/CreateCourseGradeBook.tcl
index bccc2f5..b521189 100755
--- a/CreateCourseGradeBook.tcl
+++ b/CreateCourseGradeBook.tcl
@@ -5,6 +5,7 @@ exec tclsh "$0" "$@"
package require sqlite3
package require md5
+source ./GradeBook_lib.tcl
if { $argc < 3 } {
puts {Usage:}
@@ -30,105 +31,6 @@ if { $argc >= 5 } {
sqlite3 db $dbfile
-proc dbg {msg {level 1}} {
- if { $level <=2 } {
- set fid [open log a+]
- puts $fid $msg
- close $fid
- }
-}
-
-proc htmlErrorMsg { msg } {
- puts "<div class=\"errormsg\">error: $msg</div>"
-}
-
-proc AddUserNonWeb { first_name last_name user_name password_hash {group_name {guest}} {id_number {}} {section_num {} } } {
- set eval_str [concat INSERT INTO GradesTable (FirstName, LastName, UserName, PasswordHash, GroupName, IdNum, SectionNum) VALUES('$first_name', '$last_name', '$user_name', '$password_hash', '$group_name', '$id_number', '$section_num')]
- set err [catch {db eval $eval_str } errStat]
- if { $err } {
- htmlErrorMsg $errStat
- dbg "the following error happen: $errStat" 3
- }
-}
-
-
-proc CreateGradesTable {db} {
- set err [catch {db eval {CREATE TABLE GradesTable(FirstName text, LastName text, UserName text, PasswordHash text, GroupName text, UserHiddenColums text, UserHiddenGroups text, IdNum text, SectionNum text)} } errStat]
- if { $err } {
- htmlErrorMsg $errStat
- dbg "the following error happen: $errStat" 1
- }
-
- # add special users aka special info rows
- AddUserNonWeb {} {} _Col_Category_ {} inforow
- AddUserNonWeb {} {} _Max_Points_ {} inforow
-
- #AddUserNonWeb Ins "Instruch I" instructor [::md5::md5 -hex qwerty] instructor
- # reasonable defaults for hidden columns
- set instructor_hidden_columns [list UserHiddenColums PasswordHash UserHiddenGroups IdNum]
- UpdateColValue4GroupNameNonWeb UserHiddenColums instructor $instructor_hidden_columns
-}
-
-proc AddAccessRightNonWeb { action instructor_right ta_right student_right guest_right } {
- set eval_str [concat INSERT INTO AccessRightsTable (actionname, instructor, ta, student, guest) VALUES('$action', '$instructor_right', '$ta_right', '$student_right', '$guest_right')]
- set err [catch {db eval $eval_str } errStat]
- if { $err } {
- htmlErrorMsg $errStat
- dbg "the following error happen: $errStat" 3
- }
-}
-
-proc CreateAccessRightsTable {db} {
- set err [catch {db eval {CREATE TABLE AccessRightsTable(actionname text, instructor integer, ta integer, student integer, guest integer)} } errStat]
- if { $err } {
- htmlErrorMsg $errStat
- dbg "the following error happen: $errStat" 1
- }
- # guest should have no rights make sure that 0 is evereywhere except logon
- # actionname instructor ta student guest
- AddAccessRightNonWeb logon 1 1 1 1
- AddAccessRightNonWeb showgrades 1 1 1 0
- AddAccessRightNonWeb sort 1 1 0 0
- AddAccessRightNonWeb addcolumnrequest 1 1 0 0
- AddAccessRightNonWeb addcolumn 1 1 0 0
- AddAccessRightNonWeb deletecolumn 1 1 0 0
- AddAccessRightNonWeb showcontrols 1 1 1 0
- AddAccessRightNonWeb changegrades 1 1 0 0
- AddAccessRightNonWeb updategrades 1 1 0 0
- AddAccessRightNonWeb changecolumn 1 1 0 0
- AddAccessRightNonWeb updatecolumn 1 1 0 0
- AddAccessRightNonWeb logoff 1 1 1 0
- AddAccessRightNonWeb changefirstname 1 0 0 0
- AddAccessRightNonWeb changelastname 1 0 0 0
- AddAccessRightNonWeb changeusername 1 0 0 0
- AddAccessRightNonWeb userhidecolumn 1 1 1 0
- AddAccessRightNonWeb userunhidecolumn 1 1 1 0
- AddAccessRightNonWeb userhidegroup 1 0 0 0
- AddAccessRightNonWeb userunhidegroup 1 0 0 0
-}
-
-proc UpdateColValue4UserNameNonWeb { columnname username val } {
- set sql_str [concat UPDATE GradesTable SET \"$columnname\"=\'$val\' where UserName=\"$username\"]
- set err2 [catch {
- db eval $sql_str
- } errStat2 ]
- if { $err2 } {
- htmlErrorMsg $errStat2
- dbg "the following error happen: $errStat2" 3
- }
-}
-
-proc UpdateColValue4GroupNameNonWeb { columnname groupname val } {
- set sql_str [concat UPDATE GradesTable SET \"$columnname\"=\'$val\' where GroupName=\"$groupname\"]
- set err2 [catch {
- db eval $sql_str
- } errStat2 ]
- if { $err2 } {
- htmlErrorMsg $errStat2
- dbg "the following error happen: $errStat2" 3
- }
-}
-
CreateGradesTable db
CreateAccessRightsTable db