aboutsummaryrefslogtreecommitdiff
path: root/GradeBook.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'GradeBook.tcl')
-rwxr-xr-xGradeBook.tcl59
1 files changed, 57 insertions, 2 deletions
diff --git a/GradeBook.tcl b/GradeBook.tcl
index ba25520..cf2567d 100755
--- a/GradeBook.tcl
+++ b/GradeBook.tcl
@@ -1,6 +1,6 @@
#!/bin/sh
# FILE: "/home/evmik/src/my_src/GradeBook/GradeBook.tcl"
-# LAST MODIFICATION: "Wed, 15 Dec 2010 16:01:20 -0500 (evmik)"
+# LAST MODIFICATION: "Wed, 15 Dec 2010 17:00:40 -0500 (evmik)"
# (C) 2010 by Eugeniy Mikhailov, <evgmik@gmail.com>
# $Id:$
# vim:set ft=tcl: \
@@ -67,6 +67,7 @@ proc CreateGradesTable {db} {
set eval_str [list INSERT INTO GradesTable VALUES('Ale','Lname2', 'ale', 5)]
db eval $eval_str
set eval_str [list INSERT INTO GradesTable VALUES('Dan','Lname3', 'dan', 3)]
+ db eval $eval_str
}
proc CreateAccessRightsTable {db} {
@@ -150,6 +151,7 @@ proc LogOffOption {} {
proc askToLogin {} {
global script_name
+ puts "Either you are here first time or you password and user name does not match. <br>"
puts "Please login <br>"
puts "<form name=\"input\" action=\"$script_name\" method=\"post\" />"
puts {Login: <input type="text" name="user"><br>}
@@ -231,6 +233,58 @@ proc AccessGroupRights {db user password } {
return [array get permissions]
}
+proc htmlStudentGrades { db user } {
+ set defSortCol LastName
+ global script_name
+ set sort_col $defSortCol
+
+
+ set show_header 1
+ # show the table with grades
+ set eval_str [list SELECT * FROM GradesTable WHERE UserName='$user' ORDER BY $sort_col]
+ set err [catch {
+ db eval $eval_str v {
+ if { $show_header } {
+ set show_header 0
+ puts {<table border="1">}
+ puts "<tr>"
+ foreach col $v(*) {
+ puts -nonewline "<th>$col</th>"
+ }
+ puts "</tr>"
+ puts "<tr>"
+ } else {
+ puts "<tr>"
+ }
+ foreach index $v(*) {
+ if { $index != "*" } {
+ puts -nonewline "<td>$v($index)</td>"
+ }
+ }
+ puts "</tr>"
+ }
+ } errStat ]
+ if { $err } {
+ dbg "we should never be here if $sortCol and $user exist in the table" 1
+ dbg $errStat 1
+
+ }
+ puts "</table>"
+}
+
+
+proc htmlGradesTable {db permission_list sortCol user} {
+ array set permission $permission_list
+ switch $permission(GroupName) {
+ guest { }
+ student { htmlStudentGrades db $user}
+ ta { htmlDBout db $sortCol}
+ instructor {htmlDBout db $sortCol}
+ default { }
+ }
+}
+
+
##################### end of procs ####################################
set timestamp [clock format [clock seconds] -format "%Y-%m-%dT%H:%M:%S"]
@@ -248,7 +302,8 @@ ChoseAction $action $permissions
::ncgi::header
htmlTop $permissions
-htmlDBout db $sortCol
+htmlGradesTable db $permissions $sortCol $user
+#htmlDBout db $sortCol