Log Message:
-----------
Add active javascript timer to gateway quiz module.
Tags:
----
rel-2-1-a1
Modified Files:
--------------
webwork2/lib/WeBWorK/ContentGenerator:
GatewayQuiz.pm
Revision Data
-------------
Index: GatewayQuiz.pm
===================================================================
RCS file: /webwork/cvs/system/webwork2/lib/WeBWorK/ContentGenerator/GatewayQuiz.pm,v
retrieving revision 1.9.4.7
retrieving revision 1.9.4.8
diff -Llib/WeBWorK/ContentGenerator/GatewayQuiz.pm -Llib/WeBWorK/ContentGenerator/GatewayQuiz.pm -u -r1.9.4.7 -r1.9.4.8
--- lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
+++ lib/WeBWorK/ContentGenerator/GatewayQuiz.pm
@@ -1246,21 +1246,33 @@
" right or wrong."), "\n\n";
print CGI::end_div();
} else {
+
+# FIXME: This assumes that there IS a time limit!
+# FIXME: We need to drop this out gracefully if there isn't!
+# set up a timer
+ my $timeNow = time();
+ my $timeLeft = $set->due_date() - $timeNow; # this is in seconds
print CGI::start_div({class=>"gwTiming"});
- print CGI::p(CGI::strong("This version started ",
- scalar(localtime($set->open_date())),
- CGI::br(),"\nTime limit : ",
- ($set->version_time_limit()/60),
- " minutes (must be completed by: ",
- scalar(localtime($set->due_date())), ")", CGI::br(),
- "The current time is ", scalar(localtime()))), "\n\n";
- print CGI::end_div();
- if ( $set->due_date() - $set->version_time_limit() < 1 ) {
- print CGI::start_div({class=>"gwWarning"});
- print CGI::p(CGI::strong("You have less than 1 minute to ",
- "complete this version.\n"));
- print CGI::end_div();
+ print CGI::startform({-name=>"gwtimer", -method=>"POST",
+ -action=>$r->uri}), "\n";
+ print CGI::hidden({-name=>"gwpagetimeleft", -value=>$timeLeft}), "\n";
+ print CGI::strong("Time Remaining:");
+ print CGI::textfield({-name=>'gwtime', -default=>0, -size=>8}),
+ CGI::strong("min:sec"), CGI::br(), "\n";
+ print CGI::endform();
+ if ( $timeLeft < 1 ) {
+ print CGI::span({-class=>"resultsWithError"},
+ CGI::b("You have less than 1 minute to ",
+ "complete this test.\n"));
}
+ print CGI::end_div();
+# print CGI::strong("Time Remaining:
+# scalar(localtime($set->open_date())),
+# CGI::br(),"\nTime limit : ",
+# ($set->version_time_limit()/60),
+# " minutes (must be completed by: ",
+# scalar(localtime($set->due_date())), ")", CGI::br(),
+# "The current time is ", scalar(localtime())), "\n\n";
}
@@ -1279,7 +1291,7 @@
my $jumpLinks = "Jump to problem: ";
for my $i ( 0 .. $#pg_results ) {
my $pn = $i+1;
- $jumpLinks .= "/ " . CGI::a({-href=>".", -onclick=>"jumpTo($i);return false;"}, "$pn") . " /";
+ $jumpLinks .= "/ " . CGI::a({-href=>".", -onclick=>"jumpTo($pn);return false;"}, "$pn") . " /";
}
print CGI::p($jumpLinks,"\n");
@@ -1366,7 +1378,8 @@
}
print CGI::start_div({class=>"gwProblem"});
- print CGI::a({-name=>"#$i"},"");
+ my $i1 = $i+1;
+ print CGI::a({-name=>"#$i1"},"");
print CGI::strong("Problem $problemNumber."), "\n", $recordMessage;
print CGI::p($pg->{body_text}),
CGI::p($pg->{result}->{msg} ? CGI::b("Note: ") : "",
|