--- loncom/homework/grades.pm 2006/03/03 21:50:44 1.327
+++ loncom/homework/grades.pm 2006/03/11 00:02:18 1.331
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# The LON-CAPA Grading handler
#
-# $Id: grades.pm,v 1.327 2006/03/03 21:50:44 albertel Exp $
+# $Id: grades.pm,v 1.331 2006/03/11 00:02:18 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1497,6 +1497,7 @@ sub handback_box {
sub show_problem {
my ($request,$symb,$uname,$udom,$removeform,$viewon,$mode) = @_;
my $rendered;
+ &Apache::lonxml::remember_problem_counter();
if ($mode eq 'both' or $mode eq 'text') {
$rendered=&Apache::loncommon::get_student_view($symb,$uname,$udom,
$env{'request.course.id'});
@@ -1508,6 +1509,7 @@ sub show_problem {
}
my $companswer;
if ($mode eq 'both' or $mode eq 'answer') {
+ &Apache::lonxml::restore_problem_counter();
$companswer=&Apache::loncommon::get_student_answers($symb,$uname,$udom,
$env{'request.course.id'});
}
@@ -1594,6 +1596,7 @@ sub submission {
} elsif ($env{'form.vAns'} eq 'yes') {
$mode='answer';
}
+ &Apache::lonxml::clear_problem_counter();
$request->print(&show_problem($request,$symb,$uname,$udom,0,1,$mode));
}
@@ -1692,6 +1695,7 @@ KEYWORDS
} elsif ($env{'form.vAns'} eq 'all') {
$mode='answer';
}
+ &Apache::lonxml::clear_problem_counter();
$request->print(&show_problem($request,$symb,$uname,$udom,1,1,$mode));
}
@@ -2316,14 +2320,21 @@ sub saveHandGrade {
my ($partlist,$handgrade,$responseType) = &response_type($symb);
foreach my $part_resp (sort(keys(%$handgrade))) {
my ($part_id, $resp_id) = split(/_/,$part_resp);
- &Apache::lonnet::logthis('form.'.$newflg.'_'.$part_resp.'_returndoc1');
- &Apache::lonnet::logthis("new part is $new_part and partid is $part_id");
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;
while ($env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter}) {
my $fname=$env{'form.'.$newflg.'_'.$part_resp.'_returndoc'.$file_counter.'.filename'};
$newrecord{"resource.$new_part.$resp_id.handback"} = $env{'form.returndocorig'.$file_counter};
+ # set the filename to match the submitted file name
+ $env{'form.'.$newflg.'_'.$part_resp.'_returndoc1.filename'} = $env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter};
+ my $result=&Apache::lonnet::userfileupload($newflg.'_'.$part_resp.'_returndoc'.$file_counter,'',
+ 'portfolio',undef,undef,undef,$stuname,$domain);
+ if ($result !~ m|^/uploaded/|) {
+ $request->print(' An errror occured ('.$result.
+ ') while trying to upload '.&display_file().'
');
+ # $request->print(&done('Back'));
+ }
$request->print("
".$fname." will be the uploaded file name");
$request->print("Will upload document".$env{'form.'.$newflg.'_'.$part_resp.'_origdoc'.$file_counter});
$file_counter++;
@@ -3748,6 +3759,7 @@ sub displayPage {
'
Gathering neccessary info.
");$r->rflush(); #get the student pick code ready $r->print(&Apache::loncommon::studentbrowser_javascript()); - my $max_bubble=&scantron_get_maxbubble($r); + my $max_bubble=&scantron_get_maxbubble(); my $result=&scantron_form_start($max_bubble).$default_form_data; $r->print($result); @@ -5238,28 +5259,29 @@ sub scantron_validate_doublebubble { return (0,$currentphase+1); } -sub scantron_get_maxbubble { - my ($r)=@_; +sub scantron_get_maxbubble { if (defined($env{'form.scantron_maxbubble'}) && $env{'form.scantron_maxbubble'}) { return $env{'form.scantron_maxbubble'}; } + my $navmap=Apache::lonnavmaps::navmap->new(); my (undef,undef,$sequence)= &Apache::lonnet::decode_symb($env{'form.selectpage'}); + my $map=$navmap->getResourceByUrl($sequence); my @resources=$navmap->retrieveResources($map,\&scantron_filter,1,0); - &Apache::lonnet::delenv('form.counter'); + + &Apache::lonxml::clear_problem_counter(); + foreach my $resource (@resources) { - my $result=&Apache::lonnet::ssi($resource->src().'?symb='.&Apache::lonnet::escape($resource->symb())); + my $result=&Apache::lonnet::ssi($resource->src(), + ('symb' => $resource->symb())); } &Apache::lonnet::delenv('scantron\.'); - my $envfile=$env{'user.environment'}; - $envfile=~/\/([^\/]+)\.id$/; - $envfile=$1; - &Apache::lonnet::transfer_profile_to_env($r->dir_config('lonIDsDir'), - $envfile); - $env{'form.scantron_maxbubble'}=$env{'form.counter'}-1; + $env{'form.scantron_maxbubble'} = + &Apache::lonxml::get_problem_counter()-1; + return $env{'form.scantron_maxbubble'}; } @@ -5353,7 +5375,8 @@ SCANTRONFORM next; } ($uname,$udom)=split(/:/,$uname); - &Apache::lonnet::delenv('form.counter'); + + &Apache::lonxml::clear_problem_counter(); &Apache::lonnet::appenv(%$scan_record); my $i=0; @@ -5381,7 +5404,7 @@ SCANTRONFORM $completedstudents{$uname}={'line'=>$line}; if (&Apache::loncommon::connection_aborted($r)) { last; } } continue { - &Apache::lonnet::delenv('form.counter'); + &Apache::lonxml::clear_problem_counter(); &Apache::lonnet::delenv('scantron\.'); } &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);