--- loncom/interface/statistics/lonproblemanalysis.pm 2004/02/16 19:59:49 1.67
+++ loncom/interface/statistics/lonproblemanalysis.pm 2004/02/16 20:50:03 1.68
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.67 2004/02/16 19:59:49 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.68 2004/02/16 20:50:03 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -185,6 +185,7 @@ sub BuildProblemAnalysisPage {
#########################################################
sub NumericalResponseAnalysis {
my ($r,$problem,$ProblemData,$Students) = @_;
+ $r->print('
This analysis is not yet supported
');
my ($resource,$respid) = ($problem->{'resource'},
$problem->{'respid'});
my $analysis_html;
@@ -199,9 +200,38 @@ sub NumericalResponseAnalysis {
$r->print($analysis_html);
return;
}
- my $Answers = &GetStudentAnswers($r,$problem,$Students);
-
- $r->print('This analysis is not yet supported
');
+ my ($max,$min) = &GetStudentAnswers($r,$problem,$Students);
+ $r->print('Maximum = '.$max.' Minimum = '.$min);
+ my $max_students = 0;
+ my %Data;
+ foreach my $student (@$Students) {
+ my $answer = $student->{'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);
+ $r->print('number of labels = '.scalar(@Labels));
+ my @PlotData = @Data{@Labels};
+ $r->print('number of PlotData = '.scalar(@PlotData));
+ my $graph =
+ &Apache::loncommon::DrawXYGraph('Correct Answer Distribution',
+ 'Correct Answer',
+ 'Number of students',
+ $max_students,
+ undef,
+ \@Labels,
+ [\@PlotData],
+ (xskip=>10));
+ $r->print($graph);
+ return;
}
sub GetStudentAnswers {
@@ -216,26 +246,60 @@ sub GetStudentAnswers {
'Student Answer Compilation Progress', scalar(@$Students));
$r->print("\n");
$r->rflush();
+ my ($min,$max);
foreach my $student (@$Students) {
my $sname = $student->{'username'};
my $sdom = $student->{'domain'};
my $answer = analyze_problem_as_student($resource,
$sname,$sdom,
$partid,$respid);
- $r->print(''.
- ''.$sname.' | '.
- ''.$sdom.' | '.
- ''.$answer.' | '.
- '
'."\n");
+ if (! defined($min) || $min > $answer) {
+ $min = $answer;
+ }
+ if (! defined($max) || $max < $answer) {
+ $max = $answer;
+ }
+# $r->print(''.
+# ''.$sname.' | '.
+# ''.$sdom.' | '.
+# ''.$answer.' | '.
+# '
'."\n");
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
&mt('last student'));
- $Answers{$sname.':'.$sdom}=$answer;
+ $student->{'answer'} = $answer;
}
$r->print("
\n");
$r->rflush();
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
# close progress window
- return \%Answers;
+ return ($max,$min);
+}
+
+sub build_student_data_worksheet {
+ my ($workbook,$format) = @_;
+ my $rows_output = 3;
+ my $cols_output = 0;
+ my $worksheet = $workbook->addworksheet('Student Data');
+ $worksheet->write($rows_output++,0,'Student Data',$format->{'h3'});
+ my @Headers = ('full name','username','domain','section',
+ "student\nnumber",'identifier');
+ $worksheet->write_row($rows_output++,0,\@Headers,$format->{'header'});
+ my @Students = @Apache::lonstatistics::Students;
+ my $studentrows = &Apache::loncoursedata::get_student_data(\@Students);
+ my %ids;
+ foreach my $row (@$studentrows) {
+ my ($mysqlid,$student) = @$row;
+ $ids{$student}=$mysqlid;
+ }
+ foreach my $student (@Students) {
+ my $name_domain = $student->{'username'}.':'.$student->{'domain'};
+ $worksheet->write_row($rows_output++,0,
+ [$student->{'fullname'},
+ $student->{'username'},$student->{'domain'},
+ $student->{'section'},$student->{'id'},
+ $ids{$name_domain}]);
+ }
+ return $worksheet;
}
#########################################################