';
if ($status_code eq 'stop') {
- $result.=''.&mt("Stopped grading.").'';
+ $result.=''.&mt("Stopped grading.").''.$back;
} elsif ($status_code eq 'lock_failed') {
- $result.=''.&mt("Failed to lock the request record.").'';
+ $result.=''.&mt("Failed to lock the request record.")
+ .''.$back;
} elsif ($status_code eq 'unlock') {
- $result.=''.&mt("Unlocked the requested record.").'';
+ $result.=''.&mt("Unlocked the requested record.")
+ .''.$back;
$result.=&show_queue($env{'form.queue'},1);
} elsif ($status_code eq 'show_list') {
$result.=&show_queue($env{'form.queue'},1);
} elsif ($status_code eq 'select_user') {
$result.=&select_user();
} else {
- $result.=''.&mt("No user to be graded.").'';
+ $result.=''.&mt("No user to be graded.").''.$back;
}
}
$webgrade='no';
- my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
+ my $bodytext=&Apache::lonxml::get_all_text("/task",$parser,$style);
}
if ($target eq 'webgrade' && defined($env{'form.queue'})) {
if ($webgrade eq 'yes') {
@@ -706,23 +724,25 @@ sub end_Task {
DONEBUTTON
}
if (&show_task($status,$previous) &&
- $Apache::lonhomework::history{"resource.$version.status"} =~ /^(pass|fail)$/) {
- my $bt_status=$Apache::lonhomework::history{"resource.$version.status"};
+ $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=&Apache::lonnet::get_slot($Apache::inputtags::slot_name);
+
+ 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;
- $status.="\n
\n";
+ my $status = "\n
\n";
if ($bt_status eq 'pass') {
$status.='
You passed the '.$title.' given on '.
- $start_time.'.
';
+ $start_time.'';
}
if ($bt_status eq 'fail') {
$status.='
You did not pass the '.$title.' given on '.
- $start_time.'.
';
+ $start_time.'';
if (!$previous) {
$status.=&add_request_another_attempt_button();
}
@@ -734,7 +754,7 @@ DONEBUTTON
if ($Apache::bridgetask::dimensionmandatory{$dim_id}
eq 'N') {
$opt_count++;
- if ($Apache::lonhomework::history{"resource.$version.$dim_id.status"} eq 'pass') {
+ if ($Apache::lonhomework::history{"resource.$version.0.$dim_id.status"} eq 'pass') {
$opt_passed++;
}
} else {
@@ -744,7 +764,7 @@ DONEBUTTON
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 on the bridge task.',$man_count,$opt_req,$opt_count)."
\n";
+ $status.="\n
".&mt('You needed to pass all of the [_1] mandatory components and [_2] of the [_3] optional components, of which you were required to pass [_4] on the bridge task.',$man_count,$opt_passed,$opt_count,$opt_req)."
\n";
my $internal_location=&internal_location();
$result=~s/\Q$internal_location\E/$status/;
@@ -775,8 +795,9 @@ DONEBUTTON
}
&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();
@@ -792,7 +813,7 @@ DONEBUTTON
&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') {
@@ -811,10 +832,10 @@ DONEBUTTON
$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.");
@@ -822,7 +843,7 @@ DONEBUTTON
&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.");
@@ -831,7 +852,7 @@ DONEBUTTON
&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';
@@ -849,7 +870,7 @@ DONEBUTTON
["$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';
@@ -866,8 +887,8 @@ DONEBUTTON
["$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"};
@@ -913,7 +934,7 @@ sub move_between_queues {
} else {
$cur_data = ['none'];
}
- my $result=&add_to_queue($dest_queue,$cur_data->[0]);
+ my $result=&add_to_queue($dest_queue,[$cur_data->[0]]);
if ($result ne 'ok') {
return $result;
}
@@ -941,13 +962,38 @@ sub check_queue_unlock {
return 'not_owner';
}
+sub in_queue {
+ my ($queue,$symb,$cdom,$cnum,$udom,$uname)=@_;
+ if ($queue eq 'none') { return 0; }
+ if (!defined($symb) || !defined($cdom) || !defined($cnum)
+ || !defined($udom) || !defined($uname)) {
+ ($symb,my $cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ $cnum=$env{'course.'.$cid.'.num'};
+ $cdom=$env{'course.'.$cid.'.domain'};
+ }
+
+ my $key=&encode_queue_key($symb,$udom,$uname);
+ my %results = &Apache::lonnet::get($queue,[$key],$cdom,$cnum);
+
+ if (defined($results{$key})) {
+ return 1;
+ }
+ return 0;
+}
+
sub remove_from_queue {
- my ($queue)=@_;
+ my ($queue,$symb,$cdom,$cnum,$udom,$uname)=@_;
if ($queue eq 'none') { return 'ok'; }
- my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
- my $cnum=$env{'course.'.$cid.'.num'};
- my $cdom=$env{'course.'.$cid.'.domain'};
- my $key="$symb\0queue\0$uname\@$udom";
+ if (!defined($symb) || !defined($cdom) || !defined($cnum)
+ || !defined($udom) || !defined($uname)) {
+ ($symb,my $cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ $cnum=$env{'course.'.$cid.'.num'};
+ $cdom=$env{'course.'.$cid.'.domain'};
+ }
+ if (!&in_queue($queue,$symb,$cdom,$cnum,$udom,$uname)) {
+ return 'ok';
+ }
+ my $key=&encode_queue_key($symb,$udom,$uname);
my @keys=($key,"$key\0locked");
return &Apache::lonnet::del($queue,\@keys,$cdom,$cnum);
}
@@ -976,10 +1022,10 @@ sub get_queue_data {
return undef;
}
+
sub check_queue_for_key {
- my ($cid,$queue,$todo)=@_;
- my $cnum=$env{'course.'.$cid.'.num'};
- my $cdom=$env{'course.'.$cid.'.domain'};
+ my ($cdom,$cnum,$queue,$todo)=@_;
+
my %results=
&Apache::lonnet::get($queue,[$todo,"$todo\0locked"],$cdom,$cnum);
@@ -987,10 +1033,17 @@ sub check_queue_for_key {
if (defined($results{"$todo\0locked"})) {
return 'locked';
}
- my $slot=$results{$todo}->[0];
- my %slot_data=&Apache::lonnet::get_slot($slot);
- if ($slot_data{'endtime'} > time) {
- return 'in_progress';
+ my $slot;
+ if (ref($results{$todo}) eq 'ARRAY') {
+ $slot = $results{$todo}[0];
+ } elsif (ref($results{$todo}) eq 'HASH') {
+ $slot = $results{$todo}{'slot'};
+ }
+ if (defined($slot)) {
+ my %slot_data=&Apache::lonnet::get_slot($slot);
+ if ($slot_data{'endtime'} > time) {
+ return 'in_progress';
+ }
}
return 'enqueued';
}
@@ -998,14 +1051,17 @@ sub check_queue_for_key {
}
sub add_to_queue {
- my ($queue,$slot_name)=@_;
+ my ($queue,$user_data)=@_;
if ($queue eq 'none') { return 'ok'; }
my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ if (!$cid || $env{'request.state'} eq 'construct') {
+ return 'no_queue';
+ }
my $cnum=$env{'course.'.$cid.'.num'};
my $cdom=$env{'course.'.$cid.'.domain'};
my %data;
- $data{"$symb\0queue\0$uname\@$udom"}=[$slot_name];
- return &Apache::lonnet::newput($queue,\%data,$cdom,$cnum);
+ $data{"$symb\0queue\0$uname\@$udom"}=$user_data;
+ return &Apache::lonnet::cput($queue,\%data,$cdom,$cnum);
}
sub show_queue {
@@ -1031,7 +1087,7 @@ sub show_queue {
if ($tmp=~/^error: 2 /) {
return "\n
Current Queue - $queue
Empty
";
}
- $result.="\n
Current Queue - $queue
";
+ $result.="\n
Current Queue - $symb $queue
";
if ($with_selects) { $result.="
"; }
$result.="
resource
user
type
data
";
foreach my $key (sort(keys(%queue))) {
@@ -1219,6 +1275,27 @@ sub lock_key {
return 0;
}
+sub get_queue_symb_status {
+ my ($queue,$symb,$cdom,$cnum) = @_;
+ if (!defined($cdom) || !defined($cnum)) {
+ my (undef,$cid)=&Apache::lonxml::whichuser();
+ $cnum=$env{'course.'.$cid.'.num'};
+ $cdom=$env{'course.'.$cid.'.domain'};
+ }
+ my $regexp="^$symb\0";
+ my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
+ my ($tmp)=%queue;
+ if ($tmp=~/^error: 2 /) { return; }
+ my @users;
+ foreach my $key (sort(keys(%queue))) {
+ next if ($key=~/locked$/);
+ next if ($key=~/timestamp$/);
+ my ($symb,$uname,$udom) = &decode_queue_key($key);
+ push(@users,"$uname:$udom");
+ }
+ return @users;
+}
+
sub get_from_queue {
my ($queue)=@_;
my $result;
@@ -1230,8 +1307,8 @@ sub get_from_queue {
if ($todo) { return $todo; }
while (1) {
my $starttime=time;
- &Apache::lonnet::put($queue,{"$symb\0timestamp"=>$starttime},
- $cdom,$cnum);
+ &Apache::lonnet::cput($queue,{"$symb\0timestamp"=>$starttime},
+ $cdom,$cnum);
&Apache::lonxml::debug("$starttime");
my $regexp="^$symb\0queue\0";
my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
@@ -1302,7 +1379,10 @@ sub select_user {
foreach my $student (sort {lc($$fullname{$a}) cmp lc($$fullname{$b}) } keys %$fullname) {
my ($uname,$udom) = split(/:/,$student);
- my %status = &get_student_status($symb,$cid,$udom,$uname);
+ my $cnum=$env{'course.'.$cid.'.num'};
+ my $cdom=$env{'course.'.$cid.'.domain'};
+ my %status = &get_student_status($symb,$cdom,$cnum,$udom,$uname,
+ 'Task');
my $queue = 'none';
my $cannot_grade;
if ($status{'reviewqueue'} =~ /^(in_progress|enqueue)$/) {
@@ -1381,17 +1461,23 @@ RESULT
}
sub get_student_status {
- my ($symb,$cid,$udom,$uname)=@_;
- my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
- $udom,$uname);
+ my ($symb,$cdom,$cnum,$udom,$uname,$type)=@_;
+
my %status;
- $status{'status'}=$record{'resource.status'};
- $status{'version'}=$record{'resource.version'};
- $status{'grader'}=$record{'resource.grader'};
- $status{'reviewqueue'}=&check_queue_for_key($cid,'reviewqueue',
- &encode_queue_key($symb,$udom,$uname));
- $status{'gradingqueue'}=&check_queue_for_key($cid,'gradingqueue',
- &encode_queue_key($symb,$udom,$uname));
+
+ if ($type eq 'Task') {
+ my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
+ $udom,$uname);
+ $status{'status'}=$record{'resource.0.status'};
+ $status{'version'}=$record{'resource.0.version'};
+ $status{'grader'}=$record{'resource.0.regrader'};
+ }
+ $status{'reviewqueue'}=
+ &check_queue_for_key($cdom,$cnum,'reviewqueue',
+ &encode_queue_key($symb,$udom,$uname));
+ $status{'gradingqueue'}=
+ &check_queue_for_key($cdom,$cnum,'gradingqueue',
+ &encode_queue_key($symb,$udom,$uname));
return %status;
}
@@ -1491,10 +1577,10 @@ sub get_instance {
foreach my $instance (@instances) {
@Apache::scripttag::parser_env = @_;
$result.=&Apache::scripttag::xmlparse($dimension{$instance.'.text'});
- if ($Apache::lonhomework::history{"resource.$version.status"} eq 'pass' ||
- $Apache::lonhomework::history{"resource.$version.status"} eq 'fail') {
+ if ($Apache::lonhomework::history{"resource.$version.0.status"} eq 'pass' ||
+ $Apache::lonhomework::history{"resource.$version.0.status"} eq 'fail') {
- my $dim_status=$Apache::lonhomework::history{"resource.$version.$dim.status"};
+ my $dim_status=$Apache::lonhomework::history{"resource.$version.0.$dim.status"};
my $mandatory='Mandatory';
if ($Apache::bridgetask::dimensionmandatory{$dim} eq 'N') {
$mandatory='Optional';
@@ -1514,12 +1600,12 @@ sub get_instance {
if ($dimension{$instance.'.criteria.'.$id.'.mandatory'}
eq 'N') {
$opt_count++;
- if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"} eq 'pass') {
+ if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"} eq 'pass') {
$opt_passed++;
}
} else {
$man_count++;
- if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"} eq 'pass') {
+ if ($Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"} eq 'pass') {
$man_passed++;
}
}
@@ -1533,8 +1619,8 @@ sub get_instance {
$result=~s/\Q$internal_location\E/$dim_info/;
foreach my $id (@{$dimension{$instance.'.criterias'}}) {
- my $status=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.status"};
- my $comment=$Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"};
+ my $status=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.status"};
+ my $comment=$Apache::lonhomework::history{"resource.$version.0.$dim.$instance.$id.comment"};
my $mandatory=($dimension{$instance.'.criteria.'.$id.'.mandatory'} ne 'N');
if ($mandatory) {
$mandatory='Mandatory';
@@ -1554,8 +1640,8 @@ sub get_instance {
@Apache::scripttag::parser_env = @_;
$result.=&Apache::scripttag::xmlparse($dimension{$instance.'.criteria.'.$id});
$result.='
'.$status_display.'
';
- if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}) {
- $result.='