--- loncom/interface/lonstatistics.pm 2002/03/17 01:30:00 1.11 +++ loncom/interface/lonstatistics.pm 2002/07/19 18:17:34 1.28 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: lonstatistics.pm,v 1.11 2002/03/17 01:30:00 minaeibi Exp $ +# $Id: lonstatistics.pm,v 1.28 2002/07/19 18:17:34 minaeibi Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,18 +27,21 @@ # # (Navigate problems for statistical reports # YEAR=2001 -# 5/05,7/09,7/25/01,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei -# 11/1, 11/4, 11/16, 12/14, 12/16, 12/18,12/20,12/31 Behrouz Minaei +# 5/5,7/9,7/25/1,8/11,9/13,9/26,10/5,10/9,10/22,10/26 Behrouz Minaei +# 11/1,11/4,11/16,12/14,12/16,12/18,12/20,12/31 Behrouz Minaei # YEAR=2002 -# 1/22, 2/1, 2/6, 2/25, 3/2, 3/6, 3/17 Behrouz Minaei +# 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 +# 5/12,5/14,5/15,5/19,5/26,7/16 Behrouz Minaei +# ### package Apache::lonstatistics; -use strict; +use strict; use Apache::Constants qw(:common :http); use Apache::lonnet(); use Apache::lonhomework; +use Apache::loncommon; use HTML::TokeParser; use GDBM_File; @@ -46,135 +49,568 @@ use GDBM_File; my %hash; my %CachData; my %GraphDat; -my %maps; -my %mapsort; -my %section; -my %StuBox; -my %DiscFac; -my %DisUp; -my %DisLow; -my $UpCnt; -my $CurMap; -my $CurSec; -my $CurStu; -my @cols; -my @list; -my @students; -my $p_count; -my $Pos; my $r; -my $OpSel1; -my $OpSel2; -my $OpSelDis1; -my $OpSelDis2; -my $OpSel3; -my $OpSel4; my $GData; -my $cid; -my $firstres; -my $lastres; -my $DiscFlag; -my $HWN; -my $P_Order; -my %Header = (0,"Homework Sets Order",1,"#Stdnts",2,"Tries",3,"Mod", - 4,"Mean",5,"#YES",6,"#yes",7,"%Wrng",8,"DoDiff", - 9,"S.D.",10,"Skew.",11,"D.F.1st",12,"D.F.2nd"); - - -sub get_student_answers { - my ($symb,$username,$domain,$courseid) = @_; - my ($map,$id,$feedurl) = split(/___/,$symb); - my (%old,%moreenv); - my @elements=('symb','courseid','domain','username'); - foreach my $element (@elements) { - $old{$element}=$ENV{'form.grade_'.$element}; - $moreenv{'form.grade_'.$element}=eval '$'.$element #' - } - $moreenv{'form.grade_target'}='answer'; - &Apache::lonnet::appenv(%moreenv); - my $userview=&Apache::lonnet::ssi('/res/'.$feedurl); - &Apache::lonnet::delenv('form.grade_'); - foreach my $element (@elements) { - $ENV{'form.grade_'.$element}=$old{$element}; - } - $userview=~s/\
]*\>//gi; - $userview=~s/\<\/body\>//gi; - $userview=~s/\//gi; - $userview=~s/\<\/html\>//gi; - $userview=~s/\//gi; - $userview=~s/\<\/head\>//gi; - $userview=~s/action\s*\=/would_be_action\=/gi; - return $userview; +my %color; +my %foil_to_concept; +my @Concepts; +my %ConceptData; +my %Answer=(); +my %mapsort; + +my %Activity=(); +my %Grade=(); +my %DoDiff=(); +my %Discuss=(); +my $TotalDiscuss=0; +my $TotalDiscuss_=0; + + +sub LoadDiscussion { +# my $symb=shift; +# $r->print('# | '. + "\n".'Concept | '. + "\n".'Correct | '. + "\n".'Wrong | '. + "\n".'
---|---|---|---|
".($n+1)." | ". + "\n".''.$Concepts[$n]." | ". + "\n".''.$data1[$n]." | ". + "\n".''.$data2[$n]." | ". + "\n"."From:['.localtime($ConceptData{'Int.'.$k}). + '] To: ['.localtime($ConceptData{'Int.'.($k+1)}-1). + "] | $Correct | $Wrong | "; + + $Str .= "\n".'
# | '. - "\n".'Set Title | '. - "\n".'Results | '. - "\n".'Tries | '. - "\n".'
---|---|---|---|
$SetNo | ". - "\n"."$Set | ". - "\n"."$PtrCod | ". - "\n"."$PtrTry | ". - "\n"."
P# | '."\n"; - for ( my $nIdx=0; $nIdx < $ColNo; $nIdx++ ) { - $Result .= ''.''.' | '."\n"; + my $Result = "\n".'
---|
P# | '."\n"; + for(my $nIndex=0; $nIndex < (scalar (keys %$headings)); $nIndex++) { + $Result .= ''.''.' | '."\n"; } $Result .= "\n".'
---|
'. - ' #Stdnts: Total Number of Students opened the problem.'; + +# ------ Dump the Student's DB file and handling the data for statistics table +sub ExtractStudentData { + my ($cache,$name,$list)=@_; + my %discriminantFactor; - $r->print($Ptr); - $r->rflush(); + my $totalTries = 0; + my $totalAwarded = 0; + my $tempProblemOrder=0; + my $spent=0; + my $spent_yes=0; + my $TotDiscuss=0; + my $TotalOpend = 0; + my $ProbSolved = 0; + my $ProbTot = 0; + my $TotFirst = 0; + my $TimeTot = 0; + my $Discussed=0; - if ((-e "$CacheDB")&&($ENV{'form.sort'} ne 'Recalculate Statistics')) { - if (tie(%CachData,'GDBM_File',"$CacheDB",&GDBM_READER,0640)) { - tie(%GraphDat,'GDBM_File',$GraphDB,&GDBM_WRCREAT,0640); - &Cache_Statistics(); - } - else { - $r->print("Unable to tie hash to db file"); - } - } - else { - if (tie(%CachData,'GDBM_File',$CacheDB,&GDBM_WRCREAT,0640)) { - tie(%GraphDat,'GDBM_File',$GraphDB,&GDBM_WRCREAT,0640); - foreach (keys %DiscFac) {delete $CachData{$_};} - foreach (keys %CachData) {delete $CachData{$_};} - $DiscFlag=0; - &Build_Statistics(); - } - else { - $r->print("Unable to tie hash to db file"); + foreach my $sequence (split(':', $cache->{'orderedSequences'})) { + if($cache->{'ProblemStatisticsMap'} ne 'All Maps' && + $cache->{'ProblemStatisticsMap'} ne $cache->{$sequence.':title'}) { + next; } - } - #$r->print('Total instances of the problems : '.($p_count*($#students+1))); - untie(%CachData); - untie(%GraphDat); -} + my $Dis = ''; + foreach my $problemID (split(':', $cache->{$sequence.':problems'})) { + my $problem = $cache->{$problemID.':problem'}; + my $LatestVersion = $cache->{$name.':version:'.$problem}; + + # Output dashes for all the parts of this problem if there + # is no version information about the current problem. + #if(!$LatestVersion) { + # foreach my $part (split(/\:/,$cache->{$sequence.':'. + # $problemID. + # ':parts'})) { + # $codes .= "-,"; + # $attempts .= "0,"; + # } + # next; + #} + + my %partData=undef; + # Initialize part data, display skips correctly + # Skip refers to when a student made no submissions on that + # part/problem. + foreach my $part (split(/\:/,$cache->{$sequence.':'. + $problemID. + ':parts'})) { + $partData{$part.':tries'}=0; + $partData{$part.':code'}='-'; + } + # Looping through all the versions of each part, starting with the + # oldest version. Basically, it gets the most recent + # set of grade data for each part. + for(my $Version=1; $Version<=$LatestVersion; $Version++) { + foreach my $part (split(/\:/,$cache->{$sequence.':'. + $problemID. + ':parts'})) { + + if(!defined($cache->{$name.":$Version:$problem". + ":resource.$part.solved"})) { + # No grade for this submission, so skip + next; + } + + my $tries=0; + my $time=0; + my $awarded=0; + $Discussed=0; + my $code='U'; + + $awarded = $cache->{$name. + "$Version:$problem:resource.". + "$part.awarded"}; + $partData{$part.':awarded'} = ($awarded) ? $awarded : 0; + $totalAwarded += $awarded; + + $tries = $cache->{$name.":$Version:$problem". + ":resource.$part.tries"}; + $partData{$part.':tries'} = ($tries) ? $tries : 0; + $partData{$part.':wrong'} = $partData{$part.':tries'}; + $totalTries += $tries; + + my $val = $cache->{$name.":$Version:$problem". + ":resource.$part.solved"}; + if ($val eq 'correct_by_student') {$code = 'C';} + elsif ($val eq 'correct_by_override') {$code = 'O';} + elsif ($val eq 'incorrect_attempted') {$code = 'I';} + elsif ($val eq 'incorrect_by_override'){$code = 'I';} + elsif ($val eq 'excused') {$code = 'x';} + $partData{$part.':code'}=$code; + + if($partData{$part.':wrong'} ne 0 && + ($code eq 'C' || $code eq 'O')) { + $partData{$part.':wrong'}--; + } + } + } -# ------------------------------------- Find the section of student in a course + # Loop through all the parts for the current problem in the + # correct order and prepare the output + foreach (split(/\:/,$cache->{$sequence.':'.$problemID. + ':parts'})) { + my $Yes = 0; + if($partData{$_.':code'} eq 'C' || + $partData{$_.':code'} eq 'O') { + $Yes=1; + } + #my $ptr = "$hash{'title_'.$ResId}"; + my $ptr = $tempProblemOrder.'&'.$problemID; -sub usection { - my ($udom,$unam,$courseid,$ActiveFlag)=@_; - $courseid=~s/\_/\//g; - $courseid=~s/^(\w)/\/$1/; - foreach (split(/\&/,&Apache::lonnet::reply('dump:'. - $udom.':'.$unam.':roles', - &Apache::lonnet::homeserver($unam,$udom)))){ - my ($key,$value)=split(/\=/,$_); - $key=&Apache::lonnet::unescape($key); - if ($key=~/^$courseid(?:\/)*(\w+)*\_st$/) { - my $section=$1; - if ($key eq $courseid.'_st') { $section=''; } - my ($dummy,$end,$start)=split(/\_/,&Apache::lonnet::unescape($value)); - if ( $ActiveFlag ne 'Any' ) { - my $now=time; - my $notactive=0; - if ($start) { - if ($now<$start) { $notactive=1; } - } - if ($end) { - if ($now>$end) { $notactive=1; } - } - if ((($ActiveFlag eq 'Expired') && $notactive == 1) || - (($ActiveFlag eq 'Active') && $notactive == 0 ) ) { - return $section; - } - else { return '-1'; } - } - return $section; - } - } - return '-1'; -} + if($_ > 1) { + $ptr .= "*(part $_)"; + $Dis .= '&'; + } + my ($pr_no,$dod)=split('&',$ptr); + my $DoDiff=$DoDiff{$dod}; +# $r->print('
'. - ' Tries : Total Number of Tries for solving the problem.
'. - ' Mod : Maximunm Number of Tries for solving the problem.
'. - ' Mean : Average Number of the tries. [ Tries / #Stdnts ]
'. - ' #YES : Number of students solved the problem correctly.
'. - ' #yes : Number of students solved the problem by override.
'. - ' %Wrng : Percentage of students tried to solve the problem but'. - ' still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]
'. -# ' DoDiff : Degree of Difficulty of the problem. [ Tries/(#YES+#yes+0.1) ]
'. Kashy formula - ' DoDiff : Degree of Difficulty of the problem. [ 1 - ((#YES+#yes) / Tries) ]
'. #Gerd formula - ' S.D. : Standard Deviation of the tries.'. - '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1)'. - ' where Xi denotes every student\'s tries ]
'. - ' Skew. : Skewness of the students tries.'. - ' [ (sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3) ]
'. - ' Dis.F. : Discrimination Factor: A Standard for '. - 'evaluating the problem according to a Criterion
'. - ' [Applied Criterion in %27 Upper Students - '. - 'Applied the same Criterion in %27 Lower Students]
'. - ' 1st Criterion for Sorting the Students: '. - 'Sum of Partial Credit Awarded / Total Number of Tries
'. - ' 2nd Criterion for Sorting the Students: '. - 'Total number of Correct Answers / Total Number of Tries'. - '
'; + $Ptr .= '#Stdnts: | '; + $Ptr .= 'Total Number of Students opened the problem.'; + $Ptr .= ' | ||
'; + $Ptr .= 'Tries: | '; + $Ptr .= 'Total Number of Tries for solving the problem.'; + $Ptr .= ' | ||
'; + $Ptr .= 'Mod: | '; + $Ptr .= 'Maximunm Number of Tries for solving the problem.'; + $Ptr .= ' | ||
'; + $Ptr .= 'Mean: | '; + $Ptr .= 'Average Number of the tries. [ Tries / #Stdnts ]'; + $Ptr .= ' | ||
'; + $Ptr .= '#YES: | '; + $Ptr .= 'Number of students solved the problem correctly.'; + $Ptr .= ' | ||
'; + $Ptr .= '#yes: | '; + $Ptr .= 'Number of students solved the problem by override.'; + $Ptr .= ' | ||
'; + $Ptr .= '%Wrng: | '; + $Ptr .= 'Percentage of students tried to solve the problem '; + $Ptr .= 'but still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]'; + $Ptr .= ' | ||
';
+# Kashy formula
+# ' DoDiff : Degree of Difficulty of the problem. '. +# '[ Tries/(#YES+#yes+0.1) ] '. + #Gerd formula + $Ptr .= 'DoDiff: | ';
+ $Ptr .= 'Degree of Difficulty of the problem. '; + $Ptr .= '[ 1 - ((#YES+#yes) / Tries) ]'; + $Ptr .= ' | ||
'; + $Ptr .= 'S.D.: | '; + $Ptr .= 'Standard Deviation of the tries. '; + $Ptr .= '[ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1) '; + $Ptr .= 'where Xi denotes every student\'s tries ]'; + $Ptr .= ' | ||
'; + $Ptr .= 'Skew.: | '; + $Ptr .= 'Skewness of the students tries.'; + $Ptr .= '[(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]'; + $Ptr .= ' | ||
'; + $Ptr .= 'Dis.F.: | '; + $Ptr .= 'Discrimination Factor: A Standard for evaluating the ';
+ $Ptr .= 'problem according to a Criterion '; + $Ptr .= '[Applied Criterion in %27 Upper Students - '; + $Ptr .= 'Applied the same Criterion in %27 Lower Students] '; + $Ptr .= '1st Criterion for Sorting the Students: '; + $Ptr .= 'Sum of Partial Credit Awarded / Total Number of Tries '; + $Ptr .= '2nd Criterion for Sorting the Students: '; + $Ptr .= 'Total number of Correct Answers / Total Number of Tries'; + $Ptr .= ' | ';
+ $Ptr .= 'Disc. | '; + $Ptr .= 'Number of Students had at least one discussion.'; + $Ptr .= ' |
\# | Problem Title | "; + $Str .= 'Resource | Analysis |
---|---|---|---|
'.$number.' | '; + $Str .= ''.$Temp.' | '; + $Str .= ''.$uri.' | '; + $Str .= '