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

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

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