[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 27 May 2005 21:13:49 -0000
This is a MIME encoded message
--albertel1117228429
Content-Type: text/plain
albertel Fri May 27 17:13:49 2005 EDT
Modified files:
/loncom/homework bridgetask.pm
Log:
- review queue fully functional as far as I can tell
- grading queue can also now be managed
--albertel1117228429
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20050527171349.txt"
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.32 loncom/homework/bridgetask.pm:1.33
--- loncom/homework/bridgetask.pm:1.32 Fri May 27 13:08:03 2005
+++ loncom/homework/bridgetask.pm Fri May 27 17:13:46 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.32 2005/05/27 17:08:03 albertel Exp $
+# $Id: bridgetask.pm,v 1.33 2005/05/27 21:13:46 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -148,7 +148,9 @@
#need a permissions for limitng this to 'powerful users'
#check if review queue has items
$result.=' <input type="submit" name="reviewasubmission" value="'.
- &mt("Select an entry from the review queue").'" />';
+ &mt("Select an entry from the review queue").'" />'."\n";
+ $result.=' <input type="submit" name="reviewagrading" value="'.
+ &mt("Select an entry from the grading queue").'" />'."\n";
}
return $result;
}
@@ -274,47 +276,55 @@
$target eq 'webgrade') {
my $webgrade='yes';
if ($target eq 'webgrade') {
- #FIXME FORM conflcit with the 'show queue',1
$result.=$head_tag_start.$body_tag_start;
$result.='<br />Review'.&show_queue('reviewqueue');
- $result.='<br />Before'.&show_queue('gradingqueue');
+ $result.='<br />Grade'.&show_queue('gradingqueue');
}
- if (defined($env{'form.reviewasubmission'})) {
- $result.=&show_queue('reviewqueue',1);
- my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
- } else {
- my ($todo,$status_code)=&get_key_todo($target);
- if ($todo) {
- &setup_env_for_other_user($todo,$safeeval);
- my ($symb,$uname,$udom)=&decode_queue_key($todo);
- $result.="\n".'<table><tr><td>Found '.
- &Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.'</td></tr></table>';
- $result.='<input type="hidden" name="gradingkey" value="'.
- &Apache::lonnet::escape($todo).'" />';
- $Apache::bridgetask::queue_key=$todo;
- &Apache::structuretags::initialize_storage();
- &Apache::lonhomework::showhash(%Apache::lonhomework::history);
- if ($target eq 'webgrade') {
- $result.='<br />After'.&show_queue('gradingqueue');
- $result.="\n".'<table width="100%" style="width:100%" border="1">';
+ # FIXME Blast! still need to reorg this, need to reshow the
+ # queue being reviewed once done with the grade pass...
+ # Hrrm, vaildation pass should perhaps say 'not_locked'
+ # perhaps do a search if there is a key that is mine and if
+ # there isn't reshow the queue....
+ my ($todo,$status_code)=&get_key_todo($target);
+
+ &Apache::lonnet::logthis("got todo -$todo- stat -$status_code-");
+ if ($todo) {
+ &setup_env_for_other_user($todo,$safeeval);
+ my ($symb,$uname,$udom)=&decode_queue_key($todo);
+ $result.="\n".'<table><tr><td>Found '.
+ &Apache::lonnet::gettitle($symb).' for '.$uname.' at '.$udom.'</td></tr></table>';
+ $form_tag_start.=
+ '<input type="hidden" name="gradingkey" value="'.
+ &Apache::lonnet::escape($todo).'" />';
+ $Apache::bridgetask::queue_key=$todo;
+ &Apache::structuretags::initialize_storage();
+ &Apache::lonhomework::showhash(%Apache::lonhomework::history);
+ if ($target eq 'webgrade') {
+ $result.='<br />After -'.&show_queue($env{'form.queue'});
+ $result.="\n".'<table width="100%" style="width:100%" border="1">';
+ if ($status_code eq 'selected') {
+ $form_tag_start.=
+ '<input type="hidden" name="queuemode" value="selected" />';
}
- } else {
- if ($target eq 'webgrade') {
- $result.="\n".'<table><tr><td><b>';
- if ($status_code eq 'stop') {
- $result.=&mt("Stopped grading.");
- } elsif ($status_code eq 'lock_failed') {
- $result.=&mt("Failed to lock the request record.");
- } elsif ($status_code eq 'unlock') {
- $result.=&mt("Unlocked the requested user.");
- } else {
- $result.=&mt("No user to be graded.");
- }
- $result.='</b></td></tr></table>';
+ }
+ } else {
+ if ($target eq 'webgrade') {
+ $result.="\n";
+ if ($status_code eq 'stop') {
+ $result.='<b>'.&mt("Stopped grading.").'</b>';
+ } elsif ($status_code eq 'lock_failed') {
+ $result.='<b>'.&mt("Failed to lock the request record.").'</b>';
+ } elsif ($status_code eq 'unlock') {
+ $result.='<b>'.&mt("Unlocked the requested record.").'</b>';
+ $result.=&show_queue($env{'form.queue'},1);
+ } elsif ($status_code eq 'show_list') {
+ $result.=&show_queue($env{'form.queue'},1);
+ } else {
+ $result.='<b>'.&mt("No user to be graded.").'</b>';
}
- $webgrade='no';
- my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
}
+ $webgrade='no';
+ my $bodytext=&Apache::lonxml::get_all_text("/task",$parser);
}
if ($target eq 'webgrade' && defined($env{'form.queue'})) {
$result.=$form_tag_start;
@@ -333,36 +343,73 @@
sub get_key_todo {
my ($target)=@_;
my $todo;
+
+ if (defined($env{'form.reviewasubmission'})) {
+ &Apache::lonnet::logthis("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');
+ }
+
my $queue=$env{'form.queue'};
+
if (!defined($queue)) {
$env{'form.queue'}=$queue='gradingqueue';
}
+
my $gradingkey=&Apache::lonnet::unescape($env{'form.gradingkey'});
+
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);
+ 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');
+ } 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 end_Task {
@@ -442,12 +489,21 @@
$env{'user.name'}.'@'.$env{'user.domain'};
if ($review) {
$Apache::lonhomework::results{"resource.$version.status"}='review';
- # FIXME won't work well when already in review queues
- &move_between_queues('gradingqueue','reviewqueue');
+ if ($env{'form.queue'} eq 'reviewqueue') {
+ &check_queue_unlock($env{'form.queue'});
+ &Apache::lonxml::debug(" still needs review not changing status.");
+ } else {
+ &move_between_queues('gradingqueue','reviewqueue');
+ }
} elsif ($ungraded) {
$Apache::lonhomework::results{"resource.$version.status"}='ungraded';
# FIXME if in review queue need to move back to grading queue
- &check_queue_unlock($env{'form.queue'});
+ if ($env{'form.queue'} eq 'reviewqueue') {
+ &Apache::lonxml::debug("moving back.");
+ &move_between_queues('reviewqueue','gradingqueue');
+ } else {
+ &check_queue_unlock($env{'form.queue'});
+ }
} elsif ($mandatory_failed) {
$Apache::lonhomework::results{"resource.$version.status"}='fail';
$Apache::lonhomework::results{"resource.$version.0.solved"}='incorrect_by_override';
@@ -518,7 +574,7 @@
if ($who eq $me) {
return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
} elsif ($allow_not_me) {
- &Apache::lonnet::logthis("unlocking $who by $me");
+ &Apache::lonxml::debug("unlocking $who by $me");
return &Apache::lonnet::del($queue,["$key\0locked"],$cdom,$cnum);
}
return 'not_owner';
@@ -578,9 +634,9 @@
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>";
+ return "\n<h3>Current Queue - $queue</h3><table border='1'><tr><td>Empty</td></tr></table>";
}
- $result.="\n<h3>Current Queue</h3><table border='1'><tr>";
+ $result.="\n<h3>Current Queue - $queue </h3><table border='1'><tr>";
if ($with_selects) { $result.="<th></th>"; }
$result.="<th>resource</th><th>user</th><th>type</th><th>data</th></tr>";
foreach my $key (sort(keys(%queue))) {
@@ -617,6 +673,7 @@
<input type="hidden" name="queue" value="$queue" />
<input type="hidden" name="gradingaction" value="$action" />
<input type="hidden" name="webgrade" value="no" />
+ <input type="hidden" name="queuemode" value="selected" />
<input type="submit" name="submit" value="$description" />
</form>
</td>
@@ -643,6 +700,11 @@
sub queue_key_locked {
my ($queue,$key,$cdom,$cnum)=@_;
+ if (!defined($cdom) || !defined($cnum)) {
+ my (undef,$cid)=&Apache::lonxml::whichuser();
+ $cnum=$env{'course.'.$cid.'.num'};
+ $cdom=$env{'course.'.$cid.'.domain'};
+ }
my ($key_locked,$value)=
&Apache::lonnet::get($queue,["$key\0locked"],$cdom,$cnum);
if ($key_locked eq "$key\0locked") {
@@ -658,18 +720,18 @@
if ($check_section) {
my $section=&Apache::lonnet::getsection($uname,$udom);
if ($section eq $check_section) {
- &Apache::lonnet::logthis("my sec");
+ &Apache::lonxml::debug("my sec");
next;
}
}
my $slot=$queuedata->{$key}[0];
my %slot_data=&Apache::lonnet::get_slot($slot);
if ($slot_data{'endtime'} > time) {
- &Apache::lonnet::logthis("not time");
+ &Apache::lonxml::debug("not time");
next;
}
if (&queue_key_locked($queue,$key,$cdom,$cnum)) {
- &Apache::lonnet::logthis("someone already has um.");
+ &Apache::lonxml::debug("someone already has um.");
next;
}
return $key;
@@ -706,7 +768,7 @@
my $cdom=$env{'course.'.$cid.'.domain'};
my $success=&Apache::lonnet::newput($queue,{"$todo\0locked"=> $me},
$cdom,$cnum);
- &Apache::lonnet::logthis("success $success $todo");
+ &Apache::lonxml::debug("success $success $todo");
if ($success eq 'ok') {
return 1;
}
@@ -720,39 +782,40 @@
my $cnum=$env{'course.'.$cid.'.num'};
my $cdom=$env{'course.'.$cid.'.domain'};
my $todo=&find_mid_grade($queue,$symb,$cdom,$cnum);
- &Apache::lonnet::logthis("found ".join(':',&decode_queue_key($todo)));
+ &Apache::lonxml::debug("found ".join(':',&decode_queue_key($todo)));
if ($todo) { return $todo; }
while (1) {
my $starttime=time;
&Apache::lonnet::put($queue,{"$symb\0timestamp"=>$starttime},
$cdom,$cnum);
- &Apache::lonnet::logthis("$starttime");
+ &Apache::lonxml::debug("$starttime");
my $regexp="^$symb\0queue\0";
my %queue=&Apache::lonnet::dump($queue,$cdom,$cnum,$regexp);
- #make a pass looking for a user in my section
+ #make a pass looking for a user _not_ in my section
if ($env{'request.course.sec'}) {
- &Apache::lonnet::logthis("sce");
+ &Apache::lonxml::debug("sce");
$todo=&pick_from_queue_data($queue,$env{'request.course.sec'},
\%queue,$cdom,$cnum);
- &Apache::lonnet::logthis("sce $todo");
+ &Apache::lonxml::debug("sce $todo");
}
- # no one in our section so look for any user that is ready for grading
+ # no one _not_ in our section so look for any user that is
+ # ready for grading
if (!$todo) {
- &Apache::lonnet::logthis("no sce");
+ &Apache::lonxml::debug("no sce");
$todo=&pick_from_queue_data($queue,$env{'request.course.sec'},
\%queue,$cdom,$cnum);
- &Apache::lonnet::logthis("no sce $todo");
+ &Apache::lonxml::debug("no sce $todo");
}
# no user to grade
if (!$todo) { last; }
- &Apache::lonnet::logthis("got $todo");
+ &Apache::lonxml::debug("got $todo");
# otherwise found someone so lets try to lock them
# unless someone else already picked them
if (!&lock_key($queue,$todo)) { next; }
my (undef,$endtime)=
&Apache::lonnet::get($queue,["$symb\0timestamp"],
$cdom,$cnum);
- &Apache::lonnet::logthis("emd $endtime");
+ &Apache::lonxml::debug("emd $endtime");
# someone else already modified the queue,
# perhaps our picked user wass already fully graded between
# when we picked him and when we locked his record? so lets
@@ -761,16 +824,16 @@
my ($key,$value)=
&Apache::lonnet::get($queue,["$todo"],
$cdom,$cnum);
- &Apache::lonnet::logthis("check $key .. $value");
+ &Apache::lonxml::debug("check $key .. $value");
if ($key eq $todo && ref($value)) {
} else {
&Apache::lonnet::del($queue,["$todo\0locked"],
$cdom,$cnum);
- &Apache::lonnet::logthis("del");
+ &Apache::lonxml::debug("del");
next;
}
}
- &Apache::lonnet::logthis("last $todo");
+ &Apache::lonxml::debug("last $todo");
last;
}
return $todo;
--albertel1117228429--