File:  [LON-CAPA] / loncom / interface / lonevaluate.pm
Revision 1.13: download - view: text, annotated - select for diffs
Thu Nov 11 22:20:12 2004 UTC (19 years, 7 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- fixed to handle encrypturl

    1: # The LearningOnline Network
    2: # Evaluate
    3: #
    4: # $Id: lonevaluate.pm,v 1.13 2004/11/11 22:20:12 albertel 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: use Apache::loncommon;
   44: 
   45: sub handler {
   46:     my $r = shift;
   47:     $r->content_type('text/html');
   48:     $r->send_http_header;
   49:     return OK if $r->header_only;
   50: 
   51:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['postdata']);
   52:     my $feedurl=$ENV{'form.postdata'};
   53:     $feedurl=~s/^http\:\/\///;
   54:     $feedurl=~s/^$ENV{'SERVER_NAME'}//;
   55:     $feedurl=~s/^$ENV{'HTTP_HOST'}//;
   56: 
   57:     $feedurl=&Apache::lonnet::declutter($feedurl);
   58: 
   59:     my $title=&Apache::lonnet::gettitle($feedurl);
   60:     my $showurl=&Apache::lonenc::check_encrypt($feedurl);
   61: 
   62:     my ($rdomain,$rauth)=($feedurl=~/^(\w+)\/(\w+)\//);
   63: 
   64:     my $prefix=$ENV{'user.name'}.'@'.$ENV{'user.domain'}.'___'.
   65: 	$feedurl.'___';
   66: 
   67:     my @items=('correct','helpful','depth','clear','technical','comments',
   68:                'timestamp');
   69: 
   70:     my @retrieve=map{ $prefix.$_ } @items;
   71: 
   72:     my %currenteval=
   73:        &Apache::lonnet::get('nohist_resevaldata',\@retrieve,$rdomain,$rauth);
   74: 
   75:     my $already=($currenteval{$prefix.'timestamp'} ne '');
   76: 
   77:     $ENV{'form.timestamp'}=time;
   78: 
   79:     my $warning='';
   80: 
   81:     my $bodytag=&Apache::loncommon::bodytag('Evaluate Resource');
   82: 
   83:     if ($ENV{'form.submiteval'} eq 'true') {
   84: # ------------------------------------------------ User is submitting something
   85:         my $complete=1;
   86: 	foreach my $item (@items) {
   87: 	    if ($ENV{'form.'.$item}) {
   88: 		$currenteval{$prefix.$item}=$ENV{'form.'.$item};
   89:             } elsif ($item ne 'comments') {
   90:                 $complete=0;
   91:             }
   92:         }
   93:         if ($complete) {
   94: 	    my $showurl=&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($feedurl));
   95:            $r->print(<<ENDHEADER);
   96: <html>
   97: <head>
   98: <title>Evaluation submitted</title>
   99: <script>
  100:     function goback() {
  101: 	if ((window.name=='loncapaclient')) {
  102:             window.location='$showurl';
  103:         } else {
  104:             self.close();
  105:         }
  106:     }
  107: </script>
  108: <meta http-equiv="pragma" content="no-cache"></meta>
  109: </head>
  110: $bodytag
  111: <h1>Thank you for your input!</h1>
  112: ENDHEADER
  113:        $r->print('Storing feedback: '.
  114:            &Apache::lonnet::put('nohist_resevaldata',\%currenteval,$rdomain,$rauth));
  115:            unless ($already) {
  116: 	       $r->print('<br>Logging first evaluation');
  117:            }
  118:            $r->print(
  119:             '<script>setTimeout("goback()",2000);</script></body></html>');
  120:            return OK;
  121:         } else {
  122: 	    $warning='Please fill out all fields below';
  123:         }
  124:    
  125:     }
  126: 
  127: # ---------------------------------------------------------- Dial in old values
  128:     my $dialold='';
  129:     my $oldcomments='';
  130: 
  131:     foreach my $item (@items) {
  132:        unless ($item eq 'comments') {
  133:            unless (($item eq 'timestamp') || 
  134:                    (!defined($currenteval{$prefix.$item}))) {
  135:               $dialold.=
  136:                    'document.evaluation.'.$item.'.selectedIndex='.
  137:                    $currenteval{$prefix.$item}.";\n";
  138: 	   }
  139:        } else {
  140:            $oldcomments=$currenteval{$prefix.$item};
  141:        }       
  142:     }
  143: # ------------------------------------------------------- Print out eval screen
  144:     my $standardoptions=(<<ENDOPTIONS);
  145: <option value=0>-</option>
  146: <option value=1>Strongly Disagree</option>
  147: <option value=2>Disagree</option>
  148: <option value=3>Neutral</option>
  149: <option value=4>Agree</option>
  150: <option value=5>Strongly Agree</option>
  151: ENDOPTIONS
  152: 
  153:     $r->print(<<ENDDOCUMENT);
  154: <html>
  155: <head>
  156: <title>The LearningOnline Network with CAPA</title>
  157: </head>
  158: $bodytag
  159: <tt>$title</tt><p>
  160: <h3><font color="red">$warning</font></h3>
  161: Please rank the following criteria:
  162: <form method=post name=evaluation>
  163: <input type=hidden name=submiteval value=true>
  164: <input type=hidden name=postdata value="$showurl">
  165: The material appears to be correct
  166: <br><select name=correct>
  167: $standardoptions
  168: </select>
  169: <hr>
  170: The material is helpful
  171: <br><select name=helpful>
  172: $standardoptions
  173: </select>
  174: <hr>
  175: The material is covered with sufficient depth
  176: <br><select name=depth>
  177: $standardoptions
  178: </select>
  179: <hr>
  180: The material is presented in a clear way
  181: <br><select name=clear>
  182: $standardoptions
  183: </select>
  184: <hr>
  185: The resource is technically correct 
  186: (loads fast enough, does not produce errors, links work, etc) 
  187: <br><select name=technical>
  188: $standardoptions
  189: </select>
  190: <hr>
  191: Any comments?
  192: <br><textarea name=comments cols=40 rows=5>$oldcomments</textarea>
  193: <script>$dialold</script>
  194: <br><input type=submit value="Submit Evaluation">
  195: </form>
  196: </body>
  197: </html>
  198: ENDDOCUMENT
  199:     return OK;
  200: } 
  201: 
  202: 1;
  203: __END__

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