diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2014-03-27 23:08:33 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2014-03-27 23:08:33 -0400 |
commit | fce55e8c01975d6887c6905eeb1aca56d4903130 (patch) | |
tree | 5ded8e368a0a89a9eae67bd52b016746465fff0a | |
parent | 6c4e3f07d61655e3109f58b2851ae4a5ae3ebe9d (diff) | |
download | GradeBook-fce55e8c01975d6887c6905eeb1aca56d4903130.tar.gz GradeBook-fce55e8c01975d6887c6905eeb1aca56d4903130.zip |
Added routines to output class high and low, Max Possible simplified too
-rwxr-xr-x | GradeBook_lib.tcl | 101 |
1 files changed, 82 insertions, 19 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index ccca241..6cddfc3 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -907,29 +907,90 @@ proc htmlGradesTableHeadersRaw { permission_list user sql_column_str hidden_colu puts "</tr>" } +proc getColAndValForUserName { user_name sql_column_str hidden_columns } { + set eval_str [concat SELECT $sql_column_str FROM GradesTable WHERE UserName=\"$user_name\"] + set err [catch { + db eval $eval_str v { + } + } errStat ] + if { $err } { + dbg "we should never be here if UserName: $user_name exist in the table" msg_level_critical + dbg $errStat msg_level_critical + htmlErrorMsg $errStat + return + } else { + return [array get v] + } +} + proc htmlFormatMaxPossibleRaw { sql_column_str hidden_columns } { # show max point values in html format puts "<tr>" - set eval_str_MP [concat SELECT $sql_column_str FROM GradesTable WHERE UserName=\"_Max_Points_\"] - set errMaxPoints [catch { - db eval $eval_str_MP v_MP { - foreach c $v_MP(*) { - if { $c in $hidden_columns } continue - switch $c { - "FirstName" {set MaxPointsStr "Max"} - "LastName" {set MaxPointsStr "Possible"} - "GroupName" {set MaxPointsStr ""} - "UserName" {set MaxPointsStr "_Derived_"} - default {set MaxPointsStr $v_MP($c)} + array set v [getColAndValForUserName _Max_Points_ $sql_column_str $hidden_columns] + foreach c $v(*) { + if { $c in $hidden_columns } continue + switch $c { + "FirstName" {set out_str "Max"} + "LastName" {set out_str "Possible"} + "GroupName" {set out_str ""} + "UserName" {set out_str "_Derived_"} + default { + if { ![info exists v($c)] } { + set out_str "N/A" + } else { + set out_str $v($c) } - puts "<td> <b>$MaxPointsStr</b> </td>" - } + } + } + puts "<td> <b>$out_str</b> </td>" + } + puts "</tr>" +} + +proc htmlFormatTheHighestGradeRaw { sql_column_str hidden_columns } { + # show max point values in html format + puts "<tr>" + array set v [getColAndValForUserName _The_Highest_Grade_ $sql_column_str $hidden_columns] + foreach c $v(*) { + if { $c in $hidden_columns } continue + switch $c { + "FirstName" {set out_str "Class"} + "LastName" {set out_str "High"} + "GroupName" {set out_str ""} + "UserName" {set out_str "_Derived_"} + default { + if { ![info exists v($c)] } { + set out_str "N/A" + } else { + set out_str $v($c) + } + } + } + puts "<td> <b>$out_str</b> </td>" + } + puts "</tr>" +} + +proc htmlFormatTheLowestGradeRaw { sql_column_str hidden_columns } { + # show max point values in html format + puts "<tr>" + array set v [getColAndValForUserName _The_Lowest_Grade_ $sql_column_str $hidden_columns] + foreach c $v(*) { + if { $c in $hidden_columns } continue + switch $c { + "FirstName" {set out_str "Class"} + "LastName" {set out_str "Low"} + "GroupName" {set out_str ""} + "UserName" {set out_str "_Derived_"} + default { + if { ![info exists v($c)] } { + set out_str "N/A" + } else { + set out_str $v($c) + } + } } - } errStat_MP ] - if { $errMaxPoints } { - dbg "we should never be here if UserName: _Max_Points_ exist in the table" msg_level_critical - dbg $errStat_MP msg_level_critical - htmlErrorMsg $errStat_MP + puts "<td> <b>$out_str</b> </td>" } puts "</tr>" } @@ -1026,7 +1087,9 @@ proc htmlDBout {db permission_list user {sort_col {}}} { puts {<table class="gradestable" border="1">} set v_array_list [array get v] htmlGradesTableHeadersRaw $permission_list $user $sql_column_str $hidden_columns $v_array_list - htmlFormatMaxPossibleRaw $sql_column_str $hidden_columns + htmlFormatMaxPossibleRaw $sql_column_str $hidden_columns + htmlFormatTheHighestGradeRaw $sql_column_str $hidden_columns + htmlFormatTheLowestGradeRaw $sql_column_str $hidden_columns } puts "<tr>" |