[LON-CAPA-cvs] cvs: loncom /interface/spreadsheet Spreadsheet.pm assesscalc.pm studentcalc.pm

matthew lon-capa-cvs@mail.lon-capa.org
Thu, 22 May 2003 21:16:35 -0000


matthew		Thu May 22 17:16:35 2003 EDT

  Modified files:              
    /loncom/interface/spreadsheet	assesscalc.pm studentcalc.pm 
                                 	Spreadsheet.pm 
  Log:
  Added 'blackout' support.  A blackout occurs when an assessment has a part 
  flagged with 'problemstatus' equal to 'no'.  This prevents the display of
  the students performance on the part until the answerdate has passed.
  
  Spreadsheet.pm contains &blackout, which returns the blackout status of 
  the current spreadsheet.  
  
  assesscalc.pm contains code which 
      a) causes the computation of the spreadsheet to determine the 
         blackout status
      b) forces the recomputation of the spreadsheet if the user is a student.
    Obviously (b) is less than ideal and a new approach should be found.
  
  studentcalc.pm's outsheet_html subroutine now supresses the display of the
  export (aka 'summary') row, as well as the rows of any assessments which 
  are under blackout.
  
  
  
Index: loncom/interface/spreadsheet/assesscalc.pm
diff -u loncom/interface/spreadsheet/assesscalc.pm:1.4 loncom/interface/spreadsheet/assesscalc.pm:1.5
--- loncom/interface/spreadsheet/assesscalc.pm:1.4	Thu May 22 16:23:56 2003
+++ loncom/interface/spreadsheet/assesscalc.pm	Thu May 22 17:16:35 2003
@@ -1,5 +1,5 @@
 #
-# $Id: assesscalc.pm,v 1.4 2003/05/22 20:23:56 matthew Exp $
+# $Id: assesscalc.pm,v 1.5 2003/05/22 21:16:35 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -523,6 +523,20 @@
     my %f=$self->formulas();
     my %c;
     #
