1: # The LearningOnline Network with CAPA
2: #
3: # $Id: lonproblemstatistics.pm,v 1.42 2003/03/26 15:19:16 matthew Exp $
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:
31: package Apache::lonproblemstatistics;
32:
33: use strict;
34: use Apache::lonnet();
35: use Apache::lonhtmlcommon;
36: use Apache::loncoursedata;
37: use Apache::lonstatistics;
38:
39: #######################################################
40: #######################################################
41:
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
80:
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";
130: }
131: $Str .= "</dl>\n";
132: return $Str;
133: }
134:
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};
146: }
147: }
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: }
168:
169: ###############################################
170: ###############################################
171:
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');
194: }
195: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
196: $r->rflush();
197: }
198:
199: ###############################################
200: ###############################################
201:
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;
216: }
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>");
234: }
235: return;
236: }
237:
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()) {
246: next if ($sequence->{'num_assess'}<1);
247: $r->print("<h3>".$sequence->{'title'}."</h3>");
248: $r->print('<table border="0"><tr><td bgcolor="#777777">'."\n");
249: $r->print('<table border="0" cellpadding="3">'."\n");
250: $r->print('<tr bgcolor="#FFFFE6"><th>'.
251: join("</th><th>",@Header)."</th></tr>\n");
252: foreach my $resource (@{$sequence->{'contents'}}) {
253: next if ($resource->{'type'} ne 'assessment');
254: foreach my $part (@{$resource->{'parts'}}) {
255: if ($part == 0) {
256: $part = ' ';
257: }
258: my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
259: $SKEW) = &Apache::loncoursedata::get_problem_statistics
260: (undef,$resource->{'symb'},$part,
261: $ENV{'request.course.id'});
262: my $wrongpercent = 0;
263: if (defined($num) && $num > 0) {
264: $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
265: }
266: $r->print('<tr>'.&statistics_html_table_data
267: ($resource,$part,$num,$tries,$mod,$mean,$Solved,
268: $solved,$wrongpercent,$DegOfDiff,$STD,$SKEW).
269: "</tr>\n");
270: }
271: }
272: $r->print("</table>\n");
273: $r->print("</td></tr></table>\n");
274: $r->rflush();
275: }
276: #
277: return;
278: }
279:
280:
281: ###############################################
282: ###############################################
283:
284: ###############################################
285: ###############################################
286: sub output_html_ungrouped {
287: my ($r) = @_;
288: #
289: my $show_container = 0;
290: #$r->print(&ProblemStatisticsLegend());
291: my @Header = ("Title","Part","#Stdnts","Tries","Mod",
292: "Mean","#YES","#yes","%Wrng","DoDiff",
293: "S.D.","Skew.");#,"D.F.1st","D.F.2nd");
294: #
295: my $sortby = undef;
296: foreach (@Header) {
297: if ($ENV{'form.sortby'} eq $_) {
298: $sortby = $_;
299: }
300: }
301: if (! defined($sortby) || $sortby eq '') {
302: $sortby = 'Container';
303: }
304: # #FFFFE6 #EEFFCC #DDFFFF FFDDDD #DDFFDD #FFDDFF
305: my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
306: if (@Sequences > 1) {
307: unshift(@Header,"Container");
308: $show_container = 1;
309: }
310: #
311: $r->print('<table border="0"><tr><td bgcolor="#777777">'."\n");
312: $r->print('<table border="0" cellpadding="3">'."\n");
313: my $Str = '';
314: foreach (@Header) {
315: if (/^(Part)$/) { # Do not allow sorting on this field
316: $Str .= '<th>'.$_.'</th>';
317: } else {
318: $Str .= '<th>'.
319: '<a href="javascript:document.Statistics.sortby.value='."'$_'".
320: ';document.Statistics.submit();">'.
321: $_.'</a></th>';
322: }
323: }
324: $r->print('<tr bgcolor="#FFFFE6">'.$Str."</tr>\n");
325: $r->rflush();
326: #
327: # Compile the data
328: my %Statshash;
329: my @Statsarray;
330: foreach my $sequence (@Sequences) {
331: next if ($sequence->{'num_assess'}<1);
332: foreach my $resource (@{$sequence->{'contents'}}) {
333: next if ($resource->{'type'} ne 'assessment');
334: foreach my $part (@{$resource->{'parts'}}) {
335: my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
336: $SKEW) = &Apache::loncoursedata::get_problem_statistics
337: (undef,$resource->{'symb'},$part,
338: $ENV{'request.course.id'});
339: my $wrongpercent = 0;
340: if (defined($num) && $num > 0) {
341: $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
342: }
343: my $key = $resource->{'symb'}.':'.$part;
344: $Statshash{$key} =
345: {
346: 'sequence' => $sequence,
347: 'resource' => $resource,
348: 'Title' => $resource->{'title'},
349: 'Part' => $part,
350: '#Stdnts' => $num,
351: 'Tries' => $tries,
352: 'Mod' => $mod,
353: 'Mean' => $mean,
354: '#YES' => $Solved,
355: '#yes' => $solved,
356: '%Wrng' => $wrongpercent,
357: 'DoDiff' => $DegOfDiff,
358: 'S.D.' => $STD,
359: 'Skew' => $SKEW,
360: };
361: push (@Statsarray,$Statshash{$key});
362: }
363: }
364: }
365: #
366: # Sort the data
367: if ($sortby eq 'Container') {
368: foreach my $sequence (@Sequences) {
369: next if ($sequence->{'num_assess'}<1);
370: foreach my $resource (@{$sequence->{'contents'}}) {
371: next if ($resource->{'type'} ne 'assessment');
372: foreach my $part (@{$resource->{'parts'}}) {
373: my $key = $resource->{'symb'}.':'.$part;
374: $r->print('<tr>');
375: if ($show_container) {
376: $r->print('<td bgcolor="#FFFFE6">'
377: .$sequence->{'title'}.'</td>');
378: }
379: $r->print(&stats_row_from_hash($Statshash{$key}));
380: $r->print("</tr>\n");
381: }
382: }
383: }
384: } else {
385: # $sortby is already defined, so we can charge ahead
386: my @OutputOrder;
387: if ($sortby =~ /^(title|part)$/i) {
388: # Alpha comparison
389: @OutputOrder = sort {
390: $b->{$sortby} cmp $a->{$sortby} ||
391: $b->{'Title'} cmp $a->{'Title'} ||
392: $b->{'Part'} cmp $a->{'Part'};
393: } @Statsarray;
394: } else {
395: # Numerical comparison
396: @OutputOrder = sort {
397: my $retvalue = 0;
398: if ($b->{$sortby} eq 'nan') {
399: if ($a->{$sortby} ne 'nan') {
400: $retvalue = -1;
401: } else {
402: $retvalue = 0;
403: }
404: }
405: if ($a->{$sortby} eq 'nan') {
406: if ($b->{$sortby} ne 'nan') {
407: $retvalue = 1;
408: }
409: }
410: if ($retvalue eq '0') {
411: $retvalue = $b->{$sortby} <=> $a->{$sortby} ||
412: $b->{'Title'} <=> $a->{'Title'} ||
413: $b->{'Part'} <=> $a->{'Part'};
414: }
415: $retvalue;
416: } @Statsarray;
417: }
418: foreach my $row (@OutputOrder) {
419: $r->print('<tr>');
420: if ($show_container) {
421: $r->print('<td bgcolor="#FFFFE6">'
422: .$row->{'sequence'}->{'title'}.'</td>');
423: }
424: $r->print(&stats_row_from_hash($row));
425: $r->print("</tr>\n");
426: }
427: }
428: $r->print("</table>\n");
429: $r->print("</td></tr></table>\n");
430: $r->rflush();
431: #
432: return;
433: }
434:
435: sub stats_row_from_hash {
436: my ($data) = @_;
437: if (ref($data) ne 'HASH') {
438: my %Tmp = @_;
439: $data = \%Tmp;
440: }
441: return &statistics_html_table_data($data->{'resource'},$data->{'Part'},
442: $data->{'#Stdnts'}, $data->{'Tries'},
443: $data->{'Mod'}, $data->{'Mean'},
444: $data->{'#YES'}, $data->{'#yes'},
445: $data->{"\%Wrng"}, $data->{'DoDiff'},
446: $data->{'S.D.'}, $data->{'Skew'});
447: }
448:
449: ###############################################
450: ###############################################
451:
452: ###############################################
453: ###############################################
454: sub statistics_html_table_data {
455: my ($resource,$part,$num,$tries,$mod,$mean,$Solved,$solved,$wrongpercent,
456: $DegOfDiff,$STD,$SKEW) = @_;
457: my $row = '';
458: $row .= '<td bgcolor="#FFFFE6">'.
459: '<a href="'.$resource->{'src'}.'" target="_blank" >'.
460: $resource->{'title'}.'</a>'.
461: '</td>';
462: $row .= '<td bgcolor="#FFFFE6">'.$part.'</td>' if (defined($part));
463: foreach ($num,$tries) {
464: $row .= '<td bgcolor="#EEFFCC" align="right">'.$_.'</td>';
465: }
466: foreach ($mod,$mean) {
467: $row .= '<td bgcolor="#DDFFFF" align="right">'.
468: sprintf("%5.2f",$_).'</td>';
469: }
470: foreach ($Solved,$solved) {
471: $row .= '<td bgcolor="#DDFFFF" align="right">'.$_.'</td>';
472: }
473: foreach ($wrongpercent) {
474: $row .= '<td bgcolor="#DDFFFF" align="right">'.
475: sprintf("%5.1f",$_).'</td>';
476: }
477: foreach ($DegOfDiff,$STD,$SKEW) {
478: $row .= '<td bgcolor="#FFDDDD" align="right">'.
479: sprintf("%5.2f",$_).'</td>';
480: }
481: return $row;
482: }
483:
484:
485: ###############################################
486: ###############################################
487:
488: sub BuildGraphicChart {
489: my ($graph,$cacheDB,$courseDescription,$students,$courseID,$r,$c)=@_;
490: my %cache;
491: my $max;
492: my $title = '';
493: if($graph eq 'DoDiffGraph') {
494: $title = 'Degree-of-Difficulty';
495: } else {
496: $title = 'Wrong-Percentage';
497: }
498: my $currentSequence = -1;
499: my $sortProblems = 'Sort Within Sequence';
500: my ($result, $orderedProblems) =
501: &InitializeProblemStatistics($cacheDB, $students, $courseID, $c, $r);
502: if($result ne 'OK') {
503: return;
504: }
505: my @values = ();
506: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
507: return 'Unable to tie database.7';
508: }
509: foreach(@$orderedProblems) {
510: my ($sequence,$problem,$part)=split(':', $_);
511: if($cache{'StatisticsMaps'} ne 'All Maps' &&
512: $cache{'StatisticsMaps'} ne $cache{$sequence.':title'}) {
513: next;
514: }
515: if( $currentSequence == -1 ||
516: ($sortProblems eq 'Sort Within Sequence' &&
517: $currentSequence != $sequence)) {
518: if($currentSequence != -1) {
519: &DrawGraph(\@values,$courseDescription,$title,$max,$r);
520: }
521: if($sortProblems eq 'Sort Within Sequence') {
522: $r->print('<br><b>'.$cache{$sequence.':title'}.'</b>'."\n");
523: }
524: $currentSequence = $sequence;
525: @values = ();
526: $max=0;
527: }
528: my $data = 0;
529: if($graph eq 'DoDiffGraph') {
530: $data = sprintf("%.2f", $cache{$_.':degreeOfDifficulty'}),
531: } else {
532: $data = sprintf("%.1f", $cache{$_.':percentWrong'}),
533: }
534: if($max < $data) {
535: $max = $data;
536: }
537: push(@values, $data);
538: }
539: untie(%cache);
540: &DrawGraph(\@values,$courseDescription,$title,$max,$r);
541: return;
542: }
543:
544: sub DrawGraph {
545: my ($values,$courseDescription,$title,$Max,$r)=@_;
546: my $sendValues = join(',', @$values);
547: my $sendCount = scalar(@$values);
548: $r->print("<br>The Maximum Value is: $Max");
549: if ( $Max > 1 ) {
550: if ($Max % 10) {
551: if ( int($Max) < $Max ) {
552: $Max++;
553: $Max = int($Max);
554: }
555: }
556: #(10 - $Max % 10);
557: } else { $Max = 1; }
558: my @GData = ('','Problem_number',$title,$Max,$sendCount,$sendValues);
559: # $r->print('</form>'."\n");
560: $r->print('<br>'."\n");
561: $r->print('<IMG src="/cgi-bin/graph.png?'.
562: (join('&', @GData)).'" border="1" />');
563: # $r->print('<form>'."\n");
564: $r->print('<br>'."\n");
565: }
566:
567: #---- Problem Statistics Web Page ---------------------------------------
568: sub CreateProblemStatisticsTableHeading {
569: my ($headings,$r)=@_;
570: my $Str='';
571: $Str .= '<tr>'."\n";
572: $Str .= '<th bgcolor="#ffffe6">P#</th>'."\n";
573: foreach(@$headings) {
574: $Str .= '<th bgcolor="#ffffe6">';
575: $Str .= '<a href="/adm/statistics?reportSelected=';
576: $Str .= &Apache::lonnet::escape('Problem Statistics');
577: $Str .= '&ProblemStatisticsSort=';
578: $Str .= &Apache::lonnet::escape($_).'">'.$_.'</a> </th>'."\n";
579: }
580: $Str .= "\n".'</tr>'."\n";
581: return $Str;
582: }
583:
584: sub BuildStatisticsTable {
585: my ($cache,$displayFormat,$sortProblems,$orderedProblems,$headings,
586: $r,$color)=@_;
587: my $count = 1;
588: my $currentSequence = -1;
589: foreach(@$orderedProblems) {
590: my ($sequence,$problem,$part)=split(':', $_);
591: if($cache->{'StatisticsMaps'} ne 'All Maps' &&
592: $cache->{'StatisticsMaps'} ne $cache->{$sequence.':title'}) {
593: next;
594: }
595: if($currentSequence == -1 ||
596: ($sortProblems eq 'Sort Within Sequence' &&
597: $currentSequence != $sequence)) {
598: if($displayFormat ne 'Display CSV Format') {
599: if($currentSequence ne -1) {
600: $r->print('</table>');
601: $r->print('</td></tr></table><br>');
602: }
603: if($sortProblems eq 'Sort Within Sequence') {
604: $r->print('<b>'.$cache->{$sequence.':title'}.'</b>');
605: }
606: $r->print('<table border="0"><tr><td bgcolor="#777777">'."\n");
607: $r->print('<table border="0" cellpadding="3">'."\n");
608: $r->print(&CreateProblemStatisticsTableHeading($headings, $r));
609: } else {
610: if($sortProblems eq 'Sort Within Sequence') {
611: $r->print('"'.$cache->{$sequence.':title'}.'"');
612: }
613: $r->print('<br>');
614: }
615: $currentSequence = $sequence;
616: }
617: my $ref = '<a href="'.$cache->{$problem.':source'}.
618: '" target="_blank">'.$cache->{$problem.':title'}.'</a>';
619: my $title = $cache->{$problem.':title'};
620: if($part != 0) {
621: $title .= ' Part '.$part;
622: }
623: my $source = $cache->{$problem.':source'};
624: my $tableData = join('&', $ref, $title, $source,
625: $cache->{$_.':studentCount'},
626: $cache->{$_.':totalTries'},
627: $cache->{$_.':maxTries'},
628: $cache->{$_.':mean'},
629: $cache->{$_.':correct'},
630: $cache->{$_.':correctByOverride'},
631: $cache->{$_.':percentWrong'},
632: $cache->{$_.':degreeOfDifficulty'},
633: $cache->{$_.':standardDeviation'},
634: $cache->{$_.':skewness'},
635: $cache->{$_.':discriminationFactor1'},
636: $cache->{$_.':discriminationFactor2'});
637: &TableRow($displayFormat,$tableData,$count,$r,$color);
638: $count++;
639: }
640: if($displayFormat ne 'Display CSV Format') {
641: $r->print('</table>'."\n");
642: $r->print('</td></tr></table>');
643: } else {
644: $r->print('<br>');
645: }
646: return;
647: }
648:
649: sub TableRow {
650: my ($displayFormat,$Str,$RealIdx,$r,$color)=@_;
651: my($ref,$title,$source,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override,
652: $Wrng,$DoD,$SD,$Sk,$_D1,$_D2)=split(/\&/,$Str);
653: my $Ptr;
654: if($displayFormat eq 'Display CSV Format') {
655: $Ptr='"'.$RealIdx.'",'."\n".
656: '"'.$title.'",'."\n".
657: '"'.$source.'",'."\n".
658: '"'.$StdNo.'",'."\n".
659: '"'.$TotalTries.'",'."\n".
660: '"'.$MxTries.'",'."\n".
661: '"'.$Avg.'",'."\n".
662: '"'.$YES.'",'."\n".
663: '"'.$Override.'",'."\n".
664: '"'.$Wrng.'",'."\n".
665: '"'.$DoD.'",'."\n".
666: '"'.$SD.'",'."\n".
667: '"'.$Sk.'",'."\n".
668: '"'.$_D1.'",'."\n".
669: '"'.$_D2.'"'."\n".
670: "<br>\n";
671: $r->print("\n".$Ptr);
672: } else {
673: $Ptr='<tr>'."\n".
674: '<td bgcolor="#ffffe6">'.$RealIdx.'</td>'."\n".
675: '<td bgcolor="#ffffe6">'.$ref.'</td>'."\n".
676: '<td bgcolor='.$color->{"yellow"}.'> '.$StdNo.'</td>'."\n".
677: '<td bgcolor='.$color->{"yellow"}.'>'.$TotalTries.'</td>'."\n".
678: '<td bgcolor='.$color->{"yellow"}.'>'.$MxTries.'</td>'."\n".
679: '<td bgcolor='.$color->{"gb"}.'>'.$Avg.'</td>'."\n".
680: '<td bgcolor='.$color->{"gb"}.'> '.$YES.'</td>'."\n".
681: '<td bgcolor='.$color->{"gb"}.'> '.$Override.'</td>'."\n".
682: '<td bgcolor='.$color->{"red"}.'> '.$Wrng.'</td>'."\n".
683: '<td bgcolor='.$color->{"red"}.'> '.$DoD.'</td>'."\n".
684: '<td bgcolor='.$color->{"green"}.'> '.$SD.'</td>'."\n".
685: '<td bgcolor='.$color->{"green"}.'> '.$Sk.'</td>'."\n".
686: '<td bgcolor='.$color->{"purple"}.'> '.$_D1.'</td>'."\n".
687: '<td bgcolor='.$color->{"purple"}.'> '.$_D2.'</td>'."\n";
688: $r->print($Ptr.'</tr>'."\n");
689: }
690: return;
691: }
692:
693: # For loading the colored table for display or un-colored for print
694: sub setbgcolor {
695: my $PrintTable=shift;
696: my %color;
697: if ($PrintTable){
698: $color{"gb"}="#FFFFFF";
699: $color{"red"}="#FFFFFF";
700: $color{"yellow"}="#FFFFFF";
701: $color{"green"}="#FFFFFF";
702: $color{"purple"}="#FFFFFF";
703: } else {
704: $color{"gb"}="#DDFFFF";
705: $color{"red"}="#FFDDDD";
706: $color{"yellow"}="#EEFFCC";
707: $color{"green"}="#DDFFDD";
708: $color{"purple"}="#FFDDFF";
709: }
710: return \%color;
711: }
712:
713: sub ProblemStatisticsButtons {
714: my ($displayFormat, $displayLegend, $sortProblems)=@_;
715: my $Ptr = '<tr><td></td><td align="left">';
716: $Ptr .= '<input type="submit" name="DoDiffGraph" ';
717: $Ptr .= 'value="Plot Degree of Difficulty" />'."\n";
718: $Ptr .= '</td><td align="left">';
719: $Ptr .= '<input type="submit" name="PercentWrongGraph" ';
720: $Ptr .= 'value="Plot Percent Wrong" />'."\n";
721: $Ptr .= '</td></tr><tr><td></td><td>'."\n";
722: $Ptr .= '<input type="submit" name="SortProblems" ';
723: if($sortProblems eq 'Sort All Problems') {
724: $Ptr .= 'value="Sort Within Sequence" />'."\n";
725: } else {
726: $Ptr .= 'value="Sort All Problems" />'."\n";
727: }
728: $Ptr .= '</td><td align="left">';
729: $Ptr .= '<input type="submit" name="DisplayLegend" ';
730: if($displayLegend eq 'Show Legend') {
731: $Ptr .= 'value="Hide Legend" />'."\n";
732: } else {
733: $Ptr .= 'value="Show Legend" />'."\n";
734: }
735: $Ptr .= '</td><td align="left">';
736: $Ptr .= '<input type="submit" name="DisplayCSVFormat" ';
737: if($displayFormat eq 'Display CSV Format') {
738: $Ptr .= 'value="Display Table Format" />'."\n";
739: } else {
740: $Ptr .= 'value="Display CSV Format" />'."\n";
741: }
742: $Ptr .= '</td></tr>';
743: return $Ptr;
744: }
745:
746: sub ProblemStatisticsLegend {
747: my $Ptr = '';
748: $Ptr = '<table border="0">';
749: $Ptr .= '<tr><td>';
750: $Ptr .= '<b>#Stdnts</b></td>';
751: $Ptr .= '<td>Total number of students attempted the problem.';
752: $Ptr .= '</td></tr><tr><td>';
753: $Ptr .= '<b>Tries</b></td>';
754: $Ptr .= '<td>Total number of tries for solving the problem.';
755: $Ptr .= '</td></tr><tr><td>';
756: $Ptr .= '<b>Mod</b></td>';
757: $Ptr .= '<td>Largest number of tries for solving the problem by a student.';
758: $Ptr .= '</td></tr><tr><td>';
759: $Ptr .= '<b>Mean</b></td>';
760: $Ptr .= '<td>Average number of tries. [ Tries / #Stdnts ]';
761: $Ptr .= '</td></tr><tr><td>';
762: $Ptr .= '<b>#YES</b></td>';
763: $Ptr .= '<td>Number of students solved the problem correctly.';
764: $Ptr .= '</td></tr><tr><td>';
765: $Ptr .= '<b>#yes</b></td>';
766: $Ptr .= '<td>Number of students solved the problem by override.';
767: $Ptr .= '</td></tr><tr><td>';
768: $Ptr .= '<b>%Wrong</b></td>';
769: $Ptr .= '<td>Percentage of students who tried to solve the problem ';
770: $Ptr .= 'but is still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]';
771: $Ptr .= '</td></tr><tr><td>';
772: $Ptr .= '<b>DoDiff</b></td>';
773: $Ptr .= '<td>Degree of Difficulty of the problem. ';
774: $Ptr .= '[ 1 - ((#YES+#yes) / Tries) ]';
775: $Ptr .= '</td></tr><tr><td>';
776: $Ptr .= '<b>S.D.</b></td>';
777: $Ptr .= '<td>Standard Deviation of the tries. ';
778: $Ptr .= '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1) ';
779: $Ptr .= 'where Xi denotes every student\'s tries ]';
780: $Ptr .= '</td></tr><tr><td>';
781: $Ptr .= '<b>Skew.</b></td>';
782: $Ptr .= '<td>Skewness of the students tries.';
783: $Ptr .= '[(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]';
784: $Ptr .= '</td></tr><tr><td>';
785: $Ptr .= '<b>Dis.F.</b></td>';
786: $Ptr .= '<td>Discrimination Factor: A Standard for evaluating the ';
787: $Ptr .= 'problem according to a Criterion<br>';
788: $Ptr .= '<b>[Criterion to group students into %27 Upper Students - ';
789: $Ptr .= 'and %27 Lower Students]</b><br>';
790: $Ptr .= '<b>1st Criterion</b> for Sorting the Students: ';
791: $Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>';
792: $Ptr .= '<b>2nd Criterion</b> for Sorting the Students: ';
793: $Ptr .= '<b>Total number of Correct Answers / Total Number of Tries</b>';
794: $Ptr .= '</td></tr>';
795: $Ptr .= '<tr><td><b>Disc.</b></td>';
796: $Ptr .= '<td>Number of Students had at least one discussion.';
797: $Ptr .= '</td></tr></table>';
798: return $Ptr;
799: }
800:
801: #---- END Problem Statistics Web Page ----------------------------------------
802:
803: 1;
804: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>