Annotation of loncom/interface/statistics/lonproblemstatistics.pm, revision 1.4
1.1 stredwic 1: # The LearningOnline Network with CAPA
2: # (Publication Handler
3: #
1.4 ! minaeibi 4: # $Id: lonproblemstatistics.pm,v 1.3 2002/07/26 21:50:12 minaeibi 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: # (Navigate problems for statistical reports
29: # YEAR=2001
30: # 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei
31: # 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei
32: # YEAR=2002
33: # 1/22,2/1,2/6,2/25,3/2,3/6,3/17,3/21,3/22,3/26,4/7,5/6 Behrouz Minaei
1.2 minaeibi 34: # 5/12,5/14,5/15,5/19,5/26,7/16,7/25 Behrouz Minaei
1.1 stredwic 35: #
36: ###
37:
38: package Apache::lonproblemstatistics;
39:
40: use strict;
41: use Apache::lonnet();
42: use Apache::lonhtmlcommon;
43: use Apache::loncoursedata;
44: use GDBM_File;
45:
46:
47: sub BuildProblemStatisticsPage {
1.2 minaeibi 48: my ($cacheDB, $students, $courseID, $c, $r,%color)=@_;
1.1 stredwic 49: my %cache;
1.2 minaeibi 50: #my %DoDiff;
1.1 stredwic 51: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
52: return '<html><body>Unable to tie database.</body></html>';
53: }
54:
55: my $Ptr = '';
56: $Ptr .= '<table border="0"><tbody>';
57: $Ptr .= '<tr><td align="right"><b>Select Map</b></td>'."\n";
58: $Ptr .= '<td align="left">';
59: $Ptr .= &Apache::lonhtmlcommon::MapOptions(\%cache, 'ProblemStatistics');
60: $Ptr .= '</td></tr>'."\n";
61: $Ptr .= &AscendOrderOptions($cache{'Ascend'});
62: $Ptr .= &ProblemStatisticsButtons($cache{'DisplayFormat'});
1.2 minaeibi 63: $Ptr .= '</table>';
1.1 stredwic 64:
65: $Ptr .= &ProblemStatisticsLegend();
66:
67: untie(%cache);
68: foreach (@$students) {
69: my $courseData =
70: &Apache::loncoursedata::DownloadCourseInformation($_, $courseID);
71: last if ($c->aborted());
72: if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {
73: &Apache::loncoursedata::ProcessStudentData(\%cache,
74: $courseData, $_);
75: untie(%cache);
76: }
77: }
78: if($c->aborted()) { return $Ptr; }
79:
80: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
81: return '<html><body>Unable to tie database.</body></html>';
82: }
83: my $discriminantFactor;
84: my @list=();
1.2 minaeibi 85: my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID);
86: my $index=0;
1.1 stredwic 87: foreach (@$students) {
1.3 minaeibi 88: $index++;
1.2 minaeibi 89: #&Apache::lonstatistics::Update_PrgWin(++$index,$r);
1.3 minaeibi 90: $discriminantFactor = &ExtractStudentData(\%cache, $_, \@list,
91: \%Discuss, $r);
1.1 stredwic 92: }
1.2 minaeibi 93: #&Apache::lonstatistics::Close_PrgWin($r);
94:
1.1 stredwic 95: my ($upper, $lower) = &Discriminant($discriminantFactor);
96: my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod",
97: 4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff",
98: 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd", 13, "Disc.");
1.2 minaeibi 99:
100: my %GraphDat= &BuildStatisticsTable(\%cache, $discriminantFactor, \@list,
101: \%Header, $students, $r, \%color);
1.1 stredwic 102:
103: untie(%cache);
104:
105: return $Ptr;
106: }
107:
108:
109: #---- Problem Statistics Web Page ---------------------------------------
110:
111:
112: sub NumericSort {
113: $a <=> $b;
114: }
115:
116:
117: sub CreateProblemStatisticsTableHeading {
1.2 minaeibi 118: my ($displayFormat,$sequenceSource,$sequenceTitle,$headings,$r)=@_;
1.1 stredwic 119: if($displayFormat eq 'Display CSV Format') {
120: $r->print('<br>"'.$sequenceTitle.'","');
121: $r->print($sequenceSource.'"');
122: return;
123: }
124:
125: $r->print('<br><a href="'.$sequenceSource.
126: '" target="_blank">'.$sequenceTitle.'</a>');
127:
128: my $Result = "\n".'<table border=2><tr><th>P#</th>'."\n";
129: for(my $nIndex=0; $nIndex < (scalar (keys %$headings)); $nIndex++) {
130: $Result .= '<th>'.'<input type="submit" name="';
131: $Result .= 'ProblemStatisticsHeading" value="';
132: $Result .= $headings->{$nIndex}.'" />'.'</th>'."\n";
133: }
134: $Result .= "\n".'</tr>'."\n";
135: $r->print($Result);
136: $r->rflush();
137: }
138:
139: sub CloseTable {
1.2 minaeibi 140: my ($cache,$r)=@_;
1.1 stredwic 141: if($cache->{'DisplayFormat'} eq 'Display CSV Format') {
142: return;
143: }
144: $r->print("\n".'</table>'."\n");
145: $r->rflush();
146: }
147:
148:
149:
150: # ------ Dump the Student's DB file and handling the data for statistics table
151: sub ExtractStudentData {
1.3 minaeibi 152: my ($cache,$name,$list,$Discuss,$r)=@_;
1.1 stredwic 153: my %discriminantFactor;
154:
155: my $totalTries = 0;
156: my $totalAwarded = 0;
157: my $tempProblemOrder=0;
158: my $spent=0;
159: my $spent_yes=0;
160: my $TotDiscuss=0;
161: my $TotalOpend = 0;
162: my $ProbSolved = 0;
163: my $ProbTot = 0;
164: my $TotFirst = 0;
165: my $TimeTot = 0;
166: my $Discussed=0;
167:
1.3 minaeibi 168: $Apache::lonxml::debug=1;
169: #&Apache::lonhomework::showhash(%$cache);
170: $Apache::lonxml::debug=0;
171:
1.1 stredwic 172: foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
1.3 minaeibi 173: # if($cache->{'ProblemStatisticsMap'} ne 'All Maps' &&
174: # $cache->{'ProblemStatisticsMap'} ne $cache->{$sequence.':title'}) {
1.4 ! minaeibi 175: # $r->print("<br>$name --- $sequence");
! 176: # $r->print("<br>".$cache->{$sequence.':title'});
1.3 minaeibi 177: # next;
178: # }
1.1 stredwic 179:
180: my $Dis = '';
181: foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
182: my $problem = $cache->{$problemID.':problem'};
1.3 minaeibi 183: $r->print("<br>$problemID === $problem");
1.1 stredwic 184: my $LatestVersion = $cache->{$name.':version:'.$problem};
1.3 minaeibi 185: # Output dashes for all the parts of this problem if there
1.1 stredwic 186: # is no version information about the current problem.
187: #if(!$LatestVersion) {
188: # foreach my $part (split(/\:/,$cache->{$sequence.':'.
189: # $problemID.
190: # ':parts'})) {
191: # $codes .= "-,";
192: # $attempts .= "0,";
193: # }
194: # next;
195: #}
196:
197: my %partData=undef;
198: # Initialize part data, display skips correctly
199: # Skip refers to when a student made no submissions on that
200: # part/problem.
201: foreach my $part (split(/\:/,$cache->{$sequence.':'.
202: $problemID.
203: ':parts'})) {
204: $partData{$part.':tries'}=0;
205: $partData{$part.':code'}='-';
206: }
207:
208: # Looping through all the versions of each part, starting with the
209: # oldest version. Basically, it gets the most recent
210: # set of grade data for each part.
211: for(my $Version=1; $Version<=$LatestVersion; $Version++) {
1.3 minaeibi 212: foreach my $part (split(/\:/,$cache->{$sequence.':'.
1.1 stredwic 213: $problemID.
214: ':parts'})) {
215:
216: if(!defined($cache->{$name.":$Version:$problem".
217: ":resource.$part.solved"})) {
218: # No grade for this submission, so skip
219: next;
220: }
221:
222: my $tries=0;
223: my $time=0;
224: my $awarded=0;
225: $Discussed=0;
226: my $code='U';
227:
228: $awarded = $cache->{$name.
229: "$Version:$problem:resource.".
230: "$part.awarded"};
231: $partData{$part.':awarded'} = ($awarded) ? $awarded : 0;
232: $totalAwarded += $awarded;
233:
234: $tries = $cache->{$name.":$Version:$problem".
235: ":resource.$part.tries"};
236: $partData{$part.':tries'} = ($tries) ? $tries : 0;
237: $partData{$part.':wrong'} = $partData{$part.':tries'};
238: $totalTries += $tries;
239:
240: my $val = $cache->{$name.":$Version:$problem".
241: ":resource.$part.solved"};
242: if ($val eq 'correct_by_student') {$code = 'C';}
243: elsif ($val eq 'correct_by_override') {$code = 'O';}
244: elsif ($val eq 'incorrect_attempted') {$code = 'I';}
245: elsif ($val eq 'incorrect_by_override'){$code = 'I';}
246: elsif ($val eq 'excused') {$code = 'x';}
247: $partData{$part.':code'}=$code;
248: if($partData{$part.':wrong'} ne 0 &&
249: ($code eq 'C' || $code eq 'O')) {
250: $partData{$part.':wrong'}--;
251: }
252: }
253: }
254:
255: # Loop through all the parts for the current problem in the
256: # correct order and prepare the output
257: foreach (split(/\:/,$cache->{$sequence.':'.$problemID.
258: ':parts'})) {
1.4 ! minaeibi 259: #$r->print("<br>".$cache->{$sequence.':title'});
! 260:
1.1 stredwic 261: my $Yes = 0;
262: if($partData{$_.':code'} eq 'C' ||
263: $partData{$_.':code'} eq 'O') {
264: $Yes=1;
265: }
266: my $ptr = $tempProblemOrder.'&'.$problemID;
267:
268: if($_ > 1) {
269: $ptr .= "*(part $_)";
270: $Dis .= '&';
271: }
272:
273: my ($pr_no,$dod)=split('&',$ptr);
274: # my $DoDiff=$DoDiff->{$dod};
275: # $r->print('<br>'.$name.'---'.$ptr.'==='.$DoDiff);
276:
277: my $Fac = ($partData{$_.':Tries'}) ?
278: ($partData{$_.':awarded'}/$partData{$_.':tries'}) : 0;
279: my $DisF;
280: if($Fac > 0 && $Fac < 1) {
281: $DisF = sprintf( "%.4f", $Fac );
282: } else {
283: $DisF = $Fac;
284: }
285:
1.3 minaeibi 286: if ($Discuss->{"$name:$problem"}) {
1.1 stredwic 287: $TotDiscuss++;
288: $Discussed=1;
289: }
290: my $time = $cache->{"$name:$LatestVersion:$problem:timestamp"};
291: $Dis .= $tempProblemOrder.'='.$DisF.'+'.$Yes;
1.3 minaeibi 292: $ptr .= '&'.$partData{$_.'.tries'}.
293: '&'.$partData{$_.'.wrongs'}.
294: '&'.$partData{$_.'.code'};
1.1 stredwic 295: push (@$list, $ptr."&$Discussed");
1.3 minaeibi 296: $r->print('<br>'.$name.'---'.$ptr);
297:
1.1 stredwic 298: #### if ($DoDiff>0.85) {
299:
300: $TimeTot += $time;
301:
302: if ($Yes==1 && $partData{$_.'.Tries'}==1) {
303: $TotFirst++;
304: }
305: # my $Acts= $Activity->{$name.':'.$problem};
306: # if ($Acts) {
307: # my $Pt=&ProcAct( $Acts, $time );
308: #my ($spe,$beg) = split(/\+/,$Pt);
309: # my $spe= $Pt;
310: # if ($Yes==1) {$spent_yes += $spe;}
311: # $spent += $spe;
312: #$Beg += $beg;
313: # $r->print('<br>'.$name.'---'.$problem.'---'.$spe);
314: # }
315: $TotalOpend++;
316: $ProbTot++;
317:
318: $tempProblemOrder++;
319: }
320: }
321: my $pstr;
322: if($totalTries) {
323: my $DisFac = ($totalAwarded/$totalTries);
324: my $DisFactor = sprintf( "%.4f", $DisFac );
325: my $TS = sprintf( "%.2f", $spent );
326: my $TS_yes = sprintf( "%.2f", $spent_yes );
327: # $DiscFac{$DisFactor}=$Dis;
328: $pstr=$DisFactor.':'.$name.':'.$ProbTot.':'.$TotalOpend.':'.
329: $totalTries.':'.$ProbSolved.':'.$TotFirst.':'.
330: $TS_yes.':'.$TS.':'.$TotDiscuss;
331: $discriminantFactor{$pstr}=$Dis;
332: }
333: }
334:
335: return (\%discriminantFactor);
336: }
337:
338:
339: =pod
340: sub MySort {
341: if ( $Pos > 0 ) {
342: if ($ENV{'form.order'} eq 'Descending') {$b <=> $a;}
343: else { $a <=> $b; }
344: }
345: else {
346: if ($ENV{'form.order'} eq 'Descending') {$b cmp $a;}
347: else { $a cmp $b; }
348: }
349: }
350: =cut
351:
1.3 minaeibi 352:
1.1 stredwic 353: sub BuildStatisticsTable {
1.2 minaeibi 354: my ($cache,$discriminantFactor,$list,$headings,$students,$r,%color)=@_;
1.1 stredwic 355:
356: #6666666
357: # my $file="/home/httpd/perl/tmp/183d.txt";
358: # open(OUT, ">$file");
359: #6666666
1.2 minaeibi 360: ## &Apache::lonstatistics::Create_PrgWin($r);
1.1 stredwic 361: ##777777
362: ## my (%Activity) = &LoadActivityLog();
363: ## $r->print('<script>popwin.document.popremain.remaining.value="'.
364: ## 'Loading Discussion...";</script>');
365: ## my ($doDiffFile) = &LoadDoDiffFile();
366:
367: my $p_count = 0;
368: my $nIndex = 0;
369: my $dummy;
370: my $p_val;
371: my $ResId;
1.2 minaeibi 372: my %GraphDat;
1.1 stredwic 373: my $NoElements = scalar @$list;
374:
1.3 minaeibi 375:
1.1 stredwic 376: foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
377:
378: &CreateProblemStatisticsTableHeading($cache->{'DisplayFormat'},
379: $cache->{$sequence.':source'},
380: $cache->{$sequence.':title'},
1.2 minaeibi 381: $headings,$r);
1.1 stredwic 382:
1.3 minaeibi 383: foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
384: my $problem = $cache->{$problemID.':problem'};
385: $r->print("<br>$problem");
386:
387: }
388: }
389: }
390: =pod
1.1 stredwic 391: ##777777
392: ## $Str .= &Classify($discriminantFactor, $students);
393:
394:
395: my ($Hid,$pr)=split(/\:/,$mapsort{$_});
396: my @lpr=split(/\&/,$pr);
397: for (my $i=1; $i<=$#lpr; $i++) {
398: my %storestats=();
399: my ($PrOrd,$Prob,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,$list->[$nIndex]);
400: my $Temp = $Prob;
401: my $MxTries = 0;
402: my $TotalTries = 0;
403: my $YES = 0;
404: my $Incorrect = 0;
405: my $Override = 0;
406: my $StdNo = 0;
407: my $DiscNo=0;
408: my @StdLst;
409: while ( $PrOrd == $lpr[$i] )
410: {
411: $nIndex++;
412: $StdNo++;
413: $StdLst[ $StdNo ] = $Tries;
414: $TotalTries += $Tries;
415: if ( $MxTries < $Tries ) { $MxTries = $Tries; }
416: if ( $Code eq 'C' ){ $YES++; }
417: elsif( $Code eq 'I' ) { $Incorrect++; }
418: elsif( $Code eq 'O' ) { $Override++; }
419: elsif( $Code eq 'U' ) { $StdNo--; }
420: ($PrOrd,$Prob,$Tries,$Wrongs,$Code,$Disc)=split(/\&/,$list->[$nIndex]);
421: }
422:
423: $p_count++;
424: my $Dummy;
425: ($ResId,$Dummy)=split(/\*/,$Temp);
426:
1.2 minaeibi 427: $Temp = '<a href="'.$cache->{'src_'.$ResId}.
428: '" target="_blank">'.$cache->{'title_'.$ResId}.$Dummy.'</a>';
1.1 stredwic 429:
1.2 minaeibi 430: my $res = &Apache::lonnet::declutter($cache->{'src_'.$ResId});
1.1 stredwic 431: my $urlres=$res;
432:
433: $ResId=~/(\d+)\.(\d+)/;
1.2 minaeibi 434: my $Map = &Apache::lonnet::declutter( $cache->{'map_id_'.$1} );
1.1 stredwic 435: $urlres=$Map;
436:
1.2 minaeibi 437: $res = '<a href="'.$cache->{'src_'.$ResId}.'">'.$res.'</a>';
1.1 stredwic 438: #$Map = '<a href="'.$Map.'">'.$res.'</a>';
439:
440: #------------------------ Compute the Average of Tries about one problem
441: my $Average = ($StdNo) ? $TotalTries/$StdNo : 0;
442:
443: $storestats{$ENV{'request.course.id'}.'___'.$urlres.'___timestamp'}=time;
444: $storestats{$ENV{'request.course.id'}.'___'.$urlres.'___stdno'}=$StdNo;
445: $storestats{$ENV{'request.course.id'}.'___'.$urlres.'___avetries'}=$Average;
446:
447: #-------------------------------- Compute percentage of Wrong tries
448: my $Wrong = ( $StdNo ) ? 100 * ( $Incorrect / $StdNo ) : 0;
449:
450: #-------------------------------- Compute Standard Deviation
451: my $StdDev = 0;
452: if ( $StdNo > 1 ) {
453: for ( my $n = 0; $n < $StdNo; $n++ ) {
454: my $Dif = $StdLst[ $n ]-$Average;
455: $StdDev += $Dif*$Dif;
456: }
457: $StdDev /= ( $StdNo - 1 );
458: $StdDev = sqrt( $StdDev );
459: }
460:
461: #-------------------------------- Compute Degree of Difficulty
462: my $DoDiff = 0;
463: if( $TotalTries > 0 ) {
464: $DoDiff = 1 - ( ( $YES + $Override ) / $TotalTries );
465: # $DoDiff = ($TotalTries)/($YES + $Override+ 0.1);
466: }
467:
468: $storestats{$ENV{'request.course.id'}.'___'.$urlres.'___difficulty'}=$DoDiff;
469:
470: #-------------------------------- Compute the Skewness
471: my $Skewness = 0;
472: my $Sum = 0;
473: if ( $StdNo > 0 && $StdDev > 0 ) {
474: for ( my $n = 0; $n < $StdNo; $n++ ) {
475: my $Dif = $StdLst[ $n ]-$Average;
476: $Skewness += $Dif*$Dif*$Dif;
477: }
478: $Skewness /= $StdNo;
479: $Skewness /= $StdDev*$StdDev*$StdDev;
480: }
481:
482: #--------------------- Compute the Discrimination Factors
483: my ($Up1,$Up2)=split(/\:/,':');#jason$DisUp->{$lpr[$i]});
484: my ($Lw1,$Lw2)=split(/\:/,':');#jason$DisLow->{$lpr[$i]});
485: my $Dis1 = $Up1 - $Lw1;
486: my $Dis2 = $Up2 - $Lw2;
487: my $_D1 = sprintf("%.2f", $Dis1);
488: my $_D2 = sprintf("%.2f", $Dis2);
489:
490: #----------------- Some restition in presenting the float numbers
491: my $Avg = sprintf( "%.2f", $Average );
492: my $Wrng = sprintf( "%.1f", $Wrong );
493: my $SD = sprintf( "%.1f", $StdDev );
494: my $DoD = sprintf( "%.2f", $DoDiff );
495: my $Sk = sprintf( "%.1f", $Skewness );
496: my $join = $lpr[$i].'&'.$Temp.'&'.$StdNo.'&'.
497: $TotalTries.'&'.$MxTries.'&'.$Avg.'&'.
498: $YES.'&'.$Override.'&'.$Wrng.'&'.$DoD.'&'.
499: $SD.'&'.$Sk.'&'.$_D1.'&'.$_D2.'&'.
500: $DiscNo.'&'.$Prob;
1.2 minaeibi 501: ##8888 $CachData{($p_count-1)}=$join;
1.1 stredwic 502:
503: #6666666
504: # $r->print('<br>'.$out.'&'.$DoD);
505: # print (OUT $out.'@'.$DoD.'&');
506: #6666666
507:
508: $urlres=~/^(\w+)\/(\w+)/;
509: if ($StdNo) {
510: &Apache::lonnet::put('resevaldata',\%storestats,$1,$2);
511: }
512: #-------------------------------- Row of statistical table
1.2 minaeibi 513: &TableRow($cache,$join,$i,($p_count-1),$r,\%color,\%GraphDat);
1.1 stredwic 514: }
1.2 minaeibi 515: &CloseTable($cache,$r);
1.1 stredwic 516: }
517: &Close_PrgWin();
518: #666666
519: # close( OUT );
520: #666666
521: }
1.3 minaeibi 522: =cut
1.1 stredwic 523:
524: =pod
525: sub Cache_Statistics {
1.2 minaeibi 526: my ($cache,$color)=@_;
1.1 stredwic 527: my @list = ();
528: my $Useful;
529: my $UnUseful;
530: # $r->print('<input type="hidden" name="show" value="excel" />'."\n");
531: my %myHeader = reverse( %Header );
532: $Pos = $myHeader{$ENV{'form.sort'}};
533: if ($Pos > 0) {$Pos++;}
534: my $p_count = 0;
535: foreach my $key( keys %CachData) {
536: my @Temp=split(/\&/,$CachData{$key});
537: if ( $Pos == 0 ) {
538: ($UnUseful,$Useful)=split(/\>/,$Temp[$Pos]);
539: }
540: else {
541: $Useful = $Temp[$Pos];
542: }
543: $list[$p_count]=$Useful.'@'.$CachData{$key};
544: $p_count++;
545: }
546:
547: @list = sort MySort (@list);
548:
549: my $nIndex=0;
550:
551: if ( $Pos == 0 ) {
552: foreach (sort keys %mapsort) {
553: my ($Hid,$pr)=split(/\:/,$mapsort{$_});
554: &CreateProblemStatisticsTableHeading($cache,1,$Hid);
555: my @lpr=split(/\&/,$pr);
556: for (my $i=1; $i<=$#lpr; $i++) {
557: my($Pre, $Post) = split(/\@/,$list[$nIndex]);
558: #$r->print('<br>'.$Pre.'---'.$Post);
1.2 minaeibi 559: &TableRow($cache,$Post,$i,$nIndex,\%color,\%GraphDat);
1.1 stredwic 560: $nIndex++;
561: }
562: &CloseTable($cache);
563: }
564: }
565: else {
566: &CreateProblemStatisticsTableHeading($cache,0);
567: for ( my $nIndex = 0; $nIndex < $p_count; $nIndex++ ) {
568: my($Pre, $Post) = split(/\@/,$list[$nIndex]);
1.2 minaeibi 569: &TableRow($cache,$Post,$nIndex,$nIndex,\%color,\%GraphDat);
1.1 stredwic 570: }
571: &CloseTable($cache);
572: }
573: }
574: =cut
575:
576: sub TableRow {
1.2 minaeibi 577: my ($cache,$Str,$Idx,$RealIdx,$r,$color,$GraphDat)=@_;
1.1 stredwic 578: my($PrOrd,$Temp,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override,
579: $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$DiscNo,$Prob)=split(/\&/,$Str);
580: if ($ENV{'form.showcsv'}) {
581: my ($ResId,$Dummy)=split(/\*/,$Prob);
582: my $Ptr = "\n".'<br>'.
583: "\n".'"'.($RealIdx+1).'",'.
1.2 minaeibi 584: "\n".'"'.$cache->{'title_'.$ResId}.$Dummy.'",'.
585: "\n".'"'.$cache->{'src_'.$ResId}.'",'.
1.1 stredwic 586: "\n".'"'.$StdNo.'",'.
587: "\n".'"'.$TotalTries.'",'.
588: "\n".'"'.$MxTries.'",'.
589: "\n".'"'.$Avg.'",'.
590: "\n".'"'.$YES.'",'.
591: "\n".'"'.$Override.'",'.
592: "\n".'"'.$Wrng.'",'.
593: "\n".'"'.$DoD.'",'.
594: "\n".'"'.$SD.'",'.
595: "\n".'"'.$Sk.'",'.
596: "\n".'"'.$_D1.'",'.
597: "\n".'"'.$_D2.'"'.
598: "\n".'"'.$DiscNo.'"';
599:
600: $r->print("\n".$Ptr);
601: }
602: else{
603: my $Ptr = "\n".'<tr>'.
604: "\n".'<td>'.($RealIdx+1).'</td>'.
605: # "\n".'<td>'.$PrOrd.$Temp.'</td>'.
606: "\n".'<td>'.$Temp.'</td>'.
1.2 minaeibi 607: "\n".'<td bgcolor='.$color->{"yellow"}.'> '.$StdNo.'</td>'.
608: "\n".'<td bgcolor='.$color->{"yellow"}.'>'.$TotalTries.'</td>'.
609: "\n".'<td bgcolor='.$color->{"yellow"}.'>'.$MxTries.'</td>'.
610: "\n".'<td bgcolor='.$color->{"gb"}.'>'.$Avg.'</td>'.
611: "\n".'<td bgcolor='.$color->{"gb"}.'> '.$YES.'</td>'.
612: "\n".'<td bgcolor='.$color->{"gb"}.'> '.$Override.'</td>'.
613: "\n".'<td bgcolor='.$color->{"red"}.'> '.$Wrng.'</td>'.
614: "\n".'<td bgcolor='.$color->{"red"}.'> '.$DoD.'</td>'.
615: "\n".'<td bgcolor='.$color->{"green"}.'> '.$SD.'</td>'.
616: "\n".'<td bgcolor='.$color->{"green"}.'> '.$Sk.'</td>'.
617: "\n".'<td bgcolor='.$color->{"purple"}.'> '.$_D1.'</td>'.
618: "\n".'<td bgcolor='.$color->{"purple"}.'> '.$_D2.'</td>'.
619: "\n".'<td bgcolor='.$color->{"yellow"}.'> '.$DiscNo.'</td>';
1.1 stredwic 620: $r->print("\n".$Ptr.'</tr>' );
621: }
1.2 minaeibi 622: $GraphDat->{$RealIdx}=$DoD.':'.$Wrng;
1.1 stredwic 623: }
624:
625: sub StatusOptions {
626: my ($cache)=@_;
627:
628: my $Status = $cache->{'Status'};
629: my $OpSel1 = '';
630: my $OpSel2 = '';
631: my $OpSel3 = '';
632:
633: if($Status eq 'Any') { $OpSel3 = ' selected'; }
634: elsif($Status eq 'Expired' ) { $OpSel2 = ' selected'; }
635: else { $OpSel1 = ' selected'; }
636:
637: my $Ptr = '';
638: $Ptr .= '<tr><td align="right"><b>Student Status:</b></td>'."\n";
639: $Ptr .= '<td align="left"><select name="Status">';
640: $Ptr .= '<option'.$OpSel1.'>Active</option>'."\n";
641: $Ptr .= '<option'.$OpSel2.'>Expired</option>'."\n";
642: $Ptr .= '<option'.$OpSel3.'>Any</option>'."\n";
643: $Ptr .= '</select></td></tr>'."\n";
644:
645: return $Ptr;
646: }
647:
648: sub AscendOrderOptions {
649: my ($order)=@_;
650:
651: my $OpSel1 = '';
652: my $OpSel2 = '';
653:
654: if($order eq 'Ascending') {
655: $OpSel1 = ' selected';
656: } else {
657: $OpSel2 = ' selected';
658: }
659:
660: my $Ptr = '';
661: $Ptr .= '<tr><td align="right"><b>Sorting Type:</b></td>'."\n";
662: $Ptr .= '<td align="left"><select name="Ascend">'."\n";
663: $Ptr .= '<option'.$OpSel1.'>Ascending</option>'."\n".
664: '<option'.$OpSel2.'>Descending</option>'."\n";
665: $Ptr .= '</select></td></tr>'."\n";
666:
667: return $Ptr;
668: }
669:
670: sub ProblemStatisticsButtons {
671: my ($displayFormat)=@_;
672:
673: my $Ptr = '<tr><td></td><td align="left">';
674: $Ptr .= '<input type=submit name="ProblemStatisticsRecalculate" ';
675: $Ptr .= 'value="Recalculate Statistics"/>'."\n";
676: $Ptr .= ' ';
677: $Ptr .= '<input type="submit" name="DoDiffGraph" ';
678: $Ptr .= 'value="DoDiff Graph" />'."\n";
679: $Ptr .= ' ';
680: $Ptr .= '<input type="submit" name="PercentWrongGraph" ';
681: $Ptr .= 'value="%Wrong Graph" />'."\n";
682: $Ptr .= ' ';
683: $Ptr .= '<input type="submit" name="DisplayCSVFormat" ';
684: if($displayFormat eq 'Display CSV Format') {
685: $Ptr .= 'value="Display CSV Format" />'."\n";
686: } else {
687: $Ptr .= 'value="Display Table Format" />'."\n";
688: }
689: $Ptr .= '</td></tr>';
690:
691: return $Ptr;
692: }
693:
694: sub ProblemStatisticsLegend {
695: my $Ptr = '';
696: $Ptr = '<table border="0">';
697: $Ptr .= '<tr><td>';
698: $Ptr .= '<b>#Stdnts</b>:</td>';
699: $Ptr .= '<td>Total Number of Students opened the problem.';
700: $Ptr .= '</td></tr><tr><td>';
701: $Ptr .= '<b>Tries</b>:</td>';
702: $Ptr .= '<td>Total Number of Tries for solving the problem.';
703: $Ptr .= '</td></tr><tr><td>';
704: $Ptr .= '<b>Mod</b>:</td>';
705: $Ptr .= '<td>Maximunm Number of Tries for solving the problem.';
706: $Ptr .= '</td></tr><tr><td>';
707: $Ptr .= '<b>Mean</b>:</td>';
708: $Ptr .= '<td>Average Number of the tries. [ Tries / #Stdnts ]';
709: $Ptr .= '</td></tr><tr><td>';
710: $Ptr .= '<b>#YES</b>:</td>';
711: $Ptr .= '<td>Number of students solved the problem correctly.';
712: $Ptr .= '</td></tr><tr><td>';
713: $Ptr .= '<b>#yes</b>:</td>';
714: $Ptr .= '<td>Number of students solved the problem by override.';
715: $Ptr .= '</td></tr><tr><td>';
716: $Ptr .= '<b>%Wrng</b>:</td>';
717: $Ptr .= '<td>Percentage of students tried to solve the problem ';
718: $Ptr .= 'but still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]';
719: $Ptr .= '</td></tr><tr><td>';
720: $Ptr .= '<b>DoDiff</b>:</td>';
721: $Ptr .= '<td>Degree of Difficulty of the problem. ';
722: $Ptr .= '[ 1 - ((#YES+#yes) / Tries) ]';
723: $Ptr .= '</td></tr><tr><td>';
724: $Ptr .= '<b>S.D.</b>:</td>';
725: $Ptr .= '<td>Standard Deviation of the tries. ';
726: $Ptr .= '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1) ';
727: $Ptr .= 'where Xi denotes every student\'s tries ]';
728: $Ptr .= '</td></tr><tr><td>';
729: $Ptr .= '<b>Skew.</b>:</td>';
730: $Ptr .= '<td>Skewness of the students tries.';
731: $Ptr .= '[(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]';
732: $Ptr .= '</td></tr><tr><td>';
733: $Ptr .= '<b>Dis.F.</b>:</td>';
734: $Ptr .= '<td>Discrimination Factor: A Standard for evaluating the ';
735: $Ptr .= 'problem according to a Criterion<br>';
736: $Ptr .= '<b>[Applied Criterion in %27 Upper Students - ';
737: $Ptr .= 'Applied the same Criterion in %27 Lower Students]</b><br>';
738: $Ptr .= '<b>1st Criterion</b> for Sorting the Students: ';
739: $Ptr .= '<b>Sum of Partial Credit Awarded / Total Number of Tries</b><br>';
740: $Ptr .= '<b>2nd Criterion</b> for Sorting the Students: ';
741: $Ptr .= '<b>Total number of Correct Answers / Total Number of Tries</b>';
742: $Ptr .= '</td></tr>';
743: $Ptr .= '<tr><td><b>Disc.</b></td>';
744: $Ptr .= '<td>Number of Students had at least one discussion.';
745: $Ptr .= '</td></tr></table>';
746:
747: return $Ptr;
748: }
749:
1.4 ! minaeibi 750: #------- Processing upperlist and lowerlist according to each problem
! 751: sub ProcessDiscriminant {
! 752: my ($List) = @_;
! 753: my @sortedList = sort (@$List);
! 754: my $Count = scalar @sortedList;
! 755: my $Problem;
! 756: my @Dis;
! 757: my $Slvd=0;
! 758: my $tmp;
! 759: my $Sum1=0;
! 760: my $Sum2=0;
! 761: my $nIndex=0;
! 762: my $nStudent=0;
! 763: my %Proc=undef;
! 764: while ($nIndex<$Count) {
! 765: ($Problem,$tmp)=split(/\=/,$sortedList[$nIndex]);
! 766: @Dis=split(/\+/,$tmp);
! 767: my $Temp = $Problem;
! 768: do {
! 769: $nIndex++;
! 770: $nStudent++;
! 771: $Sum1 += $Dis[0];
! 772: $Sum2 += $Dis[1];
! 773: ($Problem,$tmp)=split(/\=/,$sortedList[$nIndex]);
! 774: @Dis=split(/\+/,$tmp);
! 775: } while ( $Problem eq $Temp && $nIndex < $Count );
! 776: # $Proc{$Temp}=($Sum1/$nStudent).':'.$nStudent;
! 777: $Proc{$Temp}=($Sum1/$nStudent).':'.($Sum2/$nStudent);
! 778: # $r->print("$nIndex) $Temp --> ($nStudent) $Proc{$Temp} <br>");
! 779: $Sum1=0;
! 780: $Sum2=0;
! 781: $nStudent=0;
! 782: }
! 783:
! 784: return %Proc;
! 785: }
! 786:
! 787: #------- Creating Discimination factor
! 788: sub Discriminant {
! 789: my ($discriminantFactor)=@_;
! 790: my @discriminantKeys=keys(%$discriminantFactor);
! 791: my $Count = scalar @discriminantKeys;
! 792:
! 793: my $UpCnt = int(0.27*$Count);
! 794: my $low=0;
! 795: my $up=$Count-$UpCnt;
! 796: my @UpList=();
! 797: my @LowList=();
! 798:
! 799: $Count=0;
! 800: foreach my $key (sort(@discriminantKeys)) {
! 801: $Count++;
! 802: if($low < $UpCnt || $Count > $up) {
! 803: $low++;
! 804: my $str=$discriminantFactor->{$key};
! 805: foreach(split(/\:/,$str)){
! 806: if($_) {
! 807: if($low<$UpCnt) { push(@LowList,$_); }
! 808: else { push(@UpList,$_); }
! 809: }
! 810: }
! 811: }
! 812: }
! 813: my %DisUp = &ProcessDiscriminant(\@UpList);
! 814: my %DisLow = &ProcessDiscriminant(\@LowList);
! 815:
! 816: return (\%DisUp, \%DisLow);
! 817: }
! 818:
! 819:
! 820:
1.1 stredwic 821: #---- END Problem Statistics Web Page ----------------------------------------
822:
823: #---- Problem Statistics Graph Web Page --------------------------------------
824:
825: # ------------------------------------------- Prepare data for Graphical chart
826:
1.4 ! minaeibi 827: sub BuildDiffGraph {
! 828: my ($r)=@_;
! 829:
! 830: my $graphData = &GetGraphData('DiffGraph', $r);
! 831: return '<IMG src="/cgi-bin/graph.gif?'.$graphData.'" />';
! 832: }
! 833:
! 834: sub BuildWrongGraph {
! 835: my ($r)=@_;
! 836:
! 837: my $graphData = &GetGraphData('WrongGraph', $r);
! 838: return '<IMG src="/cgi-bin/graph.gif?'.$graphData.'" />';
! 839: }
! 840:
! 841:
1.1 stredwic 842: sub GetGraphData {
1.2 minaeibi 843: my ($ylab,$r,%GraphDat)=@_;
1.1 stredwic 844: my $Col;
845: my $data='';
846: my $count = 0;
847: my $Max = 0;
848: my $cid=$ENV{'request.course.id'};
849: my $GraphDB = "/home/httpd/perl/tmp/$ENV{'user.name'}".
850: "_$ENV{'user.domain'}_$cid\_graph.db";
851: foreach (keys %GraphDat) {delete $GraphDat{$_};}
852: if (-e "$GraphDB") {
853: if (tie(%GraphDat,'GDBM_File',"$GraphDB",&GDBM_READER,0640)) {
854: if ( $ylab eq 'DoDiff Graph' ) {
855: $ylab = 'Degree-of-Difficulty';
856: $Col = 0;
857: }
858: else {
859: $ylab = 'Wrong-Percentage';
860: $Col = 1;
861: }
862: foreach (sort NumericSort keys %GraphDat) {
863: my @Temp=split(/\:/,$GraphDat{$_});
864: my $inf = $Temp[$Col];
865: if ( $Max < $inf ) {$Max = $inf;}
866: $data .= $inf.',';
867: $count++;
868: }
869: if ( $Max > 1 ) {
870: $Max += (10 - $Max % 10);
871: $Max = int($Max);
872: }
873: else { $Max = 1; }
874: untie(%GraphDat);
875: my $Course = $ENV{'course.'.$cid.'.description'};
876: $Course =~ s/\ /"_"/eg;
1.3 minaeibi 877: my $GData=$Course.'&'.'Problems'.'&'.$ylab.'&'.
878: $Max.'&'.$count.'&'.$data;
1.1 stredwic 879: }
880: else {
881: $r->print("Unable to tie hash to db file");
882: }
883: }
884: }
1.4 ! minaeibi 885:
! 886:
1.1 stredwic 887: 1;
888: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>