Annotation of loncom/interface/statistics/lonproblemstatistics.pm, revision 1.43
1.1 stredwic 1: # The LearningOnline Network with CAPA
2: #
1.43 ! matthew 3: # $Id: lonproblemstatistics.pm,v 1.42 2003/03/26 15:19:16 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: #
29: ###
30:
1.36 minaeibi 31: package Apache::lonproblemstatistics;
1.1 stredwic 32:
33: use strict;
34: use Apache::lonnet();
35: use Apache::lonhtmlcommon;
36: use Apache::loncoursedata;
1.41 matthew 37: use Apache::lonstatistics;
1.1 stredwic 38:
1.41 matthew 39: #######################################################
40: #######################################################
1.1 stredwic 41:
1.41 matthew 42: sub CreateInterface {
43: my $Str = '';
44: $Str .= '<table cellspacing="5">'."\n";
45: $Str .= '<tr>';
46: $Str .= '<td align="center"><b>Sections</b></td>';
47: $Str .= '<td align="center"><b>Sequences and Folders</b></td>';
48: $Str .= '<td align="center"><b>Output</b></td>';
49: $Str .= '</tr>'."\n";
50: #
51: $Str .= '<tr><td align="center">'."\n";
52: $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
53: $Str .= '</td><td align="center">';
54: #
55: my $only_seq_with_assessments = sub {
56: my $s=shift;
57: if ($s->{'num_assess'} < 1) {
58: return 0;
59: } else {
60: return 1;
61: }
62: };
63: $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
64: $only_seq_with_assessments);
65: $Str .= '</td><td>'."\n";
66: $Str .= &CreateAndParseOutputSelector();
67: $Str .= '</td></tr>'."\n";
68: $Str .= '</table>'."\n";
69: return $Str;
70: }
71:
72: #######################################################
73: #######################################################
74:
75: =pod
76:
77: =item &CreateAndParseOutputSelector()
78:
79: =cut
1.16 minaeibi 80:
1.41 matthew 81: #######################################################
82: #######################################################
83: my $output_mode;
84: my $show;
85:
86: my @OutputOptions =
87: (
88: { name => 'problem statistics grouped by sequence',
89: value => 'HTML problem statistics grouped',
90: description => 'Output statistics for the problem parts.',
91: mode => 'html',
92: show => 'grouped',
93: },
94: { name => 'problem statistics ungrouped',
95: value => 'HTML problem statistics ungrouped',
96: description => 'Output statistics for the problem parts.',
97: mode => 'html',
98: show => 'ungrouped',
99: },
100: { name => 'problem statistics, Excel',
101: value => 'Excel problem statistics',
102: description => 'Output statistics for the problem parts '.
103: 'in an Excel workbook',
104: mode => 'excel',
105: show => 'all',
106: },
107: { name => 'Degree of Difficulty Plot',
108: value => 'plot deg diff',
109: description => 'Generate a plot of the degree of difficulty of each '.
110: 'problem part.',
111: mode => 'plot',
112: show => 'deg of diff',
113: },
114: { name => 'Percent Wrong Plot',
115: value => 'plot per wrong',
116: description => 'Generate a plot showing the percent of students who '.
117: 'were unable to complete each problem part',
118: mode => 'plot',
119: show => 'per wrong',
120: },
121: );
122:
123: sub OutputDescriptions {
124: my $Str = '';
125: $Str .= "<h2>Output Modes</h2>\n";
126: $Str .= "<dl>\n";
127: foreach my $outputmode (@OutputOptions) {
128: $Str .=" <dt>".$outputmode->{'name'}."</dt>\n";
129: $Str .=" <dd>".$outputmode->{'description'}."</dd>\n";
1.1 stredwic 130: }
1.41 matthew 131: $Str .= "</dl>\n";
132: return $Str;
133: }
1.1 stredwic 134:
1.41 matthew 135: sub CreateAndParseOutputSelector {
136: my $Str = '';
137: my $elementname = 'outputmode';
138: #
139: # Format for output options is 'mode, restrictions';
140: my $selected = 'html, with links';
141: if (exists($ENV{'form.'.$elementname})) {
142: if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
143: $selected = $ENV{'form.'.$elementname}->[0];
144: } else {
145: $selected = $ENV{'form.'.$elementname};
1.25 stredwic 146: }
147: }
1.41 matthew 148: #
149: # Set package variables describing output mode
150: $output_mode = 'html';
151: $show = 'all';
152: foreach my $option (@OutputOptions) {
153: next if ($option->{'value'} ne $selected);
154: $output_mode = $option->{'mode'};
155: $show = $option->{'show'};
156: }
157: #
158: # Build the form element
159: $Str = qq/<select size="5" name="$elementname">/;
160: foreach my $option (@OutputOptions) {
161: $Str .= "\n".' <option value="'.$option->{'value'}.'"';
162: $Str .= " selected " if ($option->{'value'} eq $selected);
163: $Str .= ">".$option->{'name'}."<\/option>";
164: }
165: $Str .= "\n</select>";
166: return $Str;
167: }
1.25 stredwic 168:
1.41 matthew 169: ###############################################
170: ###############################################
1.28 stredwic 171:
1.41 matthew 172: ###############################################
173: ###############################################
174: sub Gather_Student_Data {
175: my ($r) = @_;
176: my $c = $r->connection();
177: #
178: my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
179: #
180: my @Students = @Apache::lonstatistics::Students;
181: #
182: # Open the progress window
183: my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
184: ($r,'Statistics Compilation Status',
185: 'Statistics Compilation Progress', scalar(@Students));
186: #
187: while (my $student = shift @Students) {
188: return if ($c->aborted());
189: my ($status,undef) = &Apache::loncoursedata::ensure_current_data
190: ($student->{'username'},$student->{'domain'},
191: $ENV{'request.course.id'});
192: &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
193: 'last student');
1.28 stredwic 194: }
1.41 matthew 195: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
196: $r->rflush();
197: }
1.28 stredwic 198:
1.41 matthew 199: ###############################################
200: ###############################################
1.21 stredwic 201:
1.41 matthew 202: ###############################################
203: ###############################################
204: sub BuildProblemStatisticsPage {
205: my ($r,$c)=@_;
206: #
207: $output_mode = 'html';
208: $show = 'grouped';
209: #
210: $r->print(&CreateInterface());
211: $r->print('<input type="hidden" name="statsfirstcall" value="no" />');
212: $r->print('<input type="hidden" name="sortby" value="'.$ENV{'form.sortby'}.
213: '" />');
214: if (! exists($ENV{'form.statsfirstcall'})) {
215: return;
1.28 stredwic 216: }
1.41 matthew 217: #
218: &Gather_Student_Data($r);
219: #
220: #
221: if ($output_mode eq 'html') {
222: $r->print("<h2>".
223: $ENV{'course.'.$ENV{'request.course.id'}.'.description'}.
224: "</h2>\n");
225: $r->print("<h3>".localtime(time)."</h3>");
226: $r->rflush();
227: if ($show eq 'grouped') {
228: &output_html_grouped_by_sequence($r);
229: } elsif ($show eq 'ungrouped') {
230: &output_html_ungrouped($r);
231: }
232: } else {
233: $r->print("<h1>Not implemented</h1>");
1.28 stredwic 234: }
1.41 matthew 235: return;
236: }
1.21 stredwic 237:
1.41 matthew 238: sub output_html_grouped_by_sequence {
239: my ($r) = @_;
240: #$r->print(&ProblemStatisticsLegend());
241: my @Header = ("Title","Part","#Stdnts","Tries","Mod",
242: "Mean","#YES","#yes","%Wrng","DoDiff",
243: "S.D.","Skew.");#,"D.F.1st","D.F.2nd");
244: # #FFFFE6 #EEFFCC #DDFFFF FFDDDD #DDFFDD #FFDDFF
245: foreach my $sequence (&Apache::lonstatistics::Sequences_with_Assess()) {
1.43 ! matthew 246: my $show_part = 0;
1.41 matthew 247: next if ($sequence->{'num_assess'}<1);
248: $r->print("<h3>".$sequence->{'title'}."</h3>");
249: $r->print('<table border="0"><tr><td bgcolor="#777777">'."\n");
250: $r->print('<table border="0" cellpadding="3">'."\n");
251: $r->print('<tr bgcolor="#FFFFE6"><th>'.
252: join("</th><th>",@Header)."</th></tr>\n");
253: foreach my $resource (@{$sequence->{'contents'}}) {
254: next if ($resource->{'type'} ne 'assessment');
255: foreach my $part (@{$resource->{'parts'}}) {
256: my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
257: $SKEW) = &Apache::loncoursedata::get_problem_statistics
258: (undef,$resource->{'symb'},$part,
259: $ENV{'request.course.id'});
1.43 ! matthew 260: #
! 261: $show_part = 1 if ($part ne '0');
! 262: $part = ' ' if ($part == 0);
! 263: #
1.41 matthew 264: my $wrongpercent = 0;
265: if (defined($num) && $num > 0) {
266: $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
267: }
268: $r->print('<tr>'.&statistics_html_table_data
269: ($resource,$part,$num,$tries,$mod,$mean,$Solved,
1.43 ! matthew 270: $solved,$wrongpercent,$DegOfDiff,$STD,$SKEW,
! 271: $show_part).
1.41 matthew 272: "</tr>\n");
273: }
274: }
275: $r->print("</table>\n");
276: $r->print("</td></tr></table>\n");
277: $r->rflush();
1.21 stredwic 278: }
1.41 matthew 279: #
280: return;
281: }
1.25 stredwic 282:
1.28 stredwic 283:
1.41 matthew 284: ###############################################
285: ###############################################
1.26 stredwic 286:
1.41 matthew 287: ###############################################
288: ###############################################
289: sub output_html_ungrouped {
290: my ($r) = @_;
291: #
292: my $show_container = 0;
1.43 ! matthew 293: my $show_part = 0;
1.41 matthew 294: #$r->print(&ProblemStatisticsLegend());
295: my @Header = ("Title","Part","#Stdnts","Tries","Mod",
1.26 stredwic 296: "Mean","#YES","#yes","%Wrng","DoDiff",
1.43 ! matthew 297: "S.D.","Skew");#,"D.F.1st","D.F.2nd");
1.42 matthew 298: #
299: my $sortby = undef;
300: foreach (@Header) {
301: if ($ENV{'form.sortby'} eq $_) {
302: $sortby = $_;
303: }
304: }
305: if (! defined($sortby) || $sortby eq '') {
306: $sortby = 'Container';
307: }
1.41 matthew 308: # #FFFFE6 #EEFFCC #DDFFFF FFDDDD #DDFFDD #FFDDFF
309: my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
310: if (@Sequences > 1) {
311: unshift(@Header,"Container");
312: $show_container = 1;
313: }
314: #
315: $r->print('<table border="0"><tr><td bgcolor="#777777">'."\n");
316: $r->rflush();
317: #
1.42 matthew 318: # Compile the data
319: my @Statsarray;
1.41 matthew 320: foreach my $sequence (@Sequences) {
321: next if ($sequence->{'num_assess'}<1);
322: foreach my $resource (@{$sequence->{'contents'}}) {
323: next if ($resource->{'type'} ne 'assessment');
324: foreach my $part (@{$resource->{'parts'}}) {
325: my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
326: $SKEW) = &Apache::loncoursedata::get_problem_statistics
327: (undef,$resource->{'symb'},$part,
328: $ENV{'request.course.id'});
1.43 ! matthew 329: #
! 330: $show_part = 1 if ($part ne '0');
! 331: $part = ' ' if ($part == 0);
! 332: #
1.41 matthew 333: my $wrongpercent = 0;
334: if (defined($num) && $num > 0) {
335: $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
336: }
1.43 ! matthew 337: push (@Statsarray,
! 338: { 'sequence' => $sequence,
1.42 matthew 339: 'resource' => $resource,
340: 'Title' => $resource->{'title'},
341: 'Part' => $part,
342: '#Stdnts' => $num,
343: 'Tries' => $tries,
344: 'Mod' => $mod,
345: 'Mean' => $mean,
346: '#YES' => $Solved,
347: '#yes' => $solved,
348: '%Wrng' => $wrongpercent,
349: 'DoDiff' => $DegOfDiff,
350: 'S.D.' => $STD,
351: 'Skew' => $SKEW,
1.43 ! matthew 352: });
1.42 matthew 353: }
354: }
355: }
356: #
1.43 ! matthew 357: # Table Headers
! 358: $r->print('<table border="0" cellpadding="3">'."\n");
! 359: my $Str = '';
! 360: foreach (@Header) {
! 361: next if ($_ eq 'Part' && !$show_part);
! 362: # Do not allow sorting on some fields
! 363: if ($_ eq $sortby || /^(Part)$/) {
! 364: $Str .= '<th>'.$_.'</th>';
! 365: } else {
! 366: $Str .= '<th>'.
! 367: '<a href="javascript:document.Statistics.sortby.value='."'$_'".
! 368: ';document.Statistics.submit();">'.
! 369: $_.'</a></th>';
! 370: }
! 371: }
! 372: $r->print('<tr bgcolor="#FFFFE6">'.$Str."</tr>\n");
! 373: #
1.42 matthew 374: # Sort the data
1.43 ! matthew 375: my @OutputOrder;
1.42 matthew 376: if ($sortby eq 'Container') {
1.43 ! matthew 377: @OutputOrder = @Statsarray;
1.42 matthew 378: } else {
379: # $sortby is already defined, so we can charge ahead
380: if ($sortby =~ /^(title|part)$/i) {
381: # Alpha comparison
382: @OutputOrder = sort {
1.43 ! matthew 383: lc($a->{$sortby}) cmp lc($b->{$sortby}) ||
! 384: lc($a->{'Title'}) cmp lc($b->{'Title'}) ||
! 385: lc($a->{'Part'}) cmp lc($b->{'Part'});
1.42 matthew 386: } @Statsarray;
387: } else {
388: # Numerical comparison
389: @OutputOrder = sort {
390: my $retvalue = 0;
391: if ($b->{$sortby} eq 'nan') {
392: if ($a->{$sortby} ne 'nan') {
393: $retvalue = -1;
394: } else {
395: $retvalue = 0;
396: }
397: }
398: if ($a->{$sortby} eq 'nan') {
399: if ($b->{$sortby} ne 'nan') {
400: $retvalue = 1;
401: }
402: }
403: if ($retvalue eq '0') {
404: $retvalue = $b->{$sortby} <=> $a->{$sortby} ||
1.43 ! matthew 405: lc($a->{'Title'}) <=> lc($b->{'Title'}) ||
! 406: lc($a->{'Part'}) <=> lc($b->{'Part'});
1.41 matthew 407: }
1.42 matthew 408: $retvalue;
409: } @Statsarray;
410: }
1.43 ! matthew 411: }
! 412: foreach my $row (@OutputOrder) {
! 413: $r->print('<tr>');
! 414: if ($show_container) {
! 415: $r->print('<td bgcolor="#FFFFE6">'
! 416: .$row->{'sequence'}->{'title'}.'</td>');
1.41 matthew 417: }
1.43 ! matthew 418: $r->print(&stats_row_from_hash($row,$show_part));
! 419: $r->print("</tr>\n");
1.26 stredwic 420: }
1.41 matthew 421: $r->print("</table>\n");
422: $r->print("</td></tr></table>\n");
1.26 stredwic 423: $r->rflush();
1.41 matthew 424: #
425: return;
1.42 matthew 426: }
427:
428: sub stats_row_from_hash {
1.43 ! matthew 429: my ($data,$show_part) = @_;
1.42 matthew 430: return &statistics_html_table_data($data->{'resource'},$data->{'Part'},
431: $data->{'#Stdnts'}, $data->{'Tries'},
432: $data->{'Mod'}, $data->{'Mean'},
433: $data->{'#YES'}, $data->{'#yes'},
434: $data->{"\%Wrng"}, $data->{'DoDiff'},
1.43 ! matthew 435: $data->{'S.D.'}, $data->{'Skew'},
! 436: $show_part);
1.41 matthew 437: }
438:
439: ###############################################
440: ###############################################
1.26 stredwic 441:
1.41 matthew 442: ###############################################
443: ###############################################
444: sub statistics_html_table_data {
445: my ($resource,$part,$num,$tries,$mod,$mean,$Solved,$solved,$wrongpercent,
1.43 ! matthew 446: $DegOfDiff,$STD,$SKEW,$show_part) = @_;
1.41 matthew 447: my $row = '';
448: $row .= '<td bgcolor="#FFFFE6">'.
449: '<a href="'.$resource->{'src'}.'" target="_blank" >'.
450: $resource->{'title'}.'</a>'.
451: '</td>';
1.43 ! matthew 452: $row .= '<td bgcolor="#FFFFE6">'.$part.'</td>' if ($show_part);
1.41 matthew 453: foreach ($num,$tries) {
454: $row .= '<td bgcolor="#EEFFCC" align="right">'.$_.'</td>';
455: }
456: foreach ($mod,$mean) {
457: $row .= '<td bgcolor="#DDFFFF" align="right">'.
458: sprintf("%5.2f",$_).'</td>';
459: }
460: foreach ($Solved,$solved) {
461: $row .= '<td bgcolor="#DDFFFF" align="right">'.$_.'</td>';
462: }
463: foreach ($wrongpercent) {
464: $row .= '<td bgcolor="#DDFFFF" align="right">'.
465: sprintf("%5.1f",$_).'</td>';
466: }
467: foreach ($DegOfDiff,$STD,$SKEW) {
468: $row .= '<td bgcolor="#FFDDDD" align="right">'.
469: sprintf("%5.2f",$_).'</td>';
1.26 stredwic 470: }
1.41 matthew 471: return $row;
472: }
1.26 stredwic 473:
1.12 minaeibi 474:
1.41 matthew 475: ###############################################
476: ###############################################
1.1 stredwic 477:
1.24 stredwic 478: sub BuildGraphicChart {
1.26 stredwic 479: my ($graph,$cacheDB,$courseDescription,$students,$courseID,$r,$c)=@_;
1.24 stredwic 480: my %cache;
1.36 minaeibi 481: my $max;
1.34 minaeibi 482: my $title = '';
483: if($graph eq 'DoDiffGraph') {
484: $title = 'Degree-of-Difficulty';
485: } else {
486: $title = 'Wrong-Percentage';
487: }
488: my $currentSequence = -1;
489: my $sortProblems = 'Sort Within Sequence';
490: my ($result, $orderedProblems) =
1.26 stredwic 491: &InitializeProblemStatistics($cacheDB, $students, $courseID, $c, $r);
492: if($result ne 'OK') {
493: return;
494: }
1.24 stredwic 495: my @values = ();
1.38 albertel 496: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
497: return 'Unable to tie database.7';
498: }
1.34 minaeibi 499: foreach(@$orderedProblems) {
500: my ($sequence,$problem,$part)=split(':', $_);
501: if($cache{'StatisticsMaps'} ne 'All Maps' &&
502: $cache{'StatisticsMaps'} ne $cache{$sequence.':title'}) {
1.35 minaeibi 503: next;
1.34 minaeibi 504: }
1.35 minaeibi 505: if( $currentSequence == -1 ||
506: ($sortProblems eq 'Sort Within Sequence' &&
1.34 minaeibi 507: $currentSequence != $sequence)) {
1.35 minaeibi 508: if($currentSequence != -1) {
509: &DrawGraph(\@values,$courseDescription,$title,$max,$r);
510: }
1.34 minaeibi 511: if($sortProblems eq 'Sort Within Sequence') {
1.36 minaeibi 512: $r->print('<br><b>'.$cache{$sequence.':title'}.'</b>'."\n");
1.34 minaeibi 513: }
514: $currentSequence = $sequence;
515: @values = ();
1.36 minaeibi 516: $max=0;
1.34 minaeibi 517: }
1.24 stredwic 518: my $data = 0;
519: if($graph eq 'DoDiffGraph') {
520: $data = sprintf("%.2f", $cache{$_.':degreeOfDifficulty'}),
521: } else {
522: $data = sprintf("%.1f", $cache{$_.':percentWrong'}),
523: }
524: if($max < $data) {
525: $max = $data;
526: }
527: push(@values, $data);
528: }
1.35 minaeibi 529: untie(%cache);
530: &DrawGraph(\@values,$courseDescription,$title,$max,$r);
1.24 stredwic 531: return;
532: }
1.1 stredwic 533:
1.35 minaeibi 534: sub DrawGraph {
535: my ($values,$courseDescription,$title,$Max,$r)=@_;
536: my $sendValues = join(',', @$values);
537: my $sendCount = scalar(@$values);
1.36 minaeibi 538: $r->print("<br>The Maximum Value is: $Max");
1.35 minaeibi 539: if ( $Max > 1 ) {
540: if ($Max % 10) {
1.36 minaeibi 541: if ( int($Max) < $Max ) {
542: $Max++;
543: $Max = int($Max);
544: }
1.35 minaeibi 545: }
1.36 minaeibi 546: #(10 - $Max % 10);
1.35 minaeibi 547: } else { $Max = 1; }
1.36 minaeibi 548: my @GData = ('','Problem_number',$title,$Max,$sendCount,$sendValues);
549: # $r->print('</form>'."\n");
550: $r->print('<br>'."\n");
1.39 albertel 551: $r->print('<IMG src="/cgi-bin/graph.png?'.
1.35 minaeibi 552: (join('&', @GData)).'" border="1" />');
1.36 minaeibi 553: # $r->print('<form>'."\n");
554: $r->print('<br>'."\n");
1.35 minaeibi 555: }
556:
1.1 stredwic 557: #---- Problem Statistics Web Page ---------------------------------------
558: sub CreateProblemStatisticsTableHeading {
1.19 stredwic 559: my ($headings,$r)=@_;
560: my $Str='';
561: $Str .= '<tr>'."\n";
562: $Str .= '<th bgcolor="#ffffe6">P#</th>'."\n";
563: foreach(@$headings) {
1.27 stredwic 564: $Str .= '<th bgcolor="#ffffe6">';
565: $Str .= '<a href="/adm/statistics?reportSelected=';
1.19 stredwic 566: $Str .= &Apache::lonnet::escape('Problem Statistics');
567: $Str .= '&ProblemStatisticsSort=';
568: $Str .= &Apache::lonnet::escape($_).'">'.$_.'</a> </th>'."\n";
1.1 stredwic 569: }
1.34 minaeibi 570: $Str .= "\n".'</tr>'."\n";
1.19 stredwic 571: return $Str;
1.1 stredwic 572: }
1.12 minaeibi 573:
1.1 stredwic 574: sub BuildStatisticsTable {
1.26 stredwic 575: my ($cache,$displayFormat,$sortProblems,$orderedProblems,$headings,
576: $r,$color)=@_;
1.19 stredwic 577: my $count = 1;
1.26 stredwic 578: my $currentSequence = -1;
1.21 stredwic 579: foreach(@$orderedProblems) {
1.36 minaeibi 580: my ($sequence,$problem,$part)=split(':', $_);
1.25 stredwic 581: if($cache->{'StatisticsMaps'} ne 'All Maps' &&
582: $cache->{'StatisticsMaps'} ne $cache->{$sequence.':title'}) {
1.23 stredwic 583: next;
584: }
1.34 minaeibi 585: if($currentSequence == -1 ||
586: ($sortProblems eq 'Sort Within Sequence' &&
1.26 stredwic 587: $currentSequence != $sequence)) {
588: if($displayFormat ne 'Display CSV Format') {
589: if($currentSequence ne -1) {
590: $r->print('</table>');
591: $r->print('</td></tr></table><br>');
592: }
593: if($sortProblems eq 'Sort Within Sequence') {
594: $r->print('<b>'.$cache->{$sequence.':title'}.'</b>');
595: }
596: $r->print('<table border="0"><tr><td bgcolor="#777777">'."\n");
597: $r->print('<table border="0" cellpadding="3">'."\n");
598: $r->print(&CreateProblemStatisticsTableHeading($headings, $r));
599: } else {
600: if($sortProblems eq 'Sort Within Sequence') {
601: $r->print('"'.$cache->{$sequence.':title'}.'"');
602: }
603: $r->print('<br>');
604: }
605: $currentSequence = $sequence;
606: }
1.21 stredwic 607: my $ref = '<a href="'.$cache->{$problem.':source'}.
608: '" target="_blank">'.$cache->{$problem.':title'}.'</a>';
1.19 stredwic 609: my $title = $cache->{$problem.':title'};
1.27 stredwic 610: if($part != 0) {
611: $title .= ' Part '.$part;
612: }
1.26 stredwic 613: my $source = $cache->{$problem.':source'};
1.19 stredwic 614: my $tableData = join('&', $ref, $title, $source,
1.21 stredwic 615: $cache->{$_.':studentCount'},
616: $cache->{$_.':totalTries'},
617: $cache->{$_.':maxTries'},
1.27 stredwic 618: $cache->{$_.':mean'},
1.21 stredwic 619: $cache->{$_.':correct'},
620: $cache->{$_.':correctByOverride'},
1.27 stredwic 621: $cache->{$_.':percentWrong'},
622: $cache->{$_.':degreeOfDifficulty'},
623: $cache->{$_.':standardDeviation'},
624: $cache->{$_.':skewness'},
625: $cache->{$_.':discriminationFactor1'},
626: $cache->{$_.':discriminationFactor2'});
1.19 stredwic 627: &TableRow($displayFormat,$tableData,$count,$r,$color);
628: $count++;
629: }
1.26 stredwic 630: if($displayFormat ne 'Display CSV Format') {
1.19 stredwic 631: $r->print('</table>'."\n");
1.26 stredwic 632: $r->print('</td></tr></table>');
633: } else {
634: $r->print('<br>');
1.1 stredwic 635: }
1.21 stredwic 636: return;
1.1 stredwic 637: }
638:
639: sub TableRow {
1.19 stredwic 640: my ($displayFormat,$Str,$RealIdx,$r,$color)=@_;
641: my($ref,$title,$source,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override,
1.27 stredwic 642: $Wrng,$DoD,$SD,$Sk,$_D1,$_D2)=split(/\&/,$Str);
1.8 minaeibi 643: my $Ptr;
1.19 stredwic 644: if($displayFormat eq 'Display CSV Format') {
1.26 stredwic 645: $Ptr='"'.$RealIdx.'",'."\n".
646: '"'.$title.'",'."\n".
647: '"'.$source.'",'."\n".
648: '"'.$StdNo.'",'."\n".
649: '"'.$TotalTries.'",'."\n".
650: '"'.$MxTries.'",'."\n".
651: '"'.$Avg.'",'."\n".
652: '"'.$YES.'",'."\n".
653: '"'.$Override.'",'."\n".
654: '"'.$Wrng.'",'."\n".
655: '"'.$DoD.'",'."\n".
656: '"'.$SD.'",'."\n".
657: '"'.$Sk.'",'."\n".
658: '"'.$_D1.'",'."\n".
659: '"'.$_D2.'"'."\n".
660: "<br>\n";
1.1 stredwic 661: $r->print("\n".$Ptr);
1.8 minaeibi 662: } else {
1.26 stredwic 663: $Ptr='<tr>'."\n".
664: '<td bgcolor="#ffffe6">'.$RealIdx.'</td>'."\n".
665: '<td bgcolor="#ffffe6">'.$ref.'</td>'."\n".
666: '<td bgcolor='.$color->{"yellow"}.'> '.$StdNo.'</td>'."\n".
667: '<td bgcolor='.$color->{"yellow"}.'>'.$TotalTries.'</td>'."\n".
668: '<td bgcolor='.$color->{"yellow"}.'>'.$MxTries.'</td>'."\n".
669: '<td bgcolor='.$color->{"gb"}.'>'.$Avg.'</td>'."\n".
670: '<td bgcolor='.$color->{"gb"}.'> '.$YES.'</td>'."\n".
671: '<td bgcolor='.$color->{"gb"}.'> '.$Override.'</td>'."\n".
672: '<td bgcolor='.$color->{"red"}.'> '.$Wrng.'</td>'."\n".
673: '<td bgcolor='.$color->{"red"}.'> '.$DoD.'</td>'."\n".
674: '<td bgcolor='.$color->{"green"}.'> '.$SD.'</td>'."\n".
675: '<td bgcolor='.$color->{"green"}.'> '.$Sk.'</td>'."\n".
676: '<td bgcolor='.$color->{"purple"}.'> '.$_D1.'</td>'."\n".
1.27 stredwic 677: '<td bgcolor='.$color->{"purple"}.'> '.$_D2.'</td>'."\n";
1.26 stredwic 678: $r->print($Ptr.'</tr>'."\n");
1.1 stredwic 679: }
1.19 stredwic 680: return;
1.1 stredwic 681: }
1.5 minaeibi 682:
683: # For loading the colored table for display or un-colored for print
684: sub setbgcolor {
685: my $PrintTable=shift;
686: my %color;
687: if ($PrintTable){
688: $color{"gb"}="#FFFFFF";
689: $color{"red"}="#FFFFFF";
690: $color{"yellow"}="#FFFFFF";
691: $color{"green"}="#FFFFFF";
692: $color{"purple"}="#FFFFFF";
693: } else {
694: $color{"gb"}="#DDFFFF";
695: $color{"red"}="#FFDDDD";
696: $color{"yellow"}="#EEFFCC";
697: $color{"green"}="#DDFFDD";
698: $color{"purple"}="#FFDDFF";
699: }
700: return \%color;
701: }
702:
1.1 stredwic 703: sub ProblemStatisticsButtons {
1.26 stredwic 704: my ($displayFormat, $displayLegend, $sortProblems)=@_;
1.1 stredwic 705: my $Ptr = '<tr><td></td><td align="left">';
706: $Ptr .= '<input type="submit" name="DoDiffGraph" ';
1.33 minaeibi 707: $Ptr .= 'value="Plot Degree of Difficulty" />'."\n";
1.27 stredwic 708: $Ptr .= '</td><td align="left">';
1.1 stredwic 709: $Ptr .= '<input type="submit" name="PercentWrongGraph" ';
1.33 minaeibi 710: $Ptr .= 'value="Plot Percent Wrong" />'."\n";
1.20 stredwic 711: $Ptr .= '</td></tr><tr><td></td><td>'."\n";
1.26 stredwic 712: $Ptr .= '<input type="submit" name="SortProblems" ';
713: if($sortProblems eq 'Sort All Problems') {
714: $Ptr .= 'value="Sort Within Sequence" />'."\n";
715: } else {
716: $Ptr .= 'value="Sort All Problems" />'."\n";
717: }
1.27 stredwic 718: $Ptr .= '</td><td align="left">';
1.20 stredwic 719: $Ptr .= '<input type="submit" name="DisplayLegend" ';
720: if($displayLegend eq 'Show Legend') {
721: $Ptr .= 'value="Hide Legend" />'."\n";
722: } else {
723: $Ptr .= 'value="Show Legend" />'."\n";
724: }
1.27 stredwic 725: $Ptr .= '</td><td align="left">';
1.1 stredwic 726: $Ptr .= '<input type="submit" name="DisplayCSVFormat" ';
727: if($displayFormat eq 'Display CSV Format') {
1.9 stredwic 728: $Ptr .= 'value="Display Table Format" />'."\n";
729: } else {
1.1 stredwic 730: $Ptr .= 'value="Display CSV Format" />'."\n";
731: }
732: $Ptr .= '</td></tr>';
733: return $Ptr;
734: }
735:
736: sub ProblemStatisticsLegend {
737: my $Ptr = '';
738: $Ptr = '<table border="0">';
739: $Ptr .= '<tr><td>';
1.6 minaeibi 740: $Ptr .= '<b>#Stdnts</b></td>';
1.19 stredwic 741: $Ptr .= '<td>Total number of students attempted the problem.';
1.1 stredwic 742: $Ptr .= '</td></tr><tr><td>';
1.6 minaeibi 743: $Ptr .= '<b>Tries</b></td>';
1.19 stredwic 744: $Ptr .= '<td>Total number of tries for solving the problem.';
1.1 stredwic 745: $Ptr .= '</td></tr><tr><td>';
1.6 minaeibi 746: $Ptr .= '<b>Mod</b></td>';
1.19 stredwic 747: $Ptr .= '<td>Largest number of tries for solving the problem by a student.';
1.1 stredwic 748: $Ptr .= '</td></tr><tr><td>';
1.6 minaeibi 749: $Ptr .= '<b>Mean</b></td>';
1.19 stredwic 750: $Ptr .= '<td>Average number of tries. [ Tries / #Stdnts ]';
1.1 stredwic 751: $Ptr .= '</td></tr><tr><td>';
1.6 minaeibi 752: $Ptr .= '<b>#YES</b></td>';
1.1 stredwic 753: $Ptr .= '<td>Number of students solved the problem correctly.';
754: $Ptr .= '</td></tr><tr><td>';
1.6 minaeibi 755: $Ptr .= '<b>#yes</b></td>';
1.1 stredwic 756: $Ptr .= '<td>Number of students solved the problem by override.';
757: $Ptr .= '</td></tr><tr><td>';
1.19 stredwic 758: $Ptr .= '<b>%Wrong</b></td>';
759: $Ptr .= '<td>Percentage of students who tried to solve the problem ';
760: $Ptr .= 'but is still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]';
1.1 stredwic 761: $Ptr .= '</td></tr><tr><td>';
1.6 minaeibi 762: $Ptr .= '<b>DoDiff</b></td>';
1.1 stredwic 763: $Ptr .= '<td>Degree of Difficulty of the problem. ';
764: $Ptr .= '[ 1 - ((#YES+#yes) / Tries) ]';
765: $Ptr .= '</td></tr><tr><td>';
1.6 minaeibi 766: $Ptr .= '<b>S.D.</b></td>';
1.1 stredwic 767: $Ptr .= '<td>Standard Deviation of the tries. ';
768: $Ptr .= '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1) ';
769: $Ptr .= 'where Xi denotes every student\'s tries ]';
770: $Ptr .= '</td></tr><tr><td>';
1.6 minaeibi 771: $Ptr .= '<b>Skew.</b></td>';
1.1 stredwic 772: $Ptr .= '<td>Skewness of the students tries.';
773: $Ptr .= '[(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]';
774: $Ptr .= '</td></tr><tr><td>';
1.6 minaeibi 775: $Ptr .= '<b>Dis.F.</b></td>';
1.1 stredwic 776: $Ptr .= '<td>Discrimination Factor: A Standard for evaluating the ';
777: $Ptr .= 'problem according to a Criterion<br>';
1.31 stredwic 778: $Ptr .= '<b>[Criterion to group students into %27 Upper Students - ';
779: $Ptr .= 'and %27 Lower Students]</b><br>';
1.1 stredwic 780: $Ptr .= '<b>1st Criterion</b> for Sorting the Students: ';
781: $Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>';
782: $Ptr .= '<b>2nd Criterion</b> for Sorting the Students: ';
783: $Ptr .= '<b>Total number of Correct Answers / Total Number of Tries</b>';
784: $Ptr .= '</td></tr>';
785: $Ptr .= '<tr><td><b>Disc.</b></td>';
786: $Ptr .= '<td>Number of Students had at least one discussion.';
787: $Ptr .= '</td></tr></table>';
788: return $Ptr;
789: }
1.24 stredwic 790:
791: #---- END Problem Statistics Web Page ----------------------------------------
1.4 minaeibi 792:
1.1 stredwic 793: 1;
794: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>