Diff for /loncom/homework/structuretags.pm between versions 1.465.2.4 and 1.466

version 1.465.2.4, 2010/08/16 18:38:28 version 1.466, 2010/03/10 21:25:36
Line 66  use lib '/home/httpd/lib/perl/'; Line 66  use lib '/home/httpd/lib/perl/';
 use LONCAPA;  use LONCAPA;
     
 BEGIN {  BEGIN {
     &Apache::lonxml::register('Apache::structuretags',('block','languageblock','translated','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startpartmarker','startouttext','endpartmarker','endouttext','simpleeditbutton','definetag'));      &Apache::lonxml::register('Apache::structuretags',('block','languageblock','translated','instructorcomment','while','randomlist','problem','library','web','tex','part','preduedate','postanswerdate','solved','notsolved','problemtype','startouttext','endouttext','simpleeditbutton','definetag'));
 }  }
   
 sub start_web {  sub start_web {
Line 177  sub page_start { Line 177  sub page_start {
    $parstack,$parser,$safeeval);     $parstack,$parser,$safeeval);
     }      }
   
     $extra_head .= &homework_js().      $extra_head .= &homework_js();
                    &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");  
     if (&Apache::lonhtmlcommon::htmlareabrowser()) {      if ($env{'environment.wysiwygeditor'} eq 'on') {
         my %textarea_args = (   $extra_head .= &Apache::lonhtmlcommon::dragmath_js("FCKEditMathPopup");
                                 dragmath => 'math',      } else {
                               );          $extra_head .= &Apache::lonhtmlcommon::dragmath_js("EditMathPopup");
         $extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);  
     }      }
   
     my %body_args;      my %body_args;
