Index: openacs-4/packages/assessment/www/asm-admin/item-add-display-sb.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/item-add-display-sb.tcl,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/www/asm-admin/item-add-display-sb.tcl 7 Apr 2005 22:40:43 -0000 1.5 +++ openacs-4/packages/assessment/www/asm-admin/item-add-display-sb.tcl 12 Jun 2006 02:49:51 -0000 1.6 @@ -8,6 +8,7 @@ section_id:integer as_item_id:integer after:integer + {type ""} } -properties { context:onevalue page_title:onevalue @@ -28,8 +29,66 @@ set page_title [_ assessment.add_item_display_sb] set context [list [list index [_ assessment.admin]] [list [export_vars -base one-a {assessment_id}] $assessment_data(title)] $page_title] +set type $assessment_data(type) set boolean_options [list [list "[_ assessment.yes]" t] [list "[_ assessment.no]" f]] +if { $type == 1} { + set html_options "" + set multiple_p f + set label_orientation "top" + set order_type "order_of_entry" + set answer_alignment "besideright" + + db_transaction { + set new_assessment_rev_id [as::assessment::new_revision -assessment_id $assessment_id] + set section_id [as::section::latest -section_id $section_id -assessment_rev_id $new_assessment_rev_id] + set new_section_id [as::section::new_revision -section_id $section_id -assessment_id $assessment_id] + db_dml update_section_in_assessment {} + set old_item_id $as_item_id + + if {![db_0or1row item_display {}] || $object_type != "as_item_display_sb"} { + set as_item_display_id [as::item_display_sb::new \ + -html_display_options $html_options \ + -multiple_p $multiple_p \ + -choice_label_orientation $label_orientation \ + -sort_order_type $order_type \ + -item_answer_alignment $answer_alignment] + + if {![info exists object_type]} { + # first item display mapped + as::item_rels::new -item_rev_id $as_item_id -target_rev_id $as_item_display_id -type as_item_display_rel + } else { + # old item display existing + set as_item_id [as::item::new_revision -as_item_id $as_item_id] + } + } else { + # old sb item display existing + set as_item_id [as::item::new_revision -as_item_id $as_item_id] + set as_item_display_id [as::item_display_sb::edit \ + -as_item_display_id $as_item_display_id \ + -html_display_options $html_options \ + -multiple_p $multiple_p \ + -choice_label_orientation $label_orientation \ + -sort_order_type $order_type \ + -item_answer_alignment $answer_alignment] + } + + set old_item_id [as::item::latest -as_item_id $old_item_id -section_id $new_section_id -default 0] + if {$old_item_id == 0} { + db_dml move_down_items {} + incr after + db_dml insert_new_item {} + } else { + db_dml update_item_display {} + db_1row item_data {} + db_dml update_item {} + } + } + ad_returnredirect [export_vars -base one-a {assessment_id}]\#$as_item_id + ad_script_abort + +} + set label_or_types [list] foreach label_or_type [list top left right bottom] { lappend label_or_types [list "[_ assessment.$label_or_type]" $label_or_type] @@ -51,13 +110,15 @@ {multiple_p:text(select) {label "[_ assessment.Multiple]"} {options $boolean_options} {help_text "[_ assessment.Multiple_help]"}} {label_orientation:text(hidden)} {order_type:text(select) {label "[_ assessment.Order_Type]"} {options $order_types} {help_text "[_ assessment.Order_Type_help]"}} + {prepend_empty_p:text(select) {label "[_ assessment.Prepend_Empty_Item]"} {options $boolean_options} {help_text "[_ assessment.lt_Prepend_an_empty_item]"}} {answer_alignment:text(hidden)} } -edit_request { set html_options "" set multiple_p f set label_orientation "top" set order_type "order_of_entry" set answer_alignment "besideright" + set prepend_empty_p f } -validate { {html_options {[as::assessment::check_html_options -options $html_options]} "[_ assessment.error_html_options]"} } -edit_data { @@ -74,7 +135,8 @@ -multiple_p $multiple_p \ -choice_label_orientation $label_orientation \ -sort_order_type $order_type \ - -item_answer_alignment $answer_alignment] + -item_answer_alignment $answer_alignment \ + -prepend_empty_p $prepend_empty_p] if {![info exists object_type]} { # first item display mapped @@ -92,7 +154,8 @@ -multiple_p $multiple_p \ -choice_label_orientation $label_orientation \ -sort_order_type $order_type \ - -item_answer_alignment $answer_alignment] + -item_answer_alignment $answer_alignment \ + -prepend_empty_p $prepend_empty_p] } set old_item_id [as::item::latest -as_item_id $old_item_id -section_id $new_section_id -default 0] @@ -108,7 +171,7 @@ } } -after_submit { # now go to assessment-page - ad_returnredirect [export_vars -base one-a {assessment_id}] + ad_returnredirect [export_vars -base one-a {assessment_id}]&\#$as_item_id ad_script_abort }