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

1.1       www         1: # The LearningOnline Network
                      2: # Evaluate
                      3: #
1.29    ! bisitz      4: # $Id: lonevaluate.pm,v 1.28 2008/12/24 07:56:50 raeburn 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.28      raeburn    51:     $feedurl=~s/^https?\:\/\///;
1.13      albertel   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.29    ! bisitz     91:             my $js = &Apache::lonhtmlcommon::scripttag(<<ENDJS);
1.13      albertel   92:     function goback() {
1.29    ! bisitz     93:         if ((window.name=='loncapaclient')) {
1.13      albertel   94:             window.location='$showurl';
1.12      www        95:         } else {
                     96:             self.close();
1.8       www        97:         }
                     98:     }
1.19      albertel   99: ENDJS
                    100: 
1.29    ! bisitz    101:             # Breadcrumbs
        !           102:             my $brcrum = [{'href' => '/adm/evaluate',
        !           103:                            'text' => 'Evaluate Resource'},
        !           104:                           {'href' => '',
        !           105:                            'text' => 'Done'}];
        !           106: 
        !           107:             my $start_page = &Apache::loncommon::start_page('Evaluate Resource',
        !           108:                                                             $js,
        !           109:                                                             {'bread_crumbs' => $brcrum,});
        !           110: 
        !           111:             $r->print($start_page
        !           112:                      .'<p class="LC_success">'
1.27      bisitz    113:                      .&mt('Saving feedback: [_1]'
1.29    ! bisitz    114:                           ,&Apache::lonnet::put(
        !           115:                                'nohist_resevaldata',\%currenteval,$rdomain,$rauth))
        !           116:                      .'</p>'
        !           117:             );
1.4       www       118:            unless ($already) {
1.29    ! bisitz    119:                $r->print('<p>'.&mt('Logging first evaluation').'</p>');
1.4       www       120:            }
1.29    ! bisitz    121:            $r->print('<p><b>'.&mt('Thank you for your input!').'</b></p>'
        !           122:                     .&Apache::lonhtmlcommon::scripttag(
        !           123:                         'setTimeout("goback()",2000);')
        !           124:                     .&Apache::loncommon::end_page()
        !           125:            );
1.4       www       126:            return OK;
                    127:         } else {
1.29    ! bisitz    128:             $warning=&mt('Please fill out all fields below.');
1.4       www       129:         }
1.8       www       130:    
1.3       www       131:     }
1.4       www       132: 
                    133: # ---------------------------------------------------------- Dial in old values
                    134:     my $dialold='';
1.5       www       135:     my $oldcomments='';
                    136: 
                    137:     foreach my $item (@items) {
                    138:        unless ($item eq 'comments') {
1.11      www       139:            unless (($item eq 'timestamp') || 
                    140:                    (!defined($currenteval{$prefix.$item}))) {
1.5       www       141:               $dialold.=
                    142:                    'document.evaluation.'.$item.'.selectedIndex='.
                    143:                    $currenteval{$prefix.$item}.";\n";
                    144: 	   }
                    145:        } else {
                    146:            $oldcomments=$currenteval{$prefix.$item};
                    147:        }       
                    148:     }
1.3       www       149: # ------------------------------------------------------- Print out eval screen
1.23      albertel  150:     my %lt=&Apache::lonlocal::texthash('a' => 'Strongly Disagree',
                    151: 				       'b' => 'Disagree',
                    152: 				       'c' => 'Neutral',
                    153: 				       'd' => 'Agree',
                    154: 				       'e' => 'Strongly Agree',);
1.22      bisitz    155:     my $standardoptions='';
                    156:     $standardoptions = (<<ENDOPTIONS);
1.18      albertel  157: <option value="0">-</option>
1.22      bisitz    158: <option value="1">$lt{'a'}</option>
                    159: <option value="2">$lt{'b'}</option>
                    160: <option value="3">$lt{'c'}</option>
                    161: <option value="4">$lt{'d'}</option>
                    162: <option value="5">$lt{'e'}</option>
