--- loncom/homework/grades.pm 2009/06/06 19:23:30 1.578 +++ loncom/homework/grades.pm 2010/01/27 06:26:55 1.591 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.578 2009/06/06 19:23:30 raeburn Exp $ +# $Id: grades.pm,v 1.591 2010/01/27 06:26:55 raeburn 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.='' + .'' + .'' + .&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.=""; - } else { - $result.=""; - } - $partsseen{$partID}=1; - } - my $display_part=&get_display_part($partID,$symb); - $result.=''. - ''; -# ''; - } + foreach my $resID (sort(keys(%{ $responseType->{$partID} }))) { + my $handgrade=$$handgrade{$partID.'_'.$resID}; + my $responsetype = $responseType->{$partID}->{$resID}; + $hdgrade = $handgrade if ($handgrade eq 'yes'); + $result.=&Apache::loncommon::start_data_table_row(); + if ($checkboxes) { + if (exists($partsseen{$partID})) { + $result.=""; + } else { + $result.=""; + } + $partsseen{$partID}=1; + } + my $display_part=&get_display_part($partID,$symb); + $result.='' + .'' + .'' +# .'' + .&Apache::loncommon::end_data_table_row(); + } } - $result.='
 '.&mt('Problem Part').''.&mt('Res. ID').''.&mt('Type').'
 '.&mt('Part: [_1]',$display_part).''. - ' '.$resID.''.&mt('Type: [_1]',$responsetype).'
'.&mt('Handgrade: [_1]',$handgrade).'
 '.$display_part.''.''.$resID.''.&mt($responsetype).''.&mt('Handgrade: [_1]',$handgrade).'
'."\n"; + $result.=&Apache::loncommon::end_data_table(); return $result,$responseType,$hdgrade,$partlist,$handgrade; } @@ -755,7 +779,7 @@ sub verifyreceipt { my $title.= '

'. - &mt('Verifying Receipt No. [_1]',$receipt). + &mt('Verifying Receipt No. [_1]',$receipt). '

'."\n". '

'.&mt('Resource: [_1]',$env{'form.probTitle'}). '

'."\n"; @@ -767,7 +791,13 @@ sub verifyreceipt { if ($env{"course.$courseid.receiptalg"} eq 'receipt2' || $env{"course.$courseid.receiptalg"} eq 'receipt3') { $receiptparts=1; } my $parts=['0']; - if ($receiptparts) { ($parts)=&response_type($symb); } + if ($receiptparts) { + my $res_error; + ($parts)=&response_type($symb,\$res_error); + if ($res_error) { + return &navmap_errormsg(); + } + } my $header = &Apache::loncommon::start_data_table(). @@ -809,11 +839,14 @@ sub verifyreceipt { } } if ($matches == 0) { - $string = $title.&mt('No match found for the above receipt.'); + $string = $title + .'

' + .&mt('No match found for the above receipt number.') + .'

'; } else { $string = &jscriptNform($symb).$title. '

'. - &mt('The above receipt matches the following [numerate,_1,student].',$matches). + &mt('The above receipt number matches the following [quant,_1,student].',$matches). '

'. $header. $contents. @@ -960,8 +993,8 @@ LISTJAVASCRIPT # checkall buttons $gradeTable.=&check_script('gradesub', 'stuinfo'); $gradeTable.='
'."\n"; + 'onclick="javascript:checkSelect(this.form.stuinfo);" '."\n". + 'value="'.&mt('Next').' →" />
'."\n"; $gradeTable.=&check_buttons(); my ($classlist, undef, $fullname) = &getclasslist($getsec,'1',$getgroup); $gradeTable.= &Apache::loncommon::start_data_table(). @@ -1078,9 +1111,9 @@ LISTJAVASCRIPT } $gradeTable.=&Apache::loncommon::end_data_table()."\n". - ''."\n"; + ''."\n"; if ($ctr == 0) { my $num_students=(scalar(keys(%$fullname))); if ($num_students eq 0) { @@ -1584,8 +1617,8 @@ INNERJS pDoc = pWin.document; pDoc.write("<\\/table>"); pDoc.write("<\\/td><\\/tr><\\/table> "); - pDoc.write("  "); - pDoc.write("

"); + pDoc.write("  "); + pDoc.write("

