Annotation of loncom/interface/statistics/lonproblemanalysis.pm, revision 1.24
1.1 stredwic 1: # The LearningOnline Network with CAPA
2: #
1.24 ! matthew 3: # $Id: lonproblemanalysis.pm,v 1.23 2003/09/29 21:09:27 matthew Exp $
1.1 stredwic 4: #
5: # Copyright Michigan State University Board of Trustees
6: #
7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
8: #
9: # LON-CAPA is free software; you can redistribute it and/or modify
10: # it under the terms of the GNU General Public License as published by
11: # the Free Software Foundation; either version 2 of the License, or
12: # (at your option) any later version.
13: #
14: # LON-CAPA is distributed in the hope that it will be useful,
15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: # GNU General Public License for more details.
18: #
19: # You should have received a copy of the GNU General Public License
20: # along with LON-CAPA; if not, write to the Free Software
21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: #
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: # (Navigate problems for statistical reports
28: # YEAR=2002
1.11 minaeibi 29: # 5/12,7/26,9/7,11/22 Behrouz Minaei
1.1 stredwic 30: #
31: ###
32:
1.11 minaeibi 33: package Apache::lonproblemanalysis;
1.1 stredwic 34:
35: use strict;
36: use Apache::lonnet();
1.7 stredwic 37: use Apache::lonhtmlcommon();
1.23 matthew 38: use Apache::loncoursedata();
39: use Apache::lonstatistics;
40: use Apache::lonlocal;
1.2 stredwic 41:
1.1 stredwic 42: sub BuildProblemAnalysisPage {
1.23 matthew 43: my ($r,$c)=@_;
1.24 ! matthew 44: $r->print('<h2>'.&mt('Option Response Problem Analysis').'</h2>');
1.23 matthew 45: if (exists($ENV{'form.problemchoice'})) {
46: # This is me getting around my own cleverness:
47: &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
48: undef);
49: #
50: my ($symb,$id) = &get_problem_symb(
51: &Apache::lonnet::unescape($ENV{'form.problemchoice'})
52: );
53: $r->print('<hr />');
54: my $resource = &get_resource_from_symb($symb);
55: if (defined($resource)) {
56: $r->print('<table bgcolor="ffffff"><tr><td>'.
57: # Oh this is dumb! Need to rewrite relative links
58: # otherwise images (for example) will not show.
59: &Apache::lonnet::ssi_body($resource->{'src'}).
60: '</td></tr></table>');
61: } else {
62: $r->print('resource is undefined');
1.7 stredwic 63: }
1.23 matthew 64: $r->print('<ol>');
65: $r->print("<li />render problem\n");
66: $r->print("<li />image tag for plot\n");
67: $r->print("<li />plot key\n");
68: $r->print('</ol>');
69: $r->print("<pre>\nProblem choice = $symb $id\n</pre>\n");
70: $r->print('<hr />');
71: }
72: $r->print('<input type="hidden" name="analysisfirstcall" value="no" />');
73: $r->print(&CreateInterface());
74: if (! exists($ENV{'form.analysisfirstcall'})) {
1.5 stredwic 75: return;
1.1 stredwic 76: }
1.23 matthew 77: # Okay, they asked for data, so make sure we get the latest data.
78: &Apache::lonnet::logthis('got here for some reason');
79: # &Apache::lonstatistics::Gather_Full_Student_Data($r);
80: $r->print(&OptionResponseProblemSelector());
1.1 stredwic 81: }
82:
1.23 matthew 83: sub get_problem_symb {
84: my $problemstring = shift();
85: my ($symb,$id) = ($problemstring=~ /^(.*):([^:]*)$/);
86: return ($symb,$id);
1.1 stredwic 87: }
88:
1.23 matthew 89: sub CreateInterface {
1.7 stredwic 90: my $Str = '';
1.23 matthew 91: $Str .= '<table cellspacing="5">'."\n";
92: $Str .= '<tr>';
93: $Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>';
94: $Str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>';
95: $Str .= '<td align="center"><b>'.&mt('Sequences and Folders').'</b></td>';
96: $Str .= '</tr>'."\n";
97: #
98: $Str .= '<tr><td align="center">'."\n";
99: $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
100: $Str .= '</td><td align="center">';
101: $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
102: $Str .= '</td><td align="center">';
103: my $only_seq_with_assessments = sub {
104: my $s=shift;
105: if ($s->{'num_assess'} < 1) {
106: return 0;
107: } else {
108: return 1;
109: }
110: };
111: $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
112: $only_seq_with_assessments);
113: $Str .= '</td></tr>'."\n";
114: $Str .= '</table>'."\n";
115: $Str .= '<input type="submit" name="ProblemAnalysis" value="'.
116: &mt('Analyze Problem').'" />';
117: $Str .= ' 'x5;
118: $Str .= '<input type="submit" name="ClearCache" value="'.
119: &mt('Clear Caches').'" />';
120: $Str .= ' 'x5;
121: return ($Str);
122: }
123:
124: sub OptionResponseProblemSelector {
125: my $Str;
126: $Str = "\n<table>\n";
127: foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
128: next if ($seq->{'num_assess'}<1);
129: my $seq_str = '';
130: foreach my $res (@{$seq->{'contents'}}) {
131: # &Apache::lonnet::logthis('checking '.$res->{'title'});
132: # next if ($res->{'type'} ne 'assessment');
133: foreach my $part (@{$res->{'parts'}}) {
134: my $partdata = $res->{'partdata'}->{$part};
135: if (! exists($partdata->{'option'}) ||
136: $partdata->{'option'} == 0) {
137: next;
138: }
139: for (my $i=0;$i<scalar(@{$partdata->{'ResponseTypes'}});$i++){
140: my $respid = $partdata->{'ResponseIds'}->[$i];
141: my $resptype = $partdata->{'ResponseTypes'}->[$i];
142: if ($resptype eq 'option') {
143: my $value = &Apache::lonnet::escape($res->{'symb'}.':'.$respid);
144: my $checked = '';
145: if ($ENV{'form.problemchoice'} eq $value) {
146: $checked = 'checked ';
147: }
148: $seq_str .= '<tr><td>'.
149: '<input type="radio" name="problemchoice" value="'.$value.'" '.$checked.'/>'.
150: '</td><td>'.
151: '<a href="'.$res->{'src'}.'">'.$res->{'title'}.'</a> ';
152: if ($partdata->{'option'} > 1) {
153: $seq_str .= &mt('response').' '.$respid;
154: }
155: $seq_str .= "</td></tr>\n";
1.11 minaeibi 156: }
157: }
158: }
159: }
1.23 matthew 160: if ($seq_str ne '') {
161: $Str .= '<tr><td> </td><td><b>'.$seq->{'title'}.'</b></td>'.
162: "</tr>\n".$seq_str;
163: }
1.11 minaeibi 164: }
1.23 matthew 165: $Str .= "</table>\n";
166: return $Str;
1.11 minaeibi 167: }
168:
1.23 matthew 169: sub get_resource_from_symb {
170: my ($symb) = @_;
171: &Apache::lonnet::logthis('target symb = :'.$symb.':');
172: foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
173: foreach my $res (@{$seq->{'contents'}}) {
174: &Apache::lonnet::logthis('symb = :'.$res->{'symb'}.':');
175: if ($res->{'symb'} eq $symb) {
176: return $res;
1.2 stredwic 177: }
1.1 stredwic 178: }
179: }
1.23 matthew 180: return undef;
1.1 stredwic 181: }
182:
1.23 matthew 183: =pod
1.11 minaeibi 184:
1.23 matthew 185: sub InitAnalysis {
186: my ($resource,$sname,$sdom)=@_;
187: my $symb = $resource->
188: my $URI = $hash{'src_'.$rid};
189:
190: my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze',
191: 'grade_username' => $sname,
192: 'grade_domain' => $sdom,
193: 'grade_courseid' => $cid,
194: 'grade_symb' => $symb));
195: # my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze'));
196:
197: (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2);
198: %Answer=();
199: %Answer=&Apache::lonnet::str2hash($Answ);
200:
201: my $parts='';
202: foreach my $elm (@{$Answer{"parts"}}) {
203: $parts.="$elm,";
204: }
205: chop($parts);
206: my $conc='';
207: foreach my $elm (@{$Answer{"$parts.concepts"}}) {
208: $conc.="$elm@";
209: }
210: chop($conc);
211:
212: @Concepts=split(/\@/,$conc);
213: foreach my $concept (@{$Answer{"$parts.concepts"}}) {
214: foreach my $foil (@{$Answer{"$parts.concept.$concept"}}) {
215: $foil_to_concept{$foil} = $concept;
216: #$ConceptData{$foil} = $Answer{"$parts.foil.value.$foil"};
1.1 stredwic 217: }
218: }
1.23 matthew 219: return $symb;
1.1 stredwic 220: }
221:
1.23 matthew 222: =cut
1.1 stredwic 223:
1.23 matthew 224: 1;
1.1 stredwic 225:
226: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>