Diff for /loncom/interface/londocs.pm between versions 1.652 and 1.654

version 1.652, 2018/04/14 00:10:48 version 1.654, 2018/04/24 11:17:58
Line 5225  sub changewarning { Line 5225  sub changewarning {
     if (!defined($message)) {      if (!defined($message)) {
  $message='Changes will become active for your current session after [_1], or the next time you log in.';   $message='Changes will become active for your current session after [_1], or the next time you log in.';
     }      }
       my $windowname = 'loncapaclient';
       if ($env{'request.lti.login'}) {
           $windowname .= 'lti';
       }
     $r->print("\n\n".      $r->print("\n\n".
 '<script type="text/javascript">'."\n".  '<script type="text/javascript">'."\n".
 '// <![CDATA['."\n".  '// <![CDATA['."\n".
 'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".  'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
 '// ]]>'."\n".  '// ]]>'."\n".
 '</script>'."\n".  '</script>'."\n".
 '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.  '<form name="reinitform" method="post" action="/adm/roles" target="'.$windowname.'">'.
 '<input type="hidden" name="orgurl" value="'.$url.  '<input type="hidden" name="orgurl" value="'.$url.
 '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.  '" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
 &mt($message,' <input type="hidden" name="'.  &mt($message,' <input type="hidden" name="'.
Line 5456  sub handler { Line 5460  sub handler {
                       $r->internal_redirect($redirect);                        $r->internal_redirect($redirect);
                       return OK;                        return OK;
                   }                    }
                 } else {
                     $r->internal_redirect($redirect);
               }                }
           }            }
       }        }
