--- loncom/interface/statistics/lonproblemanalysis.pm 2003/09/29 21:09:27 1.23
+++ loncom/interface/statistics/lonproblemanalysis.pm 2003/10/10 13:47:48 1.30
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.23 2003/09/29 21:09:27 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.30 2003/10/10 13:47:48 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -24,16 +24,12 @@
#
# http://www.lon-capa.org/
#
-# (Navigate problems for statistical reports
-# YEAR=2002
-# 5/12,7/26,9/7,11/22 Behrouz Minaei
-#
-###
package Apache::lonproblemanalysis;
use strict;
use Apache::lonnet();
+use Apache::loncommon();
use Apache::lonhtmlcommon();
use Apache::loncoursedata();
use Apache::lonstatistics;
@@ -41,65 +37,252 @@ use Apache::lonlocal;
sub BuildProblemAnalysisPage {
my ($r,$c)=@_;
- $r->print(&mt('
Option Response Problem Analysis
'));
+ $r->print('
'.&mt('Option Response Problem Analysis').'
');
+ $r->print(&CreateInterface());
+ #
+ my @Students = @Apache::lonstatistics::Students;
+ #
if (exists($ENV{'form.problemchoice'})) {
- # This is me getting around my own cleverness:
- &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
- undef);
+ $r->print('');
+ &Apache::lonstatistics::Gather_Full_Student_Data($r);
#
- my ($symb,$id) = &get_problem_symb(
+ my ($symb,$part,$resid) = &get_problem_symb(
&Apache::lonnet::unescape($ENV{'form.problemchoice'})
);
- $r->print('');
+ #
+# my ($firsttime,$lasttime) =
+# &Apache::loncoursedata::get_timestamp_data($symb,$resid);
+ #
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
+ my $base;
+ ($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|);
+ $base = "http://".$ENV{'SERVER_NAME'}.$base;
+ my $rendered_problem =
+ &Apache::lonnet::ssi_body($resource->{'src'});
+ $rendered_problem =~ s/<\s*form\s*/)|<\/nop>|g;
$r->print('
'.
- # Oh this is dumb! Need to rewrite relative links
- # otherwise images (for example) will not show.
- &Apache::lonnet::ssi_body($resource->{'src'}).
+ ''.
+ $rendered_problem.
'
');
+ ##
+ ## Analyze the problem
+ my $PerformanceData =
+ &Apache::loncoursedata::get_optionresponse_data
+ (\@Students,$symb,$resid);
+ if (defined($PerformanceData) &&
+ ref($PerformanceData) eq 'ARRAY') {
+ if ($ENV{'form.AnalyzeBy'} eq 'Tries') {
+ my $analysis_html = &DoTriesAnalysis($PerformanceData,
+ $ORdata);
+ $r->print($analysis_html);
+# } elsif ($ENV{'form.AnalyzeBy'} eq 'Time') {
+# my $analysis_html = &DoTimeAnalysis($PerformanceData,
+# $ORdata);
+# $r->print($analysis_html);
+ } else {
+ $r->print('
'.
+ &mt('The analysis you have selected is '.
+ 'not supported at this time').
+ '
');
+ }
+ } 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("image tag for plot\n");
- $r->print("plot key\n");
- $r->print('');
- $r->print("
');
}
# Okay, they asked for data, so make sure we get the latest data.
- &Apache::lonnet::logthis('got here for some reason');
-# &Apache::lonstatistics::Gather_Full_Student_Data($r);
$r->print(&OptionResponseProblemSelector());
}
+
+sub DoTriesAnalysis {
+ my ($PerformanceData,$ORdata) = @_;
+ my $mintries = 1;
+ my $maxtries = 10;
+ 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);
+ $Row_Label{$foilid} = $ORdata->{'Foiltext'}->{$foilid};
+ }
+ my @Rows;
+ $Rows[0] = ['