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

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

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