Index: openacs-4/packages/assessment/tcl/as-qti-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-qti-procs.tcl,v diff -u -r1.26 -r1.27 --- openacs-4/packages/assessment/tcl/as-qti-procs.tcl 17 Feb 2005 10:52:20 -0000 1.26 +++ openacs-4/packages/assessment/tcl/as-qti-procs.tcl 18 Feb 2005 15:51:07 -0000 1.27 @@ -279,32 +279,37 @@ } } - # Insert section in the CR (and in the as_sections table) getting the revision_id (section_id) - set as_sections__section_id [as::section::new \ - -title $as_sections__title \ - -description $as_sections__definition \ - -instructions $as_sections__instructions \ - -feedback_text $as_sections__sectionfeedback \ - -max_time_to_complete $as_sections__duration \ - -num_items $as_sections__num_items \ - -points $as_sections__points] #section display type - set display_id [as::section_display::new \ + set display_type_id [as::section_display::new \ -title $asdt__display_type \ -num_items $asdt__s_num_items \ -adp_chunk $asdt__adp_chunk \ -branched_p $asdt__branched_p \ -back_button_p $asdt__back_button_p \ -submit_answer_p $asdt__submit_answer_p \ -sort_order_type $asdt__sort_order_type] - # now update section and map display type - db_dml add_display_to_section {} + # Insert section in the CR (and in the as_sections table) getting the revision_id (section_id) + set section_id [as::section::new \ + -title $as_sections__title \ + -description $as_sections__definition \ + -instructions $as_sections__instructions \ + -feedback_text $as_sections__sectionfeedback \ + -max_time_to_complete $as_sections__duration \ + -num_items $as_sections__num_items \ + -points $as_sections__points \ + -display_type_id $display_type_id] # Relation between as_sections and as_assessments db_dml as_assessment_section_map_insert {} incr as_assessment_section_map__sort_order + set as_item_section_map__sort_order 0 # Process the items - as::qti::parse_item $section $as_sections__section_id [file dirname $xmlfile] + set as_items [as::qti::parse_item $section [file dirname $xmlfile]] + # Relation between as_items and as_sections + foreach as_item_id $as_items { + db_dml as_item_section_map_insert {} + incr as_item_section_map__sort_order + } #get points from a section db_0or1row get_section_points {} @@ -314,14 +319,13 @@ } } else { # Just items (no assessments) - as::qti::parse_item $questestinterop 0 + as::qti::parse_item $questestinterop [file dirname $xmlfile]] } } return $as_assessments__assessment_id } -ad_proc -private as::qti::parse_item {qtiNode section_id basepath} { Parse items from a XML QTI file } { - set as_item_section_map__sort_order 0 +ad_proc -private as::qti::parse_item {qtiNode basepath} { Parse items from a XML QTI file } { set as_items__description "" set as_items__subtext "" set as_items__field_code "" @@ -599,6 +603,7 @@ as::item_rels::new -item_rev_id $as_item_id -target_rev_id $as_item_type_id -type as_item_type_rel # set the relation between as_items and as_item_display tables as::item_rels::new -item_rev_id $as_item_id -target_rev_id $as_item_display_id -type as_item_display_rel + lappend as_items $as_item_id } else { set response_lidNodes [$presentation selectNodes {.//response_lid}] # The first node of the list. It may not be a good idea if it doesn't exist @@ -651,6 +656,7 @@ as::item_rels::new -item_rev_id $as_item_id -target_rev_id $as_item_type_id -type as_item_type_rel # set the relation between as_items and as_item_display tables as::item_rels::new -item_rev_id $as_item_id -target_rev_id $as_item_display_id -type as_item_display_rel + lappend as_items $as_item_id # (each choice) set response_labelNodes [$presentation selectNodes {.//response_label}] foreach response_label $response_labelNodes { @@ -703,11 +709,6 @@ as::item_rels::new -item_rev_id $as_item_id -target_rev_id $as_item_choices__content_value -type as_item_content_rel } } - # Relation between as_items and as_sections - if {$section_id != 0} { - db_dml as_item_section_map_insert {} - incr as_item_section_map__sort_order - } } - return 1 + return $as_items } Index: openacs-4/packages/assessment/tcl/as-qti-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-qti-procs.xql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/assessment/tcl/as-qti-procs.xql 14 Feb 2005 08:43:14 -0000 1.3 +++ openacs-4/packages/assessment/tcl/as-qti-procs.xql 18 Feb 2005 15:51:07 -0000 1.4 @@ -4,38 +4,30 @@ INSERT INTO as_assessment_section_map (assessment_id, section_id, max_time_to_complete, sort_order, points) - VALUES (:as_assessments__assessment_id, :as_sections__section_id, :as_sections__duration, :as_assessment_section_map__sort_order, :as_sections__points) + VALUES (:as_assessments__assessment_id, :section_id, :as_sections__duration, :as_assessment_section_map__sort_order, :as_sections__points) - + - INSERT INTO as_item_section_map (as_item_id, section_id, max_time_to_complete, sort_order, points) - VALUES (:as_item_id, :section_id, :as_items__duration, :as_item_section_map__sort_order, :as_items__points) - - - - - - update as_sections - set display_type_id = :display_id - where section_id = :as_sections__section_id + INSERT INTO as_item_section_map (as_item_id, section_id, sort_order) + VALUES (:as_item_id, :section_id, :as_item_section_map__sort_order) select sum(aism.points) as as_sections__points from as_item_section_map aism, as_assessment_section_map aasm - where aism.section_id = aasm.section_id and aasm.section_id = :as_sections__section_id + where aism.section_id = aasm.section_id and aasm.section_id = :section_id update as_assessment_section_map set points = :as_sections__points - where section_id = :as_sections__section_id + where section_id = :section_id