';
- $Ptr .= &ProblemStatisticsLegend();
- $r->print($Ptr);
+=item &CreateInterface()
+
+Create the main intereface for the statistics page. Allows the user to
+select sections, maps, and output.
+
+=cut
+
+###############################################
+###############################################
+sub CreateInterface {
+ my $Str = '';
+ $Str .= '
'."\n";
+ return $Str;
+}
+
+#######################################################
+#######################################################
+
+=pod
+
+=item &CreateAndParseOutputSelector()
+
+Construct a selection list of options for output and parse output selections.
+The current output selected is indicated by the values of the two package
+variables $output_mode and $show. @OutputOptions holds the descriptions of
+the output options and the values for $output_mode and $show.
+
+ Based on code from lonstudentassessment.pm.
+
+=cut
+
+#######################################################
+#######################################################
+my $output_mode;
+my $show;
+
+my @OutputOptions =
+ (
+ { name => 'problem statistics grouped by sequence',
+ value => 'HTML problem statistics grouped',
+ description => 'Output statistics for the problem parts.',
+ mode => 'html',
+ show => 'grouped',
+ },
+ { name => 'problem statistics ungrouped',
+ value => 'HTML problem statistics ungrouped',
+ description => 'Output statistics for the problem parts.',
+ mode => 'html',
+ show => 'ungrouped',
+ },
+ { name => 'problem statistics, Excel',
+ value => 'Excel problem statistics',
+ description => 'Output statistics for the problem parts '.
+ 'in an Excel workbook',
+ mode => 'excel',
+ show => 'all',
+ },
+ { name => 'Degree of Difficulty Plot',
+ value => 'plot deg diff',
+ description => 'Generate a plot of the degree of difficulty of each '.
+ 'problem part.',
+ mode => 'plot',
+ show => 'deg of diff',
+ },
+ { name => 'Percent Wrong Plot',
+ value => 'plot per wrong',
+ description => 'Generate a plot showing the percent of students who '.
+ 'were unable to complete each problem part',
+ mode => 'plot',
+ show => 'per wrong',
+ },
+ );
+
+sub OutputDescriptions {
+ my $Str = '';
+ $Str .= "
Output Modes
\n";
+ $Str .= "
\n";
+ foreach my $outputmode (@OutputOptions) {
+ $Str .="
".$outputmode->{'name'}."
\n";
+ $Str .="
".$outputmode->{'description'}."
\n";
+ }
+ $Str .= "
\n";
+ return $Str;
+}
+
+sub CreateAndParseOutputSelector {
+ my $Str = '';
+ my $elementname = 'statsoutputmode';
+ #
+ # Format for output options is 'mode, restrictions';
+ my $selected = 'HTML problem statistics grouped';
+ if (exists($ENV{'form.'.$elementname})) {
+ if (ref($ENV{'form.'.$elementname} eq 'ARRAY')) {
+ $selected = $ENV{'form.'.$elementname}->[0];
+ } else {
+ $selected = $ENV{'form.'.$elementname};
+ }
+ }
+ #
+ # Set package variables describing output mode
+ $output_mode = 'html';
+ $show = 'all';
+ foreach my $option (@OutputOptions) {
+ next if ($option->{'value'} ne $selected);
+ $output_mode = $option->{'mode'};
+ $show = $option->{'show'};
+ }
+ #
+ # Build the form element
+ $Str = qq/";
+ return $Str;
+}
+
+###############################################
+###############################################
+
+=pod
+
+=item &Gather_Student_Data()
+
+Ensures all student data is up to date.
+
+=cut
+
+###############################################
+###############################################
+sub Gather_Student_Data {
+ my ($r) = @_;
+ my $c = $r->connection();
+ #
+ my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
+ #
+ my @Students = @Apache::lonstatistics::Students;
+ #
+ # Open the progress window
+ my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
+ ($r,'Statistics Compilation Status',
+ 'Statistics Compilation Progress', scalar(@Students));
+ #
+ while (my $student = shift @Students) {
+ return if ($c->aborted());
+ my ($status,undef) = &Apache::loncoursedata::ensure_current_data
+ ($student->{'username'},$student->{'domain'},
+ $ENV{'request.course.id'});
+ &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
+ 'last student');
+ }
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
$r->rflush();
+}
- untie(%cache);
- &Create_PrgWin($r);
- my $count=0;
- foreach (@$students) {
- &Update_PrgWin(scalar(@$students),$count,$_,$r);
- my $courseData =
- &Apache::loncoursedata::DownloadCourseInformation($_, $courseID);
- last if ($c->aborted());
- if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {
- &Apache::loncoursedata::ProcessStudentData(\%cache,
- $courseData, $_);
- untie(%cache);
- }
- $count++;
- }
- &Close_PrgWin($r);
- if($c->aborted()) { return; }
-
- unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER,0640)) {
- return 'Unable to tie database.';
- }
-
- 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", 13, "Disc.");
- my $color=&setbgcolor(0);
-
- my $state=$ENV{'form.ProblemStatisticsHeading'};
-
-# my $state=&Apache::lonstatistics::CheckFormElement(\%cache,
-# 'ProblemStatisticsHeading',
-# 'ProblemStatisticsHeading',
-# 'Homework Sets Order');
-# $r->print(" state=".$state);
-
- my $TempCache;
-
- if ($state) {
- $TempCache=&CacheStatisticsTable($state,\%cache,\%Header,
- $r,$color);
- } else {
- my %discriminant=();
- my @list=();
- my %Discuss=&Apache::loncoursedata::LoadDiscussion($courseID);
- my $index=0;
- foreach (@$students) {
- $index++;
- #&Apache::lonstatistics::Update_PrgWin(++$index,$r);
- &ExtractStudentData(\%cache, $_, \@list,\%Discuss, $r,
- \%discriminant);
- }
- #&Apache::lonstatistics::Close_PrgWin($r);
- my ($upper, $lower) = &Discriminant(\%discriminant,$r);
- $TempCache= &BuildStatisticsTable(\%cache, $upper, $lower,
- \@list, \%Header, $students,
- $r, $color);
- }
- untie(%cache);
+###############################################
+###############################################
- foreach (keys %$TempCache) {
- last if ($c->aborted());
- if(tie(%cache,'GDBM_File',$cacheDB,&GDBM_WRCREAT,0640)) {
- $cache{$_}=$TempCache->{$_};
+=pod
- untie(%cache);
- }
- }
- if($c->aborted()) { return; }
- untie(%cache);
-}
+=item &BuildProblemStatisticsPage()
+Main interface to problem statistics.
-#---- Problem Statistics Web Page ---------------------------------------
+=cut
-sub CreateProblemStatisticsTableHeading {
- my ($displayFormat,$sequenceSource,$sequenceTitle,$headings,$r)=@_;
- if($displayFormat eq 'Display CSV Format') {
- $r->print(' "'.$sequenceTitle.'","');
- $r->print($sequenceSource.'"');
- return;
- }
- if ($sequenceSource eq 'Sorted by: ') {
- $r->print(' '.$sequenceSource.$sequenceTitle.'');
+###############################################
+###############################################
+sub BuildProblemStatisticsPage {
+ my ($r,$c)=@_;
+ #
+ $output_mode = 'html';
+ $show = 'grouped';
+ #
+ $r->print(&CreateInterface());
+ $r->print('');
+ $r->print('');
+ if (! exists($ENV{'form.statsfirstcall'})) {
+ $r->print(<
+
+Please make your selections in the boxes above and hit
+the button marked "Update Display".
+
+
+ENDMSG
+ return;
+ }
+ #
+ &Gather_Student_Data($r);
+ #
+ #
+ if ($output_mode eq 'html') {
+ $r->print("
'+
- ''+
- '');
- popwin.document.close();
-
-ENDPOP
+=item &output_html_grouped_by_sequence()
- $r->rflush();
+Presents the statistics data as an html table organized by the order
+the assessments appear in the course.
+
+=cut
+
+###############################################
+###############################################
+sub output_html_grouped_by_sequence {
+ my ($r) = @_;
+ my $problem_num = 0;
+ #$r->print(&ProblemStatisticsLegend());
+ my @Header = ("Title","Part","#Stdnts","Tries","Mod",
+ "Mean","#YES","#yes","%Wrng","DoDiff",
+ "S.D.","Skew.");#,"D.F.1st","D.F.2nd");
+ # #FFFFE6 #EEFFCC #DDFFFF FFDDDD #DDFFDD #FFDDFF
+ foreach my $sequence (&Apache::lonstatistics::Sequences_with_Assess()) {
+ next if ($sequence->{'num_assess'}<1);
+ $r->print("
".$sequence->{'title'}."
");
+ $r->print('
'."\n");
+ $r->print('
'."\n");
+ $r->print('
'.
+ join("
",@Header)."
\n");
+ foreach my $resource (@{$sequence->{'contents'}}) {
+ next if ($resource->{'type'} ne 'assessment');
+ foreach my $part (@{$resource->{'parts'}}) {
+ $problem_num++;
+ my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
+ $SKEW) = &get_statistics($resource->{'symb'},$part);
+ #
+ $part = ' ' if ($part == 0);
+ #
+ my $wrongpercent = 0;
+ if (defined($num) && $num > 0) {
+ $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
+ }
+ my $option = '';
+ $r->print('
\n");
+ $r->rflush();
+ }
+ #
+ return;
}
-# update progress
-sub Update_PrgWin {
- my ($totalStudents,$index,$name,$r)=@_;
- $r->print('');
- $r->rflush();
-}
+###############################################
+###############################################
-# close Progress Line
-sub Close_PrgWin {
- my ($r)=@_;
- $r->print('');
- $r->rflush();
-}
-
-
-# ------ Dump the Student's DB file and handling the data for statistics table
-sub ExtractStudentData {
- my ($cache,$name,$list,$Discuss,$r,$discriminant)=@_;
- my $totalTries = 0;
- my $totalAwarded = 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;
- my $discrim='';
- my $tempSequenceOrder=100;
-
-#$Apache::lonxml::debug=1;
-#&Apache::lonhomework::showhash(%$cache);
-#$Apache::lonxml::debug=0;
-
- foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
- my $tempProblemOrder=100;
- if($cache->{'ProblemStatisticsMaps'} ne 'All Maps' &&
- $cache->{'ProblemStatisticsMaps'} ne $cache->{$sequence.':title'}) {
-# $r->print(" sequences=$cache->{'orderedSequences'}");
-# $r->print(" ".$cache->{$sequence.':title'});
- next;
- }
- $tempSequenceOrder++;
-
- #$discrim .= '&';
- foreach my $problemID (split(':', $cache->{$sequence.':problems'})) {
-# $r->print(" problems=$cache->{$sequence.':problems'}");
- my $problem = $cache->{$problemID.':problem'};
-# $r->print(" $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;
- $partData{'count'}=0;
- # 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'})) {
- $tempProblemOrder++;
- $partData{'count'}++;
-# $r->print(" parts=$cache->{$sequence.':'.$problemID.':parts'}");
- $partData{$part.':order'}=$tempProblemOrder;
- $partData{$part.':tries'}=0;
- $partData{$part.':code'}='-';
- }
+=pod
- # 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;
- }
+=item &output_html_ungrouped()
- my $tries=0;
- my $time=0;
- my $awarded=0;
- $Discussed=0;
- my $code='-';
-
- $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'}--;
- }
+Presents the statistics data in a single html table which can be sorted by
+different columns.
+
+=cut
+
+###############################################
+###############################################
+sub output_html_ungrouped {
+ my ($r,$option) = @_;
+ #
+ my $problem_num = 0;
+ my $show_container = 0;
+ my $show_part = 0;
+ #$r->print(&ProblemStatisticsLegend());
+ my @Header = ("Title","Part","#Stdnts","Tries","Mod",
+ "Mean","#YES","#yes","%Wrng","DoDiff",
+ "S.D.","Skew");#,"D.F.1st","D.F.2nd");
+ #
+ my $sortby = undef;
+ foreach (@Header) {
+ if ($ENV{'form.sortby'} eq $_) {
+ $sortby = $_;
+ }
+ }
+ if (! defined($sortby) || $sortby eq '') {
+ $sortby = 'Container';
+ }
+ # If there is more than one sequence, list their titles
+ my @Sequences = &Apache::lonstatistics::Sequences_with_Assess();
+ if (@Sequences > 1) {
+ unshift(@Header,"Container");
+ $show_container = 1;
+ }
+ #
+ # If the option for showing the problem number is needed, push that
+ # on the list too
+ if (defined($option) && $option =~ /show probnum/) {
+ unshift(@Header,"P#");
+ }
+ #
+ $r->print('
'."\n");
+ $r->rflush();
+ #
+ # Compile the data
+ my @Statsarray;
+ foreach my $sequence (@Sequences) {
+ next if ($sequence->{'num_assess'}<1);
+ foreach my $resource (@{$sequence->{'contents'}}) {
+ next if ($resource->{'type'} ne 'assessment');
+ foreach my $part (@{$resource->{'parts'}}) {
+ $problem_num++;
+ my ($num,$tries,$mod,$mean,$Solved,$solved,$DegOfDiff,$STD,
+ $SKEW) = &get_statistics($resource->{'symb'},$part);
+ #
+ $show_part = 1 if ($part ne '0');
+ $part = ' ' if ($part == 0);
+ #
+ my $wrongpercent = 0;
+ if (defined($num) && $num > 0) {
+ $wrongpercent=int(10*100*($num-$Solved+$solved)/$num)/10;
}
+ push (@Statsarray,
+ { 'sequence' => $sequence,
+ 'resource' => $resource,
+ 'Title' => $resource->{'title'},
+ 'Part' => $part,
+ '#Stdnts' => $num,
+ 'Tries' => $tries,
+ 'Mod' => $mod,
+ 'Mean' => $mean,
+ '#YES' => $Solved,
+ '#yes' => $solved,
+ '%Wrng' => $wrongpercent,
+ 'DoDiff' => $DegOfDiff,
+ 'S.D.' => $STD,
+ 'Skew' => $SKEW,
+ 'problem_num' => $problem_num,
+ });
}
-
-#$Apache::lonxml::debug=1;
-#&Apache::lonhomework::showhash(%partData);
-#$Apache::lonxml::debug=0;
-
- # Loop through all the parts for the current problem in the
- # correct order and prepare the output
- my $partCounter=0;
- foreach (split(/\:/,$cache->{$sequence.':'.$problemID.
- ':parts'})) {
- $partCounter++;
- my $Yes = 0;
- if($partData{$_.':code'} eq 'C' ||
- $partData{$_.':code'} eq 'O') {
- $Yes=1;
+ }
+ }
+ #
+ # Table Headers
+ $r->print('
'."\n");
+ my $Str = '';
+ foreach (@Header) {
+ next if ($_ eq 'Part' && !$show_part);
+ # Do not allow sorting on some fields
+ if ($_ eq $sortby || /^(Part|P\#)$/) {
+ $Str .= '
\n");
+ #
+ # Print out the data
+ $ENV{'form.sortby'} = 'Contents';
+ &output_html_ungrouped($r,'show probnum');
+ return;
}
+###############################################
+###############################################
-sub CacheStatisticsTable {
- my ($state,$cache,$headings,$r,$color)=@_;
- my @list = ();
- my %TempCache;
- my %myHeader = reverse( %$headings );
- my $pos = $myHeader{$state};
- if ($pos > 0) {$pos++;}
- my $p_count = $cache->{'ProblemCount'};
-
- for ( my $k=0; $k<$p_count;$k++) {
- my $key=$cache->{'CacheTable:'.$k};
- my @Temp=split(/\&/,$key);
- $list[$k]=$Temp[$pos].'+'.$key;
- }
-
- if ($pos>0) {
-# $r->print(' pos1='.$pos);
- @list = sort OrderedSort (@list);
- } else {
- @list = sort (@list);
- }
- my $cIdx=0;
+=pod
- if ( $pos == 0 ) {
- foreach my $sequence (split(':', $cache->{'orderedSequences'})) {
- if($cache->{'ProblemStatisticsMaps'} ne 'All Maps' &&
- $cache->{'ProblemStatisticsMaps'} ne $cache->{$sequence.':title'}) {
- next;
- }
- if ($cIdx==$p_count) {
- return \%TempCache;
- }
- &CreateProblemStatisticsTableHeading($cache->{'DisplayFormat'},
- $cache->{$sequence.':source'},
- $cache->{$sequence.':title'},
- $headings,$r);
-
- my ($tar)=split(/\&/,$list[$cIdx]);
- $tar=~s/\+//eg;
- my ($SqOrd)=split(/\@/,$tar);
- $sequence+=100;
- while ($SqOrd==$sequence && $cIdx<$p_count) {
- my($Pre, $Post) = split(/\+/,$list[$cIdx]);
- &TableRow($cache,$Post,$cIdx,$cIdx,$r,$color,\%TempCache);
- $cIdx++;
- my ($tar)=split(/\&/,$list[$cIdx]);
- $tar=~s/\+//eg;
- ($SqOrd)=split(/\@/,$tar);
+=item &DrawGraph()
+
+=cut
+
+###############################################
+###############################################
+sub DrawGraph {
+ my ($values,$title,$xaxis,$yaxis,$Max)=@_;
+ $title = '' if (! defined($title));
+ $xaxis = '' if (! defined($xaxis));
+ $yaxis = '' if (! defined($yaxis));
+ #
+ my $sendValues = join(',', @$values);
+ my $sendCount = scalar(@$values);
+ if ( $Max > 1 ) {
+ if ($Max % 10) {
+ if ( int($Max) < $Max ) {
+ $Max++;
+ $Max = int($Max);
}
- &CloseTable($cache,$r);
}
+ } else {
+ $Max = 1;
}
- else {
- &CreateProblemStatisticsTableHeading($cache->{'DisplayFormat'},
- 'Sorted by: ',
- $headings->{$pos-1},
- $headings,$r);
- for ( my $nIndex = 0; $nIndex < $p_count; $nIndex++ ) {
- my($Pre, $Post) = split(/\+/,$list[$nIndex]);
- &TableRow($cache,$Post,$nIndex,$nIndex,$r,$color,\%TempCache);
- }
- &CloseTable($cache,$r);
- }
-
- return \%TempCache;
+ my @GData = ($title,$xaxis,$yaxis,$Max,$sendCount,$sendValues);
+ return '';
}
-
-sub TableRow {
- my ($cache,$Str,$Idx,$RealIdx,$r,$color,$GraphDat)=@_;
- my($PrOrd,$Temp,$StdNo,$TotalTries,$MxTries,$Avg,$YES,$Override,
- $Wrng,$DoD,$SD,$Sk,$_D1,$_D2,$DiscNo,$Prob)=split(/\&/,$Str);
- my $Ptr;
- if($cache->{'DisplayFormat'} eq 'Display CSV Format') {
- my ($ResId,$Dummy)=split(/\*/,$Prob);
- $Ptr="\n".' '.
- "\n".'"'.($RealIdx+1).'",'.
- "\n".'"'.$cache->{$ResId.':title'}.$Dummy.'",'.
- "\n".'"'.$cache->{$ResId.':source'}.'",'.
- "\n".'"'.$StdNo.'",'.
- "\n".'"'.$TotalTries.'",'.
- "\n".'"'.$MxTries.'",'.
- "\n".'"'.$Avg.'",'.
- "\n".'"'.$YES.'",'.
- "\n".'"'.$Override.'",'.
- "\n".'"'.$Wrng.'",'.
- "\n".'"'.$DoD.'",'.
- "\n".'"'.$SD.'",'.
- "\n".'"'.$Sk.'",'.
- "\n".'"'.$_D1.'",'.
- "\n".'"'.$_D2.'"'.
- "\n".'"'.$DiscNo.'"';
-
- $r->print("\n".$Ptr);
- } else {
- $Ptr="\n".'
'.
- "\n".'
'.($RealIdx+1).'
'.
- "\n".'
'.$Temp.'
'.
- "\n".'
'.$StdNo.'
'.
- "\n".'
'.$TotalTries.'
'.
- "\n".'
'.$MxTries.'
'.
- "\n".'
'.$Avg.'
'.
- "\n".'
'.$YES.'
'.
- "\n".'
'.$Override.'
'.
- "\n".'
'.$Wrng.'
'.
- "\n".'
'.$DoD.'
'.
- "\n".'
'.$SD.'
'.
- "\n".'
'.$Sk.'
'.
- "\n".'
'.$_D1.'
'.
- "\n".'
'.$_D2.'
'.
- "\n".'
'.$DiscNo.'
';
- $r->print("\n".$Ptr.'
' );
- }
- $GraphDat->{'GraphGif:'.$RealIdx}=$DoD.':'.$Wrng;
+sub get_statistics {
+ my ($symb,$part) = @_;
+ #
+ my $courseid = $ENV{'request.course.id'};
+ #
+ my $students = \@Apache::lonstatistics::Students;
+ if ($Apache::lonstatistics::SelectedSections[0] eq 'all') {
+ $students = undef;
+ }
+ my @Results = &Apache::loncoursedata::get_problem_statistics
+ ($students,$symb,$part,$courseid);
+ return @Results;
}
+###############################################
+###############################################
-# For loading the colored table for display or un-colored for print
-sub setbgcolor {
- my $PrintTable=shift;
- my %color;
- if ($PrintTable){
- $color{"gb"}="#FFFFFF";
- $color{"red"}="#FFFFFF";
- $color{"yellow"}="#FFFFFF";
- $color{"green"}="#FFFFFF";
- $color{"purple"}="#FFFFFF";
- } else {
- $color{"gb"}="#DDFFFF";
- $color{"red"}="#FFDDDD";
- $color{"yellow"}="#EEFFCC";
- $color{"green"}="#DDFFDD";
- $color{"purple"}="#FFDDFF";
- }
-
- return \%color;
-}
-
-sub ProblemStatisticsButtons {
- my ($displayFormat)=@_;
-
- my $Ptr = '
';
- $Ptr .= '';
$Ptr .= '
';
$Ptr .= '#Stdnts
';
- $Ptr .= '
Total Number of Students opened the problem.';
+ $Ptr .= '
Total number of students attempted the problem.';
$Ptr .= '
';
$Ptr .= 'Tries
';
- $Ptr .= '
Total Number of Tries for solving the problem.';
+ $Ptr .= '
Total number of tries for solving the problem.';
$Ptr .= '
';
$Ptr .= 'Mod
';
- $Ptr .= '
Maximunm Number of Tries for solving the problem.';
+ $Ptr .= '
Largest number of tries for solving the problem by a student.';
$Ptr .= '
';
$Ptr .= 'Mean
';
- $Ptr .= '
Average Number of the tries. [ Tries / #Stdnts ]';
+ $Ptr .= '
Average number of tries. [ Tries / #Stdnts ]';
$Ptr .= '
';
$Ptr .= '#YES
';
$Ptr .= '
Number of students solved the problem correctly.';
@@ -789,9 +886,9 @@ sub ProblemStatisticsLegend {
$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 .= '%Wrong
';
+ $Ptr .= '
Percentage of students who tried to solve the problem ';
+ $Ptr .= 'but is still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]';
$Ptr .= '
';
$Ptr .= 'DoDiff
';
$Ptr .= '
Degree of Difficulty of the problem. ';
@@ -809,8 +906,8 @@ sub ProblemStatisticsLegend {
$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 .= '[Criterion to group students into %27 Upper Students - ';
+ $Ptr .= 'and %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: ';
@@ -819,152 +916,10 @@ sub ProblemStatisticsLegend {
$Ptr .= '
Disc.
';
$Ptr .= '
Number of Students had at least one discussion.';
$Ptr .= '
';
-
return $Ptr;
}
-#------- Processing upperlist and lowerlist according to each problem
-sub ProcessDiscriminant {
- my ($List,$r) = @_;
- my @sortedList = sort (@$List);
- my $Count = scalar @sortedList;
- my $Problem;
- my @Dis;
- my $Slvd=0;
- my $tmp;
- my $Sum1=0;
- my $Sum2=0;
- my $nIndex=0;
- my $nStudent=0;
- my %Proc=undef;
- while ($nIndex<$Count) {
-# $r->print(" $nIndex) $sortedList[$nIndex]");
- ($Problem,$tmp)=split(/\=/,$sortedList[$nIndex]);
- @Dis=split(/\+/,$tmp);
- my $Temp = $Problem;
- do {
- $nIndex++;
- $nStudent++;
- $Sum1 += $Dis[0];
- $Sum2 += $Dis[1];
- ($Problem,$tmp)=split(/\=/,$sortedList[$nIndex]);
- @Dis=split(/\+/,$tmp);
- } while ( $Problem eq $Temp && $nIndex < $Count );
- $Proc{$Temp}=($Sum1/$nStudent).':'.($Sum2/$nStudent);
-# $r->print(" $nIndex) $Temp --> ($nStudent) $Proc{$Temp}");
- $Sum1=0;
- $Sum2=0;
- $nStudent=0;
- }
-
- return %Proc;
-}
-
-#------- Creating Discimination factor
-sub Discriminant {
- my ($discriminant,$r)=@_;
-#$Apache::lonxml::debug=1;
-#&Apache::lonhomework::showhash(%$discriminant);
-#$Apache::lonxml::debug=0;
- my @discriminantKeys=keys(%$discriminant);
- my $Count = scalar @discriminantKeys;
-
- my $UpCnt = int(0.27*$Count);
- my $low=0;
- my $up=$Count-$UpCnt;
- my @UpList=();
- my @LowList=();
-
- $Count=0;
- foreach my $key (sort(@discriminantKeys)) {
- $Count++;
- if($low < $UpCnt || $Count > $up) {
- $low++;
- my $str=$discriminant->{$key};
- foreach(split(/\&/,$str)){
- if($_) {
- if($low<$UpCnt) { push(@LowList,$_); }
- else { push(@UpList,$_); }
- }
- }
- }
- }
- my %DisUp = &ProcessDiscriminant(\@UpList,$r);
- my %DisLow = &ProcessDiscriminant(\@LowList,$r);
-
- return (\%DisUp, \%DisLow);
-}
-
#---- END Problem Statistics Web Page ----------------------------------------
-#---- Problem Statistics Graph Web Page --------------------------------------
-
-# ------------------------------------------- Prepare data for Graphical chart
-
-sub BuildDiffGraph {
- my ($r)=@_;
-
- my $graphData = &GetGraphData('DiffGraph', $r);
- $r->print('');
-
- return;
-}
-
-sub BuildWrongGraph {
- my ($r)=@_;
-
- my $graphData = &GetGraphData('WrongGraph', $r);
- $r->print('');
-
- return;
-}
-
-
-sub GetGraphData {
- my ($ylab,$r,$cache)=@_;
- my $Col;
- my $data='';
- my $count = 0;
- my $Max = 0;
- my $cid=$ENV{'request.course.id'};
-
- if ( $ylab eq 'DoDiff Graph' ) {
- $ylab = 'Degree-of-Difficulty';
- $Col = 0;
- }
- else {
- $ylab = 'Wrong-Percentage';
- $Col = 1;
- }
-
- my $p_count = $cache->{'ProblemCount'};
-
- for ( my $k=0; $k<$p_count;$k++) {
- my $key=$cache->{'CacheTable:'.$k};
- my @Temp=split(/\&/,$key);
- # $list[$k]=$key;
- }
-
- # foreach (sort NumericSort keys %GraphDat) {
- # my @Temp=split(/\:/,$GraphDat{$_});
- # my $inf = $Temp[$Col];
- # if ( $Max < $inf ) {$Max = $inf;}
- # $data .= $inf.',';
- # $count++;
- # }
- if ( $Max > 1 ) {
- $Max += (10 - $Max % 10);
- $Max = int($Max);
- } else { $Max = 1; }
-
- #untie(%GraphDat);
-
- my $Course = $ENV{'course.'.$cid.'.description'};
- $Course =~ s/\ /"_"/eg;
- my $GData=$Course.'&'.'Problems'.'&'.$ylab.'&'.
- $Max.'&'.$count.'&'.$data;
-}
-
-
1;
__END__