--- loncom/homework/grades.pm 2013/05/10 12:48:48 1.687 +++ loncom/homework/grades.pm 2013/08/29 12:39:13 1.705 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.687 2013/05/10 12:48:48 raeburn Exp $ +# $Id: grades.pm,v 1.705 2013/08/29 12:39:13 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -736,7 +736,7 @@ sub most_similar { sub initialverifyreceipt { my ($request,$symb) = @_; &commonJSfunctions($request); - return '
'. + return ''. &Apache::lonnet::recprefix($env{'request.course.id'}). '-'. ''."\n". @@ -908,17 +908,17 @@ LISTJAVASCRIPT $submission_options.= ''. ''."\n". + &mt('last submission').' '."\n". ''. ''."\n". + &mt('last submission with details').' '."\n". ''. ''."\n". + &mt('all submissions').''."\n". ''. ''; - $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('Submissions')) + &mt('all submissions with details').''; + $gradeTable .= &Apache::lonhtmlcommon::row_title(&mt('View Submissions')) .$submission_options .&Apache::lonhtmlcommon::row_closure(); @@ -1702,7 +1702,7 @@ sub gradeBox { $wgt = ($wgt > 0 ? $wgt : '1'); my $score = ($$record{'resource.'.$partid.'.awarded'} eq '' ? '' : &compute_points($$record{'resource.'.$partid.'.awarded'},$wgt)); - my $result=''."\n"; + my $data_WGT=''."\n"; my $display_part= &get_display_part($partid,$symb); my %last_resets = &get_last_resets($symb,$env{'request.course.id'}, [$partid]); @@ -1710,7 +1710,7 @@ sub gradeBox { if ($last_resets{$partid}) { $aggtries = &get_num_tries($record,$last_resets{$partid},$partid); } - $result.=&Apache::loncommon::start_data_table_row(); + my $result=&Apache::loncommon::start_data_table_row(); my $ctr = 0; my $thisweight = 0; my $increment = &get_increment(); @@ -1747,8 +1747,9 @@ sub gradeBox { $result .= - ''.$display_part.''.$radio.''.&mt('or').''.$line.''; + ''.$data_WGT.$display_part.''.$radio.''.&mt('or').''.$line.''; $result.=&Apache::loncommon::end_data_table_row(); + $result.=&Apache::loncommon::start_data_table_row().''; $result.=''."\n". ''."\n". ''."\n"; my $res_error; $result.=&handback_box($symb,$uname,$udom,$counter,$partid,$record,\$res_error); + $result.=''.&Apache::loncommon::end_data_table_row(); if ($res_error) { return &navmap_errormsg(); } @@ -1974,7 +1976,7 @@ sub submission { $request->print(&show_problem($request,$symb,$uname,$udom,0,1,$mode)); } - # kwclr is the only variable that is guaranteed to be non blank + # kwclr is the only variable that is guaranteed not to be blank # if this subroutine has been called once. my %keyhash = (); # if ($env{'form.kwclr'} eq '' && $env{'form.handgrade'} eq 'yes') { @@ -2051,7 +2053,7 @@ sub submission {
$lt{'keyw'}:  $lt{'list'}    $lt{'past'}    + class="page">$lt{'past'}    $lt{'high'}

KEYWORDS # @@ -2137,137 +2139,146 @@ KEYWORDS $result.=$sub_result; } $request->print($result."\n"); - + # print student answer/submission # 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 # (4) The whole record for this student - if ($env{'form.lastSub'} =~ /^(lastonly|hdgrade)$/) { - my ($string,$timestamp)= &get_last_submission(\%record); + + my ($string,$timestamp)= &get_last_submission(\%record); - my $lastsubonly; + my $lastsubonly; - if ($$timestamp eq '') { - $lastsubonly.='
'.$$string[0].'
'; - } else { - $lastsubonly = - '
' - .''.&mt('Date Submitted:').' '.$$timestamp."\n"; - - my %seenparts; - my @part_response_id = &flatten_responseType($responseType); - foreach my $part (@part_response_id) { - next if ($env{'form.lastSub'} eq 'hdgrade' + if ($$timestamp eq '') { + $lastsubonly.='
'.$$string[0].'
'; + } else { + $lastsubonly = + '
' + .''.&mt('Date Submitted:').' '.$$timestamp."\n"; + + my %seenparts; + my @part_response_id = &flatten_responseType($responseType); + foreach my $part (@part_response_id) { + next if ($env{'form.lastSub'} eq 'hdgrade' && $$handgrade{$$part[0].'_'.$$part[1]} ne 'yes'); - my ($partid,$respid) = @{ $part }; - my $display_part=&get_display_part($partid,$symb); - if ($env{"form.$uname:$udom:$partid:submitted_by"}) { - if (exists($seenparts{$partid})) { next; } - $seenparts{$partid}=1; - my $submitby='Part: '.$display_part. - ' Collaborative submission by: '. - ''. - $$fullname{$env{"form.$uname:$udom:$partid:submitted_by"}}.'
'; - $request->print($submitby); - next; - } - my $responsetype = $responseType->{$partid}->{$respid}; - if (!exists($record{"resource.$partid.$respid.submission"})) { - $lastsubonly.="\n".'
'. - ''.&mt('Part: [_1]',$display_part).''. - ' '. - '('.&mt('Response ID: [_1]',$respid).')'. - '   '. - ''.&mt('Nothing submitted - no attempts.').'

