Diff for /loncom/homework/structuretags.pm between versions 1.259 and 1.273

version 1.259, 2004/07/02 08:14:41 version 1.273, 2004/11/30 23:28:57
Line 36  use Apache::File(); Line 36  use Apache::File();
 use Apache::lonmenu;  use Apache::lonmenu;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonxml;  use Apache::lonxml;
   use Time::HiRes qw( gettimeofday tv_interval );
 BEGIN {  BEGIN {
     &Apache::lonxml::register('Apache::structuretags',('block','languageblock','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startouttext','endouttext','simpleeditbutton','definetag'));      &Apache::lonxml::register('Apache::structuretags',('block','languageblock','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startouttext','endouttext','simpleeditbutton','definetag'));
 }  }
Line 83  sub page_start { Line 83  sub page_start {
  $result=&Apache::londefdef::start_html($target,$token,$tagstack,   $result=&Apache::londefdef::start_html($target,$token,$tagstack,
        $parstack,$parser,$safeeval);         $parstack,$parser,$safeeval);
  $head_tag_start='<head>'.&Apache::lonmenu::registerurl(undef,$target).   $head_tag_start='<head>'.&Apache::lonmenu::registerurl(undef,$target).
     &Apache::lonhtmlcommon::htmlareaheaders();      &Apache::lonhtmlcommon::htmlareaheaders().
       &Apache::lonhtmlcommon::spellheader().
       &Apache::lonxml::fontsettings();     
     }      }
     my $body_tag_start;      my $body_tag_start;
     if (!defined($found{'body'})) {      if (!defined($found{'body'}) && $ENV{'request.state'} eq 'construct'
  $body_tag_start='<body onLoad="'.&Apache::lonmenu::loadevents().'" '.   && $ENV{'environment.remote'} eq 'off') {
     'onUnload="'.&Apache::lonmenu::unloadevents().'" ';   $body_tag_start=&Apache::loncommon::bodytag();
       } elsif (!defined($found{'body'})) {
    $body_tag_start='<body onload="'.&Apache::lonmenu::loadevents().'" '.
       'onunload="'.&Apache::lonmenu::unloadevents().'" ';
  my $background=&Apache::lonxml::get_param('background',$parstack,   my $background=&Apache::lonxml::get_param('background',$parstack,
   $safeeval);    $safeeval);
  if ($ENV{'browser.imagesuppress'} eq 'on') { $background=''; }   if ($ENV{'browser.imagesuppress'} eq 'on') { $background=''; }
Line 122  sub page_start { Line 127  sub page_start {
     }      }
     my $form_tag_start;      my $form_tag_start;
     if (!defined($found{'form'})) {      if (!defined($found{'form'})) {
  $form_tag_start='<form name="lonhomework" method="POST" action="'.   $form_tag_start='<form name="lonhomework" method="post" action="';
     $ENV{'request.uri'}.'">';   my $uri=$ENV{'request.uri'};
    if ($ENV{'request.enc'}) { $uri=&Apache::lonenc::encrypted($uri); }
    $form_tag_start.=$uri.'">';
     }      }
     return ($result,$head_tag_start,$body_tag_start,$form_tag_start);      return ($result,$head_tag_start,$body_tag_start,$form_tag_start);
 }  }
