Class ::xowiki::formfield::TestItemField (public)
::xotcl::Class ::xowiki::formfield::TestItemField \ [ -feedback_level feedback_level ] [ -auto_correct auto_correct ]
Defined in /var/www/openacs.org/packages/xowf/tcl/test-item-procs.tcl
Abstract class for defining common attributes for all Test Item fields.
- Switches:
- -feedback_level (optional)
- "full", "single", or "none"
- -auto_correct (optional)
- boolean to let user add auto correction fields
- Testcases:
- No testcase defined.
Source code: namespace eval ::xowiki::formfield {} ::nsf::object::alloc ::xotcl::Class ::xowiki::formfield::TestItemField {set :__default_metaclass ::xotcl::Class set :__default_superclass ::xotcl::Object set :abstract 1} ::xowiki::formfield::TestItemField instproc comp_correct_when_from_value value { 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 } ::xowiki::formfield::TestItemField instproc form_markup {-interaction -intro_text -body} { 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"] } ::xowiki::formfield::TestItemField instproc twocol_layout {} { return [expr {[${:parent_field} get_named_sub_component_value -default 0 twocol] ? "col-sm-6" : "col-xs-12"}] } ::xowiki::formfield::TestItemField instproc correct_when_spec {{-nr 10}} { if {${:auto_correct}} { return [list [list correct_when [:correct_when_widget -nr $nr]]] } return "" } ::xowiki::formfield::TestItemField instproc text_attachments {} { 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 } ::xowiki::formfield::TestItemField instproc correct_when_widget {{-nr 10}} { 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] } ::xowiki::formfield::TestItemField instproc attachments_widget nr_attachments { 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] } ::xowiki::formfield::TestItemField instforward QM ::xowf::test_item::question_manager ::xowiki::formfield::TestItemField instparametercmd with_correction_notes ::xowiki::formfield::TestItemField instparametercmd nr_attachments ::xowiki::formfield::TestItemField instparametercmd feedback_level ::xowiki::formfield::TestItemField instparametercmd auto_correct ::nsf::relation::set ::xowiki::formfield::TestItemField superclass ::xowiki::formfield::FormGeneratorField ::nx::slotObj -container slot ::xowiki::formfield::TestItemField ::xowiki::formfield::TestItemField::slot eval {set :__parameter { {feedback_level full} {with_correction_notes:boolean true} {auto_correct:boolean false} {nr_attachments 15} }} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::formfield::TestItemField::slot::feedback_level {set :accessor public set :configurable true set :convert false set :default full set :defaultmethods {} set :disposition alias set :domain ::xowiki::formfield::TestItemField set :incremental 0 set :manager ::xowiki::formfield::TestItemField::slot::feedback_level set :methodname feedback_level set :multiplicity 1..1 set :name feedback_level set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::formfield::TestItemField::slot::auto_correct {set :accessor public set :configurable true set :convert false set :default false set :defaultmethods {} set :disposition alias set :domain ::xowiki::formfield::TestItemField set :incremental 0 set :manager ::xowiki::formfield::TestItemField::slot::auto_correct set :methodname auto_correct set :multiplicity 1..1 set :name auto_correct set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none set :type boolean : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::formfield::TestItemField::slot::nr_attachments {set :accessor public set :configurable true set :convert false set :default 15 set :defaultmethods {} set :disposition alias set :domain ::xowiki::formfield::TestItemField set :incremental 0 set :manager ::xowiki::formfield::TestItemField::slot::nr_attachments set :methodname nr_attachments set :multiplicity 1..1 set :name nr_attachments set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xowiki::formfield::TestItemField::slot::with_correction_notes {set :accessor public set :configurable true set :convert false set :default true set :defaultmethods {} set :disposition alias set :domain ::xowiki::formfield::TestItemField set :incremental 0 set :manager ::xowiki::formfield::TestItemField::slot::with_correction_notes set :methodname with_correction_notes set :multiplicity 1..1 set :name with_correction_notes set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none set :type boolean : init}XQL Not present: Generic, PostgreSQL, Oracle