--- loncom/homework/essayresponse.pm	2011/10/17 12:41:35	1.116
+++ loncom/homework/essayresponse.pm	2014/12/04 20:43:23	1.120
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # essay (ungraded) style responses
 #
-# $Id: essayresponse.pm,v 1.116 2011/10/17 12:41:35 raeburn Exp $
+# $Id: essayresponse.pm,v 1.120 2014/12/04 20:43:23 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -91,7 +91,7 @@ sub start_essayresponse {
                       '<label>'.
 		      &mt('Collaborators:').' <input type="text" size="70" max="80" name="HWCOL'.
 		      $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) {
                 $result .= '<br />'.&mt('If entering more than one, use spaces to separate the collaborators.');
             }
@@ -279,14 +279,14 @@ sub format_prior_response {
     }
     if ($answer =~ /\S/) {
 	$output.='<p>'.&mt('Submitted text').
-	    '<blockquote>'.$answer.'</blockquote></p>';
+	    '<blockquote>'.&HTML::Entities::encode($answer, '"<>&').'</blockquote></p>';
     }
 
     return '<div class="LC_prior_essay">'.$output.'</div>';
 }
 
 sub file_submission {
-    my ($part,$id,$award,$uploadedflag,$totalsize,$deletions)=@_;
+    my ($part,$id,$award,$uploadedflag,$totalsize,$deletions,$context,$info)=@_;
     my $files;
     my $jspart=$part;
     $jspart=~s/\./_/g;
@@ -513,6 +513,20 @@ sub file_submission {
             $$uploadedflag=1;
         }
     }
+    if ($context eq 'externalresponse') {
+        my @todelete = map { "/uploaded/$udom/$uname/portfolio".$_;  } keys(%port_delete);
+        if (@tolock || @todelete) {
+            if (ref($info) eq 'HASH') {
+                if ($info->{'ip'}) {
+                    my @adds;
+                    if (@tolock) {
+                        @adds = map { "/uploaded/$udom/$uname/portfolio".$_;  } @tolock;
+                    }
+                    &Apache::lonnet::automated_portfile_access('ip',\@adds,\@todelete,$info);
+                }
+            }
+        }
+    }
     &Apache::lonnet::unmark_as_readonly($udom,$uname,[$symb,$crsid]);
     &Apache::lonnet::mark_as_readonly($udom,$uname,[@tolock],[$symb,$crsid]);
     &Apache::lonnet::clear_selected_files($uname);