');
+ $r->print(&OptionResponseProblemSelector());
}
- # Okay, they asked for data, so make sure we get the latest data.
- $r->print(&OptionResponseProblemSelector());
}
sub DoTriesAnalysis {
- my ($Data,$ORdata) = @_;
+ my ($PerformanceData,$ORdata) = @_;
my $mintries = 1;
- my $maxtries = 3;
- my %ResponseData = &analyze_option_data_by_tries($Data,
+ my $maxtries = $ENV{'form.NumPlots'};
+ 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};
}
+ #
+ # Build up the table of row labels.
my @Rows;
- $Rows[0] = ['
'];
- for (my $i=$mintries;$i<=$maxtries;$i++) {
- push (@{$Rows[1]},('
'.&mt('Correct').'
',
- '
'.&mt('Incorrect').'
',
- '
'.&mt('Percent Correct').'
',
- ));
+ $Rows[0]= [ '
'.&mt('Foil Number').'
',
+ '
'.&mt('Foil Text').''];
+ my $table = '
'."\n";
+ my $index = 1;
+ foreach my $foilid (@Foils) {
+ $table .= '
'.$index.'
'.
+ '
'.$Row_Label{$foilid}."
\n";
+ } continue {
+ $index++;
}
+ $table .= "
\n";
+ #
+ # Compute the data neccessary to make the plots
my @PlotData;
my @CumulativePlotData;
- my $index = 1;
foreach my $foilid (@Foils) {
- my @Data = ('
'.$index.' '.$Row_Label{$foilid}.'
');
for (my $i=$mintries;$i<=$maxtries;$i++) {
- push(@Data,
- ('
'));
#
# Gather the per-attempt data
push (@{$PlotData[$i]->{'good'}},
$ResponseData{$foilid}->[$i]->{'percent_corr'});
push (@{$PlotData[$i]->{'bad'}},
100-$ResponseData{$foilid}->[$i]->{'percent_corr'});
- }
- for (my $i=0;$i<=$maxtries;$i++) {
+ #
+ # Someday we may need the cumulative data and I think
+ # this is a neat way of computing it as we go along.
push (@{$CumulativePlotData[$i]->{'good'}},
$CumulativePlotData[-1]->{'good'}+
$ResponseData{$foilid}->[$i]->{'correct'});
@@ -143,32 +167,70 @@ sub DoTriesAnalysis {
$CumulativePlotData[-1]->{'bad'}+
$ResponseData{$foilid}->[$i]->{'incorrect'});
}
- push(@Rows,\@Data);
- } continue {
- $index++;
}
- my @Data = ('
');
+ #
+ # Build a table for the plots
+ $table .= "
\n";
+ my @Plots;
for (my $i=$mintries;$i<=$maxtries;$i++) {
- push(@Data,'
\n";
+ #
+ # Should this be something the user can set? Too many dialogs!
+ my $plots_per_row = 2;
+ while (my $plotlink = shift(@Plots)) {
+ $table .= '
'.$plotlink.'
';
+ for (my $i=1;$i<$plots_per_row;$i++) {
+ if ($plotlink = shift(@Plots)) {
+ $table .= '
'.$plotlink.'
';
+ } else {
+ $table .= '
';
+ }
+ }
+ $table .= "
\n";
}
- $table .= '
';
+ $table .= "
\n";
return ($table);
}
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);
@@ -191,6 +253,8 @@ sub analyze_option_data_by_tries {
! exists($tryhash->{'incorrect'})) ||
($tryhash->{'correct'} < 1 &&
$tryhash->{'incorrect'} < 1));
+ $tryhash->{'total'} = $tryhash->{'correct'} +
+ $tryhash->{'incorrect'};
$tryhash->{'percent_corr'} = 100 *
($tryhash->{'correct'} /
($tryhash->{'correct'} + $tryhash->{'incorrect'})
@@ -200,37 +264,6 @@ sub analyze_option_data_by_tries {
return %Trydata;
}
-sub DrawGraph {
- my ($title,$xlabel,$ylabel,$MaxY,$values1,$values2)=@_;
- $title = '' if (! defined($title));
- $xlabel = '' if (! defined($xlabel));
- $ylabel = '' if (! defined($ylabel));
- $title = &Apache::lonnet::escape($title);
- $xlabel = &Apache::lonnet::escape($xlabel);
- $ylabel = &Apache::lonnet::escape($ylabel);
- #
- my $sendValues1 = join(',', @$values1);
- my $sendValues2;
- if (defined($values2)) {
- $sendValues2 = join(',', @$values2);
- }
-
- my $sendCount = scalar(@$values1);
- $MaxY =1 if ($MaxY < 1);
- if ( int($MaxY) < $MaxY ) {
- $MaxY++;
- $MaxY = int($MaxY);
- }
- my @GData = ($title,$xlabel,$ylabel,$MaxY,$sendCount,$sendValues1);
- if (defined($sendValues2)) {
- push (@GData,$sendValues2);
- }
- return '';
-}
-
-
-
sub get_problem_symb {
my $problemstring = shift();
my ($symb,$partid,$resid) = ($problemstring=~ /^(.*):([^:]*):([^:]*)$/);
@@ -238,19 +271,32 @@ sub get_problem_symb {
}
sub CreateInterface {
+ ##
+ ## Environment variable initialization
+ if (! exists$ENV{'form.AnalyzeBy'}) {
+ $ENV{'form.AnalyzeBy'} = 'Tries';
+ }
+ ##
+ ## Build the menu
my $Str = '';
$Str .= '