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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 21 Sep 2006 21:23:20 -0000


This is a MIME encoded message

--albertel1158873800
Content-Type: text/plain

albertel		Thu Sep 21 17:23:20 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
    /loncom/homework	essayresponse.pm inputtags.pm 
  Log:
  - BUG$4486b - always show submissions to essay problems 
  
  
--albertel1158873800
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060921172320.txt"

Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.457 loncom/interface/loncommon.pm:1.458
--- loncom/interface/loncommon.pm:1.457	Tue Sep 19 17:47:32 2006
+++ loncom/interface/loncommon.pm	Thu Sep 21 17:23:15 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.457 2006/09/19 21:47:32 albertel Exp $
+# $Id: loncommon.pm,v 1.458 2006/09/21 21:23:15 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3211,6 +3211,11 @@
   border: 0px;
 }
 
+table.LC_pastsubmission {
+  border: 1px solid black;
+  margin: 2px;
+}
+
 table#LC_top_nav, table#LC_menubuttons {
   width: 100%;
   background: $pgbg;
@@ -3729,8 +3734,8 @@
     my $domain   = $args->{'domain'}   || &determinedomain();
     my $bgcolor  = $args->{'bgcolor'}  || &designparm($function.'.pgbg',$domain);
     my $url = join(':',$env{'user.name'},$env{'user.domain'},
-		   #time(),
 		   $Apache::lonnet::perlvar{'lonVersion'},
+		   #time(),
 		   $env{'environment.color.timestamp'},
 		   $function,$domain,$bgcolor);
 
Index: loncom/homework/essayresponse.pm
diff -u loncom/homework/essayresponse.pm:1.73 loncom/homework/essayresponse.pm:1.74
--- loncom/homework/essayresponse.pm:1.73	Tue Aug  1 10:04:32 2006
+++ loncom/homework/essayresponse.pm	Thu Sep 21 17:23:19 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # essay (ungraded) style responses
 #
-# $Id: essayresponse.pm,v 1.73 2006/08/01 14:04:32 albertel Exp $
+# $Id: essayresponse.pm,v 1.74 2006/09/21 21:23:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -75,6 +75,32 @@
 	$result.=&Apache::inputtags::file_selector($part,$id,
 						   $uploadedfiletypes,'both');
         $result.='</table>';
+    } elsif ($target eq 'web' &&
+	     $Apache::inputtags::status[-1] ne 'CAN_ANSWER') {
+	my $part= $Apache::inputtags::part;
+	my @msgs;
+	if ($Apache::lonhomework::history{"resource.$part.$id.collaborators"} =~ /\S/) {
+	    my $coll= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.collaborators"},'<>&"');
+	    $result .= '<td>'.&mt('Collaborated with [_1]',$coll).'</td>';
+	}
+
+	my $file_submission = 
+	    &Apache::inputtags::show_past_file_submission($part,$id);
+	if ($file_submission) {
+	    $result .= '<td>'.$file_submission.'</td>';
+	}
+
+	my $port_submission = 
+	    &Apache::inputtags::show_past_portfile_submission($part,$id);
+	if ($port_submission) {
+	    $result .= '<td>'.$port_submission.'</td>';
+	}
+
+	if ($result ne '') {
+	    $result = 
+		'<table class="LC_pastsubmission"><tr>'.$result.
+		'</tr></table>';
+	}
     }
     return $result;
 }
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.204 loncom/homework/inputtags.pm:1.205
--- loncom/homework/inputtags.pm:1.204	Thu Jul 20 17:48:07 2006
+++ loncom/homework/inputtags.pm	Thu Sep 21 17:23:19 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.204 2006/07/20 21:48:07 albertel Exp $
+# $Id: inputtags.pm,v 1.205 2006/09/21 21:23:19 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -140,9 +140,9 @@
     my $resid=$Apache::inputtags::response[-1];
     if ($target eq 'web') {
 	$Apache::lonxml::evaluate--;
+	my $partid=$Apache::inputtags::part;
+	my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"');
 	if ($Apache::inputtags::status[-1] eq 'CAN_ANSWER') {
-	    my $partid=$Apache::inputtags::part;
-	    my $oldresponse = &HTML::Entities::encode($Apache::lonhomework::history{"resource.$partid.$resid.submission"},'<>&"');
 	    my $cols = &Apache::lonxml::get_param('cols',$parstack,$safeeval);
 	    if ( $cols eq '') { $cols = 80; }
 	    my $rows = &Apache::lonxml::get_param('rows',$parstack,$safeeval);
@@ -161,9 +161,13 @@
 		&Apache::lonxml::get_all_text("/textfield",$parser,$style);
 	    }
 	} else {
-	    #right or wrong don't show it
-	    #$result='<table border="1"><tr><td><i>'.$oldresponse.'</i></td></tr></table>';
-	    $result='';
+	    #show past answer in the essayresponse case
+	    if ($oldresponse =~ /\S/
+		&& &Apache::londefdef::is_inside_of($tagstack,
+						    'essayresponse') ) {
+		$result='<table class="LC_pastsubmission"><tr><td>'.
+		    $oldresponse.'</td></tr></table>';
+	    }
 	    #get rid of any startup text
 	    &Apache::lonxml::get_all_text("/textfield",$parser,$style);
 	}
