{'_Options'}});$i++) {
+ push(@{$plotdata[$i+1]},0);
}
}
-
- return;
+ #
+ # 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;
+ }
+ 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);
+ }
+ }
+ #
+ # Create the plot
+ return &Apache::loncommon::DrawBarGraph('Correct Concepts',
+ 'Concept Number',
+ 'Percent Correct',
+ 100,
+ $plotcolors,
+ undef,
+ \@plotdata,{xskip=>1});
+}
-sub DrawGraph {
- my ($k,$Src,$Concepts,$ConceptData)=@_;
- my $Max=0;
- my @data1;
- my @data2;
-
- # Adjust Data and find the Max
- for (my $n=0; $n<(scalar @$Concepts); $n++ ) {
- my $tmp=$Concepts->[$n];
- $data1[$n]=$ConceptData->{$tmp.'.'.$k.'.true'};
- $data2[$n]=$ConceptData->{$tmp.'.'.$k.'.false'};
- my $Sum=$data1[$n]+$data2[$n];
- if($Max < $Sum) {
- $Max=$Sum;
- }
- }
- for (my $n=0; $n<(scalar @$Concepts); $n++ ) {
- if ($data1[$n]+$data2[$n]<$Max) {
- $data2[$n]+=$Max-($data1[$n]+$data2[$n]);
- }
+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;
+ }
+ }
}
- my $P_No = (scalar @data1);
+ return (\%processed_time_data,$correct,$data_count,
+ scalar(keys(%distinct_students)));
+}
- if($Max > 1) {
- $Max += (10 - $Max % 10);
- $Max = int($Max);
+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 {
- $Max = 1;
+ $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);
+}
- my $Titr=($ConceptData->{'Interval'}>1) ? $Src.'_interval_'.($k+1) : $Src;
-# $GData=$Titr.'&Concepts'.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2;
- my $GData = '';
- $GData = $Titr.'&Concepts&Answers&'.$Max.'&'.$P_No.'&';
- $GData .= (join(',',@data1)).'&'.(join(',',@data2));
-
- return '';
-}
-
-sub DrawTable {
- my ($k,$Concepts,$ConceptData)=@_;
- my $Max=0;
- my @data1;
- my @data2;
- my $Correct=0;
- my $Wrong=0;
- for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
- my $tmp=$Concepts->[$n];
- $data1[$n]=$ConceptData->{$tmp.'.'.$k.'.true'};
- $Correct+=$data1[$n];
- $data2[$n]=$ConceptData->{$tmp.'.'.$k.'.false'};
- $Wrong+=$data2[$n];
- my $Sum=$data1[$n]+$data2[$n];
- if($Max < $Sum) {
- $Max=$Sum;
- }
- }
- for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
- if ($data1[$n]+$data2[$n]<$Max) {
- $data2[$n]+=$Max-($data1[$n]+$data2[$n]);
- }
+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.AnalyzeOver'})) {
+ $env{'form.AnalyzeOver'} = 'tries';
}
- my $P_No = (scalar @data1);
+ ##
+ ## Build the menu
my $Str = '';
-# $Str .= '
From: ['.localtime($ConceptData->{'Int.'.($k-1)});
-# $Str .= '] To: ['.localtime($ConceptData->{"Int.$k"}).']';
- $Str .= "\n".''.
- "\n".''.
- "\n".' # | '.
- "\n".' Concept | '.
- "\n".' Correct | '.
- "\n".' Wrong | '.
- "\n".'
';
-
- for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
- $Str .= ''."\n";
- $Str .= ''.($n+1).' | '."\n";
- my ($currentConcept) = split('::',$Concepts->[$n]);
- $Str .= ''.$currentConcept;
- $Str .= ' | '."\n";
- $Str .= ''.$data1[$n].' | '."\n";
- $Str .= ''.$data2[$n].' | '."\n";
- $Str .= '
'."\n";
- }
- $Str .= ' | From:['.localtime($ConceptData->{'Int.'.$k});
- $Str .= '] To: ['.localtime($ConceptData->{'Int.'.($k+1)}-1);
- $Str .= '] | '.$Correct.' | '.$Wrong.' | ';
- $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 .= &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 $showprob_checkbox =
+ '';
+ $Str.= ' ';
+ ##
+ my $analyze_selector = '';
+ $Str .= ' '.$/;
+ ##
+ my $numplots_selector = ' ';
+ $Str .= '';
+ ##
+ $Str .= ' | ';
+ ##
+ ##
+ $Str .= &Apache::loncommon::end_data_table_row();
+ $Str .= &Apache::loncommon::end_data_table();
+ $Str .= '';
+ $Str .= '';
return $Str;
-#$Apache::lonxml::debug=1;
-#&Apache::lonhomework::showhash(%ConceptData);
-#$Apache::lonxml::debug=0;
-}
-
-#---- END Analyze Web Page ----------------------------------------------
-
-sub Decide {
- #deciding the true or false answer belongs to each interval
- my ($type,$concept,$time,$ConceptData)=@_;
- my $k=0;
- while($time > $ConceptData->{'Int.'.($k+1)} &&
- $k < $ConceptData->{'Interval'}) {
- $k++;
- }
- $ConceptData->{$concept.'.'.$k.'.'.$type}++;
+}
- return;
+#########################################################
+#########################################################
+##
+## Misc Option Response functions
+##
+#########################################################
+#########################################################
+sub get_time_from_row {
+ my ($row) = @_;
+ if (ref($row)) {
+ return $row->[&Apache::loncoursedata::RD_timestamp()];
+ }
+ return undef;
}
-sub InitAnalysis {
- my ($uri,$part,$responseId,$problem,$student,$courseID)=@_;
- my ($name,$domain)=split(/\:/,$student);
-
- my %analyzeData;
- # Render the student's view of the problem. $Answ is the problem
- # Stringafied
- my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze',
- 'grade_username' => $name,
- 'grade_domain' => $domain,
- 'grade_courseid' => $courseID,
- 'grade_symb' => $problem));
- my ($Answer)=&Apache::lonnet::str2hashref($Answ);
-
- my $found = 0;
- my @parts=();
- if(defined($responseId)) {
- foreach (@{$Answer->{'parts'}}) {
- if($_ eq $part.'.'.$responseId) {
- push(@parts, $_);
- $found = 1;
- last;
- }
- }
- } else {
- foreach (@{$Answer->{'parts'}}) {
- if($_ =~ /$part/) {
- push(@parts, $_);
- $found = 1;
- last;
- }
- }
+sub get_tries_from_row {
+ my ($row) = @_;
+ if (ref($row)) {
+ return $row->[&Apache::loncoursedata::RD_tries()];
}
+ return undef;
+}
- if($found == 0) {
- $analyzeData{'error'} = 'No parts matching selected values';
- return \%analyzeData;
- }
-
- my @Concepts=();
- my %foil_to_concept;
- foreach my $currentPart (@parts) {
- if(defined($Answer->{$currentPart.'.concepts'})) {
- foreach my $concept (@{$Answer->{$currentPart.'.concepts'}}) {
- push(@Concepts, $concept);
- foreach my $foil (@{$Answer->{$currentPart.'.concept.'.
- $concept}}) {
- $analyzeData{$currentPart.'.foil.value.'.$foil} =
- $Answer->{$currentPart.'.foil.value.'.$foil};
- $foil_to_concept{$foil} = $concept;
- }
- }
+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 {
- foreach (keys(%$Answer)) {
- if(/$currentPart.foil\.value\.(.*)$/) {
- push(@Concepts, $1);
- $foil_to_concept{$1} = $1;
- $analyzeData{$currentPart.'.foil.value.'.$1} =
- $Answer->{$currentPart.'.foil.value.'.$1};
- }
- }
+ $submission = &unescape($submission);
+ $RowData{$foilid}->{$submission}++;
}
+ $RowData{$foilid}->{'_total'}++;
}
+ return %RowData;
+}
- $analyzeData{'parts'} = \@parts;
- $analyzeData{'concepts'} = \@Concepts;
- $analyzeData{'foil_to_concept'} = \%foil_to_concept;
-
- return \%analyzeData;
-}
-
-sub Interval {
- my ($part,$symb,$interval,$Concepts,$ConceptData)=@_;
- my $Int=$interval;
- my $due = &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb);
- my $opn = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb);
- my $add=int(($due-$opn)/$Int);
- $ConceptData->{'Int.0'}=$opn;
- for(my $i=1; $i<$Int; $i++) {
- $ConceptData->{'Int.'.$i}=$opn+$i*$add;
- }
- $ConceptData->{'Int.'.$Int}=$due;
- for(my $i=0; $i<$Int; $i++) {
- for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
- my $tmp=$Concepts->[$n];
- $ConceptData->{$tmp.'.'.$i.'.true'}=0;
- $ConceptData->{$tmp.'.'.$i.'.false'}=0;
- }
+sub submission_is_correct {
+ my ($award) = @_;
+ if ($award =~ /(APPROX_ANS|EXACT_ANS)/) {
+ return 1;
+ } else {
+ return 0;
}
}
+
1;
+
__END__