';
}
+ } 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 = '';
@@ -333,35 +612,152 @@ sub start_Task {
sub get_key_todo {
my ($target)=@_;
my $todo;
+
+ if (defined($env{'form.reviewasubmission'})) {
+ &Apache::lonxml::debug("review a submission....");
+ $env{'form.queue'}='reviewqueue';
+ return (undef,'show_list');
+ }
+
+ if (defined($env{'form.reviewagrading'})) {
+ &Apache::lonxml::debug("review a grading....");
+ $env{'form.queue'}='gradingqueue';
+ return (undef,'show_list');
+ }
+
+ if (defined($env{'form.regradeasubmission'})) {
+ &Apache::lonxml::debug("regrade a grading....");
+ $env{'form.queue'}='none';
+ 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)) {
$env{'form.queue'}=$queue='gradingqueue';
}
+
my $gradingkey=&Apache::lonnet::unescape($env{'form.gradingkey'});
+
+ if ($env{'form.queue'} eq 'none') {
+ if (defined($env{'form.gradingkey'})) {
+ if ($target eq 'webgrade') {
+ if ($env{'form.stop'}) {
+ return (undef,'stop');
+ } elsif ($env{'form.next'}) {
+ return (undef,'select_user');
+ }
+ }
+ return ($gradingkey,'selected');
+ } else {
+ return (undef,'select_user');
+ }
+ }
if (defined($env{'form.queue'}) && defined($env{'form.gradingkey'})
- && !defined($env{'form.action'})) {
- #FIXME probably need to do some cheking here for more validity
- &Apache::lonnet::logthis("Found a key was given to me");
- return ($gradingkey);
- }
- if ($env{'form.action'} eq 'resume') {
- &Apache::lonnet::logthis("Resuming a key");
- return ($gradingkey);
- } elsif ($env{'form.action'} eq 'unlock') {
- &Apache::lonnet::logthis("Unlocking a key ".
- &check_queue_unlock($queue,$gradingkey,1));
- return (undef,'unlock');
- } elsif ($env{'form.action'} eq 'select') {
- if (&lock_key($queue,$gradingkey)) {
+ && !defined($env{'form.gradingaction'})
+ && $env{'form.queuemode'} eq 'selected') {
+
+ my $who=&queue_key_locked($queue,$gradingkey);
+ if ($who eq $me) {
+ &Apache::lonxml::debug("Found a key was given to me");
+ return ($gradingkey,'selected');
+ } else {
+ return (undef,'show_list');
+ }
+
+ }
+
+ if ($target eq 'webgrade' && $env{'form.queuemode'} eq 'selected') {
+ if ($env{'form.gradingaction'} eq 'resume') {
+ delete($env{'form.gradingaction'});
+ &Apache::lonxml::debug("Resuming a key");
return ($gradingkey);
+ } elsif ($env{'form.gradingaction'} eq 'unlock') {
+ &Apache::lonxml::debug("Unlocking a key ".
+ &check_queue_unlock($queue,$gradingkey,1));
+ return (undef,'unlock');
+ } elsif ($env{'form.gradingaction'} eq 'select') {
+ &Apache::lonxml::debug("Locking a key");
+ if (&lock_key($queue,$gradingkey)) {
+ &Apache::lonxml::debug("Success $queue");
+ return ($gradingkey);
+ }
+ &Apache::lonxml::debug("Failed $queue");
+ return (undef,'lock_failed');
}
- return (undef,'lock_failed');
}
- # don't get something new from the queue if they hit the stop button
- if (!($env{'form.stop'} && $target eq 'webgrade')) {
- return (&get_from_queue($queue));
- } else {
- return (undef,'stop');
+
+ if ($env{'form.queuemode'} ne 'selected') {
+ # don't get something new from the queue if they hit the stop button
+ if (!($env{'form.stop'} && $target eq 'webgrade')
+ && !$env{'form.gradingaction'}) {
+ &Apache::lonxml::debug("Getting anew $queue");
+ return (&get_from_queue($queue));
+ } else {
+ return (undef,'stop');
+ }
+ }
+ 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});
+ }
}
}
@@ -372,22 +768,83 @@ 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","*",
- 'portfolioonly').
+ 'portfolioonly',
+ '
+'.&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_encrypt($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') {
- $result.=&Apache::lonxml::xmlend().'