%3 ::xowiki::formfield::TestItemField ::xowiki::formfield::TestItemField QM attachments_widget comp_correct_when_from_value correct_when_spec correct_when_widget form_markup text_attachments twocol_layout ::xowiki::formfield::FormGeneratorField ::xowiki::formfield::FormGeneratorField pretty_value render_input ::xowiki::formfield::TestItemField->::xowiki::formfield::FormGeneratorField ::xowiki::formfield::CompoundField ::xowiki::formfield::CompoundField ::xowiki::formfield::FormGeneratorField->::xowiki::formfield::CompoundField ::xowiki::formfield::text_interaction ::xowiki::formfield::text_interaction convert_to_internal initialize ::xowiki::formfield::text_interaction->::xowiki::formfield::TestItemField

Class ::xowiki::formfield::text_interaction

::xowiki::formfield::text_interaction[i] create ...

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xowiki::formfield::TestItemField[i]
::xotcl::Class create ::xowiki::formfield::text_interaction \
     -superclass ::xowiki::formfield::TestItemField

Methods (to be applied on instances)

  • convert_to_internal (scripted)

    next
    
    set intro_text [:get_named_sub_component_value text]
    append intro_text [:text_attachments]
    
    set fc_dict {
      _name answer
      _type textarea
      disabled_as_div 1
      label #xowf.answer#
      autosave true
    }
    dict set fc_dict rows [:get_named_sub_component_value lines]
    dict set fc_dict cols [:get_named_sub_component_value columns]
    
    if {${:auto_correct}} {
      dict set fc_dict correct_when  [:comp_correct_when_from_value  [:get_named_sub_component_value correct_when]]
    }
    
    set form [:form_markup -interaction text -intro_text $intro_text -body @answer@]
    lappend fc  @categories:off @cr_fields:hidden  [:dict_to_spec $fc_dict]
    
    #ns_log notice "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
    ${: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 false
  • initialize (scripted)

    if {${:__state} ne "after_specs"} return
    
    #
    # Create component structure.
    #
    set widget [test_item set richtextWidget]
    
    :create_components  [subst {
      {text  {$widget,label=#xowf.exercise-text#,plugins=OacsFs}}
      {lines {number,form_item_wrapper_CSSclass=form-inline,min=1,default=10,label=#xowf.answer_lines#}}
      {columns {number,form_item_wrapper_CSSclass=form-inline,min=1,max=80,default=60,label=#xowf.answer_columns#}}
      {attachments {[:attachments_widget ${:nr_attachments}]}}
      [:correct_when_spec]
    }]
    set :__initialized 1