[LON-CAPA-cvs] cvs: loncom /homework bridgetask.pm grades.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 20 Sep 2005 06:45:04 -0000
This is a MIME encoded message
--albertel1127198704
Content-Type: text/plain
albertel Tue Sep 20 02:45:04 2005 EDT
Modified files:
/loncom/homework bridgetask.pm grades.pm
Log:
- implement a quick regrade feature for BT
- fixes for blank grading
- mover the %perm handling in grades.pm to a couple of subroutines
--albertel1127198704
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20050920024504.txt"
Index: loncom/homework/bridgetask.pm
diff -u loncom/homework/bridgetask.pm:1.48 loncom/homework/bridgetask.pm:1.49
--- loncom/homework/bridgetask.pm:1.48 Wed Sep 14 17:03:48 2005
+++ loncom/homework/bridgetask.pm Tue Sep 20 02:45:02 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.48 2005/09/14 21:03:48 albertel Exp $
+# $Id: bridgetask.pm,v 1.49 2005/09/20 06:45:02 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -158,6 +158,8 @@
$result.='<p>'.&mt("Review Queue has [_1] entries. [_2] of them are ready to be graded and [_3] of them are currently being graded",$entries,$ready,$locks);
$result.=' <input type="submit" name="reviewasubmission" value="'.
&mt("Select an entry from the review queue").'" /> </p>'."\n";
+ $result.=' <input type="submit" name="regradeasubmission" value="'.
+ &mt("Select a user to regrade.").'" /> </p>'."\n";
}
return $result;
}
@@ -311,8 +313,8 @@
my $webgrade='yes';
if ($target eq 'webgrade') {
$result.=$head_tag_start.$body_tag_start;
- $result.='<br />Review'.&show_queue('reviewqueue');
- $result.='<br />Grade'.&show_queue('gradingqueue');
+ #$result.='<br />Review'.&show_queue('reviewqueue');
+ #$result.='<br />Grade'.&show_queue('gradingqueue');
}
# FIXME Blast! still need to reorg this, need to reshow the
# queue being reviewed once done with the grade pass...
@@ -334,7 +336,7 @@
&Apache::structuretags::initialize_storage();
&Apache::lonhomework::showhash(%Apache::lonhomework::history);
if ($target eq 'webgrade') {
- $result.='<br />After -'.&show_queue($env{'form.queue'});
+ #$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.=
@@ -353,6 +355,8 @@
$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.='<b>'.&mt("No user to be graded.").'</b>';
}
@@ -390,6 +394,12 @@
return (undef,'show_list');
}
+ if (defined($env{'form.regradeasubmission'})) {
+ &Apache::lonxml::debug("regrade a grading....");
+ $env{'form.queue'}='none';
+ return (undef,'select_user');
+ }
+
my $queue=$env{'form.queue'};
if (!defined($queue)) {
@@ -398,6 +408,20 @@
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,'show_list');
+ }
+ }
+ return ($gradingkey,'selected');
+ } else {
+ return (undef,'show_list');
+ }
+ }
if (defined($env{'form.queue'}) && defined($env{'form.gradingkey'})
&& !defined($env{'form.gradingaction'})
&& $env{'form.queuemode'} eq 'selected') {
@@ -516,7 +540,9 @@
$ungraded++;
} elsif ($status eq 'review') {
$review++;
- }
+ } else {
+ $ungraded++;
+ }
}
if ($optional_passed < $optional_required) {
$mandatory_failed++;
@@ -530,13 +556,14 @@
&check_queue_unlock($env{'form.queue'});
&Apache::lonxml::debug(" still needs review not changing status.");
} else {
- &move_between_queues('gradingqueue','reviewqueue');
+ &move_between_queues($env{'form.queue'},'reviewqueue');
}
} elsif ($ungraded) {
$Apache::lonhomework::results{"resource.$version.status"}='ungraded';
- if ($env{'form.queue'} eq 'reviewqueue') {
+ if ($env{'form.queue'} eq 'reviewqueue' ||
+ $env{'form.queue'} eq 'none' ) {
&Apache::lonxml::debug("moving back.");
- &move_between_queues('reviewqueue','gradingqueue');
+ &move_between_queues($env{'form.queue'},'gradingqueue');
} else {
&check_queue_unlock($env{'form.queue'});
}
@@ -605,8 +632,13 @@
sub move_between_queues {
my ($src_queue,$dest_queue)=@_;
- my $cur_data=&get_queue_data($src_queue);
- if (!$cur_data) { return 'not_exist'; }
+ my $cur_data;
+ if ($src_queue ne 'none') {
+ $cur_data=&get_queue_data($src_queue);
+ if (!$cur_data) { return 'not_exist'; }
+ } else {
+ $cur_data = ['none'];
+ }
my $result=&add_to_queue($dest_queue,$cur_data->[0]);
if ($result ne 'ok') {
return $result;
@@ -617,6 +649,7 @@
sub check_queue_unlock {
my ($queue,$key,$allow_not_me)=@_;
+ if ($queue eq 'none') { return 'ok'; }
my ($symb,$cid,$udom,$uname)=&Apache::lonxml::whichuser();
if (!defined($key)) {
$key="$symb\0queue\0$uname\@$udom";
@@ -636,6 +669,7 @@
sub remove_from_queue {
my ($queue)=@_;
+ 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'};
@@ -668,8 +702,25 @@
return undef;
}
+sub check_queue_for_key {
+ my ($cid,$queue,$todo)=@_;
+ my $cnum=$env{'course.'.$cid.'.num'};
+ my $cdom=$env{'course.'.$cid.'.domain'};
+ my %results=
+ &Apache::lonnet::get($queue,[$todo,"$todo\0locked"],$cdom,$cnum);
+
+ if (exists($results{$todo}) && ref($results{$todo})) {
+ if (defined($results{"$todo\0locked"})) {
+ return 'locked';
+ }
+ return 'enqueued';
+ }
+ return undef;
+}
+
sub add_to_queue {
my ($queue,$slot_name)=@_;
+ 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'};
@@ -781,6 +832,11 @@
return ($entries,$ready_to_grade,$locks);
}
+sub encode_queue_key {
+ my ($symb,$udom,$uname)=@_;
+ return "$symb\0queue\0$uname\@$udom";
+}
+
sub decode_queue_key {
my ($key)=@_;
my ($symb,undef,$user) = split("\0",$key);
@@ -929,6 +985,87 @@
return $todo;
}
+sub select_user {
+ my ($symb,$cid)=&Apache::lonxml::whichuser();
+ my $result.='<table border="1">';
+
+ &Apache::grades::init_perm();
+ my ($classlist,$section,$fullname)=&Apache::grades::getclasslist('all',);
+ &Apache::grades::reset_perm();
+
+ 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 $queue = 'none';
+ if ($status{'reviewqueue'} eq 'enqueued') {
+ $queue = 'reviewqueue';
+ } elsif ($status{'gradingqueue'} eq 'enqueued') {
+ $queue = 'gradingqueue';
+ }
+ my $todo =
+ &Apache::lonnet::escape(&encode_queue_key($symb,$udom,$uname));
+ $result.=<<RESULT;
+<tr>
+ <td>
+ <form method="POST">
+ <input type="hidden" name="gradingkey" value="$todo" />
+ <input type="hidden" name="queue" value="$queue" />
+ <input type="hidden" name="webgrade" value="no" />
+ <input type="submit" name="submit" value="Regrade" />
+ </form>
+ <td>$fullname->{$student}</td>
+ <td>
+RESULT
+
+ if ($status{'status'} eq 'pass') {
+ $result .= '<font color="green">'.&mt('Passed').'</font>';
+ } elsif ($status{'status'} eq 'fail') {
+ $result .= '<font color="red">'.&mt('Failed').'</font>';
+ } elsif ($status{'status'} eq 'review') {
+ $result .= '<font color="blue">'.&mt('Under Review').'</font>';
+ } elsif ($status{'status'} eq 'ungraded') {
+ $result .= &mt('Ungraded');
+ } elsif ($status{'status'} ne '') {
+ $result .= '<font color="orange">'.&mt('Unknown Status').'</font>';
+ } else {
+ $result.=" ";
+ }
+ if ($status{'version'}) {
+ $result .= ' '.&mt('Version').' '.$status{'version'};
+ }
+ $result.= '</td><td>';
+ if ($status{'reviewqueue'} eq 'enqueued') {
+ $result .= &mt('Awaiting Review');
+ } elsif ($status{'reviewqueue'} eq 'locked') {
+ $result .= &mt('Under Review');
+ } elsif ($status{'gradingqueue'} eq 'enqueued') {
+ $result .= &mt('Awaiting Grading');
+ } elsif ($status{'gradingqueue'} eq 'locked') {
+ $result .= &mt('Being Graded');
+ } else {
+ $result.=" ";
+ }
+ $result.= '</td></tr>';
+ }
+ $result.='</table>';
+ return $result;
+}
+
+sub get_student_status {
+ my ($symb,$cid,$udom,$uname)=@_;
+ my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},
+ $udom,$uname);
+ 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));
+ return %status;
+}
+
sub start_ClosingParagraph {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
my $result;
@@ -1002,7 +1139,7 @@
} elsif ($status eq 'pass') {
$result.='<font color="green">'.&mt('Passed').'</font>';
} else {
- &Apache::lonxml::error("Student viewing a graded bridgetask was show a status of $status");
+ &Apache::lonxml::error("Student viewing a graded bridgetask was shown a status of $status");
}
$result.='</td></tr><tr><td>';
if ($Apache::lonhomework::history{"resource.$version.$dim.$instance.$id.comment"}) {
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.284 loncom/homework/grades.pm:1.285
--- loncom/homework/grades.pm:1.284 Tue Sep 13 15:05:15 2005
+++ loncom/homework/grades.pm Tue Sep 20 02:45:02 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.284 2005/09/13 19:05:15 albertel Exp $
+# $Id: grades.pm,v 1.285 2005/09/20 06:45:02 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -5449,10 +5449,32 @@
return $result;
}
+sub reset_perm {
+ undef(%perm);
+}
+
+sub init_perm {
+ &reset_perm();
+ if (!($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
+ if ($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+ $perm{'vgr_section'}=$env{'request.course.sec'};
+ } else {
+ delete($perm{'vgr'});
+ }
+ }
+ if (!($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}))) {
+ if ($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
+ $perm{'mgr_section'}=$env{'request.course.sec'};
+ } else {
+ delete($perm{'mgr'});
+ }
+ }
+}
+
sub handler {
my $request=$_[0];
- undef(%perm);
+ &reset_perm();
if ($env{'browser.mathml'}) {
&Apache::loncommon::content_type($request,'text/xml');
} else {
@@ -5501,20 +5523,7 @@
}
}
} else {
- if (!($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}))) {
- if ($perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
- $perm{'vgr_section'}=$env{'request.course.sec'};
- } else {
- delete($perm{'vgr'});
- }
- }
- if (!($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}))) {
- if ($perm{'mgr'}=&Apache::lonnet::allowed('mgr',$env{'request.course.id'}.'/'.$env{'request.course.sec'})) {
- $perm{'mgr_section'}=$env{'request.course.sec'};
- } else {
- delete($perm{'mgr'});
- }
- }
+ &init_perm();
if ($command eq 'submission' && $perm{'vgr'}) {
($env{'form.student'} eq '' ? &listStudents($request) : &submission($request,0,0));
} elsif ($command eq 'pickStudentPage' && $perm{'vgr'}) {
--albertel1127198704--