@@ -415,19 +419,7 @@
 	$result.=&mt('Submit a file: (only one file can be uploaded)').
 	    ' <br /><input type="file" size="50" name="HWFILE'.
 	    $jspart.'_'.$id.'" /><br />';
-	my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"');
-
-	if ($uploadedfile) {
-	    my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"};
-	    &Apache::lonxml::extlink($url);
-	    &Apache::lonnet::allowuploaded('/adm/essayresponse',$url);
-	    my $icon=&Apache::loncommon::icon($url);
-	    my $curfile='<a href="'.$url.'"><img src="'.$icon.
-		'" border="0" />'.$uploadedfile.'</a>';
-	    $result.=&mt('Currently submitted: <tt>[_1]</tt>',$curfile);
-	} else {
-	    #$result.=&mt('(Hand in a file you have prepared on your computer)');
-	}
+	$result .= &show_past_file_submission($part,$id);
     }
     if ( $which eq 'both') { 
 	$result.='<br />'.'<strong>'.&mt('OR:').'</strong><br />';
@@ -437,36 +429,61 @@
 	    &mt('Select Portfolio Files').'</a><br />'.
 	    '<input type="text" size="50" name="HWPORT'.$jspart.'_'.$id.'" value="" />'.
 	    '<br />';
-	if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}=~/[^\s]/){
-	    my (@file_list,@bad_file_list);
-	    foreach my $file (split(/\s*,\s*/,&unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) {
-		my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();
-		my $url="/uploaded/$domain/$user/portfolio$file";
-		my $icon=&Apache::loncommon::icon($url);
-		push(@file_list,'<a href="'.$url.'"><img src="'.$icon.
-		     '" border="0" />'.$file.'</a>');
-		if (! &Apache::lonnet::stat_file($url)) {
-		    &Apache::lonnet::logthis("bad file is $url");
-		    push(@bad_file_list,'<a href="'.$url.'"><img src="'.$icon.
-			 '" border="0" />'.$file.'</a>');
-		}
-	    }
-	    my $files = '<span class="LC_filename">'.
-		join('</span>, <span class="LC_filename">',@file_list).
-		'</span>';
-	    $result.=&mt("Portfolio files previously selected: [_1]",$files);
-	    if (@bad_file_list) {
-		my $bad_files = '<span class="LC_filename">'.
-		    join('</span>, <span class="LC_filename">',@bad_file_list).
-		    '</span>';
-		$result.='<br />'.&mt('<span class="LC_error">These file(s) don\'t exist:</span> [_1]',$bad_files);
-	    }
-	}
+	$result .= &show_past_portfile_submission($part,$id);
+
     }
     $result.='</td></tr>'; 
     return $result;
 }
 
+sub show_past_file_submission {
+    my ($part,$id) = @_;
+    my $uploadedfile= &HTML::Entities::encode($Apache::lonhomework::history{"resource.$part.$id.uploadedfile"},'<>&"');
+
+    return if (!$uploadedfile);
+
+    my $url=$Apache::lonhomework::history{"resource.$part.$id.uploadedurl"};
+    &Apache::lonxml::extlink($url);
+    &Apache::lonnet::allowuploaded('/adm/essayresponse',$url);
+    my $icon=&Apache::loncommon::icon($url);
+    my $curfile='<a href="'.$url.'"><img src="'.$icon.
+	'" border="0" />'.$uploadedfile.'</a>';
+    return &mt('Currently submitted: <tt>[_1]</tt>',$curfile);
+
+}
+
+sub show_past_portfile_submission {
+    my ($part,$id) = @_;
+    if ($Apache::lonhomework::history{"resource.$part.$id.portfiles"}!~/[^\s]/){
+	return;
+    }
+    my (@file_list,@bad_file_list);
+    foreach my $file (split(/\s*,\s*/,&unescape($Apache::lonhomework::history{"resource.$part.$id.portfiles"}))) {
+	my (undef,undef,$domain,$user)=&Apache::lonxml::whichuser();
+	my $url="/uploaded/$domain/$user/portfolio$file";
+	my $icon=&Apache::loncommon::icon($url);
+	push(@file_list,'<a href="'.$url.'"><img src="'.$icon.
+	     '" border="0" />'.$file.'</a>');
+	if (! &Apache::lonnet::stat_file($url)) {
+	    &Apache::lonnet::logthis("bad file is $url");
+	    push(@bad_file_list,'<a href="'.$url.'"><img src="'.$icon.
+		 '" border="0" />'.$file.'</a>');
+	}
+    }
+    my $files = '<span class="LC_filename">'.
+	join('</span>, <span class="LC_filename">',@file_list).
+	'</span>';
+    my $result = &mt("Portfolio files previously selected: [_1]",$files);
+    if (@bad_file_list) {
+	my $bad_files = '<span class="LC_filename">'.
+	    join('</span>, <span class="LC_filename">',@bad_file_list).
+	    '</span>';
+	$result.='<br />'.&mt('<span class="LC_error">These file(s) don\'t exist:</span> [_1]',$bad_files);
+    }
+    return $result;
+
+}
+
 sub checkstatus {
     my ($value,$awardref,$msgref)=@_;
     for (my $i=0;$i<=$#$awardref;$i++) {

--albertel1158873800--