--- loncom/homework/lonhomework.pm 2011/10/06 12:32:52 1.317.4.4 +++ loncom/homework/lonhomework.pm 2011/11/29 13:24:38 1.331 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.317.4.4 2011/10/06 12:32:52 raeburn Exp $ +# $Id: lonhomework.pm,v 1.331 2011/11/29 13:24:38 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -112,7 +112,7 @@ sub get_target { } elsif ( $env{'form.grade_target'} eq 'webgrade' && ($Apache::lonhomework::queuegrade eq 'F' )) { return ($env{'form.grade_target'}); - } elsif ($env{'form.grade_target'} eq 'answer') { + } elsif ($env{'form.grade_target'} eq 'answer') { if ($env{'form.answer_output_mode'} eq 'tex') { return ($env{'form.grade_target'}); } @@ -146,10 +146,10 @@ sub get_target { } } else { if ($env{'form.problemstate'} eq 'WEB_GRADE') { - return ('grade','webgrade','answer'); + return ('grade','webgrade','answer'); } elsif ($env{'form.problemmode'} eq 'view') { return ('grade','web','answer'); - } elsif ($env{'form.problemmode'} eq 'saveview') { + } elsif ($env{'form.problemmode'} eq 'saveview') { return ('modified','web','answer'); } elsif ($env{'form.problemmode'} eq 'discard') { return ('web','answer'); @@ -157,11 +157,11 @@ sub get_target { ($env{'form.problemmode'} eq 'undo')) { return ('modified','no_output_web','edit'); } elsif ($env{'form.problemmode'} eq 'edit') { - return ('no_output_web','edit'); - } else { - return ('web'); - } - } + return ('no_output_web','edit'); + } else { + return ('web'); + } + } # # End of Construction Space # @@ -178,16 +178,6 @@ sub setup_vars { # return ';$external::target='.$target.';'; } -sub createmenu { - my ($which,$request)=@_; - if ($which eq 'grade') { - $request->print(''); - } -} - sub proctor_checked_in { my ($slot_name,$slot,$type)=@_; my @possible_proctors=split(",",$slot->{'proctor'}); @@ -386,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') { @@ -444,13 +439,16 @@ 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()) - || - $Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) { + if ( ($Apache::lonhomework::history{"resource.$id.solved"}=~/^correct/) + && (&show_problem_status()) ) { + if (&Apache::inputtags::grading_is_nonlenient($id) || + $Apache::lonhomework::history{"resource.$id.awarded"} == 1) { + $status = 'CANNOT_ANSWER'; + } + } elsif ($Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) { $status = 'CANNOT_ANSWER'; } if ($status eq 'CANNOT_ANSWER' @@ -700,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'}, @@ -913,8 +911,9 @@ sub editxmlmode { $problem=''; } + if (($env{'form.problemmode'} eq 'saveeditxml') || - ($env{'form.problemmode'} eq 'saveviewxml') || + ($env{'form.problemmode'} eq 'saveviewxml') || ($env{'form.problemmode'} eq 'undoxml')) { my $error=&handle_save_or_undo($request,\$problem, \$env{'form.editxmltext'}); @@ -935,10 +934,9 @@ sub editxmlmode { &Apache::loncommon::resize_textarea_js(). &Apache::structuretags::setmode_javascript(). &Apache::lonhtmlcommon::dragmath_js("EditMathPopup"); - my $only_body = ($env{'environment.remote'} eq 'off')? 0 : 1; # Breadcrumbs - my $brcrum = [{'href' => &Apache::loncommon::authorspace(), + my $brcrum = [{'href' => &Apache::loncommon::authorspace($request->uri), 'text' => 'Construction Space'}, {'href' => '', 'text' => 'Problem Editing'}]; @@ -946,13 +944,13 @@ sub editxmlmode { my $start_page = &Apache::loncommon::start_page(&mt("EditXML [_1]",$file),$js, {'no_auto_mt_title' => 1, - 'only_body' => $only_body, + 'only_body' => 0, 'add_entries' => { 'onresize' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')], 'onload' => q[resize_textarea('LC_editxmltext','LC_aftertextarea')], - }, + }, 'bread_crumbs' => $brcrum, - }); + }); $result=$start_page .&Apache::loncommon::head_subbox( @@ -971,8 +969,8 @@ sub editxmlmode { $result.=''. &Apache::structuretags::problem_edit_buttons('editxml'); - - $result.='
'.&Apache::lonxml::message_location().''. + + $result.='
'.&Apache::lonxml::message_location().''. '