Annotation of loncom/interface/lonevaluate.pm, revision 1.26
1.1 www 1: # The LearningOnline Network
2: # Evaluate
3: #
1.26 ! jms 4: # $Id: lonevaluate.pm,v 1.25 2008/11/18 19:14:22 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:
103: my $start_page =
104: &Apache::loncommon::start_page('Evaluate Resource',$js);
1.24 albertel 105: $r->print('
106: '.$start_page.'
107: <h1>'.&mt('Thank you for your input!').'</h1>
108: ');
109: $r->print(&mt('Saving feedback: [_1]',
110: &Apache::lonnet::put('nohist_resevaldata',\%currenteval,$rdomain,$rauth)));
1.4 www 111: unless ($already) {
1.24 albertel 112: $r->print('<br />'.&mt('Logging first evaluation'));
1.4 www 113: }
1.8 www 114: $r->print(
1.19 albertel 115: '<script type="text/javascript">setTimeout("goback()",2000);</script>'.&Apache::loncommon::end_page());
1.4 www 116: return OK;
117: } else {
1.24 albertel 118: $warning=&mt('Please fill out all fields below');
1.4 www 119: }
1.8 www 120:
1.3 www 121: }
1.4 www 122:
123: # ---------------------------------------------------------- Dial in old values
124: my $dialold='';
1.5 www 125: my $oldcomments='';
126:
127: foreach my $item (@items) {
128: unless ($item eq 'comments') {
1.11 www 129: unless (($item eq 'timestamp') ||
130: (!defined($currenteval{$prefix.$item}))) {
1.5 www 131: $dialold.=
132: 'document.evaluation.'.$item.'.selectedIndex='.
133: $currenteval{$prefix.$item}.";\n";
134: }
135: } else {
136: $oldcomments=$currenteval{$prefix.$item};
137: }
138: }
1.3 www 139: # ------------------------------------------------------- Print out eval screen
1.23 albertel 140: my %lt=&Apache::lonlocal::texthash('a' => 'Strongly Disagree',
141: 'b' => 'Disagree',
142: 'c' => 'Neutral',
143: 'd' => 'Agree',
144: 'e' => 'Strongly Agree',);
1.22 bisitz 145: my $standardoptions='';
146: $standardoptions = (<<ENDOPTIONS);
1.18 albertel 147: <option value="0">-</option>
1.22 bisitz 148: <option value="1">$lt{'a'}</option>
149: <option value="2">$lt{'b'}</option>
150: <option value="3">$lt{'c'}</option>
151: <option value="4">$lt{'d'}</option>
152: <option value="5">$lt{'e'}</option>
1.2 www 153: ENDOPTIONS
1.22 bisitz 154:
1.19 albertel 155: my $start_page = &Apache::loncommon::start_page('Evaluate Resource');
156: my $end_page = &Apache::loncommon::end_page();
1.22 bisitz 157:
158: %lt=&Apache::lonlocal::texthash(
1.23 albertel 159: 'pleaserank' => 'Please rank the following criteria:',
160: 'correct' => 'The material appears to be correct',
161: 'helpful' => 'The material is helpful',
162: 'depth' => 'The material is covered with sufficient depth',
163: 'clear' => 'The material is presented in a clear way',
164: 'technical' => 'The resource is technically correct (loads fast enough, does not produce errors, links work, etc)',
165: 'comments' => 'Any comments?',
166: 'submit' => 'Submit Evaluation',
1.22 bisitz 167: );
1.1 www 168: $r->print(<<ENDDOCUMENT);
1.19 albertel 169: $start_page
1.22 bisitz 170: <h2><tt>$title</tt></h2><br /><br />
1.4 www 171: <h3><font color="red">$warning</font></h3>
1.22 bisitz 172: $lt{'pleaserank'}<br />
1.18 albertel 173: <form method="post" name="evaluation" action="/adm/evaluate">
174: <input type="hidden" name="submiteval" value="true" />
175: <input type="hidden" name="postdata" value="$showurl" />
1.22 bisitz 176: <hr />
177: $lt{'correct'}
1.18 albertel 178: <br /><select name="correct">
1.2 www 179: $standardoptions
180: </select>
1.18 albertel 181: <hr />
1.22 bisitz 182: $lt{'helpful'}
1.18 albertel 183: <br /><select name="helpful">
1.2 www 184: $standardoptions
185: </select>
1.18 albertel 186: <hr />
1.22 bisitz 187: $lt{'depth'}
1.18 albertel 188: <br /><select name="depth">
1.2 www 189: $standardoptions
190: </select>
1.18 albertel 191: <hr />
1.22 bisitz 192: $lt{'clear'}
1.18 albertel 193: <br /><select name="clear">
1.2 www 194: $standardoptions
195: </select>
1.18 albertel 196: <hr />
1.22 bisitz 197: $lt{'technical'}
1.18 albertel 198: <br /><select name="technical">
1.2 www 199: $standardoptions
200: </select>
1.18 albertel 201: <hr />
1.22 bisitz 202: $lt{'comments'}
1.18 albertel 203: <br /><textarea name="comments" cols="40" rows="5">$oldcomments</textarea>
204: <script type="text/javascript">$dialold</script>
1.22 bisitz 205: <br /><input type="submit" value="$lt{'submit'}" />
1.2 www 206: </form>
1.19 albertel 207: $end_page
1.1 www 208: ENDDOCUMENT
209: return OK;
210: }
211:
212: 1;
213: __END__
1.26 ! jms 214:
! 215: =pod
! 216:
! 217: =head1 NAME
! 218:
! 219: Apache::lonevaluate.pm
! 220:
! 221: =head1 SYNOPSIS
! 222:
! 223: Handles evaluation.
! 224:
! 225: This is part of the LearningOnline Network with CAPA project
! 226: described at http://www.lon-capa.org.
! 227:
! 228: =head1 OVERVIEW
! 229:
! 230: None
! 231:
! 232: =cut
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>