--- loncom/homework/bridgetask.pm 2006/05/12 01:18:50 1.147
+++ loncom/homework/bridgetask.pm 2006/05/12 04:32:58 1.148
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.147 2006/05/12 01:18:50 albertel Exp $
+# $Id: bridgetask.pm,v 1.148 2006/05/12 04:32:58 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -496,8 +496,12 @@ DONESCREEN
if ($status eq 'NEEDS_CHECKIN') {
if(&proctor_check_auth($slot_name,$slot,'Task')
&& defined($Apache::inputtags::slot_name)) {
- my $result=&add_to_queue('gradingqueue',
- [$Apache::inputtags::slot_name]);
+ my $result=
+ &add_to_queue('gradingqueue',
+ {'type' => 'task',
+ 'time' => time,
+ 'slot' =>
+ $Apache::inputtags::slot_name});
&Apache::lonxml::debug("add_to_queue said $result");
}
}
@@ -871,9 +875,18 @@ DONEBUTTON
}
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
&Apache::structuretags::finalize_storage();
- if ($award eq 'SUBMITTED'
- && defined($Apache::inputtags::slot_name)) {
- &add_to_queue('gradingqueue',[$Apache::inputtags::slot_name]);
+ if ($award eq 'SUBMITTED') {
+ my $useslots = &Apache::lonnet::EXT("resource.0.useslots");
+ if ($useslots =~ /^\s*no\s*$/i) {
+ &add_to_queue('gradingqueue',
+ {'type' => 'task',
+ 'time' => time});
+ } elsif (defined($Apache::inputtags::slot_name)) {
+ &add_to_queue('gradingqueue',
+ {'type' => 'task',
+ 'time' => time,
+ 'slot' => $Apache::inputtags::slot_name});
+ }
}
} elsif ($Apache::lonhomework::results{'INTERNAL_store'}) {
&Apache::structuretags::finalize_storage();
@@ -1012,7 +1025,7 @@ sub move_between_queues {
} else {
$cur_data = ['none'];
}
- my $result=&add_to_queue($dest_queue,[$cur_data->[0]]);
+ my $result=&add_to_queue($dest_queue,$cur_data);
if ($result ne 'ok') {
return $result;
}
@@ -1111,17 +1124,17 @@ sub check_queue_for_key {
if (defined($results{"$todo\0locked"})) {
return 'locked';
}
- my $slot;
- if (ref($results{$todo}) eq 'ARRAY') {
- $slot = $results{$todo}[0];
- } elsif (ref($results{$todo}) eq 'HASH') {
- $slot = $results{$todo}{'slot'};
- }
- if (defined($slot)) {
+ if (my $slot=&slotted_access($results{$todo})) {
my %slot_data=&Apache::lonnet::get_slot($slot);
if ($slot_data{'endtime'} > time) {
return 'in_progress';
}
+ } else {
+ my ($symb) = &decode_queue_key($todo);
+ my $due_date = &Apache::lonhomework::due_date('0',$symb);
+ if ($due_date > time) {
+ return 'in_progress';
+ }
}
return 'enqueued';
}
@@ -1181,8 +1194,15 @@ sub show_queue {
&Apache::lonlocal::locallocaltime($queue{$key})."";
} elsif ($key!~/(timestamp|locked)$/) {
$result.="
";
- my $slot=$queue{$key}->[0];
- my %slot_data=&Apache::lonnet::get_slot($slot);
+ my ($end_time,$slot_text);
+ if (my $slot=&slotted_access($queue{$key})) {
+ my %slot_data=&Apache::lonnet::get_slot($slot);
+ $end_time = $slot_data{'endtime'};
+ $slot_text = &mt('Slot: [_1]',$slot);
+ } else {
+ $end_time = &Apache::lonhomework::due_date('0',$symb);
+ $slot_text = '';
+ }
if ($with_selects) {
my $ekey=&Apache::lonnet::escape($key);
my ($action,$description,$status)=('select',&mt('Select'));
@@ -1200,7 +1220,7 @@ sub show_queue {
$seclist.='';
}
- if (time > $slot_data{'endtime'}) {
+ if ($end_time ne '' && time > $end_time) {
$result.=(<
";
}
}
@@ -1253,13 +1273,19 @@ sub get_queue_counts {
} elsif ($key!~/(timestamp|locked)$/) {
my ($symb,$uname,$udom) = &decode_queue_key($key);
$entries++;
- my $slot=$queue{$key}->[0];
- if (!exists($slot_cache{$slot})) {
- my %slot_data=&Apache::lonnet::get_slot($slot);
- $slot_cache{$slot} = \%slot_data;
- }
- if (time > $slot_cache{$slot}{'endtime'}) {
- $ready_to_grade++;
+ if (my $slot=&slotted_access($queue{$key})) {
+ if (!exists($slot_cache{$slot})) {
+ my %slot_data=&Apache::lonnet::get_slot($slot);
+ $slot_cache{$slot} = \%slot_data;
+ }
+ if (time > $slot_cache{$slot}{'endtime'}) {
+ $ready_to_grade++;
+ }
+ } else {
+ my $due_date = &Apache::lonhomework::due_date('0',$symb);
+ if ($due_date ne '' && time > $due_date) {
+ $ready_to_grade++;
+ }
}
}
}
@@ -1293,6 +1319,22 @@ sub queue_key_locked {
return undef;
}
+sub slotted_access {
+ my ($queue_entry) = @_;
+ if (ref($queue_entry) eq 'ARRAY') {
+ if (defined($queue_entry->[0])) {
+ return $queue_entry->[0];
+ }
+ return undef;
+ } elsif (ref($queue_entry) eq 'HASH') {
+ if (defined($queue_entry->{'slot'})) {
+ return $queue_entry->{'slot'};
+ }
+ return undef;
+ }
+ return undef;
+}
+
sub pick_from_queue_data {
my ($queue,$check_section,$queuedata,$cdom,$cnum)=@_;
my @possible; # will hold queue entries that are valid to be selected
@@ -1307,17 +1349,28 @@ sub pick_from_queue_data {
next;
}
}
- my $slot=$queuedata->{$key}[0];
- my %slot_data=&Apache::lonnet::get_slot($slot);
- if ($slot_data{'endtime'} > time) {
+ my $end_time;
+ if (my $slot=&slotted_access($queuedata->{$key})) {
+ my %slot_data=&Apache::lonnet::get_slot($slot);
+ if ($slot_data{'endtime'} < time) {
+ $end_time = $slot_data{'endtime'};
+ }
+ } else {
+ my $due_date = &Apache::lonhomework::due_date('0',$symb);
+ if ($due_date > time) {
+ $end_time = $due_date;
+ }
+ }
+ if ($end_time ne '') {
&Apache::lonxml::debug("not time");
next;
}
+
if (exists($queuedata->{"$key\0locked"})) {
&Apache::lonxml::debug("someone already has um.");
next;
}
- push(@possible,[$key,$slot_data{'endtime'}]);
+ push(@possible,[$key,$end_time]);
}
if (@possible) {
# sort entries in order by slot end time