[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 22 Aug 2005 22:21:51 -0000


foxr		Mon Aug 22 18:21:51 2005 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Added dropdown code selector.. must still get these typed in or selected
  codes to save under a name if desired.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.387 loncom/interface/lonprintout.pm:1.388
--- loncom/interface/lonprintout.pm:1.387	Mon Aug 22 05:48:25 2005
+++ loncom/interface/lonprintout.pm	Mon Aug 22 18:21:48 2005
@@ -1,7 +1,7 @@
 #  The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.387 2005/08/22 09:48:25 foxr Exp $
+# $Id: lonprintout.pm,v 1.388 2005/08/22 22:21:48 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1363,6 +1363,8 @@
 	 my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'};
 	 my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'};
 	 my $single_code = $helper->{'VARS'}->{'SINGLE_CODE'};
+	 my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'};
+
 	 my $code_option=$helper->{'VARS'}->{'CODE_OPTION'};
 	 open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
 	 my ($code_type,$code_length)=('letter',6);
@@ -1384,6 +1386,12 @@
 	     $code_type=$result{"type\0$old_name"};
 	     @allcodes=split(',',$result{$old_name});
 	     $num_todo=scalar(@allcodes);
+	 } elsif ($selected_code) {
+	     $num_todo = 1;
+	     my ($alpha, $numeric) = split(/:/, $selected_code);
+	     $selected_code = $numeric;	# Always use numeric, converted if need be.
+	     $selected_code =~ s/\s+//g;
+	     @allcodes = ($selected_code);
 	 } elsif ($single_code) {
 
 	     $num_todo    = 1;	# Unconditionally one code to do.
@@ -2088,6 +2096,21 @@
 	    if ($name =~ /^type\0/) { next; }
 	    $namechoice.='<choice computer="'.$name.'">'.$name.'</choice>';
 	}
+        my %all_codes = &Apache::lonnet::get('CODEs',
+					     \@names, $cdom,$cnum);
+	my @all_code_array;
+	foreach my $key (keys %all_codes) {
+	    my $codes = $all_codes{$key};
+	    my @numeric_codes = split(/,/,$codes);
+	    foreach my $numeric (sort {uc($a) cmp uc($b)} @numeric_codes) {
+		my $alpha_code = &num_to_letters($numeric);
+		push (@all_code_array, "$alpha_code : $numeric");
+	    }
+	}
+	my $code_selection = "<choice></choice>\n";
+	foreach my $code (@all_code_array) {
+	    $code_selection .= '   <choice computer="'.$code.'">'.$code."</choice>\n";
+	}
 	open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
 	my $codechoice='';
 	foreach my $line (<FH>) {
@@ -2110,7 +2133,8 @@
        <validator>
 	if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
 	    !\$helper->{'VARS'}{'REUSE_OLD_CODES'}                &&
-            !\$helper->{'VARS'}{'SINGLE_CODE'}) {
+            !\$helper->{'VARS'}{'SINGLE_CODE'}                    &&
+	    !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
 	    return "You need to specify the number of assignments to print";
 	}
 	return undef;
@@ -2121,7 +2145,8 @@
     <string variable="SINGLE_CODE" size="10" defaultvalue="zzzz">
         <validator>
 	   if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}           &&
-	      !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) {
+	      !\$helper->{'VARS'}{'REUSE_OLD_CODES'}                 &&
+	      !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
 	      return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'},
 						      \$helper->{'VARS'}{'CODE_OPTION'});
 	   } else {
@@ -2130,6 +2155,12 @@
         </validator>
     </string>
     <message></td></tr><tr><td></message>
+    <message><b>Choose single code from list</b></message>
+    <message></td><td></message>
+    <dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0">
+    $code_selection
+    </dropdown>
+    <message></td></tr><tr><td></message>
     <message><b>Names to store the CODEs under for later:</b></message>
     <message></td><td></message>
     <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />
@@ -2197,7 +2228,8 @@
        <validator>
 	if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
 	    !\$helper->{'VARS'}{'REUSE_OLD_CODES'}                &&
-	    !\$helper->{'VARS'}{'SINGLE_CODE'}) {
+	    !\$helper->{'VARS'}{'SINGLE_CODE'}                   &&
+	    !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
 	    return "You need to specify the number of assignments to print";
 	}
 	return undef;
@@ -2208,7 +2240,8 @@
     <string variable="SINGLE_CODE" size="10" defaultvalue="zzzz">
         <validator>
 	   if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}           &&
-	      !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) {
+	      !\$helper->{'VARS'}{'REUSE_OLD_CODES'}                 &&
+	      !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) {
 	      return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'},
 						      \$helper->{'VARS'}{'CODE_OPTION'});
 	   } else {
@@ -2217,6 +2250,12 @@
         </validator>
     </string>
     <message></td></tr><tr><td></message>
+    <message><b>Choose single code from list</b></message>
+    <message></td><td></message>
+    <dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0">
+    $code_selection
+    </dropdown>
+    <message></td></tr><tr><td></message>
     <message><b>Names to store the CODEs under for later:</b></message>
     <message></td><td></message>
     <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />