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

From: Guy Albertelli II <[email-masked]>
Date: Mon, 2 Dec 2002 16:59:49 -0500 (EST)

Hi All,

>   Bugfix for escaping of special characters.  < and > must be
>   translated to &lt; and &gt; before & is translated to &amp;
>   because the code gets unescaped by the browser twice.  This
>   current version works for cells like:

Please don't do HTML Entity encoding by hand.

There is a routine for doing this:

use HTML::Entities();

my $encoded=&Html::Entities::encode($string_to_go_to_browser);

-- 
[email-masked]          BM: n^20 t20 z20 qS 
Guy Albertelli -7-7-7-  O-
    Well I best be going . . . crack don't smoke itself you know 
                                           -C.Chambers

---

From: "Matthew Brian Hall" <[email-masked]>
Date: Thu, 5 Dec 2002 10:41:06 -0500 (EST)

Gerd,

We do need to eventually provide a grade extrapolator but I don't think the
spreadsheet is the right place/format for it.  I doubt anyone has really used
it as such...  Something similar in appearance to the 'quickgrades' page would
probably be worthwhile - currently they would have to specify each potential
homework grade instead of 'I will get all of the next homework set right'.

At the least I'm uncomfortable with giving the students the ability to tie
up the httpd with a 'while(1)' anytime they get pissed off at us...

Matthew

> Hmmm ... not sure about the editability of cells for students. If the spreadsh

eet is
> eventually to be used as a grades extrapolator, the cells need to remain edita

ble.
>
> 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 editabl

e
> >       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 perspectiv

e)
> >       there is nothing to export the row to.
> >
> >
> > Index: loncom/interface/lonspreadsheet.pm
> > diff -u loncom/interface/lonspreadsheet.pm:1.154 loncom/interface/lonspreads

heet.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).'</t

d>';
> > +        $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
> > [email-masked]
> > http://mail.lon-capa.org/mailman/listinfo/lon-capa-cvs
>
> _______________________________________________
> LON-CAPA-cvs mailing list
> [email-masked]
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-cvs
>

--
------------------------------------------------------------------
Matthew Hall           LON-CAPA developer         [email-masked]
123 North Kedzie Hall                    Michigan State University
------------------------------------------------------------------