--- loncom/homework/lonhomework.pm 2011/02/06 18:43:10 1.323 +++ loncom/homework/lonhomework.pm 2011/11/14 00:20:39 1.330 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.323 2011/02/06 18:43:10 www Exp $ +# $Id: lonhomework.pm,v 1.330 2011/11/14 00:20:39 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -147,6 +147,8 @@ sub get_target { } else { if ($env{'form.problemstate'} eq 'WEB_GRADE') { return ('grade','webgrade','answer'); + } elsif ($env{'form.problemmode'} eq 'view') { + return ('grade','web','answer'); } elsif ($env{'form.problemmode'} eq 'saveview') { return ('modified','web','answer'); } elsif ($env{'form.problemmode'} eq 'discard') { @@ -374,7 +376,12 @@ sub check_access { $date=&mt("can not be accessed from your location."); return($status,$date); } - + if ($env{'form.grade_imsexport'}) { + if (($env{'request.course.id'}) && + (&Apache::lonnet::allowed('mdc',$env{'request.course.id'}))) { + return ('SHOW_ANSWER'); + } + } foreach my $temp ("opendate","duedate","answerdate") { $lastdate = $date; if ($temp eq 'duedate') { @@ -432,11 +439,14 @@ sub check_access { if ( $tries eq '' ) { $tries = '0'; } if ( $maxtries eq '' && $env{'request.state'} ne 'construct') { $maxtries = '2'; } + $Apache::lonhomework::results{'resource.'.$id.'.maxtries'}=$maxtries; if ($maxtries && $tries >= $maxtries) { $status = 'CANNOT_ANSWER'; } # if (correct and show prob status) or excused then CANNOT_ANSWER if(($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/ && - &show_problem_status()) + &show_problem_status() + && + $Apache::lonhomework::history{"resource.$id.awarded"}==1) || $Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) { $status = 'CANNOT_ANSWER'; @@ -688,7 +698,7 @@ sub analyze_header { my $js = &Apache::structuretags::setmode_javascript(); # Breadcrumbs - my $brcrum = [{'href' => &Apache::loncommon::authorspace(), + my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), 'text' => 'Construction Space'}, {'href' => '', 'text' => 'Problem Testing'}, @@ -894,10 +904,10 @@ sub editxmlmode { my $problem=&Apache::lonnet::getfile($file); if ($problem eq -1) { &Apache::lonxml::error( - ' ' + '
' .&mt('Unable to find [_1]', ''.$file.'') - .''); + .'
'); $problem=''; } @@ -926,7 +936,7 @@ sub editxmlmode { &Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); # Breadcrumbs - my $brcrum = [{'href' => &Apache::loncommon::authorspace(), + my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), 'text' => 'Construction Space'}, {'href' => '', 'text' => 'Problem Editing'}]; @@ -1004,9 +1014,10 @@ sub renderpage { $problem=''; my $filename=(split('/',$file))[-1]; my $error = - " ".&mt('Unable to find [_1]', + '' + .&mt('Unable to find [_1]', ''.$filename.'') - .""; + ."
"; $result.= &Apache::loncommon::simple_error_page($request,'Not available', $error); @@ -1088,6 +1099,7 @@ sub get_template_list { my $count = 0; my $currentcategory=''; my $first = 1; + my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; foreach my $file (@files) { next if ($file->[1] !~ /\S/); if ($file->[2] ne $currentcategory) { @@ -1111,7 +1123,7 @@ sub get_template_list { $result.=&Apache::loncommon::help_open_topic($file->[3]); } my $filename=$file->[0]; - $filename=~s/^\/home\/httpd\/html//; + $filename=~s{^\Q$londocroot\E}{}; $result.=' ' .''.&mt('Example').'' .''.&mt("To create a new $extension, select a template from the". " list below. Then click on the \"Create $extension\" button.").'