[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm

raeburn raeburn@source.lon-capa.org
Sun, 29 Aug 2010 19:39:16 -0000


raeburn		Sun Aug 29 19:39:16 2010 EDT

  Modified files:              
    /loncom/homework	inputtags.pm 
  Log:
  - Correction to regexp used for files uploaded from desktop to essayresponse from
    pre-2.10 versions of LON-CAPA.
  - Only show checkboxes for deletion of previously submitted files if problem is
    still answerable.
  
  
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.269 loncom/homework/inputtags.pm:1.270
--- loncom/homework/inputtags.pm:1.269	Fri Aug 27 17:21:01 2010
+++ loncom/homework/inputtags.pm	Sun Aug 29 19:39:16 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.269 2010/08/27 17:21:01 raeburn Exp $
+# $Id: inputtags.pm,v 1.270 2010/08/29 19:39:16 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -527,13 +527,15 @@
     my ($part,$id) = @_;
     my $jspart=$part;
     $jspart=~s/\./_/g;
-    my $uploadedfile=&HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"');
+    my $uploadedfile=$Apache::lonhomework::history{"resource.$part.$id.uploadedfile"};
     my $portfiles=$Apache::lonhomework::history{"resource.$part.$id.portfiles"};
     return if (($uploadedfile eq '') && ($portfiles !~/[^\s]/));
     my $header = &Apache::loncommon::start_data_table().
-                 &Apache::loncommon::start_data_table_header_row().
-                 '<th>'.&mt('Delete?').'</th>'.
-                 '<th>'.&mt('Name').'</th>'.
+                 &Apache::loncommon::start_data_table_header_row();
+    if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
+        $header .= '<th>'.&mt('Delete?').'</th>';
+    }
+    $header .=   '<th>'.&mt('Name').'</th>'.
                  '<th>'.&mt('Size (MB)').'</th>'.
                  '<th>'.&mt('Last Modified').'</th>'.
                  &Apache::loncommon::end_data_table_header_row();
@@ -542,9 +544,10 @@
     my ($result,$header_shown,%okfiles,%rows,@bad_file_list);
     if ($uploadedfile) {
         my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"};
-        my ($path,$name) = ($url =~ m{^/uploaded/\Q$cdom\E/\Q$cnum\E/(essayresponse/.+/)([^/]+)});
+        my $link = &HTML::Entities::encode($url,'<>&"');
+        my ($path,$name) = ($url =~ m{^(/uploaded/\Q$udom\E/\Q$uname\E/essayresponse.*/)([^/]+)$});
         my ($status,$hashref,$error) =
-            &current_file_info($url,$uploadedfile,$name,$path);
+            &current_file_info($url,$link,$name,$path);
         if ($status eq 'ok') {
             push(@{$okfiles{$name}},$url);
             $rows{$url} = $hashref;
@@ -584,9 +587,13 @@
                             $header_shown = 1;
                         }
                         $result.=
-                            &Apache::loncommon::start_data_table_row()."\n".
-                            '<td valign="bottom"><input type="checkbox" name="HWFILE'.$jspart.'_'.$id.'_delete" value="'.
-                            $portfile.'" /></td>'."\n".
+                            &Apache::loncommon::start_data_table_row()."\n";
+                        if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
+                            $result .=
+                                 '<td valign="bottom"><input type="checkbox" name="HWFILE'.$jspart.'_'.$id.'_delete"'.
+                                 ' value="'.$portfile.'" /></td>'."\n";
+                        }
+                        $result .= 
                             '<td><a href="'.$link.'"><img src="'.$icon.
                             '" border="0" />'.$name.'</a></td>'."\n".
                             '<td align="right" valign="bottom">'.$rows{$url}{size}.'</td>'."\n".