--- loncom/homework/grades.pm 2009/08/19 19:25:21 1.579
+++ loncom/homework/grades.pm 2010/01/15 16:41:43 1.588
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.579 2009/08/19 19:25:21 raeburn Exp $
+# $Id: grades.pm,v 1.588 2010/01/15 16:41:43 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 =
@@ -194,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) = @_;
@@ -1697,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();
@@ -1720,8 +1772,8 @@ sub gradeBox {
$wgt.')" />'."\n";
$line.='
';
return $result;
}
@@ -2047,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 = [];
@@ -2075,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
@@ -2087,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);
@@ -2178,7 +2233,7 @@ KEYWORDS
}
}
}
- $lastsubonly.='
'."\n";
+ $lastsubonly.='
'."\n"; # End: LC_grade_submissions_body
}
$request->print($lastsubonly);
} elsif ($env{'form.lastSub'} eq 'datesub') {
@@ -2240,11 +2295,11 @@ KEYWORDS
my @partlist;
my @gradePartRespid;
my @part_response_id = &flatten_responseType($responseType);
- $request->print('
'.
-
- '
'.
- &mt('Assign Grades').'
'.
- '
');
+ $request->print(
+ '
'
+ .'
'.&mt('Assign Grades').'
'
+ );
+ $request->print(&gradeBox_start()); #
foreach my $part_response_id (@part_response_id) {
my ($partid,$respid) = @{ $part_response_id };
my $part_resp = join('_',@{ $part_response_id });
@@ -2256,7 +2311,8 @@ KEYWORDS
push(@gradePartRespid,$partid.'.'.$respid);
$request->print(&gradeBox($request,$symb,$uname,$udom,$counter,$partid,\%record));
}
- $request->print('
');
+ $request->print(&gradeBox_end()); #
+ $request->print('
');
$request->print('
');
if ($perm{'vgr'}) {
@@ -2598,7 +2654,12 @@ sub processHandGrade {
}
$ctr = 0;
@parsedlist = reverse @parsedlist if ($button eq 'Previous');
- my ($partlist) = &response_type($symb);
+ my $res_error;
+ my ($partlist) = &response_type($symb,\$res_error);
+ if ($res_error) {
+ $request->print(&navmap_errormsg());
+ return;
+ }
foreach my $student (@parsedlist) {
my $submitonly=$env{'form.submitonly'};
my ($uname,$udom) = split(/:/,$student);
@@ -2796,8 +2857,12 @@ sub check_and_remove_from_queue {
sub handback_files {
my ($request,$symb,$stuname,$domain,$newflg,$new_part,$newrecord) = @_;
my $portfolio_root = '/userfiles/portfolio';
- 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;
+ }
my @part_response_id = &flatten_responseType($responseType);
foreach my $part_response_id (@part_response_id) {
my ($part_id,$resp_id) = @{ $part_response_id };
@@ -3255,7 +3320,11 @@ sub viewgrades {
$result.= '
'.$common_header.'
'.&Apache::loncommon::start_data_table();
#radio buttons/text box for assigning points for a section or class.
#handles different parts of a problem
- my ($partlist,$handgrade,$responseType) = &response_type($symb);
+ my $res_error;
+ my ($partlist,$handgrade,$responseType) = &response_type($symb,\$res_error);
+ if ($res_error) {
+ return &navmap_errormsg();
+ }
my %weight = ();
my $ctsparts = 0;
my %seen = ();
@@ -3315,7 +3384,11 @@ sub viewgrades {
&Apache::loncommon::start_data_table_header_row().
'
'.&mt('No.').'
'.
'
'.&nameUserString('header')."
\n";
- my (@parts) = sort(&getpartlist($symb));
+ my $partserror;
+ my (@parts) = sort(&getpartlist($symb,\$partserror));
+ if ($partserror) {
+ return &navmap_errormsg();
+ }
my (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
my @partids = ();
foreach my $part (@parts) {
@@ -3474,7 +3547,11 @@ sub editgrades {
my %columns = ();
my ($i,$ctr,$count,$rec_update) = (0,0,0,0);
- my (@parts) = sort(&getpartlist($symb));
+ my $partserror;
+ my (@parts) = sort(&getpartlist($symb,\$partserror));
+ if ($partserror) {
+ return &navmap_errormsg();
+ }
my $header;
while ($ctr < $env{'form.totalparts'}) {
my $partid = $env{'form.partid_'.$ctr};
@@ -3806,8 +3883,14 @@ ENDPICK
}
sub csvupload_fields {
- my ($symb) = @_;
- my (@parts) = &getpartlist($symb);
+ my ($symb,$errorref) = @_;
+ my (@parts) = &getpartlist($symb,$errorref);
+ if (ref($errorref)) {
+ if ($$errorref) {
+ return;
+ }
+ }
+
my @fields=(['ID','Student/Employee ID'],
['username','Student Username'],
['domain','Student Domain']);
@@ -3907,8 +3990,12 @@ sub csvuploadmap {
&csvuploadmap_header($request,$symb,$datatoken,$#records+1);
my ($i,$keyfields);
if (@records) {
- my @fields=&csvupload_fields($symb);
-
+ my $fieldserror;
+ my @fields=&csvupload_fields($symb,\$fieldserror);
+ if ($fieldserror) {
+ $request->print(&navmap_errormsg());
+ return;
+ }
if ($env{'form.upfile_associate'} eq 'reverse') {
&Apache::loncommon::csv_print_samples($request,\@records);
$i=&Apache::loncommon::csv_print_select_table($request,\@records,
@@ -4144,7 +4231,12 @@ LISTJAVASCRIPT
&mt('Manual Grading by Page or Sequence').'';
$result.='