%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::pool_question_placeholder ::xowiki::formfield::pool_question_placeholder ::xowiki::formfield::pool_question_placeholder->::xowiki::formfield::TestItemField ::xowiki::formfield::short_text_field ::xowiki::formfield::short_text_field initialize ::xowiki::formfield::short_text_field->::xowiki::formfield::TestItemField ::xowiki::formfield::reorder_interaction ::xowiki::formfield::reorder_interaction convert_to_internal initialize ::xowiki::formfield::reorder_interaction->::xowiki::formfield::TestItemField ::xowiki::formfield::short_text_interaction ::xowiki::formfield::short_text_interaction convert_to_internal initialize ::xowiki::formfield::short_text_interaction->::xowiki::formfield::TestItemField ::xowiki::formfield::test_section ::xowiki::formfield::test_section convert_to_internal initialize pretty_value ::xowiki::formfield::test_section->::xowiki::formfield::TestItemField ::xowiki::formfield::test_item ::xowiki::formfield::test_item feedback_definition initialize ::xowiki::formfield::test_item->::xowiki::formfield::TestItemField ::xowiki::formfield::mc_interaction2 ::xowiki::formfield::mc_interaction2 convert_to_internal initialize ::xowiki::formfield::mc_interaction2->::xowiki::formfield::TestItemField ::xowiki::formfield::text_interaction ::xowiki::formfield::text_interaction convert_to_internal initialize ::xowiki::formfield::text_interaction->::xowiki::formfield::TestItemField ::xowiki::formfield::pool_question ::xowiki::formfield::pool_question → all_item_types_selected convert_to_internal initialize ::xowiki::formfield::pool_question->::xowiki::formfield::TestItemField ::xowiki::formfield::mc_interaction ::xowiki::formfield::mc_interaction convert_to_internal initialize set_compound_value ::xowiki::formfield::mc_interaction->::xowiki::formfield::TestItemField ::xowiki::formfield::mc_choice ::xowiki::formfield::mc_choice initialize ::xowiki::formfield::mc_choice->::xowiki::formfield::TestItemField ::xowiki::formfield::upload_interaction ::xowiki::formfield::upload_interaction convert_to_internal initialize ::xowiki::formfield::upload_interaction->::xowiki::formfield::TestItemField ::xowiki::formfield::mc_field ::xowiki::formfield::mc_field initialize ::xowiki::formfield::mc_field->::xowiki::formfield::TestItemField

Class ::xowiki::formfield::TestItemField

::xowiki::formfield::TestItemField[i] create ... \
           [ -auto_correct:boolean (default "false") ] \
           [ -feedback_level (default "full") ] \
           [ -nr_attachments (default "15") ] \
           [ -with_correction_notes:boolean (default "true") ]

Abstract class for defining common attributes for all Test Item fields.
Documented Parameters:
feedback_level
"full", "single", or "none"
auto_correct
boolean to let user add auto correction fields
Defined in packages/xowf/tcl/test-item-procs.tcl

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xowiki::formfield::FormGeneratorField[i]
  • subclass: ::xowiki::formfield::pool_question_placeholder[i], ::xowiki::formfield::short_text_field[i], ::xowiki::formfield::reorder_interaction[i], ::xowiki::formfield::short_text_interaction[i], ::xowiki::formfield::test_section[i], ::xowiki::formfield::test_item[i], ::xowiki::formfield::mc_interaction2[i], ::xowiki::formfield::text_interaction[i], ::xowiki::formfield::pool_question[i], ::xowiki::formfield::mc_interaction[i], ::xowiki::formfield::mc_choice[i], ::xowiki::formfield::upload_interaction[i], ::xowiki::formfield::mc_field[i]
::xotcl::Class create ::xowiki::formfield::TestItemField \
     -superclass ::xowiki::formfield::FormGeneratorField

Methods (to be applied on instances)

  • QM (forward)

  • attachments_widget (scripted)

    
    dict set attachments_dict repeat 0..${:nr_attachments}
    dict set attachments_dict repeat_add_label #xowiki.form-repeatable-add-file#
    dict set attachments_dict label #general-comments.Attachments#
    
    # {attachments {file,0..${:nr_attachments},label=#general-comments.Attachments#}}
    # {attachments {bootstrap_file_input,multiple=true,label=#general-comments.Attachments#}}
    # {attachments {file,multiple=true,label=#general-comments.Attachments#}}
    return [:dict_to_fc -type file $attachments_dict]
  • auto_correct (setter)

  • comp_correct_when_from_value (scripted)

    set correct_whens {}
    foreach {compound_key compound_entries} $value {
      if {![string match "*.0" $compound_key]} {
        # ns_log notice "key $compound_key, value $compound_entries"
        set d {}
        foreach {entry_key entry_value} $compound_entries {
          set tail [lindex [split $entry_key .] end]
          # ns_log notice "... entry_key $tail, entry_value $entry_value"
          dict set d $tail $entry_value
        }
        set text [string trim [dict get $d text]]
        if {$text ne ""} {
          set correct_when "[dict get $d operator] "
          append correct_when [expr {[dict get $d nocase] ? "-nocase " : ""}]
          append correct_when $text
          lappend correct_whens $correct_when
        } else {
          set correct_when ""
        }
      }
    }
    if {[llength $correct_whens] < 2} {
      set correct_when [lindex $correct_whens 0]
    } else {
      set correct_when "AND $correct_whens"
    }
    ns_log notice FINAL-correct_when([self])='$correct_when'
    return $correct_when
  • correct_when_spec (scripted)

    if {${:auto_correct}} {
      return [list [list correct_when [:correct_when_widget -nr $nr]]]
    }
    return ""
  • correct_when_widget (scripted)

    dict set dict repeat 1..10
    dict set dict repeat_add_label #xowiki.form-repeatable-add-condition#
    dict set dict help_text #xowiki.formfield-comp_correct_when-help_text#
    dict set dict label #xowf.correct_when#
    
    return [:dict_to_fc -type comp_correct_when $dict]
  • feedback_level (setter)

  • form_markup (scripted)

    set twocol [:twocol_layout]
    return [string cat  "<form>\n"  "<div class='${interaction}_interaction row row-$twocol'>\n"  "<div class='question_text first-column $twocol'>$intro_text</div>\n"  "<div class='second-column $twocol'>$body</div>\n"  "</div>\n"  "</form>\n"]
  • nr_attachments (setter)

  • text_attachments (scripted)

    set html ""
    if {[:exists_named_sub_component attachments]} {
      set attachments_ff [:get_named_sub_component attachments]
      set attachments_count [$attachments_ff count_values [$attachments_ff value]]
      set attachments_label [expr {$attachments_count > 1
                                   ? "#general-comments.Attachments# ($attachments_count)"
                                   : "#attachments.Attachment#"}]
    
      for {set i 1} {$i <= $attachments_count} {incr i} {
        set label [lindex [dict get [:get_named_sub_component_value -from_repeat attachments $i] name] 0]
        set encoded_label [ns_urlencode $label]
        append attachments_links  {<div class='attachment'>}  [subst -nocommands {[[file:question.interaction.attachments.$i|$label|-query filename=$encoded_label]]}]  </div>
      }
      if {$attachments_count > 0} {
        append html "<div class='question_attachments'>$attachments_label $attachments_links</div><br>"
      }
    }
    #ns_log notice text_attachments=>$attachments_html
    return $html
  • twocol_layout (scripted)

    return [expr {[${:parent_field} get_named_sub_component_value -default 0 twocol]
                  ? "col-sm-6" : "col-xs-12"}]
  • with_correction_notes (setter)