--- loncom/homework/lonhomework.pm 2006/06/24 01:28:17 1.253 +++ loncom/homework/lonhomework.pm 2006/10/17 15:11:11 1.261 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.253 2006/06/24 01:28:17 albertel Exp $ +# $Id: lonhomework.pm,v 1.261 2006/10/17 15:11:11 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -344,9 +344,14 @@ sub check_slot_access { } } + if ( $is_correct) { + if ($type eq 'problem') { + return ($status); + } return ('SHOW_ANSWER'); } + if ( $status eq 'CANNOT_ANSWER' && ($slotstatus ne 'NEEDS_CHECKIN' && $slotstatus ne 'NOT_IN_A_SLOT')) { return ($status,$datemsg); @@ -388,7 +393,7 @@ sub check_access { &Apache::lonxml::debug("checking for part :$id:"); &Apache::lonxml::debug("time:".time); - my ($symb)=&Apache::lonxml::whichuser(); + my ($symb)=&Apache::lonnet::whichuser(); &Apache::lonxml::debug("symb:".$symb); #if ($env{'request.state'} ne "construct" && $symb ne '') { if ($env{'request.state'} ne "construct") { @@ -475,7 +480,11 @@ sub check_access { if (!$first_access) { $status='NOT_YET_VIEWED'; my $due_date = &due_date($id); - $datemsg=&seconds_to_human_length($due_date-time); + my $seconds_left = $due_date - time; + if ($seconds_left > $interval || $due_date eq '') { + $seconds_left = $interval; + } + $datemsg=&seconds_to_human_length($seconds_left); } } } @@ -505,8 +514,9 @@ sub due_date { my $due_date= &Apache::lonnet::EXT("resource.$part_id.duedate",$symb, $udom,$uname); &Apache::lonxml::debug("looking for due_date $part_id $symb $due_date"); - if (defined($interval)) { + if ($interval =~ /\d+/) { my $first_access=&Apache::lonnet::get_first_access('map',$symb); + &Apache::lonxml::debug("looking for first_access $first_access"); if (defined($first_access)) { $interval = $first_access+$interval; $date = ($interval < $due_date)? $interval : $due_date; @@ -594,7 +604,7 @@ sub setuppermissions { if ($Apache::lonhomework::browse eq 'F' && $env{'form.devalidatecourseresdata'} eq 'on') { - my (undef,$courseid) = &Apache::lonxml::whichuser(); + my (undef,$courseid) = &Apache::lonnet::whichuser(); &Apache::lonnet::devalidatecourseresdata($env{"course.$courseid.num"}, $env{"course.$courseid.domain"}); } @@ -814,7 +824,7 @@ sub editxmlmode { &Apache::loncommon::helpLatexCheatsheet("Problem_Editor_XML_Index", "Problem Editing Help"). ''. - &Apache::loncommon::help_open_menu('',undef,undef,undef,5,'Authoring'). + &Apache::loncommon::help_open_menu(undef,undef,5,'Authoring'). ''; if ($cols > 80) { $cols = 80; } if ($cols < 70) { $cols = 70; } @@ -875,9 +885,16 @@ sub renderpage { my $problem=&Apache::lonnet::getfile($file); my $result; if ($problem eq -1) { - my $filename=(split('/',$file))[-1]; - $result.=" ".&mt('Unable to find')." $filename"; $problem=''; + my $filename=(split('/',$file))[-1]; + my $error = + " ".&mt('Unable to find [_1]', + ' '.$filename.'') + .""; + $result.= + &Apache::loncommon::simple_error_page($request,'Not available', + $error); + return; } my %mystyle; @@ -959,7 +976,7 @@ sub newproblem { # I don't like hard-coded filenames but for now, this will work. use File::Copy; my $templatefilename = - $request->dir_config('lonIncludes').'/templates/blank.problem'; + $request->dir_config('lonIncludes').'/templates/blank.'.$extension; &Apache::lonxml::debug("$templatefilename"); my $dest = &Apache::lonnet::filelocation("",$request->uri); copy($templatefilename,$dest); @@ -976,25 +993,18 @@ sub newproblem { my $instructions; my $start_page = &Apache::loncommon::start_page("Create New $extension"); - if ($templatelist) { $instructions=&mt(", select a template from the pull-down menu below.").'
'.&mt("Then");} - my %lt=&Apache::lonlocal::texthash( 'create' => 'Creating a new', - 'resource' => 'resource', - 'requested' => 'The requested file', - 'not exist' => 'currently does not exist', - 'createnew' => 'To create a new', - 'click' => 'click on the', - 'Create' => 'Create', - 'button' => 'button'); - $request->print(<print(" $start_page -

$lt{'create'} $extension $lt{'resource'}

+

".&mt("Creating a new $extension resource.")."

$errormsg -$lt{'requested'} $shownurl $lt{'not exist'}. +".&mt("The requested file [_1] currently does not exist.", + "$shownurl")."

-$lt{'createnew'} $extension$instructions $lt{'click'} "$lt{'Create'} $extension" $lt{'button'}. -

-

-ENDNEWPROBLEM + +".&mt("To create a new $extension, select a template from the". + "pull-down menu below. Then click on the \"Create $extension\" button.")." +

"); + if (defined($templatelist)) { $request->print(""); } @@ -1038,7 +1048,7 @@ sub handler { } &Apache::lonxml::debug("Permissions:$Apache::lonhomework::browse:$Apache::lonhomework::viewgrades:$Apache::lonhomework::modifygrades:$Apache::lonhomework::queuegrade"); &Apache::lonxml::debug("Problem Mode ".$env{'form.problemmode'}); - my ($symb) = &Apache::lonxml::whichuser(); + my ($symb) = &Apache::lonnet::whichuser(); &Apache::lonxml::debug('symb is '.$symb); if ($env{'request.state'} eq "construct") { if ( -e $file ) {