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

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

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