Diff for /loncom/homework/essayresponse.pm between versions 1.114 and 1.118.2.1

version 1.114, 2011/01/29 19:41:41 version 1.118.2.1, 2019/02/19 14:24:38
Line 91  sub start_essayresponse { Line 91  sub start_essayresponse {
                       '<label>'.                        '<label>'.
       &mt('Collaborators:').' <input type="text" size="70" max="80" name="HWCOL'.        &mt('Collaborators:').' <input type="text" size="70" max="80" name="HWCOL'.
       $part.'_'.$id.'" value="'.$coll.'" /><br />'.        $part.'_'.$id.'" value="'.$coll.'" /><br />'.
       &mt('(Enter a maximum of [quant,_1,collaborator] using username or username:domain, e.g. smithje or smithje:[_2].)',$ncol,$env{'user.domain'});        &mt('Enter a maximum of [quant,_1,collaborator] using username or username:domain, e.g. smithje or smithje:[_2].',$ncol,$env{'user.domain'});
             if ($ncol > 1) {              if ($ncol > 1) {
                 $result .= '<br />'.&mt('If entering more than one, use spaces to separate the collaborators.');                  $result .= '<br />'.&mt('If entering more than one, use spaces to separate the collaborators.');
             }              }
Line 210  sub end_essayresponse { Line 210  sub end_essayresponse {
       &escape($crsid));        &escape($crsid));
  my $essayurl=   my $essayurl=
     &Apache::lonnet::declutter($ENV{'REQUEST_URI'});      &Apache::lonnet::declutter($ENV{'REQUEST_URI'});
  my ($adom,$aname,$apath)=                          if ($essayurl eq 'lib/templates/simpleproblem.problem') {
     ($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/);                              my %crsinfo = &Apache::lonnet::coursedescription($crsid);
                         $apath=&escape($apath);                              my $cdom = $crsinfo{'domain'};
  $apath=~s/\W/\_/gs;                              my $cnum = $crsinfo{'num'};
  &Apache::lonnet::put('nohist_essay_'.$apath,                              my ($map,$id,$res) = &Apache::lonnet::decode_symb($symb);
  { $akey => $response },$adom,$aname);                              if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(default(?:|_\d+)\.(?:sequence|page))$}) {
     }                                  my $apath = $1.'_'.$id;
                                   $apath=~s/\W/\_/gs;
                                   my $akey = join('.',&escape($name),&escape($domain));
                                   &Apache::lonnet::put('nohist_essay_'.$apath,
                                                        { $akey => $response },$cdom,$cnum);
                               }
                           } else {
       my ($adom,$aname,$apath)=
           ($essayurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\/(.*)$/);
                               $apath=&escape($apath);
       $apath=~s/\W/\_/gs;
       &Apache::lonnet::put('nohist_essay_'.$apath,
                                                    { $akey => $response },$adom,$aname);
                           }
                       }
                 }                  }
             }              }
  }           }
     } elsif ($target eq 'edit') {      } elsif ($target eq 'edit') {
  $result.=&Apache::edit::end_table();   $result.=&Apache::edit::end_table();
   
Line 279  sub format_prior_response { Line 293  sub format_prior_response {
     }      }
     if ($answer =~ /\S/) {      if ($answer =~ /\S/) {
  $output.='<p>'.&mt('Submitted text').   $output.='<p>'.&mt('Submitted text').
     '<blockquote>'.$answer.'</blockquote></p>';      '<blockquote>'.&HTML::Entities::encode($answer, '"<>&').'</blockquote></p>';
     }      }
   
     return '<div class="LC_prior_essay">'.$output.'</div>';      return '<div class="LC_prior_essay">'.$output.'</div>';
Line 397  sub file_submission { Line 411  sub file_submission {
                 my ($path,$filename) = ($file =~ m{^(.*/)([^/]+)$});                  my ($path,$filename) = ($file =~ m{^(.*/)([^/]+)$});
                 my $fullpath = '/userfiles/portfolio'.$path;                  my $fullpath = '/userfiles/portfolio'.$path;
                 if (!exists($dirlist{$fullpath})) {                  if (!exists($dirlist{$fullpath})) {
                     my @list = &Apache::lonnet::dirlist($fullpath,$udom,$uname,1);                      my ($listref,$listerror) =
                     $dirlist{$fullpath} = \@list;                          &Apache::lonnet::dirlist($fullpath,$udom,$uname,1);
                       if (ref($listref) eq 'ARRAY') {
                           $dirlist{$fullpath} = $listref;
                       }
                 }                  }
                 if (ref($dirlist{$fullpath}) eq 'ARRAY') {                  if (ref($dirlist{$fullpath}) eq 'ARRAY') {
                     foreach my $dir_line (@{$dirlist{$fullpath}}) {                      foreach my $dir_line (@{$dirlist{$fullpath}}) {
Line 441  sub file_submission { Line 458  sub file_submission {
         }          }
     }      }
     if ($accepted_upload ne '') {      if ($accepted_upload ne '') {
         my ($map,$resid,$resurl)=&Apache::lonnet::decode_symb($symb);          my ($path,$multiresp) = 
         my $turnindir;              &Apache::loncommon::get_turnedin_filepath($symb,$uname,$udom,
         my %userhash = &Apache::lonnet::userenvironment($udom,$uname,'turnindir');                                                        'submission');
         $turnindir = $userhash{'turnindir'};          if ($path eq '') {
         if ($turnindir eq '') {              $$award = 'INTERNAL_ERROR';
             $turnindir = &mt('turned in');          } else {
             $turnindir =~ s/\W+/_/g;              if ($multiresp) {
             my %newhash = (                  $path .= '/'.$jspart.'_'.$id;
                             'turnindir' => $turnindir,              }
                           );              my $prefix = 'portfolio';
             &Apache::lonnet::put('environment',\%newhash,$udom,$uname);              my $formelement = 'HWFILE'.$jspart.'_'.$id;
         }              my $fname = &Apache::lonnet::clean_filename($env{'form.'.$formelement.'.filename'});
         my $prefix = 'portfolio';              my $url = '/uploaded/'.$udom.'/'.$uname.'/'.$prefix.$path.'/'.$fname;
         my $path = '/'.$turnindir.'/';              my @stat = &Apache::lonnet::stat_file($url);
         my $restitle=&Apache::lonnet::gettitle($symb);              my $conflicts = 0;
         $restitle =~ s/\W+/_/g;              if (@stat && $stat[0] ne 'no_such_dir') {
         if ($restitle eq '') {                  my $current_permissions = 
             $restitle = ($resurl =~ m{/[^/]+$});                      &Apache::lonnet::get_portfile_permissions($udom,$uname);
             if ($restitle eq '') {                  if (ref($current_permissions) eq 'HASH') {
                 $restitle = time;                      if (ref($current_permissions->{$path.'/'.$fname}) eq 'ARRAY') {
             }                          foreach my $record (@{$current_permissions->{$path.'/'.$fname}}) {
         }                              if (ref($record) eq 'ARRAY') {
         my @pathitems;                                  next if (($record->[0] eq $symb) && 
         my $navmap = Apache::lonnavmaps::navmap->new();                                           ($record->[1] eq $crsid));
         if (defined($navmap)) {                                  $conflicts ++;
             my $mapres = $navmap->getResourceByUrl($map);                              } 
             if (ref($mapres)) {  
                 my $pcslist = $mapres->map_hierarchy();  
                 if ($pcslist ne '') {  
                     foreach my $pc (split(/,/,$pcslist)) {  
                         my $res = $navmap->getByMapPc($pc);  
                         if (ref($res)) {  
                             my $title = $res->compTitle();  
                             $title =~ s/\W+/_/g;  
                             if ($title ne '') {  
                                 push(@pathitems,$title);  
                             }  
                         }                          }
                     }                      }
                 }                  }
                 my $maptitle = $mapres->compTitle();                  if ($conflicts) {
                 $maptitle =~ s/\W+/_/g;                      $$award = 'FILENAME_INUSE';
                 if ($maptitle ne '') {  
                     push(@pathitems,$maptitle);  
                 }                  }
             } else {  
                 $$award = 'INTERNAL_ERROR';  
             }              }
         } else {              unless ($conflicts) { 
             $$award = 'INTERNAL_ERROR';                  my ($mode,%allfiles,%codebase);
         }                  my $result = &Apache::lonnet::userfileupload($formelement,'',
         push(@pathitems,$restitle);  
         $path .= join('/',@pathitems);  
         my $formelement = 'HWFILE'.$jspart.'_'.$id;  
         my $fname = &Apache::lonnet::clean_filename($env{'form.'.$formelement.'.filename'});  
         my $url = '/uploaded/'.$udom.'/'.$uname.'/'.$prefix.$path.'/'.$fname;  
         my @stat = &Apache::lonnet::stat_file($url);  
         if (@stat && $stat[0] ne 'no_such_dir') {  
             $$award = 'FILENAME_INUSE';  
         } else {  
             my ($mode,%allfiles,%codebase);  
             my $result = &Apache::lonnet::userfileupload($formelement,'',  
                              $prefix.$path,$mode,\%allfiles,\%codebase);                               $prefix.$path,$mode,\%allfiles,\%codebase);
             if ($result =~ m{^/uploaded/}) {                  if ($result =~ m{^/uploaded/}) {
                 $stored_upload = $path.'/'.$fname;                      $stored_upload = $path.'/'.$fname;
                 $Apache::lonhomework::results{"resource.$part.$id.portfiles"} = $stored_upload;                      unless (grep(/^\Q$stored_upload\E$/,@accepted_portfiles)) {
                 push(@tolock,$stored_upload);                          $Apache::lonhomework::results{"resource.$part.$id.portfiles"} = $stored_upload;
             } else {                          push(@tolock,$stored_upload);
                 $$award = 'INTERNAL_ERROR';                      }
                   } else {
                       $$award = 'INTERNAL_ERROR';
                   }
             }              }
         }          }
         delete($env{'form.HWFILE'.$jspart.'_'.$id});          delete($env{'form.HWFILE'.$jspart.'_'.$id});
     }      }
     if (@accepted_portfiles) {      if (@accepted_portfiles) {
         if ($stored_upload) {          if ($Apache::lonhomework::results{"resource.$part.$id.portfiles"}) {
             $Apache::lonhomework::results{"resource.$part.$id.portfiles"} .= ',';              $Apache::lonhomework::results{"resource.$part.$id.portfiles"} .= ',';
         }          }
         $Apache::lonhomework::results{"resource.$part.$id.portfiles"}.=join(',',@accepted_portfiles);          $Apache::lonhomework::results{"resource.$part.$id.portfiles"}.=join(',',@accepted_portfiles);

Removed from v.1.114  
changed lines
  Added in v.1.118.2.1


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