1.2       www       163: ENDOPTIONS
1.22      bisitz    164: 
1.29    ! bisitz    165:     # Breadcrumbs
        !           166:     my $brcrum = [{'href' => '/adm/evaluate',
        !           167:                    'text' => 'Evaluate Resource'}];
        !           168: 
        !           169:     my $start_page = &Apache::loncommon::start_page('Evaluate Resource',
        !           170:                                                     undef,
        !           171:                                                     {'bread_crumbs' => $brcrum,});
1.19      albertel  172:     my $end_page   = &Apache::loncommon::end_page();
1.22      bisitz    173: 
1.29    ! bisitz    174:     %lt=&Apache::lonlocal::texthash(
1.23      albertel  175:        'pleaserank' => 'Please rank the following criteria:',
                    176:        'correct'    => 'The material appears to be correct',
                    177:        'helpful'    => 'The material is helpful',
                    178:        'depth'      => 'The material is covered with sufficient depth',
                    179:        'clear'      => 'The material is presented in a clear way',
                    180:        'technical'  => 'The resource is technically correct (loads fast enough, does not produce errors, links work, etc)',
1.29    ! bisitz    181:        'comments'   => 'Comments',
1.23      albertel  182:        'submit'     => 'Submit Evaluation',
1.22      bisitz    183:     );
1.29    ! bisitz    184:     $r->print(
        !           185:         $start_page
        !           186:        .'<h2>'.$title.'</h2>'
        !           187:        .'<p class="LC_warning">'.$warning.'</p>'
        !           188:        .'<form method="post" name="evaluation" action="/adm/evaluate">'
        !           189:        .'<input type="hidden" name="submiteval" value="true" />'
        !           190:        .'<input type="hidden" name="postdata" value="'.$showurl.'" />'
        !           191:     );
        !           192:     $r->print(
        !           193:         &Apache::lonhtmlcommon::start_pick_box()
        !           194:        .&Apache::lonhtmlcommon::row_headline()
        !           195:        .$lt{'pleaserank'}
        !           196:        .&Apache::lonhtmlcommon::row_closure()
        !           197:     );
        !           198: 
        !           199:     foreach my $key ('correct', 'helpful', 'depth', 'clear', 'technical') {
        !           200:         $r->print(
        !           201:             &Apache::lonhtmlcommon::row_title($lt{$key})
        !           202:            .'<select name="'.$key.'">'
        !           203:            .$standardoptions
        !           204:            .'</select>'
        !           205:            .&Apache::lonhtmlcommon::row_closure()
        !           206:         );
        !           207:     }
        !           208: 
        !           209:     $r->print(
        !           210:         &Apache::lonhtmlcommon::row_title($lt{'comments'})
        !           211:        .'<textarea name="comments" cols="40" rows="5">'
        !           212:        .$oldcomments
        !           213:        .'</textarea>'
        !           214:        .&Apache::lonhtmlcommon::row_closure(1)
        !           215:        .&Apache::lonhtmlcommon::end_pick_box()
        !           216:        .'<p>'
        !           217:        .'<input type="submit" value="'.$lt{'submit'}.'" />'
        !           218:        .'</p>'
        !           219:     );
        !           220: 
        !           221:     $r->print(
        !           222:         &Apache::lonhtmlcommon::scripttag($dialold)
        !           223:        .'</form>'
        !           224:        .$end_page
        !           225:     );
        !           226: 
1.1       www       227:     return OK;
                    228: } 
                    229: 
                    230: 1;
                    231: __END__
1.26      jms       232: 
                    233: =pod
                    234: 
                    235: =head1 NAME
                    236: 
                    237: Apache::lonevaluate.pm
                    238: 
                    239: =head1 SYNOPSIS
                    240: 
                    241: Handles evaluation.
                    242: 
                    243: This is part of the LearningOnline Network with CAPA project
                    244: described at http://www.lon-capa.org.
                    245: 
                    246: =head1 OVERVIEW
                    247: 
                    248: None
                    249: 
                    250: =cut

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.