Index: openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl,v diff -u -r1.13 -r1.13.2.1 --- openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl 12 Jun 2006 02:49:50 -0000 1.13 +++ openacs-4/packages/assessment/tcl/as-item-display-rb-procs.tcl 5 Feb 2007 14:12:47 -0000 1.13.2.1 @@ -160,3 +160,63 @@ db_1row display_item_data {} -column_array type return [array get type] } + +ad_proc as::item_display_rb::set_item_display_type { + -assessment_id + -section_id + -as_item_id + -after + {-type ""} + {-html_options ""} + {-choice_orientation "vertical"} + {-label_orientation "top"} + {-order_type "order_of_entry"} + {-answer_alignment "beside_right"} +} { + + 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_rb"} { + set as_item_display_id [as::item_display_rb::new \ + -html_display_options $html_options \ + -choice_orientation $choice_orientation \ + -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 rb 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_rb::edit \ + -as_item_display_id $as_item_display_id \ + -html_display_options $html_options \ + -choice_orientation $choice_orientation \ + -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 {} + } + } +} \ No newline at end of file