Line 183  sub setup_rndseed { Line 190  sub setup_rndseed {
     return $rndseed;      return $rndseed;
 }  }
   
   sub remember_problem_state {
       return '
          <input type="hidden" name="problemstate" value="'.$ENV{'form.problemstate'}.'" />
          <input type="hidden" name="problemtype" value="'.$ENV{'form.problemtype'}.'" />
          <input type="hidden" name="problemstatus" value="'.$ENV{'form.problemstatus'}.'" />';
   }
   
 sub problem_edit_header {  sub problem_edit_header {
     return '<input type="hidden" name="submitted" value="edit" />      return '<input type="hidden" name="submitted" value="edit" />'.
    &Apache::structuretags::remember_problem_state().'
        <input type="hidden" name="problemmode" value="'.&mt('Edit').'" />         <input type="hidden" name="problemmode" value="'.&mt('Edit').'" />
        <input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" />         <input type="submit" name="problemmode" accesskey="d" value="'.&mt('Discard Edits and View').'" />
        <input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" />         <input type="submit" name="problemmode" accesskey="x" value="'.&mt('EditXML').'" />
        <input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" /> <hr />         <input type="submit" name="Undo" accesskey="u" value="'.&mt('undo').'" /> <hr />
        <input type="submit" name="submit" accesskey="s" value="'.&mt('Submit Changes and Edit').'" />         <input type="submit" name="submit" accesskey="s" value="'.&mt('Submit Changes and Edit').'" />
        <input type="submit" name="submit" accesskey="v" value="'.&mt('Submit Changes and View').'" /><table><tr><td>'.         <input type="submit" name="submit" accesskey="v" value="'.&mt('Submit Changes and View').'" /><table><tr><td>'.
        &Apache::loncommon::help_open_topic('Problem_Editor_XML_Index',         &Apache::loncommon::help_open_menu('','Problem Editing Help','Problem_Editor_XML_Index','',5,'Authoring',undef,undef,undef,'Problem Editing Help')
    'Problem Editing Help').'</td><td>'.         .'</td></tr></table>'.
        &Apache::loncommon::help_open_faq(5).  
        &Apache::loncommon::help_open_bug('Authoring').'</td></tr></table>'.  
        '<table border="0"><tr><td bgcolor="#DDDDDD">';         '<table border="0"><tr><td bgcolor="#DDDDDD">';
 }  }
   
