- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xowiki::formfield::mc_interaction2
::xowiki::formfield::mc_interaction2 create ... \
[ -multiple (default "true") ] \
[ -nr (default "25") ]
Class Relations
::xotcl::Class create ::xowiki::formfield::mc_interaction2 \ -superclass ::xowiki::formfield::TestItemFieldMethods (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 { #ns_log notice ...fieldName=$fieldName->$value #set af answer[incr count] set text [dict get $value $fieldName.text] # Trim leading <p> and whitespace. Trimming leading <p> is # necessary since this causes a newline in the checkbox label regsub -all {^(\s|<p>)+} $text "" text regsub -all {(\s|</p>)+$} $text "" text # skip empty entries 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 #ns_log notice "mc_interaction2 $form\n$fc" ${:object} set_property -new 1 form $form ${:object} set_property -new 1 form_constraints $fc set anon_instances true ;# TODO make me configurable ${: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 # # Create component structure. # set widget [test_item set richtextWidget] #ns_log notice "[self] [:info class] auto_correct=${:auto_correct}" :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)
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables