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

1.1       www         1: # The LearningOnline Network
                      2: # Evaluate
                      3: #
1.25    ! jms         4: # $Id: lonevaluate.pm,v 1.24 2007/11/28 01:46: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.17      albertel   28: 
1.25    ! jms        29: =pod
        !            30: 
        !            31: =head1 NAME
        !            32: 
        !            33: Apache::lonevaluate.pm
        !            34: 
        !            35: =head1 SYNOPSIS
        !            36: 
        !            37: Handles evaluation.
        !            38: 
        !            39: This is part of the LearningOnline Network with CAPA project
        !            40: described at http://www.lon-capa.org.
        !            41: 
        !            42: =head1 OVERVIEW
        !            43: 
        !            44: None
        !            45: 
        !            46: =cut
        !            47: 
1.1       www        48: package Apache::lonevaluate;
                     49: 
                     50: use strict;
1.17      albertel   51: use Apache::lonnet;
1.1       www        52: use Apache::Constants qw(:common);
1.14      albertel   53: use Apache::loncommon();
                     54: use Apache::lonenc();
1.24      albertel   55: use Apache::lonlocal;
1.20      albertel   56: use LONCAPA();
1.1       www        57: 
                     58: sub handler {
                     59:     my $r = shift;
1.16      albertel   60:     &Apache::loncommon::content_type($r,'text/html');
1.19      albertel   61:     &Apache::loncommon::no_cache($r);
                     62:     
1.1       www        63:     $r->send_http_header;
                     64:     return OK if $r->header_only;
                     65: 
1.7       www        66:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['postdata']);
1.17      albertel   67:     my $feedurl=$env{'form.postdata'};
1.13      albertel   68:     $feedurl=~s/^http\:\/\///;
                     69:     $feedurl=~s/^$ENV{'SERVER_NAME'}//;
                     70:     $feedurl=~s/^$ENV{'HTTP_HOST'}//;
1.3       www        71: 
1.13      albertel   72:     $feedurl=&Apache::lonnet::declutter($feedurl);
                     73: 
                     74:     my $title=&Apache::lonnet::gettitle($feedurl);
                     75:     my $showurl=&Apache::lonenc::check_encrypt($feedurl);
