aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2010-12-15 17:01:28 -0500
committerEugeniy Mikhailov <evgmik@gmail.com>2010-12-15 17:01:28 -0500
commit8ba275a6039f356b41cfeff6ba08a26c01c476c4 (patch)
tree647e466215b78fce0f880950ab47423c6d81c38b
parent9bffd28bb1f659882877a04e05d3bedf34f18344 (diff)
downloadGradeBook-8ba275a6039f356b41cfeff6ba08a26c01c476c4.tar.gz
GradeBook-8ba275a6039f356b41cfeff6ba08a26c01c476c4.zip
different view for instructor and student
darcs-hash:20101215220128-067c0-88dd99c18f664e4bd602b782ffb17d411876f11f.gz
-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