Diff for /loncom/interface/londocs.pm between versions 1.637 and 1.646

version 1.637, 2017/08/27 02:36:49 version 1.646, 2017/12/29 15:04:11
Line 45  use Apache::lontemplate(); Line 45  use Apache::lontemplate();
 use Apache::lonsimplepage();  use Apache::lonsimplepage();
 use Apache::lonhomework();  use Apache::lonhomework();
 use Apache::lonpublisher();  use Apache::lonpublisher();
   use Apache::lonparmset();
 use HTML::Entities;  use HTML::Entities;
 use HTML::TokeParser;  use HTML::TokeParser;
 use GDBM_File;  use GDBM_File;
Line 52  use File::MMagic; Line 53  use File::MMagic;
 use File::Copy;  use File::Copy;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Cwd;  use Cwd;
   use UUID::Tiny ':std';
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
   
 my $iconpath;  my $iconpath;
Line 659  sub group_import { Line 661  sub group_import {
                 my $marker = $2;                  my $marker = $2;
                 my $info = $3;                  my $info = $3;
                 my ($toolid,%toolhash,%toolsettings);                  my ($toolid,%toolhash,%toolsettings);
                 my @extras = ('linktext','explanation','crslabel','crstitle');                  my @extras = ('linktext','explanation','crslabel','crstitle','crsappend');
                 my @toolinfo = split(/:/,$info);                  my @toolinfo = split(/:/,$info);
                 if ($residx) {                  if ($residx) {
                     %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);                      %toolsettings=&Apache::lonnet::dump('exttool_'.$marker,$coursedom,$coursenum);
Line 669  sub group_import { Line 671  sub group_import {
                 }                  }
                 $toolid =~ s/\D//g;                  $toolid =~ s/\D//g;
                 ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},                  ($toolhash{'target'},$toolhash{'width'},$toolhash{'height'},
                  $toolhash{'linktext'},$toolhash{'explanation'},                   $toolhash{'linktext'},$toolhash{'explanation'},$toolhash{'crslabel'},
                  $toolhash{'crslabel'},$toolhash{'crstitle'}) = @toolinfo;                   $toolhash{'crstitle'},$toolhash{'crsappend'},$toolhash{'gradable'}) = @toolinfo;
                 foreach my $item (@extras) {                  foreach my $item (@extras) {
                     $toolhash{$item} = &unescape($toolhash{$item});                      $toolhash{$item} = &unescape($toolhash{$item});
                 }                  }
                   if ($folder =~ /^supplemental/) {
                       delete($toolhash{'gradable'}); 
                   }
                 if (ref($ltitoolsref) eq 'HASH') {                  if (ref($ltitoolsref) eq 'HASH') {
                     my @deleted;  
                     if (ref($ltitoolsref->{$toolid}) eq 'HASH') {                      if (ref($ltitoolsref->{$toolid}) eq 'HASH') {
                           my @deleted;
                         $toolhash{'id'} = $toolid;                          $toolhash{'id'} = $toolid;
                         if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||                          if (($toolhash{'target'} eq 'iframe') || ($toolhash{'target'} eq 'tab') ||
                             ($toolhash{'target'} eq 'window')) {                              ($toolhash{'target'} eq 'window')) {
Line 751  sub group_import { Line 756  sub group_import {
                                 }                                  }
                             }                              }
                         }                          }
                           if ($toolhash{'passback'}) {
                               my $gradesecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
                               $toolhash{'gradesecret'} = $gradesecret;
                               $toolhash{'gradesecretdate'} = time;
                           }
                           if ($toolhash{'roster'}) {
                               my $rostersecret = UUID::Tiny::create_uuid_as_string(UUID_V4);
                               $toolhash{'rostersecret'} = $rostersecret;
                               $toolhash{'rostersecretdate'} = time;
                           }
                           my $changegradable;
                           if (($residx) && ($folder =~ /^default/)) {
                               if (exists($toolsettings{'gradable'})) {
                                   if (!exists($toolhash{'gradable'})) {
                                       push(@deleted,'gradable');
                                       $changegradable = 1;
                                   }
                               } elsif (exists($toolhash{'gradable'})) {
                                   $changegradable = 1;
                               }
                           }
                         my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);                          my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$coursedom,$coursenum);
                         if ($putres eq 'ok') {                          if ($putres eq 'ok') {
                             if (@deleted) {                              if (@deleted) {
                                 &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);                                  &Apache::lonnet::del('exttool_'.$marker,\@deleted,$coursedom,$coursenum);
                             }                               }
                               if (($changegradable) && ($folder =~ /^default/)) {
                                   my $val;
                                   if ($toolhash{'gradable'}) {
                                       $val = 'yes';
                                   } else {
                                       $val = 'no';
                                   }
                                   &LONCAPA::map::storeparameter($residx,'parameter_0_gradable',$val,
                                                                 'string_yesno');
                                   &remember_parms($residx,'gradable','set',$val);
                               }
                           } else {
                               return (&mt('Failed to save update to external tool.'),1);
                         }                          }
                     }                      }
                 }                  }
Line 993  sub docs_change_log { Line 1032  sub docs_change_log {
     'encrypturl'     => 'URL hidden',      'encrypturl'     => 'URL hidden',
     'randompick'     => 'Randomly pick',      'randompick'     => 'Randomly pick',
     'randomorder'    => 'Randomly ordered',      'randomorder'    => 'Randomly ordered',
               'gradable'       => 'Grade can be assigned to External Tool',
     'set'            => 'set to',      'set'            => 'set to',
     'del'            => 'deleted');      'del'            => 'deleted');
     my $filter = &Apache::loncommon::display_filter('docslog')."\n".      my $filter = &Apache::loncommon::display_filter('docslog')."\n".
