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.35.2.7 -r1.35.2.8 --- openacs-4/packages/assessment/tcl/as-qti-procs.tcl 5 Apr 2006 16:20:38 -0000 1.35.2.7 +++ openacs-4/packages/assessment/tcl/as-qti-procs.tcl 6 May 2006 15:52:56 -0000 1.35.2.8 @@ -1,8 +1,8 @@ ad_library { - assessment -- QTI parser library routines - @author eperez@it.uc3m.es - @creation-date 2004-04-16 - @cvs-id $Id$ + assessment -- QTI parser library routines + @author eperez@it.uc3m.es + @creation-date 2004-04-16 + @cvs-id $Id$ } namespace eval as::qti {} @@ -14,7 +14,7 @@ Relation with assessment } { - + if {[regexp -nocase -- {\.zip$} $tmp_dir]} { # Generate a random directory name set tmpdirectory [ns_tmpnam] @@ -74,337 +74,341 @@ # Restore the package_id ad_conn -set package_id $current_package_id - + return $assessment_id } ad_proc -private as::qti::mattext_gethtml { mattextNode } { Get the HTML of a mattext } { - set texttype [$mattextNode getAttribute {texttype} {text/plain}] - if { $texttype == "text/html" } { - return [$mattextNode text] - } else { - return [ad_html_text_convert -from text/plain -to text/html -- [$mattextNode text]] - } + set texttype [$mattextNode getAttribute {texttype} {text/plain}] + if { $texttype == "text/html" } { + return [$mattextNode text] + } else { + return [ad_html_text_convert -from text/plain -to text/html -- [$mattextNode text]] + } } ad_proc -public as::qti::parse_qti_xml { xmlfile } { Parse a XML QTI file } { - set as_assessments__assessment_id {} + set as_assessments__assessment_id {} - # Parser - # XML => DOM document - dom parse [::tDOM::xmlReadFile $xmlfile] document - # DOM document => DOM root - $document documentElement root - # XPath v1.0 - # get all elements of a XML instance file - set questestinteropNodes [$root selectNodes {/questestinterop}] - foreach questestinterop $questestinteropNodes { - # Looks for assessments - set assessmentNodes [$questestinterop selectNodes {assessment}] - if { [llength $assessmentNodes] > 0 } { - # There are assessments - foreach assessment $assessmentNodes { - set as_assessments__title [$assessment getAttribute {title} {Assessment}] - #get assessment's children: section, (qticomment, duration, qtimetadata, objectives, assessmentcontrol, - #rubric, presentation_material, outcomes_processing, assessproc_extension, assessfeedback, - #selection_ordering, reference, sectionref) - set nodesList [$assessment childNodes] - set as_assessments__definition "" - set as_assessments__instructions "" - set as_assessments__duration "" - #for each assessment's child - foreach node $nodesList { - set nodeName [$node nodeName] - #as_assessmentsx.description = or - if {$nodeName == "qticomment"} { - set definitionNodes [$assessment selectNodes {qticomment}] - if {[llength $definitionNodes] != 0} { - set definition [lindex $definitionNodes 0] - set as_assessments__definition [as::qti::mattext_gethtml $definition] - } - } elseif {$nodeName == "objectives"} { - set definitionNodes [$assessment selectNodes {objectives/material/mattext}] - if {[llength $definitionNodes] != 0} { - set definition [lindex $definitionNodes 0] - set as_assessments__definition [as::qti::mattext_gethtml $definition] - } - #as_assessments.instructions = - } elseif {$nodeName == "rubric"} { - set instructionNodes [$assessment selectNodes {rubric/material/mattext}] - if {[llength $instructionNodes] != 0} { - set instruction [lindex $instructionNodes 0] - set as_assessments__instructions [as::qti::mattext_gethtml $instruction] - } - #as_assessments.time_for_response = - } elseif {$nodeName == "duration"} { - set durationNodes [$assessment selectNodes {duration/text()}] - if {[llength $durationNodes] != 0} { - set duration [lindex $durationNodes 0] - set as_assessments__duration [$duration nodeValue] - } - } + # Parser + # XML => DOM document + dom parse [::tDOM::xmlReadFile $xmlfile] document + # DOM document => DOM root + $document documentElement root + # XPath v1.0 + # get all elements of a XML instance file + set questestinteropNodes [$root selectNodes {/questestinterop}] + foreach questestinterop $questestinteropNodes { + # Looks for assessments + set assessmentNodes [$questestinterop selectNodes {assessment}] + if { [llength $assessmentNodes] > 0 } { + # There are assessments + foreach assessment $assessmentNodes { + set as_assessments__title [$assessment getAttribute {title} {Assessment}] + #get assessment's children: section, (qticomment, duration, qtimetadata, objectives, assessmentcontrol, + #rubric, presentation_material, outcomes_processing, assessproc_extension, assessfeedback, + #selection_ordering, reference, sectionref) + set nodesList [$assessment childNodes] + set as_assessments__definition "" + set as_assessments__instructions "" + set as_assessments__duration "" + #for each assessment's child + foreach node $nodesList { + set nodeName [$node nodeName] + #as_assessmentsx.description = or + if {$nodeName == "qticomment"} { + set definitionNodes [$assessment selectNodes {qticomment}] + if {[llength $definitionNodes] != 0} { + set definition [lindex $definitionNodes 0] + set as_assessments__definition [as::qti::mattext_gethtml $definition] + } + } elseif {$nodeName == "objectives"} { + set definitionNodes [$assessment selectNodes {objectives/material/mattext}] + if {[llength $definitionNodes] != 0} { + set definition [lindex $definitionNodes 0] + set as_assessments__definition [as::qti::mattext_gethtml $definition] + } + #as_assessments.instructions = + } elseif {$nodeName == "rubric"} { + set instructionNodes [$assessment selectNodes {rubric/material/mattext}] + if {[llength $instructionNodes] != 0} { + set instruction [lindex $instructionNodes 0] + set as_assessments__instructions [as::qti::mattext_gethtml $instruction] + } + #as_assessments.time_for_response = + } elseif {$nodeName == "duration"} { + set durationNodes [$assessment selectNodes {duration/text()}] + if {[llength $durationNodes] != 0} { + set duration [lindex $durationNodes 0] + set as_assessments__duration [as::qti::duration [$duration nodeValue]] + } + } + } + set qtimetadataNodes [$assessment selectNodes {qtimetadata}] + set as_assessments__run_mode "" + set as_assessments__anonymous_p f + set as_assessments__secure_access_p f + set as_assessments__reuse_responses_p f + set as_assessments__show_item_name_p f + set as_assessments__consent_page "" + set as_assessments__return_url "" + set as_assessments__start_time "" + set as_assessments__end_time "" + set as_assessments__number_tries "" + set as_assessments__wait_between_tries "" + set as_assessments__ip_mask "" + set as_assessments__show_feedback "none" + set as_assessments__section_navigation "default path" + + set itemfeedbacknodes [$root selectNodes {/questestinterop/assessment/section/item/itemfeedback}] + if { [llength $itemfeedbacknodes] >0} { + set as_assessments__show_feedback "all" + } + set resprocessNodes [$root selectNodes {/questestinterop/assessment/section/item/resprocessing}] + set as_assessments__survey_p {f} + if { [llength $resprocessNodes] == 0 } { + set as_assessments__survey_p {t} + #if it's a survey don't show feedback + set as_assessments__show_feedback "none" + } + + if {[llength $qtimetadataNodes] > 0} { + #nodes qtimetadatafield + set qtimetadatafieldNodes [$qtimetadataNodes selectNodes {qtimetadatafield}] + foreach qtimetadatafieldnode $qtimetadatafieldNodes { + set label [$qtimetadatafieldnode selectNodes {fieldlabel/text()}] + set label [$label nodeValue] + set value [$qtimetadatafieldnode selectNodes {fieldentry/text()}] + if { $value ne ""} { set value [$value nodeValue] } + + switch -exact -- $label { + run_mode { + set as_assessments__run_mode $value + } + anonymous_p { + set as_assessments__anonymous_p $value + } + secure_access_p { + set as_assessments__secure_access_p $value + } + reuse_responses_p { + set as_assessments__reuse_responses_p $value + } + show_item_name_p { + set as_assessments__show_item_name_p $value + } + consent_page { + set as_assessments__consent_page $value + } + start_time { + set as_assessments__start_time $value + } + end_time { + set as_assessments__end_time $value + } + number_tries { + set as_assessments__number_tries $value + } + wait_between_tries { + set as_assessments__wait_between_tries $value + } + ip_mask { + set as_assessments__ip_mask $value + } + show_feedback { + set as_assessments__show_feedback $value + } + section_navigation { + set as_assessments__section_navigation $value + } + } + + } + } + + # Insert assessment in the CR (and as_assessments table) getting the revision_id (assessment_id) + set as_assessments__assessment_id [as::assessment::new \ + -title $as_assessments__title \ + -description $as_assessments__definition \ + -instructions $as_assessments__instructions \ + -run_mode $as_assessments__run_mode \ + -anonymous_p $as_assessments__anonymous_p \ + -secure_access_p $as_assessments__secure_access_p \ + -reuse_responses_p $as_assessments__reuse_responses_p \ + -show_item_name_p $as_assessments__show_item_name_p \ + -consent_page $as_assessments__consent_page \ + -return_url $as_assessments__return_url \ + -start_time $as_assessments__start_time \ + -end_time $as_assessments__end_time \ + -number_tries $as_assessments__number_tries \ + -wait_between_tries $as_assessments__wait_between_tries \ + -time_for_response $as_assessments__duration \ + -ip_mask $as_assessments__ip_mask \ + -show_feedback $as_assessments__show_feedback \ + -section_navigation $as_assessments__section_navigation \ + -survey_p $as_assessments__survey_p ] + + # Section + set sectionNodes [$assessment selectNodes {section}] + set as_assessment_section_map__sort_order 0 + foreach section $sectionNodes { + set as_sections__title [$section getAttribute {title} {Section}] + set as_sections__ident [$section getAttribute {ident} {Section}] + #get section's children (qticomment, duration, qtimetadata, objectives, sectioncontrol, + #sectionprecondition, sectionpostcondition, rubric, presentation_material, outcomes_processing, + #sectionproc_extension, sectionfeedback, selection_ordering, reference, itemref, item, sectionref, + #section) + set nodesList [$section childNodes] + set as_sections__definition "" + set as_sections__instructions "" + set as_sections__duration "" + set as_sections__sectionfeedback "" + #for each section's child + foreach node $nodesList { + set nodeName [$node nodeName] + #as_sectionsx.description = or + if {$nodeName == "qticomment"} { + set definitionNodes [$section selectNodes {qticomment}] + if {[llength $definitionNodes] != 0} { + set definition [lindex $definitionNodes 0] + set as_sections__definition [as::qti::mattext_gethtml $definition] + } + } elseif {$nodeName == "objectives"} { + set definitionNodes [$section selectNodes {objectives/material/mattext}] + if {[llength $definitionNodes] != 0} { + set definition [lindex $definitionNodes 0] + set as_sections__definition [as::qti::mattext_gethtml $definition] + } + #as_sections.max_time_to_complete = + } elseif {$nodeName == "duration"} { + set section_durationNodes [$section selectNodes {duration/text()}] + if {[llength $section_durationNodes] != 0} { + set section_duration [lindex $section_durationNodes 0] + set as_sections__duration [as::qti::duration [$section_duration nodeValue]] + } + #as_sections.instructions = + } elseif {$nodeName == "rubric"} { + set section_instructionNodes [$section selectNodes {rubric/material/mattext}] + if {[llength $section_instructionNodes] != 0} { + set section_instruction [lindex $section_instructionNodes 0] + set as_sections__instructions [as::qti::mattext_gethtml $section_instruction] + } + #as_sections.feedback_text = + } elseif {$nodeName == "sectionfeedback"} { + set sectionfeedbackNodes [$section selectNodes {sectionfeedback/material/mattext}] + if {[llength $sectionfeedbackNodes] != 0} { + set sectionfeedback [lindex $sectionfeedbackNodes 0] + set as_sections__sectionfeedback [as::qti::mattext_gethtml $sectionfeedback] + } + } + } + + set qtimetadataNodes [$section selectNodes {qtimetadata}] + set as_sections__num_items "" + set as_sections__points "" + set asdt__display_type none + set asdt__s_num_items "" + set asdt__adp_chunk "" + set asdt__branched_p f + set asdt__back_button_p t + set asdt__submit_answer_p f + set asdt__sort_order_type order_of_entry + + if {[llength $qtimetadataNodes] > 0} { + #nodes qtimetadatafield + set qtimetadatafieldNodes [$qtimetadataNodes selectNodes {qtimetadatafield}] + foreach qtimetadatafieldnode $qtimetadatafieldNodes { + set label [$qtimetadatafieldnode selectNodes {fieldlabel/text()}] + set label [$label nodeValue] + set value [$qtimetadatafieldnode selectNodes {fieldentry/text()}] + if { $value ne ""} { set value [$value nodeValue] } + + switch -exact -- $label { + num_items { + set as_sections__num_items $value } - set qtimetadataNodes [$assessment selectNodes {qtimetadata}] - set as_assessments__run_mode "" - set as_assessments__anonymous_p f - set as_assessments__secure_access_p f - set as_assessments__reuse_responses_p f - set as_assessments__show_item_name_p f - set as_assessments__consent_page "" - set as_assessments__return_url "" - set as_assessments__start_time "" - set as_assessments__end_time "" - set as_assessments__number_tries "" - set as_assessments__wait_between_tries "" - set as_assessments__ip_mask "" - set as_assessments__show_feedback "none" - set as_assessments__section_navigation "default path" - - set itemfeedbacknodes [$root selectNodes {/questestinterop/assessment/section/item/itemfeedback}] - if { [llength $itemfeedbacknodes] >0} { - set as_assessments__show_feedback "all" + points { + set as_sections__points $value } - set resprocessNodes [$root selectNodes {/questestinterop/assessment/section/item/resprocessing}] - set as_assessments__survey_p {f} - if { [llength $resprocessNodes] == 0 } { - set as_assessments__survey_p {t} - #if it's a survey don't show feedback - set as_assessments__show_feedback "none" - } - - if {[llength $qtimetadataNodes] > 0} { - #nodes qtimetadatafield - set qtimetadatafieldNodes [$qtimetadataNodes selectNodes {qtimetadatafield}] - foreach qtimetadatafieldnode $qtimetadatafieldNodes { - set label [$qtimetadatafieldnode selectNodes {fieldlabel/text()}] - set label [$label nodeValue] - set value [$qtimetadatafieldnode selectNodes {fieldentry/text()}] - set value [$value nodeValue] - - switch -exact -- $label { - run_mode { - set as_assessments__run_mode $value - } - anonymous_p { - set as_assessments__anonymous_p $value - } - secure_access_p { - set as_assessments__secure_access_p $value - } - reuse_responses_p { - set as_assessments__reuse_responses_p $value - } - show_item_name_p { - set as_assessments__show_item_name_p $value - } - consent_page { - set as_assessments__consent_page $value - } - start_time { - set as_assessments__start_time $value - } - end_time { - set as_assessments__end_time $value - } - number_tries { - set as_assessments__number_tries $value - } - wait_between_tries { - set as_assessments__wait_between_tries $value - } - ip_mask { - set as_assessments__ip_mask $value - } - show_feedback { - set as_assessments__show_feedback $value - } - section_navigation { - set as_assessments__section_navigation $value - } - } - - } - } - - # Insert assessment in the CR (and as_assessments table) getting the revision_id (assessment_id) - set as_assessments__assessment_id [as::assessment::new \ - -title $as_assessments__title \ - -description $as_assessments__definition \ - -instructions $as_assessments__instructions \ - -run_mode $as_assessments__run_mode \ - -anonymous_p $as_assessments__anonymous_p \ - -secure_access_p $as_assessments__secure_access_p \ - -reuse_responses_p $as_assessments__reuse_responses_p \ - -show_item_name_p $as_assessments__show_item_name_p \ - -consent_page $as_assessments__consent_page \ - -return_url $as_assessments__return_url \ - -start_time $as_assessments__start_time \ - -end_time $as_assessments__end_time \ - -number_tries $as_assessments__number_tries \ - -wait_between_tries $as_assessments__wait_between_tries \ - -time_for_response $as_assessments__duration \ - -ip_mask $as_assessments__ip_mask \ - -show_feedback $as_assessments__show_feedback \ - -section_navigation $as_assessments__section_navigation \ - -survey_p $as_assessments__survey_p ] - - # Section - set sectionNodes [$assessment selectNodes {section}] - set as_assessment_section_map__sort_order 0 - foreach section $sectionNodes { - set as_sections__title [$section getAttribute {title} {Section}] - #get section's children (qticomment, duration, qtimetadata, objectives, sectioncontrol, - #sectionprecondition, sectionpostcondition, rubric, presentation_material, outcomes_processing, - #sectionproc_extension, sectionfeedback, selection_ordering, reference, itemref, item, sectionref, - #section) - set nodesList [$section childNodes] - set as_sections__definition "" - set as_sections__instructions "" - set as_sections__duration "" - set as_sections__sectionfeedback "" - #for each section's child - foreach node $nodesList { - set nodeName [$node nodeName] - #as_sectionsx.description = or - if {$nodeName == "qticomment"} { - set definitionNodes [$section selectNodes {qticomment}] - if {[llength $definitionNodes] != 0} { - set definition [lindex $definitionNodes 0] - set as_sections__definition [as::qti::mattext_gethtml $definition] - } - } elseif {$nodeName == "objectives"} { - set definitionNodes [$section selectNodes {objectives/material/mattext}] - if {[llength $definitionNodes] != 0} { - set definition [lindex $definitionNodes 0] - set as_sections__definition [as::qti::mattext_gethtml $definition] - } - #as_sections.max_time_to_complete = - } elseif {$nodeName == "duration"} { - set section_durationNodes [$section selectNodes {duration/text()}] - if {[llength $section_durationNodes] != 0} { - set section_duration [lindex $section_durationNodes 0] - set as_sections__duration [$section_duration nodeValue] - } - #as_sections.instructions = - } elseif {$nodeName == "rubric"} { - set section_instructionNodes [$section selectNodes {rubric/material/mattext}] - if {[llength $section_instructionNodes] != 0} { - set section_instruction [lindex $section_instructionNodes 0] - set as_sections__instructions [as::qti::mattext_gethtml $section_instruction] - } - #as_sections.feedback_text = - } elseif {$nodeName == "sectionfeedback"} { - set sectionfeedbackNodes [$section selectNodes {sectionfeedback/material/mattext}] - if {[llength $sectionfeedbackNodes] != 0} { - set sectionfeedback [lindex $sectionfeedbackNodes 0] - set as_sections__sectionfeedback [as::qti::mattext_gethtml $sectionfeedback] - } - } - } - - set qtimetadataNodes [$section selectNodes {qtimetadata}] - set as_sections__num_items "" - set as_sections__points "" - set asdt__display_type none - set asdt__s_num_items "" - set asdt__adp_chunk "" - set asdt__branched_p f - set asdt__back_button_p t - set asdt__submit_answer_p f - set asdt__sort_order_type order_of_entry - - if {[llength $qtimetadataNodes] > 0} { - #nodes qtimetadatafield - set qtimetadatafieldNodes [$qtimetadataNodes selectNodes {qtimetadatafield}] - foreach qtimetadatafieldnode $qtimetadatafieldNodes { - set label [$qtimetadatafieldnode selectNodes {fieldlabel/text()}] - set label [$label nodeValue] - set value [$qtimetadatafieldnode selectNodes {fieldentry/text()}] - set value [$value nodeValue] - - switch -exact -- $label { - num_items { - set as_sections__num_items $value - } - points { - set as_sections__points $value - } - display_type { - set asdt__display_type $value - } - s_num_items { - set asdt__s_num_items $value - } - adp_chunk { - set asdt__adp_chunk $value - } - branched_p { - set asdt__branched_p $value - } - back_button_p { - set asdt__back_button_p $value - } - submit_answer_p { - set asdt__submit_answer_p $value - } - sort_order_type { - set asdt__sort_order_type $value - } - } - } - } - - #section display type - 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] - # 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 - set as_items [as::qti::parse_item $section [file dirname $xmlfile]] - # Relation between as_items and as_sections - foreach as_item_list $as_items { - array set as_item $as_item_list - set as_item_id $as_item(as_item_id) - set as_item__duration $as_item(duration) - set as_item__points $as_item(points) - db_dml as_item_section_map_insert {} - incr as_item_section_map__sort_order - } - - #get points from a section - db_0or1row get_section_points {} - #update as_assessment_section_map with section points - db_dml update_as_assessment_section_map {} + display_type { + set asdt__display_type $value } - } - } else { - # Just items (no assessments) - as::qti::parse_item $questestinterop [file dirname $xmlfile]] + s_num_items { + set asdt__s_num_items $value + } + adp_chunk { + set asdt__adp_chunk $value + } + branched_p { + set asdt__branched_p $value + } + back_button_p { + set asdt__back_button_p $value + } + submit_answer_p { + set asdt__submit_answer_p $value + } + sort_order_type { + set asdt__sort_order_type $value + } + } + } + } + + #section display type + 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] + # Insert section in the CR (and in the as_sections table) getting the revision_id (section_id) + set section_id [as::section::new \ + -name $as_sections__ident \ + -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 + set as_items [as::qti::parse_item $section [file dirname $xmlfile]] + # Relation between as_items and as_sections + foreach as_item_list $as_items { + array set as_item $as_item_list + set as_item_id $as_item(as_item_id) + set as_item__duration $as_item(duration) + set as_item__points $as_item(points) + set as_item__required_p $as_item(required_p) + db_dml as_item_section_map_insert {} + incr as_item_section_map__sort_order + } + + #get points from a section + db_0or1row get_section_points {} + #update as_assessment_section_map with section points + db_dml update_as_assessment_section_map {} } - } - return $as_assessments__assessment_id + } + } else { + # Just items (no assessments) + as::qti::parse_item $questestinterop [file dirname $xmlfile]] + } } +return $as_assessments__assessment_id +} ad_proc -private as::qti::parse_item {qtiNode basepath} { Parse items from a XML QTI file } { + set as_items__ident "" set as_items__description "" set as_items__subtext "" set as_items__field_code "" @@ -438,16 +442,16 @@ set durationNodes [$item selectNodes {duration/text()}] if {[llength $durationNodes] != 0} { set duration [lindex $durationNodes 0] - set as_items__duration [$duration nodeValue] + set as_items__duration [as::qti::duration [$duration nodeValue]] } - #as_items.description = + #as_items.description = } elseif {$nodeName == "qticomment"} { set qticommentNodes [$item selectNodes {qticomment/text()}] if {[llength $qticommentNodes] != 0} { set qticomment [lindex $qticommentNodes 0] set as_items__description [$qticomment nodeValue] } - #as_items.subtext = + #as_items.subtext = } elseif {$nodeName == "rubric"} { set instructionNodes [$item selectNodes {rubric/material/mattext}] if {[llength $instructionNodes] != 0} { @@ -457,72 +461,79 @@ } } - set qtimetadataNodes [$item selectNodes {qtimetadata}] - if {[llength $qtimetadataNodes] > 0} { - #nodes qtimetadatafield - set qtimetadatafieldNodes [$qtimetadataNodes selectNodes {qtimetadatafield}] - foreach qtimetadatafieldnode $qtimetadatafieldNodes { - set label [$qtimetadatafieldnode selectNodes {fieldlabel/text()}] - set label [$label nodeValue] - set value [$qtimetadatafieldnode selectNodes {fieldentry/text()}] - set value [$value nodeValue] - - switch -exact -- $label { - field_code { - set as_items__field_code $value - } - required_p { - set as_items__required_p $value - } - data_type { - set as_items__data_type $value - } - increasing_p { - set aitmc__increasing_p $value - } - allow_negative_p { - set aitmc__allow_negative_p $value - } - num_correct_answers { - set aitmc__num_correct_answers $value - } - num_answers { - set aitmc__num_answers $value - } - default_value { - set aitoq__default_value $value - } - feedback_text { - set aitoq__feedback_text $value - } - html_display_options { - set aidrb__html_options $value - } - choice_orientation { - set aidrb__choice_orientation $value - } - choice_label_orientation { - set aidrb__label_orientation $value - } - sort_order_type { - set aidrb__order_type $value - } - item_answer_alignment { - set aidrb__answer_alignment $value - } - abs_size { - set aidta__abs_size $value - } - tb_abs_size { - set aidtb__abs_size $value - } - } - } - } - + set itemmetadataNodes [$item selectNodes {itemmetadata}] + + if { [llength $itemmetadataNodes] > 0 } { + + set qtimetadataNodes [$itemmetadataNodes selectNodes {qtimetadata}] + if {[llength $qtimetadataNodes] > 0} { + #nodes qtimetadatafield + set qtimetadatafieldNodes [$qtimetadataNodes selectNodes {qtimetadatafield}] + foreach qtimetadatafieldnode $qtimetadatafieldNodes { + set label [$qtimetadatafieldnode selectNodes {fieldlabel/text()}] + set label [$label nodeValue] + set value [$qtimetadatafieldnode selectNodes {fieldentry/text()}] + if { $value ne "" } { set value [$value nodeValue] } + + switch -exact -- $label { + field_code { + set as_items__field_code $value + } + required_p { + set as_items__required_p $value + } + data_type { + set as_items__data_type $value + } + increasing_p { + set aitmc__increasing_p $value + } + allow_negative_p { + set aitmc__allow_negative_p $value + } + num_correct_answers { + set aitmc__num_correct_answers $value + } + num_answers { + set aitmc__num_answers $value + } + default_value { + set aitoq__default_value $value + } + feedback_text { + set aitoq__feedback_text $value + } + html_display_options { + set aidrb__html_options $value + } + choice_orientation { + set aidrb__choice_orientation $value + } + choice_label_orientation { + set aidrb__label_orientation $value + } + sort_order_type { + set aidrb__order_type $value + } + item_answer_alignment { + set aidrb__answer_alignment $value + } + abs_size { + set aidta__abs_size $value + } + tb_abs_size { + set aidtb__abs_size $value + } + } + } + } + } + # Order of the item_choices set sort_order 0 set as_items__title [$item getAttribute {title} {Item}] + set as_items__ident [$item getAttribute {ident} {Item}] + array set as_item_choices__correct_answer_p {} array set as_item_choices__score {} array set as_item_choices__feedback_text {} @@ -549,45 +560,45 @@ foreach choice $scoreNodes { set choice_id "" set choice_id [string trim [$choice nodeValue]] - - if {[info exists choice_id]} { - set score 0 - # get score - set scoreNodes [$respcondition selectNodes {setvar/text()}] - foreach scorenode $scoreNodes { - set score [string trim [$scorenode nodeValue]] - if {$score>0} { - set as_item_choices__correct_answer_p($choice_id) {t} + + if {[info exists choice_id]} { + set score 0 + # get score + set scoreNodes [$respcondition selectNodes {setvar/text()}] + foreach scorenode $scoreNodes { + set score [string trim [$scorenode nodeValue]] + if {$score>0} { + set as_item_choices__correct_answer_p($choice_id) {t} + } } + set as_item_choices__score($choice_id) $score + incr as_items__points $score } - set as_item_choices__score($choice_id) $score - incr as_items__points $score } - } set scoreNodes [$respcondition selectNodes {conditionvar/and/varequal/text()}] foreach choice $scoreNodes { set choice_id "" set choice_id [string trim [$choice nodeValue]] - - if {[info exists choice_id]} { - set score 0 - # get score - set scoreNodes [$respcondition selectNodes {setvar/text()}] - foreach scorenode $scoreNodes { - set score [string trim [$scorenode nodeValue]] - if {$score>0} { - set as_item_choices__correct_answer_p($choice_id) {t} + + if {[info exists choice_id]} { + set score 0 + # get score + set scoreNodes [$respcondition selectNodes {setvar/text()}] + foreach scorenode $scoreNodes { + set score [string trim [$scorenode nodeValue]] + if {$score>0} { + set as_item_choices__correct_answer_p($choice_id) {t} + } } + set scoreNodes1 [$respcondition selectNodes {conditionvar/and/varequal}] + if {[llength $scoreNodes1]>0} { + set score1 [expr ($score*1.0/[llength $scoreNodes1])] + } + set as_item_choices__score($choice_id) $score1 + set as_items__points $score } - set scoreNodes1 [$respcondition selectNodes {conditionvar/and/varequal}] - if {[llength $scoreNodes1]>0} { - set score1 [expr ($score*1.0/[llength $scoreNodes1])] - } - set as_item_choices__score($choice_id) $score1 - set as_items__points $score } - } set resp_cond_varNodes [$respcondition selectNodes {conditionvar/varequal/text()}] if {[llength $resp_cond_varNodes]==1} { } else { @@ -612,9 +623,9 @@ set as_items__feedback_right [$as_items__feedback_right nodeValue] } } - } - } - } + } + } + } } } @@ -628,7 +639,7 @@ set material [lindex $materialNodes 0] # Initialize in case it doesn't exist set as_items__title {} - if {[$material nodeName] == {material}} { + if {$material ne "" && [$material nodeName] == {material}} { set mattextNodes [$material selectNodes {mattext}] set mattext [lindex $mattextNodes 0] set as_items__title [as::qti::mattext_gethtml $mattext] @@ -651,9 +662,9 @@ set html "rows $rows cols $cols" # insert as_item_display_ta in the CR (and in the as_item_display_ta table) getting the revision_id (item_display_id) set as_item_display_id [as::item_display_ta::new \ - -html_display_options $html \ - -abs_size $aidta__abs_size \ - -item_answer_alignment $aidrb__answer_alignment] + -html_display_options $html \ + -abs_size $aidta__abs_size \ + -item_answer_alignment $aidrb__answer_alignment] foreach node $presentationChildNodes { # get the title of item if {[$node nodeName] == {material}} { @@ -666,14 +677,14 @@ } # insert as_item_type_oq (shortanswer) set as_item_type_id [as::item_type_oq::new \ - -default_value $aitoq__default_value \ - -feedback_text $aitoq__feedback_text] + -default_value $aitoq__default_value \ + -feedback_text $aitoq__feedback_text] # if render_fib element has not the attribute rows then it's a fill in blank item } else { # textbox set as_item_display_id [as::item_display_tb::new \ - -abs_size $aidtb__abs_size \ - -item_answer_alignment $aidrb__answer_alignment] + -abs_size $aidtb__abs_size \ + -item_answer_alignment $aidrb__answer_alignment] # multiple choice set as_item_type_id [as::item_type_mc::new] @@ -704,79 +715,87 @@ } # Insert as_item set as_item_id [as::item::new \ - -title $as_items__title \ - -description $as_items__description \ - -subtext $as_items__subtext \ - -field_code $as_items__field_code \ - -required_p $as_items__required_p \ - -data_type $as_items__data_type \ - -feedback_right $as_items__feedback_right \ - -feedback_wrong $as_items__feedback_wrong \ - -max_time_to_complete $as_items__duration \ - -points $as_items__points] + -title $as_items__title \ + -description $as_items__description \ + -subtext $as_items__subtext \ + -field_code $as_items__field_code \ + -field_name $as_items__ident \ + -required_p $as_items__required_p \ + -data_type $as_items__data_type \ + -feedback_right $as_items__feedback_right \ + -feedback_wrong $as_items__feedback_wrong \ + -max_time_to_complete $as_items__duration \ + -points $as_items__points] # set the relation between as_items and as_item_type tables 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 set as_item(as_item_id) $as_item_id set as_item(points) $as_items__points set as_item(duration) $as_items__duration + set as_item(required_p) $as_items__required_p lappend as_items [array get as_item] } 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 set response_lid [lindex $response_lidNodes 0] - set as_items__rcardinality [$response_lid getAttribute {rcardinality} {Single}] - + if { $response_lid ne "" } { + set as_items__rcardinality [$response_lid getAttribute {rcardinality} {Single}] + } else { + set as_items__rcardinality "" + } + # multiple choice either text (remember it can be internationalized or changed), images, sounds, videos # this is the default set as_item_display_id {} if {$as_items__rcardinality == {Multiple}} { # multiple response (checkbox) either text (remember it can be internationalized or changed), images, sounds, videos # insert as_item_display_cb set as_item_display_id [as::item_display_cb::new \ - -html_display_options $aidrb__html_options \ - -choice_orientation $aidrb__choice_orientation \ - -choice_label_orientation $aidrb__label_orientation \ - -sort_order_type $aidrb__order_type \ - -item_answer_alignment $aidrb__answer_alignment] + -html_display_options $aidrb__html_options \ + -choice_orientation $aidrb__choice_orientation \ + -choice_label_orientation $aidrb__label_orientation \ + -sort_order_type $aidrb__order_type \ + -item_answer_alignment $aidrb__answer_alignment] } else { # multiple choice (radiobutton) # insert as_item_display_rb set as_item_display_id [as::item_display_rb::new \ - -html_display_options $aidrb__html_options \ - -choice_orientation $aidrb__choice_orientation \ - -choice_label_orientation $aidrb__label_orientation \ - -sort_order_type $aidrb__order_type \ - -item_answer_alignment $aidrb__answer_alignment] + -html_display_options $aidrb__html_options \ + -choice_orientation $aidrb__choice_orientation \ + -choice_label_orientation $aidrb__label_orientation \ + -sort_order_type $aidrb__order_type \ + -item_answer_alignment $aidrb__answer_alignment] } # insert as_item_type_mc set as_item_type_id [as::item_type_mc::new \ - -increasing_p $aitmc__increasing_p \ - -allow_negative_p $aitmc__allow_negative_p \ - -num_correct_answers $aitmc__num_correct_answers \ - -num_answers $aitmc__num_answers] - + -increasing_p $aitmc__increasing_p \ + -allow_negative_p $aitmc__allow_negative_p \ + -num_correct_answers $aitmc__num_correct_answers \ + -num_answers $aitmc__num_answers] + # Insert as_item set as_item_id [as::item::new \ - -title $as_items__title \ - -description $as_items__description \ - -subtext $as_items__subtext \ - -field_code $as_items__field_code \ - -required_p $as_items__required_p \ - -data_type $as_items__data_type \ - -feedback_right $as_items__feedback_right \ - -feedback_wrong $as_items__feedback_wrong \ - -max_time_to_complete $as_items__duration \ - -points $as_items__points] + -title $as_items__title \ + -description $as_items__description \ + -subtext $as_items__subtext \ + -field_code $as_items__field_code \ + -field_name $as_items__ident \ + -required_p $as_items__required_p \ + -data_type $as_items__data_type \ + -feedback_right $as_items__feedback_right \ + -feedback_wrong $as_items__feedback_wrong \ + -max_time_to_complete $as_items__duration \ + -points $as_items__points] # set the relation between as_items and as_item_type tables 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 set as_item(as_item_id) $as_item_id set as_item(points) $as_items__points set as_item(duration) $as_items__duration + set as_item(required_p) $as_items__required_p lappend as_items [array get as_item] # (each choice) set response_labelNodes [$presentation selectNodes {.//response_label}] @@ -812,50 +831,76 @@ set resprocessingNodes [$item selectNodes {resprocessing}] foreach resprocessing $resprocessingNodes { - # - set respconditionNodes [$resprocessing selectNodes {respcondition}] - foreach respcondition $respconditionNodes { - set displayfeedbackNode "" - set resp_cond_varNodes [$respcondition selectNodes {conditionvar/varequal/text()}] - if {[llength $resp_cond_varNodes]==1} { - set displayfeedbackNode [$respcondition selectNodes {displayfeedback}] - set choice_identifier [$resp_cond_varNodes nodeValue] - if {[llength $displayfeedbackNode]>0} { - set displayfeedback__ident [$displayfeedbackNode getAttribute {linkrefid}] - set choice_identifier [$resp_cond_varNodes nodeValue] - if {$as_item_choices__ident == $choice_identifier} { - set choices__feedback_text [$item selectNodes "//itemfeedback\[@ident='$displayfeedback__ident'\]/flow_mat/material/mattext/text()"] - if {[llength $choices__feedback_text]>0} { - set as_item_choices__feedback_text($as_item_choices__ident) [$choices__feedback_text nodeValue] - } - } - } - } + # + set respconditionNodes [$resprocessing selectNodes {respcondition}] + foreach respcondition $respconditionNodes { + set displayfeedbackNode "" + set resp_cond_varNodes [$respcondition selectNodes {conditionvar/varequal/text()}] + if {[llength $resp_cond_varNodes]==1} { + set displayfeedbackNode [$respcondition selectNodes {displayfeedback}] + set choice_identifier [$resp_cond_varNodes nodeValue] + if {[llength $displayfeedbackNode]>0} { + set displayfeedback__ident [$displayfeedbackNode getAttribute {linkrefid}] + set choice_identifier [$resp_cond_varNodes nodeValue] + if {$as_item_choices__ident == $choice_identifier} { + set choices__feedback_text [$item selectNodes "//itemfeedback\[@ident='$displayfeedback__ident'\]/flow_mat/material/mattext/text()"] + if {[llength $choices__feedback_text]>0} { + set as_item_choices__feedback_text($as_item_choices__ident) [$choices__feedback_text nodeValue] + } + } + } + } + } } - } # insert as_item_choice as::item_choice::new \ - -mc_id $as_item_type_id \ - -title $as_item_choices__choice_text \ - -sort_order $sort_order \ - -selected_p $selected_p \ - -feedback_text $as_item_choices__feedback_text($as_item_choices__ident) \ - -correct_answer_p $as_item_choices__correct_answer_p($as_item_choices__ident) \ - -percent_score $as_item_choices__score($as_item_choices__ident) \ - -content_value $as_item_choices__content_value + -mc_id $as_item_type_id \ + -title $as_item_choices__choice_text \ + -sort_order $sort_order \ + -selected_p $selected_p \ + -feedback_text $as_item_choices__feedback_text($as_item_choices__ident) \ + -correct_answer_p $as_item_choices__correct_answer_p($as_item_choices__ident) \ + -percent_score $as_item_choices__score($as_item_choices__ident) \ + -content_value $as_item_choices__content_value # order of the item_choices incr sort_order } } #import an image as title of item set matmediaNodes [$presentation selectNodes {material/matimage[@uri]}] - if {[llength $matmediaNodes]>0} { - set mediabasepath [file join $basepath [$matmediaNodes getAttribute {uri}]] - # insert as_file in the CR (and in the as_file table) getting the content value - set as_item_choices__content_value [as::file::new -file_pathname $mediabasepath] - as::item_rels::new -item_rev_id $as_item_id -target_rev_id $as_item_choices__content_value -type as_item_content_rel - } + if {[llength $matmediaNodes]>0} { + set mediabasepath [file join $basepath [$matmediaNodes getAttribute {uri}]] + # insert as_file in the CR (and in the as_file table) getting the content value + set as_item_choices__content_value [as::file::new -file_pathname $mediabasepath] + as::item_rels::new -item_rev_id $as_item_id -target_rev_id $as_item_choices__content_value -type as_item_content_rel + } } } return $as_items } + +ad_proc -public as::qti::duration { + duration +} { + Convert duration + + @author Roel Canicula (roel@solutiongrove.com) + @creation-date 2006-05-04 + + @param duration + + @return + + @error +} { + if { [regexp {^\d+$} $duration] } { + return $duration + } elseif { [regexp {^p|P$} $duration] } { + return "" + } elseif { [regexp {^p|P} $duration] } { + # check for format P0Y0M0DT0H1M0S + regexp {t|T(\d+)h|H(\d+)m|M(\d+)s|S} $duration match h m s + # ignore year, month and days for now + return [expr $h*3600+$m*60+$s] + } +} 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.5 -r1.5.2.1 --- openacs-4/packages/assessment/tcl/as-qti-procs.xql 22 Feb 2005 15:20:00 -0000 1.5 +++ openacs-4/packages/assessment/tcl/as-qti-procs.xql 6 May 2006 15:52:56 -0000 1.5.2.1 @@ -10,8 +10,8 @@ - INSERT INTO as_item_section_map (as_item_id, section_id, sort_order, points, max_time_to_complete) - VALUES (:as_item_id, :section_id, :as_item_section_map__sort_order, :as_item__points, :as_item__duration) + INSERT INTO as_item_section_map (as_item_id, section_id, sort_order, points, max_time_to_complete, required_p) + VALUES (:as_item_id, :section_id, :as_item_section_map__sort_order, :as_item__points, :as_item__duration, :as_item__required_p) @@ -31,4 +31,17 @@ + + + + update as_item_section_map + set as_item_id = :new_item_id, + points = :points, + required_p = :required_p + where section_id = :new_section_id + and as_item_id = :as_item_id + + + + Index: openacs-4/packages/assessment/tcl/as-section-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs.tcl,v diff -u -r1.23.2.4 -r1.23.2.5 --- openacs-4/packages/assessment/tcl/as-section-procs.tcl 27 Jan 2006 09:41:09 -0000 1.23.2.4 +++ openacs-4/packages/assessment/tcl/as-section-procs.tcl 6 May 2006 15:52:56 -0000 1.23.2.5 @@ -29,7 +29,9 @@ # Insert as_section in the CR (and as_sections table) getting the revision_id (as_section_id) db_transaction { set section_item_id [db_nextval acs_object_id_seq] - if {[empty_string_p $name]} { + if { ![empty_string_p $name] && [db_0or1row item_exists {}] } { + set name "$section_item_id: $name" + } elseif {[empty_string_p $name]} { set name "SEC_$section_item_id" } set section_item_id [content::item::new -item_id $section_item_id -parent_id $folder_id -content_type {as_sections} -name $name] Index: openacs-4/packages/assessment/tcl/as-section-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/tcl/as-section-procs.xql,v diff -u -r1.12 -r1.12.2.1 --- openacs-4/packages/assessment/tcl/as-section-procs.xql 13 Apr 2005 10:48:29 -0000 1.12 +++ openacs-4/packages/assessment/tcl/as-section-procs.xql 6 May 2006 15:52:56 -0000 1.12.2.1 @@ -113,5 +113,15 @@ + + + select item_id + from cr_items + where parent_id = :folder_id + and name = :name + + + + Index: openacs-4/packages/assessment/www/asm-admin/export/index.vuh =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/export/index.vuh,v diff -u -r1.7.2.1 -r1.7.2.2 --- openacs-4/packages/assessment/www/asm-admin/export/index.vuh 24 Nov 2005 15:32:03 -0000 1.7.2.1 +++ openacs-4/packages/assessment/www/asm-admin/export/index.vuh 6 May 2006 15:52:55 -0000 1.7.2.2 @@ -9,20 +9,20 @@ } if {[exists_and_not_null assessment_id]} { - # Get the assessment data - as::assessment::data -assessment_id $assessment_id - set download_name $assessment_data(title) - - # We get rid of spaces since they are annoying - regsub -all { } $download_name {_} download_name + # Get the assessment data + as::assessment::data -assessment_id $assessment_id + set download_name $assessment_data(title) + + # We get rid of spaces since they are annoying + regsub -all { } $download_name {_} download_name - set tmp_dir $download_name - set ext "zip" + set tmp_dir $download_name + set ext "zip" - append download_name ".${ext}" + append download_name ".${ext}" - ad_returnredirect "${assessment_id}/${download_name}" - ad_script_abort + ad_returnredirect "${assessment_id}/${download_name}" + ad_script_abort } # convenient way to get the values out of a list @@ -154,14 +154,14 @@ #sort_order_type as::export::element_qtimetadatafield -root $doc -father $qtimetadata -label sort_order_type -value $s_sort_order_type } - + # as::export::new_element -value $section_description -father $section -label objectives -root $doc -material_p t # as::export::new_element -value $section_instructions -father $section -label rubric -root $doc -material_p t # as::export::new_element -value $section_feedback_text -father $section -label sectionfeedback -root $doc -material_p t -attribute_label ident -attribute_value $section_id - + # set selection_ordering [$doc createElement selection_ordering] $section appendChild $selection_ordering @@ -199,12 +199,15 @@ db_0or1row as_item_display_tbx "SELECT as_item_display_id AS tb__display_id FROM as_item_display_tb WHERE as_item_display_id=:item_display_id" #textarea (short answer) db_0or1row as_item_display_tax "SELECT as_item_display_id AS ta__display_id FROM as_item_display_ta WHERE as_item_display_id=:item_display_id" - + # set item [$doc createElement item] + if { $field_name ne "" } { + set item_name $field_name + } $item setAttribute ident $item_name $section appendChild $item - + # as::export::new_element -value $item_description -father $item -label qticomment -root $doc # @@ -268,7 +271,7 @@ #item_answer_alignment as::export::element_qtimetadatafield -root $doc -father $qtimetadata -label item_answer_alignment -value $item_answer_alignment } - + # open question item db_0or1row as_item_oq { } if {[info exists id__as_item_type_oq]} { @@ -301,7 +304,7 @@ #content_type: imagen set content_type "" - + db_0or1row get_content_type_items {} if {$content_type == "image"} { # @@ -316,8 +319,8 @@ file copy -force -- "${cr_path}${cr_file_name}" [file join ${in_path} $content_filename] } } - + #find out the item type (multiple choice or multiple response) if {[info exists cb__display_id] || [info exists rb__display_id]} { if {[info exists cb__display_id]} { @@ -372,7 +375,7 @@ } } else { #short answer - if {[info exists ta__display_id]} { + if {[info exists ta__display_id] } { # set response_str [$doc createElement response_str] $response_str setAttribute ident $item_name @@ -382,8 +385,8 @@ #get rows and cols for painting a textarea (in abs_size is stored as "rows value cols value", we need to add the symbol =) db_0or1row html_rows_cols "SELECT html_display_options FROM as_item_display_ta WHERE as_item_display_id=:item_display_id" if {![empty_string_p $html_display_options]} { - set rows "[lindex $html_display_options 1]" - set columns "[lindex $html_display_options 3]" + set rows "[lindex $html_display_options 3]" + set columns "[lindex $html_display_options 1]" } else { set rows 5 set columns 25 @@ -404,12 +407,16 @@ } else { #fill in the blank #whether it's a fill-in-blank I have to split by + ns_log notice "DEBUG::1 $item_title" regsub -all -line -nocase -- "" $html ":" html1 + ns_log notice "DEBUG::3 $html1" set item_title1 [split $html1 :] set longitud [llength $item_title1] - - for {set i 0} {$i<[llength $item_title1]-1} {incr i 2} { + + for {set i 0} {$i<=[llength $item_title1]-1} {incr i 2} { + ns_log notice "DEBUG::4 $i" set item_title [lindex $item_title1 $i] # set material [$doc createElement material] @@ -439,9 +446,9 @@ $render_fib appendChild $response_label } } - } - - if { $assessment_data(survey_p) != "t" && ![info exists ta__display_id] } { + } + + if { $assessment_data(survey_p) != "t" && ![info exists ta__display_id] } { # set resprocessing [$doc createElement resprocessing] $item appendChild $resprocessing @@ -461,65 +468,65 @@ #fill-in-blank if {[info exists tb__display_id]} { - set i 0 - db_foreach query_all_choices {} { - # - set or [$doc createElement or] - $conditionvar appendChild $or - set list_choice_title $choice_title - for {set j 0} {$j < [llength $list_choice_title]} {incr j 1} { - # - set varequal [$doc createElement varequal] - $varequal setAttribute respident $item_name$i - $or appendChild $varequal - set text [$doc createCDATASection [lindex $list_choice_title $j]] - $varequal appendChild $text - } - incr i 2 - } - } else { - - - # - set and [$doc createElement and] - $conditionvar appendChild $and - - set exist_false 0 - db_foreach query_all_choices2 {} { - if {$correct_answer_p == "t" } { - # - set varequal [$doc createElement varequal] - $varequal setAttribute respident $item_name - $and appendChild $varequal - set text [$doc createCDATASection $name] - $varequal appendChild $text - } else { - set exist_false 1 + set i 0 + db_foreach query_all_choices {} { + # + set or [$doc createElement or] + $conditionvar appendChild $or + set list_choice_title $choice_title + for {set j 0} {$j < [llength $list_choice_title]} {incr j 1} { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name$i + $or appendChild $varequal + set text [$doc createCDATASection [lindex $list_choice_title $j]] + $varequal appendChild $text + } + incr i 2 } - } - if { $exist_false == 1 } { - # - set not [$doc createElement not] - $and appendChild $not - # - set or [$doc createElement or] - $not appendChild $or + } else { + + + # + set and [$doc createElement and] + $conditionvar appendChild $and + + set exist_false 0 db_foreach query_all_choices2 {} { - if {$correct_answer_p == "f" } { - # - set varequal [$doc createElement varequal] - $varequal setAttribute respident $item_name - $or appendChild $varequal - set text [$doc createCDATASection $name] - $varequal appendChild $text + if {$correct_answer_p == "t" } { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name + $and appendChild $varequal + set text [$doc createCDATASection $name] + $varequal appendChild $text + } else { + set exist_false 1 } } - } + if { $exist_false == 1 } { + # + set not [$doc createElement not] + $and appendChild $not + # + set or [$doc createElement or] + $not appendChild $or + db_foreach query_all_choices2 {} { + if {$correct_answer_p == "f" } { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name + $or appendChild $varequal + set text [$doc createCDATASection $name] + $varequal appendChild $text + } + } + } } set num_answers_correct "" db_0or1row num_answers_correct {} - + if {$item_points == 1 && $num_answers_correct>1} { # set setvar [$doc createElement setvar] @@ -546,202 +553,202 @@ #fill-in-blank if {[info exists tb__display_id]} { - set i 0 - # - set not [$doc createElement not] - $conditionvar appendChild $not - # - set and [$doc createElement and] - $not appendChild $and - db_foreach query_all_choices {} { - # - set or [$doc createElement or] - $and appendChild $or - set list_choice_title $choice_title - for {set j 0} {$j < [llength $list_choice_title]} {incr j 1} { - # - set varequal [$doc createElement varequal] - $varequal setAttribute respident $item_name$i - $or appendChild $varequal - set text [$doc createCDATASection [lindex $list_choice_title $j]] - $varequal appendChild $text - } - incr i 2 - } - - } else { - - # - set or [$doc createElement or] - $conditionvar appendChild $or - - set exist_true 0 - db_foreach query_all_choices2 {} { - if {$correct_answer_p == "f" } { - # - set varequal [$doc createElement varequal] - $varequal setAttribute respident $item_name - $or appendChild $varequal - set text [$doc createCDATASection $name] - $varequal appendChild $text - } else { - set exist_true 1 - } - } - if { $exist_true == 1 } { + set i 0 # set not [$doc createElement not] - $or appendChild $not + $conditionvar appendChild $not # set and [$doc createElement and] $not appendChild $and - db_foreach query_all_choices2 {} { - if {$correct_answer_p == "t" } { - # - set varequal [$doc createElement varequal] - $varequal setAttribute respident $item_name - $and appendChild $varequal - set text [$doc createCDATASection $name] - $varequal appendChild $text - } - } - } - } - - # - set displayfeedback [$doc createElement displayfeedback] - set linkrefid { } - append linkrefid $item_name displayWrong - $displayfeedback setAttribute linkrefid $linkrefid - $respcondition appendChild $displayfeedback - - - if {$item_points>1 || $num_answers_correct==1} { - db_foreach query_all_choices {} { - set i 0 - # [info exists tb__display_id] because for fib item choice_correct_answer_p is null - if { $choice_correct_answer_p == "t" || [info exists tb__display_id] } { - set list_choice_title $choice_title - set length_list_choice_title [llength $list_choice_title] - - if {![info exists tb__display_id]} { - set length_list_choice_title 1 - } - - for {set j 0} {$j < $length_list_choice_title} {incr j 1} { - # - set respcondition [$doc createElement respcondition] - $respcondition setAttribute title "adjustscore" - $resprocessing appendChild $respcondition - # - set conditionvar [$doc createElement conditionvar] - $respcondition appendChild $conditionvar - # - set varequal [$doc createElement varequal] - if {[info exists tb__display_id]} { - $varequal setAttribute respident $item_name$i - } else { - $varequal setAttribute respident $item_name + db_foreach query_all_choices {} { + # + set or [$doc createElement or] + $and appendChild $or + set list_choice_title $choice_title + for {set j 0} {$j < [llength $list_choice_title]} {incr j 1} { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name$i + $or appendChild $varequal + set text [$doc createCDATASection [lindex $list_choice_title $j]] + $varequal appendChild $text } - $conditionvar appendChild $varequal - if {[info exists tb__display_id]} { - set text [$doc createCDATASection [lindex $list_choice_title $j]] + incr i 2 + } + + } else { + + # + set or [$doc createElement or] + $conditionvar appendChild $or + + set exist_true 0 + db_foreach query_all_choices2 {} { + if {$correct_answer_p == "f" } { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name + $or appendChild $varequal + set text [$doc createCDATASection $name] + $varequal appendChild $text } else { - set text [$doc createCDATASection $choice_name] + set exist_true 1 } - $varequal appendChild $text - # - set setvar [$doc createElement setvar] - $setvar setAttribute varname "SCORE" - $setvar setAttribute action "Add" - $respcondition appendChild $setvar - # in fib items choice_percent_score column is null - if {[empty_string_p $choice_percent_score]} { - set choice_percent_score 1 - } else { - set choice_percent_score [expr round (($num_answers_correct * $choice_percent_score * 1.0) / 100)] - } - set text [$doc createCDATASection $choice_percent_score] - $setvar appendChild $text - #feedback choice - if {![empty_string_p $choice_feedback_text]} { - set displayfeedback [$doc createElement displayfeedback] + } + if { $exist_true == 1 } { + # + set not [$doc createElement not] + $or appendChild $not + # + set and [$doc createElement and] + $not appendChild $and + db_foreach query_all_choices2 {} { + if {$correct_answer_p == "t" } { + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name + $and appendChild $varequal + set text [$doc createCDATASection $name] + $varequal appendChild $text + } + } + } + } + + # + set displayfeedback [$doc createElement displayfeedback] + set linkrefid { } + append linkrefid $item_name displayWrong + $displayfeedback setAttribute linkrefid $linkrefid + $respcondition appendChild $displayfeedback + + + if {$item_points>1 || $num_answers_correct==1} { + db_foreach query_all_choices {} { + set i 0 + # [info exists tb__display_id] because for fib item choice_correct_answer_p is null + if { $choice_correct_answer_p == "t" || [info exists tb__display_id] } { + set list_choice_title $choice_title + set length_list_choice_title [llength $list_choice_title] + + if {![info exists tb__display_id]} { + set length_list_choice_title 1 + } + + for {set j 0} {$j < $length_list_choice_title} {incr j 1} { + # + set respcondition [$doc createElement respcondition] + $respcondition setAttribute title "adjustscore" + $resprocessing appendChild $respcondition + # + set conditionvar [$doc createElement conditionvar] + $respcondition appendChild $conditionvar + # + set varequal [$doc createElement varequal] + if {[info exists tb__display_id]} { + $varequal setAttribute respident $item_name$i + } else { + $varequal setAttribute respident $item_name + } + $conditionvar appendChild $varequal + if {[info exists tb__display_id]} { + set text [$doc createCDATASection [lindex $list_choice_title $j]] + } else { + set text [$doc createCDATASection $choice_name] + } + $varequal appendChild $text + # + set setvar [$doc createElement setvar] + $setvar setAttribute varname "SCORE" + $setvar setAttribute action "Add" + $respcondition appendChild $setvar + # in fib items choice_percent_score column is null + if {[empty_string_p $choice_percent_score]} { + set choice_percent_score 1 + } else { + set choice_percent_score [expr round (($num_answers_correct * $choice_percent_score * 1.0) / 100)] + } + set text [$doc createCDATASection $choice_percent_score] + $setvar appendChild $text + #feedback choice + if {![empty_string_p $choice_feedback_text]} { + set displayfeedback [$doc createElement displayfeedback] + set linkrefid { } + append linkrefid $choice_name feedbackChoice + $displayfeedback setAttribute linkrefid $linkrefid + $respcondition appendChild $displayfeedback + } + } + } + incr i 2 + + #for feedback choice + if { $choice_correct_answer_p == "f" && ![empty_string_p $choice_feedback_text] } { + # + set respcondition [$doc createElement respcondition] + $resprocessing appendChild $respcondition + # + set conditionvar [$doc createElement conditionvar] + $respcondition appendChild $conditionvar + # + set varequal [$doc createElement varequal] + $varequal setAttribute respident $item_name + $conditionvar appendChild $varequal + set text [$doc createCDATASection $choice_name] + $varequal appendChild $text + #feedback choice + set displayfeedback [$doc createElement displayfeedback] set linkrefid { } append linkrefid $choice_name feedbackChoice $displayfeedback setAttribute linkrefid $linkrefid - $respcondition appendChild $displayfeedback - } - } + $respcondition appendChild $displayfeedback + } + } } - incr i 2 - #for feedback choice - if { $choice_correct_answer_p == "f" && ![empty_string_p $choice_feedback_text] } { - # - set respcondition [$doc createElement respcondition] - $resprocessing appendChild $respcondition - # - set conditionvar [$doc createElement conditionvar] - $respcondition appendChild $conditionvar - # - set varequal [$doc createElement varequal] - $varequal setAttribute respident $item_name - $conditionvar appendChild $varequal - set text [$doc createCDATASection $choice_name] - $varequal appendChild $text - #feedback choice - set displayfeedback [$doc createElement displayfeedback] - set linkrefid { } - append linkrefid $choice_name feedbackChoice - $displayfeedback setAttribute linkrefid $linkrefid - $respcondition appendChild $displayfeedback - } - } - } + #feedback_wrong + if {![empty_string_p $item_feedback_wrong] } { + # + set itemfeedback [$doc createElement itemfeedback] + set ident { } + append ident $item_name displayWrong + $itemfeedback setAttribute ident $ident + $item appendChild $itemfeedback + # + as::export::new_element -value $item_feedback_wrong -father $itemfeedback -label flow_mat -root $doc -material_p t + } + + #feedback_right + if {![empty_string_p $item_feedback_right]} { + # + set itemfeedback [$doc createElement itemfeedback] + set ident { } + append ident $item_name displayRight + $itemfeedback setAttribute ident $ident + $item appendChild $itemfeedback + # + as::export::new_element -value $item_feedback_right -father $itemfeedback -label flow_mat -root $doc -material_p t + } + + #feedback_choice + db_foreach query_all_choices {} { + if {![empty_string_p $choice_feedback_text]} { + # + set itemfeedback [$doc createElement itemfeedback] + set ident { } + append ident $choice_name feedbackChoice + $itemfeedback setAttribute ident $ident + $item appendChild $itemfeedback + # + as::export::new_element -value $choice_feedback_text -father $itemfeedback -label flow_mat -root $doc -material_p t + } + } + } - #feedback_wrong - if {![empty_string_p $item_feedback_wrong] } { - # - set itemfeedback [$doc createElement itemfeedback] - set ident { } - append ident $item_name displayWrong - $itemfeedback setAttribute ident $ident - $item appendChild $itemfeedback - # - as::export::new_element -value $item_feedback_wrong -father $itemfeedback -label flow_mat -root $doc -material_p t - } - - #feedback_right - if {![empty_string_p $item_feedback_right]} { - # - set itemfeedback [$doc createElement itemfeedback] - set ident { } - append ident $item_name displayRight - $itemfeedback setAttribute ident $ident - $item appendChild $itemfeedback - # - as::export::new_element -value $item_feedback_right -father $itemfeedback -label flow_mat -root $doc -material_p t - } - - #feedback_choice - db_foreach query_all_choices {} { - if {![empty_string_p $choice_feedback_text]} { - # - set itemfeedback [$doc createElement itemfeedback] - set ident { } - append ident $choice_name feedbackChoice - $itemfeedback setAttribute ident $ident - $item appendChild $itemfeedback - # - as::export::new_element -value $choice_feedback_text -father $itemfeedback -label flow_mat -root $doc -material_p t - } - } - } - } - } - +} + #puts [$root asXML] set outfd "" @@ -757,15 +764,15 @@ set tmp_file "[ad_generate_random_string].zip" set out_file [file join ${out_path} ${tmp_file}] - + # get the archive command # TODO SECURITY DONT USE GLOBBING set cmd "zip -r -9 -X '$out_file' *" # create the archive with_catch errmsg { -# TODO SECURITY DONT USE THE SHELL - exec bash -c "cd '$in_path'; $cmd; cd -" + # TODO SECURITY DONT USE THE SHELL + exec bash -c "cd '$in_path'; $cmd; cd -" } { # some day we'll do something useful here error $errmsg Index: openacs-4/packages/assessment/www/asm-admin/export/index.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/assessment/www/asm-admin/export/index.xql,v diff -u -r1.6 -r1.6.2.1 --- openacs-4/packages/assessment/www/asm-admin/export/index.xql 24 Mar 2005 14:31:13 -0000 1.6 +++ openacs-4/packages/assessment/www/asm-admin/export/index.xql 6 May 2006 15:52:55 -0000 1.6.2.1 @@ -14,7 +14,7 @@ - SELECT i.as_item_id, i.title as item_title, i.name as item_name, i.description as item_description, i.subtext as item_subtext, i.field_code as item_field_code, i.required_p as item_required_p, i.data_type as item_data_type, i.max_time_to_complete as item_max_time_to_complete, i.feedback_right as item_feedback_right, i.feedback_wrong as item_feedback_wrong, i.points as item_points + SELECT i.as_item_id, i.title as item_title, i.name as item_name, i.description as item_description, i.subtext as item_subtext, i.field_code as item_field_code, i.required_p as item_required_p, i.data_type as item_data_type, i.max_time_to_complete as item_max_time_to_complete, i.feedback_right as item_feedback_right, i.feedback_wrong as item_feedback_wrong, i.points as item_points, i.field_name FROM as_itemsx i, as_item_section_map ism WHERE i.as_item_id = ism.as_item_id AND ism.section_id = :section_id ORDER BY ism.sort_order