Class ::xowiki::formfield::mc_interaction2
::xowiki::formfield::mc_interaction2
create ... \
[ -multiple (default "true") ] \
[ -nr (default "25") ]
Class Relations
- class: ::xotcl::Class
![[i]](/resources/acs-subsite/ZoomIn16.gif)
- superclass: ::xowiki::formfield::TestItemField
![[i]](/resources/acs-subsite/ZoomIn16.gif)
::xotcl::Class create ::xowiki::formfield::mc_interaction2 \
-superclass ::xowiki::formfield::TestItemField
Methods (to be applied on instances)
convert_to_internal (scripted)
set intro_text [:get_named_sub_component_value text]
set answerFields [:get_named_sub_component_value -from_repeat answer]
set count 0
set options {}
set correct {}
set solution {}
foreach {fieldName value} $answerFields {
set text [dict get $value $fieldName.text]
regsub -all {^(\s|<p>)+} $text "" text
regsub -all {(\s|</p>)+$} $text "" text
if {$text eq ""} {
continue
}
lappend options [list $text [incr count]]
lappend correct [dict get $value $fieldName.correct]
lappend solution [dict get $value $fieldName.solution]
}
dict set fc_dict _name answer
dict set fc_dict _type [expr {${:multiple} ? "checkbox" : "radio"}]
dict set fc_dict richtext 1
dict set fc_dict answer $correct
dict set fc_dict options $options
dict set fc_dict descriptions $solution
dict set fc_dict shuffle_kind [${:parent_field} get_named_sub_component_value shuffle]
dict set fc_dict grading [${:parent_field} get_named_sub_component_value grading]
dict set fc_dict show_max [${:parent_field} get_named_sub_component_value show_max]
set interaction [expr {${:multiple} ? "mc" : "sc"}]
set form [:form_markup -interaction $interaction -intro_text $intro_text -body @answer@]
set fc {}
lappend fc [:dict_to_spec $fc_dict] @categories:off @cr_fields:hidden
${:object} set_property -new 1 form $form
${:object} set_property -new 1 form_constraints $fc
set anon_instances true ;
${:object} set_property -new 1 anon_instances $anon_instances
${:object} set_property -new 1 auto_correct ${:auto_correct}
${:object} set_property -new 1 has_solution falseinitialize (scripted)
if {${:__state} ne "after_specs"} return
set widget [test_item set richtextWidget]
:create_components [subst {
{text {$widget,height=100px,label=#xowf.exercise-text#,plugins=OacsFs}}
{answer {mc_field,repeat=1..${:nr},label=}}
}]
set :__initialized 1multiple (setter)
nr (setter)