[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm
raeburn
raeburn@source.lon-capa.org
Mon, 01 Nov 2010 16:32:32 -0000
raeburn Mon Nov 1 16:32:32 2010 EDT
Modified files:
/loncom/homework bridgetask.pm
Log:
- Bug 5497. Time limits can be used with bridge tasks.
However, limit parameter should be resource-specific (rather than folder, or course-wide),
as accesstime is automatically deleted when BT is graded, to allow the user the possibility
of a later attempt (if user failed this BT), when the next slot becomes available.
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.255 loncom/homework/bridgetask.pm:1.256
--- loncom/homework/bridgetask.pm:1.255 Tue Oct 12 16:07:43 2010
+++ loncom/homework/bridgetask.pm Mon Nov 1 16:32:32 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.255 2010/10/12 16:07:43 raeburn Exp $
+# $Id: bridgetask.pm,v 1.256 2010/11/01 16:32:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,6 +37,7 @@
use Apache::lonlocal;
use Apache::lonxml;
use Apache::slotrequest();
+use Apache::structuretags();
use Time::HiRes qw( gettimeofday tv_interval );
use LONCAPA;
@@ -380,6 +381,7 @@
( $status eq 'BANNED') ||
( $status eq 'UNAVAILABLE') ||
( $status eq 'NOT_IN_A_SLOT') ||
+ ( $status eq 'NOT_YET_VIEWED') ||
( $status eq 'NEEDS_CHECKIN') ||
( $status eq 'WAITING_FOR_GRADE') ||
( $status eq 'INVALID_ACCESS') ||
@@ -627,6 +629,14 @@
&Apache::structuretags::page_start($target,$token,$tagstack,
$parstack,$parser,$safeeval,
$name,&style($target));
+
+ }
+ if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
+ $target eq 'tex') {
+ if ($env{'form.markaccess'}) {
+ my @interval=&Apache::lonnet::EXT("resource.0.interval");
+ &Apache::lonnet::set_first_access($interval[1]);
+ }
}
if ($target eq 'web' && $env{'request.state'} ne 'construct') {
@@ -669,8 +679,8 @@
my ($version,$previous)=&get_version();
($status,$accessmsg,my $slot_name,$slot) =
&Apache::lonhomework::check_slot_access('0','Task');
- if ($status eq 'CAN_ANSWER' && $version eq '') {
- # CAN_ANSWER mode, and no current version, unproctored access
+ if ((($status eq 'CAN_ANSWER') || ($status eq 'NOT_YET_VIEWED')) && ($version eq '')) {
+ # CAN_ANSWER or NOT_YET_VIEWED mode, and no current version, unproctored access
# thus self-checkedin
my $check = &check_in('Task',undef,undef,$slot_name);
if ($check =~ /^error: /) {
@@ -714,7 +724,10 @@
$msg.='<h1>'.&mt('Your submission is in the grading queue.').'</h1>';
} elsif ($env{'form.donescreen'}) {
$result .= &done_screen($version);
- } elsif ($status ne 'NOT_YET_VIEWED') {
+ } elsif ($status eq 'NOT_YET_VIEWED') {
+ my $symb=&Apache::lonnet::symbread();
+ $msg.=&Apache::structuretags::firstaccess_msg($accessmsg,$symb);
+ } else {
$msg.='<h1>'.&mt('Not open to be viewed').'</h1>';
}
if ($status eq 'CLOSED' || $status eq 'INVALID_ACCESS') {
@@ -1339,10 +1352,10 @@
$Apache::lonhomework::results{"resource.$version.0.solved"};
}
&minimize_storage();
- my ($canstore,$domain,$name);
+ my ($canstore,$domain,$name,$symb,$courseid);
+ ($symb,$courseid,$domain,$name) = &Apache::lonnet::whichuser();
+
if ($env{'form.gradingkey'}) {
- (my $symb,my $courseid,$domain,$name) =
- &Apache::lonnet::whichuser();
my $todo=&unescape($env{'form.gradingkey'});
my ($keysymb,$uname,$udom)=&decode_queue_key($todo);
if ($symb eq $keysymb) {
@@ -1353,6 +1366,16 @@
}
if ($canstore) {
&Apache::structuretags::finalize_storage();
+ my @interval = &Apache::lonnet::EXT("resource.0.interval");
+ if ($interval[0] =~ /^\d+$/ && $interval[1] eq 'resource') {
+ my $key=$courseid."\0".$symb;
+ my %times=&Apache::lonnet::get('firstaccesstimes',
+ [$key],$domain,$name);
+ if ($times{$key}) {
+ my $delresult.=&Apache::lonnet::del('firstaccesstimes',
+ [$key],$domain,$name);
+ }
+ }
# data stored, now handle queue
if ($review) {
if ($env{'form.queue'} eq 'reviewqueue') {