Diff for /loncom/homework/structuretags.pm between versions 1.490 and 1.498

version 1.490, 2011/07/04 13:01:57 version 1.498, 2011/12/10 17:53:45
Line 129  sub homework_js { Line 129  sub homework_js {
  <<'JS';   <<'JS';
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  // <![CDATA[
 function setSubmittedPart (part) {  function setSubmittedPart (part,prefix) {
    this.document.lonhomework.submitted.value="part_"+part;      if (typeof(prefix) == 'undefined') {
           this.document.lonhomework.submitted.value="part_"+part;
       } else {
           for (var i=0;i<this.document.lonhomework.elements.length;i++) {
               if (this.document.lonhomework.elements[i].name == prefix+'submitted') {
                   this.document.lonhomework.elements[i].value="part_"+part;
               }
           }
       }
 }  }
   
 function image_response_click (which, e) {  function image_response_click (which, e) {
Line 164  function setmode(form,probmode) { Line 172  function setmode(form,probmode) {
 ENDSCRIPT  ENDSCRIPT
 }  }
   
 sub file_delchk_js {  
     my $delfilewarn = &mt('You have indicated you wish to remove some files previously included in your submission.').'\\n'.  
                       &mt('Continue submission with these files removed?');  
     return <<"ENDSCRIPT";  
 <script type="text/javascript">  
 // <![CDATA[  
 function file_deletion_check(formname) {  
     var elemnum = formname.elements.length;  
     if (elemnum == 0) {  
         return true;  
     }  
     var str = new RegExp("^HWFILE.+_delete\$");  
     var delboxes = new Array();  
     for (var 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) {  
                         delboxes.push(id);  
                     }  
                 }  
             }  
         }  
     }  
     if (delboxes.length > 0) {  
         if (confirm("$delfilewarn")) {  
             return true;  
         } else {  
             for (var j=0; j<delboxes.length; j++) {  
                 formname.elements[delboxes[j]].checked = false;  
             }  
             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 232  sub page_start { Line 197  sub page_start {
         $extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);          $extra_head .= &Apache::lonhtmlcommon::htmlareaselectactive(\%textarea_args);
     }      }
     my $is_task = ($env{'request.uri'} =~ /\.task$/);      my $is_task = ($env{'request.uri'} =~ /\.task$/);
       my $needs_upload;
       my ($symb)= &Apache::lonnet::whichuser();
       my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);
     if ($is_task) {      if ($is_task) {
         $extra_head .= &file_delchk_js();          $extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js();
       } else {
           if (&Apache::lonnet::EXT("resource.$Apache::inputtags::part.uploadedfiletypes") ne '') {
               unless ($env{'request.state'} eq 'construct') {
                   my $navmap = Apache::lonnavmaps::navmap->new();
                   if (ref($navmap)) {
                       my $mapres = $navmap->getResourceByUrl($map);
                       my $is_page;
                       if (ref($mapres)) {
                           $is_page = $mapres->is_page();
                       }
                       unless ($is_page) {
                           $needs_upload = 1;
                       }
                   }
               }
           } else {
               unless ($env{'request.state'} eq 'construct') {
                   my $navmap = Apache::lonnavmaps::navmap->new();
                   if (ref($navmap)) {
                       my $mapres = $navmap->getResourceByUrl($map);
                       my $is_page;
                       if (ref($mapres)) {
                           $is_page = $mapres->is_page();
                       }
                       unless ($is_page) {
                           my $res = $navmap->getBySymb($symb);
                           if (ref($res)) {
                               my $partlist = $res->parts();
                               if (ref($partlist) eq 'ARRAY') {
                                   foreach my $part (@{$partlist}) {
                                       my @types = $res->responseType($part);
                                       my @ids = $res->responseIds($part);
                                       for (my $i=0; $i < scalar(@ids); $i++) {
                                           if ($types[$i] eq 'essay') {
                                               my $partid = $part.'_'.$ids[$i];
                                               if (&Apache::lonnet::EXT("resource.$partid.uploadedfiletypes") ne '') {
                                                   $needs_upload = 1;
                                                   last;
                                               }
                                           }
                                       }
                                   }
                               } 
                           }
                       }
                   }
               }
           }
           if ($needs_upload) {
               $extra_head .= &Apache::lonhtmlcommon::file_submissionchk_js();
           }
     }      }
   
     my %body_args;      my %body_args;
Line 264  sub page_start { Line 283  sub page_start {
         &Apache::lonhtmlcommon::clear_breadcrumbs();          &Apache::lonhtmlcommon::clear_breadcrumbs();
         &Apache::lonhtmlcommon::add_breadcrumb({          &Apache::lonhtmlcommon::add_breadcrumb({
             'text'  => 'Construction Space',              'text'  => 'Construction Space',
             'href'  => &Apache::loncommon::authorspace(),              'href'  => &Apache::loncommon::authorspace($env{'request.uri'}),
         });          });
         # breadcrumbs (and tools) will be created           # breadcrumbs (and tools) will be created 
         # in start_page->bodytag->innerregister          # in start_page->bodytag->innerregister
Line 316  sub page_start { Line 335  sub page_start {
     if (!defined($found{'body'}) && $env{'request.state'} ne 'construct') {      if (!defined($found{'body'}) && $env{'request.state'} ne 'construct') {
  $page_start .= &Apache::lonxml::message_location();   $page_start .= &Apache::lonxml::message_location();
     }      }
       
     my $form_tag_start;      my $form_tag_start;
     if (!defined($found{'form'})) {      if (!defined($found{'form'})) {
  $form_tag_start='<form name="lonhomework" enctype="multipart/form-data" method="post" action="';   $form_tag_start='<form name="lonhomework" enctype="multipart/form-data" method="post" action="';
Line 327  sub page_start { Line 345  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) {          my ($symb,$courseid,$udom,$uname)=&Apache::lonnet::whichuser();
             $form_tag_start .= ' onsubmit="return file_deletion_check(this);"';          my ($path,$multiresp) = 
               &Apache::loncommon::get_turnedin_filepath($symb,$uname,$udom);
           if (($is_task) || ($needs_upload)) {
               $form_tag_start .= ' onsubmit="return file_submission_check(this,'."'$path','$multiresp'".');"';
         }          }
  $form_tag_start.='>'."\n";   $form_tag_start.='>'."\n";
   
Line 939  sub reset_problem_globals { Line 960  sub reset_problem_globals {
     undef(%Apache::lonhomework::history);      undef(%Apache::lonhomework::history);
     undef(%Apache::lonhomework::results);      undef(%Apache::lonhomework::results);
     undef($Apache::inputtags::part);      undef($Apache::inputtags::part);
       if ($type eq 'Task') {
           undef($Apache::inputtags::slot_name);
       }
 #don't undef this, lonhomework.pm takes care of this, we use this to   #don't undef this, lonhomework.pm takes care of this, we use this to 
 #detect if we try to do 2 problems in one file  #detect if we try to do 2 problems in one file
 #   undef($Apache::lonhomework::parsing_a_problem);  #   undef($Apache::lonhomework::parsing_a_problem);
Line 1290  sub end_problem { Line 1314  sub end_problem {
  } else {   } else {
     $frontmatter.= $begin_doc.$toc_line;      $frontmatter.= $begin_doc.$toc_line;
     if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) {       if ($Apache::lonhomework::type eq 'exam' and $allow_print_points==1) { 
  $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';   $frontmatter .= '\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}';
     }      }
  }   }
     } else {      } else {
Line 1300  sub end_problem { Line 1324  sub end_problem {
     if (not $env{'request.symb'} =~ m/\.page_/) {      if (not $env{'request.symb'} =~ m/\.page_/) {
  $frontmatter .= $begin_doc.$toc_line;   $frontmatter .= $begin_doc.$toc_line;
  if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) {    if (($Apache::lonhomework::type eq 'exam') and ($allow_print_points==1)) { 
     $frontmatter .= '\fbox{\textit{'.$weight.' pt}}';      $frontmatter .= '\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}';
  }   }
     } else {      } else {
  $frontmatter .= '\vskip 1mm \\\\\\\\'.$startminipage;   $frontmatter .= '\vskip 1mm \\\\\\\\'.$startminipage;
Line 1991  sub start_part { Line 2015  sub start_part {
  $allow_print_points=0;   $allow_print_points=0;
     }      }
     if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) {       if (($Apache::lonhomework::type eq 'exam') && ($allow_print_points)) { 
  $result .= '\vskip 10mm\fbox{\textit{'.$weight.' pt}}';   $result .= '\vskip 10mm\fbox{\textit{'.&mt('[quant,_1,pt,pt]',$weight ).'}}';
   
     }      }
  } elsif ($target eq 'web') {   } elsif ($target eq 'web') {

Removed from v.1.490  
changed lines
  Added in v.1.498


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