{'_Options'}});$i++) {
+ push(@{$plotdata[$i+1]},0);
}
}
#
# Create the plot
- my $count = $end_index-$begin_index;
- my $title;
- if ($count == 0) {
- $title = 'no submissions';
- } elsif ($count == 1) {
- $title = 'one submission';
- } else {
- $title = $count.' submissions';
- }
- my $correctplot = &Apache::loncommon::DrawBarGraph($title,
- 'Foil Number',
- 'Percent Correct',
- 100,
- $plotcolors,
- undef,
- $Plotdata[0]);
- for (my $j=0; $j< scalar(@{$Plotdata[0]});$j++) {
- $Plotdata[0]->[$j]=0;
- }
- $count = $end_index-$begin_index-$TimeData{'_correct'};
- if ($count == 0) {
- $title = 'no submissions';
- } elsif ($count == 1) {
- $title = 'one submission';
- } else {
- $title = $count.' submissions';
- }
- my $incorrectplot = &Apache::loncommon::DrawBarGraph($title,
- 'Foil Number',
- 'Incorrect Option Choice',
- 100,
- $plotcolors,
- undef,
- @Plotdata);
- $analysis_html.=''.
- ''.$correctplot.' | '.
- ''.$incorrectplot.' | '.
- ''.$foilkey.' | '."
\n";
- $analysis_html.= ''.''.
- 'Start Time:'.
- ' '.$interval->{'startdateform'}.' '.
- 'End Time : '.
- ' '.$interval->{'enddateform'}.' '.
-# 'Plot Title :'.
-# (" "x3).$interval->{'titleform'}.
- ' | '.
- "
\n";
- return $analysis_html;
+ my $correct_plot = &Apache::loncommon::DrawBarGraph('Correct Statements',
+ 'Statement Number',
+ 'Percent Correct',
+ 100,
+ $plotcolors,
+ undef,
+ $plotdata[0]);
+ for (my $j=0; $j< scalar(@{$plotdata[0]});$j++) {
+ $plotdata[0]->[$j]=0;
+ }
+ my $incorrect_plot =
+ &Apache::loncommon::DrawBarGraph('Incorrect Statements',
+ 'Statement Number',
+ 'Incorrect Option Choice',
+ 100,
+ $plotcolors,
+ undef,
+ @plotdata);
+ return ($correct_plot,$incorrect_plot);
}
sub OR_Concept_Time_Analysis {
- my ($PerformanceData,$ORdata,$Concepts,$interval) = @_;
- my $analysis_html;
- ##
- ## Determine starttime, endtime, startindex, endindex
- my ($begin_index,$end_index) = ($interval->{'begin_index'},
- $interval->{'end_index'});
- my %TimeData;
- #
- # Compute the number getting the foils correct or incorrects
- for (my $j=$begin_index;$j<=$end_index;$j++) {
- my $row = $PerformanceData->[$j];
- next if (! defined($row));
- my %Row = &Process_OR_Row($row);
- while (my ($foilid,$href) = each(%Row)) {
- if (! ref($href)) {
- $TimeData{$foilid} += $href;
- next;
- }
- while (my ($option,$value) = each(%$href)) {
- $TimeData{$foilid}->{$option}+=$value;
- }
- }
- }
+ my ($processed_time_data,$correct,$data_count,$student_count,
+ $ORdata,$Concepts) = @_;
+ return '' if ($data_count == 0);
#
# Put the data in plottable form
- my @Plotdata;
+ my @plotdata;
foreach my $concept (@$Concepts) {
my ($total,$correct);
foreach my $foil (@{$concept->{'foils'}}) {
- $total += $TimeData{$foil}->{'_total'};
- $correct += $TimeData{$foil}->{'_correct'};
+ $total += $processed_time_data->{$foil}->{'_total'};
+ $correct += $processed_time_data->{$foil}->{'_correct'};
}
if ($total == 0) {
- push(@Plotdata,0);
+ push(@plotdata,0);
} else {
- push(@Plotdata,100 * $correct / $total);
+ push(@plotdata,100 * $correct / $total);
}
}
#
# Create the plot
- my $title = ($end_index - $begin_index).' submissions';
- my $correctplot = &Apache::loncommon::DrawBarGraph($title,
- 'Concept Number',
- 'Percent Correct',
- 100,
- $plotcolors,
- undef,
- \@Plotdata);
- $analysis_html.=''.
- ''.$correctplot.' | '.
- ''.
- 'Start Time: '.$interval->{'startdateform'}.' '.
- 'End Time : '.
- ' '.$interval->{'enddateform'}.' '.
-# 'Plot Title :'.(" "x3).
-# $interval->{'titleform'}.
- ' | '.
- "
\n";
- return $analysis_html;
+ return &Apache::loncommon::DrawBarGraph('Correct Concepts',
+ 'Concept Number',
+ 'Percent Correct',
+ 100,
+ $plotcolors,
+ undef,
+ \@plotdata);
+}
+
+sub OR_time_process_data {
+ my ($performance_data,$begin_index,$end_index)=@_;
+ my %processed_time_data;
+ my %distinct_students;
+ my ($correct,$data_count);
+ if (($begin_index == $end_index) &&
+ ($end_index != scalar(@$performance_data)-1)) {
+ return undef;
+ }
+ # Be sure we include the last one if we are asked for it.
+ # That we have to correct here (and not when $end_index is
+ # given a value) should probably be considered a bug.
+ if ($end_index == scalar(@$performance_data)-1) {
+ $end_index++;
+ }
+ my $count;
+ for (my $i=$begin_index;$i<$end_index;$i++) {
+ my $attempt = $performance_data->[$i];
+ $count++;
+ next if (! defined($attempt));
+ my %attempt = &Process_OR_Row($attempt);
+ $data_count++;
+ $correct += $attempt{'_correct'};
+ $distinct_students{$attempt->[&Apache::loncoursedata::RD_student_id()]}++;
+ while (my ($foilid,$href) = each(%attempt)) {
+ if (! ref($href)) {
+ $processed_time_data{$foilid} += $href;
+ next;
+ }
+ while (my ($option,$value) = each(%$href)) {
+ $processed_time_data{$foilid}->{$option}+=$value;
+ }
+ }
+ }
+ return (\%processed_time_data,$correct,$data_count,
+ scalar(keys(%distinct_students)));
}
#########################################################
@@ -992,7 +1264,7 @@ sub OR_Concept_Time_Analysis {
#########################################################
#########################################################
sub OR_excel_sheet {
- my ($r,$resource,$PerformanceData,$ORdata) = @_;
+ my ($r,$resource,$performance_data,$ORdata) = @_;
my $response = '';
my (undef,$Foils,$Concepts) = &build_foil_index($ORdata);
#
@@ -1030,7 +1302,7 @@ sub OR_excel_sheet {
# Do something useful
}
$result = &OR_build_response_data_worksheet($response_data_sheet,$format,
- $PerformanceData,$Foils,
+ $performance_data,$Foils,
$ORdata);
if ($result ne 'okay') {
# Do something useful
@@ -1118,7 +1390,7 @@ sub OR_build_problem_data_worksheet {
}
sub OR_build_response_data_worksheet {
- my ($worksheet,$format,$PerformanceData,$Foils,$ORdata)=@_;
+ my ($worksheet,$format,$performance_data,$Foils,$ORdata)=@_;
my $rows_output = 3;
my $cols_output = 0;
$worksheet->write($rows_output++,0,'Response Data',$format->{'h3'});
@@ -1131,18 +1403,18 @@ sub OR_build_response_data_worksheet {
}
$worksheet->write_row($rows_output++,0,\@Headers,$format->{'header'});
#
- foreach my $row (@$PerformanceData) {
+ foreach my $row (@$performance_data) {
next if (! defined($row));
my ($student,$award,$grading,$submission,$time,$tries) = @$row;
my @Foilgrades = split('&',$grading);
my @Foilsubs = split('&',$submission);
- my %ResponseData;
+ my %response_data;
for (my $j=0;$j<=$#Foilgrades;$j++) {
my ($foilid,$correct) = split('=',$Foilgrades[$j]);
my (undef,$submission) = split('=',$Foilsubs[$j]);
$submission = &Apache::lonnet::unescape($submission);
- $ResponseData{$foilid.' submission'}=$submission;
- $ResponseData{$foilid.' award'}=$correct;
+ $response_data{$foilid.' submission'}=$submission;
+ $response_data{$foilid.' award'}=$correct;
}
$worksheet->write($rows_output,$cols_output++,$student);
$worksheet->write($rows_output,$cols_output++,
@@ -1151,9 +1423,9 @@ sub OR_build_response_data_worksheet {
$worksheet->write($rows_output,$cols_output++,$tries);
foreach my $foilid (@$Foils) {
$worksheet->write($rows_output,$cols_output++,
- $ResponseData{$foilid.' submission'});
+ $response_data{$foilid.' submission'});
$worksheet->write($rows_output,$cols_output++,
- $ResponseData{$foilid.' award'});
+ $response_data{$foilid.' award'});
}
$rows_output++;
$cols_output = 0;
@@ -1238,18 +1510,18 @@ sub build_foil_index {
if (@Concepts > 1) {
$table .= ''.
''.$conceptindex.' | '.
- ''.&HTML::Entities::encode($concept->{'name'}).' | '.
+ ''.&HTML::Entities::encode($concept->{'name'},'<>&"').' | '.
''.$foilindex++.' | '.
- ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'name'}).' | '.
+ ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'name'},'<>&"').' | '.
''.$Foildata{$firstfoil}->{'text'}.' | '.
- ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'value'}).' | '.
+ ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'value'},'<>&"').' | '.
"
\n";
} else {
$table .= ''.
''.$foilindex++.' | '.
- ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'name'}).' | '.
+ ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'name'},'<>&"').' | '.
''.$Foildata{$firstfoil}->{'text'}.' | '.
- ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'value'}).' | '.
+ ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'value'},'<>&"').' | '.
"
\n";
}
foreach my $foilid (@FoilsInConcept) {
@@ -1258,16 +1530,16 @@ sub build_foil_index {
' | '.
' | '.
''.$foilindex.' | '.
- ''.&HTML::Entities::encode($Foildata{$foilid}->{'name'}).' | '.
+ ''.&HTML::Entities::encode($Foildata{$foilid}->{'name'},'<>&"').' | '.
''.$Foildata{$foilid}->{'text'}.' | '.
- ''.&HTML::Entities::encode($Foildata{$foilid}->{'value'}).' | '.
+ ''.&HTML::Entities::encode($Foildata{$foilid}->{'value'},'<>&"').' | '.
"\n";
} else {
$table .= ''.
''.$foilindex.' | '.
- ''.&HTML::Entities::encode($Foildata{$foilid}->{'name'}).' | '.
+ ''.&HTML::Entities::encode($Foildata{$foilid}->{'name'},'<>&"').' | '.
''.$Foildata{$foilid}->{'text'}.' | '.
- ''.&HTML::Entities::encode($Foildata{$foilid}->{'value'}).' | '.
+ ''.&HTML::Entities::encode($Foildata{$foilid}->{'value'},'<>&"').' | '.
"
\n";
}
} continue {
@@ -1288,11 +1560,12 @@ sub build_option_index {
my $optionindex = 0;
my @Rows;
foreach my $option (&mt('correct option chosen'),@{$ORdata->{'_Options'}}) {
+ my $color = $plotcolors->[$optionindex++];
push (@Rows,
''.
- ''.
- (' 'x4).' | '.
- ''.&HTML::Entities::encode($option).' | '.
+ ''.
+ ''.('*'x3).''.' | '.
+ ''.&HTML::Entities::encode($option,'<>&"').' | '.
"
\n");
}
shift(@Rows); # Throw away 'correct option chosen' color
@@ -1300,6 +1573,27 @@ sub build_option_index {
$table .= "