version 1.77, 2004/03/11 20:11:18
|
version 1.81, 2004/03/16 16:41:26
|
Line 99 sub BuildProblemAnalysisPage {
|
Line 99 sub BuildProblemAnalysisPage {
|
} |
} |
$r->rflush(); |
$r->rflush(); |
# |
# |
my $problem_types = '(option|radiobutton)'; |
my $problem_types = '(option|radiobutton|numerical)'; |
if (exists($ENV{'form.problemchoice'}) && |
if (exists($ENV{'form.problemchoice'}) && |
! exists($ENV{'form.SelectAnother'})) { |
! exists($ENV{'form.SelectAnother'})) { |
foreach my $button (@SubmitButtons) { |
foreach my $button (@SubmitButtons) { |
Line 160 sub BuildProblemAnalysisPage {
|
Line 160 sub BuildProblemAnalysisPage {
|
$ProblemData, |
$ProblemData, |
\@Students); |
\@Students); |
} elsif ($current_problem->{'resptype'} eq 'numerical') { |
} elsif ($current_problem->{'resptype'} eq 'numerical') { |
# if (exists($ENV{'form.ExcelOutput'})) { |
&NumericalResponseAnalysis($r,$current_problem, |
&Apache::lonstudentsubmissions::prepare_excel_output |
$ProblemData,\@Students); |
($r,$current_problem,$ProblemData,\@Students); |
|
# } else { |
|
# &NumericalResponseAnalysis($r,$current_problem, |
|
# $ProblemData,\@Students); |
|
# } |
|
} else { |
} else { |
$r->print('<h2>This analysis is not supported</h2>'); |
$r->print('<h2>This analysis is not supported</h2>'); |
} |
} |
Line 192 sub BuildProblemAnalysisPage {
|
Line 187 sub BuildProblemAnalysisPage {
|
######################################################### |
######################################################### |
sub NumericalResponseAnalysis { |
sub NumericalResponseAnalysis { |
my ($r,$problem,$ProblemData,$Students) = @_; |
my ($r,$problem,$ProblemData,$Students) = @_; |
$r->print('<h2>This analysis is not yet supported</h2>'); |
my $c = $r->connection(); |
my ($resource,$respid) = ($problem->{'resource'}, |
my ($resource,$respid) = ($problem->{'resource'}, |
$problem->{'respid'}); |
$problem->{'respid'}); |
|
$r->print('Response '.$respid.'</br />'); |
my $analysis_html; |
my $analysis_html; |
my $PerformanceData = |
my $PerformanceData = |
&Apache::loncoursedata::get_response_data |
&Apache::loncoursedata::get_response_data |
Line 207 sub NumericalResponseAnalysis {
|
Line 203 sub NumericalResponseAnalysis {
|
$r->print($analysis_html); |
$r->print($analysis_html); |
return; |
return; |
} |
} |
my ($max,$min) = &GetStudentAnswers($r,$problem,$Students); |
# |
$r->print('Maximum = '.$max.' Minimum = '.$min); |
# This next call causes all the waiting around that people complain about |
my $max_students = 0; |
my ($max,$min) = &Apache::lonstathelpers::GetStudentAnswers($r,$problem, |
|
$Students); |
|
return if ($c->aborted()); |
|
# |
|
# Collate the data |
my %Data; |
my %Data; |
foreach my $student (@$Students) { |
foreach my $student (@$Students) { |
my $answer = $student->{'answer'}; |
my $answer = $student->{'answer'}; |
$Data{$answer}++; |
$Data{$answer}++; |
if ($max_students < $Data{$answer}) { |
|
$max_students = $Data{$answer}; |
|
} |
|
} |
|
foreach (5,10,20,25,50,75,100,150,200,250,500,1000,1500,2000,2500,5000) { |
|
if ($max_students < $_) { |
|
$max_students = $_; |
|
last; |
|
} |
|
} |
} |
my @Labels = sort {$a <=> $b } keys(%Data); |
my @Labels = sort {$a <=> $b } keys(%Data); |
$r->print('number of labels = '.scalar(@Labels)); |
|
my @PlotData = @Data{@Labels}; |
my @PlotData = @Data{@Labels}; |
$r->print('number of PlotData = '.scalar(@PlotData)); |
# |
my $graph = |
my $width = 500; |
&Apache::loncommon::DrawXYGraph('Correct Answer Distribution', |
my $height = 100; |
'Correct Answer', |
my $plot = &one_dimensional_plot($r,500,100,scalar(@$Students), |
'Number of students', |
\@Labels,\@PlotData); |
$max_students, |
$r->print($plot); |
undef, |
|
\@Labels, |
|
[\@PlotData], |
|
(xskip=>10)); |
|
$r->print($graph); |
|
return; |
return; |
} |
} |
|
|
sub GetStudentAnswers { |
sub one_dimensional_plot { |
my ($r,$problem,$Students) = @_; |
my ($r,$width,$height,$N,$Labels,$Data)=@_; |
my %Answers; |
# |
my ($resource,$partid,$respid) = ($problem->{'resource'}, |
# Compute data -> image scaling factors |
$problem->{'part'}, |
my $min = $Labels->[0]; |
$problem->{'respid'}); |
my $max = $Labels->[-1]; |
# Open progress window |
my $h_scale = ($width-10)/($max-$min); |
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin |
# |
($r,'Student Answer Compilation Status', |
my $max_y = 0; |
'Student Answer Compilation Progress', scalar(@$Students)); |
foreach (@$Data) { |
$r->print("<table>\n"); |
$max_y = $_ if ($max_y < $_); |
$r->rflush(); |
} |
foreach my $student (@$Students) { |
my $ticscale = 5; |
my $sname = $student->{'username'}; |
if ($max_y * $ticscale > $height/2) { |
my $sdom = $student->{'domain'}; |
$ticscale = int($height/2/$max_y); |
my $answer = &Apache::lonstathelpers::analyze_problem_as_student |
$ticscale = 1 if ($ticscale < 1); |
($resource,$sname,$sdom,$partid,$respid); |
|
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
|
&mt('last student')); |
|
$student->{'answer'} = $answer; |
|
} |
} |
$r->print("</table>\n"); |
# |
$r->rflush(); |
# Create the plot |
# close progress window |
my $plot = |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
qq{<drawimage width="$width" height="$height" bgcolor="transparent" >}; |
return; |
for (my $idx=0;$idx<scalar(@$Labels);$idx++) { |
|
my $xloc = 5+$h_scale*($Labels->[$idx] - $min); |
|
my $top = $height/2-$Data->[$idx]*$ticscale; |
|
my $bottom = $height/2+$Data->[$idx]*$ticscale; |
|
$plot .= |
|
&line($xloc,$top,$xloc,$bottom,'888888',1); |
|
} |
|
# |
|
# Put the scale on last to ensure it is on top of the data. |
|
if ($min < 0 && $max > 0) { |
|
my $circle_x = 5+$h_scale*abs($min); # '0' in data coordinates |
|
my $r = 4; |
|
$plot .= &line(5,$height/2,$circle_x-$r,$height/2,'000000',1); |
|
$plot .= &circle($circle_x,$height/2,$r+1,'000000'); |
|
$plot .= &line($circle_x+$r,$height/2,$width-5,$height/2,'000000',1); |
|
} else { |
|
$plot .= &line(5,$height/2,$width-5,$height/2,'000000',1); |
|
} |
|
$plot .= '</drawimage>'; |
|
my $plotresult = &Apache::lonxml::xmlparse($r,'web',$plot); |
|
|
|
my $title = 'Distribution of correct answers'; |
|
my $result = '<table>'. |
|
'<tr><td colspan="3" align="center">'. |
|
'<font size="+2">'.$title.' (N='.$N.')'. |
|
'</font>'. |
|
'</td></tr>'. |
|
'<tr>'. |
|
'<td valign="center">'.$min.'</td>'. |
|
'<td>'.$plotresult.'</td>'. |
|
'<td valign="center">'.$max.'</td>'. |
|
'</tr>'. |
|
'<tr><td colspan="3" align="center">'. |
|
'Maximum Number of Coinciding Values: '.$max_y. |
|
'</td></tr>'. |
|
'</table>'; |
|
return $result; |
|
} |
|
|
|
## |
|
## Helper subroutines for <drawimage>. |
|
## These should probably go somewhere more suitable soon. |
|
sub line { |
|
my ($x1,$y1,$x2,$y2,$color,$thickness) = @_; |
|
return qq{<line x1="$x1" y1="$y1" x2="$x2" y2="$y2" color="$color" thickness="$thickness" />$/}; |
|
} |
|
|
|
sub rectangle { |
|
my ($x1,$y1,$x2,$y2,$color,$thickness,$filled) = @_; |
|
return qq{<rectangle x1="$x1" y1="$y1" x2="$x2" y2="$y2" color="$color" thickness="$thickness" filled="$filled" />}; |
|
} |
|
|
|
sub arc { |
|
my ($x,$y,$width,$height,$start,$end,$color,$thickness,$filled)=@_; |
|
return qq{<arc x="$x" y="$y" width="$width" height="$height" start="$start" end="$end" color="$color" thickness="$thickness" filled="$filled" />}; |
|
} |
|
|
|
sub circle { |
|
my ($x,$y,$radius,$color,$thickness,$filled)=@_; |
|
return &arc($x,$y,$radius,$radius,0,360,$color,$thickness,$filled); |
} |
} |
|
|
sub build_student_data_worksheet { |
sub build_student_data_worksheet { |
Line 541 sub OR_tries_analysis {
|
Line 581 sub OR_tries_analysis {
|
my $mintries = 1; |
my $mintries = 1; |
my $maxtries = $ENV{'form.NumPlots'}; |
my $maxtries = $ENV{'form.NumPlots'}; |
my ($table,$Foils,$Concepts) = &build_foil_index($ORdata); |
my ($table,$Foils,$Concepts) = &build_foil_index($ORdata); |
if ((@$Concepts < 2) && ($ENV{'form.AnalyzeAs'} ne 'Foils')) { |
if (! defined($Concepts) || |
|
((@$Concepts < 2) && ($ENV{'form.AnalyzeAs'} ne 'Foils'))) { |
$table = '<h3>'. |
$table = '<h3>'. |
&mt('Not enough data for concept analysis. '. |
&mt('Not enough data for concept analysis. '. |
'Performing Foil Analysis'). |
'Performing Foil Analysis'). |