Index: openacs-4/packages/xowf/tcl/test-item-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/test-item-procs.tcl,v diff -u -N -r1.2.2.1 -r1.2.2.2 --- openacs-4/packages/xowf/tcl/test-item-procs.tcl 7 Dec 2015 17:02:51 -0000 1.2.2.1 +++ openacs-4/packages/xowf/tcl/test-item-procs.tcl 6 Mar 2017 00:12:32 -0000 1.2.2.2 @@ -53,7 +53,7 @@ return "" } - set widget "richtext,editor=xinha,slim=true,inplace=$inplace,plugins=OacsFs,height=150px" + set widget "richtext,height=150px" if {$auto_correct} { return [subst { {feedback_correct {$widget,label=#xowf.feedback_correct#}} @@ -113,7 +113,7 @@ my create_components [subst { {minutes numeric,size=2,label=#xowf.Minutes#} {grading {select,options={exact exact} {partial partial},default=exact,label=#xowf.Grading-Schema#}} - {interaction {$interaction_class,$options,feedback_level=$feedback_level,inplace=$inplace,form_item_wrapper_CSSclass=hidden-field-set}} + {interaction {$interaction_class,$options,feedback_level=$feedback_level,inplace=$inplace}} [my feed_back_definition $auto_correct] }] my set __initialized 1 @@ -162,19 +162,16 @@ # # build choices # - set choice_definition "{mc_choice,feedback_level=$feedback_level,label=#xowf.alternative#,inplace=$inplace,multiple=[my multiple]}" - set input_field_names [my generate_fieldnames [my nr_choices]] - set choices "" + if {![my multiple]} { append choices "{correct radio,omit}\n" } - foreach n $input_field_names {append choices "{$n $choice_definition}\n"} # # create component structure # my create_components [subst { - {text {richtext,required,editor=xinha,height=150px,label=#xowf.exercise-text#,plugins=OacsFs,javascript=$javascript,inplace=$inplace}} - $choices + {text {richtext,required,height=150px,label=#xowf.exercise-text#}} + {mc {mc_choice,feedback_level=$feedback_level,label=#xowf.alternative#,inplace=$inplace,multiple=[my multiple],repeat=5..5}} }] my set __initialized 1 } @@ -191,18 +188,33 @@ append form "
$intro_text
\n" #my msg " input_field_names=[my set input_field_names]" + set mc [my get_named_sub_component_value mc] + #ns_log notice "MC <$mc>" if {![my multiple]} { set correct_field_name [my get_named_sub_component_value correct] } + + set input_field_names [lmap {name .} $mc {set name}] + #mc_exercise.mc.0 {mc_exercise.mc.0.text {} mc_exercise.mc.0.correct t} + #mc_exercise.mc.1 {mc_exercise.mc.1.text a mc_exercise.mc.1.correct t} + #ns_log notice input_field_names=$input_field_names - foreach input_field_name [my set input_field_names] { + # don't iterate over the template field + foreach {input_field_name data} [lrange $mc 2 end] { foreach f {text correct feedback_correct feedback_incorrect} { - set value($f) [my get_named_sub_component_value $input_field_name $f] + if {[dict exists $data $input_field_name.$f]} { + set value($f) [dict get $data $input_field_name.$f] + } else { + set value($f) "" + } + #ns_log notice "$input_field_name: value($f) = <$value($f)>" } # skip empty entries if {$value(text) eq ""} continue + regsub -all {[.:]} [${:object} name] "" form_name + set input_field_name $form_name-[lindex [split $input_field_name .] end] # # fill values into form # @@ -218,13 +230,14 @@ "\n" \ "$value(text)\n" } + #ns_log notice "$input_field_name [array get value] corr=$correct" #my msg "[array get value] corr=$correct" # # build form constraints per input field # set if_fc [list] - if {$correct} {lappend if_fc "answer=$input_field_name"} else {lappend if_fc "answer="} + if {[string is true -strict $correct]} {lappend if_fc "answer=$input_field_name"} else {lappend if_fc "answer="} if {$value(feedback_correct) ne ""} { lappend if_fc "feedback_answer_correct=[::xowiki::formfield::FormField fc_encode $value(feedback_correct)]" } @@ -240,6 +253,8 @@ lappend fc "radio:text,answer=$correct_field_value" } append form "\n" + #ns_log notice FORM=$form + #ns_log notice FC=$fc [my object] set_property -new 1 form $form [my object] set_property -new 1 form_constraints $fc set anon_instances true ;# TODO make me configurable @@ -265,7 +280,7 @@ if {1} { test_item instvar {xinha(javascript) javascript} - set text_config [subst {editor=xinha,height=100px,label=Text,plugins=OacsFs,inplace=[my inplace],javascript=$javascript}] + set text_config [subst {height=100px,label=Text}] } else { set text_config [subst {editor=wym,height=100px,label=Text}] } Index: openacs-4/packages/xowf/tcl/xowf-form-field-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/xowf-form-field-procs.tcl,v diff -u -N -r1.2.2.3 -r1.2.2.4 --- openacs-4/packages/xowf/tcl/xowf-form-field-procs.tcl 5 Jul 2016 16:36:44 -0000 1.2.2.3 +++ openacs-4/packages/xowf/tcl/xowf-form-field-procs.tcl 6 Mar 2017 00:12:32 -0000 1.2.2.4 @@ -240,20 +240,14 @@ mc_exercise instproc initialize {} { my log "[self class] deprecated, you should switch to test-item procs" if {[my set __state] ne "after_specs"} return - set javascript [::xowiki::formfield::FormField fc_encode { - xinha_config.toolbar = [ - ['popupeditor', 'bold','italic','createlink','insertimage','separator'], - ['killword','removeformat','htmlmode'] - ]; - }] my instvar feedback inplace my create_components [subst { - {text {richtext,required,editor=xinha,height=150px,label=#xowf.exercise-text#,plugins=OacsFs,javascript=$javascript,inplace=$inplace}} - {alt-1 {mc_alternative,feedback=$feedback,label=#xowf.alternative#,inplace=$inplace}} - {alt-2 {mc_alternative,feedback=$feedback,label=#xowf.alternative#,inplace=$inplace}} - {alt-3 {mc_alternative,feedback=$feedback,label=#xowf.alternative#,inplace=$inplace}} - {alt-4 {mc_alternative,feedback=$feedback,label=#xowf.alternative#,inplace=$inplace}} - {alt-5 {mc_alternative,feedback=$feedback,label=#xowf.alternative#,inplace=$inplace}} + {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#}} }] my set __initialized 1 } @@ -315,7 +309,7 @@ my log "[self class] deprecated, you should switch to test-item procs" if {[my set __state] ne "after_specs"} return - if {1} { + if {0} { set javascript [::xowiki::formfield::FormField fc_encode { xinha_config.toolbar = [ ['popupeditor', 'bold','italic','createlink','insertimage','separator'], Index: openacs-4/packages/xowf/tcl/xowf-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/xowf-procs.tcl,v diff -u -N -r1.3.2.10 -r1.3.2.11 --- openacs-4/packages/xowf/tcl/xowf-procs.tcl 25 Feb 2017 17:14:32 -0000 1.3.2.10 +++ openacs-4/packages/xowf/tcl/xowf-procs.tcl 6 Mar 2017 00:12:32 -0000 1.3.2.11 @@ -954,11 +954,21 @@ set helpText [$f help_text] if {$helpText ne ""} { - set divNode [$dom_doc createElement div] - $divNode setAttribute class [$f form_widget_CSSclass] - $divNode appendChild [$dom_doc createTextNode $helpText] - [$n parentNode] insertBefore $divNode [$n nextSibling] - util_user_message -message "field [$f name], value [$f value]: $helpText" + #set divNode [$dom_doc createElement div] + #$divNode setAttribute class [$f form_widget_CSSclass] + #$divNode appendChild [$dom_doc createTextNode $helpText] + #[$n parentNode] insertBefore $divNode [$n nextSibling] + + #set spanNode [$dom_doc createElement span] + #$spanNode setAttribute class "glyphicon glyphicon-ok [$f form_widget_CSSclass]" + #[$n parentNode] insertBefore $spanNode [$n nextSibling] + + set parentNode [$n parentNode] + set oldClass [$parentNode getAttribute class ""] + $parentNode setAttribute class "selection [$f form_widget_CSSclass]" + $parentNode setAttribute title $helpText + + #util_user_message -message "field [$f name], value [$f value]: $helpText" } } } @@ -1023,13 +1033,13 @@ switch -- $method { view_user_input { #my msg "calling edit with disable_input_fields=1" - return [my edit -disable_input_fields 1] + return [my www-edit -disable_input_fields 1] #return [$package_id call [self] edit [list -disable_input_fields 1]] } view_user_input_with_feedback { my set __feedback_mode 1 #my msg "calling edit with disable_input_fields=1" - return [my edit -disable_input_fields 1] + return [my www-edit -disable_input_fields 1] #return [$package_id call [self] edit [list -disable_input_fields 1]] } default { @@ -1343,9 +1353,9 @@ my activate $ctx allocate # - # After allocate, the payload might contain "name" and - # "parent_id". Using the payload dict has the advantage that it - # does not touch the instance variables. + # After allocate, the payload might contain "name", "parent_id" + # or "m". Using the payload dict has the advantage that it does + # not touch the instance variables. # set payload [${ctx}::allocate payload] set m ""