--- loncom/homework/bridgetask.pm 2005/05/20 18:07:29 1.27
+++ loncom/homework/bridgetask.pm 2005/09/21 21:54:20 1.52
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.27 2005/05/20 18:07:29 albertel Exp $
+# $Id: bridgetask.pm,v 1.52 2005/09/21 21:54:20 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -36,6 +36,7 @@ use Apache::File();
use Apache::lonmenu;
use Apache::lonlocal;
use Apache::lonxml;
+use Apache::slotrequest();
use Time::HiRes qw( gettimeofday tv_interval );
BEGIN {
@@ -76,6 +77,11 @@ sub proctor_check_auth {
$user.'@'.$domain;
$Apache::lonhomework::results{"resource.$version.checkedin.slot"}=
$slot_name;
+ foreach my $key (keys(%Apache::lonhomework::history)) {
+ if ($key=~/^resource\.0\./) {
+ $Apache::lonhomework::results{$key}='';
+ }
+ }
return 1;
}
}
@@ -84,42 +90,117 @@ sub proctor_check_auth {
}
sub get_version {
+ my ($version,$previous);
if ($env{'form.previousversion'} &&
+ $env{'form.previousversion'} ne 'current' &&
defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.status'})) {
- return $env{'form.previousversion'};
+ $version=$env{'form.previousversion'};
+ $previous=1;
+ } else {
+ $version=$Apache::lonhomework::history{'resource.version'};
+ $previous=0;
}
- return $Apache::lonhomework::history{'resource.version'};
+ if (wantarray) {
+ return ($version,$previous);
+ }
+ return $version;
}
sub add_previous_version_button {
my ($status)=@_;
my $result;
- if ($Apache::lonhomework::history{'resource.version'} eq '0') {
+ if ($Apache::lonhomework::history{'resource.version'} eq '') {
return '';
}
- my $version=&get_version();
- if ($version ne $Apache::lonhomework::history{'resource.version'}) {
+ if ($Apache::lonhomework::history{'resource.version'} < 2 &&
+ $status ne 'NEEDS_CHECKIN') {
return '';
}
-
- $result.=&mt(' Show a previously done version: [_1]','');
+ my $version=&get_version();
+ if ($env{'form.previousversion'} ne '' &&
+ $env{'form.previousversion'} eq $version) {
+ $result.="
".&mt("Showing previous version [_1]",$version).
+ "
\n";
+ }
+ my @to_show;
+ foreach my $test_version (1..$Apache::lonhomework::history{'resource.version'}) {
+ if (defined($Apache::lonhomework::history{'resource.'.$test_version.'.status'})) {
+ push(@to_show,$test_version);
+ }
+ }
+ my $list='\n\n";
+ $list.='';
+ $result.='";
return $result;
}
sub add_grading_button {
- my $result;
- $result.=' ';
$result.='';
+ if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
+ my ($entries,$ready,$locks)=&get_queue_counts('gradingqueue');
+ $result.='
'.&mt("Grading Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
+
+ $result.='
'.&mt("Review Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
+ $result.='
'."\n";
+ $result.=' '."\n";
+ }
return $result;
}
sub add_request_another_attempt_button {
+ my ($text)=@_;
+ if (!$text) { $text="Request another attempt"; }
+ my $result;
+ my $symb=&Apache::lonnet::symbread();
+ my ($slot_name,$slot)=&Apache::slotrequest::check_for_reservation($symb);
+ my $action='get_reservation';
+ if ($slot_name) {
+ $text="Change reservation.";
+ $action='change_reservation';
+ my $description=&Apache::slotrequest::get_description($slot_name,
+ $slot);
+ $result.=(< Will be next available: $description
+STUFF
+ }
+
+ if ($env{'request.enc'}) { $symb=&Apache::lonenc::encrypted($symb); }
+ $symb=&Apache::lonnet::escape($symb);
+ $result.='';
+ return $result;
+}
+
+sub preserve_grade_info {
my $result;
- $result.=' ';
+ # if we are viewing someone else preserve that info
+ if (defined $env{'form.grade_symb'}) {
+ foreach my $field ('symb','courseid','domain','username') {
+ $result .= ''."\n";
+ }
+ }
return $result;
}
@@ -143,11 +224,20 @@ sub start_Task {
my $uri=$env{'request.uri'};
if ($env{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
$body_tag_start.=$uri.'">'.&add_grading_button()."";
+ my $symb=&Apache::lonnet::symbread();
+ if (&Apache::lonnet::allowed('mgq',$env{'request.course.id'})) {
+ $body_tag_start.='';
+ }
}
}
if ($target eq 'web' || ($target eq 'grade' && !$env{'form.webgrade'}) || $target eq 'answer' ||
$target eq 'tex') {
- my $version=&get_version();
+ my ($version,$previous)=&get_version();
($status,$accessmsg,my $slot_name,$slot) =
&Apache::lonhomework::check_task_access('0');
push(@Apache::inputtags::status,$status);
@@ -157,13 +247,14 @@ sub start_Task {
&Apache::run::run($expression,$safeeval);
&Apache::lonxml::debug("Got $status");
$body_tag_start.=&add_previous_version_button($status);
- if (( $status eq 'CLOSED' ) ||
- ( $status eq 'BANNED') ||
- ( $status eq 'UNAVAILABLE') ||
- ( $status eq 'NOT_IN_A_SLOT') ||
- ( $status eq 'NEEDS_CHECKIN') ||
- ( $status eq 'WAITING_FOR_GRADE') ||
- ( $status eq 'INVALID_ACCESS')) {
+ if (!$previous && (
+ ( $status eq 'CLOSED' ) ||
+ ( $status eq 'BANNED') ||
+ ( $status eq 'UNAVAILABLE') ||
+ ( $status eq 'NOT_IN_A_SLOT') ||
+ ( $status eq 'NEEDS_CHECKIN') ||
+ ( $status eq 'WAITING_FOR_GRADE') ||
+ ( $status eq 'INVALID_ACCESS') )) {
my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
if ( $target eq "web" ) {
$result.= $head_tag_start.''.$body_tag_start;
@@ -172,6 +263,7 @@ sub start_Task {
$msg.='
'.&mt('Unable to determine if this resource is open due to network problems. Please try again later.').'
';
} elsif ($status eq 'NOT_IN_A_SLOT') {
$msg.='
'.&mt('You are not currently signed up to work at this time and/or place.').'
';
+ $msg.=&add_request_another_attempt_button("Sign up for time to work.");
} elsif ($status eq 'NEEDS_CHECKIN') {
$msg.='
'.&mt('You need the Proctor to validate you.').
'
'.&proctor_validation_screen($slot);
@@ -193,63 +285,96 @@ sub start_Task {
}
} elsif ($target eq 'grade' && !$env{'form.webgrade'}) {
if ($status eq 'NEEDS_CHECKIN') {
- if (&proctor_check_auth($slot_name,$slot)) {
- #FIXME immeadiatly add this to the grading queue
- # with slot->{'endtime'} for when grading can
- # begin on this resource
- # FIXME I think the above is done by default,
- # need to check that
- # failure doesn't do this.
- }
+ &proctor_check_auth($slot_name,$slot);
}
}
} elsif ($target eq 'web') {
my $name= &Apache::structuretags::get_resource_name($parstack,$safeeval);
$result.="$head_tag_start$name
- $body_tag_start \n $form_tag_start".
- '';
- # if we are viewing someone else preserve that info
- if (defined $env{'form.grade_symb'}) {
- foreach my $field ('symb','courseid','domain','username') {
- $result .= ''."\n";
- }
- }
- my $version=&get_version();
+ $body_tag_start \n";
+
+ my ($version,$previous)=&get_version();
if ($Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
$result.='
'.&mt('Did not pass').'
';
- $result.=&add_request_another_attempt_button();
+ if (!$previous) {
+ $result.=&add_request_another_attempt_button();
+ }
}
if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass') {
$result.='
'.&mt('Passed').'
';
}
+ $result.=$form_tag_start.
+ '';
+ $result.=&preserve_grade_info();
+
}
} elsif ( ($target eq 'grade' && $env{'form.webgrade'}) ||
$target eq 'webgrade') {
+ my $webgrade='yes';
if ($target eq 'webgrade') {
- $result.=$head_tag_start.$body_tag_start.$form_tag_start;
- $result.='';
- $result.=&show_queue();
+ $result.=$head_tag_start.$body_tag_start;
+ #$result.=' Review'.&show_queue('reviewqueue');
+ #$result.=' Grade'.&show_queue('gradingqueue');
}
- my $todo=&get_from_queue();
+ # FIXME Blast! still need to reorg this, need to reshow the
+ # queue being reviewed once done with the grade pass...
+ # Hrrm, vaildation pass should perhaps say 'not_locked'
+ # perhaps do a search if there is a key that is mine and if
+ # there isn't reshow the queue....
+ my ($todo,$status_code)=&get_key_todo($target);
+
+ &Apache::lonnet::logthis("got todo -$todo- stat -$status_code-");
if ($todo) {
&setup_env_for_other_user($todo,$safeeval);
my ($symb,$uname,$udom)=&decode_queue_key($todo);
$result.="\n".'
Found '.
&Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.'