Diff for /loncom/homework/structuretags.pm between versions 1.465.2.5 and 1.478

version 1.465.2.5, 2010/09/14 02:46:20 version 1.478, 2010/11/03 17:06:28
Line 161  function setmode(form,probmode) { Line 161  function setmode(form,probmode) {
 ENDSCRIPT  ENDSCRIPT
 }  }
   
   sub file_delchk_js {
       my $delfilewarn = &mt('You have indicated you wish to delete some files previously included for submission.').'\\n'.
                             &mt('Deleted files will not be graded.').' '.
                             &mt('Submit Answer?');
       return <<"ENDSCRIPT";
   <script type="text/javascript">
   function file_deletion_check(formname) {
       var str = new RegExp("^HWFILE.+_delete\$");
       var delfilecount = 0;
       var elemnum = formname.elements.length;
       if (elemnum == 0) {
           return true;
       }
       for (i=0; i<formname.elements.length; i++) {
           var id = formname.elements[i].id;
           if (id != '') {
               if (str.test(id)) {
                   if (formname.elements[i].type == 'checkbox') {
                       if (formname.elements[i].checked) {
                           delfilecount ++;
                       }
                   }
               }
           }
       }
       if (delfilecount > 0) {
           if (confirm("$delfilewarn")) {
               return true;
           } else {
               return false;
           }
       } else {
           return true;
       }
   }
   </script>
   ENDSCRIPT
   }
   
 sub page_start {  sub page_start {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name,      my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$name,
  $extra_head)=@_;   $extra_head)=@_;
