xowf::test_item::Answer_manager method export_answer (public)
<instance of xowf::test_item::Answer_manager> export_answer \ [ -combined_form_info combined_form_info ] -html html \ -recutil recutil [ -submission submission ]
Defined in packages/xowf/tcl/test-item-procs.tcl
Export the provided question and answer in GNU rectuil format. ns_log notice "answers: [$submission serialize]"
- Switches:
- -combined_form_info (optional)
- -html (required)
- -recutil (required, object)
- -submission (optional, object)
- Testcases:
- No testcase defined.
Source code: if {[$submission exists __form_fields]} { set form_fields [$submission set __form_fields] } else { # # We do not have the newest version of xowiki, so locate the # objs the hard way based on the naming convention. # set form_field_objs [lmap f [::xowiki::formfield::FormField info instances -closure] { if {![string match *_ [$f name]]} {continue} set f }] foreach form_field_obj $form_field_objs { dict set form_fields [$form_field_obj name] $form_field_obj } ns_log notice "export_answers: old style form_fields: $form_fields" } set export_dict "" set user [$submission set creation_user] if {![info exists ::__running_ids]} { set ::__running_ids "" } if {![dict exists $::__running_ids $user]} { dict set ::__running_ids $user [incr ::__running_id] } set seeds [$submission property seeds] set instance_attributes [$submission set instance_attributes] set answer_attributes [lmap a $instance_attributes { if {![string match *_ $a]} {continue} set a }] #ns_log notice "export_answers: combined_form_info: $combined_form_info" #set title_infos [dict get $combined_form_info title_infos] # # Get the question dict, which is a mapping between question # names and form_obj_ids. # set question_dict [:FL name_to_question_obj_dict [dict get $combined_form_info question_objs]] # ns_log notice "export_answers: question_dict: $question_dict" set form_constraints [lsort -unique [dict get $combined_form_info form_constraints]] set fc_dict [:fc_to_dict $form_constraints] #ns_log notice "... form_constraints ([llength $form_constraints]) $form_constraints" #ns_log notice ".... dict $fc_dict" # # Every answer_attribute contains the answer to a test_item # (which potentially sub answers). # foreach a $answer_attributes { #ns_log notice "answers <[dict get $instance_attributes $a]>" foreach {alternative_id answer} [dict get $instance_attributes $a] { set alt_value [lindex [split $alternative_id .] 1] set form_obj [dict get $question_dict $a] #set ff [dict get $form_fields $a] #ns_log notice "answer $a: [dict get $instance_attributes $a] [$ff serialize]" #ns_log notice "answer $a: form_obj [$form_obj serialize]" set form_obj_ia [$form_obj instance_attributes] #ns_log notice "answer $a: [dict get $instance_attributes $a] [dict keys [dict get $form_obj_ia question]]" #ns_log notice "INTERACTION [dict get [dict get $form_obj_ia question] question.interaction]" set intro [dict get [dict get [dict get $form_obj_ia question] question.interaction] question.interaction.text] #ns_log notice "TEXT $intro" #set question_title [question_manager question_property $form_obj title] #set question_minutes [question_manager question_property $form_obj minutes] #ns_log notice "answer $a: [dict get $instance_attributes $a] [dict keys [dict get $form_obj_ia question]]" #dict set export_dict name $a dict set export_dict name $alternative_id dict set export_dict user_id $user dict set export_dict running_id [dict get $::__running_ids $user] dict set export_dict question_obj $form_obj dict set export_dict question_title [$form_obj title] dict set export_dict question_intro [ns_striphtml $intro] dict set export_dict question_minutes [dict get $fc_dict $a test_item_minutes] dict set export_dict question_points [dict get $fc_dict $a test_item_points] dict set export_dict question_text [ns_striphtml [:get_label_from_options $alt_value [dict get $fc_dict $a options]]] #dict set export_dict options [dict get $fc_dict $a options] dict set export_dict answer $answer ns_log notice "answer $a: DICT $export_dict" #ns_log notice "avail $a: [dict get $fc_dict $a]" $recutil ins $export_dict } }XQL Not present: Generic, PostgreSQL, Oracle