Index: openacs-4/packages/xowf/lib/inclass-exam.wf =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/lib/inclass-exam.wf,v diff -u -r1.1.2.29 -r1.1.2.30 --- openacs-4/packages/xowf/lib/inclass-exam.wf 28 Apr 2020 22:37:42 -0000 1.1.2.29 +++ openacs-4/packages/xowf/lib/inclass-exam.wf 28 Apr 2020 22:58:04 -0000 1.1.2.30 @@ -156,7 +156,7 @@ set text "

$title

" set menu "" set proctoring [$obj property proctoring 0] - set synchronized [$obj property synchronized 0] + set synchronized [$obj property synchronized 0] append text [subst {

[expr {$synchronized ? "" : "Non-"}]Synchronized Exam @@ -509,7 +509,7 @@ foreach f [::xowiki::formfield::FormField info instances -closure] { #ns_log notice "FF could DESTROY $f [$f name]" if {[string match *_ [$f name]]} { - #ns_log notice "FF DESTROY $f [$f name]" + #ns_log notice "FF DESTROY $f [$f name]" $f destroy } } @@ -616,28 +616,11 @@ -achieved_points $achieved_points \ $i] if {$autograde} { - # achieved_points achievedPoints 4.0 achieveablePoints 4 totalPoints 4 - if {[dict exists $achieved_points totalPoints] && [dict get $achieved_points totalPoints] > 0} { - set percentage [format %.2f [expr { - [dict get $achieved_points achievedPoints]*100/ - [dict get $achieved_points totalPoints] - }]] - set grade 1 - set gradePos 0 - foreach boundary $percentage_to_grade { - #ns_log notice "compare $percentage < $boundary" - if {$percentage < $boundary} { - set grade [expr {5-$gradePos}] - #ns_log notice "setting grade to $grade" - break - } - incr gradePos - } - dict incr grade_count $grade - } + dict incr grade_count [xowf::test_item::answer_manager grade \ + -achieved_points $achieved_points \ + -percentage_boundaries $percentage_to_grade] } - set heading "$userName · $fullName · $pretty_date" append HTML [subst {

@@ -666,26 +649,9 @@ set HTML "

#xowf.online-exam-protocol#

\n$HTML" if {$autograde} { - set gradingTable {
} - append gradingTable \ - "" \ - "\n" - set nrGrades 0 - foreach v [dict values $grade_count] { incr nrGrades $v} - foreach k [lsort [dict keys $grade_count]] { - set count [dict get $grade_count $k] - set countPercentage [format %.2f [expr {$count*100.0/$nrGrades}]] - append gradingTable \ - \ - [subst {}] \ - [subst {
#xowf.Grade##
$k$count
$countPercentage%
\n - } - append gradingTable "
\n" - append HTML

$gradingTable

+ append HTML

[xowf::test_item::answer_manager grading_table $grade_count]

} - + set return_url [$package_id query_parameter local_return_url:localurl [:pretty_link]] append HTML "

#xowiki.back#

\n" } 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.57 -r1.7.2.58 --- openacs-4/packages/xowf/tcl/test-item-procs.tcl 28 Apr 2020 22:29:41 -0000 1.7.2.57 +++ openacs-4/packages/xowf/tcl/test-item-procs.tcl 28 Apr 2020 22:58:04 -0000 1.7.2.58 @@ -1142,6 +1142,8 @@ # - marked_results # - answers_panel # - results_table + # - grading_table + # - grade # - participants_table # - revisions_up_to # @@ -1592,7 +1594,61 @@ } } + :public method grading_table {grade_count_dict} { + # + # Produce HTML markup based on a dict with grades as keys and + # counts as values. + # + set gradingTable {
} + append gradingTable \ + "" \ + "\n" + set nrGrades 0 + foreach v [dict values $grade_count_dict] { incr nrGrades $v} + foreach k [lsort [dict keys $grade_count_dict]] { + set count [dict get $grade_count_dict $k] + set countPercentage [format %.2f [expr {$count *100.0 / $nrGrades}]] + append gradingTable \ + \ + [subst {}] \ + [subst {
#xowf.Grade##
$k$count
$countPercentage%
\n + } + append gradingTable "
\n" + return $gradingTable + } + :public method grade {-achieved_points -percentage_boundaries} { + # + # Return a numeric grade based on achieved_points dict and + # percentage_mapping. On invalid data, return 0. + # + # achieved_points: {achievedPoints 4.0 achieveablePoints 4 totalPoints 4} + # percentage_mapping: {50.0 60.0 70.0 80.0} + # + if {[dict exists $achieved_points totalPoints] && [dict get $achieved_points totalPoints] > 0} { + set percentage [format %.2f [expr { + [dict get $achieved_points achievedPoints]*100/ + [dict get $achieved_points totalPoints] + }]] + set grade 1 + set gradePos 0 + foreach boundary $percentage_boundaries { + #ns_log notice "compare $percentage < $boundary" + if {$percentage < $boundary} { + set grade [expr {5-$gradePos}] + #ns_log notice "setting grade to $grade" + break + } + incr gradePos + } + } else { + set grade 0 + } + return $grade + } + :public method results_table { -package_id:integer -items:object,required