--- loncom/interface/statistics/lonproblemanalysis.pm 2003/10/06 20:51:20 1.25
+++ loncom/interface/statistics/lonproblemanalysis.pm 2003/10/07 16:07:39 1.26
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.25 2003/10/06 20:51:20 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.26 2003/10/07 16:07:39 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -46,39 +46,40 @@ sub BuildProblemAnalysisPage {
my ($symb,$part,$resid) = &get_problem_symb(
&Apache::lonnet::unescape($ENV{'form.problemchoice'})
);
- $r->print('
');
my $resource = &get_resource_from_symb($symb);
if (defined($resource)) {
my %Data = &get_problem_data($resource->{'src'});
my $ORdata = $Data{$part.'.'.$resid};
##
- ## Render the problem for display
+ ## Render the problem
my $base;
($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|);
$base = "http://".$ENV{'SERVER_NAME'}.$base;
- $r->print(''.
- ''.
+ my $rendered_problem =
+ &Apache::lonnet::ssi_body($resource->{'src'});
+ $rendered_problem =~ s/ |
');
##
## Analyze the problem
- my @Data = &Apache::loncoursedata::get_optionresponse_data
- (undef,$symb,$resid);
- my $analysis_html = &DoTriesAnalysis(\@Data,$ORdata);
- $r->print($analysis_html);
+ my $PerformanceData =
+ &Apache::loncoursedata::get_optionresponse_data
+ (undef,$symb,$resid);
+ if (defined($PerformanceData) &&
+ ref($PerformanceData) eq 'ARRAY') {
+ my $analysis_html = &DoTriesAnalysis($PerformanceData,$ORdata);
+ $r->print($analysis_html);
+ } else {
+ $r->print(''.
+ &mt('There is no student data for this problem.').
+ '
');
+ }
} else {
$r->print('resource is undefined');
}
- $r->print('');
- $r->print("render problem\n");
- $r->print("Get student response data\n");
- $r->print("image tag for plot\n");
- $r->print("plot key\n");
- $r->print('
');
$r->print('
');
} else {
$r->print('No Problem Selected
');
@@ -89,16 +90,16 @@ sub BuildProblemAnalysisPage {
sub DoTriesAnalysis {
- my ($Data,$ORdata) = @_;
+ my ($PerformanceData,$ORdata) = @_;
my $mintries = 1;
my $maxtries = 3;
- my %ResponseData = &analyze_option_data_by_tries($Data,
+ my %ResponseData = &analyze_option_data_by_tries($PerformanceData,
$mintries,$maxtries);
my @Foils = sort(keys(%ResponseData));
my %Row_Label;
foreach my $foilid (@Foils) {
my $value = $ORdata->{'Foiltext'}->{$foilid};
- &Apache::lonnet::logthis('row label '.$foilid.' = '.$value);
+# &Apache::lonnet::logthis('row label '.$foilid.' = '.$value);
$Row_Label{$foilid} = $ORdata->{'Foiltext'}->{$foilid};
}
my @Rows;
@@ -164,11 +165,12 @@ sub DoTriesAnalysis {
}
sub analyze_option_data_by_tries {
- my ($data,$mintries,$maxtries) = @_;
+ my ($PerformanceData,$mintries,$maxtries) = @_;
my %Trydata;
$mintries = 1 if (! defined($mintries) || $mintries < 1);
$maxtries = $mintries if (! defined($maxtries) || $maxtries < $mintries);
- foreach my $row (@$data) {
+ foreach my $row (@$PerformanceData) {
+ next if (! defined($row));
my ($grading,$submission,$time,$tries) = @$row;
my @Foilgrades = split('&',$grading);
my @Foilsubs = split('&',$submission);
@@ -202,6 +204,9 @@ sub analyze_option_data_by_tries {
sub DrawGraph {
my ($title,$xlabel,$ylabel,$MaxY,$values1,$values2)=@_;
+ if (! defined($values1) || ref($values1) ne 'ARRAY') {
+ return '';
+ }
$title = '' if (! defined($title));
$xlabel = '' if (! defined($xlabel));
$ylabel = '' if (! defined($ylabel));
@@ -280,7 +285,7 @@ sub OptionResponseProblemSelector {
my $seq_str = '';
foreach my $res (@{$seq->{'contents'}}) {
# &Apache::lonnet::logthis('checking '.$res->{'title'});
-# next if ($res->{'type'} ne 'assessment');
+ next if ($res->{'type'} ne 'assessment');
foreach my $part (@{$res->{'parts'}}) {
my $partdata = $res->{'partdata'}->{$part};
if (! exists($partdata->{'option'}) ||
@@ -359,8 +364,8 @@ sub get_problem_data {
$Partdata{$part}->{$foil}->{'Concept'}=$concept;
}
}
- &Apache::lonnet::logthis($part.' '.$key.' (array) = '.
- join(', ',@$value));
+ # &Apache::lonnet::logthis($part.' '.$key.' (array) = '.
+ # join(', ',@$value));
} else {
$value =~ s/^\s*//g;
$value =~ s/\s*$//g;
@@ -371,7 +376,7 @@ sub get_problem_data {
my $foil = $1;
$Partdata{$part}->{'FoilValues'}->{$foil}=$value;
}
- &Apache::lonnet::logthis($part.' '.$key.' = '.$value);
+# &Apache::lonnet::logthis($part.' '.$key.' = '.$value);
}
}
}