Index: openacs-4/packages/xowf/lib/inclass-exam-answer.wf =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/lib/inclass-exam-answer.wf,v diff -u -r1.1.2.15 -r1.1.2.16 --- openacs-4/packages/xowf/lib/inclass-exam-answer.wf 26 Apr 2020 20:14:20 -0000 1.1.2.15 +++ openacs-4/packages/xowf/lib/inclass-exam-answer.wf 28 Apr 2020 16:39:03 -0000 1.1.2.16 @@ -283,8 +283,7 @@ :plain_template $obj if {[$parent_obj state] eq "published" && [$obj state] ne "done"} { - set synchronized [$parent_obj property synchronized] - if {$synchronized eq ""} {set synchronized 0} + set synchronized [$parent_obj property synchronized 0] set target_time [::xowf::test_item::question_manager exam_target_time \ -manager $parent_obj \ -base_time [expr { $synchronized 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.54 -r1.7.2.55 --- openacs-4/packages/xowf/tcl/test-item-procs.tcl 26 Apr 2020 20:14:20 -0000 1.7.2.54 +++ openacs-4/packages/xowf/tcl/test-item-procs.tcl 28 Apr 2020 16:39:03 -0000 1.7.2.55 @@ -1603,6 +1603,7 @@ #set form_info [:combined_question_form -with_numbers $wf] set form_info [::xowf::test_item::question_manager combined_question_form $wf] set answer_form_field_objs [:answer_form_field_objs -wf $wf $form_info] + set autograde [dict get $form_info autograde] set form_field_objs {} lappend form_field_objs \ @@ -1913,12 +1914,22 @@ # # Accepted formats for target_time, determined by JavaScript # ISO 8601, e.g. YYYY-MM-DDTHH:mm:ss.sss" - + # + # Set current time based on host time instead of new + # Date().getTime() to avoid surprises, in cases, the time at the + # client browser is set incorrectly. + # + set nowMs [clock milliseconds] + set nowIsoTime [clock format [expr {$nowMs/1000}] -format "%Y-%m-%dT%H:%M:%S"].[format %.3d [expr {$nowMs % 1000}]] + template::add_body_script -script [subst { var countdown_target_date = new Date('$target_time').getTime(); var countdown_days, countdown_hours, countdown_minutes, countdown_seconds; var countdown = document.getElementById('$id'); + // adjust target time by the difference between the host and client time + countdown_target_date = countdown_target_date - (new Date('$nowIsoTime').getTime() - new Date().getTime()); + setInterval(function () { var current_date = new Date().getTime(); var seconds_left = (countdown_target_date - current_date) / 1000; @@ -2263,6 +2274,7 @@ } set target_time [clock format [expr {$base_clock + $total_minutes*60}] \ -format %Y-%m-%dT%H:%M:%S] + ns_log notice "exam_target_time $base_time base clock $base_clock + total_minutes $total_minutes = ${target_time}.$secfrac" return ${target_time}.$secfrac }