Index: openacs-4/packages/evaluation/www/admin/grades/grades.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/evaluation/www/admin/grades/grades.tcl,v
diff -u -r1.15 -r1.16
--- openacs-4/packages/evaluation/www/admin/grades/grades.tcl 24 May 2005 10:42:45 -0000 1.15
+++ openacs-4/packages/evaluation/www/admin/grades/grades.tcl 8 Aug 2006 21:26:42 -0000 1.16
@@ -1,74 +1,97 @@
# /packages/evaluation/www/admin/grades/grades.tcl
ad_page_contract {
-
+
List of grades and options to admin grades
-
+
@author jopez@galileo.edu
@creation-date Feb 2004
@cvs-id $Id$
-
} -query {
{orderby:optional}
+ {set_grade_id_live:optional ""}
}
set context [list "[_ evaluation.Grades_]"]
set package_id [ad_conn package_id]
+set simple_p [parameter::get -parameter "SimpleVersion"]
+set class "list"
+set aggregate ""
+set bulk_actions [list "[_ evaluation.Add_assignment_type_]" [export_vars -base "grades-add-edit" { }]]
set page_title "[_ evaluation.lt_Admin_Assignment_Type]"
set return_url [ad_conn url]
+set total 0
+set a_label [_ evaluation.total_of_course]
+set actions "
[_ evaluation.Add_assignment_type_]"
-set actions [list "[_ evaluation.Add_assignment_type_]" [export_vars -base "grades-add-edit" { }]]
+if { ![empty_string_p $set_grade_id_live] } {
+ evaluation::set_live_grade -grade_item_id $set_grade_id_live
+}
if { [lc_numeric %2.f [db_string sum_grades { *SQL* }]] > 100.00} {
- set aggregate_label "[_ evaluation.Total_]"
+ set aggregate_label "[_ evaluation.Total_d]"
} else {
- set aggregate_label "[_ evaluation.Total_]"
+ set aggregate_label "[_ evaluation.Total_d]"
}
+if { !$simple_p } {
+ set aggregate_label ""
+ set aggregate "sum"
+ set total "Total"
+ set a_label ""
+} else {
+ set class "pbs_list"
+ set bulk_actions ""
+}
+
+
template::list::create \
-name grades \
-multirow grades \
- -actions $actions \
-key grade_id \
- -pass_properties { return_url aggregate_label } \
+ -actions $bulk_actions \
+ -main_class $class \
+ -sub_class narrow \
+ -pass_properties { return_url aggregate_label total a_label aggregate} \
-elements {
grade_plural_name {
- label "[_ evaluation.Name_]"
+ label "[_ evaluation.name]"
orderby_asc {grade_plural_name asc}
orderby_desc {grade_plural_name desc}
link_url_eval {[export_vars -base "distribution-edit" { grade_id }]}
link_html { title "View assignment type distribution" }
+ aggregate ""
+ aggregate_label {@aggregate_label;noquote@}
}
weight {
label "[_ evaluation.lt_Weight_over_100_br__o]"
orderby_asc {weight asc}
orderby_desc {weight desc}
display_template { @grades.weight@% }
- aggregate sum
- aggregate_label { @aggregate_label;noquote@ }
+ aggregate "$aggregate"
+ aggregate_label {@total;noquote@}
}
comments {
- label "[_ evaluation.Description_]"
+ label "[_ evaluation.description]"
orderby_asc {comments asc}
orderby_desc {comments desc}
+ aggregate ""
+ aggregate_label {@a_label;noquote@}
+
}
edit {
label {}
sub_class narrow
- display_template {
-
+ display_template {[_ evaluation-portlet.edit]
}
link_url_eval {[export_vars -base "grades-add-edit" { item_id grade_id }]}
link_html { title "[_ evaluation.lt_Edit_assignment_type_]" }
}
delete {
label {}
sub_class narrow
- display_template {
-
- }
- link_url_eval {[export_vars -base "grades-delete" { grade_id return_url }]}
+ display_template {@grades.delete_template;noquote@}
link_html { title "[_ evaluation.lt_Delete_assignment_typ]" }
}
}
@@ -79,15 +102,26 @@
set orderby " order by grade_plural_name asc"
}
-db_multirow grades get_class_grades { *SQL* } {
- set weight [lc_numeric %.2f $weight]
+
+db_multirow -extend { delete_template } grades get_class_grades { *SQL* } {
+ if { $simple_p } {
+ set total [expr $total + $weight]
+ }
+ if { [empty_string_p $live_revision] } {
+ set delete_template "[_ evaluation.Deleted] [_ evaluation.make_it_live]"
+ } elseif { $simple_p } {
+ set delete_template "[_ evaluation-portlet.Delete]"
+ } else {
+ set delete_template "
"
+ }
}
db_1row get_total_weight { *SQL* }
-set total_weight [format %.2f $total_weight]
+set total_weight [lc_numeric %.2f $total_weight]
-if { ![string eq $total_weight "100.00"] && ![string eq $total_weight "0"] } {
+
+if { ($total_weight < 100 && $total_weight > 0) || $total_weight > 100} {
set notice "[_ evaluation.lt_The_sum_of_the_weight]"
} else {
set notice ""