- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables
Class ::xowiki::formfield::test_section
::xowiki::formfield::test_section create ... \
[ -form (default "en:edit-interaction.wf") ] \
[ -multiple (default "true") ]
Class Relations
::xotcl::Class create ::xowiki::formfield::test_section \ -superclass ::xowiki::formfield::TestItemFieldMethods (to be applied on instances)
convert_to_internal (scripted)
# # Build a complex form composed of the specified form pages names # contained in the value of this field. The form-fields have to # be renamed. This affects the input field names in the form and # the form constraints. # set intro_text [:get_named_sub_component_value text] set selection [:get_named_sub_component_value selection] # # Load the forms specified via "selection". # set package_id [${:object} package_id] set formObjs [::$package_id instantiate_forms -forms [join [split $selection \n] |] -default_lang en] # foreach formObj $formObjs { # set substvalues [$formObj property substvalues] # if {$substvalues ne ""} { # ns_log notice ".... [$formObj name] has substvalues $substvalues" # set d [:QM percent_substitute_in_form # -obj ${:object} # -form_obj $formObj # -position $position # $html] # $form_obj set_property form [dict get $d form] # $form_obj set_property form_constraints [dict get $d form_constraints] # $form_obj set_property disabled_form_constraints [dict get $d disabled_form_constraints] # } # } # # Build a form with the usual numbering containing all the # formObjs and remove all form tags. # set number 0 set numbers [lmap formObj $formObjs {incr number}] set option_dict {with_minutes t with_points f with_title f} foreach field {show_minutes show_points show_title} { set value [${:parent_field} get_named_sub_component_value -default "" $field] if {$value ne ""} { dict set option_dict $field $value } } set title_options [lmap kind {minutes points title} { if {![dict get $option_dict show_$kind]} { continue } set result "-with_$kind" }] set question_infos [:QM question_info -question_number_label "#xowf.subquestion#" {*}$title_options -numbers $numbers -no_position -obj ${:object} $formObjs] # ns_log notice "SELECTION question_info '$question_infos'" # # Build a single clean form based on the question infors, # containing all selected items. # set aggregatedForm [:QM aggregated_form -with_grading_box hidden $question_infos] set aggregatedFC [dict get $question_infos form_constraints] #ns_log notice "SELECTION aggregatedFC\n$aggregatedFC" # # The following regexps are dangerous (esp. on form # constraints). I think, we have already a better function for # this. # set names [regexp -inline -all {@([^@]+_)@} $aggregatedForm] foreach {. name} $names { regsub -all "@$name@" $aggregatedForm "@answer_$name@" aggregatedForm regsub -all ${name}: $aggregatedFC "answer_${name}:" aggregatedFC } ns_log notice "AGGREGATED FORM $aggregatedForm\nFC\n$aggregatedFC\n" # # Automatically compute the minutes and points of the composite # field and update the form field. # set total_minutes [:QM total_minutes $question_infos] set total_points [:QM total_points $question_infos] [${:parent_field} get_named_sub_component minutes] value $total_minutes [${:parent_field} get_named_sub_component points] value $total_points set form [:form_markup -interaction composite -intro_text $intro_text -body $aggregatedForm] ${:object} set_property -new 1 form $form ${:object} set_property -new 1 form_constraints $aggregatedFC set anon_instances true ;# TODO make me configurable ${:object} set_property -new 1 anon_instances $anon_instancesform (setter)
initialize (scripted)
if {${:__state} ne "after_specs"} { return } next set widget [test_item set richtextWidget] # We could exclude the "self" item (inclusion would lead to # infinite loops), but that is as well excluded, when no Composite # items are allowed. # # set item_id [${:object} item_id] # {selection {form_page,form=en:edit-interaction.wf,unless=_item_id=$item_id,multiple=true}} :create_components [subst { {text {$widget,height=150px,label=#xowf.exercise-text#,plugins=OacsFs}} {selection {form_page,form=en:edit-interaction.wf,unless=item_type=Composite|PoolQuestion,multiple=true,label=#xowf.question_selection#}} }] set :__initialized 1multiple (setter)
pretty_value (scripted)
return [${:object} property form ""]
- Methods: All Methods Documented Methods Hide Methods
- Source: Display Source Hide Source
- Variables: Show Variables Hide Variables