Index: openacs-4/packages/assessment/tcl/assessment-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/Attic/assessment-procs.tcl,v diff -u -r1.9 -r1.10 --- openacs-4/packages/assessment/tcl/assessment-procs.tcl 19 Sep 2004 22:22:24 -0000 1.9 +++ openacs-4/packages/assessment/tcl/assessment-procs.tcl 21 Sep 2004 15:07:11 -0000 1.10 @@ -15,7 +15,7 @@ {-content_value ""} {-feedback_text ""} {-selected_p:boolean ""} - {-correct_answer_p:boolean ""} + {-correct_answer_p ""} {-sort_order ""} {-percent_score ""} @@ -204,7 +204,7 @@ {-event_id ""} {-subject_id ""} {-staff_id ""} - {-item_id:required} + {-as_item_id:required} {-choice_id_answer ""} {-boolean_answer ""} {-numeric_answer ""} @@ -224,8 +224,8 @@ set folder_id [db_string get_folder_id "select folder_id from cr_folders where package_id=:package_id"] # Insert as_item_data in the CR (and as_item_data table) getting the revision_id (item_data_id) - set item_data_id [content::item::new -parent_id $folder_id -content_type {as_item_data} -name "$item_id-$subject_id" -title "$item_id-$subject_id" ] - set as_item_data_id [content::revision::new -item_id $item_data_id -content_type {as_item_data} -title "$item_id-$subject_id" -attributes [list [list session_id $session_id] [list event_id $event_id] [list subject_id $subject_id] [list staff_id $staff_id] [list item_id $item_id] [list choice_id_answer $choice_id_answer] [list boolean_answer $boolean_answer] [list numeric_answer $numeric_answer] [list integer_answer $integer_answer] [list text_answer $text_answer] [list timestamp_answer $timestamp_answer] [list content_answer $content_answer] [list signed_data $signed_data] [list percent_score $percent_score] ] ] + set item_data_id [content::item::new -parent_id $folder_id -content_type {as_item_data} -name "$as_item_id-$subject_id-$choice_id_answer" -title "$as_item_id-$subject_id-$choice_id_answer" ] + set as_item_data_id [content::revision::new -item_id $item_data_id -content_type {as_item_data} -title "$as_item_id-$subject_id-$choice_id_answer" -attributes [list [list session_id $session_id] [list event_id $event_id] [list subject_id $subject_id] [list staff_id $staff_id] [list as_item_id $as_item_id] [list choice_id_answer $choice_id_answer] [list boolean_answer $boolean_answer] [list numeric_answer $numeric_answer] [list integer_answer $integer_answer] [list text_answer $text_answer] [list timestamp_answer $timestamp_answer] [list content_answer $content_answer] [list signed_data $signed_data] [list percent_score $percent_score] ] ] return $as_item_data_id } Index: openacs-4/packages/assessment/tcl/assessment-qti-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/Attic/assessment-qti-procs-postgresql.xql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/assessment/tcl/assessment-qti-procs-postgresql.xql 21 Jul 2004 10:22:46 -0000 1.5 +++ openacs-4/packages/assessment/tcl/assessment-qti-procs-postgresql.xql 21 Sep 2004 15:07:11 -0000 1.6 @@ -5,15 +5,15 @@ - INSERT INTO as_assessment_section_map (assessment_id, section_id) - VALUES (:as_assessments__assessment_id, :as_sections__section_id) + INSERT INTO as_assessment_section_map (assessment_id, section_id, sort_order) + VALUES (:as_assessments__assessment_id, :as_sections__section_id, :as_assessment_section_map__sort_order) - INSERT INTO as_item_section_map (as_item_id, section_id) - VALUES (:as_item_id, :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) Index: openacs-4/packages/assessment/tcl/assessment-qti-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/Attic/assessment-qti-procs.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/assessment/tcl/assessment-qti-procs.tcl 15 Sep 2004 19:37:57 -0000 1.16 +++ openacs-4/packages/assessment/tcl/assessment-qti-procs.tcl 21 Sep 2004 15:07:11 -0000 1.17 @@ -51,6 +51,7 @@ # Section set sectionNodes [$assessment selectNodes {section}] foreach section $sectionNodes { + set as_assessment_section_map__sort_order 0 set as_sections__title [$section getAttribute {title}] set as_sections__name [$section getAttribute {ident}] set nodesList [$section childNodes] @@ -70,6 +71,7 @@ # Relation between as_sections and as_assessments db_dml as_assessment_section_map_insert {} + incr as_assessment_section_map__sort_order # Process the items parse_item $section $as_sections__section_id } @@ -83,25 +85,40 @@ } ad_proc -private parse_item { qtiNode section_id} { Parse items from a XML QTI file } { + set as_item_section_map__sort_order 0 set items [list] set itemNodes [$qtiNode selectNodes {item}] foreach item $itemNodes { # Order of the item_choices set sort_order 0 set as_items__title [$item getAttribute {title}] set as_items__name [$item getAttribute {ident}] + array set as_item_choices__correct_answer_p {} set objectivesNodes [$item selectNodes {objectives}] foreach objectives $objectivesNodes { set mattextNodes [$objectives selectNodes {material/mattext/text()}] foreach mattext $mattextNodes { set as_items__name [$mattext nodeValue] } } + set resprocessingNodes [$item selectNodes {resprocessing}] + foreach resprocessing $resprocessingNodes { + set respconditionNodes [$resprocessing selectNodes {respcondition}] + foreach respcondition $respconditionNodes { + set title [$respcondition getAttribute {title} {}] + if {$title == {Correct}} { + set correctNodes [$respcondition selectNodes {conditionvar/and/varequal/text()}] + foreach correct $correctNodes { + set as_item_choices__correct_answer_p([string trim [$correct nodeValue]]) {t} + } + } + } + } set presentationNodes [$item selectNodes {presentation}] foreach presentation $presentationNodes { set nodeNodes [$presentation selectNodes {.//material}] set node [lindex $nodeNodes 0] - # Initialize in case it doen't exist + # Initialize in case it doesn't exist set as_items__title {} if {[$node nodeName] == {material}} { set mattextNodes [$node selectNodes {mattext/text()}] @@ -163,7 +180,8 @@ set as_item_choices__choice_text [$mattext nodeValue] } # Insert as_item_choice in the CR (and as_item_choices table) getting the revision_id (choice_id) - as_item_choice_new -mc_id $as_item_type_id -name $as_item_choices__ident -title $as_item_choices__choice_text -sort_order $sort_order + set as_item_choices__correct_answer_p($as_item_choices__ident) [expr [info exists as_item_choices__correct_answer_p($as_item_choices__ident)]?{t}:{f}] + as_item_choice_new -mc_id $as_item_type_id -name $as_item_choices__ident -title $as_item_choices__choice_text -sort_order $sort_order -correct_answer_p $as_item_choices__correct_answer_p($as_item_choices__ident) # order of the item_choices incr sort_order } @@ -172,6 +190,7 @@ # 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 $items Index: openacs-4/packages/assessment/tcl/item-form-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/Attic/item-form-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/tcl/item-form-procs.tcl 28 Aug 2004 15:35:10 -0000 1.2 +++ openacs-4/packages/assessment/tcl/item-form-procs.tcl 21 Sep 2004 15:07:11 -0000 1.3 @@ -39,7 +39,6 @@ set mc_id [db_string item_to_rev "SELECT revision_id FROM cr_revisions WHERE item_id=:item_mc_id"] set optionlist [list] db_foreach item_choices_2 "" { - ns_log notice $title lappend optionlist [list $title $choice_id] } set options $optionlist @@ -53,10 +52,13 @@ } "checkbox" { + set item_item_id [db_string cr_item_from_revision "select item_id from cr_revisions where revision_id=:item_id"] + set item_mc_id [db_string item_item_type "SELECT related_object_id FROM cr_item_rels WHERE item_id=:item_item_id"] + set mc_id [db_string item_to_rev "SELECT revision_id FROM cr_revisions WHERE item_id=:item_mc_id"] set choices [list] set optionlist [list] - db_foreach item_choices_3 "" { - lappend optionlist [list $choice_text $choice_id] + db_foreach item_choices_2 "" { + lappend optionlist [list $title $choice_id] } set options $optionlist template::element::create $form $element_name \ Index: openacs-4/packages/assessment/tcl/item-form-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/Attic/item-form-procs.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/tcl/item-form-procs.xql 28 Aug 2004 15:35:10 -0000 1.2 +++ openacs-4/packages/assessment/tcl/item-form-procs.xql 21 Sep 2004 15:07:11 -0000 1.3 @@ -17,20 +17,20 @@ select - as_item_choicesx.choice_id, as_item_choicesx.title, as_item_choices.numeric_value, as_item_choicesx.sort_order + as_item_choicesx.choice_id, as_item_choicesx.title from as_item_choicesx where as_item_choicesx.mc_id=:mc_id order by - as_item_choicex.sort_order + as_item_choicesx.sort_order select - as_itemsx.title, as_itemsx.required_p, 'radiobutton' AS presentation_type + as_itemsx.title, as_itemsx.required_p, 'checkbox' AS presentation_type from as_itemsx where Index: openacs-4/packages/assessment/www/process-response.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/Attic/process-response.tcl,v diff -u -r1.1 -r1.2 --- openacs-4/packages/assessment/www/process-response.tcl 15 Sep 2004 19:47:48 -0000 1.1 +++ openacs-4/packages/assessment/www/process-response.tcl 21 Sep 2004 15:07:12 -0000 1.2 @@ -13,6 +13,13 @@ set context_bar [list] +set as_session_id [as_session__get_session_id_from_user_assessment -subject_id [ad_conn user_id] -assessment_id $assessment_id] + foreach response_to_item_id [array names response_to_item] { - as_item_data_new -session_id [as_session__get_session_id_from_user_assessment -subject_id [ad_conn user_id] -assessment_id $assessment_id] -item_id $response_to_item_id -choice_id_answer $response_to_item($response_to_item_id) + db_foreach session_responses_to_item {SELECT as_item_datax.item_id FROM (as_item_datax INNER JOIN as_sessionsx ON as_item_datax.session_id = as_sessionsx.session_id) INNER JOIN as_itemsx ON as_item_datax.as_item_id=as_itemsx.as_item_id WHERE as_itemsx.as_item_id=:response_to_item_id AND as_sessionsx.session_id=:as_session_id} { + content::item::delete -item_id $item_id + } + foreach response $response_to_item($response_to_item_id) { + as_item_data_new -session_id $as_session_id -as_item_id $response_to_item_id -choice_id_answer $response + } } Index: openacs-4/packages/assessment/www/session.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/session.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/assessment/www/session.xql 21 Sep 2004 11:52:50 -0000 1.2 +++ openacs-4/packages/assessment/www/session.xql 21 Sep 2004 15:07:12 -0000 1.3 @@ -8,6 +8,7 @@ FROM ((as_sectionsx INNER JOIN (as_assessmentsx INNER JOIN as_assessment_section_map ON as_assessmentsx.assessment_id=as_assessment_section_map.assessment_id) ON as_sectionsx.section_id=as_assessment_section_map.section_id) INNER JOIN (as_itemsx INNER JOIN as_item_section_map ON as_itemsx.as_item_id=as_item_section_map.as_item_id) ON as_sectionsx.section_id=as_item_section_map.section_id) INNER JOIN as_sessionsx ON as_assessmentsx.assessment_id = as_sessionsx.assessment_id WHERE as_sessionsx.session_id = :session_id + ORDER BY as_item_section_map.sort_order