version 1.5, 2004/02/03 16:28:55
|
version 1.11, 2004/06/04 21:42:18
|
Line 39 use Apache::lonlocal;
|
Line 39 use Apache::lonlocal;
|
my @SubmitButtons = ( |
my @SubmitButtons = ( |
{ name => 'CreatePlot', |
{ name => 'CreatePlot', |
text => 'Create Plot' }, |
text => 'Create Plot' }, |
{ name => 'ClearCache', |
|
text => 'Clear Caches' }, |
|
{ name => 'updatecaches', |
|
text => 'Update Student Data' }, |
|
); |
); |
|
|
######################################################### |
######################################################### |
Line 71 sub BuildCorrectProblemsPage {
|
Line 67 sub BuildCorrectProblemsPage {
|
# |
# |
&Apache::lonstatistics::PrepareClasslist(); |
&Apache::lonstatistics::PrepareClasslist(); |
# |
# |
$r->print('<h2>'.&mt('Number of Correct Problems Plot').'</h2>'); |
|
$r->print(&CreateInterface()); |
$r->print(&CreateInterface()); |
# |
# |
my @Students = @Apache::lonstatistics::Students; |
my @Students = @Apache::lonstatistics::Students; |
Line 82 sub BuildCorrectProblemsPage {
|
Line 77 sub BuildCorrectProblemsPage {
|
'</h2>'); |
'</h2>'); |
} |
} |
# |
# |
&Apache::loncoursedata::clear_internal_caches(); |
my @CacheButtonHTML = |
if (exists($ENV{'form.ClearCache'}) || |
&Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status'); |
exists($ENV{'form.updatecaches'}) || |
|
(exists($ENV{'form.firstanalysis'}) && |
|
$ENV{'form.firstanalysis'} ne 'no')) { |
|
&Apache::lonstatistics::Gather_Full_Student_Data($r); |
|
} |
|
if (! exists($ENV{'form.firstanalysis'})) { |
|
$r->print('<input type="hidden" name="firstanalysis" value="yes" />'); |
|
} else { |
|
$r->print('<input type="hidden" name="firstanalysis" value="no" />'); |
|
} |
|
foreach my $button (@SubmitButtons) { |
foreach my $button (@SubmitButtons) { |
$r->print('<input type="submit" name="'.$button->{'name'}.'" '. |
$r->print('<input type="submit" name="'.$button->{'name'}.'" '. |
'value="'.&mt($button->{'text'}).'" />'); |
'value="'.&mt($button->{'text'}).'" />'); |
$r->print(' 'x5); |
$r->print(' 'x5); |
} |
} |
|
foreach my $html (@CacheButtonHTML) { |
|
$r->print($html.(' 'x5)); |
|
} |
$r->rflush(); |
$r->rflush(); |
# |
# |
# Determine which problem symbs we are to sum over |
# Determine which problem symbs we are to sum over |
if (exists($ENV{'form.CreatePlot'})) { |
if (exists($ENV{'form.CreatePlot'})) { |
my @ProblemSymbs; |
my @ProblemSymbs; |
|
my $total_parts = 0; |
|
my $title = ''; |
if ($Apache::lonstatistics::SelectedMaps[0] ne 'all') { |
if ($Apache::lonstatistics::SelectedMaps[0] ne 'all') { |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()){ |
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()){ |
|
if ($title eq '') { |
|
$title = $seq->{'title'}; |
|
} else { |
|
$title = 'Multiple Sequences'; |
|
} |
foreach my $res (@{$seq->{'contents'}}) { |
foreach my $res (@{$seq->{'contents'}}) { |
next if ($res->{'type'} ne 'assessment'); |
next if ($res->{'type'} ne 'assessment'); |
foreach my $part (@{$res->{'parts'}}) { |
foreach my $part (@{$res->{'parts'}}) { |
|
$total_parts++; |
push(@ProblemSymbs,{symb=>$res->{'symb'}, |
push(@ProblemSymbs,{symb=>$res->{'symb'}, |
part=>$part}); |
part=>$part}); |
} |
} |
} |
} |
} |
} |
} |
} |
|
my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); |
|
if (defined($starttime) || defined($endtime)) { |
|
# Inform the user what the time limits on the data are. |
|
$r->print(&mt('Statistics on submissions from [_1] to [_2]', |
|
&Apache::lonlocal::locallocaltime($starttime), |
|
&Apache::lonlocal::locallocaltime($endtime))); |
|
} |
my $score_data = &Apache::loncoursedata::get_student_scores |
my $score_data = &Apache::loncoursedata::get_student_scores |
(\@Apache::lonstatistics::SelectedSections, |
(\@Apache::lonstatistics::SelectedSections, |
\@ProblemSymbs, |
\@ProblemSymbs, |
$Apache::lonstatistics::enrollment_status); |
$Apache::lonstatistics::enrollment_status,undef, |
$r->print(&AnalyzeScoreData($score_data)); |
$starttime,$endtime); |
|
$r->print(&AnalyzeScoreData($score_data,$title,$total_parts)); |
|
} else { |
|
$r->print('<h3>'.&mt('Make a sequence selection from the "Sequences and Folders" menu and hit "Create Plot" to begin').'</h3>'); |
} |
} |
return; |
return; |
} |
} |
Line 139 return html with a plot of the data and
|
Line 145 return html with a plot of the data and
|
######################################################### |
######################################################### |
######################################################### |
######################################################### |
sub AnalyzeScoreData { |
sub AnalyzeScoreData { |
my ($score_data) = @_; |
my ($score_data,$title,$total_parts) = @_; |
# |
# |
# Basic check first |
# Basic check first |
if (@$score_data < 1) { |
if (@$score_data < 1) { |
Line 150 sub AnalyzeScoreData {
|
Line 156 sub AnalyzeScoreData {
|
my $lowest = $score_data->[0]->[0]; |
my $lowest = $score_data->[0]->[0]; |
$lowest = 0; |
$lowest = 0; |
my $highest = $score_data->[-1]->[0]; |
my $highest = $score_data->[-1]->[0]; |
|
&Apache::lonnet::logthis('highest = '.$highest); |
my $binsize = 1; |
my $binsize = 1; |
if ($highest > 50) { $binsize = 2; } |
if ($highest > 50) { $binsize = 2; } |
if ($highest > 100) { $binsize = 5; } |
if ($highest > 100) { $binsize = 5; } |
Line 161 sub AnalyzeScoreData {
|
Line 168 sub AnalyzeScoreData {
|
# Get the data into the bins (destroying $score_data in the process) |
# Get the data into the bins (destroying $score_data in the process) |
my @Bins = &bin_data($score_data,$binsize,$lowest,$highest); |
my @Bins = &bin_data($score_data,$binsize,$lowest,$highest); |
my @Xdata; my @Ydata; my $max; |
my @Xdata; my @Ydata; my $max; |
my $Str = '<table border="1">'."\n".'<tr><th>Range</th><th>Count</th></tr>'."\n"; |
my $Str = |
|
'<table border="1">'."\n".'<tr><th>Range</th><th>Count</th></tr>'."\n"; |
|
my $sum = 0; |
while (my $bin = shift(@Bins)) { |
while (my $bin = shift(@Bins)) { |
push (@Xdata,$bin->{'start'}); |
push (@Xdata,$bin->{'start'}); |
push (@Ydata,$bin->{'count'}); |
push (@Ydata,$bin->{'count'}); |
|
$sum += $bin->{'count'}; |
if ($bin->{'count'} > $max) { |
if ($bin->{'count'} > $max) { |
$max = $bin->{'count'}; |
$max = $bin->{'count'}; |
} |
} |
Line 173 sub AnalyzeScoreData {
|
Line 183 sub AnalyzeScoreData {
|
} |
} |
# scale max to an integer. |
# scale max to an integer. |
$max = 5*(int($max/5)+1); |
$max = 5*(int($max/5)+1); |
my $title = 'Correct Problems Plot'; |
|
$Str .= "</table><br />\n"; |
$Str .= "</table><br />\n"; |
$Str = "<br />\n".&Apache::loncommon::DrawBarGraph($title, |
$title = &HTML::Entities::decode($title); |
'Num Correct Problems', |
$Str = "\n<p>".&Apache::loncommon::DrawBarGraph($title.' N = '.$sum, |
|
'Num Correct Problems (max:'.$total_parts.')', |
'Number of students', |
'Number of students', |
$max, |
$max, |
undef, # colors |
undef, # colors |
\@Xdata, |
\@Xdata, |
\@Ydata). |
\@Ydata). |
"\n<br />\n".$Str; |
"\n<br />\n".$Str; |
|
$Str .= '</p>'."\n"; |
return $Str; |
return $Str; |
} |
} |
|
|
Line 219 sub bin_data {
|
Line 230 sub bin_data {
|
my @Bins; |
my @Bins; |
my $count=0; |
my $count=0; |
my $idx=0; |
my $idx=0; |
while ($idx < scalar(@$data) && ($binend-$endbin)<$binsize) { |
while ($idx < scalar(@$data) && ($endbin-$binend + $binsize)>0) { |
my $dataset = $data->[$idx++]; |
my $dataset = $data->[$idx++]; |
my ($x,$y) = @{$dataset}; |
my ($x,$y) = @{$dataset}; |
while ($x > $binend) { |
while ($x > ($binend-.001)) { |
# store the old data |
# store the old data |
push (@Bins,{ start => $binstart, |
push (@Bins,{ start => $binstart, |
count => $count, |
count => $count, |
Line 234 sub bin_data {
|
Line 245 sub bin_data {
|
} |
} |
$count+=$y; |
$count+=$y; |
} |
} |
|
if ($count > 0) { |
|
push (@Bins,{ start => $binstart, |
|
count => $count, |
|
end => $binend }); |
|
} |
return @Bins; |
return @Bins; |
} |
} |
|
|
Line 256 sub CreateInterface {
|
Line 272 sub CreateInterface {
|
## |
## |
## Environment variable initialization |
## Environment variable initialization |
my $Str; |
my $Str; |
|
$Str .= &Apache::lonhtmlcommon::breadcrumbs |
|
(undef,'Correct Problems Plot'); |
|
$Str .= '<p>'; |
|
# |
$Str .= '<table cellspacing="5">'."\n"; |
$Str .= '<table cellspacing="5">'."\n"; |
$Str .= '<tr>'; |
$Str .= '<tr>'; |
$Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Sections').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Enrollment Status').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Sequences and Folders').'</b></td>'; |
$Str .= '<td align="center"><b>'.&mt('Sequences and Folders').'</b></td>'; |
|
$Str .= '<td rowspan="2">'. |
|
&Apache::lonstathelpers::limit_by_time_form().'</td>'; |
$Str .= '</tr>'."\n"; |
$Str .= '</tr>'."\n"; |
## |
# |
## |
|
$Str .= '<tr><td align="center">'."\n"; |
$Str .= '<tr><td align="center">'."\n"; |
$Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); |
$Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); |
$Str .= '</td>'; |
$Str .= '</td>'; |
Line 282 sub CreateInterface {
|
Line 303 sub CreateInterface {
|
}; |
}; |
$Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, |
$Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, |
$only_seq_with_assessments); |
$only_seq_with_assessments); |
$Str .= '</td><td>'."\n"; |
$Str .= '</td>'; |
## |
# |
$Str .= '</tr>'."\n"; |
$Str .= '</tr>'."\n"; |
$Str .= '</table>'."\n"; |
$Str .= '</table>'."\n"; |
|
# |
|
$Str .= '<nobr>'.&mt('Status: [_1]', |
|
'<input type="text" '. |
|
'name="stats_status" size="60" value="" />'). |
|
'</nobr>'.'</p>'; |
|
## |
return $Str; |
return $Str; |
} |
} |
|
|