--- loncom/homework/grades.pm 2006/06/21 20:18:43 1.364
+++ loncom/homework/grades.pm 2006/09/14 17:52:22 1.374
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.364 2006/06/21 20:18:43 banghart Exp $
+# $Id: grades.pm,v 1.374 2006/09/14 17:52:22 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1551,15 +1551,18 @@ sub handback_box {
next if (!@$files);
my $file_counter = 1;
foreach my $file (@$files) {
- my ($file_path, $file_disp) = ($file =~ m|(.+/)(.+)$|);
- my ($name,$version,$ext) = &file_name_version_ext($file_disp);
- $file_disp = "$name.$ext";
- $file = $file_path.$file_disp;
- $result.=&mt('Return commented version of [_1] to student.',
- ''.$file_disp.'');
- $result.=''."\n";
- $result.=' ';
- $file_counter++;
+ if ($file =~ /\/portfolio\//) {
+ my ($file_path, $file_disp) = ($file =~ m|(.+/)(.+)$|);
+ my ($name,$version,$ext) = &file_name_version_ext($file_disp);
+ $file_disp = "$name.$ext";
+ $file = $file_path.$file_disp;
+ $result.=&mt('Return commented version of [_1] to student.',
+ ''.$file_disp.'');
+ $result.=''."\n";
+ $result.=' ';
+ $result.='(File will be uploaded when you click on Save & Next below.) ';
+ $file_counter++;
+ }
}
}
return $result;
@@ -1576,7 +1579,7 @@ sub show_problem {
if ($removeform) {
$rendered=~s|
||g;
- $rendered=~s|name="submit"|name="would_have_been_submit"|g;
+ $rendered=~s|(]*name\s*=\s*"?)(\w+)("?)|$1would_have_been_$2$3|g;
}
my $companswer;
if ($mode eq 'both' or $mode eq 'answer') {
@@ -2390,7 +2393,6 @@ sub saveHandGrade {
}
$newrecord{'resource.'.$new_part.'.regrader'}=
"$env{'user.name'}:$env{'user.domain'}";
- &handback_files($request,$symb,$stuname,$domain,$newflg,$new_part,\%newrecord);
}
# unless problem has been graded, set flag to version the submitted files
unless ($record{'resource.'.$new_part.'.solved'} =~ /^correct_/ ||
@@ -2408,6 +2410,10 @@ sub saveHandGrade {
my @changed_keys = &version_portfiles(\%record, \@parts_graded,
$env{'request.course.id'}, $symb, $domain, $stuname, \@version_parts);
@newrecord{@changed_keys} = @record{@changed_keys};
+ foreach my $new_part (@version_parts) {
+ &handback_files($request,$symb,$stuname,$domain,$newflg,
+ $new_part,\%newrecord);
+ }
}
&Apache::lonnet::cstore(\%newrecord,$symb,
$env{'request.course.id'},$domain,$stuname);
@@ -2439,6 +2445,7 @@ sub handback_files {
if (($env{'form.'.$newflg.'_'.$part_resp.'_returndoc1'}) && ($new_part == $part_id)) {
# if multiple files are uploaded names will be 'returndoc2','returndoc3'
my $file_counter = 1;
+ my $file_msg;
while ($env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter}) {
my $fname=$env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'.filename'};
my ($directory,$answer_file) =
@@ -2459,23 +2466,29 @@ sub handback_files {
} else {
# mark the file as read only
my @files = ($save_file_name);
- my @what = ($symb,'handback');
+ my @what = ($symb,$env{'request.course.id'},'handback');
&Apache::lonnet::mark_as_readonly($domain,$stuname,\@files,\@what);
- $$newrecord{"resource.$new_part.$resp_id.handback"} = $save_file_name;
- my $subject = "File Handed Back by Instructor ";
- my $message = "A file has been returned that was originally submitted in reponse to: ";
- $message .= "".&Apache::lonnet::gettitle($symb)." ";
- $message .= " The returned file is named: ".$save_file_name." ";
- $message .= " and can be found in your portfolio space.";
- my $url = (&Apache::lonnet::decode_symb($symb))[2];
- $url = &Apache::lonnet::declutter($url);
- my $msgstatus = &Apache::lonmsg::user_normal_msg($stuname,$domain,
- $subject.' (File Returned) ['.$url.']',$message);
+ if (exists($$newrecord{"resource.$new_part.$resp_id.handback"})) {
+ $$newrecord{"resource.$new_part.$resp_id.handback"}.=',';
+ }
+ $$newrecord{"resource.$new_part.$resp_id.handback"} .= $save_file_name;
+ $file_msg.= "\n".' '.$save_file_name." ";
+
}
$request->print(" ".$fname." will be the uploaded file name");
$request->print(" ".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter});
$file_counter++;
}
+ my $subject = "File Handed Back by Instructor ";
+ my $message = "A file has been returned that was originally submitted in reponse to: ";
+ $message .= "".&Apache::lonnet::gettitle($symb)." ";
+ $message .= ' The returned file(s) are named: '. $file_msg;
+ $message .= " and can be found in your portfolio space.";
+ my $url = (&Apache::lonnet::decode_symb($symb))[2];
+ $url = &Apache::lonnet::declutter($url);
+ my $msgstatus = &Apache::lonmsg::user_normal_msg($stuname,$domain,
+ $subject.' (File Returned) ['.$url.']',$message);
+
}
}
return;
@@ -2567,7 +2580,7 @@ sub version_portfiles {
my $new_portfiles;
if ($key =~ /^resource\.($version_parts)\./ && $key =~ /\.portfiles$/ ) {
my @versioned_portfiles;
- my @portfiles = split(/,/,$$record{$key});
+ my @portfiles = split(/\s*,\s*/,$$record{$key});
foreach my $file (@portfiles) {
&Apache::lonnet::unmark_as_readonly($domain,$stu_name,[$symb,$env{'request.course.id'}],$file);
my ($directory,$answer_file) =($file =~ /^(.*?)([^\/]*)$/);
@@ -2579,7 +2592,7 @@ sub version_portfiles {
if ($new_answer ne 'problem getting file') {
push(@versioned_portfiles, $directory.$new_answer);
&Apache::lonnet::mark_as_readonly($domain,$stu_name,
- ['/portfolio'.$directory.$new_answer],
+ [$directory.$new_answer],
[$symb,$env{'request.course.id'},'graded']);
}
}
@@ -3429,9 +3442,10 @@ sub upcsvScores_form {
$result.=$table;
$result.='
'."\n";
$result.='
'."\n";
- $result.=' Specify a file containing the class scores for current resource'.
+ $result.=' '.&mt('Specify a file containing the class scores for current resource').
'.
'."\n";
$result.='
'."\n";
+ my $upload=&mt("Upload Scores");
my $upfile_select=&Apache::loncommon::upfile_select_html();
my $ignore=&mt('Ignore First Line');
$result.=<
$upfile_select
-
+
ENDUPFORM
- $result.='
'."\n";
+ $result.=&Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
+ &mt("How do I create a CSV file from a spreadsheet"))
+ .'
'."\n";
$result.='
'."\n";
$result.=&show_grading_menu_form($symb);
return $result;
@@ -4592,7 +4608,8 @@ sub scantron_parse_scanline {
substr($questions,0,$$scantron_config{'Qlength'})='';
if (length($currentquest) < $$scantron_config{'Qlength'}) { next; }
if ($$scantron_config{'Qon'} eq 'letter') {
- if ($currentquest eq '?') {
+ if ($currentquest eq '?'
+ || $currentquest eq '*') {
push(@{$record{'scantron.doubleerror'}},$questnum);
$record{"scantron.$questnum.answer"}='';
} elsif (!$currentquest
@@ -4606,7 +4623,8 @@ sub scantron_parse_scanline {
$record{"scantron.$questnum.answer"}=$currentquest;
}
} elsif ($$scantron_config{'Qon'} eq 'number') {
- if ($currentquest eq '?') {
+ if ($currentquest eq '?'
+ || $currentquest eq '*') {
push(@{$record{'scantron.doubleerror'}},$questnum);
$record{"scantron.$questnum.answer"}='';
} elsif (!$currentquest
@@ -4617,8 +4635,14 @@ sub scantron_parse_scanline {
push(@{$record{"scantron.missingerror"}},$questnum);
}
} else {
- $record{"scantron.$questnum.answer"}=
- $alphabet[$currentquest-1];
+ # wrap zero back to J
+ if ($currentquest eq '0') {
+ $record{"scantron.$questnum.answer"}=
+ $alphabet[9];
+ } else {
+ $record{"scantron.$questnum.answer"}=
+ $alphabet[$currentquest-1];
+ }
}
} else {
my @array=split($$scantron_config{'Qon'},$currentquest,-1);
@@ -4789,15 +4813,15 @@ sub scantron_warning_screen {
my ($button_text)=@_;
my $title=&Apache::lonnet::gettitle($env{'form.selectpage'});
my %scantron_config=&get_scantron_config($env{'form.scantron_format'});
- my $CODElist="a";
+ my $CODElist;
if ($scantron_config{'CODElocation'} &&
$scantron_config{'CODEstart'} &&
$scantron_config{'CODElength'}) {
$CODElist=$env{'form.scantron_CODElist'};
- if ($CODElist eq '') { $CODElist='None'; }
+ if ($env{'form.scantron_CODElist'} eq '') { $CODElist='None'; }
$CODElist=
'