Annotation of loncom/interface/lonevaluate.pm, revision 1.4

1.1       www         1: # The LearningOnline Network
                      2: # Evaluate
                      3: #
1.2       www         4: # $Id: gplheader.pl,v 1.1 2001/11/29 18:19:27 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: #
1.1       www        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: #
1.3       www        36: # 3/1,12/6,12/12 Gerd Kortemeyer
1.1       www        37: #
                     38: package Apache::lonevaluate;
                     39: 
                     40: use strict;
1.3       www        41: use Apache::lonnet;
1.1       www        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: 
1.3       www        50:   my $feedurl=$ENV{'form.postdata'};
                     51:   $feedurl=~s/^http\:\/\///;
                     52:   $feedurl=~s/^$ENV{'SERVER_NAME'}//;
                     53:   $feedurl=~s/^$ENV{'HTTP_HOST'}//;
                     54: 
                     55:   $feedurl=&Apache::lonnet::declutter($feedurl);
                     56:   my $symb=&Apache::lonnet::symbread($feedurl);
                     57: 
                     58:     my ($rdomain,$rauth)=($feedurl=~/^(\w+)\/(\w+)\//);
                     59: 
                     60:     my $prefix=$ENV{'user.name.'}.'@'.$ENV{'user.domain'}.'___'.
                     61: 	$feedurl.'___';
                     62: 
1.4     ! www        63:     my @items=('correct','helpful','depth','clear','technical','comments',
        !            64:                'timestamp');
1.3       www        65: 
                     66:     my @retrieve=map{ $prefix.$_ } @items;
                     67: 
1.4     ! www        68:     my %currenteval=
        !            69:        &Apache::lonnet::get('resevaldata',\@retrieve,$rdomain,$rauth);
        !            70: 
        !            71:     my $already=($currenteval{$prefix.'timestamp'} ne '');
        !            72: 
        !            73:     $ENV{'form.timestamp'}=time;
        !            74: 
        !            75:     my $warning='';
        !            76: 
1.3       www        77:     if ($ENV{'form.submiteval'} eq 'true') {
                     78: # ------------------------------------------------ User is submitting something
1.4     ! www        79:         my $complete=1;
        !            80: 	foreach my $item (@items) {
        !            81: 	    if ($ENV{'form.'.$item}) {
        !            82: 		$currenteval{$prefix.$item}=$ENV{'form.'.$item};
        !            83:             } elsif ($item ne 'comments') {
        !            84:                 $complete=0;
        !            85:             }
        !            86:         }
        !            87:         if ($complete) {
        !            88:            $r->print(<<ENDHEADER);
        !            89: <html>
        !            90: <head>
        !            91: <title>Evaluation submitted</title>
        !            92: <meta http-equiv="pragma" content="no-cache"></meta>
        !            93: <meta HTTP-EQUIV="Refresh" CONTENT="2; url=/res/$feedurl">
        !            94: </head>
        !            95: <body bgcolor="#FFFFFF">
        !            96: <h1>Thank you for your input!</h1>
        !            97: ENDHEADER
        !            98:        $r->print('Storing feedback: '.
        !            99:            &Apache::lonnet::put('resevaldata',\%currenteval,$rdomain,$rauth));
        !           100:            unless ($already) {
        !           101: 	       $r->print('<br>Logging first evaluation');
        !           102:            }
        !           103:            $r->print('</body></html>');
        !           104:            return OK;
        !           105:         } else {
        !           106: 	    $warning='Please fill out all fields below';
        !           107:         }
        !           108:     
1.3       www       109:     }
1.4     ! www       110: 
        !           111: # ---------------------------------------------------------- Dial in old values
        !           112:     my $dialold='';
        !           113: 
1.3       www       114: # ------------------------------------------------------- Print out eval screen
1.2       www       115:     my $standardoptions=(<<ENDOPTIONS);
                    116: <option value=0>-</option>
                    117: <option value=1>Strongly Disagree</option>
                    118: <option value=2>Disagree</option>
                    119: <option value=3>Neutral</option>
                    120: <option value=4>Agree</option>
                    121: <option value=5>Strongly Agree</option>
                    122: ENDOPTIONS
                    123: 
                    124:     my $oldcomments='';
                    125: 
1.1       www       126:     $r->print(<<ENDDOCUMENT);
                    127: <html>
                    128: <head>
                    129: <title>The LearningOnline Network with CAPA</title>
                    130: </head>
                    131: <body bgcolor="#FFFFFF">
1.2       www       132: <h1>Evaluate Resource</h1>
1.3       www       133: <tt>$feedurl</tt><p>
1.4     ! www       134: <h3><font color="red">$warning</font></h3>
1.2       www       135: Please rank the following criteria:
                    136: <form method=post>
                    137: <input type=hidden name=submiteval value=true>
1.3       www       138: <input type=hidden name=postdata value="$feedurl">
1.2       www       139: The material appears to be correct
                    140: <br><select name=correct>
                    141: $standardoptions
                    142: </select>
                    143: <hr>
                    144: The material is helpful
                    145: <br><select name=helpful>
                    146: $standardoptions
                    147: </select>
                    148: <hr>
                    149: The material is covered with sufficient depth
                    150: <br><select name=depth>
                    151: $standardoptions
                    152: </select>
                    153: <hr>
                    154: The material is presented in a clear way
                    155: <br><select name=clear>
                    156: $standardoptions
                    157: </select>
                    158: <hr>
                    159: The resource is technically correct 
                    160: (loads fast enough, does not produce errors, links work, etc) 
1.3       www       161: <br><select name=technical>
1.2       www       162: $standardoptions
                    163: </select>
                    164: <hr>
                    165: Any comments?
                    166: <br><textarea name=comments cols=40 rows=5>$oldcomments</textarea>
                    167: $dialold
1.4     ! www       168: <br><input type=submit value="Submit Evaluation">
1.2       www       169: </form>
1.1       www       170: </body>
                    171: </html>
                    172: ENDDOCUMENT
                    173:     return OK;
                    174: } 
                    175: 
                    176: 1;
                    177: __END__

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