Line 6153  HIDDENFORM Line 6159  HIDDENFORM
        }         }
        my $postexec='';         my $postexec='';
        if ($folder eq 'default') {         if ($folder eq 'default') {
              my $windowname = 'loncapaclient';
              if ($env{'request.lti.login'}) {
                  $windowname .= 'lti';
              }
            $r->print('<script type="text/javascript">'."\n"             $r->print('<script type="text/javascript">'."\n"
                     .'// <![CDATA['."\n"                      .'// <![CDATA['."\n"
                     .'this.window.name="loncapaclient";'."\n"                      .'this.window.name="'.$windowname.'";'."\n"
                     .'// ]]>'."\n"                      .'// ]]>'."\n"
                     .'</script>'."\n"                      .'</script>'."\n"
        );         );
Line 8629  sub makenewproblem { Line 8639  sub makenewproblem {
         if ($env{'form.newsubdir'}) {          if ($env{'form.newsubdir'}) {
             if ($env{'form.newsubdirname'} ne '') {              if ($env{'form.newsubdirname'} ne '') {
                 $newsubdir = $env{'form.newsubdirname'};                  $newsubdir = $env{'form.newsubdirname'};
             }                  }
         }          }
         if ($env{'form.newresourcename'}) {          if ($env{'form.newresourcename'}) {
             $filename = $env{'form.newresourcename'};              $filename = $env{'form.newresourcename'};
Line 8712  END Line 8722  END
 <subject></subject>  <subject></subject>
 <title></title>  <title></title>
 END  END
                                         close($fh);                                      close($fh);
                                 }  
                                 if ((-e $sourcerights) && (-e "$sourcerights.meta")) {  
                                     if (!-e "$docroot/res/$coursedom") {  
                                         mkdir("$docroot/res/$coursedom",0755);  
                                     }  
                                     if (!-e "$docroot/res/$coursedom/$coursenum") {  
                                         mkdir("$docroot/res/$coursedom/$coursenum",0755);  
                                     }  
                                     if ((-e "$docroot/res/$coursedom/$coursenum") && (!-e $targetrights)) {  
                                         my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes'));  
                                         my $output = &Apache::lonpublisher::batchpublish($r,$sourcerights,$targetrights,$nokeyref,1);  
                                     }  
                                 }                                  }
                             }                              }
                             if ($env{'form.newresourceadd'}) {                              if ((-e $sourcerights) && (-e "$sourcerights.meta")) {
                                 my $template = $env{'form.template'};                                  if (!-e "$docroot/res/$coursedom") {
                                 my $source = $docroot.$redirect;                                      mkdir("$docroot/res/$coursedom",0755);
                                 my $target = $redirect;  
                                 $target =~ s{^/priv/}{/res/};  
                                 $target = $docroot.$target;  
                                 if (!-e $source) {  
                                     my $copyfrom;   
                                     if ($template) {  
                                         my %templates;  
                                         my @files = &Apache::lonhomework::get_template_list('problem');  
                                         foreach my $poss (@files) {  
                                             if (ref($poss) eq 'ARRAY') {  
                                                 if ($template eq $poss->[0]) {  
                                                     $templates{$template} = 1;  
                                                     last;  
                                                 }  
                                             }  
                                         }  
                                         if ($templates{$template}) {  
                                             $copyfrom = $template;  
                                         }  
                                     }  
                                     unless ($copyfrom) {  
                                         $copyfrom = $r->dir_config('lonIncludes').'/templates/blank.problem';  
                                     }  
                                     &File::Copy::copy($copyfrom,$source);  
                                 }                                  }
                                 if (!-e "$source.meta") {                                  if (!-e "$docroot/res/$coursedom/$coursenum") {
                                     my $cid = $coursedom.'_'.$coursenum;                                      mkdir("$docroot/res/$coursedom/$coursenum",0755);
                                     my $now = time;                                  }
                                     if (open(my $fh,">$source.meta")) {                                  if ((-e "$docroot/res/$coursedom/$coursenum") && (!-e $targetrights)) {
                                         my $author=$env{'environment.firstname'}.' '.                                      my $nokeyref = &Apache::lonpublisher::getnokey($r->dir_config('lonIncludes'));
                                                    $env{'environment.middlename'}.' '.                                      my $output = &Apache::lonpublisher::batchpublish($r,$sourcerights,$targetrights,$nokeyref,1);
                                                    $env{'environment.lastname'}.' '.                                  }
                                                    $env{'environment.generation'};                              }
                                         $author =~ s/\s+$//;                              my $source = $docroot.$redirect;
                                         my $title = $env{'form.newresourcetitle'};                              if (!-e "$source.meta") {
                                         $title =~ s/^\s+|\s+$//g;                                  my $cid = $coursedom.'_'.$coursenum;
                                         print $fh <<END;                                  my $now = time;
                                   if (open(my $fh,">$source.meta")) {
                                       my $author=$env{'environment.firstname'}.' '.
                                                  $env{'environment.middlename'}.' '.
                                                  $env{'environment.lastname'}.' '.
                                                  $env{'environment.generation'};
                                       $author =~ s/\s+$//;
                                       my $title = $env{'form.newresourcetitle'};
                                       $title =~ s/^\s+|\s+$//g;
                                       print $fh <<END;
   
 <abstract></abstract>  <abstract></abstract>
 <author>$author</author>  <author>$author</author>
Line 8792  END Line 8775  END
 <subject></subject>  <subject></subject>
 <title>$title</title>  <title>$title</title>
 END  END
                                         close($fh);                                      close($fh);
                                     }  
                                 }                                  }
                             }                              }
                         }                          }
Line 8821  END Line 8803  END
 }  }
   
 sub finishnewprob {  sub finishnewprob {
     my ($url,$path,$subdir,$newsubdir,$filename) = @_;      my ($url,$path,$subdir,$newsubdir,$filename,$context) = @_;
     unless (-d $path) {      unless (-d $path) {
         unless (mkdir($path,02770)) {          unless (mkdir($path,02770)) {
             return;              return;
Line 8864  sub finishnewprob { Line 8846  sub finishnewprob {
             $redirect = "$url/$filename";              $redirect = "$url/$filename";
         }          }
     }      }
       if ((!-e $dest) && ($context ne 'upload')) {
           my $template = $env{'form.template'};
           my $copyfrom;
           if ($template ne '') {
               my %templates;
               my @files = &Apache::lonhomework::get_template_list('problem');
               foreach my $poss (@files) {
                   if (ref($poss) eq 'ARRAY') {
                       if ($template eq $poss->[0]) {
                           $templates{$template} = 1;
                           last;
                       }
                   }
               }
               if ($templates{$template}) {
                   $copyfrom = $template;
               }
           }
           if ($filename =~ /\.problem$/) {
               unless ($copyfrom) {
                   $copyfrom = $Apache::lonnet::perlvar{'lonIncludes'}.'/templates/blank.problem';
               }
               &File::Copy::copy($copyfrom,$dest);
           }
       }
     return $redirect;      return $redirect;
 }  }
   

Removed from v.1.652  
changed lines
  Added in v.1.654


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