File:  [LON-CAPA] / loncom / interface / lonevaluate.pm
Revision 1.12: download - view: text, annotated - select for diffs
Sat Jul 5 10:07:11 2003 UTC (20 years, 10 months ago) by www
Branches: MAIN
CVS tags: version_1_2_X, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, HEAD
Have very limited connectivity, need to do big commit while online.
Will call this JULYone in Bugzilla. Fixes several small bugs.

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

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