1.3       www        76: 
1.20      albertel   77:     my ($rdomain,$rauth)=($feedurl=~/^($LONCAPA::domain_re)\/($LONCAPA::username_re)\//);
1.3       www        78: 
1.17      albertel   79:     my $prefix=$env{'user.name'}.'@'.$env{'user.domain'}.'___'.
1.3       www        80: 	$feedurl.'___';
                     81: 
1.4       www        82:     my @items=('correct','helpful','depth','clear','technical','comments',
                     83:                'timestamp');
1.3       www        84: 
                     85:     my @retrieve=map{ $prefix.$_ } @items;
                     86: 
1.4       www        87:     my %currenteval=
1.9       albertel   88:        &Apache::lonnet::get('nohist_resevaldata',\@retrieve,$rdomain,$rauth);
1.4       www        89: 
                     90:     my $already=($currenteval{$prefix.'timestamp'} ne '');
                     91: 
1.17      albertel   92:     $env{'form.timestamp'}=time;
1.4       www        93: 
                     94:     my $warning='';
                     95: 
1.17      albertel   96:     if ($env{'form.submiteval'} eq 'true') {
1.3       www        97: # ------------------------------------------------ User is submitting something
1.4       www        98:         my $complete=1;
                     99: 	foreach my $item (@items) {
1.17      albertel  100: 	    if ($env{'form.'.$item}) {
                    101: 		$currenteval{$prefix.$item}=$env{'form.'.$item};
1.4       www       102:             } elsif ($item ne 'comments') {
                    103:                 $complete=0;
                    104:             }
                    105:         }
                    106:         if ($complete) {
1.13      albertel  107: 	    my $showurl=&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($feedurl));
1.19      albertel  108: 	    my $js =<<ENDJS;
1.18      albertel  109: <script type="text/javascript">
1.13      albertel  110:     function goback() {
1.12      www       111: 	if ((window.name=='loncapaclient')) {
1.13      albertel  112:             window.location='$showurl';
1.12      www       113:         } else {
                    114:             self.close();
1.8       www       115:         }
                    116:     }
                    117: </script>
1.19      albertel  118: ENDJS
                    119: 
                    120:             my $start_page = 
                    121: 	        &Apache::loncommon::start_page('Evaluate Resource',$js);
1.24      albertel  122: 	    $r->print('
                    123: '.$start_page.'
                    124: <h1>'.&mt('Thank you for your input!').'</h1>
                    125: ');
                    126:        $r->print(&mt('Saving feedback: [_1]',
                    127: 		     &Apache::lonnet::put('nohist_resevaldata',\%currenteval,$rdomain,$rauth)));
1.4       www       128:            unless ($already) {
1.24      albertel  129: 	       $r->print('<br />'.&mt('Logging first evaluation'));
1.4       www       130:            }
1.8       www       131:            $r->print(
1.19      albertel  132:             '<script type="text/javascript">setTimeout("goback()",2000);</script>'.&Apache::loncommon::end_page());
1.4       www       133:            return OK;
                    134:         } else {
1.24      albertel  135: 	    $warning=&mt('Please fill out all fields below');
1.4       www       136:         }
1.8       www       137:    
1.3       www       138:     }
1.4       www       139: 
                    140: # ---------------------------------------------------------- Dial in old values
                    141:     my $dialold='';
1.5       www       142:     my $oldcomments='';
                    143: 
                    144:     foreach my $item (@items) {
                    145:        unless ($item eq 'comments') {
1.11      www       146:            unless (($item eq 'timestamp') || 
                    147:                    (!defined($currenteval{$prefix.$item}))) {
1.5       www       148:               $dialold.=
                    149:                    'document.evaluation.'.$item.'.selectedIndex='.
                    150:                    $currenteval{$prefix.$item}.";\n";
                    151: 	   }
                    152:        } else {
                    153:            $oldcomments=$currenteval{$prefix.$item};
                    154:        }       
                    155:     }
1.3       www       156: # ------------------------------------------------------- Print out eval screen
1.23      albertel  157:     my %lt=&Apache::lonlocal::texthash('a' => 'Strongly Disagree',
                    158: 				       'b' => 'Disagree',
                    159: 				       'c' => 'Neutral',
                    160: 				       'd' => 'Agree',
                    161: 				       'e' => 'Strongly Agree',);
1.22      bisitz    162:     my $standardoptions='';
                    163:     $standardoptions = (<<ENDOPTIONS);
1.18      albertel  164: <option value="0">-</option>
1.22      bisitz    165: <option value="1">$lt{'a'}</option>
                    166: <option value="2">$lt{'b'}</option>
                    167: <option value="3">$lt{'c'}</option>
                    168: <option value="4">$lt{'d'}</option>
                    169: <option value="5">$lt{'e'}</option>
1.2       www       170: ENDOPTIONS
1.22      bisitz    171: 
1.19      albertel  172:     my $start_page = &Apache::loncommon::start_page('Evaluate Resource');
                    173:     my $end_page   = &Apache::loncommon::end_page();
1.22      bisitz    174: 
                    175:      %lt=&Apache::lonlocal::texthash(
1.23      albertel  176:        'pleaserank' => 'Please rank the following criteria:',
                    177:        'correct'    => 'The material appears to be correct',
                    178:        'helpful'    => 'The material is helpful',
                    179:        'depth'      => 'The material is covered with sufficient depth',
                    180:        'clear'      => 'The material is presented in a clear way',
                    181:        'technical'  => 'The resource is technically correct (loads fast enough, does not produce errors, links work, etc)',
                    182:        'comments'   => 'Any comments?',
                    183:        'submit'     => 'Submit Evaluation',
1.22      bisitz    184:     );
1.1       www       185:     $r->print(<<ENDDOCUMENT);
1.19      albertel  186: $start_page
1.22      bisitz    187: <h2><tt>$title</tt></h2><br /><br />
1.4       www       188: <h3><font color="red">$warning</font></h3>
1.22      bisitz    189: $lt{'pleaserank'}<br />
1.18      albertel  190: <form method="post" name="evaluation" action="/adm/evaluate">
                    191: <input type="hidden" name="submiteval" value="true" />
                    192: <input type="hidden" name="postdata" value="$showurl" />
1.22      bisitz    193: <hr />
                    194: $lt{'correct'}
1.18      albertel  195: <br /><select name="correct">
1.2       www       196: $standardoptions
                    197: </select>
1.18      albertel  198: <hr />
1.22      bisitz    199: $lt{'helpful'}
1.18      albertel  200: <br /><select name="helpful">
1.2       www       201: $standardoptions
                    202: </select>
1.18      albertel  203: <hr />
1.22      bisitz    204: $lt{'depth'}
1.18      albertel  205: <br /><select name="depth">
1.2       www       206: $standardoptions
                    207: </select>
1.18      albertel  208: <hr />
1.22      bisitz    209: $lt{'clear'}
1.18      albertel  210: <br /><select name="clear">
1.2       www       211: $standardoptions
                    212: </select>
1.18      albertel  213: <hr />
1.22      bisitz    214: $lt{'technical'}
1.18      albertel  215: <br /><select name="technical">
1.2       www       216: $standardoptions
                    217: </select>
1.18      albertel  218: <hr />
1.22      bisitz    219: $lt{'comments'}
1.18      albertel  220: <br /><textarea name="comments" cols="40" rows="5">$oldcomments</textarea>
                    221: <script type="text/javascript">$dialold</script>
1.22      bisitz    222: <br /><input type="submit" value="$lt{'submit'}" />
1.2       www       223: </form>
1.19      albertel  224: $end_page
1.1       www       225: ENDDOCUMENT
                    226:     return OK;
                    227: } 
                    228: 
                    229: 1;
                    230: __END__

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