--- loncom/homework/grades.pm 2013/12/06 14:19:49 1.709 +++ loncom/homework/grades.pm 2013/12/20 17:18:42 1.710 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Grading handler # -# $Id: grades.pm,v 1.709 2013/12/06 14:19:49 bisitz Exp $ +# $Id: grades.pm,v 1.710 2013/12/20 17:18:42 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -8688,23 +8688,30 @@ sub scantron_upload_scantron_data_save { } my %coursedata=&Apache::lonnet::coursedescription($env{'form.domainid'}.'_'.$env{'form.courseid'}); my $uploadedfile; - $r->print('

'.&mt("Uploading file to [_1]",$coursedata{'description'}).'

'); + $r->print('

'.&mt('Uploading file to [_1]','"'.$coursedata{'description'}.'"').'

'); if (length($env{'form.upfile'}) < 2) { - $r->print(&mt('[_1]Error:[_2] The file you attempted to upload, [_3] contained no information. Please check that you entered the correct filename.','','',''.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').'')); + $r->print( + &Apache::lonhtmlcommon::confirm_success( + &mt('The file: [_1] you attempted to upload contained no information. Please check that you entered the correct filename.', + ''.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').''),1)); } else { my $result = &Apache::lonnet::userfileupload('upfile','','scantron','','','', $env{'form.courseid'},$env{'form.domainid'}); - if ($result =~ m{^/uploaded/}) { - $r->print(&mt('[_1]Success:[_2] Successfully uploaded [_3] bytes of data into location: [_4]', - '','',(length($env{'form.upfile'})-1), - ''.$result.'')); + if ($result =~ m{^/uploaded/}) { + $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('Upload successful')).'
'. + &mt('Uploaded [_1] bytes of data into location: [_2]', + (length($env{'form.upfile'})-1), + ''.$result.'')); ($uploadedfile) = ($result =~ m{/([^/]+)$}); $r->print(&validate_uploaded_scantron_file($env{'form.domainid'}, $env{'form.courseid'},$uploadedfile)); - } else { - $r->print(&mt('[_1]Error:[_2] An error ([_3]) occurred when attempting to upload the file, [_4]', - '','',$result, + } else { + $r->print( + &Apache::lonhtmlcommon::confirm_success(&mt('Upload failed'),1).'
'. + &mt('An error ([_1]) occurred when attempting to upload the file: [_2]', + $result, ''.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').'')); } } @@ -8726,7 +8733,7 @@ sub validate_uploaded_scantron_file { my $output; if (@lines) { my (%counts,$max_match_format); - my ($max_match_count,$max_match_pct) = (0,0); + my ($found_match_count,$max_match_count,$max_match_pct) = (0,0,0); my $classlist = &Apache::loncoursedata::get_classlist($cdom,$cname); my %idmap = &username_to_idmap($classlist); foreach my $key (keys(%idmap)) { @@ -8769,6 +8776,7 @@ sub validate_uploaded_scantron_file { if (($max_match_format eq '') || ($percent_match > $max_match_pct)) { $max_match_pct = $percent_match; $max_match_format = $key; + $found_match_count = $counts{$key}{'found'}; $max_match_count = $counts{$key}{'total'}; } } @@ -8787,17 +8795,40 @@ sub validate_uploaded_scantron_file { } } my $showpct = sprintf("%.0f",$max_match_pct).'%'; - $output .= '
'.&mt('Comparison of student IDs in the uploaded file with the course roster found matches for [_1] of the [_2] entries in the file (for the format defined for [_3]).',''.$showpct.'',''.$max_match_count.'',$format_descs). - '
'.&mt('A low percentage of matches results from one of the following:').''; + $output .= '
'; + if ($found_match_count == $max_match_count) { + # 100% matching entries + $output .= &Apache::lonhtmlcommon::confirm_success( + &mt('Comparison of student IDs: [_1] matching ([quant,_2,entry,entries])', + ''.$showpct.'',$found_match_count)).'
'. + &mt('Comparison of student IDs in the uploaded file with'. + ' the course roster found matches for [_1] of the [_2] entries'. + ' in the file (for the format defined for [_3]).', + ''.$showpct.'',''.$max_match_count.'',$format_descs); + } else { + # Not all entries matching? -> Show warning and additional info + $output .= + &Apache::lonhtmlcommon::confirm_success( + &mt('Comparison of student IDs: [_1] matching ([_2]/[quant,_3,entry,entries])', + ''.$showpct.'',$found_match_count,$max_match_count).'
'. + &mt('Not all entries could be matched!'),1).'
'. + &mt('Comparison of student IDs in the uploaded file with'. + ' the course roster found matches for [_1] of the [_2] entries'. + ' in the file (for the format defined for [_3]).', + ''.$showpct.'',''.$max_match_count.'',$format_descs). + '

'. + &mt('A low percentage of matches results from one of the following:'). + '

'; + } } } else { - $output = ''.&mt('Uploaded file contained no data').''; + $output = '

'.&mt('Uploaded file contained no data').'

'; } return $output; } @@ -9712,16 +9743,18 @@ sub process_clicker_file { $number++; } $result.="

\n"; - if ($number==0) { - $result.=''.&mt('No IDs found to determine correct answer').''; - return $result; - } + if ($number==0) { + $result .= + &Apache::lonhtmlcommon::confirm_success( + &mt('No IDs found to determine correct answer'),1); + return $result; + } } if (length($env{'form.upfile'}) < 2) { - $result.=&mt('[_1] Error: [_2] The file you attempted to upload, [_3] contained no information. Please check that you entered the correct filename.', - '', - '', - ''.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').''); + $result .= + &Apache::lonhtmlcommon::confirm_success( + &mt('The file: [_1] you attempted to upload contained no information. Please check that you entered the correct filename.', + ''.&HTML::Entities::encode($env{'form.upfile.filename'},'<>&"').''),1); return $result; }