diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-01-24 21:34:30 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-01-24 21:34:30 -0500 |
commit | 494e45d4f08841bd9b2d56f3ced8418f8aa1d008 (patch) | |
tree | fedfed125ff9333b07d233bda2dc83dfa3eb7ae5 /CreateCourseGradeBook.tcl | |
parent | b322dd885e403492f818a5110a9a7957a6b304ce (diff) | |
download | GradeBook-494e45d4f08841bd9b2d56f3ced8418f8aa1d008.tar.gz GradeBook-494e45d4f08841bd9b2d56f3ced8418f8aa1d008.zip |
all shared procs move to library file
Ignore-this: 75e219cb44fc45e281a42d514cf2600f
darcs-hash:20110125023430-067c0-ed0225f6b7d24c31e9f8eb4498a04191abf7f355.gz
Diffstat (limited to 'CreateCourseGradeBook.tcl')
-rwxr-xr-x | CreateCourseGradeBook.tcl | 100 |
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 |