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.28 -r1.1.2.29 --- openacs-4/packages/xowf/lib/inclass-exam.wf 28 Apr 2020 19:47:20 -0000 1.1.2.28 +++ openacs-4/packages/xowf/lib/inclass-exam.wf 28 Apr 2020 22:37:42 -0000 1.1.2.29 @@ -448,6 +448,7 @@ set combined_form_info [::xowf::test_item::question_manager combined_question_form [self]] set autograde [dict get $combined_form_info autograde] set totalPoints [::xowf::test_item::question_manager total_minutes $combined_form_info] + set percentage_to_grade {50.0 60.0 70.0 80.0} ;# WI set ctx [::xowf::Context require [self]] set wf [xowf::test_item::answer_manager get_answer_wf [self]] @@ -505,6 +506,15 @@ # instance is in state "done". We set the __feedback_mode to # get the auto-correction included. # + 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]" + $f destroy + } + } + $wf form_field_flush_cache + set achieved_points {} xo::cc eval_as_user -user_id [$i creation_user] { $i set __feedback_mode 2 @@ -525,7 +535,7 @@ set signatureString "
online-exam-actual_signature: $sha256
\n" set submissionSignature [$i property signature ""] if {$submissionSignature ne ""} { - append signatureString "
#xowf.online-exam-submission_signature#: $submissionSignature
\n" + append signatureString "
#xowf.online-exam-submission_signature#: $submissionSignature
\n" } } else { set signatureString "" @@ -605,6 +615,29 @@ -view $view \ -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 + } + } + + set heading "$userName · $fullName · $pretty_date" append HTML [subst {
@@ -631,6 +664,28 @@ set HTML "

#xowf.online-exam-review-protocol# - $heading

\n$HTML" } else { 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

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

#xowiki.back#

\n" } @@ -722,7 +777,7 @@ set id ${:item_id} set proctoring_dir [acs_root_dir]/proctoring/$id/$user_id set png_path $proctoring_dir/$type-$ts.$ext - #ns_log notice "image: $png_path" + #ns_log notice "image: $png_path ... [file exists $$png_path]" ns_returnfile 200 [ns_guesstype $ts.$ext] $png_path ad_script_abort }