diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2014-03-29 19:48:58 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2014-03-29 19:48:58 -0400 |
commit | 760f79f2763ec8b6511a6c20bd24ef1dbabba0a8 (patch) | |
tree | 0fabaa8ed78d7a8a0e7b2015c6265b400021fc79 | |
parent | b8c08fdb29a22a3284b4e1f4948db8c5edac1d8d (diff) | |
download | GradeBook-760f79f2763ec8b6511a6c20bd24ef1dbabba0a8.tar.gz GradeBook-760f79f2763ec8b6511a6c20bd24ef1dbabba0a8.zip |
Output of high or low grade moved in one proc
-rwxr-xr-x | GradeBook_lib.tcl | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/GradeBook_lib.tcl b/GradeBook_lib.tcl index 2150ce0..7aaa8e7 100755 --- a/GradeBook_lib.tcl +++ b/GradeBook_lib.tcl @@ -976,39 +976,33 @@ proc htmlFormatMaxPossibleRaw { sql_column_str hidden_columns } { puts "</tr>" } -proc htmlFormatTheHighestGradeRaw { sql_column_str hidden_columns } { - # show max point values in html format - array set v [getColAndValForUserName _The_Highest_Grade_ $sql_column_str $hidden_columns] - set html_str "<tr>\n" - foreach columnname $v(*) { - if { $columnname in $hidden_columns } continue - switch $columnname { - "FirstName" {set col_value "Class"} - "LastName" {set col_value "High"} - "UserName" {set col_value "_Derived_"} - default { - if { ![info exists v($columnname)] } { - set col_value "N/A" - } else { - set col_value $v($columnname) - } - } +proc htmlFormatTheHighOrLowGradeRaw { stats_needed sql_column_str hidden_columns } { + # show max or min point values in html format + switch $stats_needed { + "high" {set sql_user_name _The_Highest_Grade_} + "low" {set sql_user_name _The_Lowest_Grade_} + default { + htmlErrorMsg "Required stats ($stats_needed) to output is not known" + return "" } - set html_str [join [list $html_str "\n" [htmlFormatColVal $col_value $columnname _The_Highest_Grade_ _The_Highest_Grade_ {} {b}] ] {}] } - set html_str [join [list $html_str "\n" "</tr>"]] - return $html_str -} - -proc htmlFormatTheLowestGradeRaw { sql_column_str hidden_columns } { - # show max point values in html format - array set v [getColAndValForUserName _The_Lowest_Grade_ $sql_column_str $hidden_columns] + array set v [getColAndValForUserName $sql_user_name $sql_column_str $hidden_columns] set html_str "<tr>\n" foreach columnname $v(*) { + if { ![info exists v($columnname)] } { + # this raw does not exist abandone raw compillation + return "" + } if { $columnname in $hidden_columns } continue switch $columnname { "FirstName" {set col_value "Class"} - "LastName" {set col_value "Low"} + "LastName" { + switch $stats_needed { + "high" {set col_value "High"} + "low" {set col_value "Low"} + default {set col_value "UNKNOWN"} + } + } "UserName" {set col_value "_Derived_"} default { if { ![info exists v($columnname)] } { @@ -1018,7 +1012,7 @@ proc htmlFormatTheLowestGradeRaw { sql_column_str hidden_columns } { } } } - set html_str [join [list $html_str "\n" [htmlFormatColVal $col_value $columnname _The_Lowest_Grade_ _The_Lowest_Grade_ {} {b}] ] {}] + set html_str [join [list $html_str "\n" [htmlFormatColVal $col_value $columnname _The_Highest_Grade_ _The_Highest_Grade_ {} {b}] ] {}] } set html_str [join [list $html_str "\n" "</tr>"]] return $html_str @@ -1167,8 +1161,8 @@ proc htmlDBout {db permission_list user {sort_col {}}} { 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 - puts [htmlFormatTheHighestGradeRaw $sql_column_str $hidden_columns] - puts [htmlFormatTheLowestGradeRaw $sql_column_str $hidden_columns] + puts [htmlFormatTheHighOrLowGradeRaw high $sql_column_str $hidden_columns] + puts [htmlFormatTheHighOrLowGradeRaw low $sql_column_str $hidden_columns] } puts "<tr>" |