'; - next; - } - foreach my $submission (@$string) { - my ($partid,$respid) = ($submission =~ /^resource\.([^\.]*)\.([^\.]*)\.submission/); - if (join('_',@{$part}) ne ($partid.'_'.$respid)) { next; } - my ($ressub,$hide,$subval) = split(/:/,$submission,3); - # Similarity check - my $similar=''; - my ($type,$trial,$rndseed); - if ($hide eq 'rand') { - $type = 'randomizetry'; - $trial = $record{"resource.$partid.tries"}; - $rndseed = $record{"resource.$partid.rndseed"}; - } - if($env{'form.checkPlag'}){ - my ($oname,$odom,$ocrsid,$oessay,$osim)= - &most_similar($uname,$udom,$symb,$subval); - if ($osim) { - $osim=int($osim*100.0); - my %old_course_desc = - &Apache::lonnet::coursedescription($ocrsid, - {'one_time' => 1}); - - if ($hide eq 'anon') { - $similar='
'.&mt("Essay was found to be similar to another essay submitted for this assignment.").'
'. - &mt('As the current submission is for an anonymous survey, no other details are available.').'

'; - } else { - $similar="

". - &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.')', + my ($partid,$respid) = @{ $part }; + my $display_part=&get_display_part($partid,$symb); + if ($env{"form.$uname:$udom:$partid:submitted_by"}) { + if (exists($seenparts{$partid})) { next; } + $seenparts{$partid}=1; + $request->print( + ''.&mt('Part: [_1]',$display_part).''. + ' '.&mt('Collaborative submission by: [_1]', + ''. + $$fullname{$env{"form.$uname:$udom:$partid:submitted_by"}}.''). + '
'); + next; + } + my $responsetype = $responseType->{$partid}->{$respid}; + if (!exists($record{"resource.$partid.$respid.submission"})) { + $lastsubonly.="\n".'
'. + ''.&mt('Part: [_1]',$display_part).''. + ' '. + '('.&mt('Response ID: [_1]',$respid).')'. + '   '. + ''.&mt('Nothing submitted - no attempts.').'

'; + next; + } + foreach my $submission (@$string) { + my ($partid,$respid) = ($submission =~ /^resource\.([^\.]*)\.([^\.]*)\.submission/); + if (join('_',@{$part}) ne ($partid.'_'.$respid)) { next; } + my ($ressub,$hide,$subval) = split(/:/,$submission,3); + # Similarity check + my $similar=''; + my ($type,$trial,$rndseed); + if ($hide eq 'rand') { + $type = 'randomizetry'; + $trial = $record{"resource.$partid.tries"}; + $rndseed = $record{"resource.$partid.rndseed"}; + } + if ($env{'form.checkPlag'}) { + my ($oname,$odom,$ocrsid,$oessay,$osim)= + &most_similar($uname,$udom,$symb,$subval); + if ($osim) { + $osim=int($osim*100.0); + my %old_course_desc = + &Apache::lonnet::coursedescription($ocrsid, + {'one_time' => 1}); + + if ($hide eq 'anon') { + $similar='
'.&mt("Essay was found to be similar to another essay submitted for this assignment.").'
'. + &mt('As the current submission is for an anonymous survey, no other details are available.').'

'; + } else { + $similar="

". + &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.')', $old_course_desc{'description'}, $old_course_desc{'num'}, $old_course_desc{'domain'}). '

