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