Index: openacs-4/packages/xowiki/xowiki.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/xowiki.info,v diff -u -N -r1.180.2.55 -r1.180.2.56 --- openacs-4/packages/xowiki/xowiki.info 28 Jan 2021 02:25:10 -0000 1.180.2.55 +++ openacs-4/packages/xowiki/xowiki.info 4 Feb 2021 13:18:51 -0000 1.180.2.56 @@ -10,7 +10,7 @@ t xowiki - + Gustaf Neumann A xotcl-based enterprise wiki system with multiple object types 2017-08-06 @@ -55,7 +55,7 @@ BSD-Style 2 - + @@ -120,7 +120,7 @@ - + Index: openacs-4/packages/xowiki/catalog/xowiki.de_DE.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/catalog/xowiki.de_DE.ISO-8859-1.xml,v diff -u -N -r1.47.2.16 -r1.47.2.17 --- openacs-4/packages/xowiki/catalog/xowiki.de_DE.ISO-8859-1.xml 18 Jan 2021 13:59:42 -0000 1.47.2.16 +++ openacs-4/packages/xowiki/catalog/xowiki.de_DE.ISO-8859-1.xml 4 Feb 2021 13:18:51 -0000 1.47.2.17 @@ -88,6 +88,7 @@ Formular ausf�llen [weiteres Element hinzuf�gen] [Datei anf�gen] + [weitere Bedingung hinzuf�gen] [Weitere Datei anf�gen] [x] OK @@ -99,6 +100,8 @@ Wiki Form Wiki Forms Verfasser/in + Alle angegebenen + Bedingungen m�ssen f�r eine korrekte Antwort wahr sein. URL des Bildes (Sie k�nnen die URL des Bildes, die im Webbrowser angezeigt wird, hier einf�gen) Name des -zip- oder .tar.gz-Files ausw�hlen Archiv importieren @@ -113,6 +116,7 @@ Stunde Stunden Breite und H�he werden in Pixel berechnet ( die Proportionen k�nnen verloren gehen ). + Kleinschreibung Importieren User-IDs erstellen Falls dieses K�stchen aktiviert ist, werden beim Import gegebenenfalls neue User-IDs erstellt. Index: openacs-4/packages/xowiki/catalog/xowiki.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/catalog/xowiki.en_US.ISO-8859-1.xml,v diff -u -N -r1.71.2.21 -r1.71.2.22 --- openacs-4/packages/xowiki/catalog/xowiki.en_US.ISO-8859-1.xml 18 Jan 2021 13:59:42 -0000 1.71.2.21 +++ openacs-4/packages/xowiki/catalog/xowiki.en_US.ISO-8859-1.xml 4 Feb 2021 13:18:51 -0000 1.71.2.22 @@ -92,6 +92,7 @@ Fill out [add another] [add file] + [add condition] [add another file] [x] OK @@ -107,6 +108,8 @@ the answer is correct, specified as a predicate followed by arguments (Tcl words). The predefined predicates are "eq", "gt", "ge", "lt", "le", "btwn", "in", "contains", "match", "answer_words" + All specified + conditions must be true for a correct answer. HTTP Url of the Image (you might drag an image displayed by a web-browser here) Select the Name of a .zip or .tar.gz File Import Archive @@ -121,6 +124,7 @@ Height hour hours + Ignore case The width and height are calculated in pixels (proportions might get lost). Import Create user_ids Index: openacs-4/packages/xowiki/tcl/form-field-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/form-field-procs.tcl,v diff -u -N -r1.284.2.143 -r1.284.2.144 --- openacs-4/packages/xowiki/tcl/form-field-procs.tcl 1 Feb 2021 10:41:29 -0000 1.284.2.143 +++ openacs-4/packages/xowiki/tcl/form-field-procs.tcl 4 Feb 2021 13:18:51 -0000 1.284.2.144 @@ -147,6 +147,22 @@ # application classes FormField instproc initialize {} {next} + + FormField instproc CSSclass_list_add {attrName value} { + # + # Convenience function to add a CSS class to the existing values + # in "attrName". The function is named somewhat similar to the + # JavaScript function "classList.add" + # + if {$value ne ""} { + if {[info exists :$attrName]} { + lappend :$attrName $value + } else { + set :$attrName $value + } + } + } + FormField instproc same_value {v1 v2} { if {$v1 eq $v2} {return 1} return 0 @@ -588,7 +604,7 @@ set CSSclass form-label } ::html::div -class $CSSclass { - ::html::label -for ${:id} { + ::html::label -class [lindex [split ${:name} .] end] -for ${:id} { ::html::t ${:label} } if {${:required} && ${:mode} eq "edit"} { @@ -705,9 +721,38 @@ set words [lrange ${:correct_when} 1 end] set modifier "" } - return [list words $words value $value modifier $modifier] + return [list op [lindex ${:correct_when} 0] words $words value $value modifier $modifier] } + FormField instproc answer_check=AND {} { + set results "" + # + # The AND clause iterates over the list elements and reduces the + # composite AND into multiple simple clauses and overwrites (! + # danger) these in the instance variable "correct_when", but + # resets these at the end. + # + set composite_correct_when ${:correct_when} + ns_log notice "${:name} ... answercheck ${:correct_when}" + foreach clause [lrange ${:correct_when} 1 end] { + set :correct_when $clause + ns_log notice "${:name} ... AND '$clause' for '${:value}' -> [:answer_is_correct]" + lappend results [:answer_is_correct] + } + set :correct_when $composite_correct_when + ns_log notice "${:name} $composite_correct_when => $results" + if {0 in $results} { + # + # When one element is undecided, all is undecided. + # + return 0 + } + # + # If one element is wrong, all is wrong + # + return [expr {-1 ni $results}] + } + FormField instproc answer_check=eq {} { set d [:process_correct_when_modifier] dict with d { @@ -771,6 +816,13 @@ } return 0 } + FormField instproc answer_check=contains-not {} { + # + # Correct, when answer does not contain any of the provided + # words. Just a negation of "contains". + # + return [expr {[:answer_check=contains] ? 0 : 1}] + } FormField instproc answer_check=answer_words {} { # # Correct, when the answer is equal to the provided (sequence of) @@ -801,6 +853,7 @@ #:log "CORRECT? ${:name} ([:info class]): value=${:value}, answer=[expr {[info exists :answer]?${:answer}:{NONE}}]" if {[info exists :correct_when]} { set op [lindex ${:correct_when} 0] + #:log "CORRECT? ${:name} with op=$op '${:correct_when}'" if {[:procsearch answer_check=$op] ne ""} { set r [:answer_check=$op] if {$r == 0} { @@ -915,28 +968,45 @@ # rendering. Otherwise, the plain :value is used. # set :value [ns_quotehtml ${:value}] - if {[lindex ${:correct_when} 0] eq "contains"} { - # - # Mark matches in the div element. - # - set d [:process_correct_when_modifier] - set nocase [expr {[dict get $d modifier] eq "nocase" ? "-nocase" : ""}] - set annotated_value ${:value} - foreach word [dict get $d words] { + set op [lindex ${:correct_when} 0] + if {$op in {contains contains-not}} { + set and_clause "AND ${:correct_when}" + set op AND + } + set dicts {} + if {$op eq "AND"} { + set composite_correct_when ${:correct_when} + foreach clause [lrange ${:correct_when} 1 end] { + set :correct_when $clause + lappend dicts [:process_correct_when_modifier] + } + set :correct_when $composite_correct_when + } + ns_log notice dics=$dicts + set annotated_value ${:value} + foreach d $dicts { + if {[dict get $d op] in {contains contains-not}} { + set CSSclass [dict get $d op] # - # We need here probably more escapes, or we should be more - # restrictive on allowed content in the "contains" clause. + # Mark matches in the div element. # - set word [string map {* \\*} $word] - regsub -all {*}$nocase -- [ns_quotehtml $word] \ - $annotated_value \ - {&} \ - annotated_value + set nocase [expr {[dict get $d modifier] eq "nocase" ? "-nocase" : ""}] + foreach word [dict get $d words] { + # + # We need here probably more escapes, or we should be more + # restrictive on allowed content in the "contains" clause. + # + set word [string map {* \\*} $word] + regsub -all {*}$nocase -- [ns_quotehtml $word] \ + $annotated_value \ + "&" \ + annotated_value + } } - if {$annotated_value ne ${:value}} { - set :value_with_markup $annotated_value - } } + if {$annotated_value ne ${:value}} { + set :value_with_markup $annotated_value + } } } #:log "==== ${:name} setting feedback $feedback" @@ -1544,6 +1614,7 @@ # # Render content within in a fieldset, but with labels etc. # + :CSSclass_list_add CSSclass [namespace tail [:info class]] html::fieldset [:get_attributes id {CSSclass class}] { foreach c ${:components} { $c render } } @@ -2307,6 +2378,41 @@ ########################################################### # + # ::xowiki::formfield::comp_correct_when + # + ########################################################### + Class create comp_correct_when -superclass CompoundField + + # + # The operator {between btwn} is not needed, since one use more + # precisely and for inclusive/exclusive between operations. + # + comp_correct_when set operators { + {= eq} + {< lt} + {<= le} + {> gt} + {>= ge} + {contains contains} + {"contains not" contains-not} + {"one of" in} + } + comp_correct_when instproc initialize {} { + if {${:__state} ne "after_specs"} return + :create_components [subst { + {operator {select,options=[[self class] set operators],default=eq,form_item_wrapper_CSSclass=form-inline,label=}} + {text text,form_item_wrapper_CSSclass=form-inline,size=50,label=} + {nocase boolean_checkbox,horizontal=true,default=f,form_item_wrapper_CSSclass=form-inline,label=#xowiki.ignore_case#} + }] + next + set :__initialized 1 + if {${:help_text} eq ""} { + set :help_text "#xowiki.formfield-comp_correct_when-help_text#" + } + } + + ########################################################### + # # ::xowiki::formfield::color # ###########################################################