Index: openacs-4/packages/xowf/lib/inclass-exam.wf =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/lib/Attic/inclass-exam.wf,v diff -u -N -r1.1.2.6 -r1.1.2.7 --- openacs-4/packages/xowf/lib/inclass-exam.wf 21 Mar 2020 19:59:09 -0000 1.1.2.6 +++ openacs-4/packages/xowf/lib/inclass-exam.wf 22 Mar 2020 11:18:21 -0000 1.1.2.7 @@ -351,11 +351,23 @@ : 0 }] set examTitle ${:title} set filter_id [[$wf package_id] query_parameter id:integer ""] + set revision_id [[$wf package_id] query_parameter rid:integer ""] + if {$revision_id ne ""} { + set r [::xowiki::FormPage get_instance_from_db -revision_id $revision_id] + if {[[lindex [$items children] 0] item_id] ne [$r item_id]} { + error "invalid revision id '$revision_id' provided" + } + $items destroy + set items [::xo::OrderedComposite new -destroy_on_cleanup] + $items add $r + } + foreach i [$items children] { $i set online-exam-userName [acs_user::get_element -user_id [$i creation_user] -element username] $i set online-exam-fullName [::xo::get_user_name [$i creation_user]] } + $items orderby online-exam-userName foreach i [$items children] { set userName [$i set online-exam-userName] @@ -402,17 +414,11 @@ set time [::xo::db::tcl_date [$i property _last_modified] tz_var] set pretty_date [clock format [clock scan $time] -format "%Y-%m-%d %T"] - set duration [xowf::test_item::answer_manager get_duration $revisions] - set IPs [xowf::test_item::answer_manager get_IPs $revisions] - set submissionState [expr {$state ne "done" ? "- #xowf.not_submitted#" : ""}] append HTML [subst {

$userName · $fullName · $pretty_date

- #xowf.nr_changes#: [llength $revisions]
- #xowf.duration#: [dict get $duration from] - [dict get $duration to] - ([dict get $duration duration]) $submissionState
- IP: $IPs + [xowf::test_item::answer_manager runtime_panel -revision_id $revision_id -filter_id $filter_id $i]
$signatureString $question_form 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.7.2.34 -r1.7.2.35 --- openacs-4/packages/xowf/tcl/test-item-procs.tcl 21 Mar 2020 19:59:09 -0000 1.7.2.34 +++ openacs-4/packages/xowf/tcl/test-item-procs.tcl 22 Mar 2020 11:18:21 -0000 1.7.2.35 @@ -1128,6 +1128,7 @@ # # - get_duration # - get_IPs + # - runtime_panel # # - marked_results # - answers_panel @@ -1279,7 +1280,7 @@ :public method get_duration {revision_sets} { # # Get the duration from a set of revisions and return a dict - # containing at least "from", "to" and "duration" + # containing "from", "fromClock","to", "toClock", and "duration" # set first [lindex $revision_sets 0] @@ -1314,6 +1315,68 @@ ######################################################################## + :method revisions_up_to {revision_sets revision_id} { + set result "" + set stop 0 + return [lmap s $revision_sets { + if {$stop} break + set stop [expr {[ns_set get $s revision_id] eq $revision_id}] + set s + }] + } + + ######################################################################## + + :public method runtime_panel { + {-revision_id ""} + {-filter_id ""} + answerObj:object + } { + # + # Return statistics for the provided object: + # - minimal statistics: when 'filter_id' is empty + # - statistics with clickable revisions: when 'filter_id' is non empty + # - per-revision statistics: when revision_id is provided + # + set revision_sets [$answerObj get_revision_sets] + + if {$filter_id ne ""} { + set baseUrl [ns_conn url] + set filtered_revision_sets [:revisions_up_to $revision_sets $revision_id] + set c 0 + foreach s $revision_sets { + set rid [ns_set get $s revision_id] + set revision_url $baseUrl?[::xo::update_query [ns_conn query] rid $rid] + if {$rid == [$answerObj revision_id]} { + set suffix "*" + set CSSclass "current" + } else { + set suffix "" + set CSSclass "othter" + } + lappend revision_list [subst {[incr c]$suffix}] + } + set revision_sets $filtered_revision_sets + set revisionDetails "#xowiki.revisions#: [join $revision_list {, }]" + } else { + set revisionDetails "#xowf.nr_changes#: [llength $revision_sets]" + } + set duration [xowf::test_item::answer_manager get_duration $revision_sets] + set IPs [xowf::test_item::answer_manager get_IPs $revision_sets] + set state [$answerObj state] + set submissionState [expr {$state ne "done" ? "- #xowf.not_submitted#" : ""}] + set HTML [subst { + $revisionDetails
+ #xowf.duration#: [dict get $duration from] - [dict get $duration to] + ([dict get $duration duration]) $submissionState
+ IP: $IPs + }] + + return $HTML + } + + ######################################################################## + :method participant_result { -obj:object answerObj:object