Line 185  sub page_start { Line 224  sub page_start {
                               );                                );
         $extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);          $extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);
     }      }
       my $is_task = ($env{'request.uri'} =~ /\.task$/);
       if ($is_task) {
           $extra_head .= &file_delchk_js();
       }
   
     my %body_args;      my %body_args;
     if (defined($found{'html'})) {      if (defined($found{'html'})) {
Line 210  sub page_start { Line 253  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 286  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 281  sub page_start { Line 320  sub page_start {
  if ($target eq 'edit') {   if ($target eq 'edit') {
     $form_tag_start.=&Apache::edit::form_change_detection();      $form_tag_start.=&Apache::edit::form_change_detection();
  }   }
           if ($is_task) {
               $form_tag_start .= ' onsubmit="return file_deletion_check(this);"';
           }
  $form_tag_start.='>'."\n";   $form_tag_start.='>'."\n";
   
  my $symb=&Apache::lonnet::symbread();   my $symb=&Apache::lonnet::symbread();
Line 664  sub store_aggregates { Line 706  sub store_aggregates {
     foreach my $part (@parts) {      foreach my $part (@parts) {
         if ($env{'request.role'} =~/^st/) {          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) {              if ($Apache::lonhomework::results{'resource.'.$part.'.tries'} == 1) {
                 $aggregate{$symb."\0".$part."\0users"} = 1;                  $aggregate{$symb."\0".$part."\0users"} = 1;
             } else {              } else {
                 my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]);                  my (undef,$last_reset) = &Apache::grades::get_last_resets($symb,$env{'request.course.id'},[$part]); 
                 if ($last_reset) {                  if ($last_reset) {
                     if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) {                      if (&Apache::grades::get_num_tries(\%Apache::lonhomework::history,$last_reset,$part) == 0) {
                         $aggregate{$symb."\0".$part."\0users"} = 1;                          $aggregate{$symb."\0".$part."\0users"} = 1;
Line 681  sub store_aggregates { Line 723  sub store_aggregates {
             }              }
             $aggregate{$symb."\0".$part."\0attempts"} = 1;              $aggregate{$symb."\0".$part."\0attempts"} = 1;
         }          }
         if (($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurvey') ||          if (($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurvey') || 
             ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurveycred')) {              ($Apache::lonhomework::results{'resource.'.$part.'.type'} eq 'anonsurveycred')) {
             $anoncounter{$symb."\0".$part} = 1;              $anoncounter{$symb."\0".$part} = 1;
             my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}};              my $needsrelease = $Apache::lonnet::needsrelease{'parameter:type:'.$Apache::lonhomework::results{'resource.'.$part.'.type'}};
             if ($needsrelease) {              if ($needsrelease) {   
                 my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};                  my $curr_required = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'};
                 if ($curr_required eq '') {                  if ($curr_required eq '') {
                     &Apache::lonnet::update_released_required($needsrelease);                      &Apache::lonnet::update_released_required($needsrelease);
Line 787  sub init_problem_globals { Line 829  sub init_problem_globals {
  &Apache::lonhomework::reset_show_problem_status();   &Apache::lonhomework::reset_show_problem_status();
  $Apache::lonhomework::ignore_response_errors=1;   $Apache::lonhomework::ignore_response_errors=1;
     }      }
       @Apache::functionplotresponse::callscripts=();
     @Apache::inputtags::responselist = ();      @Apache::inputtags::responselist = ();
     @Apache::inputtags::importlist = ();      @Apache::inputtags::importlist = ();
     @Apache::inputtags::previous=();      @Apache::inputtags::previous=();
Line 814  sub reset_problem_globals { Line 857  sub reset_problem_globals {
     undef($Apache::lonhomework::type);      undef($Apache::lonhomework::type);
     undef($Apache::lonhomework::scantronmode);      undef($Apache::lonhomework::scantronmode);
     undef($Apache::lonhomework::ignore_response_errors);      undef($Apache::lonhomework::ignore_response_errors);
       undef(@Apache::functionplotresponse::callscripts);
     &Apache::lonhomework::reset_show_problem_status();      &Apache::lonhomework::reset_show_problem_status();
 }  }
   
Line 917  sub start_problem { Line 961  sub start_problem {
     if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval); }      if ($target eq 'analyze') { my $rndseed=&setup_rndseed($safeeval); }
     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 'tex') {
  #handle exam checkout  
  if ($Apache::lonhomework::type eq 'exam') {  
     my $token=  
  $Apache::lonhomework::history{"resource.0.outtoken"};  
     if (($env{'form.doescheckout'}) && (!$token)) {  
  $token=&Apache::lonxml::maketoken();  
  $Apache::lonhomework::history{"resource.0.outtoken"}=  
     $token;  
     }  
     $result.=&Apache::lonxml::printtokenheader($target,$token);  
  }  
  if ($env{'form.markaccess'}) {   if ($env{'form.markaccess'}) {
     my @interval=&Apache::lonnet::EXT("resource.0.interval");      my @interval=&Apache::lonnet::EXT("resource.0.interval");
     &Apache::lonnet::set_first_access($interval[1]);      &Apache::lonnet::set_first_access($interval[1]);
Line 1217  sub end_problem { Line 1250  sub end_problem {
  }   }
     }      }
  }   }
           if ($target eq 'web') {
              $result.=&Apache::functionplotresponse::init_script();
           }
  if ($target eq 'grade') {   if ($target eq 'grade') {
     &Apache::lonhomework::showhash(%Apache::lonhomework::results);      &Apache::lonhomework::showhash(%Apache::lonhomework::results);
     &finalize_storage();      &finalize_storage();
Line 1718  sub ordered_show_check { Line 1754  sub ordered_show_check {
     return $in_order_show;      return $in_order_show;
 }  }
   
   
 sub start_startpartmarker {  sub start_startpartmarker {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;      my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result='';      my $result='';
Line 1726  sub start_startpartmarker { Line 1763  sub start_startpartmarker {
         $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.=&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();          $result.=&Apache::edit::end_table();
   
     }      } 
     return $result;      return $result;
 }  }
   
Line 1756  sub end_endpartmarker { Line 1793  sub end_endpartmarker {
     return @result;      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 1845  sub start_part { Line 1886  sub start_part {
   
     }      }
  } elsif ($target eq 'web') {   } elsif ($target eq 'web') {
     $result.='<a name="'.&escape($Apache::inputtags::part).'"></a>';      $result.='<a name="'.&escape($Apache::inputtags::part).'" ></a>';
  }   }
     }      }
  }   }
Line 2058  sub end_startouttext { Line 2099  sub end_startouttext {
                  .'</span></td>'                   .'</span></td>'
          .'<td align="left"><span id="math_'.$areaid.'" />'           .'<td align="left"><span id="math_'.$areaid.'" />'
  .&Apache::lonhtmlcommon::dragmath_button($areaid,1)   .&Apache::lonhtmlcommon::dragmath_button($areaid,1)
  .'</td>'   .'<span></td>'
  .'<td>'   .'<td>'
  .&Apache::edit::insertlist($target,$token)   .&Apache::edit::insertlist($target,$token)
  .'</td>'   .'</td>'

Removed from v.1.465.2.5  
changed lines
  Added in v.1.478


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