+    # Check for blackout requirements
+    if ((!exists($ENV{'request.role.adv'}) || !$ENV{'request.role.adv'})) {
+        while (my ($parm,$value) = each(%parameters)) {
+            last if ($self->blackout());
+            next if ($parm !~ /^(parameter_.*)_problemstatus$/);
+            next if ($parameters{$1.'_answerdate'}<time);
+            if (lc($value) eq 'no') {
+                # We must blackout this sheet
+                $self->blackout(1);
+            }
+        }
+    }
+    #
+    # Move the parameters into the spreadsheet
     while (my ($parm,$value) = each(%parameters)) {
         my $cell = 'A'.$self->get_row_number_from_key($parm);
         $f{$cell} = $parm;
@@ -652,7 +666,8 @@
 sub export_data {
     my $self = shift;
     my $symb = $self->{'symb'};
-    if (! exists($Exportrows{$symb}) || ! defined($Exportrows{$symb})  ||
+    if (! exists($ENV{'request.role.adv'}) || ! $ENV{'request.role.adv'} ||
+        ! exists($Exportrows{$symb}) || ! defined($Exportrows{$symb})  ||
         ! $self->check_expiration_time($Exportrows{$symb}->{'time'}) ||
         ! exists($Exportrows{$symb}->{$self->{'filename'}}) ||
         ! defined($Exportrows{$symb}->{$self->{'filename'}})) {
Index: loncom/interface/spreadsheet/studentcalc.pm
diff -u loncom/interface/spreadsheet/studentcalc.pm:1.3 loncom/interface/spreadsheet/studentcalc.pm:1.4
--- loncom/interface/spreadsheet/studentcalc.pm:1.3	Mon May 19 11:48:18 2003
+++ loncom/interface/spreadsheet/studentcalc.pm	Thu May 22 17:16:35 2003
@@ -1,5 +1,5 @@
 #
-# $Id: studentcalc.pm,v 1.3 2003/05/19 15:48:18 matthew Exp $
+# $Id: studentcalc.pm,v 1.4 2003/05/22 21:16:35 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -156,24 +156,40 @@
         $label_num++;
     }
     $tableheader .="</tr>\n";
-    #
-    $r->print($tableheader);
-    #
-    # Print out template row
-    $r->print('<tr><td>Template</td><td>&nbsp;</td>'.
-	      $self->html_template_row($num_uneditable)."</tr>\n");
-    #
-    # Print out summary/export row
-    $r->print('<tr><td>Export</td><td>0</td>'.
-	      $self->html_export_row()."</tr>\n");
+    if ($self->blackout()) {
+        $r->print('<font color="red" size="+2"><p>'.
+                  'Some computations are not available at this time.<br />'.
+                  'There are problems whose status you are allowed to view.'.
+                  '</font></p>'."\n");
+    } else {
+        $r->print($tableheader);
+        #
+        # Print out template row
+        if (exists($ENV{'request.role.adv'}) && $ENV{'request.role.adv'}) {
+            $r->print('<tr><td>Template</td><td>&nbsp;</td>'.
+                      $self->html_template_row($num_uneditable)."</tr>\n");
+        }
+        #
+        # Print out summary/export row
+        $r->print('<tr><td>Summary</td><td>0</td>'.
+                  $self->html_export_row()."</tr>\n");
+    }
     $r->print("</table>\n");
     #
     # Prepare to output rows
-    $tableheader =<<"END";
+    if (exists($ENV{'request.role.adv'}) && $ENV{'request.role.adv'}) {
+        $tableheader =<<"END";
 </p><p>
 <table border="2">
 <tr><th>Row</th><th>Assessment</th>
 END
+    } else {
+        $tableheader =<<"END";
+</p><p>
+<table border="2">
+<tr><th>&nbsp;</th><th>Assessment</th>
+END
+    }
     foreach (split(//,'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz')){
 	if ($label_num<$num_uneditable) { 
             $tableheader.='<td bgcolor="#FFDDDD">';
@@ -203,19 +219,25 @@
                     '<a href="/adm/assesscalc?sname='.$self->{'name'}.
                     '&sdomain='.$self->{'domain'}.
                     '&filename='.$assess_filename.
-                    '&usymb='.&Apache::lonnet::escape($resource->{'symb'}).'">'.
-                    $resource->{'title'}.'</a><br />';
+                    '&usymb='.&Apache::lonnet::escape($resource->{'symb'}).
+                    '">'.$resource->{'title'}.'</a><br />';
                 $row_output .= &assess_file_selector($rownum,
                                                      $assess_filename,
                                                      \@AssessFileNames).
                                                          '</td>';
             } else {
                 $row_output .= '<td><a href="'.$resource->{'src'}.'?symb='.
-                    &Apache::lonnet::escape($resource->{'symb'}).'>Go To</a>';
+                    &Apache::lonnet::escape($resource->{'symb'}).
+                    '">Go&nbsp;To</a>';
                 $row_output .= '</td><td>'.$resource->{'title'}.'</td>';
             }
-            $row_output .= $self->html_row($num_uneditable,$rownum).
-                "</tr>\n";
+            if ($self->blackout() && $self->{'blackout_rows'}->{$rownum}>0) {
+                $row_output .= 
+                    '<td colspan="52">Unavailable at this time</td></tr>'."\n";
+            } else {
+                $row_output .= $self->html_row($num_uneditable,$rownum).
+                    "</tr>\n";
+            }
             $r->print($row_output);
 	}
 	$r->print("</table>\n");
@@ -356,6 +378,10 @@
                                                       $assess_filename,
                                                       $resource->{'symb'});
             my @exportdata = $assessSheet->export_data();
+            if ($assessSheet->blackout()) {
+                $self->blackout(1);
+                $self->{'blackout_rows'}->{$rownum} = 1;
+            }
             #
             # Be sure not to disturb the formulas in the 'A' column
             my $data = shift(@exportdata);
Index: loncom/interface/spreadsheet/Spreadsheet.pm
diff -u loncom/interface/spreadsheet/Spreadsheet.pm:1.2 loncom/interface/spreadsheet/Spreadsheet.pm:1.3
--- loncom/interface/spreadsheet/Spreadsheet.pm:1.2	Mon May 19 09:58:05 2003
+++ loncom/interface/spreadsheet/Spreadsheet.pm	Thu May 22 17:16:35 2003
@@ -1,5 +1,5 @@
 #
-# $Id: Spreadsheet.pm,v 1.2 2003/05/19 13:58:05 matthew Exp $
+# $Id: Spreadsheet.pm,v 1.3 2003/05/22 21:16:35 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -98,6 +98,10 @@
         coursedesc => $ENV{'course.'.$ENV{'request.course.id'}.'.description'},
         coursefilename => $ENV{'request.course.fn'},
         #
+        # blackout is used to determine if any data needs to be hidden from the
+        # student.
+        blackout => 0,
+        #
         # Data storage
         formulas    => {},
         constants   => {},
@@ -1506,6 +1510,12 @@
         @alternatives = sort (keys(%results));
     }
     return @alternatives; 
+}
+
+sub blackout {
+    my $self = shift;
+    $self->{'blackout'} = $_[0] if (@_);
+    return $self->{'blackout'};
 }
 
 sub get_row {