Index: openacs-4/packages/assessment/tcl/as-item-form-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-form-procs.tcl,v
diff -u -r1.8 -r1.9
--- openacs-4/packages/assessment/tcl/as-item-form-procs.tcl 8 Dec 2004 15:30:34 -0000 1.8
+++ openacs-4/packages/assessment/tcl/as-item-form-procs.tcl 10 Dec 2004 20:21:50 -0000 1.9
@@ -10,93 +10,29 @@
form
item_id
} {
+ @author Timo Hentschel (timo@timohentschel.de)
+ @modified-date 2004-12-10
+
Add items to a form. The form values are stored in response_to_item.item_id
} {
+ randomInit [randomRange 20000]
set element_name "response_to_item.$item_id"
- db_1row item_properties ""
- set user_value ""
+ db_1row item_properties {}
+ set item_type [string range $item_type end-1 end]
+ set display_type [string range $display_type end-1 end]
- set item_display_id [as::item_rels::get_target -item_rev_id $item_id -type as_item_display_rel]
- db_0or1row as_item_display_rbx "SELECT as_item_display_id AS rb__display_id FROM as_item_display_rb WHERE as_item_display_id=:item_display_id"
- db_0or1row as_item_display_tbx "SELECT as_item_display_id AS tb__display_id FROM as_item_display_tbx WHERE as_item_display_id=:item_display_id"
- db_0or1row as_item_display_tax "SELECT as_item_display_id AS ta__display_id FROM as_item_display_tax WHERE as_item_display_id=:item_display_id"
- set presentation_type "checkbox" ;# DEFAULT
- #get the presentation type
- if {[info exists rb__display_id]} {set presentation_type "radio"}
- if {[info exists tb__display_id]} {set presentation_type "fitb"}
- if {[info exists ta__display_id]} {set presentation_type "textarea"}
+ util_unlist [as::item_type_$item_type\::render -type_id $item_type_id] default_value data
- #Add the items depending on the presentation type (as_item_display_types)
- switch -- $presentation_type {
- "textbox" {
- template::element::create $form $element_name \
- -datatype text \
- -widget text \
- -label $title \
- -value $user_value \
- -size 40 \
- -required_p $required_p
- }
+ as::item_display_$display_type\::render \
+ -form $form \
+ -element $element_name \
+ -type_id $display_type_id \
+ -datatype $data_type \
+ -title $title \
+ -subtext $subtext \
+ -required_p $required_p \
+ -default_value $default_value \
+ -data $data
- "textarea" {
- db_0or1row html_rows_cols "SELECT html_display_options FROM as_item_display_ta WHERE as_item_display_id=:item_display_id"
- template::element::create $form $element_name \
- -datatype text \
- -widget textarea \
- -label $title \
- -value $user_value \
- -html $html_display_options \
- -nospell \
- -required_p $required_p
- }
-
- "radio" {
- set widget "text(radio)"
- set mc_id [as::item_rels::get_target -item_rev_id $item_id -type as_item_type_rel]
- set optionlist [list]
- db_foreach item_choices_2 "" {
- #for multiple choice item with multimedia
- if {[empty_string_p $content_value]} {
- lappend optionlist [list $title $choice_id]
- } elseif {[db_string mime_type {SELECT mime_type LIKE 'image%' FROM cr_revisions WHERE revision_id = :content_value}]} {
- lappend optionlist [list "$title" $choice_id]
- } else {
- lappend optionlist [list "$title