'. &keywords_highlight($oessay). '

'; - } - } - } - my $order=&get_order($partid,$respid,$symb,$uname,$udom, - undef,$type,$trial,$rndseed); - if ($env{'form.lastSub'} eq 'lastonly' || - ($env{'form.lastSub'} eq 'hdgrade' && + } + } + } + my $order=&get_order($partid,$respid,$symb,$uname,$udom, + undef,$type,$trial,$rndseed); + if ($env{'form.lastSub'} eq 'lastonly' || $env{'form.lastSub'} eq 'datesub' || $env{'form.lastSub'} =~ /^(last|all)$/ || ($env{'form.lastSub'} eq 'hdgrade' && $$handgrade{$$part[0].'_'.$$part[1]} eq 'yes')) { - my $display_part=&get_display_part($partid,$symb); - $lastsubonly.='
'. - ''.&mt('Part: [_1]',$display_part).''. - ' '. - '('.&mt('Response ID: [_1]',$respid).')'. - '   '; - my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record); - if (@$files) { - if ($hide eq 'anon') { - $lastsubonly.='
'.&mt('[quant,_1,file] uploaded to this anonymous survey',scalar(@{$files})); - } else { - $lastsubonly.='
'.&mt('Like all files provided by users, this file may contain viruses').'
'; - foreach my $file (@$files) { - &Apache::lonnet::allowuploaded('/adm/grades',$file); - $lastsubonly.='
'.$file.''; - } - } - $lastsubonly.='
'; - } + my $display_part=&get_display_part($partid,$symb); + $lastsubonly.='
'. + ''.&mt('Part: [_1]',$display_part).''. + ' '. + '('.&mt('Response ID: [_1]',$respid).')'. + '   '; + my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record); + + if (@$files) { if ($hide eq 'anon') { - $lastsubonly.=''.&mt('Anonymous Survey').''; + $lastsubonly.='
'.&mt('[quant,_1,file] uploaded to this anonymous survey',scalar(@{$files})); } else { - $lastsubonly.=''.&mt('Submitted Answer:').' '. - &cleanRecord($subval,$responsetype,$symb,$partid, - $respid,\%record,$order,undef,$uname,$udom,$type,$trial,$rndseed); + $lastsubonly.='

'.''.&mt('Submitted Files:').'' + .'
'; + if(@$files == 1) { + $lastsubonly .= &mt('Like all files provided by users, this file may contain viruses!'); + } else { + $lastsubonly .= &mt('Like all files provided by users, these files may contain viruses!'); + } + $lastsubonly .= ''; + foreach my $file (@$files) { + &Apache::lonnet::allowuploaded('/adm/grades',$file); + $lastsubonly.='
'.$file.''; + } } - if ($similar) {$lastsubonly.="

$similar\n";} - $lastsubonly.='
'; - } + $lastsubonly.='
'; + } + if ($hide eq 'anon') { + $lastsubonly.='
'.&mt('Anonymous Survey').''; + } else { + $lastsubonly.='
'.&mt('Submitted Answer:').' '. + &cleanRecord($subval,$responsetype,$symb,$partid, + $respid,\%record,$order,undef,$uname,$udom,$type,$trial,$rndseed); + } + if ($similar) {$lastsubonly.="

$similar\n";} + $lastsubonly.='
'; } - } - $lastsubonly.='

'."\n"; # End: LC_grade_submissions_body + } } - $request->print($lastsubonly); - } elsif ($env{'form.lastSub'} eq 'datesub') { + $lastsubonly.='
'."\n"; # End: LC_grade_submissions_body + } + $request->print($lastsubonly); + if ($env{'form.lastSub'} eq 'datesub') { my ($parts,$handgrade,$responseType) = &response_type($symb,\$res_error); $request->print(&displaySubByDates($symb,\%record,$parts,$responseType,$checkIcon,$uname,$udom)); - } elsif ($env{'form.lastSub'} =~ /^(last|all)$/) { - $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom, + } + if ($env{'form.lastSub'} =~ /^(last|all)$/) { + $request->print(&Apache::loncommon::get_previous_attempt($symb,$uname,$udom, $env{'request.course.id'}, $last,'.submission', 'Apache::grades::keywords_highlight')); @@ -2300,10 +2311,10 @@ KEYWORDS ''."\n"; $result.=' '. - &mt('Compose message to student').(scalar(@$col_fullnames) >= 1 ? 's' : '').'