Line 210  sub page_start { Line 209  sub page_start {
     } elsif (!defined($found{'body'})       } elsif (!defined($found{'body'}) 
      && $env{'request.state'} eq 'construct') {       && $env{'request.state'} eq 'construct') {
  if ($target eq 'web' || $target eq 'edit') {   if ($target eq 'web' || $target eq 'edit') {
     if ($env{'environment.remote'} ne 'off') {  
  $body_args{'only_body'}  = 1;  
     }  
         # Breadcrumbs for Construction Space          # Breadcrumbs for Construction Space
         &Apache::lonhtmlcommon::clear_breadcrumbs();          &Apache::lonhtmlcommon::clear_breadcrumbs();
         &Apache::lonhtmlcommon::add_breadcrumb({          &Apache::lonhtmlcommon::add_breadcrumb({
Line 246  sub page_start { Line 242  sub page_start {
         # $body_args{'no_title'}       = 1;          # $body_args{'no_title'}       = 1;
         $body_args{'force_register'} = 1;          $body_args{'force_register'} = 1;
         $body_args{'add_entries'}    = \%add_entries;          $body_args{'add_entries'}    = \%add_entries;
         if ($env{'environment.remote'} eq 'off'          if ( $env{'request.state'} eq   'construct') {
             && $env{'request.state'} eq   'construct') {  
             $body_args{'only_body'}  = 1;              $body_args{'only_body'}  = 1;
         }          }
     }      }
Line 406  sub problem_edit_footer { Line 401  sub problem_edit_footer {
   <hr style="clear:both;" />    <hr style="clear:both;" />
 </div>  </div>
 '.  '.
   
       &Apache::lonhtmlcommon::htmlareaselectactive(&Apache::lonhtmlcommon::get_htmlareafields()).
     "\n</form>\n".&Apache::loncommon::end_page();      "\n</form>\n".&Apache::loncommon::end_page();
 }  }
   
Line 632  sub finalize_storage { Line 629  sub finalize_storage {
     $result=&Apache::lonnet::cstore(\%Apache::lonhomework::results,      $result=&Apache::lonnet::cstore(\%Apache::lonhomework::results,
     $symb,$courseid,$domain,$name);      $symb,$courseid,$domain,$name);
     &Apache::lonxml::debug('Store return message:'.$result);      &Apache::lonxml::debug('Store return message:'.$result);
             &store_aggregates($symb,$courseid);              if ($env{'request.role'} =~/^st/) {
                   &store_aggregates($symb,$courseid);
               }
  }   }
     } else {      } else {
  &Apache::lonxml::debug('Nothing to store');   &Apache::lonxml::debug('Nothing to store');
Line 652  item store_aggregates() Line 651  item store_aggregates()
   
 sub store_aggregates {  sub store_aggregates {
     my ($symb,$courseid) = @_;      my ($symb,$courseid) = @_;
     my (%aggregate,%anoncounter);      my %aggregate;
     my @parts;      my @parts;
     my $cdomain = $env{'course.'.$env{'request.course.id'}.'.domain'};      my $cdomain = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $cname = $env{'course.'.$env{'request.course.id'}.'.num'};      my $cname = $env{'course.'.$env{'request.course.id'}.'.num'};
Line 662  sub store_aggregates { Line 661  sub store_aggregates {
         }          }
     }      }
     foreach my $part (@parts) {      foreach my $part (@parts) {
         if ($env{'request.role'} =~/^st/) {          if ($Apache::lonhomework::results{'resource.'.$part.'.award'}
             if ($Apache::lonhomework::results{'resource.'.$part.'.award'}      eq 'APPROX_ANS' ||
                 eq 'APPROX_ANS' ||      $Apache::lonhomework::results{'resource.'.$part.'.award'}
                 $Apache::lonhomework::results{'resource.'.$part.'.award'}      eq 'EXACT_ANS') {
                 eq 'EXACT_ANS') {              $aggregate{$symb."\0".$part."\0correct"} = 1;
                 $aggregate{$symb."\0".$part."\0correct"} = 1;  
             }  
             if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) {  
                 $aggregate{$symb."\0".$part."\0users"} = 1;  
             } else {  
                 my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]);  
                 if ($last_reset) {  
                     if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) {  
                         $aggregate{$symb."\0".$part."\0users"} = 1;  
                     }  
                 }  
             }  
             $aggregate{$symb."\0".$part."\0attempts"} = 1;  
         }          }
         if (($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurvey') ||          if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) {
             ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurveycred')) {              $aggregate{$symb."\0".$part."\0users"} = 1;
             $anoncounter{$symb."\0".$part} = 1;          } else {
             my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}};              my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]); 
             if ($needsrelease) {              if ($last_reset) {
                 my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};                  if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) {
                 if ($curr_required eq '') {                      $aggregate{$symb."\0".$part."\0users"} = 1;
                     &Apache::lonnet::update_released_required($needsrelease);  
                 } else {  
                     my ($currmajor,$currminor) = split(/\./,$curr_required);  
                     my ($needsmajor,$needsminor) = split(/\./,$needsrelease);  
                     if (($currmajor < $needsmajor) || ($currmajor == $needsmajor && $currminor < $needsminor)) {  
                         &Apache::lonnet::update_released_required($needsrelease);  
                     }  
                 }                  }
             }              }
         }          }
           $aggregate{$symb."\0".$part."\0attempts"} = 1;
     }      }
     if (keys (%aggregate) > 0) {      if (keys (%aggregate) > 0) {
  &Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate,   &Apache::lonnet::cinc('nohist_resourcetracker',\%aggregate,
                             $cdomain,$cname);                              $cdomain,$cname);
     }      }
     if (keys(%anoncounter) > 0) {  
         &Apache::lonnet::cinc('nohist_anonsurveys',\%anoncounter,  
                             $cdomain,$cname);  
     }  
 }  }
   
 sub checkout_msg {  sub checkout_msg {
Line 1197  sub end_problem { Line 1173  sub end_problem {
     if ($target ne 'tex' &&      if ($target ne 'tex' &&
  $env{'form.answer_output_mode'} ne 'tex') {   $env{'form.answer_output_mode'} ne 'tex') {
  $result.="</form>";   $result.="</form>";
    $result.= &Apache::lonhtmlcommon::htmlareaselectactive(&Apache::lonhtmlcommon::get_htmlareafields());
     }      }
     if ($target eq 'web') {      if ($target eq 'web') {
  $result.= &Apache::loncommon::end_page({'discussion' => 1});   $result.= &Apache::loncommon::end_page({'discussion' => 1});
Line 1513  sub start_instructorcomment { Line 1490  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 'webgrade') {   $target eq 'tex' || $target eq 'analyze' || $target eq 'webgrade') {
         $result=($env{'request.role'}=~/^(in|cc|co|au|ca|li)/);          $result=($env{'request.role'}=~/^(in|cc|au|ca|li)/);
  if ( (! $result) or ($env{'form.instructor_comments'} eq 'hide')) {   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);
Line 1718  sub ordered_show_check { Line 1695  sub ordered_show_check {
     return $in_order_show;      return $in_order_show;
 }  }
   
 sub start_startpartmarker {  
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;  
     my $result='';  
     if ($target eq 'edit') {  
         $result=&Apache::edit::tag_start($target,$token);  
         $result.=&mt('Marker for the start of a part. Place end marker below to wrap in-between tags into a new part.').'</td></tr>';  
         $result.=&Apache::edit::end_table();  
   
     }  
     return $result;  
 }  
   
 sub end_startpartmarker {  
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;  
     my @result;  
     if ($target eq 'edit') { $result[1]='no'; }  
     return @result;  
 }  
   
 sub start_endpartmarker {  
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;  
     my $result='';  
     if ($target eq 'edit') {  
         $result=&Apache::edit::tag_start($target,$token);  
         $result.=&mt('Marker for the end of a part. Place start marker above to wrap in-between tags into a new part.').'</td></tr>';  
         $result.=&Apache::edit::end_table();  
   
     }  
     return $result;  
 }  
   
 sub end_endpartmarker {  
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;  
     my @result;  
     if ($target eq 'edit') { $result[1]='no'; }  
     return @result;  
 }  
   
 sub start_part {  sub start_part {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     if (!$Apache::lonxml::metamode) {      if (!$Apache::lonxml::metamode) {
Line 2055  sub end_startouttext { Line 1994  sub end_startouttext {
  $result.=&Apache::edit::start_table($token)."<tr><td>".&mt('Text Block')."</td>"   $result.=&Apache::edit::start_table($token)."<tr><td>".&mt('Text Block')."</td>"
                  .'<td><span class="LC_nobreak">'.&mt('Delete?').' '                   .'<td><span class="LC_nobreak">'.&mt('Delete?').' '
                  .&Apache::edit::deletelist($target,$token)                   .&Apache::edit::deletelist($target,$token)
                  .'</span></td>'                   .'</span></td>';
          .'<td align="left"><span id="math_'.$areaid.'" />'          unless ($env{'environment.wysiwygeditor'} eq 'on') {
  .&Apache::lonhtmlcommon::dragmath_button($areaid,1)      $result .= '<td align="left">'
  .'</td>'   .&Apache::lonhtmlcommon::dragmath_button($areaid,1)
  .'<td>'   .'</td>'
  .&Apache::edit::insertlist($target,$token)   .'<td>'
  .'</td>'   .&Apache::edit::insertlist($target,$token)
          .'<td align="right" valign="top">' .   .'</td>';
          &Apache::loncommon::helpLatexCheatsheet().   }
    $result.='<td align="right" valign="top">' .
       &Apache::loncommon::helpLatexCheatsheet().
  &Apache::edit::end_row().   &Apache::edit::end_row().
                  &Apache::edit::start_spanning_row()."\n".                   &Apache::edit::start_spanning_row()."\n".
  &Apache::edit::editfield($token->[1],$text,"",80,8,1);   &Apache::edit::editfield($token->[1],$text,"",80,8,1);

Removed from v.1.465.2.4  
changed lines
  Added in v.1.466


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