"); pDoc.write("<\\/form>"); pDoc.write('$end_page_msg_central'); pDoc.close(); @@ -1658,8 +1691,8 @@ INNERJS var hDoc = hwdWin.document; hDoc.write("<\\/table>"); hDoc.write("<\\/td><\\/tr><\\/table> "); - hDoc.write("  "); - hDoc.write("

"); + hDoc.write("  "); + hDoc.write("

"); hDoc.write("<\\/form>"); hDoc.write('$end_page_highlight_central'); hDoc.close(); @@ -1678,6 +1711,25 @@ sub get_increment { return $increment; } +sub gradeBox_start { + return ( + &Apache::loncommon::start_data_table() + .&Apache::loncommon::start_data_table_header_row() + .''.&mt('Part').'' + .''.&mt('Points').'' + .' ' + .''.&mt('Assign Grade').'' + .''.&mt('Weight').'' + .''.&mt('Grade Status').'' + .&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(); @@ -1705,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 ? '' : ''); @@ -1716,13 +1768,13 @@ sub gradeBox { my $line.=''."\n"; $line.=''."\n"; + $line.='',$display_part,$radio,$line); $result .= - ''. - - $result.='
/'.$wgt.' '.$wgtmsg. ($$record{'resource.'.$partid.'.solved'} eq 'correct_by_student' ? ' '.$checkIcon : ''). - ' '.&mt('Grade Status').':'."\n"; - $line.='Part:[_1]Points:[_2]or[_3]'.&mt('Part:').''.$display_part.''.&mt('Points:').''.$radio.''.&mt('or').''.$line.'
'."\n"; + ''.$display_part.''.$radio.''.&mt('or').''.$line.''; + $result.=&Apache::loncommon::end_data_table_row(); $result.=''."\n". ''."\n". ''."\n". ''."\n"; - $result.=&handback_box($symb,$uname,$udom,$counter,$partid,$record); + my $res_error; + $result.=&handback_box($symb,$uname,$udom,$counter,$partid,$record,\$res_error); + if ($res_error) { + return &navmap_errormsg(); + } return $result; } sub handback_box { - my ($symb,$uname,$udom,$counter,$partid,$record) = @_; - my ($partlist,$handgrade,$responseType) = &response_type($symb); + my ($symb,$uname,$udom,$counter,$partid,$record,$res_error) = @_; + my ($partlist,$handgrade,$responseType) = &response_type($symb,$res_error); my (@respids); my @part_response_id = &flatten_responseType($responseType); foreach my $part_response_id (@part_response_id) { @@ -1814,26 +1869,23 @@ sub show_problem { $companswer=~s|name="submit"|name="would_have_been_submit"|g; } $rendered= - '
'. - &mt('View of the problem'). - '
'. - $rendered. - '
'; + '
' + .'

'.&mt('View of the problem').'

' + .$rendered + .'
'; $companswer= - '
'. - &mt('Correct answer'). - '
'. - $companswer. - '
'; + '
' + .'

'.&mt('Correct answer').'

' + .$companswer + .'
'; my $result; if ($mode eq 'both') { - $result=$rendered.$companswer; + $result=$rendered.$companswer; } elsif ($mode eq 'text') { - $result=$rendered; + $result=$rendered; } elsif ($mode eq 'answer') { - $result=$companswer; + $result=$companswer; } - $result='
'.$result.'
'; return $result; } @@ -2011,7 +2063,7 @@ sub submission { $request->print(<Keyword Options:  List    -Paste Selection to List    Highlight Attribute

KEYWORDS @@ -2047,24 +2099,26 @@ 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'); + + my $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 +2129,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 +2141,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 +2232,7 @@ KEYWORDS } } } - $lastsubonly.='
'."\n"; + $lastsubonly.='
'."\n"; # End: LC_grade_submissions_body } $request->print($lastsubonly); } elsif ($env{'form.lastSub'} eq 'datesub') { @@ -2196,7 +2250,7 @@ KEYWORDS # return if view submission with no grading option if ($env{'form.showgrading'} eq '' || (!&canmodify($usec))) { my $toGrade.='  '."\n" if (&canmodify($usec)); $toGrade.='
'."\n"; if (($env{'form.command'} eq 'submission') || @@ -2240,11 +2294,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 +2310,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('