'
+ .&mt('There is no student data for this problem.')
+ .'
'
+ );
+ } else {
+ $r->rflush();
+ if ($env{'form.AnalyzeOver'} eq 'tries') {
+ my $analysis_html = &OR_tries_analysis($r,
+ $PerformanceData,
+ $problem_data);
+ $r->print($analysis_html);
+ $r->rflush();
+ } elsif ($env{'form.AnalyzeOver'} eq 'time') {
+ my $analysis_html = &OR_time_analysis($PerformanceData,
+ $problem_data);
+ $r->print($analysis_html);
+ $r->rflush();
+ } else {
+ $r->print(''
+ );
+ }
+ }
+}
+
+#########################################################
+#
+# Option Response: tries Analysis
+#
+#########################################################
+sub OR_tries_analysis {
+ my ($r,$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 $maxtries = $env{'form.NumPlots'};
+ my ($table,$Foils,$Concepts) = &build_foil_index($ORdata);
+ if (! defined($Concepts)) {
+ $Concepts = [];
}
- my @Rows;
- $Rows[0] = ['
'];
- for (my $i=$mintries;$i<=$maxtries;$i++) {
- push (@{$Rows[0]},
- '
'.&mt('Attempt').' '.$i.' ');
- }
- $Rows[1] = ['
'.&mt('Foil').' '];
- for (my $i=$mintries;$i<=$maxtries;$i++) {
- push (@{$Rows[1]},('
'.&mt('Correct').' ',
- '
'.&mt('Incorrect').' ',
- '
'.&mt('Percent Correct').' ',
- ));
- }
- 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,
- ('
'.$ResponseData{$foilid}->[$i]->{'correct'}.' ',
- '
'.$ResponseData{$foilid}->[$i]->{'incorrect'}.
- ' ',
- '
'.
- sprintf("%4.2f",
- $ResponseData{$foilid}->[$i]->{'percent_corr'}).
- ' '));
+ my %response_data = &OR_analyze_by_tries($r,$PerformanceData,
+ $mintries,$maxtries);
+ my $analysis = '';
+ #
+ # Compute the data necessary to make the plots
+ my @foil_plot;
+ my @concept_data;
+ for (my $j=0;$j<=scalar(@$Concepts);$j++) {
+ my $concept = $Concepts->[$j];
+ foreach my $foilid (@{$concept->{'foils'}}) {
+ for (my $try=$mintries;$try<=$maxtries;$try++) {
+ # concept analysis data
+ $concept_data[$j]->[$try]->{'_correct'} +=
+ $response_data{$foilid}->[$try]->{'_correct'};
+ $concept_data[$j]->[$try]->{'_total'} +=
+ $response_data{$foilid}->[$try]->{'_total'};
+ #
+ # foil analysis data
+ if ($response_data{$foilid}->[$try]->{'_total'} == 0) {
+ push(@{$foil_plot[$try]->{'_correct'}},0);
+ } else {
+ push(@{$foil_plot[$try]->{'_correct'}},
+ 100*$response_data{$foilid}->[$try]->{'_correct'}/
+ $response_data{$foilid}->[$try]->{'_total'});
+ }
+ foreach my $option (@{$ORdata->{'_Options'}}) {
+ push(@{$foil_plot[$try]->{'_total'}},
+ $response_data{$foilid}->[$try]->{'_total'});
+ if ($response_data{$foilid}->[$try]->{'_total'} == 0) {
+ push (@{$foil_plot[$try]->{$option}},0);
+ } else {
+ if ($response_data{$foilid}->[$try]->{'_total'} ==
+ $response_data{$foilid}->[$try]->{'_correct'}) {
+ push(@{$foil_plot[$try]->{$option}},0);
+ } else {
+ push (@{$foil_plot[$try]->{$option}},
+ 100 *
+ $response_data{$foilid}->[$try]->{$option} /
+ ($response_data{$foilid}->[$try]->{'_total'}
+ -
+ $response_data{$foilid}->[$try]->{'_correct'}
+ ));
+ }
+ }
+ } # End of foreach my $option
+ }
+ } # End of foreach my $foilid
+ } # End of concept loops
+ #
+ # Build a table for the plots
+ my $analysis_html = "
\n";
+ my $optionkey = &build_option_index($ORdata);
+ my $num_concepts = 1;
+ if (defined($Concepts)) { $num_concepts = scalar(@$Concepts); }
+ #
+ for (my $try=$mintries;$try<=$maxtries;$try++) {
+ if (! defined($response_data{'_total'}->[$try]) ||
+ $response_data{'_total'}->[$try] == 0) {
+ if ($try > 1) {
+ $analysis_html.= ''
+ .''
+ .&mt('None of the selected students attempted the problem more than [quant,_1,time].'
+ ,$try-1)
+ .'
'
+ .' ';
+ } else {
+ $analysis_html.= ''
+ .''
+ .&mt('None of the selected students have attempted the problem.')
+ .'
'
+ .' ';
+ }
+ last;
+ }
+ my $concept_graph='';
+ if ($num_concepts > 1) {
+ #
+ # Create concept plot
+ my @concept_plot_data;
+ for (my $j=0;$j<=$#concept_data;$j++) {
+ my $total = $concept_data[$j]->[$try]->{'_total'};
+ if ($total == 0) {
+ $concept_plot_data[$j] = 0;
+ } else {
+ $concept_plot_data[$j] = 100 *
+ sprintf('%0.3f',
+ $concept_data[$j]->[$try]->{'_correct'} /
+ $total);
+ }
+ }
#
- # 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++) {
- push (@{$CumulativePlotData[$i]->{'good'}},
- $CumulativePlotData[-1]->{'good'}+
- $ResponseData{$foilid}->[$i]->{'correct'});
- push (@{$CumulativePlotData[$i]->{'bad'}},
- $CumulativePlotData[-1]->{'bad'}+
- $ResponseData{$foilid}->[$i]->{'incorrect'});
+ my %lt = &Apache::lonlocal::texthash(
+ 'title' => 'Correct Concepts',
+ 'xlabel' => 'Concept Number',
+ 'ylabel' => 'Percent Correct');
+ $concept_graph = &Apache::loncommon::DrawBarGraph
+ ($lt{'title'},$lt{'xlabel'},$lt{'ylabel'},
+ 100,$plotcolors,undef,\@concept_plot_data,{xskip=>1});
}
- push(@Rows,\@Data);
- } continue {
- $index++;
- }
- my @Data = (' ');
- for (my $i=$mintries;$i<=$maxtries;$i++) {
- my $minstu = $ResponseData{$Foils[0]}->[$i]->{'total'};
- my $maxstu = $ResponseData{$Foils[0]}->[$i]->{'total'};
- foreach my $foilid (@Foils) {
- if ($minstu > $ResponseData{$foilid}->[$i]->{'total'}) {
- $minstu = $ResponseData{$foilid}->[$i]->{'total'};
- }
- if ($maxstu < $ResponseData{$foilid}->[$i]->{'total'}) {
- $maxstu = $ResponseData{$foilid}->[$i]->{'total'};
- }
- }
- $maxstu = 0 if (! $maxstu);
- $minstu = 0 if (! $minstu);
- my $graphlink;
- if ($maxstu == $minstu) {
- $graphlink = &Apache::loncommon::DrawGraph
- ('Attempt '.$i.', '.$maxstu.' students',
- 'Foil Number',
- 'Percent Correct',
- 100,
- $PlotData[$i]->{'good'},
- $PlotData[$i]->{'bad'});
- } else {
- $graphlink = &Apache::loncommon::DrawGraph
- ('Attempt '.$i.', '.$minstu.'-'.$maxstu.
- ' students',
- 'Foil Number',
- 'Percent Correct',
- 100,
- $PlotData[$i]->{'good'},
- $PlotData[$i]->{'bad'});
- }
- push(@Data,''.$graphlink.' ');
- }
- push (@Rows,\@Data);
- my $table = ''."\n";
- for (my $i=0; $i <=$#Rows;$i++) {
- $table .= ''.join('',@{$Rows[$i]})." \n";
+ #
+ # Create Foil Plots
+ my $data_count = $response_data{'_total'}->[$try];
+ my $correct = $response_data{'_correct'}->[$try];
+ $correct |= 0;
+ my @Datasets;
+ foreach my $option ('_correct',@{$ORdata->{'_Options'}}) {
+ next if (! exists($foil_plot[$try]->{$option}));
+ push(@Datasets,$foil_plot[$try]->{$option});
+ }
+ #
+ # Put a blank in the data set between concepts
+ for (my $set =0;$set<=$#Datasets;$set++) {
+ my @Data = @{$Datasets[$set]};
+ my $idx = 0;
+ foreach my $concept (@{$Concepts}) {
+ foreach my $foilid (@{$concept->{'foils'}}) {
+ $Datasets[$set]->[$idx++]=shift(@Data);
+ }
+ if ($concept->{'name'} ne $Concepts->[-1]->{'name'}) {
+ $Datasets[$set]->[$idx++] = 0;
+ }
+ }
+ }
+ #
+ # Set up the labels needed for the bar graph
+ my @Labels;
+ my $idx = 1;
+ foreach my $concept (@{$Concepts}) {
+ foreach my $foilid (@{$concept->{'foils'}}) {
+ push(@Labels,$idx++);
+ }
+ push(@Labels,'');
+ }
+ #
+ my %lt = &Apache::lonlocal::texthash(
+ 'title' => 'Correct Statements',
+ 'xlabel' => 'Statement',
+ 'ylabel' => '% Answered Correct');
+ my $correct_graph = &Apache::loncommon::DrawBarGraph
+ ($lt{'title'},$lt{'xlabel'},$lt{'ylabel'},
+ 100,$plotcolors,\@Labels,$Datasets[0],{xskip=>1});
+
+ #
+ #
+ next if (! defined($Datasets[0]));
+ for (my $i=0; $i< scalar(@{$Datasets[0]});$i++) {
+ $Datasets[0]->[$i]=0;
+ }
+ my $count = $response_data{'_total'}->[$try] -
+ $response_data{'_correct'}->[$try];
+ %lt = &Apache::lonlocal::texthash(
+ 'title' => 'Incorrect Statements',
+ 'xlabel' => 'Statement',
+ 'ylabel' => '% Chosen Incorrectly');
+ my $incorrect_graph = &Apache::loncommon::DrawBarGraph
+ ($lt{'title'},$lt{'xlabel'},$lt{'ylabel'},
+ 100,$plotcolors,\@Labels,@Datasets,{xskip=>1});
+ $analysis_html.=
+ ''.
+ ''.
+ &mt('Attempt [_1], [_2] submissions, [_3] correct, [_4] incorrect',
+ $try,$data_count,$correct,$data_count-$correct).
+ ' '.' '.$/.
+ ''.
+ ''.$concept_graph.' '.
+ ''.$correct_graph.' '.
+ ''.$incorrect_graph.' '.
+ ''.$optionkey.' '.
+ ' '.$/;
}
- $table .= '
';
- return ($table);
+ $analysis_html .= "
\n";
+ $table .= $analysis_html;
+ return $table;
}
-sub analyze_option_data_by_tries {
- my ($PerformanceData,$mintries,$maxtries) = @_;
+sub OR_analyze_by_tries {
+ my ($r,$PerformanceData,$mintries,$maxtries) = @_;
my %Trydata;
$mintries = 1 if (! defined($mintries) || $mintries < 1);
$maxtries = $mintries if (! defined($maxtries) || $maxtries < $mintries);
+ my @students;
foreach my $row (@$PerformanceData) {
next if (! defined($row));
- my ($grading,$submission,$time,$tries) = @$row;
- my @Foilgrades = split('&',$grading);
- my @Foilsubs = split('&',$submission);
- for (my $numtries = 1; $numtries <= $maxtries; $numtries++) {
- if ($tries == $numtries) {
- foreach my $foilgrade (@Foilgrades) {
- my ($foilid,$correct) = split('=',$foilgrade);
- if ($correct) {
- $Trydata{$foilid}->[$numtries]->{'correct'}++;
- } else {
- $Trydata{$foilid}->[$numtries]->{'incorrect'}++;
- }
+ my $tries = &get_tries_from_row($row);
+ my %Row = &Process_OR_Row($row);
+ next if (! %Row);
+ my $student_id = $row->[&Apache::loncoursedata::RD_student_id()];
+ $students[$tries]->{$student_id}++;
+ while (my ($foilid,$href) = each(%Row)) {
+ if (! ref($href)) {
+ $Trydata{$foilid}->[$tries] += $href;
+ next;
+ }
+ while (my ($option,$value) = each(%$href)) {
+ $Trydata{$foilid}->[$tries]->{$option}+=$value;
+ }
+ }
+ }
+ for (my $try=$mintries;$try<=$maxtries;$try++) {
+ $Trydata{'_studentcount'}->[$try] = scalar(keys(%{$students[$try]}));
+ }
+ return %Trydata;
+}
+
+#########################################################
+#
+# Option Response: Time Analysis
+#
+#########################################################
+sub OR_time_analysis {
+ my ($performance_data,$ORdata) = @_;
+ my ($table,$Foils,$Concepts) = &build_foil_index($ORdata);
+ my $foilkey = &build_option_index($ORdata);
+ my $num_concepts = 1;
+ if (defined($Concepts)) { $num_concepts = scalar(@$Concepts); }
+ #
+ if ($num_concepts < 2) {
+ $table = '
'.
+ &mt('Not enough data for concept analysis.'.
+ ' Performing Foil Analysis instead.').
+ '
'.
+ $table;
+ }
+ #
+ my $num_plots = $env{'form.NumPlots'};
+ my $num_data = scalar(@$performance_data)-1;
+ #
+ my $current_index;
+ $table .= "
\n";
+ for (my $i=0;$i<$num_plots;$i++) {
+ ##
+ my $starttime = &Apache::lonhtmlcommon::get_date_from_form
+ ('startdate_'.$i);
+ my $endtime = &Apache::lonhtmlcommon::get_date_from_form
+ ('enddate_'.$i);
+ if (! defined($starttime) || ! defined($endtime)) {
+ my $sec_in_day = 86400;
+ my $last_sub_time = &get_time_from_row($performance_data->[-1]);
+ my ($sday,$smon,$syear) =
+ (localtime($last_sub_time - $sec_in_day*$i))[3..5];
+ $starttime = &Time::Local::timelocal(0,0,0,$sday,$smon,$syear);
+ $endtime = $starttime + $sec_in_day;
+ if ($i == ($num_plots -1 )) {
+ $starttime = &get_time_from_row($performance_data->[0]);
+ }
+ }
+ $table .= ''.
+ &mt('Data from [_1] to [_2]',
+ &Apache::lonlocal::locallocaltime($starttime),
+ &Apache::lonlocal::locallocaltime($endtime)).
+ ' '.$/;
+ my $startdateform = &Apache::lonhtmlcommon::date_setter
+ ('Statistics','startdate_'.$i,$starttime);
+ my $enddateform = &Apache::lonhtmlcommon::date_setter
+ ('Statistics','enddate_'.$i,$endtime);
+ #
+ my $begin_index;
+ my $end_index;
+ my $j;
+ while (++$j < scalar(@$performance_data)) {
+ last if (&get_time_from_row($performance_data->[$j])
+ > $starttime);
+ }
+ $begin_index = $j;
+ while ($j < scalar(@$performance_data)) {
+ if (&get_time_from_row($performance_data->[$j]) > $endtime) {
+ last;
+ } else {
+ $j++;
+ }
+ }
+ $end_index = $j;
+ ##
+ my ($processed_time_data,$correct,$data_count,$student_count) =
+ &OR_time_process_data($performance_data,$begin_index,$end_index);
+ $correct |= 0;
+ ##
+ $table .= ''.
+ &mt('[quant,_1,submission,submissions,No submissions] from [quant,_2,student], [_3] correct, [_4] incorrect',
+ $data_count,$student_count,$correct,$data_count-$correct).
+ ' '.$/;
+ my $concept_correct_plot = '';
+ if ($num_concepts > 1) {
+ $concept_correct_plot =
+ &OR_Concept_Time_Analysis($processed_time_data,
+ $correct,$data_count,$student_count,
+ $ORdata,$Concepts);
+ }
+ my ($foil_correct_plot,$foil_incorrect_plot) =
+ &OR_Foil_Time_Analysis($processed_time_data,
+ $correct,$data_count,$student_count,
+ $ORdata,$Foils,$Concepts);
+ $table .= ''.
+ ''.$concept_correct_plot.' '.
+ ''.$foil_correct_plot.' '.
+ ''.$foil_incorrect_plot.' '.
+ ''.$foilkey.' '.$/;
+ $table .= ''.
+ &mt('Start time: [_1]',$startdateform).' '.
+ &mt('End time: [_1]',$enddateform).' '.$/;
+ $table.= ' '.$/;
+ }
+ $table .= '
';
+ #
+ return $table;
+}
+
+sub OR_Foil_Time_Analysis {
+ my ($processed_time_data,$correct,$data_count,$student_count,
+ $ORdata,$Foils,$Concepts) = @_;
+ if ($data_count <= 0) {
+ return ('
'
+ .&mt('There is no data to plot.')
+ .'
'
+ ,''
+ );
+ }
+ my $analysis_html;
+ my @plotdata;
+ my @labels;
+ foreach my $concept (@{$Concepts}) {
+ foreach my $foil (@{$concept->{'foils'}}) {
+ push(@labels,scalar(@labels)+1);
+ my $total = $processed_time_data->{$foil}->{'_total'};
+ if ($total == 0) {
+ push(@{$plotdata[0]},0);
+ } else {
+ push(@{$plotdata[0]},
+ 100 * $processed_time_data->{$foil}->{'_correct'} / $total);
+ }
+ my $total_incorrect = $total - $processed_time_data->{$foil}->{'_correct'};
+ for (my $i=0;$i
{'_Options'}});$i++) {
+ my $option = $ORdata->{'_Options'}->[$i];
+ if ($total_incorrect == 0) {
+ push(@{$plotdata[$i+1]},0);
+ } else {
+ push(@{$plotdata[$i+1]},
+ 100 * $processed_time_data->{$foil}->{$option} / $total_incorrect);
}
}
}
+ # Put in a blank one
+ push(@labels,'');
+ push(@{$plotdata[0]},0);
+ for (my $i=0;$i{'_Options'}});$i++) {
+ push(@{$plotdata[$i+1]},0);
+ }
+ }
+ #
+ # Create the plot
+ my %lt = &Apache::lonlocal::texthash(
+ 'title' => 'Correct Statements',
+ 'xlabel' => 'Statement Number',
+ 'ylabel' => 'Percent Correct');
+ my $correct_plot = &Apache::loncommon::DrawBarGraph($lt{'title'},
+ $lt{'xlabel'},
+ $lt{'ylabel'},
+ 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'})
- );
+ %lt = &Apache::lonlocal::texthash(
+ 'title' => 'Incorrect Statements',
+ 'xlabel' => 'Statement Number',
+ 'ylabel' => 'Incorrect Option Choice');
+ my $incorrect_plot =
+ &Apache::loncommon::DrawBarGraph($lt{'title'},
+ $lt{'xlabel'},
+ $lt{'ylabel'},
+ 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
+ my %lt = &Apache::lonlocal::texthash(
+ 'title' => 'Correct Concepts',
+ 'xlabel' => 'Concept Number',
+ 'ylabel' => 'Percent Correct');
+ return &Apache::loncommon::DrawBarGraph($lt{'title'},
+ $lt{'xlabel'},
+ $lt{'ylabel'},
+ 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 .= ''.&mt('Analyze By').' ';
- $Str .= ' '."\n";
- #
- $Str .= ''."\n";
+ $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 .= '';
- $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
+ $Str .= ' '."\n";
+ $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
$Str .= ' ';
#
$Str .= '';
- my $only_seq_with_assessments = sub {
- my $s=shift;
- if ($s->{'num_assess'} < 1) {
- return 0;
- } else {
- return 1;
- }
- };
- $Str .= &Apache::lonstatistics::MapSelect('Maps','multiple,all',5,
- $only_seq_with_assessments);
+ $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
$Str .= ' ';
#
- $Str .= '';
- $Str .=' ';
- $Str .=' ';
- $Str .= ' ';
- #
- $Str .= ' '."\n";
- $Str .= '
'."\n";
- $Str .= ' ';
- $Str .= ' 'x5;
- $Str .= ' ';
- $Str .= ' 'x5;
- return ($Str);
-}
-
-sub OptionResponseProblemSelector {
- my $Str;
- $Str = "\n\n";
- foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
- next if ($seq->{'num_assess'}<1);
- my $seq_str = '';
- foreach my $res (@{$seq->{'contents'}}) {
-# &Apache::lonnet::logthis('checking '.$res->{'title'});
- next if ($res->{'type'} ne 'assessment');
- foreach my $part (@{$res->{'parts'}}) {
- my $partdata = $res->{'partdata'}->{$part};
- if (! exists($partdata->{'option'}) ||
- $partdata->{'option'} == 0) {
- next;
- }
- for (my $i=0;$i{'ResponseTypes'}});$i++){
- my $respid = $partdata->{'ResponseIds'}->[$i];
- my $resptype = $partdata->{'ResponseTypes'}->[$i];
- if ($resptype eq 'option') {
- my $value = &Apache::lonnet::escape($res->{'symb'}.':'.$part.':'.$respid);
- my $checked = '';
- if ($ENV{'form.problemchoice'} eq $value) {
- $checked = 'checked ';
- }
- $seq_str .= ''.
- ' '.
- ' '.
- ''.$res->{'title'}.' ';
- if ($partdata->{'option'} > 1) {
- $seq_str .= &mt('response').' '.$respid;
- }
- $seq_str .= " \n";
- }
- }
- }
- }
- if ($seq_str ne '') {
- $Str .= '  '.$seq->{'title'}.' '.
- " \n".$seq_str;
- }
+ $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) {
+ $numplots_selector .= '';
}
- $Str .= "
\n";
+ $numplots_selector .= '';
+ $Str .= ''.&mt('Number of Plots [_1]',$numplots_selector).
+ ' ';
+ ##
+ $Str .= '';
+ ##
+ ##
+ $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;