Line 1100  sub docs_change_log { Line 1140  sub docs_change_log {
  $r->print('</ul>');   $r->print('</ul>');
  if ($docslog{$id}{'logentry'}{'parameter_res'}) {   if ($docslog{$id}{'logentry'}{'parameter_res'}) {
     $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');      $r->print(&LONCAPA::map::qtescape((split(/\:/,$docslog{$id}{'logentry'}{'parameter_res'}))[0]).':<ul>');
     foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder') {      foreach my $parameter ('randompick','hiddenresource','encrypturl','randomorder','gradable') {
  if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {   if ($docslog{$id}{'logentry'}{'parameter_action_'.$parameter}) {
 # FIXME: internationalization seems wrong here  # FIXME: internationalization seems wrong here
     $r->print('<li>'.      $r->print('<li>'.
Line 2755  sub apply_fixups { Line 2795  sub apply_fixups {
                     }                      }
                 }                  }
             }              }
             for (my $i=0; $i<@LONCAPA::map::order; $i++) {              my $total = scalar(@LONCAPA::map::order) - 1;
               for (my $i=$total; $i>=0; $i--) {
                 my $idx = $LONCAPA::map::order[$i];                  my $idx = $LONCAPA::map::order[$i];
                 if (defined($LONCAPA::map::resources[$idx])) {                  if (defined($LONCAPA::map::resources[$idx])) {
                     my $changed;                      my $changed;
Line 4104  END Line 4145  END
                     }                      }
                 }                  }
                 if ($url ne '') {                  if ($url ne '') {
                     $url.=(($url=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');                      $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
                 }                  }
             } elsif (!$env{'request.role.adv'}) {              } elsif (!$env{'request.role.adv'}) {
                 my $checkencrypt;                  my $checkencrypt;
Line 4125  END Line 4166  END
                     my $shownsymb = &Apache::lonenc::encrypted($symb);                      my $shownsymb = &Apache::lonenc::encrypted($symb);
                     my $shownurl = &Apache::lonenc::encrypted($url);                      my $shownurl = &Apache::lonenc::encrypted($url);
                     if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {                      if (&Apache::lonnet::symbverify($shownsymb,$shownurl)) {
                         $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&HTML::Entities::encode($shownsymb,'"<>&');                          $url = $shownurl.(($shownurl=~/\?/)?'&':'?').'symb='.&escape($shownsymb);
                         if ($env{'request.enc'} ne '') {                          if ($env{'request.enc'} ne '') {
                             delete($env{'request.enc'});                              delete($env{'request.enc'});
                         }                          }
Line 5590  sub handler { Line 5631  sub handler {
                 }                  }
             }              }
             my $tabidstr = join("','",@tabids);              my $tabidstr = join("','",@tabids);
             %ltitools = &Apache::lonnet::get_domain_ltitools($coursedom);              %ltitools = &Apache::lonnet::get_domain_lti($coursedom,'consumer');
             my $posslti = keys(%ltitools);              my $posslti = keys(%ltitools);
             my $hostname = $r->hostname();              my $hostname = $r->hostname();
     $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,      $script .= &editing_js($udom,$uname,$supplementalflag,$coursedom,$coursenum,$posslti,
Line 5678  sub handler { Line 5719  sub handler {
   undef($hadchanges);    undef($hadchanges);
           $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,            $uploadphase = &process_file_upload(\$upload_output,$coursenum,$coursedom,
                                               \%allfiles,\%codebase,$context,$crstype);                                                \%allfiles,\%codebase,$context,$crstype);
             undef($navmap);
   if ($hadchanges) {    if ($hadchanges) {
       &mark_hash_old();        &mark_hash_old();
   }    }
Line 6477  unless ($container eq 'page') { Line 6519  unless ($container eq 'page') {
              $r->print('<p><span class="LC_error">'.$error.'</span></p>');               $r->print('<p><span class="LC_error">'.$error.'</span></p>');
           }            }
           if ($hadchanges) {            if ($hadchanges) {
              &mark_hash_old();                unless (&is_hash_old()) {
           }                    &mark_hash_old();
                 }
     }
   
           &changewarning($r,'');            &changewarning($r,'');
         }          }
Line 7100  sub editing_js { Line 7144  sub editing_js {
                 } else {                  } else {
                     $url = $res;                      $url = $res;
                 }                  }
                 $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"').'?symb='.                  $backtourl = &HTML::Entities::encode(&Apache::lonnet::clutter($url),'<>&"');
                              &HTML::Entities::encode($caller,'<>&"');                  if ($backtourl =~ m{^\Q/uploaded/$coursedom/$coursenum/\Edefault_\d+\.sequence$}) {
                       $backtourl .= '?navmap=1';
                   } else {
                       $backtourl .= '?symb='.
                                     &HTML::Entities::encode($caller,'<>&"');
                   }
                 if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {                  if ($backtourl =~ m{^\Q/public/$coursedom/$coursenum/syllabus\E}) {
                     if (($ENV{'SERVER_PORT'} == 443) &&                      if (($ENV{'SERVER_PORT'} == 443) &&
                         ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {                          ($env{'course.'.$env{'request.course.id'}.'.externalsyllabus'} =~ m{^http://})) {

Removed from v.1.637  
changed lines
  Added in v.1.646


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