\n" \
+ "
\n" \
"
$intro_text
\n" \
"@answer@" \n \
"
\n" \
"\n"
+
set fc {}
lappend fc \
- "answer:text_fields,disabled_as_div=1,options=$options,shuffle_kind=$shuffle_kind,answer=$answer,label=" \
+ answer:[:dict_to_fc -type text_fields $fc_dict] \
@categories:off @cr_fields:hidden
- ns_log notice "text_entry_interaction $form\n$fc"
+ ns_log notice "short_text_interaction $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
@@ -513,27 +533,27 @@
}
#
- # ::xowiki::formfield::text_entry_field
+ # ::xowiki::formfield::short_text_field
#
- Class create text_entry_field -superclass TestItemField -parameter {
+ Class create short_text_field -superclass TestItemField -parameter {
}
- text_entry_field instproc initialize {} {
+ short_text_field instproc initialize {} {
if {${:__state} ne "after_specs"} return
#
# Create component structure.
#
set widget [test_item set richtextWidget]
#
- # Get auto_correct from the interaction (passing "auto_correct="
- # via form constrain would requires to extend the RepeatContainer,
+ # Get "auto_correct" from the interaction (passing "auto_correct="
+ # via form constrain would require to extend the RepeatContainer,
# otherwise the attribute is rejected).
#
set p [:info parent]
while {1} {
if {![$p istype ::xowiki::formfield::FormField]} break
- if {![$p istype ::xowiki::formfield::text_entry_interaction]} {
+ if {![$p istype ::xowiki::formfield::short_text_interaction]} {
set p [$p info parent]
continue
}
@@ -547,10 +567,21 @@
} else {
set autoCorrectSpec ""
}
+ set render_hints [join {
+ "{#xowiki.number# number}"
+ "{#xowiki.single_word# single_word}"
+ "{#xowiki.multiple_words# multiple_words}"
+ "{#xowiki.multiple_lines# multiple_lines}"
+ } " "]
+ set textEntryConfigSpec [subst {
+ {options {radio,horizontal=true,form_item_wrapper_CSSclass=form-inline,options=$render_hints,default=single_word,label=#xowf.answer#}}
+ {lines {number,form_item_wrapper_CSSclass=form-inline,default=1,min=1,label=#xowf.lines#}}
+ }]
+
#:msg autoCorrectSpec=$autoCorrectSpec
:create_components [subst {
- {text {$widget,height=100px,label=Teilaufgabe,plugins=OacsFs}}
- $autoCorrectSpec
+ {text {$widget,height=100px,label=#xowf.sub_question#,plugins=OacsFs}}
+ $textEntryConfigSpec $autoCorrectSpec
}]
set :__initialized 1
}
@@ -565,9 +596,11 @@
###########################################################
Class create mc_interaction2 -superclass TestItemField -parameter {
+ {multiple true}
}
mc_interaction2 instproc initialize {} {
+
if {${:__state} ne "after_specs"} return
#
# Create component structure.
@@ -576,7 +609,7 @@
#ns_log notice "[self] [:info class] auto_correct=${:auto_correct}"
:create_components [subst {
- {text {$widget,label=#xowf.exercise-text#,plugins=OacsFs}}
+ {text {$widget,height=100px,label=#xowf.exercise-text#,plugins=OacsFs}}
{answer {mc_field,repeat=1..10,label=}}
}]
set :__initialized 1
@@ -585,12 +618,11 @@
mc_interaction2 instproc convert_to_internal {} {
set intro_text [:get_named_sub_component_value text]
- set shuffle_kind [${:parent_field} get_named_sub_component_value shuffle]
set answerFields [:get_named_sub_component_value answer]
-
set count 0
set options {}
set correct {}
+
foreach {fieldName value} $answerFields {
# skip template entry
if {[lindex [split $fieldName .] end] eq 0} {
@@ -601,21 +633,32 @@
set text [dict get $value $fieldName.text]
# trim leading
since this causes a newline in the checkbox label
regexp {^\s*(
)(.*)$} $text . . text
+ regexp {^(.*)(
)\s*$} $text . text .
lappend options [list $text [incr count]]
lappend correct [dict get $value $fieldName.correct]
}
- set options [::xowiki::formfield::FormField fc_encode $options]
- set fc [list answer:checkbox,richtext=1,answer=$correct,shuffle_kind=$shuffle_kind,options=$options]
+ dict set fc_dict richtext 1
+ dict set fc_dict answer $correct
+ dict set fc_dict options $options
+ dict set fc_dict shuffle_kind [${:parent_field} get_named_sub_component_value shuffle]
+ dict set fc_dict show_max [${:parent_field} get_named_sub_component_value show_max]
+
+ set interaction_class [expr {${:multiple} ? "mc_interaction" : "sc_interaction"}]
append form \
"