aboutsummaryrefslogtreecommitdiff
path: root/GradeBook_lib.tcl
diff options
context:
space:
mode:
authorEugeniy Mikhailov <evgmik@gmail.com>2011-04-15 16:01:31 -0400
committerEugeniy Mikhailov <evgmik@gmail.com>2011-04-15 16:01:31 -0400
commit574401ff1c22353e55a58681334f3e8ce257dfce (patch)
tree7b38d6f00bbfbe1997c2977aaa18724b467520b0 /GradeBook_lib.tcl
parent18a1559f23ee17d062fd79d2b52f405f0b950895 (diff)
downloadGradeBook-574401ff1c22353e55a58681334f3e8ce257dfce.tar.gz
GradeBook-574401ff1c22353e55a58681334f3e8ce257dfce.zip
added code to edit categories weight
Ignore-this: 6a18fd7ba0b7442ee9b86a98f02813be darcs-hash:20110415200131-067c0-d1fb4e0d5dbb424ded0807841a8b5d4402f8a1c6.gz
Diffstat (limited to 'GradeBook_lib.tcl')
-rwxr-xr-xGradeBook_lib.tcl86
1 files changed, 84 insertions, 2 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl
index e31dd6c..ddc3476 100755
--- a/GradeBook_lib.tcl
+++ b/GradeBook_lib.tcl
@@ -6,7 +6,7 @@ exec tclsh "$0" "$@"
# require Tcl version of at least 8.5 since I use 'ni' and 'in' in expressions for lists
package require Tcl 8.5
# internal version of this code
-set VERSION 1.4.5
+set VERSION 1.5.0
# Grades category and their html names
set grades_category [list \
@@ -361,7 +361,6 @@ proc ModifyWeightForGradesCategory {db category weight} {
AddGradesCategory db $category
}
set eval_str [concat UPDATE GradesCategoryTable SET \"CategoryWeight\"='$weight' WHERE \"CategoryName\"=\'$category\']
- puts $eval_str
set err [catch {db eval $eval_str } errStat]
if { $err } {
htmlErrorMsg $errStat
@@ -397,6 +396,83 @@ proc CreateGradesCategoryTable {db} {
}
}
+proc UpdateGradesCategores { db permission_list user } {
+ global script_name
+ set subaction [::ncgi::value subaction {}]
+ set nv [::ncgi::nvlist]
+ array set colval $nv
+ if { $subaction eq "Cancel" } {
+ return
+ }
+ if { $subaction eq "Submit" } {
+ set eval_str "SELECT CategoryName FROM GradesCategoryTable"
+ set err [catch {
+ db eval $eval_str v {
+ if { [info exist colval($v(CategoryName))] } {
+ ModifyWeightForGradesCategory db $v(CategoryName) $colval($v(CategoryName))
+ }
+ }
+ } errStat ]
+ if { $err } {
+ htmlErrorMsg $errStat
+ dbg "the following error happen: $errStat" 3
+ }
+ }
+
+ calculteWeightedTotals
+}
+
+proc EditGradesCategories { db permission_list user } {
+ global script_name
+ lappend column_list CategoryName CategoryWeight
+ set sql_column_list [join $column_list ","]
+ puts {<div class="change_categories">}
+ puts {<div class="categories_table">}
+ puts "<form name=\"input\" action=\"$script_name\" method=\"post\" />"
+ # output only selected columns
+ set eval_str "SELECT $sql_column_list FROM GradesCategoryTable"
+ set show_header 1
+ set err [catch {
+ db eval $eval_str v {
+ if { $show_header } {
+ set show_header 0
+ puts {<table class="categories_table" border="1">}
+ puts "<tr>"
+ foreach col $v(*) {
+ puts -nonewline "<th>$col</th>"
+ }
+ puts "<tr>"
+ } else {
+ puts "<tr>"
+ }
+ foreach index $v(*) {
+ if { $index != "*" } {
+ if { $index eq "CategoryWeight" } {
+ puts "<th><input type=\"text\" name=\"$v(CategoryName)\" value=\"$v(CategoryWeight)\" size=5></th>"
+ } else {
+ puts -nonewline "<td>$v($index)</td>"
+ }
+ }
+ }
+ puts "</tr>"
+ }
+ } errStat ]
+ puts "</table>"
+ if { $err } {
+ htmlErrorMsg $errStat
+ dbg "the following error happen: $errStat" 3
+ }
+ puts {<input type="hidden" name="action" value="update_grades_categories"/>}
+ puts {<input type="submit" name="subaction" value="Submit" />}
+ puts {<input type="submit" name="subaction" value="Cancel" />}
+ puts {</form>}
+ puts {</div>}
+ puts {</div>}
+ #puts "<a href=\"$script_name\">Cancel changes</a>"
+
+}
+
+
proc CreateGradesTable {db} {
# construct sql string for table creation
set sql_str {CREATE TABLE GradesTable(}
@@ -454,6 +530,8 @@ proc CreateAccessRightsTable {db} {
AddAccessRightNonWeb showcontrols 1 1 1 1 0
AddAccessRightNonWeb changegrades 1 1 0 0 0
AddAccessRightNonWeb updategrades 1 1 0 0 0
+ AddAccessRightNonWeb edit_grades_categories 1 0 0 0 0
+ AddAccessRightNonWeb update_grades_categories 1 0 0 0 0
AddAccessRightNonWeb changecolumn 1 1 0 0 0
AddAccessRightNonWeb updatecolumn 1 1 0 0 0
AddAccessRightNonWeb logoff 1 1 1 1 0
@@ -921,6 +999,9 @@ proc ChoseAction {action permission_list user} {
userunhidegradecategory { UserUnHideGradeCategory $permission_list $user
htmlDefaultView $permission_list $user }
showgrades { htmlGradesTable db $permission_list $user }
+ edit_grades_categories { EditGradesCategories db $permission_list $user }
+ update_grades_categories { UpdateGradesCategores db $permission_list $user
+ htmlDefaultView $permission_list $user }
editcourseinfo { EditCourseInfo db $permission_list $user }
updatecourseinfo { UpdateCourseInfo db $permission_list $user
htmlDefaultView $permission_list $user }
@@ -1479,6 +1560,7 @@ proc ShowControls { permission_list user } {
editcourseinfo "Edit Course Info"\
editnewuserinfo "Add new user"\
choosenewpassword "Choose new password"\
+ edit_grades_categories "Edit Grades Categories and Weights"\
logoff "Logoff"\
]
set separator { }