{'_Options'}});$i++) {
+ push(@{$plotdata[$i+1]},0);
+ }
+ }
+ #
+ # Create the plot
+ my $correct_plot = &Apache::loncommon::DrawBarGraph('Correct Statements',
+ 'Statement Number',
+ 'Percent Correct',
+ 100,
+ $plotcolors,
+ undef,
+ $plotdata[0],
+ {xskip=>1});
+ for (my $j=0; $j< scalar(@{$plotdata[0]});$j++) {
+ $plotdata[0]->[$j]=0;
}
- foreach my $foilid (keys(%Trydata)) {
- foreach my $tryhash (@{$Trydata{$foilid}}) {
- next if ((! exists($tryhash->{'correct'}) &&
- ! 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'})
- );
+ my $incorrect_plot =
+ &Apache::loncommon::DrawBarGraph('Incorrect Statements',
+ 'Statement Number',
+ 'Incorrect Option Choice',
+ 100,
+ $plotcolors,
+ undef,
+ @plotdata,{xskip=>1});
+ return ($correct_plot,$incorrect_plot);
+}
+
+sub OR_Concept_Time_Analysis {
+ my ($processed_time_data,$correct,$data_count,$student_count,
+ $ORdata,$Concepts) = @_;
+ return '' if ($data_count == 0);
+ #
+ # Put the data in plottable form
+ my @plotdata;
+ foreach my $concept (@$Concepts) {
+ my ($total,$correct);
+ foreach my $foil (@{$concept->{'foils'}}) {
+ $total += $processed_time_data->{$foil}->{'_total'};
+ $correct += $processed_time_data->{$foil}->{'_correct'};
+ }
+ if ($total == 0) {
+ push(@plotdata,0);
+ } else {
+ push(@plotdata,100 * $correct / $total);
}
}
- return %Trydata;
+ #
+ # Create the plot
+ return &Apache::loncommon::DrawBarGraph('Correct Concepts',
+ 'Concept Number',
+ 'Percent Correct',
+ 100,
+ $plotcolors,
+ undef,
+ \@plotdata,{xskip=>1});
}
-sub get_problem_symb {
- my $problemstring = shift();
- my ($symb,$partid,$resid) = ($problemstring=~ /^(.*):([^:]*):([^:]*)$/);
- return ($symb,$partid,$resid);
+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)));
+}
+
+sub build_foil_index {
+ my ($ORdata) = @_;
+ return if (! exists($ORdata->{'_Foils'}));
+ my %Foildata = %{$ORdata->{'_Foils'}};
+ my @Foils = sort(keys(%Foildata));
+ my %Concepts;
+ foreach my $foilid (@Foils) {
+ push(@{$Concepts{$Foildata{$foilid}->{'_Concept'}}},
+ $foilid);
+ }
+ undef(@Foils);
+ # Having gathered the concept information in a hash, we now translate it
+ # into an array because we need to be consistent about order.
+ # Also put the foils in order, too.
+ my $sortfunction = sub {
+ my %Numbers = (one => 1,
+ two => 2,
+ three => 3,
+ four => 4,
+ five => 5,
+ six => 6,
+ seven => 7,
+ eight => 8,
+ nine => 9,
+ ten => 10,);
+ my $a1 = lc($a);
+ my $b1 = lc($b);
+ if (exists($Numbers{$a1})) {
+ $a1 = $Numbers{$a1};
+ }
+ if (exists($Numbers{$b1})) {
+ $b1 = $Numbers{$b1};
+ }
+ if (($a1 =~/^\d+$/) && ($b1 =~/^\d+$/)) {
+ return $a1 <=> $b1;
+ } else {
+ return $a1 cmp $b1;
+ }
+ };
+ my @Concepts;
+ foreach my $concept (sort $sortfunction (keys(%Concepts))) {
+ if (! defined($Concepts{$concept})) {
+ $Concepts{$concept}=[];
+# next;
+ }
+ push(@Concepts,{ name => $concept,
+ foils => [@{$Concepts{$concept}}]});
+ push(@Foils,(@{$Concepts{$concept}}));
+ }
+ #
+ # Build up the table of row labels.
+ my $table = &Apache::loncommon::start_data_table();
+ if (@Concepts > 1) {
+ $table .= &Apache::loncommon::start_data_table_header_row().
+ ''.&mt('Concept Number').' '.
+ ''.&mt('Concept').' '.
+ ''.&mt('Foil Number').' '.
+ ''.&mt('Foil Name').' '.
+ ''.&mt('Foil Text').' '.
+ ''.&mt('Correct Value').' '.
+ &Apache::loncommon::end_data_table_header_row();
+ } else {
+ $table .= &Apache::loncommon::start_data_table_header_row().
+ ''.&mt('Foil Number').' '.
+ ''.&mt('Foil Name').' '.
+ ''.&mt('Foil Text').' '.
+ ''.&mt('Correct Value').' '.
+ &Apache::loncommon::end_data_table_header_row();
+ }
+ my $conceptindex = 1;
+ my $foilindex = 1;
+ foreach my $concept (@Concepts) {
+ my @FoilsInConcept = @{$concept->{'foils'}};
+ my $firstfoil = shift(@FoilsInConcept);
+ if (@Concepts > 1) {
+ $table .= &Apache::loncommon::start_data_table_row().
+ ''.$conceptindex.' '.
+ ''.&HTML::Entities::encode($concept->{'name'},'<>&"').' '.
+ ''.$foilindex++.' '.
+ ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'name'},'<>&"').' '.
+ ''.$Foildata{$firstfoil}->{'text'}.' '.
+ ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'value'},'<>&"').' '.
+ &Apache::loncommon::end_data_table_row();
+ } else {
+ $table .= &Apache::loncommon::start_data_table_row().
+ ''.$foilindex++.' '.
+ ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'name'},'<>&"').' '.
+ ''.$Foildata{$firstfoil}->{'text'}.' '.
+ ''.&HTML::Entities::encode($Foildata{$firstfoil}->{'value'},'<>&"').' '.
+ &Apache::loncommon::end_data_table_row();
+ }
+ foreach my $foilid (@FoilsInConcept) {
+ if (@Concepts > 1) {
+ $table .= &Apache::loncommon::start_data_table_row().
+ ' '.
+ ' '.
+ ''.$foilindex.' '.
+ ''.&HTML::Entities::encode($Foildata{$foilid}->{'name'},'<>&"').' '.
+ ''.$Foildata{$foilid}->{'text'}.' '.
+ ''.&HTML::Entities::encode($Foildata{$foilid}->{'value'},'<>&"').' '.
+ &Apache::loncommon::end_data_table_row();
+ } else {
+ $table .= &Apache::loncommon::start_data_table_row().
+ ''.$foilindex.' '.
+ ''.&HTML::Entities::encode($Foildata{$foilid}->{'name'},'<>&"').' '.
+ ''.$Foildata{$foilid}->{'text'}.' '.
+ ''.&HTML::Entities::encode($Foildata{$foilid}->{'value'},'<>&"').' '.
+ &Apache::loncommon::end_data_table_row();
+ }
+ } continue {
+ $foilindex++;
+ }
+ } continue {
+ $conceptindex++;
+ }
+ $table .= &Apache::loncommon::end_data_table();
+ #
+ # Build option index with color stuff
+ return ($table,\@Foils,\@Concepts);
}
+sub build_option_index {
+ my ($ORdata)= @_;
+ my $table = "\n";
+ my $optionindex = 0;
+ my @Rows;
+ foreach my $option (&mt('correct option chosen'),@{$ORdata->{'_Options'}}) {
+ my $color = $plotcolors->[$optionindex++];
+ push (@Rows,
+ ''.
+ ''.
+ ''.('*'x3).' '.' '.
+ ''.&HTML::Entities::encode($option,'<>&"').' '.
+ " \n");
+ }
+ shift(@Rows); # Throw away 'correct option chosen' color
+ $table .= join('',reverse(@Rows));
+ $table .= "
\n";
+}
+
+sub build_foil_key {
+ my ($foils,$extra_data)= @_;
+ if (! defined($extra_data)) { $extra_data = {}; }
+ my $table = "\n";
+ my $foil_index = 0;
+ my @rows;
+ foreach my $foil (&mt('correct foil chosen'),@{$foils}) {
+ my $color = $plotcolors->[$foil_index++];
+ push (@rows,
+ ''.
+ ''.
+ ''.('*'x4).' '.
+ ''.&HTML::Entities::encode($foil,'<>&"').
+ (' 'x2).$extra_data->{$foil}.' '.
+ " \n");
+ }
+ shift(@rows); # Throw away 'correct foil chosen' color
+ $table .= join('',reverse(@rows));
+ $table .= "
\n";
+}
+
+#########################################################
+#########################################################
+##
+## Generic Interface Routines
+##
+#########################################################
+#########################################################
sub CreateInterface {
##
## Environment variable initialization
- if (! exists$ENV{'form.AnalyzeBy'}) {
- $ENV{'form.AnalyzeBy'} = 'Tries';
+ if (! exists($env{'form.AnalyzeOver'})) {
+ $env{'form.AnalyzeOver'} = 'tries';
}
##
## Build the menu
my $Str = '';
- $Str .= ''."\n";
- $Str .= '';
- $Str .= ''.&mt('Sections').' ';
- $Str .= ''.&mt('Enrollment Status').' ';
-# $Str .= ''.&mt('Sequences and Folders').' ';
- $Str .= ' ';
- $Str .= ' '."\n";
+ $Str .= &Apache::lonhtmlcommon::breadcrumbs('Detailed Problem Analysis');
+ $Str .= '';
+ $Str .= &Apache::loncommon::start_data_table();
+ $Str .= &Apache::loncommon::start_data_table_header_row();
+ $Str .= '
'.&mt('Sections').' ';
+ $Str .= ''.&mt('Groups').' ';
+ $Str .= ''.&mt('Access Status').' ';
+ $Str .= ''.&mt('Options').' ';
+ $Str .= &Apache::loncommon::end_data_table_header_row();
##
##
- $Str .= ''."\n";
+ $Str .= &Apache::loncommon::start_data_table_row();
+ $Str .= ' '."\n";
$Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
$Str .= ' ';
#
+ $Str .= ''."\n";
+ $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
+ $Str .= ' ';
+ #
$Str .= '';
$Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
$Str .= ' ';
#
-# $Str .= '';
- my $only_seq_with_assessments = sub {
- my $s=shift;
- if ($s->{'num_assess'} < 1) {
- return 0;
- } else {
- return 1;
- }
- };
- &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
- $only_seq_with_assessments);
-# $Str .= ' ';
- #
- $Str .= '';
- $Str .= ''.&mt('Analyze By ');
- $Str .='';
- #
- $Str .= '';
- #
- $Str .= ' ';
- $Str .= ' ';
- #
- $Str .= ''.&mt('Number of Plots:');
- $Str .= '';
- if (! exists($ENV{'form.NumPlots'})
- || $ENV{'form.NumPlots'} < 1
- || $ENV{'form.NumPlots'} > 20) {
- $ENV{'form.NumPlots'} = 7;
+ ##
+ ##
+ $Str .= '';
+ ##
+ my $showprob_checkbox =
+ ' ';
+ $Str.= ''.
+ $showprob_checkbox.' '.&mt('Show problem').
+ ' ';
+ ##
+ my $analyze_selector = '';
+ $analyze_selector .= '';
+ $analyze_selector .= ' ';
+ $analyze_selector .= ' ';
+ $Str .= ''.
+ &mt('Analyze Over [_1] [_2]',
+ $analyze_selector,
+ &Apache::loncommon::help_open_topic('Analysis_Analyze_Over')).
+ ' '.$/;
+ ##
+ my $numplots_selector = '';
+ if (! exists($env{'form.NumPlots'})
+ || $env{'form.NumPlots'} < 1
+ || $env{'form.NumPlots'} > 20) {
+ $env{'form.NumPlots'} = 5;
}
foreach my $i (1,2,3,4,5,6,7,8,10,15,20) {
- $Str .= '';
+ $numplots_selector .= ' ';
}
- $Str .= ' ';
+ $numplots_selector .= '';
+ $Str .= ''.&mt('Number of Plots [_1]',$numplots_selector).
+ ' ';
+ ##
$Str .= ' ';
- #
- $Str .= ' '."\n";
- $Str .= '
'."\n";
- return ($Str);
-}
-
-sub OptionResponseProblemSelector {
- my $Str;
- $Str = "\n\n";
+ ##
+ ##
+ $Str .= &Apache::loncommon::end_data_table_row();
+ $Str .= &Apache::loncommon::end_data_table();
+ $Str .= ''
+ .&mt('Status: [_1]',
+ ' ')
+ .'
';
+ $Str .= '';
return $Str;
}
-sub get_resource_from_symb {
- my ($symb) = @_;
- foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
- foreach my $res (@{$seq->{'contents'}}) {
- if ($res->{'symb'} eq $symb) {
- return $res;
- }
- }
+#########################################################
+#########################################################
+##
+## Misc Option Response functions
+##
+#########################################################
+#########################################################
+sub get_time_from_row {
+ my ($row) = @_;
+ if (ref($row)) {
+ return $row->[&Apache::loncoursedata::RD_timestamp()];
+ }
+ return undef;
+}
+
+sub get_tries_from_row {
+ my ($row) = @_;
+ if (ref($row)) {
+ return $row->[&Apache::loncoursedata::RD_tries()];
}
return undef;
}
-sub get_problem_data {
- my ($url) = @_;
-# my $Answ=&Apache::lonnet::ssi($URI,('grade_target' => 'analyze',
-# 'grade_username' => $sname,
-# 'grade_domain' => $sdom,
-# 'grade_courseid' => $cid,
-# 'grade_symb' => $symb));
- my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze'));
- (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2);
- my %Answer;
- %Answer=&Apache::lonnet::str2hash($Answ);
-# &Apache::lonnet::logthis('keys of %Answer = '.join(', ',(keys(%Answer))));
-# &Apache::lonnet::logthis('$Answer{parts} = '.
-# join(', ',@{$Answer{'parts'}}));
- my %Partdata;
- foreach my $part (@{$Answer{'parts'}}) {
- while (my($key,$value) = each(%Answer)) {
- next if ($key !~ /^$part/);
- $key =~ s/^$part\.//;
- if (ref($value) eq 'ARRAY') {
- if ($key eq 'options') {
- $Partdata{$part}->{'Options'}=$value;
- } elsif ($key eq 'concepts') {
- $Partdata{$part}->{'Concepts'}=$value;
- } elsif ($key =~ /^concept\.(.*)$/) {
- my $concept = $1;
- foreach my $foil (@$value) {
- $Partdata{$part}->{$foil}->{'Concept'}=$concept;
- }
- }
- # &Apache::lonnet::logthis($part.' '.$key.' (array) = '.
- # join(', ',@$value));
- } else {
- $value =~ s/^\s*//g;
- $value =~ s/\s*$//g;
- if ($key=~ /^foil\.text\.(.*)$/) {
- my $foil = $1;
- $Partdata{$part}->{'Foiltext'}->{$foil}=$value;
- } elsif ($key =~ /^foil\.value\.(.*)$/) {
- my $foil = $1;
- $Partdata{$part}->{'FoilValues'}->{$foil}=$value;
- }
-# &Apache::lonnet::logthis($part.' '.$key.' = '.$value);
- }
+sub hashify_attempt {
+ my ($row) = @_;
+ my %attempt;
+ $attempt{'student'} = $row->[&Apache::loncoursedata::RD_sname()];
+ $attempt{'tries'} = $row->[&Apache::loncoursedata::RD_tries()];
+ $attempt{'submission'} = &unescape($row->[&Apache::loncoursedata::RD_submission()]);
+ $attempt{'award'} = $row->[&Apache::loncoursedata::RD_awarddetail()];
+ $attempt{'timestamp'} = $row->[&Apache::loncoursedata::RD_timestamp()];
+ return %attempt;
+}
+
+sub Process_OR_Row {
+ my ($row) = @_;
+ my %RowData;
+# my $student_id = $row->[&Apache::loncoursedata::RD_student_id()];
+ my $award = $row->[&Apache::loncoursedata::RD_awarddetail()];
+ my $grading = $row->[&Apache::loncoursedata::RD_response_eval()];
+ my $submission = $row->[&Apache::loncoursedata::RD_submission()];
+ my $time = $row->[&Apache::loncoursedata::RD_timestamp()];
+# my $tries = $row->[&Apache::loncoursedata::RD_tries()];
+ return undef if ($award eq 'MISSING_ANSWER');
+ if (&submission_is_correct($award)) {
+ $RowData{'_correct'} = 1;
+ }
+ $RowData{'_total'} = 1;
+ my @Foilgrades = split('&',$grading);
+ my @Foilsubs = split('&',$submission);
+ for (my $j=0;$j<=$#Foilgrades;$j++) {
+ my ($foilid,$correct) = split('=',$Foilgrades[$j]);
+ $foilid = &unescape($foilid);
+ my (undef,$submission) = split('=',$Foilsubs[$j]);
+ if ($correct) {
+ $RowData{$foilid}->{'_correct'}++;
+ } else {
+ $submission = &unescape($submission);
+ $RowData{$foilid}->{$submission}++;
}
+ $RowData{$foilid}->{'_total'}++;
}
+ return %RowData;
+}
-# my $parts='';
-# foreach my $elm (@{$Answer{"parts"}}) {
-# $parts.="$elm,";
-# }
-# chop($parts);
-# my $conc='';
-# foreach my $elm (@{$Answer{"$parts.concepts"}}) {
-# $conc.="$elm@";
-# }
-# chop($conc);
-#
-# @Concepts=split(/\@/,$conc);
-# foreach my $concept (@{$Answer{"$parts.concepts"}}) {
-# foreach my $foil (@{$Answer{"$parts.concept.$concept"}}) {
-# $foil_to_concept{$foil} = $concept;
-# #$ConceptData{$foil} = $Answer{"$parts.foil.value.$foil"};
-# }
-# }
-# return $symb;
- return %Partdata;
+sub submission_is_correct {
+ my ($award) = @_;
+ if ($award =~ /(APPROX_ANS|EXACT_ANS)/) {
+ return 1;
+ } else {
+ return 0;
+ }
}
1;