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

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 19 May 2003 14:34:54 -0000


matthew		Mon May 19 10:34:54 2003 EDT

  Modified files:              
    /loncom/interface/spreadsheet	studentcalc.pm 
  Log:
  Cosmetic HTML changes.
  If the user does not have 'mgr' privileges the student spreadsheet will display
  a link to the resource for each assessment instead of a link to the assessment
  spreadsheet.
  
  
Index: loncom/interface/spreadsheet/studentcalc.pm
diff -u loncom/interface/spreadsheet/studentcalc.pm:1.1 loncom/interface/spreadsheet/studentcalc.pm:1.2
--- loncom/interface/spreadsheet/studentcalc.pm:1.1	Fri May 16 16:55:11 2003
+++ loncom/interface/spreadsheet/studentcalc.pm	Mon May 19 10:34:54 2003
@@ -1,5 +1,5 @@
 #
-# $Id: studentcalc.pm,v 1.1 2003/05/16 20:55:11 matthew Exp $
+# $Id: studentcalc.pm,v 1.2 2003/05/19 14:34:54 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -76,7 +76,7 @@
         &Apache::loncoursedata::get_sequence_assessment_data();
     if (! defined($top) || ! ref($top)) {
         # There has been an error, better report it
-        &Apache::lonnet::logthis('top is undefined');
+        &Apache::lonnet::logthis('top is undefined (studentcalc.pm)');
         return;
     }
     @Sequences = @{$sequences} if (ref($sequences) eq 'ARRAY');
@@ -111,12 +111,15 @@
     # Get the list of assessment files #
     ####################################
     my @AssessFileNames = $self->othersheets('assesscalc');
+    my $editing_is_allowed = &Apache::lonnet::allowed('mgr',
+                                                $ENV{'request.course.id'});
     ####################################
     # Determine table structure        #
     ####################################
     my $num_uneditable = 26;
     my $num_left = 52-$num_uneditable;
     my $tableheader =<<"END";
+<p>
 <table border="2">
 <tr>
   <th colspan="2" rowspan="2"><font size="+2">Student</font></th>
@@ -151,6 +154,7 @@
     #
     # Prepare to output rows
     $tableheader =<<"END";
+</p><p>
 <table border="2">
 <tr><th>Row</th><th>Assessment</th>
 END
@@ -176,22 +180,31 @@
 	    next if ($resource->{'type'} ne 'assessment');
 	    my $rownum = $self->get_row_number_from_key($resource->{'symb'});
             my $assess_filename = $self->{'row_source'}->{$rownum};
-	    my $row_output = '<tr><td>'.$rownum.'</td>';
-            $row_output .= '<td>'.
-                '<a href="/adm/assesscalc?sname='.$self->{'name'}.
-                '&sdomain='.$self->{'domain'}.
-                '&filename='.$assess_filename.
-                '&usymb='.$resource->{'symb'}.'">'.
-                $resource->{'title'}.'</a>';
-            $row_output .= &assess_file_selector($rownum,
-                                                 $assess_filename,
-                                                 \@AssessFileNames);
-            $row_output .= '</td>'.$self->html_row($num_uneditable,$rownum).
+            my $row_output = '<tr>';
+            if ($editing_is_allowed) {
+                $row_output .= '<td>'.$rownum.'</td>';
+                $row_output .= '<td>'.
+                    '<a href="/adm/assesscalc?sname='.$self->{'name'}.
+                    '&sdomain='.$self->{'domain'}.
+                    '&filename='.$assess_filename.
+                    '&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>';
+                $row_output .= '</td><td>'.$resource->{'title'}.'</td>';
+            }
+            $row_output .= $self->html_row($num_uneditable,$rownum).
                 "</tr>\n";
             $r->print($row_output);
 	}
 	$r->print("</table>\n");
     }
+    $r->print("</p>\n");
     return;
 }
 
@@ -208,7 +221,9 @@
 ########################################################
 sub assess_file_selector {
     my ($row,$default,$AssessFiles)=@_;
-    return '' if (!defined($AssessFiles) || ! @$AssessFiles);
+    if (!defined($AssessFiles) || ! @$AssessFiles) {
+        return '';
+    }
     return '' if (! &Apache::lonnet::allowed('mgr',$ENV{'request.course.id'}));
     my $element_name = 'FileSelect_'.$row;
     my $load_dialog = '<select size="1" name="'.$element_name.'" '.