From 1a11938b5ccdbf5ff137352e829bb866d8255190 Mon Sep 17 00:00:00 2001 From: Eugeniy Mikhailov Date: Sat, 18 Dec 2010 01:51:01 -0500 Subject: frades update implemented darcs-hash:20101218065101-067c0-4d27f297e0e46d2919c00897ae09f21069119f1a.gz --- GradeBook.tcl | 71 ++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 13 deletions(-) (limited to 'GradeBook.tcl') diff --git a/GradeBook.tcl b/GradeBook.tcl index 7df3c76..3ecfb42 100755 --- a/GradeBook.tcl +++ b/GradeBook.tcl @@ -81,6 +81,7 @@ proc CreateAccessRightsTable {db} { db eval {INSERT INTO AccessRightsTable VALUES('renamecolumn', 1, 1, 0, 0)} db eval {INSERT INTO AccessRightsTable VALUES('showcontrols', 1, 1, 0, 0)} db eval {INSERT INTO AccessRightsTable VALUES('changegrades', 1, 1, 0, 0)} + db eval {INSERT INTO AccessRightsTable VALUES('updategrades', 1, 1, 0, 0)} } proc htmlDBout {db permission_list {sort_col {}}} { @@ -155,17 +156,17 @@ proc htmlTop {permission_list} { } -proc htmlBottom {permission_list} { +proc htmlFooter {permission_list} { array set permission $permission_list global VERSION - puts "
" + puts "
" puts "GradeBook $VERSION code is written by Eugeniy Mikhailov" puts "
" } proc LogOffOption {} { global user password script_name - puts "
" + puts "
" puts "You are logged in as $user do you wish to " puts "logoff" puts "
" @@ -174,6 +175,7 @@ proc LogOffOption {} { proc askToLogin {} { global script_name + puts "
" puts "Either you are here first time or you password and user name does not match.
" puts "Please login
" puts "
" @@ -182,6 +184,7 @@ proc askToLogin {} { puts {} puts {} puts {
} + puts "
" } @@ -256,7 +259,10 @@ proc ChoseAction {action permission_list user} { DeleteColumn $permission_list $user; htmlDefaultView $permission_list $user } - changegrades { ChangeGrades $permission_list $user } + changegrades { ChangeGrades $permission_list $user } + updategrades { UpdateGrades $permission_list $user + htmlDefaultView $permission_list $user + } renamecolumn { } showcontrols { ShowControls $permission_list $user } showgrades { htmlGradesTable db $permission_list $user } @@ -266,6 +272,27 @@ proc ChoseAction {action permission_list user} { } } +proc UpdateGrades { permission_list user } { + global script_name + set subaction [::ncgi::value subaction {}] + set columnname [::ncgi::value columnname {}] + set nv [::ncgi::nvlist] + array set colval $nv + if { $subaction eq "Submit" } { + set eval_str "SELECT UserName FROM GradesTable" + set err [catch { + db eval $eval_str v { + set sql_str [concat UPDATE GradesTable SET \"$columnname\"=\"$colval($v(UserName))\" where UserName=\"$v(UserName)\"] + db eval $sql_str + } + + } errStat ] + if { $err } { + puts "the following error happen: $errStat" + dbg "the following error happen: $errStat" 3 + } + } +} proc ChangeGrades { permission_list user } { global script_name @@ -273,9 +300,10 @@ proc ChangeGrades { permission_list user } { if { $columnname != "" } { # output only selected columns set column_list {} - lappend column_list FirstName LastName + lappend column_list FirstName LastName UserName lappend column_list \"$columnname\" set sql_column_list [join $column_list ","] + puts "
" # output only selected columns set eval_str "SELECT $sql_column_list FROM GradesTable ORDER BY LastName" set show_header 1 @@ -294,7 +322,12 @@ proc ChangeGrades { permission_list user } { } foreach index $v(*) { if { $index != "*" } { - puts -nonewline "$v($index)" + if { $index eq $columnname } { + #column with grade + puts "" + } else { + puts -nonewline "$v($index)" + } } } puts "" @@ -305,11 +338,10 @@ proc ChangeGrades { permission_list user } { puts "the following error happen: $errStat" dbg "the following error happen: $errStat" 3 } - puts "" - #puts {} - puts {Column Name:
} - puts {} - puts {} + puts {} + puts [concat ] + puts {} + puts {} puts {
} puts "Cancel changes" @@ -384,7 +416,7 @@ proc ShowControls { permission_list user } { array set permission $permission_list global script_name dbg "outputing contol list" - puts "
" + puts "
" set action_list [ list addcolumnrequest "Add Column" ] set separator {} foreach {act act_label} $action_list { @@ -472,6 +504,16 @@ proc htmlDefaultView { permission_list user } { ChoseAction showgrades $permission_list $user } +proc htmlHeader {} { +puts { + + + + Grade Book + + +} +} ##################### end of procs #################################### @@ -489,12 +531,15 @@ dbg "===== Connection at $timestamp for user $user =====" set permission_list [AccessGroupRights db $user $password] ::ncgi::header +htmlHeader +puts "" htmlTop $permission_list ChoseAction $action $permission_list $user #htmlDefaultView $permission_list $user #htmlGradesTable db $permission_list $user #htmlDBout db $sortCol -htmlBottom $permission_list +htmlFooter $permission_list +puts "" -- cgit v1.2.3