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

raeburn raeburn@source.lon-capa.org
Sun, 06 Jun 2010 21:42:05 -0000


raeburn		Sun Jun  6 21:42:05 2010 EDT

  Modified files:              
    /loncom/homework	inputtags.pm 
  Log:
  - Surveys:
    Consistent use of term "Submissions" in place of "Tries" when displaying
    information about survey submissions.
    - bug 6119.
      - Only display submission details in "Previous Submissions" pop-up
        if viewer is the submitter.
  
  
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.262 loncom/homework/inputtags.pm:1.263
--- loncom/homework/inputtags.pm:1.262	Sat Jun  5 01:38:43 2010
+++ loncom/homework/inputtags.pm	Sun Jun  6 21:42:04 2010
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.262 2010/06/05 01:38:43 www Exp $
+# $Id: inputtags.pm,v 1.263 2010/06/06 21:42:04 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1255,15 +1255,7 @@
     if ( $tries eq '' ) { $tries = '0'; }
     if ( $maxtries eq '' ) { $maxtries = '2'; } 
     if ( $maxtries eq 'con_lost' ) { $maxtries = '0'; } 
-    my $tries_text=&mt('Tries');
-    if ( $Apache::lonhomework::type eq 'survey' ||
-         $Apache::lonhomework::type eq 'surveycred' ||
-         $Apache::lonhomework::type eq 'anonsurvey' ||
-         $Apache::lonhomework::type eq 'anonsurveycred' ||
-	 $Apache::lonhomework::parsing_a_task) {
-	$tries_text=&mt('Submissions');
-    }
-
+    my $tries_text= &get_tries_text();;
     if ($showbutton) {
 	if ($target eq 'tex') {
 	    if ($env{'request.state'} ne "construct"
@@ -1275,7 +1267,7 @@
 		$trystr = '\vskip 0 mm ';
 	    }
 	} else {
-	    $trystr = '<td><span class="LC_nobreak">'.$tries_text." $tries";
+	    $trystr = '<td><span class="LC_nobreak">'.&mt($tries_text)." $tries";
 	    if ($Apache::lonhomework::parsing_a_task) {
 	    } elsif($env{'request.state'} ne 'construct') {
 		$trystr.="/$maxtries";
@@ -1362,7 +1354,13 @@
 
     foreach my $i (1..$Apache::lonhomework::history{'version'}) {
 	my $prefix = $i.":resource.$id";
-
+        my $is_anon; 
+        if (defined($env{'form.grade_symb'})) {
+            if (($Apache::lonhomework::history{"$prefix.type"} eq 'anonsurvey') || 
+                ($Apache::lonhomework::history{"$prefix.type"} eq 'anonsurveycred')) {
+                $is_anon = 1;
+            }
+        }
 	next if (!exists($Apache::lonhomework::history{"$prefix.award"}));
 	$count++;
 	$count_lookup{$i} = $count;
@@ -1407,7 +1405,11 @@
 		    $submission = 
 			$Apache::lonhomework::history{"$prefix.submission"};
 		}
-		$output.='<td>'.$submission.'</td>';
+                if ($is_anon) {
+                    $output.='<td>'.&mt('(only shown to submitter)').'</td>';
+                } else {
+		    $output.='<td>'.$submission.'</td>';
+                }
 	    } else {
 		$output.='<td></td>';
 	    }
@@ -1425,8 +1427,9 @@
     $output.='<br /><form action=""><center><input type="button" name="close" value="'.&mt('Close Window').'" onClick="window.close()" /></center></form>';
 
     my $windowopen=&Apache::lonhtmlcommon::javascript_docopen();
+    my $tries_text = &get_tries_text('link');
     my $start_page =
-	&Apache::loncommon::start_page('Previous Tries', undef,
+	&Apache::loncommon::start_page($tries_text, undef,
 				       {'only_body'      => 1,
 					'bgcolor'        => '#FFFFFF',
 					'js_ready'       => 1,
@@ -1441,12 +1444,34 @@
 // <![CDATA[
     function $function_name() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.$windowopen;newWindow.document.writeln('$start_page $output $end_page');newWindow.document.close();newWindow.focus()}
 // ]]>
-</script><a href=\"javascript:$function_name();void(0);\">".&mt("Previous Tries")."</a><br />";
+</script><a href=\"javascript:$function_name();void(0);\">".&mt($tries_text)."</a><br />";
     #use Data::Dumper;
     #&Apache::lonnet::logthis(&Dumper(\%Apache::inputtags::submission_display));
     return $result;
 }
 
+sub get_tries_text {
+    my ($context) = @_;
+    my $tries_text;
+    if ($context eq 'link') {
+        $tries_text = 'Previous Tries';
+    } else {
+        $tries_text = 'Tries';
+    }
+    if ( $Apache::lonhomework::type eq 'survey' ||
+         $Apache::lonhomework::type eq 'surveycred' ||
+         $Apache::lonhomework::type eq 'anonsurvey' ||
+         $Apache::lonhomework::type eq 'anonsurveycred' ||
+         $Apache::lonhomework::parsing_a_task) {
+        if ($context eq 'link') {
+            $tries_text = 'Previous Submissions';
+        } else {
+            $tries_text = 'Submissions';
+        }
+    }
+    return $tries_text;
+}
+
 1;
 __END__