--- loncom/homework/grades.pm 2006/01/27 23:53:11 1.307
+++ loncom/homework/grades.pm 2006/02/14 19:41:06 1.314
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.307 2006/01/27 23:53:11 banghart Exp $
+# $Id: grades.pm,v 1.314 2006/02/14 19:41:06 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1386,10 +1386,8 @@ SUBJAVASCRIPT
#--- displays the grading box, used in essay type problem and grading by page/sequence
sub gradeBox {
my ($request,$symb,$uname,$udom,$counter,$partid,$record) = @_;
-
my $checkIcon = '';
-
my $wgt = &Apache::lonnet::EXT('resource.'.$partid.'.weight',$symb,$udom,$uname);
my $wgtmsg = ($wgt > 0 ? '(problem weight)' :
'problem weight assigned by computer');
@@ -1397,19 +1395,15 @@ sub gradeBox {
my $score = ($$record{'resource.'.$partid.'.awarded'} eq '' ?
'' : $$record{'resource.'.$partid.'.awarded'}*$wgt);
my $result=''."\n";
-
my $display_part=&get_display_part($partid,undef,$symb);
-
my %last_resets = &get_last_resets($symb,$env{'request.course.id'},
[$partid]);
my $aggtries = $$record{'resource.'.$partid.'.tries'};
if ($last_resets{$partid}) {
$aggtries = &get_num_tries($record,$last_resets{$partid},$partid);
}
-
$result.='
Part: '.
$display_part.' ( ID '.$respid.
' ) ';
- my @files;
- if ($record{"resource.$partid.$respid.portfiles"}) {
- my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio';
- foreach my $file (split(',',$record{"resource.$partid.$respid.portfiles"})) {
- push(@files,$file_url.$file);
-
- &Apache::lonnet::logthis("found a portfolio file".$record{"resource.$partid.$respid.portfiles"});
- &Apache::lonnet::logthis("uploaded URL file".$record{"resource.$partid.$respid.uploadedurl"});
- }
- }
- if ($record{"resource.$partid.$respid.uploadedurl"}) {
- push(@files,$record{"resource.$partid.$respid.uploadedurl"});
- }
- if (@files) {
+ my $files=&get_submitted_files($udom,$uname,$partid,$respid,\%record);
+# if ($record{"resource.$partid.$respid.portfiles"}) {
+# my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio';
+# foreach my $file (split(',',$record{"resource.$partid.$respid.portfiles"})) {
+# push(@files,$file_url.$file);
+# }
+# }
+# if ($record{"resource.$partid.$respid.uploadedurl"}) {
+# push(@files,$record{"resource.$partid.$respid.uploadedurl"});
+# }
+ if (@$files) {
$lastsubonly.=' Like all files provided by users, this file may contain virusses ';
my $file_counter = 0;
- foreach my $file (@files) {
+ foreach my $file (@$files) {
$file_counter ++;
&Apache::lonnet::allowuploaded('/adm/grades',$file);
- $lastsubonly.=' '.$file.'';
- $lastsubonly.='Return commented document to student. '."\n";
- $lastsubonly.='';
-
+ $lastsubonly.=' '.$file.'';
}
$lastsubonly.=' ';
}
@@ -2029,32 +2027,21 @@ sub processHandGrade {
my @collabstrs=&Apache::loncommon::get_env_multiple("form.collaborator$ctr");
foreach my $collabstr (@collabstrs) {
my ($part,@collaborators) = split(/:/,$collabstr);
- foreach (@collaborators) {
+ foreach my $collaborator (@collaborators) {
my ($errorflag,$pts,$wgt) =
- &saveHandGrade($request,$url,$symb,$_,$udom,$ctr,
+ &saveHandGrade($request,$url,$symb,$collaborator,$udom,$ctr,
$env{'form.unamedom'.$ctr},$part);
if ($errorflag eq 'not_allowed') {
- $request->print("Not allowed to modify grades for $_:$udom");
+ $request->print("Not allowed to modify grades for $collaborator:$udom");
next;
} else {
if ($message ne '') {
- $msgstatus = &Apache::lonmsg::user_normal_msg($_,$udom,$env{'form.msgsub'},$message);
+ $msgstatus = &Apache::lonmsg::user_normal_msg($collaborator,$udom,$env{'form.msgsub'},$message);
}
-
}
}
}
}
- if ($env{'form.returndoc1'}) {
- # if multiple files are uploaded names will be 'returndoc2', 'returndoc3'
- my $file_counter = 1;
- while ($env{'form.returndoc'.$file_counter}) {
- my $fname=$env{'form.returndoc'.$file_counter.'.filename'};
- $request->print(" ".$fname." will be the uploaded file name");
- $request->print("Will upload document".$env{'form.returndocorig'.$file_counter});
- $file_counter ++;
- }
- }
$ctr++;
}
}
@@ -2302,6 +2289,28 @@ sub saveHandGrade {
$newrecord{'resource.'.$new_part.'.regrader'}=
"$env{'user.name'}:$env{'user.domain'}";
}
+ if ($env{'form.part'.$new_part.'_returndoc1'}) {
+ # if multiple files are uploaded names will be 'returndoc2','returndoc3'
+
+ my $portfolio_root = &Apache::loncommon::propath($domain,
+ $stuname).
+ '/userfiles/portfolio';
+ $request->print(' '.$portfolio_root.' ');
+
+ # my $result=&Apache::lonnet::userfileupload('uploaddoc','',
+ # 'portfolio'.$env{'form.currentpath'});
+
+ my $file_counter = 1;
+ my $respid = $env{'form.respid'};
+ while ($env{'form.part'.$new_part.'_returndoc'.$file_counter}) {
+ my $fname=$env{'form.returndoc'.$file_counter.'.filename'};
+ $newrecord{"resource.$new_part.$respid.handback"} = $env{'form.returndocorig'.$file_counter};
+ $request->print(" ".$fname." will be the uploaded file name");
+ $request->print("Will upload document".$env{'form.returndocorig'.$file_counter});
+ $file_counter++;
+ }
+ }
+
# unless problem has been graded, set flag to version the submitted files
unless ($record{'resource.'.$new_part.'.solved'} =~ /^correct_/ ||
$record{'resource.'.$new_part.'.solved'} eq 'incorrect_by_override' ||
@@ -2338,7 +2347,20 @@ sub saveHandGrade {
}
return ('',$pts,$wgt);
}
-
+sub get_submitted_files {
+ my ($udom,$uname,$partid,$respid,$record) = @_;
+ my @files;
+ if ($$record{"resource.$partid.$respid.portfiles"}) {
+ my $file_url = '/uploaded/'.$udom.'/'.$uname.'/portfolio';
+ foreach my $file (split(',',$$record{"resource.$partid.$respid.portfiles"})) {
+ push(@files,$file_url.$file);
+ }
+ }
+ if ($$record{"resource.$partid.$respid.uploadedurl"}) {
+ push(@files,$$record{"resource.$partid.$respid.uploadedurl"});
+ }
+ return (\@files);
+}
# ----------- Provides number of tries since last reset.
sub get_num_tries {
my ($record,$last_reset,$part) = @_;
@@ -3326,8 +3348,13 @@ sub csvuploadmap {
unshift(@fields,['none','']);
$i=&Apache::loncommon::csv_samples_select_table($request,\@records,
\@fields);
- my %sone=&Apache::loncommon::record_sep($records[0]);
- $keyfields=join(',',sort(keys(%sone)));
+ foreach my $rec (@records) {
+ my %temp = &Apache::loncommon::record_sep($rec);
+ if (%temp) {
+ $keyfields=join(',',sort(keys(%temp)));
+ last;
+ }
+ }
}
}
&csvuploadmap_footer($request,$i,$keyfields);
@@ -4093,11 +4120,11 @@ sub scantron_CODElist {
sub scantron_CODEunique {
my $result='
+ value="yes" checked="checked" /> Yes
+ value="no" /> No
';
return $result;
}
|