--- loncom/homework/bridgetask.pm 2005/05/13 15:34:50 1.24
+++ loncom/homework/bridgetask.pm 2005/05/19 21:22:44 1.25
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.24 2005/05/13 15:34:50 albertel Exp $
+# $Id: bridgetask.pm,v 1.25 2005/05/19 21:22:44 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -83,8 +83,25 @@ sub proctor_check_auth {
return 0;
}
+sub get_version {
+ if ($env{'form.previousversion'} &&
+ defined($Apache::lonhomework::history{'resource.'.$env{'form.previousversion'}.'.status'})) {
+ return $env{'form.previousversion'};
+ }
+ return $Apache::lonhomework::history{'resource.version'};
+}
+
sub add_previous_version_button {
+ my ($status)=@_;
my $result;
+ if ($Apache::lonhomework::history{'resource.version'} eq '0') {
+ return '';
+ }
+ my $version=&get_version();
+ if ($version ne $Apache::lonhomework::history{'resource.version'}) {
+ return '';
+ }
+
$result.=&mt(' Show a previously done version: [_1]','');
@@ -100,7 +117,10 @@ sub add_grading_button {
}
sub add_request_another_attempt_button {
-
+ my $result;
+ $result.=' ';
+ return $result;
}
sub start_Task {
@@ -118,7 +138,6 @@ sub start_Task {
&Apache::structuretags::page_start($target,$token,$tagstack,$parstack,$parser,$safeeval);
if ($target eq 'web') {
- $body_tag_start.=&add_previous_version_button();
if ($Apache::lonhomework::modifygrades) {
$body_tag_start.='
'."\n";
}
}
- if ($Apache::lonhomework::history{'resource.status'} eq 'fail') {
+ my $version=&get_version();
+ if ($Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
$result.='
'.&mt('Did not pass').'
';
- $result.=&request_another_attempt_button();
+ $result.=&add_request_another_attempt_button();
}
- if ($Apache::lonhomework::history{'resource.status'} eq 'pass') {
+ if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass') {
$result.='
'.&mt('Passed').'
';
}
}
@@ -240,7 +261,7 @@ sub end_Task {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result='';
my $status=$Apache::inputtags::status['-1'];
- my $version=$Apache::lonhomework::history{'resource.version'};
+ my $version=&get_version();
if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
$target eq 'tex') {
if (
@@ -288,7 +309,7 @@ sub end_Task {
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
my $status=
- $Apache::lonhomework::results{"resource.$dim_id.status"};
+ $Apache::lonhomework::results{"resource.$version.$dim_id.status"};
my $mandatory=
($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N');
if ($status eq 'pass') {
@@ -308,20 +329,34 @@ sub end_Task {
$Apache::lonhomework::results{'resource.grader'}=
$env{'user.name'}.'@'.$env{'user.domain'};
if ($review) {
- $Apache::lonhomework::results{'resource.status'}='review';
+ $Apache::lonhomework::results{"resource.$version.status"}='review';
&move_to_review_queue();
} elsif ($ungraded) {
- $Apache::lonhomework::results{'resource.status'}='ungraded';
+ $Apache::lonhomework::results{"resource.$version.status"}='ungraded';
&check_queue_unlock();
} elsif ($mandatory_failed) {
- $Apache::lonhomework::results{'resource.status'}='fail';
- $Apache::lonhomework::results{"resource.$version.award"}='EXACT_ANS';
+ $Apache::lonhomework::results{"resource.$version.status"}='fail';
+ $Apache::lonhomework::results{"resource.$version.0.solved"}='incorrect_by_override';
+ $Apache::lonhomework::results{"resource.$version.0.award"}='INCORRECT';
+ $Apache::lonhomework::results{"resource.$version.0.awarded"}='0';
&remove_from_queue();
} else {
- $Apache::lonhomework::results{'resource.status'}='pass';
- $Apache::lonhomework::results{"resource.$version.award"}='INCORRECT';
+ $Apache::lonhomework::results{"resource.$version.status"}='pass';
+ $Apache::lonhomework::results{"resource.$version.0.solved"}='correct_by_override';
+ $Apache::lonhomework::results{"resource.$version.0.award"}='EXACT_ANS';
+ $Apache::lonhomework::results{"resource.$version.0.awarded"}='1';
&remove_from_queue();
}
+ $Apache::lonhomework::results{'resource.status'}=
+ $Apache::lonhomework::results{'resource.$version.status'};
+ if (defined($Apache::lonhomework::results{'resource.$version.awarded'})) {
+ $Apache::lonhomework::results{'resource.0.award'}=
+ $Apache::lonhomework::results{'resource.$version.award'};
+ $Apache::lonhomework::results{'resource.0.awarded'}=
+ $Apache::lonhomework::results{'resource.$version.awarded'};
+ $Apache::lonhomework::results{'resource.0.solved'}=
+ $Apache::lonhomework::results{'resource.$version.solved'};
+ }
&Apache::structuretags::finalize_storage();
}
} elsif ($target eq 'webgrade') {
@@ -598,15 +633,16 @@ sub get_instance {
sub end_Dimension {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result;
- my $dim_id=&get_id($parstack,$safeeval);
+ my $dim=&get_id($parstack,$safeeval);
my $instance=&get_instance();
+ my $version=&get_version();
if ($target eq 'web') {
$result=$dimension{'intro'}.$dimension{$instance.'.text'};
- if ($Apache::lonhomework::history{'resource.status'} eq 'pass' ||
- $Apache::lonhomework::history{'resource.status'} eq 'fail') {
+ if ($Apache::lonhomework::history{'resource.$version.status'} eq 'pass' ||
+ $Apache::lonhomework::history{'resource.$version.status'} eq 'fail') {
foreach my $id (@{$dimension{$instance.'.criterias'}}) {
- my $status=$Apache::lonhomework::history{"resource.$dim_id.$instance.$id.status"};
- my $comment=$Apache::lonhomework::history{"resource.$dim_id.$instance.$id.comment"};
+ my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"};
+ my $comment=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"};
$result.='
';
if ($status eq 'fail') {
$result.=''.&mt('Did not pass').'';
@@ -616,18 +652,17 @@ sub get_instance {
&Apache::lonxml::error("Student viewing a graded bridgetask was show a status of $status");
}
$result.='
';
- if ($Apache::lonhomework::history{"resource.$dim_id.$instance.$id.comment"}) {
- $result.=&mt('Comment from grader: ').$Apache::lonhomework::history{"resource.$dim_id.$instance.$id.comment"}.'
';
+ if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}) {
+ $result.=&mt('Comment from grader: ').$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}.'