version 1.2, 2002/08/30 17:11:44
|
version 1.11, 2008/12/12 10:01:30
|
Line 1
|
Line 1
|
# The LearningOnline Network with CAPA |
# The LearningOnline Network with CAPA |
# (Publication Handler |
|
# |
# |
# $Id$ |
# $Id$ |
# |
# |
Line 33 use strict;
|
Line 32 use strict;
|
use Apache::lonhtmlcommon; |
use Apache::lonhtmlcommon; |
use Apache::loncoursedata; |
use Apache::loncoursedata; |
use GDBM_File; |
use GDBM_File; |
|
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
|
|
|
|
#my $jr; |
|
|
|
sub BuildPercentageGraph { |
sub BuildPercentageGraph { |
my ($cacheDB, $students, $courseID, $c, $r)=@_; |
my ($cacheDB, $students, $courseID, $c, $r)=@_; |
Line 60 sub BuildPercentageGraph {
|
Line 61 sub BuildPercentageGraph {
|
return; |
return; |
} |
} |
|
|
my ($Ptr, $percentage) = &GraphData(\%cache, $students); |
my ($Ptr, $percentage) = &GraphData(\%cache, $students,$r); |
$r->print($Ptr.'<br><br>'); |
$r->print($Ptr.'<br>'); |
|
|
$r->print(&TableData(\%cache, $percentage)); |
$r->print(&TableData(\%cache, $percentage)); |
|
|
Line 111 sub CreateInterface {
|
Line 112 sub CreateInterface {
|
$Ptr .= '<td align="left">'."\n"; |
$Ptr .= '<td align="left">'."\n"; |
my @sections = split(':',$cache->{'sectionList'}); |
my @sections = split(':',$cache->{'sectionList'}); |
my @sectionsSelected = split(':',$cache->{'sectionsSelected'}); |
my @sectionsSelected = split(':',$cache->{'sectionsSelected'}); |
$Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections, |
$Ptr .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); |
\@sectionsSelected, |
|
'Statistics'); |
|
$Ptr .= '</td></tr>'."\n"; |
$Ptr .= '</td></tr>'."\n"; |
$Ptr .= '</table>'; |
$Ptr .= '</table>'; |
|
|
Line 186 sub InitializeSelectedStudents {
|
Line 185 sub InitializeSelectedStudents {
|
} |
} |
|
|
sub GraphData { |
sub GraphData { |
my ($cache,$students)=@_; |
my ($cache,$students,$r)=@_; |
|
|
my $sequenceSelected = $cache->{'StatisticsMaps'}; |
my $sequenceSelected = $cache->{'StatisticsMaps'}; |
my $problemSelected = $cache->{'StatisticsProblemSelect'}; |
my $problemSelected = $cache->{'StatisticsProblemSelect'}; |
Line 194 sub GraphData {
|
Line 193 sub GraphData {
|
|
|
my %percentages; |
my %percentages; |
my $Ptr = ''; |
my $Ptr = ''; |
|
my $totalProblems = 0; |
|
|
foreach(@$students) { |
foreach(@$students) { |
my $totalCorrect = 0; |
my $totalCorrect = 0; |
my $totalProblems = 0; |
$totalProblems = 0; |
|
|
foreach my $sequence (split(':',$cache->{'orderedSequences'})) { |
foreach my $sequence (split(':',$cache->{'orderedSequences'})) { |
next if($cache->{$sequence.':title'} ne $sequenceSelected && |
next if($cache->{$sequence.':title'} ne $sequenceSelected && |
Line 222 sub GraphData {
|
Line 222 sub GraphData {
|
} |
} |
} |
} |
} |
} |
|
my $percent; |
my $percent = sprintf("%d", ($totalProblems) ? |
if ( $totalProblems >= 100 ) { |
(($totalCorrect/$totalProblems)*100) : 0); |
$percent = sprintf("%d", ($totalProblems) ? |
|
(($totalCorrect/$totalProblems)*100) : 0); |
|
} else { |
|
$percent = sprintf("%d", ($totalProblems) ? $totalCorrect : 0); |
|
} |
if(defined($percentages{$percent})) { |
if(defined($percentages{$percent})) { |
$percentages{$percent} .= ':::'.$_; |
$percentages{$percent} .= ':::'.$_; |
} else { |
} else { |
Line 235 sub GraphData {
|
Line 239 sub GraphData {
|
my @percent = (); |
my @percent = (); |
my @percentCount = (); |
my @percentCount = (); |
my $max = 0; |
my $max = 0; |
foreach my $key (sort(keys(%percentages))) { |
my $pno = 0; |
|
|
|
foreach my $key (sort NumericSort keys(%percentages)) { |
push(@percent, $key); |
push(@percent, $key); |
my @temp = split(':::', $percentages{$key}); |
my @temp = split(':::', $percentages{$key}); |
my $count = scalar(@temp); |
my $count = scalar(@temp); |
Line 243 sub GraphData {
|
Line 249 sub GraphData {
|
$max = $count; |
$max = $count; |
} |
} |
push(@percentCount, $count); |
push(@percentCount, $count); |
|
$pno++; |
} |
} |
|
|
my @GData = ('', 'Percentage', 'Number_of_Students', |
my $cId=0; |
$max, scalar(@percent), |
my @data1=(); |
join(',',@percent), join(',', @percentCount)); |
my @data2=(); |
|
for (my $nIdx=0; $nIdx<$pno; $nIdx++ ) { |
|
$data1[$cId]=$percent[$nIdx]; |
|
$data2[$cId]=$percentCount[$nIdx]; |
|
my $cr=$percent[$nIdx+1]; |
|
while ($data1[$cId]<$cr) { |
|
$cId++; |
|
$data1[$cId]=$cId; |
|
$data2[$cId]=0; |
|
} |
|
} |
|
|
|
my $xlabel; |
|
my $Freq; |
|
if ($totalProblems >= 100 ) { |
|
$xlabel = 'Percentage_of_Problems_Correct'; |
|
$Freq=101; |
|
} else { |
|
$xlabel = 'Number_of_Problems_Correct'; |
|
$Freq = $cId; |
|
} |
|
|
|
# $r->print('<br>Freq='.$Freq); |
|
# $r->print('<br>max='.$max); |
|
# $r->print('<br> percentcount='.join(',', @percentCount)); |
|
# $r->print('<br> percent='.join(',', @percent)); |
|
# $r->print('<br> percentcount='.join(',', @data1)); |
|
# $r->print('<br> percent='.join(',', @data2)); |
|
|
|
my @GData = ("Percentage",$xlabel, |
|
'Number_of_Students',$max,$Freq, |
|
join(',',@data1), join(',', @data2)); |
|
|
$Ptr .= '</form>'."\n"; |
$Ptr .= '</form>'."\n"; |
$Ptr .= '<IMG src="/cgi-bin/graph.gif?'.(join('&', @GData)); |
$Ptr .= '<IMG src="/cgi-bin/graph.png?'.(join('&', @GData)); |
$Ptr .= '" border="1" />'; |
$Ptr .= '" border="1" />'; |
$Ptr .= '<form>'."\n"; |
$Ptr .= '<form>'."\n"; |
|
|
return ($Ptr, \%percentages); |
return ($Ptr, \%percentages); |
} |
} |
|
|
|
sub NumericSort { |
|
$a <=> $b; |
|
} |
|
|
sub TableData { |
sub TableData { |
my($cache,$percentage)=@_; |
my($cache,$percentage)=@_; |
my $Ptr; |
my $Ptr; |
|
|
$Ptr .= '<table border="0"><tr><td bgcolor="#777777">'."\n"; |
$Ptr .= '<table border="0"><tr><td bgcolor="#D7D7D7">'."\n"; |
$Ptr .= '<table border="0" cellpadding="3"><tr bgcolor="#e6ffff">'."\n"; |
$Ptr .= '<table border="0" cellpadding="3"><tr bgcolor="#e6ffff">'."\n"; |
|
|
$Ptr .= '<tr>'."\n"; |
$Ptr .= '<tr>'."\n"; |
$Ptr .= '<td>Percent Correct</td><td>Students</td>'; |
$Ptr .= '<td>% Correct</td>'. |
|
'<td>Frequency</td>'. |
|
'<td>Students</td>'; |
$Ptr .= '</tr>'."\n"; |
$Ptr .= '</tr>'."\n"; |
|
|
my $alternate=0; |
my $alternate=0; |
foreach (sort(keys(%$percentage))) { |
foreach (sort NumericSort keys(%$percentage)) { |
|
|
|
my @temp = split(':::', $percentage->{$_}); |
|
my $count = scalar(@temp); |
|
|
if($alternate) { |
if($alternate) { |
$Ptr .= '<tr bgcolor="#ffffe6">'; |
$Ptr .= '<tr bgcolor="#ffffe6">'; |
} else { |
} else { |
Line 277 sub TableData {
|
Line 325 sub TableData {
|
} |
} |
$alternate = ($alternate + 1) % 2; |
$alternate = ($alternate + 1) % 2; |
|
|
$Ptr .= '<td>'.$_.'</td><td>'; |
$Ptr .= '<td>'.$_.'</td>'; |
|
$Ptr .= '<td>'.$count.'</td><td>'; |
|
|
foreach my $name (sort(split(':::', $percentage->{$_}))) { |
foreach my $name (sort(split(':::', $percentage->{$_}))) { |
$Ptr .= '<a href="/adm/statistics?reportSelected='; |
$Ptr .= '<a href="/adm/statistics?reportSelected='; |
$Ptr .= &Apache::lonnet::escape('Student Assessment'); |
$Ptr .= &escape('Student Assessment'); |
$Ptr .= '&StudentAssessmentStudent='; |
$Ptr .= '&StudentAssessmentStudent='; |
$Ptr .= &Apache::lonnet::escape($cache->{$name.':fullname'}).'">'; |
$Ptr .= &escape($cache->{$name.':fullname'}).'">'; |
$Ptr .= $cache->{$name.':fullname'}; |
$Ptr .= $cache->{$name.':fullname'}; |
$Ptr .= '</a>,  '; |
$Ptr .= '</a>, '; |
} |
} |
|
|
$Ptr .= '</td></tr>'."\n"; |
$Ptr .= '</td></tr>'."\n"; |