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

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.5     ! www        36: # 3/1,12/6,12/12,12/21 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='';
1.5     ! www       113:     my $oldcomments='';
        !           114: 
        !           115:     foreach my $item (@items) {
        !           116:        unless ($item eq 'comments') {
        !           117:            unless ($item eq 'timestamp') {
        !           118:               $dialold.=
        !           119:                    'document.evaluation.'.$item.'.selectedIndex='.
        !           120:                    $currenteval{$prefix.$item}.";\n";
        !           121: 	   }
        !           122:        } else {
        !           123:            $oldcomments=$currenteval{$prefix.$item};
        !           124:        }       
        !           125:     }
1.4       www       126: 
1.3       www       127: # ------------------------------------------------------- Print out eval screen
1.2       www       128:     my $standardoptions=(<<ENDOPTIONS);
                    129: <option value=0>-</option>
                    130: <option value=1>Strongly Disagree</option>
                    131: <option value=2>Disagree</option>
                    132: <option value=3>Neutral</option>
                    133: <option value=4>Agree</option>
                    134: <option value=5>Strongly Agree</option>
                    135: ENDOPTIONS
                    136: 
1.1       www       137:     $r->print(<<ENDDOCUMENT);
                    138: <html>
                    139: <head>
                    140: <title>The LearningOnline Network with CAPA</title>
                    141: </head>
                    142: <body bgcolor="#FFFFFF">
1.2       www       143: <h1>Evaluate Resource</h1>
1.3       www       144: <tt>$feedurl</tt><p>
1.4       www       145: <h3><font color="red">$warning</font></h3>
1.2       www       146: Please rank the following criteria:
1.5     ! www       147: <form method=post name=evaluation>
1.2       www       148: <input type=hidden name=submiteval value=true>
1.3       www       149: <input type=hidden name=postdata value="$feedurl">
1.2       www       150: The material appears to be correct
                    151: <br><select name=correct>
                    152: $standardoptions
                    153: </select>
                    154: <hr>
                    155: The material is helpful
                    156: <br><select name=helpful>
                    157: $standardoptions
                    158: </select>
                    159: <hr>
                    160: The material is covered with sufficient depth
                    161: <br><select name=depth>
                    162: $standardoptions
                    163: </select>
                    164: <hr>
                    165: The material is presented in a clear way
                    166: <br><select name=clear>
                    167: $standardoptions
                    168: </select>
                    169: <hr>
                    170: The resource is technically correct 
                    171: (loads fast enough, does not produce errors, links work, etc) 
1.3       www       172: <br><select name=technical>
1.2       www       173: $standardoptions
                    174: </select>
                    175: <hr>
                    176: Any comments?
                    177: <br><textarea name=comments cols=40 rows=5>$oldcomments</textarea>
1.5     ! www       178: <script>$dialold</script>
1.4       www       179: <br><input type=submit value="Submit Evaluation">
1.2       www       180: </form>
1.1       www       181: </body>
                    182: </html>
                    183: ENDDOCUMENT
                    184:     return OK;
                    185: } 
                    186: 
                    187: 1;
                    188: __END__

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