Index: openacs-4/packages/xowf/catalog/xowf.de_DE.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/catalog/xowf.de_DE.ISO-8859-1.xml,v diff -u -r1.2.2.50 -r1.2.2.51 --- openacs-4/packages/xowf/catalog/xowf.de_DE.ISO-8859-1.xml 25 Apr 2021 08:47:05 -0000 1.2.2.50 +++ openacs-4/packages/xowf/catalog/xowf.de_DE.ISO-8859-1.xml 25 Apr 2021 20:46:09 -0000 1.2.2.51 @@ -217,5 +217,6 @@ Zusammenfassung Fragen�bersicht Detail�bersicht - aus + aus + Aufbau Index: openacs-4/packages/xowf/catalog/xowf.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/catalog/xowf.en_US.ISO-8859-1.xml,v diff -u -r1.2.2.50 -r1.2.2.51 --- openacs-4/packages/xowf/catalog/xowf.en_US.ISO-8859-1.xml 25 Apr 2021 08:47:05 -0000 1.2.2.50 +++ openacs-4/packages/xowf/catalog/xowf.en_US.ISO-8859-1.xml 25 Apr 2021 20:46:09 -0000 1.2.2.51 @@ -236,5 +236,6 @@ Summary Questions Detailed summary - of + of + Structure 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 -r1.7.2.125 -r1.7.2.126 --- openacs-4/packages/xowf/tcl/test-item-procs.tcl 25 Apr 2021 08:51:32 -0000 1.7.2.125 +++ openacs-4/packages/xowf/tcl/test-item-procs.tcl 25 Apr 2021 20:46:09 -0000 1.7.2.126 @@ -2567,18 +2567,16 @@ // console.log("cookie $cookie_name " + cookieValue); if (cookieValue > 1) { alert('Already open!'); - document.cookie = "$cookie_name=1"; window.open("about:blank", "_self").close(); - } else { - document.cookie = "$cookie_name=" + cookieValue; } + document.cookie = "$cookie_name=" + cookieValue; // console.log("START finished -> " + document.cookie); window.onunload = function () { var cookieLine = document.cookie.split('; ').find(row => row.startsWith('$cookie_name=')); var cookieValue = (cookieLine === undefined) ? 0 : parseInt(cookieLine.split('=')\[1\]) - 1; document.cookie = "$cookie_name=" + cookieValue; - //console.log("UNLOAD finished -> " + document.cookie); + // console.log("UNLOAD finished -> " + document.cookie); }; }] } @@ -3413,7 +3411,47 @@ $form_objs] } - :public method -debug describe_form {{-asHTML:switch} form_obj} { + :method pretty_nr_alternatives {question_infos} { + set result {} + foreach question_info $question_infos { + if {$question_info ne ""} { + # + # The handled metrics are currently hardcoded here. So, we can + # rely on having the returned value in the message keys. The + # list order is important, since it determines also the ordering + # in the message. + # + if {[dict exists $question_info show_max] + && [dict get $question_info show_max] ne "" + } { + foreach key {choice_options sub_questions} { + if {[dict exists $question_info $key] + && [dict get $question_info show_max] ne [dict get $question_info $key] + } { + set new "[dict get $question_info show_max] #xowf.out_of# [dict get $question_info $key]" + dict set question_info question_structure $new + } + } + } + lappend result $question_info + } + } + return $result + } + + :method pretty_ncorrect {m} { + return " (#xowf.Correct# $m) " + } + :method pretty_shuffle {m} { + if {$m ne ""} { + return #xowf.shuffle_$m# + } + } + :method dict_value {dict key {default ""}} { + expr {[dict exists $dict $key] ? [dict get $dict $key] : $default} + } + + :public method describe_form {{-asHTML:switch} form_obj} { # # Call for every form field of the form_obj the "describe" # method and return these infos in a form of a list. @@ -3426,8 +3464,9 @@ set question_infos [lmap form_field $form_fields { $form_field describe }] - #ns_log notice "describe_form [$form_obj name]: $question_infos" + #ns_log notice "describe_form [$form_obj name]: $question_infos" + set question_infos [:pretty_nr_alternatives $question_infos] if {!$asHTML} { return $question_infos } @@ -3441,25 +3480,16 @@ # list order is important, since it determines also the ordering # in the message. # - if {[dict exists $question_info show_max] - && [dict get $question_info show_max] ne "" - } { - foreach key {choice_options sub_questions} { - if {[dict exists $question_info $key] - && [dict get $question_info show_max] ne [dict get $question_info $key] - } { - set new "[dict get $question_info show_max] #xowf.out_of# [dict get $question_info $key]" - dict set question_info $key $new - } - } - } set msg "" - foreach metric { choice_options sub_questions nrcorrect Minutes Points shuffle } { + set hasStructure [dict exists $question_info question_structure] + set metrics [expr {$hasStructure ? "question_structure" : [list choice_options sub_questions]}] + lappend metrics nrcorrect Minutes Points shuffle + foreach metric $metrics { if {[dict exists $question_info $metric]} { set m [dict get $question_info $metric] switch $metric { - nrcorrect { append msg " (#xowf.Correct# $m) " } - shuffle { append msg "#xowf.Shuffle#: #xowf.shuffle_$m# " } + nrcorrect { append msg [:pretty_ncorrect $m] } + shuffle { append msg "#xowf.Shuffle#: [:pretty_shuffle $m]" } default { append msg "#xowf.$metric#: $m "} } } @@ -3489,16 +3519,39 @@
#xowf.question_summary#
-
+
+ + + + + + }] foreach form_obj $form_objs { - set chunk [:describe_form -asHTML $form_obj] + set chunk [lindex [:describe_form $form_obj] 0] + set structure "" + foreach att {question_structure choice_options sub_questions} { + if {[dict exists $chunk $att]} { + append structure [dict get $chunk $att] + break + } + } + if {[dict exists $chunk nrcorrect]} { + append structure " " [:pretty_ncorrect [dict get $chunk nrcorrect]] + } + set shuffle [:dict_value $chunk shuffle] + if {$shuffle ne ""} { + set shuffle + } append HTML [subst { - - - }] + + + + + + }] } append HTML "
#xowf.question_structure##xowf.Minutes##xowf.Points##xowf.Shuffle#
[ns_quotehtml [$form_obj title]][join $chunk { }]
$structure[:dict_value $chunk Minutes][:dict_value $chunk Points][:pretty_shuffle [:dict_value $chunk shuffle]][:dict_value $chunk grading]
\n" @@ -3744,6 +3797,7 @@ # to message keys to ease multi-language communication. # set qa [${:object} property question] + foreach {key name} { question.minutes Minutes question.points Points @@ -3755,6 +3809,7 @@ } } switch [:info class] { + ::xowiki::formfield::radio - ::xowiki::formfield::checkbox { # mc interaction #