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

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 06 Mar 2006 23:32:32 -0000


foxr		Mon Mar  6 18:32:32 2006 EDT

  Modified files:              
    /loncom/interface	lonhelper.pm lonprintout.pm 
  Log:
  Enh. request 3809: Got the expired students separated from the 
  unexpired students now.
  
  
Index: loncom/interface/lonhelper.pm
diff -u loncom/interface/lonhelper.pm:1.131 loncom/interface/lonhelper.pm:1.132
--- loncom/interface/lonhelper.pm:1.131	Thu Mar  2 18:56:55 2006
+++ loncom/interface/lonhelper.pm	Mon Mar  6 18:32:31 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # .helper XML handler to implement the LON-CAPA helper
 #
-# $Id: lonhelper.pm,v 1.131 2006/03/02 23:56:55 foxr Exp $
+# $Id: lonhelper.pm,v 1.132 2006/03/06 23:32:31 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2306,6 +2306,13 @@
             } 
         }
     }
+    function checkexpired()  {
+	for (i=0; i<document.forms.helpform.elements.length; i++) {
+            if (document.forms.helpform.elements[i].value.indexOf(':Expired') != -1) {
+                document.forms.helpform.elements[i].checked=true;
+            } 
+        }
+    }
     function uncheckexpired() {
 	for (i=0; i<document.forms.helpform.elements.length; i++) {
             if (document.forms.helpform.elements[i].value.indexOf(':Expired') != -1) {
@@ -2395,6 +2402,7 @@
 	delete($defaultUsers{''});
     }
     my $choices = [];
+    my $expired_students = [];	# Will hold expired students.
 
     # Load up the non-students, if necessary
     if ($self->{'coursepersonnel'}) {
@@ -2479,12 +2487,20 @@
 
     # username, fullname, section, type
     for (@keys) {
-	# Filter out inactive students if we've set "activeonly"
-	if (!$self->{'activeonly'} || $classlist->{$_}->[$status] eq
+
+	# We split the active students into the choices array and
+        # inactive ones into expired_students so that we can put them in 2 separate
+	# tables.
+
+	if ( $classlist->{$_}->[$status] eq
 	    'Active') {
 	    push @$choices, [$_, $classlist->{$_}->[$fullname], 
 			     $classlist->{$_}->[$section],
 			     $classlist->{$_}->[$status], 'Student'];
+	} else {
+	    push @$expired_students, [$_, $classlist->{$_}->[$fullname], 
+				      $classlist->{$_}->[$section],
+				      $classlist->{$_}->[$status], 'Student'];
 	}
     }
 
@@ -2499,6 +2515,9 @@
 	"<td align='center'><b>".&mt('Username').":".&mt('Domain')."</b></td></tr>";
 
     my $checked = 0;
+    #
+    # Give the active students and staff:
+    #
     for my $choice (@$choices) {
         $result .= "<tr><td><input type='$type' name='" .
             $self->{'variable'} . '.forminput' . "'";
@@ -2530,9 +2549,58 @@
 	    . HTML::Entities::encode($choice->[0],'<>&"')
 	    . "</td></tr>\n";
     }
-
     $result .= "</table>\n\n";
 
+    # If activeonly is not set then we can also give the expired students:
+    #
+    if (!$self->{'activeonly'} && ((scalar @$expired_students) > 0)) {
+	$result .= "<p>Inactive students: </p>\n";
+	$result .= <<INACTIVEBUTTONS;
+	   <table>
+              <tr>
+                 <td><input type="button" value="Select expired" onclick="checkexpired();" /> </td>
+		 <td><input type="button" value="Unselect expired" onclick="uncheckexpired();" /></td>
+              </tr>
+           </table>
+INACTIVEBUTTONS
+	$result .= "<table>\n";
+
+	for my $choice (@$expired_students) {
+        $result .= "<tr><td><input type='$type' name='" .
+            $self->{'variable'} . '.forminput' . "'";
+            
+	if (%defaultUsers) {
+	    my $user=$choice->[0];
+	    if (exists($defaultUsers{$user})) {
+		$result .= " checked='checked' ";
+		$checked = 1;
+	    }
+	} elsif (!$self->{'multichoice'} && !$checked) {
+            $result .= " checked='checked' ";
+            $checked = 1;
+        }
+        $result .=
+            " value='" . HTML::Entities::encode($choice->[0] . ':' 
+						.$choice->[2] . ':' 
+						.$choice->[1] . ':' 
+						.$choice->[3], "<>&\"'")
+            . "' /></td><td>"
+            . HTML::Entities::encode($choice->[1],'<>&"')
+            . "</td><td align='center'>" 
+            . HTML::Entities::encode($choice->[2],'<>&"')
+            . "</td>\n<td>" 
+	    . HTML::Entities::encode($choice->[3],'<>&"')
+            . "</td>\n<td>" 
+	    . HTML::Entities::encode($choice->[4],'<>&"')
+            . "</td>\n<td>" 
+	    . HTML::Entities::encode($choice->[0],'<>&"')
+	    . "</td></tr>\n";	    
+	}
+	$result .= "</table>\n";
+	
+    }
+
+
 
     return $result;
 }
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.425 loncom/interface/lonprintout.pm:1.426
--- loncom/interface/lonprintout.pm:1.425	Thu Mar  2 18:56:55 2006
+++ loncom/interface/lonprintout.pm	Mon Mar  6 18:32:31 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.425 2006/03/02 23:56:55 foxr Exp $
+# $Id: lonprintout.pm,v 1.426 2006/03/06 23:32:31 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2351,11 +2351,11 @@
 
 	&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);
   <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">
-    <student multichoice='1' variable="STUDENTS" nextstate="SELECT_RESOURCES" coursepersonnel="1" />
     <choices variable='student_sort'>
       <choice computer='0'>Sort by section then student</choice>
       <choice computer='1'>Sort by students across sections.</choice>
     </choices>
+    <student multichoice='1' variable="STUDENTS" nextstate="SELECT_RESOURCES" coursepersonnel="1" />
 
     </state>
     $resource_selector