[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 24 May 2005 22:06:42 -0000
albertel Tue May 24 18:06:42 2005 EDT
Modified files:
/loncom/homework bridgetask.pm
Log:
- starting on review queue
- if any 'review' toggles are set, user is moved lock stock and barrel to review queue
(still need some way of getting a user out of review queue)
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.30 loncom/homework/bridgetask.pm:1.31
--- loncom/homework/bridgetask.pm:1.30 Tue May 24 15:33:28 2005
+++ loncom/homework/bridgetask.pm Tue May 24 18:06:39 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# definition of tags that give a structure to a document
#
-# $Id: bridgetask.pm,v 1.30 2005/05/24 19:33:28 albertel Exp $
+# $Id: bridgetask.pm,v 1.31 2005/05/24 22:06:39 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -269,6 +269,7 @@
if ($target eq 'webgrade') {
$result.=$head_tag_start.$body_tag_start.$form_tag_start;
$result.='<input type="hidden" name="webgrade" value="yes" />';
+ $result.='<br />Review'.&show_queue('reviewqueue');
$result.='<br />Before'.&show_queue('gradingqueue');
}
my $todo;
@@ -351,7 +352,7 @@
&Apache::lonhomework::showhash(%Apache::lonhomework::results);
&Apache::structuretags::finalize_storage();
if ($award eq 'SUBMITTED') {
- &add_to_queue('gradingqueue');
+ &add_to_queue('gradingqueue',$Apache::inputtags::slot_name);
}
}
if ($target eq 'grade' && $env{'form.webgrade'}) {
@@ -386,7 +387,7 @@
$env{'user.name'}.'@'.$env{'user.domain'};
if ($review) {
$Apache::lonhomework::results{"resource.$version.status"}='review';
- &move_to_review_queue();
+ &move_between_queues('gradingqueue','reviewqueue');
} elsif ($ungraded) {
$Apache::lonhomework::results{"resource.$version.status"}='ungraded';
&check_queue_unlock('gradingqueue');
@@ -401,7 +402,7 @@
$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();
+ &remove_from_queue('grading_queue');
}
$Apache::lonhomework::results{"resource.status"}=
$Apache::lonhomework::results{"resource.$version.status"};
@@ -435,9 +436,16 @@
return $result;
}
-sub move_to_review_queue {
-
- &Apache::lonxml::debug("Want to move");
+sub move_between_queues {
+ my ($src_queue,$dest_queue)=@_;
+ my $cur_data=&get_queue_data($src_queue);
+ if (!$cur_data) { return 'not_exist'; }
+ my $result=&add_to_queue($dest_queue,$cur_data->[0]);
+ if ($result ne 'ok') {
+ return $result;
+ }
+ &check_queue_unlock($src_queue);
+ return &remove_from_queue($src_queue);
}
sub check_queue_unlock {
@@ -460,7 +468,7 @@
my $cdom=$env{'course.'.$cid.'.domain'};
my $key="$symb\0queue\0$uname\@$udom";
my @keys=($key,"$key\0locked");
- &Apache::lonnet::del($queue,\@keys,$cdom,$cnum);
+ return &Apache::lonnet::del($queue,\@keys,$cdom,$cnum);
}
sub setup_env_for_other_user {
@@ -474,14 +482,27 @@
&Apache::lonxml::initialize_rndseed($safeeval);
}
-sub add_to_queue {
+sub get_queue_data {
my ($queue)=@_;
my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
my $cnum=$env{'course.'.$cid.'.num'};
my $cdom=$env{'course.'.$cid.'.domain'};
+ my $todo="$symb\0queue\0$uname\@$udom";
+ my ($key,$value)=&Apache::lonnet::get($queue,[$todo],$cdom,$cnum);
+ if ($key eq $todo && ref($value)) {
+ return $value;
+ }
+ return undef;
+}
+
+sub add_to_queue {
+ my ($queue,$slot_name)=@_;
+ my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
+ my $cnum=$env{'course.'.$cid.'.num'};
+ my $cdom=$env{'course.'.$cid.'.domain'};
my %data;
- $data{"$symb\0queue\0$uname\@$udom"}=[$Apache::inputtags::slot_name];
- &Apache::lonnet::put($queue,\%data,$cdom,$cnum);
+ $data{"$symb\0queue\0$uname\@$udom"}=[$slot_name];
+ return &Apache::lonnet::put($queue,\%data,$cdom,$cnum);
}
sub show_queue {
@@ -492,6 +513,10 @@
my $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 "\n<h3>Current Queue</h3><table border='1'><tr><td>Empty</td></tr></table>";
+ }
$result.="\n<h3>Current Queue</h3><table border='1'><tr><th>resource</th>".
"<th>user</th><th>type</th><th>data</th></tr>";
foreach my $key (sort(keys(%queue))) {
@@ -613,8 +638,8 @@
# no one in our section so look for any user that is ready for grading
if (!$todo) {
&Apache::lonnet::logthis("no sce");
- $todo=&pick_from_queue_data($env{'request.course.sec'},\%queue,
- $cdom,$cnum);
+ $todo=&pick_from_queue_data($queue,$env{'request.course.sec'},
+ \%queue,$cdom,$cnum);
&Apache::lonnet::logthis("no sce $todo");
}
# no user to grade