';
+ }
+ } elsif ($target eq 'edit') {
+ $result.=$head_tag_start."".$body_tag_start.$form_tag_start.
+ &Apache::structuretags::problem_edit_header();
+ $Apache::lonxml::warnings_error_header=
+ &mt("Editor Errors - these errors might not effect the running of the problem, but they will likely cause problems with further use of the Edit mode. Please use the EditXML mode to fix these errors.")."
";
+ my $temp=&Apache::edit::insertlist($target,$token);
+ $result.=$temp;
} else {
# page_start returned a starting result, delete it if we don't need it
$result = '';
@@ -387,7 +641,7 @@ sub get_key_todo {
my $todo;
if (defined($env{'form.reviewasubmission'})) {
- &Apache::lonnet::logthis("review a submission....");
+ &Apache::lonxml::debug("review a submission....");
$env{'form.queue'}='reviewqueue';
return (undef,'show_list');
}
@@ -404,6 +658,57 @@ sub get_key_todo {
return (undef,'select_user');
}
+
+ my $me=$env{'user.name'}.'@'.$env{'user.domain'};
+
+ #need to try both queues..
+ if (defined($env{'form.regradeaspecificsubmission'}) &&
+ defined($env{'form.gradinguser'}) &&
+ defined($env{'form.gradingdomain'}) ) {
+ my ($symb,$cid)=&Apache::lonxml::whichuser();
+ my $cnum = $env{'course.'.$cid.'.num'};
+ my $cdom = $env{'course.'.$cid.'.domain'};
+ my $uname = $env{'form.gradinguser'};
+ my $udom = $env{'form.gradingdomain'};
+
+ my $gradingkey=&encode_queue_key($symb,$udom,$uname);
+
+ my $queue;
+
+ if (&in_queue('gradingqueue',$symb,$cdom,$cnum,$udom,$uname)) {
+ $env{'form.queue'} = $queue = 'gradingqueue';
+ } elsif (&in_queue('reviewqueue' ,$symb,$cdom,$cnum,$udom,$uname)) {
+ $env{'form.queue'} = $queue = 'reviewqueue';
+ }
+
+ if (!$queue) {
+ $env{'form.queue'} = $queue = 'none';
+ #not queued so doing either a re or pre grade
+ return ($gradingkey);
+ }
+
+ my $who=&queue_key_locked($queue,$gradingkey);
+ if ($who eq $me) {
+ #already have the lock
+ $env{'form.gradingkey'}=&Apache::lonnet::escape($gradingkey);
+ return ($gradingkey);
+ }
+
+ if (!defined($who)) {
+ if (&lock_key($queue,$gradingkey)) {
+ return ($gradingkey);
+ } else {
+ return (undef,'lock_failed');
+ }
+ }
+
+ #otherwise (defined($who) && $who ne $me) some else has it...
+ return (undef,'not_allowed',
+ &mt('Another user ([_1]) currently has the record for [_2] locked.',
+ $who,$env{'form.gradinguser'}.'@'.$env{'form.gradingdomain'}));
+ }
+
+
my $queue=$env{'form.queue'};
if (!defined($queue)) {
@@ -418,12 +723,12 @@ sub get_key_todo {
if ($env{'form.stop'}) {
return (undef,'stop');
} elsif ($env{'form.next'}) {
- return (undef,'show_list');
+ return (undef,'select_user');
}
}
return ($gradingkey,'selected');
} else {
- return (undef,'show_list');
+ return (undef,'select_user');
}
}
if (defined($env{'form.queue'}) && defined($env{'form.gradingkey'})
@@ -431,7 +736,6 @@ sub get_key_todo {
&& $env{'form.queuemode'} eq 'selected') {
my $who=&queue_key_locked($queue,$gradingkey);
- my $me=$env{'user.name'}.'@'.$env{'user.domain'};
if ($who eq $me) {
&Apache::lonxml::debug("Found a key was given to me");
return ($gradingkey,'selected');
@@ -474,6 +778,16 @@ sub get_key_todo {
return (undef,undef)
}
+sub minimize_storage {
+ foreach my $key (keys(%Apache::lonhomework::results)) {
+ if ($key =~ /regrader$/) { next; }
+ if ($Apache::lonhomework::results{$key} eq
+ $Apache::lonhomework::history{$key}) {
+ delete($Apache::lonhomework::results{$key});
+ }
+ }
+}
+
sub end_Task {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result='';
@@ -481,12 +795,13 @@ sub end_Task {
my ($version,$previous)=&get_version();
if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
$target eq 'tex') {
- if (
- (($target eq 'web') && ($env{'request.state'} ne 'construct')) ||
- ($target eq 'answer') || ($target eq 'tex')
- ) {
+ if ($target eq 'web' || $target eq 'answer' || $target eq 'tex') {
if ($target eq 'web') {
- if ($status eq 'CAN_ANSWER' && !$previous) {
+ if (&show_task($status,$previous)) {
+ $result.=&Apache::lonxml::endredirection();
+ }
+ if ($status eq 'CAN_ANSWER' && !$previous &&
+ !$env{'form.donescreen'}) {
$result.="\n".'
'.
&Apache::inputtags::file_selector("$version.0",
"bridgetask","*",
@@ -495,7 +810,64 @@ sub end_Task {
'.&mt('Submit Portfolio Files for Grading').'
'.&mt('Indicate the files from your portfolio to be evaluated in grading this task.').'
').
"
";
+ }
+ if (!$previous && $status ne 'SHOW_ANSWER' &&
+ &show_task($status,$previous)) {
$result.=&Apache::inputtags::gradestatus('0');
+ $result.='';
+ my $action = &Apache::lonenc::check_encrypted($env{'request.uri'});
+ $result.=<
+
+
+
+DONEBUTTON
+ }
+ if (&show_task($status,$previous) &&
+ $Apache::lonhomework::history{"resource.$version.0.status"} =~ /^(pass|fail)$/) {
+ my $bt_status=$Apache::lonhomework::history{"resource.$version.0.status"};
+ my $title=&Apache::lonnet::gettitle();
+
+ my $slot_name=
+ $Apache::lonhomework::history{"resource.$version.0.checkedin.slot"};
+ my %slot=&Apache::lonnet::get_slot($slot_name);
+ my $start_time=
+ &Apache::lonlocal::locallocaltime($slot{'starttime'});
+
+ my $status = "\n\n";
+
+ if ($bt_status eq 'pass') {
+ $status.='
You passed the '.$title.' given on '.
+ $start_time.'
';
+ }
+ if ($bt_status eq 'fail') {
+ $status.='
You did not pass the '.$title.' given on '.
+ $start_time.'
';
+ if (!$previous) {
+ $status.=&add_request_another_attempt_button();
+ }
+ }
+ my $man_count=0;
+ my $opt_count=0;
+ my $opt_passed=0;
+ foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
+ if ($Apache::bridgetask::dimensionmandatory{$dim_id}
+ eq 'N') {
+ $opt_count++;
+ if ($Apache::lonhomework::history{"resource.$version.0.$dim_id.status"} eq 'pass') {
+ $opt_passed++;
+ }
+ } else {
+ $man_count++;
+ }
+ }
+ my $opt_req=&Apache::lonxml::get_param('OptionalRequired',
+ $parstack,$safeeval);
+ if ($opt_req !~ /\S/) { $opt_req='0'; }
+ $status.="\n
".&mt('You needed to pass all of the [_1] mandatory components and [_2] of the [_3] optional components, of which you passed [_4].',$man_count,$opt_req,$opt_count,$opt_passed)."
\n";
+
+ my $internal_location=&internal_location();
+ $result=~s/\Q$internal_location\E/$status/;
}
}
if ($target eq 'web' || $target eq 'webgrade') {
@@ -517,12 +889,18 @@ sub end_Task {
$award;
$Apache::lonhomework::results{"resource.0.submission"}=
$Apache::lonhomework::results{"resource.$version.0.submission"}='';
+ } else {
+ delete($Apache::lonhomework::results{"resource.$version.0.bridgetask.portfiles"});
+ $award = '';
}
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
&Apache::structuretags::finalize_storage();
- if ($award eq 'SUBMITTED') {
- &add_to_queue('gradingqueue',$Apache::inputtags::slot_name);
+ if ($award eq 'SUBMITTED'
+ && defined($Apache::inputtags::slot_name)) {
+ &add_to_queue('gradingqueue',[$Apache::inputtags::slot_name]);
}
+ } elsif ($Apache::lonhomework::results{'INTERNAL_store'}) {
+ &Apache::structuretags::finalize_storage();
}
if ($target eq 'grade' && $env{'form.webgrade'} eq 'yes') {
my $optional_required=
@@ -535,7 +913,7 @@ sub end_Task {
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
foreach my $dim_id (@Apache::bridgetask::dimensionlist) {
my $status=
- $Apache::lonhomework::results{"resource.$version.$dim_id.status"};
+ $Apache::lonhomework::results{"resource.$version.0.$dim_id.status"};
my $mandatory=
($Apache::bridgetask::dimensionmandatory{$dim_id} ne 'N');
if ($status eq 'pass') {
@@ -554,10 +932,10 @@ sub end_Task {
$mandatory_failed++;
}
&Apache::lonxml::debug("all dim ".join(':',@Apache::bridgetask::dimensionlist)."results -> m_f $mandatory_failed o_p $optional_passed u $ungraded r $review");
- $Apache::lonhomework::results{'resource.grader'}=
+ $Apache::lonhomework::results{'resource.0.regrader'}=
$env{'user.name'}.'@'.$env{'user.domain'};
if ($review) {
- $Apache::lonhomework::results{"resource.$version.status"}='review';
+ $Apache::lonhomework::results{"resource.$version.0.status"}='review';
if ($env{'form.queue'} eq 'reviewqueue') {
&check_queue_unlock($env{'form.queue'});
&Apache::lonxml::debug(" still needs review not changing status.");
@@ -565,7 +943,7 @@ sub end_Task {
&move_between_queues($env{'form.queue'},'reviewqueue');
}
} elsif ($ungraded) {
- $Apache::lonhomework::results{"resource.$version.status"}='ungraded';
+ $Apache::lonhomework::results{"resource.$version.0.status"}='ungraded';
if ($env{'form.queue'} eq 'reviewqueue' ||
$env{'form.queue'} eq 'none' ) {
&Apache::lonxml::debug("moving back.");
@@ -574,7 +952,7 @@ sub end_Task {
&check_queue_unlock($env{'form.queue'});
}
} elsif ($mandatory_failed) {
- $Apache::lonhomework::results{"resource.$version.status"}='fail';
+ $Apache::lonhomework::results{"resource.$version.0.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';
@@ -592,7 +970,7 @@ sub end_Task {
["$version.0.bridgetask"]);
}
} else {
- $Apache::lonhomework::results{"resource.$version.status"}='pass';
+ $Apache::lonhomework::results{"resource.$version.0.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';
@@ -609,8 +987,8 @@ sub end_Task {
["$version.0.bridgetask"]);
}
}
- $Apache::lonhomework::results{"resource.status"}=
- $Apache::lonhomework::results{"resource.$version.status"};
+ $Apache::lonhomework::results{"resource.0.status"}=
+ $Apache::lonhomework::results{"resource.$version.0.status"};
if (defined($Apache::lonhomework::results{"resource.$version.0.awarded"})) {
$Apache::lonhomework::results{"resource.0.award"}=
$Apache::lonhomework::results{"resource.$version.0.award"};
@@ -619,10 +997,11 @@ sub end_Task {
$Apache::lonhomework::results{"resource.0.solved"}=
$Apache::lonhomework::results{"resource.$version.0.solved"};
}
+ &minimize_storage();
&Apache::structuretags::finalize_storage();
}
} elsif ($target eq 'webgrade') {
- $result.="