--- loncom/homework/structuretags.pm 2005/10/18 21:46:42 1.306 +++ loncom/homework/structuretags.pm 2005/11/03 17:55:12 1.312 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # definition of tags that give a structure to a document # -# $Id: structuretags.pm,v 1.306 2005/10/18 21:46:42 albertel Exp $ +# $Id: structuretags.pm,v 1.312 2005/11/03 17:55:12 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -192,7 +192,7 @@ sub setup_rndseed { delete($env{'form.newrandomization'}); } if (defined($rndseed) && $rndseed ne int($rndseed)) { - $rndseed=join(',',&Math::Random::random_seed_from_phrase($rndseed)); + $rndseed=join(':',&Apache::lonnet::digest($rndseed)); } if ($Apache::lonhomework::history{'resource.CODE'}) { $rndseed=&Apache::lonnet::rndseed(); @@ -425,16 +425,21 @@ ENDCHECKOUT sub init_problem_globals { my ($type)=@_; #initialize globals + # For problems, we start out in part 0 (outside a tag). + # and part 0 is used to describe the main body of the + # if ($type eq 'problem') { $Apache::inputtags::part='0'; @Apache::inputtags::partlist=('0'); $Apache::lonhomework::problemstatus=&get_problem_status('0'); $Apache::lonhomework::ignore_response_errors=0; + } elsif ($type eq 'library') { $Apache::inputtags::part=''; @Apache::inputtags::partlist=(); $Apache::lonhomework::problemstatus=''; $Apache::lonhomework::ignore_response_errors=1; + } elsif ($type eq 'Task') { $Apache::inputtags::part='0'; @Apache::inputtags::partlist=('0'); @@ -490,6 +495,12 @@ sub get_problem_status { sub start_problem { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; + # We'll use the redirection to fix up printing of duedates. + &Apache::lonxml::startredirection(); + + # Problems don't nest and we don't allow more than one in + # a .problem file. + # if ( $Apache::inputtags::part ne '' || $Apache::lonhomework::parsing_a_problem) { &Apache::lonxml::error('Only one <problem> allowed in a .problem file'); @@ -653,25 +664,35 @@ sub start_problem { '.disableexampointprint'}) eq 'yes') { $allow_print_points=0; } - my $duedate = &Apache::lonnet::EXT("resource.$id.duedate"); - $duedate = POSIX::strftime("%c",localtime($duedate)); - my $temp_file; - my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due"; - if (-e $filename) { - $temp_file = Apache::File->new($filename); - } else { - $temp_file = Apache::File->new('>>'.$filename); - } - my @due_file_content = <$temp_file>; - my $due_file_content = $due_file_content[$#due_file_content]; - chomp $due_file_content; my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header'); my $begin_doc='\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource

"'.$name_of_resourse.'"

located in
'.$env{'request.uri'}.'
STAMPOFPASSEDRESOURCEEND} \noindent '; my $toc_line='\vskip 1 mm\noindent '.$startminipage. '\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}'; - if ($due_file_content ne $duedate) { + + # Figure out what the due date is and if we need to print + # it in the problem header. We have been logging the + # last due date written to file. + + my $duetime = &Apache::lonnet::EXT("resource.$id.duedate"); + my $duedate = POSIX::strftime("%c",localtime($duetime)); + my $temp_file; + my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due"; + + # Figure out what the last printed due date is or set it + # to the epoch if no duedates have been printed. + + my $due_file_content = 0; # If the file does not yet exist, time is the epoch. + if (-e $filename) { + $temp_file = Apache::File->new($filename); + my @due_file = <$temp_file>; + $due_file_content = $due_file[$#due_file]; + chomp $due_file_content; + } + + # comparisons of the absolute times + if ($due_file_content != $duetime) { $temp_file = Apache::File->new('>'.$filename); - print $temp_file "$duedate\n"; + print $temp_file "$duetime\n"; if (not $env{'request.symb'} =~ m/\.page_/) { if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') { $result .= $begin_doc. @@ -711,7 +732,8 @@ sub start_problem { sub end_problem { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; - my $result=''; + my $result= &Apache::lonxml::endredirection(); # started in &start_problem + my $status=$Apache::inputtags::status['-1']; if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' || $target eq 'tex') { @@ -1151,6 +1173,8 @@ sub ordered_show_check { sub start_part { my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_; + &Apache::lonxml::startredirection(); # we'll use redirection to fix up + # duedates. my $result=''; my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval); if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; } @@ -1259,13 +1283,11 @@ sub end_part { my $status=$Apache::inputtags::status['-1']; my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part); my $in_order_show=&ordered_show_check(); - my $result=''; - if ( $target eq 'meta' ) { - $result=''; - } elsif ($target eq 'grade') { + my $result= &Apache::lonxml::endredirection(); # started in &start_part + if ($target eq 'grade') { if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) && !$hidden && $in_order_show) { - $result=&Apache::inputtags::grade; + $result.=&Apache::inputtags::grade; } else { # move any submission data to .hidden &Apache::inputtags::hidealldata($Apache::inputtags::part); @@ -1277,10 +1299,10 @@ sub end_part { if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') { $gradestatus=''; } - $result=$gradestatus; + $result.=$gradestatus; if ($$tagstack[-2] eq 'td' and $target eq 'tex') {$result.='\end{minipage}';} } elsif ($target eq 'edit') { - $result=&Apache::edit::end_table(); + $result.=&Apache::edit::end_table(); } pop @Apache::inputtags::status; $Apache::inputtags::part='';