Line 223  sub problem_web_to_edit_header { Line 236  sub problem_web_to_edit_header {
              <input type="submit" name="newrandomization" accesskey="a" value="'.&mt('New Randomization').'" />               <input type="submit" name="newrandomization" accesskey="a" value="'.&mt('New Randomization').'" />
              <input type="submit" name="resetdata" accesskey="r" value="'.&mt('Reset Submissions').'" />               <input type="submit" name="resetdata" accesskey="r" value="'.&mt('Reset Submissions').'" />
              <nobr><input type="submit" name="changerandseed" value="'.&mt('Change Random Seed To:').'" />               <nobr><input type="submit" name="changerandseed" value="'.&mt('Change Random Seed To:').'" />
               <input type="text" name="rndseed" width="10" value="'.                <input type="text" name="rndseed" size="10" value="'.
        $rndseed.'"         $rndseed.'"
            onChange="javascript:document.lonhomework.changerandseed.click()" /></nobr>             onchange="javascript:document.lonhomework.changerandseed.click()" /></nobr>
              <input type="checkbox" name="showallfoils" ';               <input type="checkbox" name="showallfoils" ';
     if (defined($ENV{'form.showallfoils'})) { $result.='checked="on"'; }      if (defined($ENV{'form.showallfoils'})) { $result.='checked="on"'; }
     $result.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils').      $result.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils').
Line 235  sub problem_web_to_edit_header { Line 248  sub problem_web_to_edit_header {
 <nobr>  <nobr>
 Problem Status:  Problem Status:
 <select name='problemstate'>  <select name='problemstate'>
   <option name=''></option>    <option value=''></option>
   ".&option('CLOSED'               ,'problemstate').&mt("Closed")."</option>    ".&option('CLOSED'               ,'problemstate').&mt("Closed")."</option>
   ".&option('CAN_ANSWER'           ,'problemstate').&mt("Answerable")."</option>    ".&option('CAN_ANSWER'           ,'problemstate').&mt("Answerable")."</option>
   ".&option('CANNOT_ANSWER_tries'  ,'problemstate').&mt("Open with full tries")."</option>    ".&option('CANNOT_ANSWER_tries'  ,'problemstate').&mt("Open with full tries")."</option>
Line 246  Problem Status: Line 259  Problem Status:
 <nobr>  <nobr>
 Problem Type:  Problem Type:
 <select name='problemtype'>  <select name='problemtype'>
   <option name=''></option>    <option value=''></option>
   ".&option('exam'   ,'problemtype').&mt("Exam Problem")."</option>    ".&option('exam'   ,'problemtype').&mt("Exam Problem")."</option>
   ".&option('problem','problemtype').&mt("Homework problem")."</option>    ".&option('problem','problemtype').&mt("Homework problem")."</option>
   ".&option('survey' ,'problemtype').&mt("Survey Question")."</option>    ".&option('survey' ,'problemtype').&mt("Survey Question")."</option>
Line 328  sub checkout_msg { Line 341  sub checkout_msg {
 <font color="red">  <font color="red">
 <p>$lt{'warning'}</p>  <p>$lt{'warning'}</p>
 </font>  </font>
 <form name="checkout" method="POST" action="$ENV{'request.uri'}">  <form name="checkout" method="post" action="$ENV{'request.uri'}">
 <input type="hidden" name="doescheckout" value="yes" />  <input type="hidden" name="doescheckout" value="yes" />
 <input type="button" name="checkoutbutton" value="$lt{'checkout'}" onClick="javascript:if (confirm('$lt{'checkout?'}')) { document.checkout.submit(); }" />  <input type="button" name="checkoutbutton" value="$lt{'checkout'}" onClick="javascript:if (confirm('$lt{'checkout?'}')) { document.checkout.submit(); }" />
 </form>  </form>
Line 342  sub firstaccess_msg { Line 355  sub firstaccess_msg {
     &Apache::lonxml::debug("map is $map title is $foldertitle");      &Apache::lonxml::debug("map is $map title is $foldertitle");
     return (<<ENDCHECKOUT);      return (<<ENDCHECKOUT);
 <h2>The resources in "$foldertitle" are open for a limited time. Once you click the 'Show Resource' button below you have $time to complete all resources "$foldertitle".</h2>  <h2>The resources in "$foldertitle" are open for a limited time. Once you click the 'Show Resource' button below you have $time to complete all resources "$foldertitle".</h2>
 <form name="markaccess" method="POST" action="$ENV{'request.uri'}">  <form name="markaccess" method="post" action="$ENV{'request.uri'}">
 <input type="hidden" name="markaccess" value="yes" />  <input type="hidden" name="markaccess" value="yes" />
 <input type="button" name="accessbutton" value="Show Resource" onClick="javascript:if (confirm('Start Timer?')) { document.markaccess.submit(); }" />  <input type="button" name="accessbutton" value="Show Resource" onClick="javascript:if (confirm('Start Timer?')) { document.markaccess.submit(); }" />
 </form>  </form>
Line 355  sub init_problem_globals { Line 368  sub init_problem_globals {
     if ($type eq 'problem') {      if ($type eq 'problem') {
  $Apache::inputtags::part='0';   $Apache::inputtags::part='0';
  @Apache::inputtags::partlist=('0');   @Apache::inputtags::partlist=('0');
    $Apache::lonhomework::problemstatus=&get_problem_status('0');
  $Apache::lonhomework::problemstatus=&get_problem_status('0')   $Apache::lonhomework::ignore_response_errors=0;
     } else {      } elsif ($type eq 'library') {
  $Apache::inputtags::part='';   $Apache::inputtags::part='';
  @Apache::inputtags::partlist=();   @Apache::inputtags::partlist=();
  $Apache::lonhomework::problemstatus='';   $Apache::lonhomework::problemstatus='';
    $Apache::lonhomework::ignore_response_errors=1;
     }      }
     @Apache::inputtags::responselist = ();      @Apache::inputtags::responselist = ();
     @Apache::inputtags::importlist = ();      @Apache::inputtags::importlist = ();
Line 396  sub set_problem_state { Line 410  sub set_problem_state {
   
 sub get_problem_status {  sub get_problem_status {
     my ($part)=@_;      my ($part)=@_;
     my $problem_status=&Apache::lonnet::EXT("resource.$part.problemstatus");      my $problem_status;
     &Apache::lonxml::debug("problem status for $part is $problem_status");  
     &Apache::lonxml::debug("env probstat is ".$ENV{'form.problemstatus'});  
     if ($ENV{'request.state'} eq 'construct' &&      if ($ENV{'request.state'} eq 'construct' &&
  defined($ENV{'form.problemstatus'})) {   defined($ENV{'form.problemstatus'})) {
  $problem_status=$ENV{'form.problemstatus'};   $problem_status=$ENV{'form.problemstatus'};
       } else {
    $problem_status=&Apache::lonnet::EXT("resource.$part.problemstatus");
    &Apache::lonxml::debug("problem status for $part is $problem_status");
    &Apache::lonxml::debug("env probstat is ".$ENV{'form.problemstatus'});
     }      }
     return $problem_status;      return $problem_status;
 }  }
Line 485  sub start_problem { Line 501  sub start_problem {
     '<input type="submit" name="resetdata"      '<input type="submit" name="resetdata"
                              value="'.&mt('New Problem Variation').'" />'.                               value="'.&mt('New Problem Variation').'" />'.
     '<input type="hidden" name="username"      '<input type="hidden" name="username"
                              value="'.$ENV{'form.username'}.'" /> <br />';                               value="'.$ENV{'form.username'}.'" />';
       if ($ENV{'user.adv'}) {
    $form_tag_start.=
       ' <input type="checkbox" name="showallfoils" ';
    if (defined($ENV{'form.showallfoils'})) {
       $form_tag_start.='checked="on"';
    }
    $form_tag_start.= ' />'.&mt('&nbsp;Show&nbsp;All&nbsp;Foils');
       }
       $form_tag_start.='<hr />';
  }   }
  ($status,$accessmsg) = &Apache::lonhomework::check_access('0');   ($status,$accessmsg) = &Apache::lonhomework::check_access('0');
  push (@Apache::inputtags::status,$status);   push (@Apache::inputtags::status,$status);
Line 647  sub end_problem { Line 672  sub end_problem {
     $endminipage = '\end{minipage}';      $endminipage = '\end{minipage}';
  }   }
                 if ($ENV{'form.print_discussions'} eq 'yes') {                  if ($ENV{'form.print_discussions'} eq 'yes') {
     $result.=&Apache::lonxml::xmlend();      $result.=&Apache::lonxml::xmlend($target,$parser);
     $result=~s/<\/html>//;      $result=~s/<\/html>//;
  }  
  $result .= '\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}';  
  if (not $ENV{'request.symb'} =~ m/\.page_/) {  
     $result .= $endminipage.'\end{document} ';  
  } else {   } else {
     $result .= '';      $result .= '\keephidden{ENDOFPROBLEM}\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}';
       if (not $ENV{'request.symb'} =~ m/\.page_/) {
    $result .= $endminipage.'\end{document} ';
       } else {
    $result .= '';
       }
  }   }
     }      }
  }   }
Line 862  sub start_instructorcomment { Line 888  sub start_instructorcomment {
     if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||      if ($target eq 'web' || $target eq 'grade' || $target eq 'answer' ||
  $target eq 'tex' || $target eq 'analyze') {   $target eq 'tex' || $target eq 'analyze') {
         $result=($ENV{'request.role'}=~/^(in|cc|au|ca|li)/);          $result=($ENV{'request.role'}=~/^(in|cc|au|ca|li)/);
  if ( ! $result ) {   if ( (! $result) or ($ENV{'form.instructor_comments'} eq 'hide')) {
     my $skip=&Apache::lonxml::get_all_text("/instructorcomment",      my $skip=&Apache::lonxml::get_all_text("/instructorcomment",
    $parser,$style);     $parser,$style);
     &Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]");      &Apache::lonxml::debug("skipping ahead :$skip: $$parser[-1]");
Line 932  sub end_while { Line 958  sub end_while {
  while ($return) {   while ($return) {
     if (time-$starttime >      if (time-$starttime >
  $Apache::lonnet::perlvar{'lonScriptTimeout'}) {   $Apache::lonnet::perlvar{'lonScriptTimeout'}) {
  $return = 0; $error=1; next;   #$return = 0; $error=1; next;
     }      }
     $result.=&Apache::scripttag::xmlparse($bodytext);      $result.=&Apache::scripttag::xmlparse($bodytext);
     $return = &Apache::run::run($code,$safeeval);      $return = &Apache::run::run($code,$safeeval);
  }   }
  if ($error) {   if ($error) {
     &Apache::lonxml::error('<pre>'.&mt('Code ran too long. It ran for more than').' '.$Apache::lonnet::perlvar{'lonScriptTimeout'}.' '.&mt('seconds occured while running &lt;while$gt; on line').' '.$line.'</pre>');      &Apache::lonxml::error('<pre>'.&mt('Code ran too long. It ran for more than').' '.$Apache::lonnet::perlvar{'lonScriptTimeout'}.' '.&mt('seconds occured while running &lt;while&gt; on line').' '.$line.'</pre>');
  }   }
     } elsif ($target eq "edit") {      } elsif ($target eq "edit") {
  $result.= &Apache::edit::tag_end($target,$token,'');   $result.= &Apache::edit::tag_end($target,$token,'');
Line 1085  sub start_part { Line 1111  sub start_part {
     } else {      } else {
  if ($target eq 'tex') {   if ($target eq 'tex') {
     if (not $ENV{'form.problem_split'}=~/yes/) {      if (not $ENV{'form.problem_split'}=~/yes/) {
  $result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent';   if ($$tagstack[-2] eq 'td') {
       $result.='\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent';
    } else {
       $result.='\noindent \end{minipage}\vskip 0 mm \noindent \begin{minipage}{\textwidth}\noindent';
    }
     }      }
     my $weight = &Apache::lonnet::EXT("resource.$id.weight");      my $weight = &Apache::lonnet::EXT("resource.$id.weight");
     my $allkeys=&Apache::lonnet::metadata($ENV{'request.uri'},'packages');      my $allkeys=&Apache::lonnet::metadata($ENV{'request.uri'},'packages');
Line 1145  sub end_part { Line 1175  sub end_part {
     $gradestatus='';      $gradestatus='';
  }   }
  $result=$gradestatus;   $result=$gradestatus;
    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();
     }      }
Line 1332  sub delete_startouttext { Line 1363  sub delete_startouttext {
 sub start_simpleeditbutton {  sub start_simpleeditbutton {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result='';      my $result='';
     if (($target eq 'web') &&      if (($ENV{'form.simple_edit_button'} ne 'off') &&
    ($target eq 'web') &&
         (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {          (&Apache::lonnet::allowed('srm',$ENV{'request.course.id'}))) {
         my $url=$ENV{'request.noversionuri'};          my $url=$ENV{'request.noversionuri'};
         $url=~s/\?.*$//;          $url=~s/\?.*$//;
  $result='<table width="100%" bgcolor="#FFFFAA" border="2"><tr><td>'.   $result='<table width="100%" bgcolor="#FFFFAA" border="2"><tr><td>'.
                 '<a href="'.$url.'/smpedit">'.&mt('Simple Problem Editor').'</a> - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.').                  '<a href="'.$url.'/smpedit">'.&mt('Edit').'</a> - '.&mt('Note: it can take up to 10 minutes for changes to take effect for all users.').
 &Apache::loncommon::help_open_topic('Caching').'</td></tr></table><br />';  &Apache::loncommon::help_open_topic('Caching').'</td></tr></table><br />';
     }      }
     return $result;      return $result;

Removed from v.1.259  
changed lines
  Added in v.1.273


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