File:  [LON-CAPA] / loncom / interface / lonevaluate.pm
Revision 1.7: download - view: text, annotated - select for diffs
Thu Mar 28 21:38:53 2002 UTC (22 years, 3 months ago) by www
Branches: MAIN
CVS tags: HEAD
Evaluate accepts postdata, and get_unprocessed_cgi does not paste over existing
post values (important when doing no-target post submit on URL with query
string - get array reference otherwise).

    1: # The LearningOnline Network
    2: # Evaluate
    3: #
    4: # $Id: lonevaluate.pm,v 1.7 2002/03/28 21:38:53 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # (Internal Server Error Handler
   29: #
   30: # (Login Screen
   31: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
   32: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
   33: #
   34: # 3/1/1 Gerd Kortemeyer)
   35: #
   36: # 3/1,12/6,12/12,12/21,12/22 Gerd Kortemeyer
   37: #
   38: package Apache::lonevaluate;
   39: 
   40: use strict;
   41: use Apache::lonnet;
   42: use Apache::Constants qw(:common);
   43: 
   44: sub handler {
   45:     my $r = shift;
   46:     $r->content_type('text/html');
   47:     $r->send_http_header;
   48:     return OK if $r->header_only;
   49: 
   50:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['postdata']);
   51:   my $feedurl=$ENV{'form.postdata'};
   52:   $feedurl=~s/^http\:\/\///;
   53:   $feedurl=~s/^$ENV{'SERVER_NAME'}//;
   54:   $feedurl=~s/^$ENV{'HTTP_HOST'}//;
   55: 
   56:   $feedurl=&Apache::lonnet::declutter($feedurl);
   57:   my $symb=&Apache::lonnet::symbread($feedurl);
   58: 
   59:     my ($rdomain,$rauth)=($feedurl=~/^(\w+)\/(\w+)\//);
   60: 
   61:     my $prefix=$ENV{'user.name'}.'@'.$ENV{'user.domain'}.'___'.
   62: 	$feedurl.'___';
   63: 
   64:     my @items=('correct','helpful','depth','clear','technical','comments',
   65:                'timestamp');
   66: 
   67:     my @retrieve=map{ $prefix.$_ } @items;
   68: 
   69:     my %currenteval=
   70:        &Apache::lonnet::get('resevaldata',\@retrieve,$rdomain,$rauth);
   71: 
   72:     my $already=($currenteval{$prefix.'timestamp'} ne '');
   73: 
   74:     $ENV{'form.timestamp'}=time;
   75: 
   76:     my $warning='';
   77: 
   78:     if ($ENV{'form.submiteval'} eq 'true') {
   79: # ------------------------------------------------ User is submitting something
   80:         my $complete=1;
   81: 	foreach my $item (@items) {
   82: 	    if ($ENV{'form.'.$item}) {
   83: 		$currenteval{$prefix.$item}=$ENV{'form.'.$item};
   84:             } elsif ($item ne 'comments') {
   85:                 $complete=0;
   86:             }
   87:         }
   88:         if ($complete) {
   89:            $r->print(<<ENDHEADER);
   90: <html>
   91: <head>
   92: <title>Evaluation submitted</title>
   93: <meta http-equiv="pragma" content="no-cache"></meta>
   94: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=/res/$feedurl">
   95: </head>
   96: <body bgcolor="#FFFFFF">
   97: <h1>Thank you for your input!</h1>
   98: ENDHEADER
   99:        $r->print('Storing feedback: '.
  100:            &Apache::lonnet::put('resevaldata',\%currenteval,$rdomain,$rauth));
  101:            unless ($already) {
  102: 	       $r->print('<br>Logging first evaluation');
  103:            }
  104:            $r->print('</body></html>');
  105:            return OK;
  106:         } else {
  107: 	    $warning='Please fill out all fields below';
  108:         }
  109:     
  110:     }
  111: 
  112: # ---------------------------------------------------------- Dial in old values
  113:     my $dialold='';
  114:     my $oldcomments='';
  115: 
  116:     foreach my $item (@items) {
  117:        unless ($item eq 'comments') {
  118:            unless ($item eq 'timestamp') {
  119:               $dialold.=
  120:                    'document.evaluation.'.$item.'.selectedIndex='.
  121:                    $currenteval{$prefix.$item}.";\n";
  122: 	   }
  123:        } else {
  124:            $oldcomments=$currenteval{$prefix.$item};
  125:        }       
  126:     }
  127: 
  128: # ------------------------------------------------------- Print out eval screen
  129:     my $standardoptions=(<<ENDOPTIONS);
  130: <option value=0>-</option>
  131: <option value=1>Strongly Disagree</option>
  132: <option value=2>Disagree</option>
  133: <option value=3>Neutral</option>
  134: <option value=4>Agree</option>
  135: <option value=5>Strongly Agree</option>
  136: ENDOPTIONS
  137: 
  138:     $r->print(<<ENDDOCUMENT);
  139: <html>
  140: <head>
  141: <title>The LearningOnline Network with CAPA</title>
  142: </head>
  143: <body bgcolor="#FFFFFF">
  144: <h1>Evaluate Resource</h1>
  145: <tt>$feedurl</tt><p>
  146: <h3><font color="red">$warning</font></h3>
  147: Please rank the following criteria:
  148: <form method=post name=evaluation>
  149: <input type=hidden name=submiteval value=true>
  150: <input type=hidden name=postdata value="$feedurl">
  151: The material appears to be correct
  152: <br><select name=correct>
  153: $standardoptions
  154: </select>
  155: <hr>
  156: The material is helpful
  157: <br><select name=helpful>
  158: $standardoptions
  159: </select>
  160: <hr>
  161: The material is covered with sufficient depth
  162: <br><select name=depth>
  163: $standardoptions
  164: </select>
  165: <hr>
  166: The material is presented in a clear way
  167: <br><select name=clear>
  168: $standardoptions
  169: </select>
  170: <hr>
  171: The resource is technically correct 
  172: (loads fast enough, does not produce errors, links work, etc) 
  173: <br><select name=technical>
  174: $standardoptions
  175: </select>
  176: <hr>
  177: Any comments?
  178: <br><textarea name=comments cols=40 rows=5>$oldcomments</textarea>
  179: <script>$dialold</script>
  180: <br><input type=submit value="Submit Evaluation">
  181: </form>
  182: </body>
  183: </html>
  184: ENDDOCUMENT
  185:     return OK;
  186: } 
  187: 
  188: 1;
  189: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>