Index: openacs-4/packages/assessment/tcl/as-item-display-tb-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-item-display-tb-procs.tcl,v diff -u -N -r1.9 -r1.10 --- openacs-4/packages/assessment/tcl/as-item-display-tb-procs.tcl 12 Jun 2006 02:49:50 -0000 1.9 +++ openacs-4/packages/assessment/tcl/as-item-display-tb-procs.tcl 15 May 2007 20:14:16 -0000 1.10 @@ -146,3 +146,59 @@ db_1row display_item_data {} -column_array type return [array get type] } + +ad_proc -private as::item_display_tb::set_item_display_type { + -assessment_id + -section_id + -as_item_id + -after + {-type ""} + {-html_options {size 50 maxlength 1000}} + {-abs_size ""} + {-answer_alignment "beside_right"} +} { + Add display type to item and add item and all components to assessment + and section + + +} { + 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_tb"} { + set as_item_display_id [as::item_display_tb::new \ + -html_display_options $html_options \ + -abs_size $abs_size \ + -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 tb 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_tb::edit \ + -as_item_display_id $as_item_display_id \ + -html_display_options $html_options \ + -abs_size $abs_size \ + -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