Annotation of loncom/interface/statistics/lonproblemanalysis.pm, revision 1.37
1.1 stredwic 1: # The LearningOnline Network with CAPA
2: #
1.33 matthew 3:
1.37 ! matthew 4: # $Id: lonproblemanalysis.pm,v 1.36 2003/10/14 20:20:40 matthew Exp $
1.1 stredwic 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:
1.11 minaeibi 29: package Apache::lonproblemanalysis;
1.1 stredwic 30:
31: use strict;
32: use Apache::lonnet();
1.25 matthew 33: use Apache::loncommon();
1.7 stredwic 34: use Apache::lonhtmlcommon();
1.23 matthew 35: use Apache::loncoursedata();
36: use Apache::lonstatistics;
37: use Apache::lonlocal;
1.37 ! matthew 38: use HTML::Entities();
1.2 stredwic 39:
1.1 stredwic 40: sub BuildProblemAnalysisPage {
1.23 matthew 41: my ($r,$c)=@_;
1.24 matthew 42: $r->print('<h2>'.&mt('Option Response Problem Analysis').'</h2>');
1.25 matthew 43: $r->print(&CreateInterface());
1.28 matthew 44: #
45: my @Students = @Apache::lonstatistics::Students;
46: #
1.33 matthew 47: if (exists($ENV{'form.updatecaches'}) ||
48: (exists($ENV{'form.firstanalysis'}) &&
49: $ENV{'form.firstanalysis'} ne 'no')) {
50: &Apache::lonstatistics::Gather_Full_Student_Data($r);
51: }
52: if (! exists($ENV{'form.firstanalysis'})) {
53: $r->print('<input type="hidden" name="firstanalysis" value="yes" />');
54: } else {
55: $r->print('<input type="hidden" name="firstanalysis" value="no" />');
56: }
57: if (exists($ENV{'form.problemchoice'}) &&
58: ! exists($ENV{'form.SelectAnother'})) {
1.31 matthew 59: $r->print('<input type="submit" name="ProblemAnalysis" value="'.
60: &mt('Analyze Problem Again').'" />');
61: $r->print(' 'x5);
62: $r->print('<input type="submit" name="ClearCache" value="'.
63: &mt('Clear Caches').'" />');
64: $r->print(' 'x5);
1.33 matthew 65: $r->print('<input type="submit" name="updatecaches" value="'.
66: &mt('Update Student Data').'" />');
67: $r->print(' 'x5);
1.31 matthew 68: $r->print('<input type="hidden" name="problemchoice" value="'.
69: $ENV{'form.problemchoice'}.'" />');
70: $r->print('<input type="submit" name="SelectAnother" value="'.
71: &mt('Choose a different resource').'" />');
72: $r->print(' 'x5);
73: #
1.25 matthew 74: $r->print('<hr />');
1.23 matthew 75: #
1.25 matthew 76: my ($symb,$part,$resid) = &get_problem_symb(
1.23 matthew 77: &Apache::lonnet::unescape($ENV{'form.problemchoice'})
78: );
1.28 matthew 79: #
1.23 matthew 80: my $resource = &get_resource_from_symb($symb);
81: if (defined($resource)) {
1.25 matthew 82: my %Data = &get_problem_data($resource->{'src'});
83: my $ORdata = $Data{$part.'.'.$resid};
84: ##
1.26 matthew 85: ## Render the problem
1.25 matthew 86: my $base;
87: ($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|);
88: $base = "http://".$ENV{'SERVER_NAME'}.$base;
1.26 matthew 89: my $rendered_problem =
90: &Apache::lonnet::ssi_body($resource->{'src'});
1.30 matthew 91: $rendered_problem =~ s/<\s*form\s*/<nop /g;
92: $rendered_problem =~ s|(<\s*/form\s*>)|<\/nop>|g;
1.26 matthew 93: $r->print('<table bgcolor="ffffff"><tr><td>'.
1.25 matthew 94: '<base href="'.$base.'" />'.
1.26 matthew 95: $rendered_problem.
96: '</td></tr></table>');
1.25 matthew 97: ##
98: ## Analyze the problem
1.26 matthew 99: my $PerformanceData =
100: &Apache::loncoursedata::get_optionresponse_data
1.28 matthew 101: (\@Students,$symb,$resid);
1.26 matthew 102: if (defined($PerformanceData) &&
103: ref($PerformanceData) eq 'ARRAY') {
1.36 matthew 104: if ($ENV{'form.AnalyzeOver'} eq 'Tries') {
1.33 matthew 105: my $analysis_html = &tries_analysis($PerformanceData,
106: $ORdata);
107: $r->print($analysis_html);
1.36 matthew 108: } elsif ($ENV{'form.AnalyzeOver'} eq 'Time') {
1.33 matthew 109: my $analysis_html = &time_analysis($PerformanceData,
1.28 matthew 110: $ORdata);
1.26 matthew 111: $r->print($analysis_html);
1.28 matthew 112: } else {
113: $r->print('<h2>'.
114: &mt('The analysis you have selected is '.
115: 'not supported at this time').
116: '</h2>');
117: }
1.26 matthew 118: } else {
119: $r->print('<h2>'.
120: &mt('There is no student data for this problem.').
121: '</h2>');
122: }
1.23 matthew 123: } else {
124: $r->print('resource is undefined');
1.7 stredwic 125: }
1.23 matthew 126: $r->print('<hr />');
1.25 matthew 127: } else {
1.31 matthew 128: $r->print('<input type="submit" name="ProblemAnalysis" value="'.
129: &mt('Analyze Problem').'" />');
130: $r->print(' 'x5);
1.27 matthew 131: $r->print('<h3>'.&mt('Please select a problem to analyze').'</h3>');
1.31 matthew 132: $r->print(&OptionResponseProblemSelector());
1.1 stredwic 133: }
134: }
135:
1.25 matthew 136:
1.33 matthew 137: #########################################################
138: #########################################################
139: ##
140: ## Misc interface routines use by analysis code
141: ##
142: #########################################################
143: #########################################################
144: sub build_foil_index {
145: my ($ORdata) = @_;
1.36 matthew 146: my %Foildata = %{$ORdata->{'Foils'}};
147: my @Foils = sort(keys(%Foildata));
148: my %Concepts;
1.25 matthew 149: foreach my $foilid (@Foils) {
1.36 matthew 150: push(@{$Concepts{$Foildata{$foilid}->{'Concept'}}},
151: $foilid);
152: }
153: undef(@Foils);
154: # Having gathered the concept information in a hash, we now translate it
155: # into an array because we need to be consistent about order.
156: # Also put the foils in order, too.
157: my $sortfunction = sub {
158: my %Numbers = (one => 1,
159: two => 2,
160: three => 3,
161: four => 4,
162: five => 5,
163: six => 6,
164: seven => 7,
165: eight => 8,
166: nine => 9,
167: ten => 10,);
168: my $a1 = $a;
169: my $b1 = $b;
170: if (exists($Numbers{$a})) {
171: $a1 = $Numbers{$a};
172: }
173: if (exists($Numbers{$b})) {
174: $b1 = $Numbers{$b};
175: }
176: $a1 cmp $b1;
177: };
178: my @Concepts;
179: foreach my $concept (sort $sortfunction (keys(%Concepts))) {
180: push(@Concepts,{name => $concept,
181: foils => [@{$Concepts{$concept}}]});
182: push(@Foils,(@{$Concepts{$concept}}));
1.25 matthew 183: }
1.31 matthew 184: #
185: # Build up the table of row labels.
186: my $table = '<table border="1" >'."\n";
1.36 matthew 187: $table .= '<tr>'.
188: '<th>'.&mt('Concept Number').'</th>'.
189: '<th>'.&mt('Concept').'</th>'.
190: '<th>'.&mt('Foil Number').'</th>'.
191: '<th>'.&mt('Foil Name').'</th>'.
192: '<th>'.&mt('Foil Text').'</th>'.
193: '<th>'.&mt('Correct Value').'</th>'.
194: "</tr>\n";
195: my $conceptindex = 1;
196: my $foilindex = 1;
197: foreach my $concept (@Concepts) {
198: my @FoilsInConcept = @{$concept->{'foils'}};
199: my $firstfoil = shift(@FoilsInConcept);
200: $table .= '<tr>'.
201: '<td>'.$conceptindex.'</td>'.
202: '<td>'.$concept->{'name'}.'</td>'.
203: '<td>'.$foilindex++.'</td>'.
204: '<td>'.$Foildata{$firstfoil}->{'name'}.'</td>'.
205: '<td>'.$Foildata{$firstfoil}->{'text'}.'</td>'.
206: '<td>'.$Foildata{$firstfoil}->{'value'}.'</td>'.
207: "</tr>\n";
208: foreach my $foilid (@FoilsInConcept) {
209: $table .= '<tr>'.
210: '<td></td>'.
211: '<td></td>'.
212: '<td>'.$foilindex.'</td>'.
213: '<td>'.$Foildata{$foilid}->{'name'}.'</td>'.
214: '<td>'.$Foildata{$foilid}->{'text'}.'</td>'.
215: '<td>'.$Foildata{$foilid}->{'value'}.'</td>'.
216: "</tr>\n";
217: } continue {
218: $foilindex++;
219: }
1.31 matthew 220: } continue {
1.36 matthew 221: $conceptindex++;
1.25 matthew 222: }
1.31 matthew 223: $table .= "</table>\n";
1.36 matthew 224: return ($table,\@Foils,\@Concepts);
1.33 matthew 225: }
226:
227: #########################################################
228: #########################################################
229: ##
230: ## Tries Analysis
231: ##
232: #########################################################
233: #########################################################
234: sub tries_analysis {
235: my ($PerformanceData,$ORdata) = @_;
236: my $mintries = 1;
237: my $maxtries = $ENV{'form.NumPlots'};
238: my %ResponseData = &analyze_option_data_by_tries($PerformanceData,
1.36 matthew 239: $mintries,$maxtries);
240: my ($table,$Foils,$Concepts) = &build_foil_index($ORdata);
1.31 matthew 241: #
242: # Compute the data neccessary to make the plots
1.25 matthew 243: my @PlotData;
1.36 matthew 244: my $xlabel;
245: if ($ENV{'form.AnalyzeAs'} eq 'Foils') {
246: $xlabel = 'Foil Number';
247: foreach my $foilid (@$Foils) {
248: for (my $i=$mintries;$i<=$maxtries;$i++) {
249: #
250: # Gather the per-attempt data
251: my $percent;
252: if ($ResponseData{$foilid}->[$i]->{'total'} == 0) {
253: $percent = 0;
254: } else {
255: $percent = $ResponseData{$foilid}->[$i]->{'correct'} /
256: $ResponseData{$foilid}->[$i]->{'total'};
257: }
258: push (@{$PlotData[$i]->{'total'}},
259: $ResponseData{$foilid}->[$i]->{'total'});
260: push (@{$PlotData[$i]->{'good'}},100 * $percent);
261: push (@{$PlotData[$i]->{'bad'}}, 100 *(1-$percent));
262: }
263: }
264: } else {
265: # Concept analysis
266: $xlabel = 'Concept Number';
267: foreach my $concept (@$Concepts) {
268: for (my $i=$mintries;$i<=$maxtries;$i++) {
269: #
270: # Gather the per-attempt data
271: my ($correct,$incorrect,$total);
272: foreach my $foil (@{$concept->{'foils'}}) {
273: $correct += $ResponseData{$foil}->[$i]->{'correct'};
274: $incorrect += $ResponseData{$foil}->[$i]->{'incorrect'};
275: $total += $ResponseData{$foil}->[$i]->{'total'};
276: }
277: push (@{$PlotData[$i]->{'correct'}}, $correct);
278: push (@{$PlotData[$i]->{'incorrect'}},$incorrect);
279: push (@{$PlotData[$i]->{'total'}}, $total);
280: my $percent;
281: if ($total == 0) {
282: $percent = 0;
283: } else {
284: $percent = $correct/$total;
285: }
286: push (@{$PlotData[$i]->{'good'}},100*$percent);
287: push (@{$PlotData[$i]->{'bad'}},100*(1-$percent));
288: }
1.25 matthew 289: }
290: }
1.31 matthew 291: #
292: # Build a table for the plots
293: $table .= "<table>\n";
294: my @Plots;
1.25 matthew 295: for (my $i=$mintries;$i<=$maxtries;$i++) {
1.36 matthew 296: my $minstu = $PlotData[$i]->{'total'}->[0];
297: my $maxstu = $PlotData[$i]->{'total'}->[0];
298: foreach my $count (@{$PlotData[$i]->{'total'}}) {
299: if ($minstu > $count) {
300: $minstu = $count;
1.27 matthew 301: }
1.36 matthew 302: if ($maxstu < $count) {
303: $maxstu = $count;
1.27 matthew 304: }
305: }
1.28 matthew 306: $maxstu = 0 if (! $maxstu);
307: $minstu = 0 if (! $minstu);
1.35 matthew 308: my $title;
1.27 matthew 309: if ($maxstu == $minstu) {
1.35 matthew 310: $title = 'Attempt '.$i.', '.$maxstu.' students';
1.27 matthew 311: } else {
1.35 matthew 312: $title = 'Attempt '.$i.', '.$minstu.'-'.$maxstu.' students';
1.27 matthew 313: }
1.35 matthew 314: my $graphlink = &Apache::loncommon::DrawGraph($title,
1.36 matthew 315: $xlabel,
1.35 matthew 316: 'Percent Correct',
317: 100,
318: $PlotData[$i]->{'good'},
319: $PlotData[$i]->{'bad'});
1.31 matthew 320: push(@Plots,$graphlink);
1.25 matthew 321: }
1.31 matthew 322: #
323: # Should this be something the user can set? Too many dialogs!
324: my $plots_per_row = 2;
325: while (my $plotlink = shift(@Plots)) {
326: $table .= '<tr><td>'.$plotlink.'</td>';
327: for (my $i=1;$i<$plots_per_row;$i++) {
328: if ($plotlink = shift(@Plots)) {
329: $table .= '<td>'.$plotlink.'</td>';
330: } else {
331: $table .= '<td></td>';
332: }
333: }
334: $table .= "</tr>\n";
1.25 matthew 335: }
1.31 matthew 336: $table .= "</table>\n";
1.25 matthew 337: return ($table);
338: }
339:
340: sub analyze_option_data_by_tries {
1.26 matthew 341: my ($PerformanceData,$mintries,$maxtries) = @_;
1.25 matthew 342: my %Trydata;
343: $mintries = 1 if (! defined($mintries) || $mintries < 1);
344: $maxtries = $mintries if (! defined($maxtries) || $maxtries < $mintries);
1.26 matthew 345: foreach my $row (@$PerformanceData) {
346: next if (! defined($row));
1.25 matthew 347: my ($grading,$submission,$time,$tries) = @$row;
348: my @Foilgrades = split('&',$grading);
349: my @Foilsubs = split('&',$submission);
350: for (my $numtries = 1; $numtries <= $maxtries; $numtries++) {
351: if ($tries == $numtries) {
352: foreach my $foilgrade (@Foilgrades) {
353: my ($foilid,$correct) = split('=',$foilgrade);
354: if ($correct) {
355: $Trydata{$foilid}->[$numtries]->{'correct'}++;
356: } else {
357: $Trydata{$foilid}->[$numtries]->{'incorrect'}++;
358: }
359: }
360: }
361: }
362: }
363: foreach my $foilid (keys(%Trydata)) {
364: foreach my $tryhash (@{$Trydata{$foilid}}) {
365: next if ((! exists($tryhash->{'correct'}) &&
366: ! exists($tryhash->{'incorrect'})) ||
367: ($tryhash->{'correct'} < 1 &&
368: $tryhash->{'incorrect'} < 1));
1.27 matthew 369: $tryhash->{'total'} = $tryhash->{'correct'} +
1.36 matthew 370: $tryhash->{'incorrect'};
1.25 matthew 371: }
372: }
373: return %Trydata;
374: }
375:
1.33 matthew 376: #########################################################
377: #########################################################
378: ##
379: ## Time Analysis
380: ##
381: #########################################################
382: #########################################################
383: sub time_analysis {
384: my ($PerformanceData,$ORdata) = @_;
385: my $num_plots = $ENV{'form.NumPlots'};
1.36 matthew 386: my ($table,$Foils,$Concepts) = &build_foil_index($ORdata);
1.33 matthew 387: my $num_data = scalar(@$PerformanceData)-1;
388: my $percent = sprintf('%2f',100/$num_plots);
1.37 ! matthew 389: $table .= "<table>\n";
1.33 matthew 390: for (my $i=0;$i<$num_plots;$i++) {
1.34 matthew 391: my $starttime = &Apache::lonhtmlcommon::get_date_from_form
392: ('startdate_'.$i);
393: my $endtime = &Apache::lonhtmlcommon::get_date_from_form
394: ('enddate_'.$i);
395: my ($begin_index,$end_index,$plottitle,$plothtml,$data);
396: if (! defined($starttime) || ! defined($endtime)) {
397: $begin_index = $i*int($num_data/$num_plots);
398: $end_index = ($i+1)*int($num_data/$num_plots);
399: my $lownum = sprintf('%2.1f',$i*$percent);
400: $lownum =~ s/(\.0)$//;
401: my $highnum = sprintf('%2.1f',($i+1)*$percent);
402: $highnum =~ s/(\.0)$//;
403: $plottitle = $lownum.'% to '.$highnum.'% of submissions';
404: } else {
405: my $j;
406: while (++$j < scalar(@$PerformanceData)) {
407: last if ($PerformanceData->[$j]->[2] > $starttime);
408: }
409: $begin_index = $j;
410: while (++$j < scalar(@$PerformanceData)) {
411: last if ($PerformanceData->[$j]->[2] > $endtime);
412: }
413: $end_index = $j;
1.37 ! matthew 414: $plottitle = $ENV{'form.plottitle_'.$i};
1.34 matthew 415: }
416: ($plothtml,$starttime,$endtime,$data) =
1.33 matthew 417: &analyze_option_data_by_time($PerformanceData,
418: $begin_index,$end_index,
1.34 matthew 419: $plottitle,
1.37 ! matthew 420: @$Concepts);
1.34 matthew 421: my $startdateform = &Apache::lonhtmlcommon::date_setter
422: ('Statistics','startdate_'.$i,$starttime);
423: my $enddateform = &Apache::lonhtmlcommon::date_setter
424: ('Statistics','enddate_'.$i,$endtime);
1.37 ! matthew 425: $table.="<tr><td>".$plothtml.'</td><td align="left" valign="top">'.
! 426: "<b>Start Time</b>: ".$startdateform."<br />".
! 427: "<b>End Time</b> : "." ".$enddateform."<br />".
! 428: '<b>Plot Title</b> :'.
! 429: '<input type="text" size="30" name="plottitle_'.$i.'" value="'.
! 430: &HTML::Entities::encode($plottitle).'" /><br />'.
! 431: "</td></tr>\n";
1.33 matthew 432: }
1.37 ! matthew 433: $table .="</table>\n";
1.33 matthew 434: return $table;
435: }
436:
437: sub analyze_option_data_by_time {
1.37 ! matthew 438: my ($PerformanceData,$begin_index,$end_index,$description,@Concepts) = @_;
1.33 matthew 439: my %TimeData;
440: #
441: # Get the start and end times for this segment of the plot
442: my $starttime = $PerformanceData->[$begin_index]->[2];
443: my $endtime = $PerformanceData->[$end_index ]->[2];
444: #
445: # Compute the number getting the foils correct or incorrects
446: for (my $i=$begin_index;$i<=$end_index;$i++) {
447: my $row = $PerformanceData->[$i];
448: next if (! defined($row));
449: my ($grading,$submission,$time,$tries) = @$row;
450: my @Foilgrades = split('&',$grading);
451: my @Foilsubs = split('&',$submission);
452: foreach my $foilgrade (@Foilgrades) {
453: my ($foilid,$correct) = split('=',$foilgrade);
454: if ($correct) {
455: $TimeData{$foilid}->{'correct'}++;
456: } else {
457: $TimeData{$foilid}->{'incorrect'}++;
458: }
459: }
460: }
461: #
462: # Compute the total and percent correct
463: my @Plotdata1;
464: my @Plotdata2;
1.37 ! matthew 465: foreach my $concept (@Concepts) {
! 466: my ($correct,$incorrect,$total);
! 467: foreach my $foilid (@{$concept->{'foils'}}) {
! 468: if (! exists($TimeData{$foilid}->{'correct'})) {
! 469: $TimeData{$foilid}->{'correct'} = 0;
! 470: }
! 471: if (! exists($TimeData{$foilid}->{'incorrect'})) {
! 472: $incorrect = 0;
! 473: $TimeData{$foilid}->{'incorrect'} = 0;
! 474: }
! 475: $correct += $TimeData{$foilid}->{'correct'};
! 476: $incorrect += $TimeData{$foilid}->{'incorrect'};
! 477: $total += $TimeData{$foilid}->{'correct'}+
! 478: $TimeData{$foilid}->{'incorrect'};
! 479: $TimeData{$foilid}->{'total'} = $TimeData{$foilid}->{'correct'} +
! 480: $TimeData{$foilid}->{'incorrect'};
! 481: my $percent;
! 482: if ($TimeData{$foilid}->{'total'} == 0) {
! 483: $percent = 0;
! 484: } else {
! 485: $percent = $TimeData{$foilid}->{'correct'} /
! 486: $TimeData{$foilid}->{'total'};
! 487: }
! 488: $TimeData{$foilid}->{'percent_corr'} = 100 * $percent;
! 489: if ($ENV{'form.AnalyzeAs'} eq 'Foils') {
! 490: push (@Plotdata1, $TimeData{$foilid}->{'percent_corr'});
! 491: push (@Plotdata2,100-$TimeData{$foilid}->{'percent_corr'});
! 492: }
1.33 matthew 493: }
1.37 ! matthew 494: if ($ENV{'form.AnalyzeAs'} ne 'Foils') {
! 495: if ($total == 0) {
! 496: push (@Plotdata1,0);
! 497: push (@Plotdata2,100);
! 498: } else {
! 499: push (@Plotdata1,100 * $correct / $total);
! 500: push (@Plotdata2,100 * (1-$correct / $total));
! 501: }
1.33 matthew 502: }
503: }
504: #
505: # Create the plot
1.37 ! matthew 506: my $xlabel;
! 507: if ($ENV{'form.AnalyzeAs'} eq 'Foils') {
! 508: $xlabel = 'Foil Number';
! 509: } else {
! 510: $xlabel = 'Concept Number';
! 511: }
1.33 matthew 512: my $graphlink = &Apache::loncommon::DrawGraph
513: ($description,#'Time Interval Analysis',
1.37 ! matthew 514: $xlabel,
1.33 matthew 515: 'Percent Correct / Incorrect',
516: 100,
517: \@Plotdata1,\@Plotdata2);
518: #
519: return ($graphlink,$starttime,$endtime,\%TimeData);
1.1 stredwic 520: }
521:
1.33 matthew 522: #########################################################
523: #########################################################
524: ##
525: ## Interface
526: ##
527: #########################################################
528: #########################################################
1.23 matthew 529: sub CreateInterface {
1.28 matthew 530: ##
531: ## Environment variable initialization
1.36 matthew 532: if (! exists$ENV{'form.AnalyzeOver'}) {
533: $ENV{'form.AnalyzeOver'} = 'Tries';
1.28 matthew 534: }
535: ##
536: ## Build the menu
1.7 stredwic 537: my $Str = '';
1.23 matthew 538: $Str .= '<table cellspacing="5">'."\n";
539: $Str .= '<tr>';
540: $Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>';
541: $Str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>';
1.31 matthew 542: # $Str .= '<td align="center"><b>'.&mt('Sequences and Folders').'</b></td>';
543: $Str .= '<td align="center"> </td>';
1.23 matthew 544: $Str .= '</tr>'."\n";
1.31 matthew 545: ##
546: ##
1.23 matthew 547: $Str .= '<tr><td align="center">'."\n";
548: $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
1.28 matthew 549: $Str .= '</td>';
550: #
551: $Str .= '<td align="center">';
1.23 matthew 552: $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
1.28 matthew 553: $Str .= '</td>';
554: #
1.31 matthew 555: # $Str .= '<td align="center">';
1.23 matthew 556: my $only_seq_with_assessments = sub {
557: my $s=shift;
558: if ($s->{'num_assess'} < 1) {
559: return 0;
560: } else {
561: return 1;
562: }
563: };
1.31 matthew 564: &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
1.23 matthew 565: $only_seq_with_assessments);
1.36 matthew 566: ##
567: ##
1.28 matthew 568: $Str .= '<td>';
1.36 matthew 569: { # These braces are here to organize the code, not scope it.
570: {
571: $Str .= '<nobr>'.&mt('Analyze Over ');
572: $Str .='<select name="AnalyzeOver" >';
573: $Str .= '<option value="Tries" ';
574: if (! exists($ENV{'form.AnalyzeOver'}) ||
575: $ENV{'form.AnalyzeOver'} eq 'Tries'){
576: # Default to Tries
577: $Str .= ' selected ';
578: }
579: $Str .= '>'.&mt('Tries').'</option>';
580: $Str .= '<option value="Time" ';
581: $Str .= ' selected ' if ($ENV{'form.AnalyzeOver'} eq 'Time');
582: $Str .= '>'.&mt('Time').'</option>';
583: $Str .= '</select></nobr><br />';
584: }
585: {
586: $Str .= '<nobr>'.&mt('Analyze as ');
587: $Str .='<select name="AnalyzeAs" >';
588: $Str .= '<option value="Concepts" ';
589: if (! exists($ENV{'form.AnalyzeAs'}) ||
590: $ENV{'form.AnalyzeAs'} eq 'Concepts'){
591: # Default to Concepts
592: $Str .= ' selected ';
593: }
594: $Str .= '>'.&mt('Concepts').'</option>';
595: $Str .= '<option value="Foils" ';
596: $Str .= ' selected ' if ($ENV{'form.AnalyzeAs'} eq 'Foils');
597: $Str .= '>'.&mt('Foils').'</option>';
598: $Str .= '</select></nobr><br />';
599: }
600: {
601: $Str .= '<br /><nobr>'.&mt('Number of Plots:');
602: $Str .= '<select name="NumPlots">';
603: if (! exists($ENV{'form.NumPlots'})
604: || $ENV{'form.NumPlots'} < 1
605: || $ENV{'form.NumPlots'} > 20) {
606: $ENV{'form.NumPlots'} = 5;
607: }
608: foreach my $i (1,2,3,4,5,6,7,8,10,15,20) {
609: $Str .= '<option value="'.$i.'" ';
610: if ($ENV{'form.NumPlots'} == $i) { $Str.=' selected '; }
611: $Str .= '>'.$i.'</option>';
612: }
613: $Str .= '</select></nobr>';
614: }
1.28 matthew 615: }
616: $Str .= '</td>';
1.36 matthew 617: ##
618: ##
1.28 matthew 619: $Str .= '</tr>'."\n";
1.23 matthew 620: $Str .= '</table>'."\n";
621: return ($Str);
622: }
623:
624: sub OptionResponseProblemSelector {
625: my $Str;
626: $Str = "\n<table>\n";
627: foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
628: next if ($seq->{'num_assess'}<1);
629: my $seq_str = '';
630: foreach my $res (@{$seq->{'contents'}}) {
1.26 matthew 631: next if ($res->{'type'} ne 'assessment');
1.23 matthew 632: foreach my $part (@{$res->{'parts'}}) {
633: my $partdata = $res->{'partdata'}->{$part};
634: if (! exists($partdata->{'option'}) ||
635: $partdata->{'option'} == 0) {
636: next;
637: }
638: for (my $i=0;$i<scalar(@{$partdata->{'ResponseTypes'}});$i++){
639: my $respid = $partdata->{'ResponseIds'}->[$i];
640: my $resptype = $partdata->{'ResponseTypes'}->[$i];
641: if ($resptype eq 'option') {
1.25 matthew 642: my $value = &Apache::lonnet::escape($res->{'symb'}.':'.$part.':'.$respid);
1.23 matthew 643: my $checked = '';
644: if ($ENV{'form.problemchoice'} eq $value) {
645: $checked = 'checked ';
646: }
647: $seq_str .= '<tr><td>'.
648: '<input type="radio" name="problemchoice" value="'.$value.'" '.$checked.'/>'.
649: '</td><td>'.
650: '<a href="'.$res->{'src'}.'">'.$res->{'title'}.'</a> ';
651: if ($partdata->{'option'} > 1) {
652: $seq_str .= &mt('response').' '.$respid;
653: }
654: $seq_str .= "</td></tr>\n";
1.11 minaeibi 655: }
656: }
657: }
658: }
1.23 matthew 659: if ($seq_str ne '') {
660: $Str .= '<tr><td> </td><td><b>'.$seq->{'title'}.'</b></td>'.
661: "</tr>\n".$seq_str;
662: }
1.11 minaeibi 663: }
1.23 matthew 664: $Str .= "</table>\n";
665: return $Str;
1.33 matthew 666: }
667:
668: #########################################################
669: #########################################################
670: ##
671: ## Misc functions
672: ##
673: #########################################################
674: #########################################################
675: sub get_problem_symb {
676: my $problemstring = shift();
677: my ($symb,$partid,$resid) = ($problemstring=~ /^(.*):([^:]*):([^:]*)$/);
678: return ($symb,$partid,$resid);
1.11 minaeibi 679: }
680:
1.23 matthew 681: sub get_resource_from_symb {
682: my ($symb) = @_;
683: foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
684: foreach my $res (@{$seq->{'contents'}}) {
685: if ($res->{'symb'} eq $symb) {
686: return $res;
1.2 stredwic 687: }
1.1 stredwic 688: }
689: }
1.23 matthew 690: return undef;
1.1 stredwic 691: }
692:
1.25 matthew 693: sub get_problem_data {
694: my ($url) = @_;
695: my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze'));
1.23 matthew 696: (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2);
1.25 matthew 697: my %Answer;
1.23 matthew 698: %Answer=&Apache::lonnet::str2hash($Answ);
1.25 matthew 699: my %Partdata;
700: foreach my $part (@{$Answer{'parts'}}) {
701: while (my($key,$value) = each(%Answer)) {
702: next if ($key !~ /^$part/);
703: $key =~ s/^$part\.//;
704: if (ref($value) eq 'ARRAY') {
705: if ($key eq 'options') {
706: $Partdata{$part}->{'Options'}=$value;
707: } elsif ($key eq 'concepts') {
708: $Partdata{$part}->{'Concepts'}=$value;
709: } elsif ($key =~ /^concept\.(.*)$/) {
710: my $concept = $1;
711: foreach my $foil (@$value) {
1.36 matthew 712: $Partdata{$part}->{'Foils'}->{$foil}->{'Concept'}=
713: $concept;
1.25 matthew 714: }
715: }
716: } else {
717: $value =~ s/^\s*//g;
718: $value =~ s/\s*$//g;
719: if ($key=~ /^foil\.text\.(.*)$/) {
720: my $foil = $1;
1.36 matthew 721: $Partdata{$part}->{'Foils'}->{$foil}->{'name'}=$foil;
722: $Partdata{$part}->{'Foils'}->{$foil}->{'text'}=$value;
1.25 matthew 723: } elsif ($key =~ /^foil\.value\.(.*)$/) {
724: my $foil = $1;
1.36 matthew 725: $Partdata{$part}->{'Foils'}->{$foil}->{'value'}=$value;
1.25 matthew 726: }
727: }
728: }
1.23 matthew 729: }
1.25 matthew 730: return %Partdata;
1.1 stredwic 731: }
732:
1.23 matthew 733: 1;
1.1 stredwic 734:
735: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>