');
+ }
+ #
my $analysis_html;
- my $PerformanceData =
- &Apache::loncoursedata::get_response_data
- ($Students,$resource->{'symb'},$respid);
+ my $PerformanceData = &Apache::loncoursedata::get_response_data
+ (\@Apache::lonstatistics::SelectedSections,
+ $Apache::lonstatistics::enrollment_status,
+ $resource->{'symb'},$respid);
if (! defined($PerformanceData) ||
ref($PerformanceData) ne 'ARRAY' ) {
$analysis_html = '
'.
@@ -208,7 +222,10 @@ sub NumericalResponseAnalysis {
}
#
# This next call causes all the waiting around that people complain about
- my ($max,$min) = &GetStudentAnswers($r,$problem,$Students);
+ &Apache::lonstathelpers::GetStudentAnswers($r,$problem,$Students,
+ 'Statistics',
+ 'stats_status');
+ return if ($c->aborted());
#
# Collate the data
my %Data;
@@ -233,6 +250,9 @@ sub one_dimensional_plot {
# Compute data -> image scaling factors
my $min = $Labels->[0];
my $max = $Labels->[-1];
+ if ($max == $min) {
+ $max =$min+1;
+ }
my $h_scale = ($width-10)/($max-$min);
#
my $max_y = 0;
@@ -295,6 +315,17 @@ sub line {
return qq{$/};
}
+sub text {
+ my ($x,$y,$color,$text,$font,$direction) = @_;
+ if (! defined($font) || $font !~ /^(tiny|small|medium|large|giant)$/) {
+ $font = 'medium';
+ }
+ if (! defined($direction) || $direction ne 'vertical') {
+ $direction = '';
+ }
+ return qq{$text};
+}
+
sub rectangle {
my ($x1,$y1,$x2,$y2,$color,$thickness,$filled) = @_;
return qq{};
@@ -310,34 +341,6 @@ sub circle {
return &arc($x,$y,$radius,$radius,0,360,$color,$thickness,$filled);
}
-sub GetStudentAnswers {
- my ($r,$problem,$Students) = @_;
- my %Answers;
- my ($resource,$partid,$respid) = ($problem->{'resource'},
- $problem->{'part'},
- $problem->{'respid'});
- # Open progress window
- my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
- ($r,'Student Answer Compilation Status',
- 'Student Answer Compilation Progress', scalar(@$Students));
- $r->print("
\n");
- $r->rflush();
- foreach my $student (@$Students) {
- my $sname = $student->{'username'};
- my $sdom = $student->{'domain'};
- my $answer = &Apache::lonstathelpers::analyze_problem_as_student
- ($resource,$sname,$sdom,$partid,$respid);
- &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
- &mt('last student'));
- $student->{'answer'} = $answer;
- }
- $r->print("
\n");
- $r->rflush();
- # close progress window
- &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
- return;
-}
-
sub build_student_data_worksheet {
my ($workbook,$format) = @_;
my $rows_output = 3;
@@ -373,68 +376,395 @@ sub build_student_data_worksheet {
#########################################################
#########################################################
sub RadioResponseAnalysis {
- my ($r,$problem,$ProblemData,$Students) = @_;
- my ($resource,$respid) = ($problem->{'resource'},
- $problem->{'respid'});
+ my ($r,$problem,$problem_analysis,$students) = @_;
+ if ($ENV{'form.AnalyzeOver'} eq 'tries') {
+ &RR_tries_analysis($r,$problem,$problem_analysis,$students);
+ } elsif ($ENV{'form.AnalyzeOver'} eq 'time') {
+ &RR_static_time_analysis($r,$problem,$problem_analysis,$students);
+ } else {
+ $r->print('Bad request');
+ }
+ return;
+}
+
+sub RR_computed_tries_analysis {
+ my ($r,$problem,$problem_analysis) = @_;
+ my ($resource,$partid,$respid) = ($problem->{'resource'},
+ $problem->{'part'},
+ $problem->{'respid'});
+ $r->print('The tries answer you seek must be computed');
+ # Gather student data
+ # for each try
+ # loop through data, classifying it by
+ # correct foil -> selected foil
+ # if there is concept data
+ # make a concept correct plot
+ # for each correct foil
+ # make a plot of the data
+}
+
+sub RR_computed_time_analysis {
+ my ($r,$problem,$problem_analysis) = @_;
+ my ($resource,$partid,$respid) = ($problem->{'resource'},
+ $problem->{'part'},
+ $problem->{'respid'});
+ $r->print('The time answer you seek must be computed');
+ # Gather student data
+ # for time division
+ # limit to between start time & end time
+ # loop through data, classifying it by
+ # correct foil -> selected foil
+ # if there is concept data
+ # make a concept correct plot
+ # for each correct foil
+ # make a plot of the data
+}
+
+sub RR_tries_analysis {
+ my ($r,$problem,$problem_analysis,$students) = @_;
+ my ($resource,$partid,$respid) = ($problem->{'resource'},
+ $problem->{'part'},
+ $problem->{'respid'});
+ #
my $analysis_html;
- my $PerformanceData =
- &Apache::loncoursedata::get_response_data
- ($Students,$resource->{'symb'},$respid);
- if (! defined($PerformanceData) ||
- ref($PerformanceData) ne 'ARRAY' ) {
+ my $foildata = $problem_analysis->{'_Foils'};
+ my ($table,$foils,$concepts) = &build_foil_index($problem_analysis);
+ $analysis_html .= $table;
+ # Gather student data
+ my $response_data = &Apache::loncoursedata::get_response_data
+ (\@Apache::lonstatistics::SelectedSections,
+ $Apache::lonstatistics::enrollment_status,
+ $resource->{'symb'},$respid);
+ my $correct; # either a hash reference or a scalar
+ if ($problem_analysis->{'answercomputed'} || scalar(@$concepts) > 1) {
+ # This takes a while for large classes...
+ &Apache::lonstathelpers::GetStudentAnswers($r,$problem,$students,
+ 'Statistics',
+ 'stats_status');
+ foreach my $student (@$students) {
+ my ($idx,@remainder) = split('&',$student->{'answer'});
+ my ($answer) = ($remainder[$idx]=~/^(.*)=([^=]*)$/);
+ $correct->{$student->{'username'}.':'.$student->{'domain'}}=
+ &Apache::lonnet::unescape($answer);
+ }
+ } else {
+ foreach my $foil (keys(%$foildata)) {
+ if ($foildata->{$foil}->{'value'} eq 'true') {
+ $correct = $foildata->{$foil}->{'name'};
+ last;
+ }
+ }
+ }
+ if (! defined($response_data) ||
+ ref($response_data) ne 'ARRAY' ) {
+ $analysis_html = '
'.
+ &mt('There is no submission data for this resource').
+ '