--- loncom/homework/grades.pm 2009/05/06 16:19:26 1.569
+++ loncom/homework/grades.pm 2010/01/15 17:12:18 1.589
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.569 2009/05/06 16:19:26 bisitz Exp $
+# $Id: grades.pm,v 1.589 2010/01/15 17:12:18 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -97,9 +97,15 @@ sub ssi_print_error {
#
# --- Retrieve the parts from the metadata file.---
sub getpartlist {
- my ($symb) = @_;
+ my ($symb,$errorref) = @_;
my $navmap = Apache::lonnavmaps::navmap->new();
+ unless (ref($navmap)) {
+ if (ref($errorref)) {
+ $$errorref = 'navmap';
+ return;
+ }
+ }
my $res = $navmap->getBySymb($symb);
my $partlist = $res->parts();
my $url = $res->src();
@@ -144,9 +150,15 @@ sub nameUserString {
#--- Get the partlist and the response type for a given problem. ---
#--- Indicate if a response type is coded handgraded or not. ---
sub response_type {
- my ($symb) = shift;
+ my ($symb,$response_error) = @_;
my $navmap = Apache::lonnavmaps::navmap->new();
+ unless (ref($navmap)) {
+ if (ref($response_error)) {
+ $$response_error = 1;
+ }
+ return;
+ }
my $res = $navmap->getBySymb($symb);
my $partlist = $res->parts();
my %vPart =
@@ -183,7 +195,8 @@ sub get_display_part {
my ($partID,$symb)=@_;
my $display=&Apache::lonnet::EXT('resource.'.$partID.'.display',$symb);
if (defined($display) and $display ne '') {
- $display.= " (id $partID)";
+ $display.= ' ('
+ .&mt('Part ID: [_1]',$partID).')';
} else {
$display=$partID;
}
@@ -193,37 +206,49 @@ sub get_display_part {
#--- Show resource title
#--- and parts and response type
sub showResourceInfo {
- my ($symb,$probTitle,$checkboxes) = @_;
- my $col=3;
- if ($checkboxes) { $col=4; }
+ my ($symb,$probTitle,$checkboxes,$res_error) = @_;
my $result = '
'.&mt('Current Resource').': '.$probTitle.'
'."\n";
- $result .='
';
- my ($partlist,$handgrade,$responseType) = &response_type($symb);
+ my ($partlist,$handgrade,$responseType) = &response_type($symb,$res_error);
+ if (ref($res_error)) {
+ if ($$res_error) {
+ return;
+ }
+ }
+ $result.=&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table_header_row();
+ if ($checkboxes) {
+ $result.='
';
+ }
+ $result.='
'.&mt('Problem Part').'
'
+ .'
'.&mt('Res. ID').'
'
+ .'
'.&mt('Type').'
'
+ .&Apache::loncommon::end_data_table_header_row();
my %resptype = ();
my $hdgrade='no';
my %partsseen;
foreach my $partID (sort(keys(%$responseType))) {
- foreach my $resID (sort(keys(%{ $responseType->{$partID} }))) {
- my $handgrade=$$handgrade{$partID.'_'.$resID};
- my $responsetype = $responseType->{$partID}->{$resID};
- $hdgrade = $handgrade if ($handgrade eq 'yes');
- $result.='
';
- if ($checkboxes) {
- if (exists($partsseen{$partID})) {
- $result.="
'.
- &mt('The above receipt matches the following [numerate,_1,student].',$matches).
+ &mt('The above receipt number matches the following [quant,_1,student].',$matches).
'
'
+ .&Apache::loncommon::end_data_table_header_row()
+ );
+}
+
+sub gradeBox_end {
+ return (
+ &Apache::loncommon::end_data_table()
+ );
+}
#--- displays the grading box, used in essay type problem and grading by page/sequence
sub gradeBox {
my ($request,$symb,$uname,$udom,$counter,$partid,$record) = @_;
@@ -1696,7 +1749,7 @@ sub gradeBox {
if ($last_resets{$partid}) {
$aggtries = &get_num_tries($record,$last_resets{$partid},$partid);
}
- $result.='
';
+ $result.=&Apache::loncommon::start_data_table_row();
my $ctr = 0;
my $thisweight = 0;
my $increment = &get_increment();
@@ -1704,7 +1757,7 @@ sub gradeBox {
my $radio.='
'."\n"; # display radio buttons in a nice table 10 across
while ($thisweight<=$wgt) {
$radio.= '
\n";
$radio.=(($ctr+1)%10 == 0 ? '
' : '');
@@ -1715,13 +1768,13 @@ sub gradeBox {
my $line.=''."\n";
$line.='
KEYWORDS
@@ -2046,24 +2099,27 @@ KEYWORDS
}
my %record = &Apache::lonnet::restore($symb,$env{'request.course.id'},$udom,$uname);
- my ($partlist,$handgrade,$responseType) = &response_type($symb);
+ my $res_error;
+ my ($partlist,$handgrade,$responseType) = &response_type($symb,\$res_error);
+ if ($res_error) {
+ $request->print(&navmap_errormsg());
+ return;
+ }
# Display student info
$request->print(($counter == 0 ? '' : ' '));
my $result='
';
- $result.='
';
- $result.= &mt('Submissions');
+ $result.='
'
+ .'
'.&mt('Submissions').'
';
$result.=''."\n";
+ '" value="'.$env{'form.fullname'}.'" />'."\n";
if ($env{'form.handgrade'} eq 'no') {
- $result.=''.
- &mt('Part(s) graded correct by the computer is marked with a [_1] symbol.',$checkIcon)."\n";
-
+ $result.='
'
+ .&mt('Part(s) graded correct by the computer is marked with a [_1] symbol.',$checkIcon)
+ ."
\n";
}
-
-
# If any part of the problem is an essay-response (handgraded), then check for collaborators
my $fullname;
my $col_fullnames = [];
@@ -2074,9 +2130,9 @@ KEYWORDS
$result.=$sub_result;
}
$request->print($result."\n");
- $request->print('
'."\n");
+
# print student answer/submission
- # Options are (1) Handgaded submission only
+ # Options are (1) Handgraded submission only
# (2) Last submission, includes submission that is not handgraded
# (for multi-response type part)
# (3) Last submission plus the parts info
@@ -2086,10 +2142,10 @@ KEYWORDS
my $lastsubonly;
- if ($$timestamp eq '') {
- $lastsubonly.='
'.$$string[0].'
';
- } else {
- $lastsubonly = '
Date Submitted: '.$$timestamp."\n";
+ if ($$timestamp eq '') {
+ $lastsubonly.='
'.$$string[0].'
';
+ } else {
+ $lastsubonly = '
Date Submitted: '.$$timestamp."\n";
my %seenparts;
my @part_response_id = &flatten_responseType($responseType);
@@ -2113,9 +2169,11 @@ KEYWORDS
}
my $responsetype = $responseType->{$partid}->{$respid};
if (!exists($record{"resource.$partid.$respid.submission"})) {
- $lastsubonly.="\n".'
".
- &mt('Essay is [_1]% similar to an essay by [_2] ([_3]:[_4]) in course [_5] (course id [_6]:[_7])',
+ &mt('Essay is [_1]% similar to an essay by [_2] in course [_3] (course id [_4]:[_5])',
$osim,
- &Apache::loncommon::plainname($oname,$odom),
- $oname,$odom,
+ &Apache::loncommon::plainname($oname,$odom).' ('.$oname.':'.$odom.')',
$old_course_desc{'description'},
$old_course_desc{'num'},
$old_course_desc{'domain'}).
@@ -2152,9 +2209,11 @@ KEYWORDS
($env{'form.lastSub'} eq 'hdgrade' &&
$$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) {
my $display_part=&get_display_part($partid,$symb);
- $lastsubonly.='