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

Gerd Kortemeyer lon-capa-cvs@mail.lon-capa.org
Thu, 05 Dec 2002 10:35:15 -0500


Hmmm ... not sure about the editability of cells for students. If the spreadsheet is
eventually to be used as a grades extrapolator, the cells need to remain editable.

matthew wrote:

> matthew         Thu Dec  5 10:31:05 2002 EDT
>
>   Modified files:
>     /loncom/interface   lonspreadsheet.pm
>   Log:
>   Changes to fix bug 1031 - no longer print out spreadsheet cells as editable
>       when the users role is that of a student.
>   Omit the Template row when displaying information to the student.
>   Rename the 'Export' row as 'Summary' because (from the students perspective)
>       there is nothing to export the row to.
>
>
> Index: loncom/interface/lonspreadsheet.pm
> diff -u loncom/interface/lonspreadsheet.pm:1.154 loncom/interface/lonspreadsheet.pm:1.155
> --- loncom/interface/lonspreadsheet.pm:1.154    Wed Dec  4 16:49:33 2002
> +++ loncom/interface/lonspreadsheet.pm  Thu Dec  5 10:31:05 2002
> @@ -1,5 +1,5 @@
>  #
> -# $Id: lonspreadsheet.pm,v 1.154 2002/12/04 21:49:33 matthew Exp $
> +# $Id: lonspreadsheet.pm,v 1.155 2002/12/05 15:31:05 matthew Exp $
>  #
>  # Copyright Michigan State University Board of Trustees
>  #
> @@ -1284,6 +1284,7 @@
>  sub outsheet_html  {
>      my ($sheet,$r) = @_;
>      my ($num_uneditable,$realm,$row_type);
> +    my $requester_is_student = ($ENV{'request.role'} =~ /^st\./);
>      if ($sheet->{'sheettype'} eq 'assesscalc') {
>          $num_uneditable = 1;
>          $realm = 'Assessment';
> @@ -1328,34 +1329,39 @@
>      ####################################
>      # Print out template row
>      ####################################
> -    my ($rowlabel,@rowdata) = &get_row($sheet,'-');
> -    my $row_html = '<tr><td>'.&format_html_rowlabel($sheet,$rowlabel).'</td>';
> -    my $num_cols_output = 0;
> -    foreach my $cell (@rowdata) {
> -        if ($num_cols_output++ < $num_uneditable) {
> -            $row_html .= '<td bgcolor="#FFDDDD">';
> -            $row_html .= &html_uneditable_cell($cell,'#FFDDDD');
> -        } else {
> -            $row_html .= '<td bgcolor="#EOFFDD">';
> -            $row_html .= &html_editable_cell($cell,'#E0FFDD');
> +    my ($num_cols_output,$row_html,$rowlabel,@rowdata);
> +
> +    if (! $requester_is_student) {
> +        ($rowlabel,@rowdata) = &get_row($sheet,'-');
> +        $row_html = '<tr><td>'.&format_html_rowlabel($sheet,$rowlabel).'</td>';
> +        $num_cols_output = 0;
> +        foreach my $cell (@rowdata) {
> +            if ($requester_is_student ||
> +                $num_cols_output++ < $num_uneditable) {
> +                $row_html .= '<td bgcolor="#FFDDDD">';
> +                $row_html .= &html_uneditable_cell($cell,'#FFDDDD');
> +            } else {
> +                $row_html .= '<td bgcolor="#EOFFDD">';
> +                $row_html .= &html_editable_cell($cell,'#E0FFDD');
> +            }
> +            $row_html .= '</td>';
>          }
> -        $row_html .= '</td>';
> +        $row_html.= "</tr>\n";
> +        $r->print($row_html);
>      }
> -    $row_html.= "</tr>\n";
> -    $r->print($row_html);
>      ####################################
>      # Print out summary/export row
>      ####################################
>      ($rowlabel,@rowdata) = &get_row($sheet,'0');
> -    $row_html = '<tr><td>'.&format_html_rowlabel($sheet,$rowlabel).'</td>';
> +    $row_html = '<tr><td>'.&format_html_rowlabel($sheet,'Summary').'</td>';
>      $num_cols_output = 0;
>      foreach my $cell (@rowdata) {
> -        if ($num_cols_output++ < 26) {
> +        if ($num_cols_output++ < 26 && ! $requester_is_student) {
>              $row_html .= '<td bgcolor="#CCCCFF">';
>              $row_html .= &html_editable_cell($cell,'#CCCCFF');
>          } else {
>              $row_html .= '<td bgcolor="#DDCCFF">';
> -            $row_html .= &html_uneditable_cell(undef,'#CCCCFF');
> +            $row_html .= &html_uneditable_cell($cell,'#CCCCFF');
>          }
>          $row_html .= '</td>';
>      }
> @@ -1432,7 +1438,7 @@
>              $bgcolor='#FFDDDD' if ($shown_cells < $num_uneditable);
>              #
>              $row_html.='<td bgcolor='.$bgcolor.'>';
> -            if ($shown_cells < $num_uneditable) {
> +            if ($requester_is_student || $shown_cells < $num_uneditable) {
>                  $row_html .= &html_uneditable_cell($cell,$bgcolor);
>              } else {
>                  $row_html .= &html_editable_cell($cell,$bgcolor);
>
> _______________________________________________
> LON-CAPA-cvs mailing list
> LON-CAPA-cvs@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-cvs