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

sakharuk lon-capa-cvs@mail.lon-capa.org
Mon, 09 Sep 2002 19:27:43 -0000


sakharuk		Mon Sep  9 15:27:43 2002 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Interface for student choice was changed according to Gerd's desire.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.56 loncom/interface/lonprintout.pm:1.57
--- loncom/interface/lonprintout.pm:1.56	Fri Sep  6 13:46:13 2002
+++ loncom/interface/lonprintout.pm	Mon Sep  9 15:27:42 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.56 2002/09/06 17:46:13 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.57 2002/09/09 19:27:42 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -45,7 +45,6 @@
 use Apache::lonnet;
 use Apache::loncommon;
 use Apache::inputtags;
-use Apache::loncoursedata;
 use Apache::grades;
 use Apache::edit;
 use Apache::File();
@@ -62,7 +61,6 @@
 <body bgcolor="FFFFFF">
 <form method="post" enctype="multipart/form-data" action="/adm/printout" name="printform">
 <tt>$ENV{'form.postdata'}</tt><p>
-<h1>What do you want to print? Make a choice.</h1><br />
 ENDHEADER
 }
 
@@ -70,6 +68,7 @@
 sub menu_for_output {
     my $r = shift;
     $r->print(<<ENDMENUOUT1);
+<h1>What do you want to print? Make a choice.</h1><br />
 <input type="hidden" name="phase" value="two">
 <input type="hidden" name="url" value="$ENV{'form.postdata'}">
 <input type="radio" name="choice" value="Standard LaTeX output for current document" checked>  Current document
@@ -109,13 +108,6 @@
      Number of columns: <select name="numberofcolumns">
                          <option selected> 1 </option>
                          <option> 2 </option>
-                         <option> 3 </option>
-                         <option> 4 </option>
-                         <option> 5 </option>
-                         <option> 6 </option>
-                         <option> 7 </option>
-                         <option> 8 </option>
-                         <option> 9 </option>
                         </select> 
    </td>
  </tr>
@@ -135,28 +127,72 @@
 <input type="hidden" name="numberofcolumns" value="$ENV{'form.numberofcolumns'}">
 <h1>Mark students which assignments you want to print</h1>
 ENDMENUOUT1
-    my $c = $r->connection;    
-    my %cache;
-    my $courseID = $ENV{'request.course.id'};
-    my $classlist = &Apache::loncoursedata::DownloadClasslist($courseID,$cache{'ClasslistTimestamp'},$c);
-    &Apache::loncoursedata::ProcessClasslist(\%cache,$classlist,$courseID,$c);    
-    my @all_students = split(':::',$cache{'NamesOfStudents'});
-    my @active_students = ();
-    foreach my $student (@all_students) {
-	if ($cache{$student.':Status'} eq 'Active') {
-	    push @active_students,$student;
-	}
+    my %courselist=&Apache::lonnet::dump(
+                   'classlist',
+		   $ENV{'course.'.$ENV{'request.course.id'}.'.domain'},
+		   $ENV{'course.'.$ENV{'request.course.id'}.'.num'});
+    my $now=time;
+    $r->print(<<ENDDISHEADER);
+<input type=hidden name=sendmode value=group>
+<script>
+    function checkall() {
+	for (i=0; i<document.forms.printform.elements.length; i++) {
+            if 
+          (document.forms.printform.elements[i].name.indexOf('whomtoprint')==0) {
+	      document.forms.printform.elements[i].checked=true;
+            }
+        }
+    }
+
+    function checksec() {
+	for (i=0; i<document.forms.printform.elements.length; i++) {
+            if 
+          (document.forms.printform.elements[i].value.indexOf
+           (document.forms.printform.chksec.value)==0) {
+	      document.forms.printform.elements[i].checked=true;
+            }
+        }
+    }
+
+    function uncheckall() {
+	for (i=0; i<document.forms.printform.elements.length; i++) {
+            if 
+          (document.forms.printform.elements[i].name.indexOf('whomtoprint')==0) {
+	      document.forms.printform.elements[i].checked=false;
+            }
+        }
     }
-    my $what_to_print = '<table border="1">';    
+</script>
+<input type=button onClick="checkall()" value="Check for All">&nbsp;
+<input type=button onClick="checksec()" value="Check for Section/Group">
+<input type=text size=5 name=chksec>&nbsp;
+<input type=button onClick="uncheckall()" value="Check for None">
+<p>
+ENDDISHEADER
     my $i = 0;
-    foreach my $student (@active_students) {
-	$what_to_print .= '<tr><td><input type="checkbox" name="whomtoprint'.$i.'" value="'.$student.'">'.$cache{$student.':fullname'}.'</td></tr>';
-#	$what_to_print .= '<tr><td><input type="checkbox" name="whomtoprint'.$i.'" value="'.$cache{$student.':fullname'}.'">'.$cache{$student.':fullname'}.'</td></tr>';
-	$i++;
+    foreach (sort keys %courselist) {
+        my ($end,$start)=split(/\:/,$courselist{$_});
+        my $active=1;
+        if (($end) && ($now>$end)) { $active=0; }
+        if ($active) {
+           my ($sname,$sdom)=split(/\:/,$_);
+           my %reply=&Apache::lonnet::get('environment',
+              ['firstname','middlename','lastname','generation'],
+              $sdom,$sname);
+           my $section=&Apache::lonnet::usection
+	       ($sdom,$sname,$ENV{'request.course.id'});
+           $r->print(
+        '<br /><input type=checkbox name="whomtoprint'.$i.'" value="'.$section.':'.$_.'"> '.
+		      $reply{'firstname'}.' '. 
+                      $reply{'middlename'}.' '.
+                      $reply{'lastname'}.' '.
+                      $reply{'generation'}.
+                      ' ('.$_.') '.$section);
+	   $i++;
+        } 
     }
-    $what_to_print .= '</table>';
     $r->print(<<ENDMENUOUT2);
-    $what_to_print <br />
+<br />
 <input type="hidden" name="numberofstudents" value="$i">
 <input type="hidden" name="phase" value="three">
 <input type="submit" value="Submit">
@@ -177,7 +213,10 @@
 <input type="hidden" name="layout" value="$ENV{'form.layout'}">
 <input type="hidden" name="numberofstudents" value="$ENV{'form.numberofstudents'}">
 <input type="hidden" name="numberofcolumns" value="$ENV{'form.numberofcolumns'}">
-Enter width of the page: <input type="text" name="width" width="10" value="9cm"> <br />
+Define page layout parameters: <br />
+<b>Width</b>: <input type="text" name="width" width="8" value="9cm"> <br />
+<b>Height</b>: <input type="text" name="height" width="8" value="25.9cm"> <br />
+<b>Left margin</b>: <input type="text" name="leftmargin" width="8" value="-0.57in"> <br />
 <input type="hidden" name="phase" value="four">
 <input type="submit" value="Submit">
 </form>
@@ -339,7 +378,7 @@
         #loop over students
 	foreach my $person (@students) {
 	    my $current_output = ''; 
-	    my ($username,$userdomain) = split /:/,$person;
+	    my ($usersection,$username,$userdomain) = split /:/,$person;
 	    my $fullname = &Apache::grades::get_fullname($username,$userdomain);
             #goes through all resources, checks if they are available for current student, and produces output 
 	    foreach my $curres (@master_seq)  {