--- loncom/homework/bridgetask.pm 2005/05/19 21:28:06 1.26
+++ loncom/homework/bridgetask.pm 2005/05/24 19:33:28 1.30
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.26 2005/05/19 21:28:06 albertel Exp $
+# $Id: bridgetask.pm,v 1.30 2005/05/24 19:33:28 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -71,11 +71,16 @@ sub proctor_check_auth {
if ($authhost ne 'no_host') {
my $version=
$Apache::lonhomework::results{'resource.version'}=
- $Apache::lonhomework::history{'resource.version'}++;
+ ++$Apache::lonhomework::history{'resource.version'};
$Apache::lonhomework::results{"resource.$version.checkedin"}=
$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,33 +89,59 @@ sub proctor_check_auth {
}
sub get_version {
+ my ($version,$previous);
if ($env{'form.previousversion'} &&
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";
+ $result.='";
return $result;
}
sub add_grading_button {
- my $result;
- $result.=' ';
$result.='';
return $result;
@@ -123,6 +154,18 @@ sub add_request_another_attempt_button {
return $result;
}
+sub preserve_grade_info {
+ my $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;
+}
+
sub start_Task {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
@@ -147,7 +190,7 @@ sub start_Task {
}
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 +200,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;
@@ -208,17 +252,13 @@ sub start_Task {
$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();
+ $result.=&preserve_grade_info();
+ 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').'
';
@@ -229,9 +269,13 @@ sub start_Task {
if ($target eq 'webgrade') {
$result.=$head_tag_start.$body_tag_start.$form_tag_start;
$result.='';
- $result.=&show_queue();
+ $result.=' Before'.&show_queue('gradingqueue');
+ }
+ my $todo;
+ # don't get something new from the queue if they hit the stop button
+ if (!($env{'form.stop'} && $target eq 'webgrade')) {
+ $todo=&get_from_queue('gradingqueue');
}
- my $todo=&get_from_queue();
if ($todo) {
&setup_env_for_other_user($todo,$safeeval);
my ($symb,$uname,$udom)=&decode_queue_key($todo);
@@ -242,11 +286,19 @@ sub start_Task {
$Apache::bridgetask::queue_key=$todo;
&Apache::structuretags::initialize_storage();
&Apache::lonhomework::showhash(%Apache::lonhomework::history);
- $result.="\n".'