--- loncom/homework/lonhomework.pm 2007/11/03 00:52:06 1.282 +++ loncom/homework/lonhomework.pm 2007/12/24 06:35:18 1.287 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # The LON-CAPA Homework handler # -# $Id: lonhomework.pm,v 1.282 2007/11/03 00:52:06 albertel Exp $ +# $Id: lonhomework.pm,v 1.287 2007/12/24 06:35:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -494,19 +494,23 @@ sub check_access { $Apache::lonhomework::history{"resource.$id.solved"}=~/^excused/) { $status = 'CANNOT_ANSWER'; } + if ($status eq 'CANNOT_ANSWER' + && &show_answer_problem_status()) { + $status = 'SHOW_ANSWER'; + } } if ($status eq 'CAN_ANSWER' || $status eq 'CANNOT_ANSWER') { - my $interval=&Apache::lonnet::EXT("resource.$id.interval"); - &Apache::lonxml::debug("looking for interval $interval"); - if ($interval) { - my $first_access=&Apache::lonnet::get_first_access('map'); + my @interval=&Apache::lonnet::EXT("resource.$id.interval"); + &Apache::lonxml::debug("looking for interval @interval"); + if ($interval[0]) { + my $first_access=&Apache::lonnet::get_first_access($interval[1]); &Apache::lonxml::debug("looking for accesstime $first_access"); if (!$first_access) { $status='NOT_YET_VIEWED'; my $due_date = &due_date($id); my $seconds_left = $due_date - time; - if ($seconds_left > $interval || $due_date eq '') { - $seconds_left = $interval; + if ($seconds_left > $interval[0] || $due_date eq '') { + $seconds_left = $interval[0]; } $datemsg=&seconds_to_human_length($seconds_left); } @@ -532,18 +536,19 @@ sub check_access { sub due_date { my ($part_id,$symb,$udom,$uname)=@_; my $date; - my $interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb, + my @interval= &Apache::lonnet::EXT("resource.$part_id.interval",$symb, $udom,$uname); - &Apache::lonxml::debug("looking for interval $part_id $symb $interval"); + &Apache::lonxml::debug("looking for interval $part_id $symb @interval"); 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 ($interval =~ /\d+/) { - my $first_access=&Apache::lonnet::get_first_access('map',$symb); - &Apache::lonxml::debug("looking for first_access $first_access"); + if ($interval[0] =~ /\d+/) { + my $first_access=&Apache::lonnet::get_first_access($interval[1],$symb); + &Apache::lonxml::debug("looking for first_access $first_access ($interval[1])"); if (defined($first_access)) { - $interval = $first_access+$interval; - $date = ($interval < $due_date)? $interval : $due_date; + my $interval = $first_access+$interval[0]; + $date = (!$due_date || $interval < $due_date) ? $interval + : $due_date; } else { $date = $due_date; } @@ -683,9 +688,9 @@ sub handle_save_or_undo { my $error=0; if ($env{'form.Undo'} eq &mt('undo')) { my $error=0; - if (!copy($file,$filetmp)) { $error=1; } - if ((!$error) && (!copy($filebak,$file))) { $error=1; } - if ((!$error) && (!move($filetmp,$filebak))) { $error=1; } + if (!&File::Copy::copy($file,$filetmp)) { $error=1; } + if ((!$error) && (!&File::Copy::copy($filebak,$file))) { $error=1; } + if ((!$error) && (!&File::Copy::move($filetmp,$filebak))) { $error=1; } if (!$error) { &Apache::lonxml::info("
".
&mt("Undid changes, Switched [_1] and [_2]",
@@ -882,6 +887,7 @@ sub analyze {
sub show_problem_status {
return ($show_problem_status eq 'yes'
+ || $show_problem_status eq 'answer'
|| $show_problem_status eq '');
}
@@ -892,6 +898,10 @@ sub analyze {
sub show_no_problem_status {
return ($show_problem_status eq 'no_feedback_ever');
}
+
+ sub show_answer_problem_status {
+ return ($show_problem_status eq 'answer');
+ }
}
sub editxmlmode {
@@ -1072,11 +1082,33 @@ sub get_template_list {
'/templates/*.'.$glob_extension);
@files = map {[$_,&mt(&Apache::lonnet::metadata($_, 'title'))]} (@files);
@files = sort {$a->[1] cmp $b->[1]} (@files);
+ my ($midpoint,$seconddiv,$numfiles);
+ $numfiles = 0;
+ foreach my $file (@files) {
+ next if ($file->[1] !~ /\S/);
+ $numfiles ++;
+ }
+ if ($numfiles > 0) {
+ $result = '
';
+ $file->[1].'
'."\n";
+ $count ++;
+ if ((!$seconddiv) && ($count >= $midpoint)) {
+ $result .= '