Diff for /loncom/homework/structuretags.pm between versions 1.315 and 1.325

version 1.315, 2005/11/04 15:34:32 version 1.325, 2005/11/21 22:16:38
Line 115  sub page_start { Line 115  sub page_start {
     &Apache::lonxml::fontsettings();           &Apache::lonxml::fontsettings();     
     }      }
     my $body_tag_start;      my $body_tag_start;
     if (!defined($found{'body'}) && $env{'request.state'} eq 'construct'      if (!defined($found{'body'}) && $env{'request.state'} eq 'construct') {
  && $env{'environment.remote'} eq 'off') {   if ($env{'environment.remote'} eq 'off') {
  if ($target eq 'web' || $target eq 'edit') {      if ($target eq 'web' || $target eq 'edit') {
     $body_tag_start=&Apache::loncommon::bodytag();   $body_tag_start=&Apache::loncommon::bodytag();
     $body_tag_start.=&Apache::lonxml::message_location();   $body_tag_start.=&Apache::lonxml::message_location();
       }
    } else {
       if ($target eq 'web' || $target eq 'edit') {
    $body_tag_start=&Apache::loncommon::bodytag(undef,undef,undef,1);
    $body_tag_start.=&Apache::lonxml::message_location();
       }
  }   }
     } elsif (!defined($found{'body'})) {      } elsif (!defined($found{'body'})) {
  my $background=&Apache::lonxml::get_param('background',$parstack,   my $background=&Apache::lonxml::get_param('background',$parstack,
Line 175  sub setup_rndseed { Line 181  sub setup_rndseed {
     my ($symb)=&Apache::lonxml::whichuser();      my ($symb)=&Apache::lonxml::whichuser();
     if ($env{'request.state'} eq "construct" || $symb eq '' ||      if ($env{'request.state'} eq "construct" || $symb eq '' ||
           $Apache::lonhomework::history{'resource.CODE'}) {            $Apache::lonhomework::history{'resource.CODE'}) {
    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
    ['rndseed']);
  $rndseed=$env{'form.rndseed'};   $rndseed=$env{'form.rndseed'};
  if (!$rndseed) {   if (!$rndseed) {
     $rndseed=$Apache::lonhomework::history{'rndseed'};      $rndseed=$Apache::lonhomework::history{'rndseed'};
Line 338  sub initialize_storage { Line 346  sub initialize_storage {
 sub finalize_storage {  sub finalize_storage {
     my $result;      my $result;
     if (%Apache::lonhomework::results) {      if (%Apache::lonhomework::results) {
    my @remove = grep(/^INTERNAL_/,keys(%Apache::lonhomework::results));
    delete(@Apache::lonhomework::results{@remove});
  my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();   my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser();
  if ($env{'request.state'} eq 'construct' || $symb eq '') {   if ($env{'request.state'} eq 'construct' || $symb eq '') {
     $Apache::lonhomework::results{'rndseed'}=$env{'form.rndseed'};      $Apache::lonhomework::results{'rndseed'}=$env{'form.rndseed'};
Line 352  sub finalize_storage { Line 362  sub finalize_storage {
                 &store_aggregates($symb,$courseid);                  &store_aggregates($symb,$courseid);
             }              }
  }   }
       } else {
    &Apache::lonxml::debug('Nothing to store');
     }      }
     return $result;      return $result;
 }  }
Line 505  sub start_problem { Line 517  sub start_problem {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
   
     # We'll use the redirection to fix up printing of duedates.      # We'll use the redirection to fix up printing of duedates.
     &Apache::lonxml::startredirection();      if (!$Apache::lonxml::metamode) {
    &Apache::lonxml::startredirection();
       }
   
     # Problems don't nest and we don't allow more than one <problem> in      # Problems don't nest and we don't allow more than one <problem> in
     # a .problem file.      # a .problem file.
Line 599  sub start_problem { Line 613  sub start_problem {
     }      }
     $form_tag_start.='<hr />';      $form_tag_start.='<hr />';
  }   }
  ($status,$accessmsg) = &Apache::lonhomework::check_access('0');  
    ($status,$accessmsg,my $slot_name,my $slot) = 
       &Apache::lonhomework::check_slot_access('0','problem');
  push (@Apache::inputtags::status,$status);   push (@Apache::inputtags::status,$status);
   
  my $expression='$external::datestatus="'.$status.'";';   my $expression='$external::datestatus="'.$status.'";';
  $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";';   $expression.='$external::gradestatus="'.$Apache::lonhomework::history{"resource.0.solved"}.'";';
  &Apache::run::run($expression,$safeeval);   &Apache::run::run($expression,$safeeval);
  &Apache::lonxml::debug("Got $status");   &Apache::lonxml::debug("Got $status");
   
  if (( $status eq 'CLOSED' ) ||   if (( $status eq 'CLOSED' ) ||
     ( $status eq 'UNCHECKEDOUT') ||      ( $status eq 'UNCHECKEDOUT') ||
     ( $status eq 'NOT_YET_VIEWED') ||      ( $status eq 'NOT_YET_VIEWED') ||
     ( $status eq 'BANNED') ||      ( $status eq 'BANNED') ||
     ( $status eq 'UNAVAILABLE') ||      ( $status eq 'UNAVAILABLE') ||
       ( $status eq 'NOT_IN_A_SLOT') ||
     ( $status eq 'INVALID_ACCESS')) {      ( $status eq 'INVALID_ACCESS')) {
     my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);      my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);
     if ( $target eq "web" ) {      if ( $target eq "web" ) {
Line 626  sub start_problem { Line 645  sub start_problem {
     $msg.=&checkout_msg;      $msg.=&checkout_msg;
  } elsif ($status eq 'NOT_YET_VIEWED') {   } elsif ($status eq 'NOT_YET_VIEWED') {
     $msg.=&firstaccess_msg($accessmsg,$symb);      $msg.=&firstaccess_msg($accessmsg,$symb);
    } elsif ($status eq 'NOT_IN_A_SLOT') {
       $msg.=&Apache::bridgetask::add_request_another_attempt_button("Sign up for time to work.");
  }   }
  $result.=$msg.'<br />';   $result.=$msg.'<br />';
     } elsif ($target eq 'tex') {      } elsif ($target eq 'tex') {
Line 636  sub start_problem { Line 657  sub start_problem {
     $result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";      $result.=&mt('Problem is not open to be viewed. It')." $accessmsg \\vskip 0 mm ";
  }   }
     }      }
    } elsif ($status eq 'NEEDS_CHECKIN') {
       my $bodytext=&Apache::lonxml::get_all_text("/problem",$parser);
       if ($target eq 'web') {
    $result .= $head_tag_start.'</head>';
    $result .= $body_tag_start;
    $result .= &Apache::bridgetask::proctor_validation_screen();
       } elsif ($target eq 'grade') {
    &Apache::bridgetask::proctor_check_auth($slot_name,$slot,
    'problem');
       }
  } elsif ($target eq 'web') {   } elsif ($target eq 'web') {
     my $name= &get_resource_name($parstack,$safeeval);      my $name= &get_resource_name($parstack,$safeeval);
     $result.="$head_tag_start<title>$name</title></head>      $result.="$head_tag_start<title>$name</title></head>
Line 653  sub start_problem { Line 684  sub start_problem {
  }   }
     }      }
  } elsif ($target eq 'tex') {   } elsif ($target eq 'tex') {
     my $startminipage = '';      $result .= 'INSERTTEXFRONTMATTERHERE';
     if (not $env{'form.problem_split'}=~/yes/) {  
  $startminipage = '\begin{minipage}{\textwidth}';  
     }  
     my $id = $Apache::inputtags::part;  
     my $weight = &Apache::lonnet::EXT("resource.$id.weight");  
     my $packages=&Apache::lonnet::metadata($env{'request.uri'},'packages');  
     my @packages = split /,/,$packages;  
     my $allow_print_points = 0;  
     foreach my $partial_key (@packages) {  
  if ($partial_key=~m/^part_0$/) {  
     $allow_print_points=1;  
  }  
     }  
     my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");  
     if (defined($maxtries) && $maxtries < 0) { $allow_print_points=0; }  
     if (lc($env{'course.'.$env{'request.course.id'}.  
     '.disableexampointprint'}) eq 'yes') {  
  $allow_print_points=0;  
     }  
     my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header');  
     my $begin_doc='\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent ';  
     my $toc_line='\vskip 1 mm\noindent '.$startminipage.  
  '\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';  
   
     #  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 "$duetime\n";  
  if (not $env{'request.symb'} =~ m/\.page_/) {  
     if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') {  
  $result .= $begin_doc.  
     '\textit{Due date: '.$duedate.'} '.$toc_line;  
     } else {  
  $result .= $begin_doc.$toc_line;  
  if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $result .= '\fbox{\textit{'.$weight.' pt}}';}  
     }  
  } else {  
     $result .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\';  
  }  
     } else {  
  if (not $env{'request.symb'} =~ m/\.page_/) {  
     $result .= $begin_doc.$toc_line;  
     if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $result .= '\fbox{\textit{'.$weight.' pt}}';}  
  } else {  
     $result .= '\vskip 1mm \\\\\\\\';  
  }  
     }  
  }   }
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start.   $result.=$head_tag_start."</head>".$body_tag_start.$form_tag_start.
Line 741  sub start_problem { Line 706  sub start_problem {
   
 sub end_problem {  sub end_problem {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result= &Apache::lonxml::endredirection(); # started in &start_problem      my $result;
   
       if (!$Apache::lonxml::metamode) {
    $result = &Apache::lonxml::endredirection(); #started in &start_problem
       }
   
       if ($target eq 'tex') {
   
    # Figure out the front matter and replace the
    # INSERTTEXFRONTMATTERHERE in result with it.  note that we do
    # this in end_problem because whether or not we display due
    # dates depends on whether due dates have already been
    # displayed in the problem parts.
   
    my $frontmatter   = '';
    my $startminipage = '';
    if (not $env{'form.problem_split'}=~/yes/) {
       $startminipage = '\begin{minipage}{\textwidth}';
    }
    my $id = $Apache::inputtags::part;
    my $weight = &Apache::lonnet::EXT("resource.$id.weight");
    my $packages=&Apache::lonnet::metadata($env{'request.uri'},'packages');
    my @packages = split /,/,$packages;
    my $allow_print_points = 0;
    foreach my $partial_key (@packages) {
       if ($partial_key=~m/^part_0$/) {
    $allow_print_points=1;
       }
    }
    my $maxtries = &Apache::lonnet::EXT("resource.$id.maxtries");
    if (defined($maxtries) && $maxtries < 0) { $allow_print_points=0; }
    if (lc($env{'course.'.$env{'request.course.id'}.
    '.disableexampointprint'}) eq 'yes') {
       $allow_print_points=0;
    }
    my $name_of_resourse= &Apache::lonxml::latex_special_symbols(&get_resource_name($parstack,$safeeval),'header');
    my $begin_doc='\begin{document} \typeout{STAMPOFPASSEDRESOURCESTART Resource <h2>"'.$name_of_resourse.'"</h2> located in <br /><small><b>'.$env{'request.uri'}.'</b></small><br /> STAMPOFPASSEDRESOURCEEND} \noindent ';
    my $toc_line='\vskip 1 mm\noindent '.$startminipage.
       '\addcontentsline{toc}{subsection}{'.$name_of_resourse.'}';
   
    #  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;
    } 
   
    # We display the due date iff it is not the same as the last
    # duedate in problem header ($due_file_content), and
    # none of our parts displayed a duedate.
    #
    my $parts_with_displayduedate;
    if (defined $Apache::outputtags::showonce{'displayduedate'}) {
       $parts_with_displayduedate = 
    scalar(@{$Apache::outputtags::showonce{'displayduedate'}});
    } else {
       $parts_with_displayduedate = 0;
    }
    if (($due_file_content != $duetime) && ($parts_with_displayduedate == 0) ) {
       $temp_file = Apache::File->new('>'.$filename);
       print $temp_file "$duetime\n";
       if (not $env{'request.symb'} =~ m/\.page_/) {
    if(not $duedate=~m/1969/ and $Apache::lonhomework::type ne 'exam') {
       $frontmatter .= $begin_doc.
    '\textit{Due date: '.$duedate.'} '.$toc_line;
    } else {
       $frontmatter.= $begin_doc.$toc_line;
       if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';}
    }
       } else {
    $frontmatter .= '\vskip 1mm\textit{Due date: '.$duedate.'} \\\\\\\\';
       }
    } else {
       if (not $env{'request.symb'} =~ m/\.page_/) {
    $frontmatter .= $begin_doc.$toc_line;
    if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';}
       } else {
    $frontmatter .= '\vskip 1mm \\\\\\\\';
       }
    }
    $result =~ s/INSERTTEXFRONTMATTERHERE/$frontmatter/;
       }
   
     my $status=$Apache::inputtags::status['-1'];      my $status=$Apache::inputtags::status['-1'];
     if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||      if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
Line 750  sub end_problem { Line 809  sub end_problem {
     # if part is zero, no <part>s existed, so we need to the grading      # if part is zero, no <part>s existed, so we need to the grading
     if ($status eq 'CAN_ANSWER' ||$Apache::lonhomework::scantronmode) {      if ($status eq 'CAN_ANSWER' ||$Apache::lonhomework::scantronmode) {
  &Apache::inputtags::grade;   &Apache::inputtags::grade;
       } elsif ($status eq 'NEEDS_CHECKIN') {
    # no need to grade, and don't want to hide data
     } else {      } else {
  # move any submission data to .hidden   # move any submission data to .hidden
  &Apache::inputtags::hidealldata($Apache::inputtags::part);   &Apache::inputtags::hidealldata($Apache::inputtags::part);
Line 811  sub end_problem { Line 872  sub end_problem {
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  &Apache::lonxml::debug("in end_problem with $target, edit");   &Apache::lonxml::debug("in end_problem with $target, edit");
  $result .= &problem_edit_footer();   $result .= &problem_edit_footer();
       } elsif ($target eq 'modified') {
    $result .= $token->[2];
    $result.=&Apache::edit::handle_insertafter($token->[1]);
     }      }
   
     if ($env{'request.state'} eq 'construct' && $target eq 'web') {      if ($env{'request.state'} eq 'construct' && $target eq 'web') {
Line 1182  sub ordered_show_check { Line 1246  sub ordered_show_check {
   
 sub start_part {  sub start_part {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     &Apache::lonxml::startredirection(); # we'll use redirection to fix up       if (!$Apache::lonxml::metamode) {
                                          # duedates.   &Apache::lonxml::startredirection(); # we'll use redirection to fix up 
                                        # duedates.
       }
     my $result='';      my $result='';
     my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);      my $id= &Apache::lonxml::get_param('id',$parstack,$safeeval);
     if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }      if ($id =~ /^\s*$/) { $id = $Apache::lonxml::curdepth; }
Line 1292  sub end_part { Line 1358  sub end_part {
     my $status=$Apache::inputtags::status['-1'];      my $status=$Apache::inputtags::status['-1'];
     my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);      my $hidden=&Apache::loncommon::check_if_partid_hidden($Apache::inputtags::part);
     my $in_order_show=&ordered_show_check();      my $in_order_show=&ordered_show_check();
     my $result= &Apache::lonxml::endredirection(); # started in &start_part      my $result;
       if (!$Apache::lonxml::metamode) {
    $result = &Apache::lonxml::endredirection(); # started in &start_part
       }
     if ($target eq 'grade') {      if ($target eq 'grade') {
  if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) &&   if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) &&
     !$hidden && $in_order_show) {      !$hidden && $in_order_show) {
Line 1312  sub end_part { Line 1381  sub end_part {
  if ($$tagstack[-2] eq 'td' and $target eq 'tex') {$result.='\end{minipage}';}    if ($$tagstack[-2] eq 'td' and $target eq 'tex') {$result.='\end{minipage}';} 
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result.=&Apache::edit::end_table();   $result.=&Apache::edit::end_table();
       } elsif ($target eq 'modified') {
    $result .= $token->[2];
    $result.=&Apache::edit::handle_insertafter($token->[1]);
     }      }
     pop @Apache::inputtags::status;      pop @Apache::inputtags::status;
     $Apache::inputtags::part='';      $Apache::inputtags::part='';

Removed from v.1.315  
changed lines
  Added in v.1.325


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>