%3 ::xowiki::formfield::CompoundField ::xowiki::formfield::CompoundField add_component add_statistics check=compound convert_to_external convert_to_internal create_components exists_named_sub_component generate_fieldnames get_component get_compound_value get_named_sub_component get_named_sub_component_value has_instance_variable leaf_components make_correct named_sub_components object pretty_value render_input reset_on_validation_error same_value set_compound_value set_disabled set_is_repeat_template specs_unmodified validate value ::xowiki::formfield::FormField ::xowiki::formfield::FormField → fc_decode → fc_encode → get_from_name → get_single_spec → interprete_condition CSSclass_list_add add_statistics answer_check=AND answer_check=answer_words answer_check=btwn answer_check=contains answer_check=contains-not answer_check=eq answer_check=ge answer_check=gt answer_check=in answer_check=le answer_check=lt answer_check=match answer_is_correct asWidgetSpec behavior booleanAttributes config_from_spec convert_to_external convert_to_internal describe dict_to_fc dict_to_spec dict_value escape_message_keys field_value handle_transmit_always has_instance_variable init initialize interprete_single_spec is_disabled is_repeat_template_p leaf_components localize make_correct pretty_image pretty_value process_correct_when_modifier remove_omit render render_answer_statistics render_collapsed render_disabled_as_div render_error_msg render_form_widget render_help_text render_input render_item render_localizer render_modal render_result_statistics render_word_statistics repeat repeat_add_label resetBooleanAttributes reset_on_validation_error reset_parameter same_value set_disabled set_feedback set_is_repeat_template stats_record_count validate validation_check value_if_nothing_is_returned_from_form word_statistics ::xowiki::formfield::CompoundField->::xowiki::formfield::FormField ::xo::tdom::Object ::xo::tdom::Object ::xowiki::formfield::FormField->::xo::tdom::Object ::xowiki::formfield::mc_exercise ::xowiki::formfield::mc_exercise convert_to_internal initialize pretty_value render_input ::xowiki::formfield::mc_exercise->::xowiki::formfield::CompoundField

Class ::xowiki::formfield::mc_exercise

::xowiki::formfield::mc_exercise[i] create ... \
           [ -feedback (default "full") ] \
           [ -inplace (default "true") ]

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xowiki::formfield::CompoundField[i]
::xotcl::Class create ::xowiki::formfield::mc_exercise \
     -superclass ::xowiki::formfield::CompoundField

Methods (to be applied on instances)

  • convert_to_internal (scripted)

    #
    # Build a form from the components of the exercise on the fly.
    # Actually, this method computes the properties "form" and
    # "form_constraints" based on the components of this form field.
    #
    set form "<FORM>\n<table class='mchoice'>\n<tbody>"
    set fc "@categories:off @cr_fields:hidden\n"
    set intro_text [:get_named_sub_component_value text]
    append form "<tr><td class='text' colspan='2'>$intro_text</td></tr>\n"
    foreach input_field_name {alt-1 alt-2 alt-3 alt-4 alt-5} {
      foreach f {text correct feedback_correct feedback_incorrect} {
        set value($f) [:get_named_sub_component_value $input_field_name $f]
      }
      append form  "<tr><td class='selection'><input type='checkbox' id='$input_field_name' name='$input_field_name' /></td>\n"  "<td class='value'><label for='$input_field_name'>$value(text)</label></td></tr>\n"
      set alt_fc [list]
      if {$value(correct)} {lappend alt_fc "answer=on"} else {lappend alt_fc "answer="}
      if {$value(feedback_correct) ne ""} {
        lappend alt_fc "feedback_answer_correct=[::xowiki::formfield::FormField fc_encode $value(feedback_correct)]"
      }
      if {$value(feedback_incorrect) ne ""} {
        lappend alt_fc "feedback_answer_incorrect=[::xowiki::formfield::FormField fc_encode $value(feedback_incorrect)]"
      }
      if {[llength $alt_fc] > 0} {
        append fc [list $input_field_name:checkbox,[join $alt_fc ,]] \n
      }
      #:msg "$input_field_name .correct = $value(correct)"
    }
    append form "</tbody></table></FORM>\n"
    ${:object} set_property -new 1 form $form
    ${:object} set_property -new 1 form_constraints $fc
  • feedback (setter)

  • initialize (scripted)

    :log "[self class] deprecated, you should switch to test-item procs"
    if {${:__state} ne "after_specs"} return
    :create_components  [subst {
      {text  {richtext,required,height=150px,label=#xowf.exercise-text#}}
      {alt-1 {mc_alternative,feedback=${:feedback},label=#xowf.alternative#}}
      {alt-2 {mc_alternative,feedback=${:feedback},label=#xowf.alternative#}}
      {alt-3 {mc_alternative,feedback=${:feedback},label=#xowf.alternative#}}
      {alt-4 {mc_alternative,feedback=${:feedback},label=#xowf.alternative#}}
      {alt-5 {mc_alternative,feedback=${:feedback},label=#xowf.alternative#}}
    }]
    set :__initialized 1
  • inplace (setter)

  • pretty_value (scripted)

    return [${:object} property form ""]
  • render_input (scripted)

    ::xo::Page requireCSS /resources/xowf/myform.css
    next