--- loncom/homework/essayresponse.pm	2015/03/10 17:32:53	1.124
+++ loncom/homework/essayresponse.pm	2025/03/02 05:22:43	1.128
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # essay (ungraded) style responses
 #
-# $Id: essayresponse.pm,v 1.124 2015/03/10 17:32:53 raeburn Exp $
+# $Id: essayresponse.pm,v 1.128 2025/03/02 05:22:43 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -118,12 +118,13 @@ sub draft_row {
                   }
     );
     return &Apache::lonhtmlcommon::row_title($status_text).
-           '<label>'.
-           '<input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="yes" checked="checked" />'.
-           '&nbsp;'.$label{'submit'}{$resptype}.'</label> <br />'.
-           '<label>'.
+           '<fieldset class="LC_landmark">'.
+           '<legend class="LC_visually_hidden">'.$status_text.'</legend>'.
+           '<div><label><input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="yes" checked="checked" />'.
+           '&nbsp;'.$label{'submit'}{$resptype}.'</label></div>'.
+           '<div><label>'.
            '<input type="radio" name="HWDRAFT'.$part.'_'.$id.'" value="no" />&nbsp;'.
-           $label{'draft'}{$resptype}.'</label>'.
+           $label{'draft'}{$resptype}.'</label></div></fieldset>'.
            &Apache::lonhtmlcommon::row_closure($closure);
 }
 
@@ -148,16 +149,43 @@ sub show_status_table {
     my ($part,$id,$coll) = @_;
     my $output;
     if ($coll) {
-        $output = '<td><i>'.&mt('Collaborated with [_1]',$coll).'</i></td>';
+        my $udom = $env{'user.domain'};
+        my $uname = $env{'user.name'};
+        my @collaborators;
+        foreach my $possible_collaborator
+            (split(/[,;\s]+/,$coll)) {
+            $possible_collaborator =~ s/[\$\^\(\)]//g;
+            next if ($possible_collaborator eq '');
+            my ($co_name,$co_dom) = split(/:/,$possible_collaborator);
+            $co_dom = $udom if (! defined($co_dom) || $co_dom =~ /^domain$/i);
+            next if ($co_name eq $uname && $co_dom eq $udom);
+            push(@collaborators,$possible_collaborator);
+        }
+        if (@collaborators) {
+            $output = '<div style="display: inline-block; float: left">'."\n".
+                      &Apache::loncommon::start_data_table().
+                      &Apache::loncommon::data_table_caption(&mt('Collaborators'),'LC_filesub_status').
+                      &Apache::loncommon::start_data_table_header_row().
+                      '<th>'.&mt('Username').'</th>'.
+                      &Apache::loncommon::end_data_table_header_row()."\n";
+            foreach my $user (@collaborators) {
+                $output .= &Apache::loncommon::start_data_table_row().
+                           '<td>'.$user.'</td>'.
+                           &Apache::loncommon::end_data_table_row()."\n";
+            }
+            $output .= &Apache::loncommon::end_data_table().'</div>';
+        }
     }
-    my $current_files_display = &Apache::inputtags::current_file_submissions($part,$id);
+    my $current_files_display =
+        &Apache::inputtags::current_file_submissions($part,$id,'',&mt('Submitted files'));
     if ($current_files_display) {
-        $output .= '<td><b>'.&mt('Submitted files:').'</b><br />'.
-                   $current_files_display.'</td>';
+        $output .= '<div style="display: inline-block; float:left;">'.
+                   $current_files_display.'</div>';
     }
     if ($output ne '') {
-        return '<table class="LC_pastsubmission"><tr>'.$output.
-               '</tr></table>';
+        return '<div style="padding:0;clear:both;margin:0;border:0"></div>'.
+               $output.
+               '<div style="padding:0;clear:both;margin:0;border:0"></div>';
     }
     return;
 }
@@ -226,16 +254,30 @@ sub end_essayresponse {
 				      &escape($crsid));
 			my $essayurl=
 			    &Apache::lonnet::declutter($ENV{'REQUEST_URI'});
-			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);
-		    }
+                        if ($essayurl eq 'lib/templates/simpleproblem.problem') {
+                            my %crsinfo = &Apache::lonnet::coursedescription($crsid);
+                            my $cdom = $crsinfo{'domain'};
+                            my $cnum = $crsinfo{'num'};
+                            my ($map,$id,$res) = &Apache::lonnet::decode_symb($symb);
+                            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') {
 	$result.=&Apache::edit::end_table();