Index: openacs-4/packages/dotlrn-ecommerce/lib/section.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/section.adp,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/dotlrn-ecommerce/lib/section.adp 19 Jun 2005 06:05:06 -0000 1.1
+++ openacs-4/packages/dotlrn-ecommerce/lib/section.adp 27 Jul 2005 15:49:20 -0000 1.2
@@ -1,3 +1,11 @@
-
+
+
+
\ No newline at end of file
Index: openacs-4/packages/dotlrn-ecommerce/lib/section.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-ecommerce/lib/section.tcl,v
diff -u -r1.15 -r1.16
--- openacs-4/packages/dotlrn-ecommerce/lib/section.tcl 22 Jul 2005 10:56:09 -0000 1.15
+++ openacs-4/packages/dotlrn-ecommerce/lib/section.tcl 27 Jul 2005 15:49:20 -0000 1.16
@@ -6,6 +6,33 @@
# return_url
# has_edit
+proc dotlrn_ecommerce_check_grade { section_id categories } {
+ set grade_tree_id [parameter::get -parameter GradeCategoryTree -default 0]
+
+ if { $grade_tree_id } {
+ db_1row community {
+ select community_id
+ from dotlrn_ecommerce_section
+ where section_id = :section_id
+ }
+
+ if { $categories == [list [list $community_id [ad_conn package_id]]] } {
+ set categories ""
+ }
+
+ lappend categories 0
+
+ return [db_string selected_grades [subst {
+ select count(*)
+ from categories
+ where tree_id = :grade_tree_id
+ and category_id in ([join $categories ,])
+ }] -default 0]
+ }
+
+ return 1
+}
+
if {![info exists has_edit]} {
set has_edit 0
}
@@ -50,6 +77,23 @@
"The section '$section_key' key already exists"
}
+ # Try to default to Adult, this may not exist
+ # Roel: Right now I'm doing this using javascript, doesn't seem to
+ # be a way to set the value of a category widget
+ set grade_tree_id [parameter::get -parameter GradeCategoryTree -default 0]
+
+ if { $grade_tree_id } {
+ set locale [ad_conn locale]
+ db_0or1row default_grade {
+ select c.category_id as adult_category_id
+ from category_translations t, categories c
+ where t.category_id = c.category_id
+ and t.name = 'Adult'
+ and t.locale = :locale
+ and c.tree_id = :grade_tree_id
+ }
+ }
+
} else {
ad_form -extend -name add_section -form {
{section_key:text(inform) {label "Section Key"}}
@@ -136,29 +180,13 @@
where section_id = :section_id
}
- set tree_options [list]
- db_foreach prerequisites {
- select tree_id
- from dotlrn_ecommerce_prereq_map
- } {
- lappend tree_options [list [category_tree::get_name $tree_id] $tree_id]
- }
-
ad_form -extend -name add_section -form {
{categories:text(category),multiple,optional
{label "Categories"}
{html {size 4}}
{value "$community_id $package_id"}
}
}
-
- if { [llength $tree_options] > 0 } {
- ad_form -extend -name add_section -form {
- {prerequisites:integer(checkbox),multiple,optional {label "Check Prerequisites"}
- {options {$tree_options}}
- }
- }
- }
} else {
ad_form -extend -name add_section -form {
{categories:text(category),multiple,optional
@@ -168,6 +196,22 @@
}
}
+set tree_options [list]
+db_foreach prerequisites {
+ select tree_id
+ from dotlrn_ecommerce_prereq_map
+} {
+ lappend tree_options [list [category_tree::get_name $tree_id] $tree_id]
+}
+
+if { [llength $tree_options] > 0 } {
+ ad_form -extend -name add_section -form {
+ {prerequisites:integer(checkbox),multiple,optional {label "Check Prerequisites"}
+ {options {$tree_options}}
+ }
+ }
+}
+
# TICKET #159 section_description
ad_form -extend -name add_section -form {
{description:text(textarea)
@@ -300,9 +344,11 @@
}
}
+lappend validate {categories
+ { [dotlrn_ecommerce_check_grade $section_id $categories] }
+ "Please select one or more grades"
+}
-
-
ad_form -extend -name add_section -validate $validate -on_request {
# Set session times
foreach s $sessions_list {