'
+ .&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(''
+ );
+ }
+ }
+}
-# Joson code for reading data from cache
-=pod
-sub OpStatus {
- my ($problemID, $student, $ConceptData, $foil_to_concept,
- $analyzeData, $cache)=@_;
-
- my $ids = $analyzeData->{'parts'};
-
- my @True = ();
- my @False = ();
- my $flag=0;
-
- my $tries=0;
-
- foreach my $id (@$ids) {
- my ($part, $response) = split(/\./, $id);
- my $time=$cache->{$student.':'.$problemID.':'.$part.':timestamp'};
- my @submissions = split(':::', $cache->{$student.':'.$problemID.':'.
- $part.':'.$response.
- ':submission'});
- foreach my $Resp (@submissions) {
- my %submission=&Apache::lonnet::str2hash($Resp);
- foreach (keys(%submission)) {
- if($submission{$_}) {
- my $answer = $analyzeData->{$id.'.foil.value.'.$_};
- if($submission{$_} eq $answer) {
- &Decide("true", $foil_to_concept->{$_},
- $time, $ConceptData);
+#########################################################
+#
+# Option Response: tries Analysis
+#
+#########################################################
+sub OR_tries_analysis {
+ my ($r,$PerformanceData,$ORdata) = @_;
+ my $mintries = 1;
+ my $maxtries = $env{'form.NumPlots'};
+ my ($table,$Foils,$Concepts) = &build_foil_index($ORdata);
+ if (! defined($Concepts)) {
+ $Concepts = [];
+ }
+ 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 {
- &Decide("false", $foil_to_concept->{$_},
- $time, $ConceptData);
+ 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);
}
}
+ #
+ 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});
}
- }
-
- return;
+ #
+ # 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.' | '.
+ ' |
'.$/;
+ }
+ $analysis_html .= "
\n";
+ $table .= $analysis_html;
+ return $table;
}
-=cut
+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 $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;
+}
-#restore the student submissions and finding the result
+#########################################################
+#
+# 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 OpStatus {
- my ($problemID, $student, $ConceptData, $foil_to_concept,
- $analyzeData, $cache, $courseID)=@_;
-
- my $ids = $analyzeData->{'parts'};
- my ($uname,$udom)=split(/\:/,$student);
- my $symb = $cache->{$problemID.':problem'};
-
- my @True = ();
- my @False = ();
- my $flag=0;
- my $tries=0;
-
- foreach my $id (@$ids) {
- my ($part, $response) = split(/\./, $id);
- my %reshash=&Apache::lonnet::restore($symb,$courseID,$udom,$uname);
- if ($reshash{'version'}) {
- my $tries=0;
- for (my $version=1;$version<=$reshash{'version'};$version++) {
- my $time=$reshash{"$version:timestamp"};
- foreach my $key (sort(split(/\:/,$reshash{$version.':keys'}))) {
- if (($key=~/\.(\w+)\.(\w+)\.submission$/)) {
- my $Id1 = $1; my $Id2 = $2;
- #check if this is a repeat submission, if so skip it
- if ($reshash{"$version:resource.$Id1.previous"}) { next; }
- #if no solved this wasn't a real submission, ignore it
- if (!defined($reshash{"$version:resource.$Id1.solved"})) {
- &Apache::lonxml::debug("skipping ");
- next;
- }
- my $Resp = $reshash{"$version:$key"};
- my %submission=&Apache::lonnet::str2hash($Resp);
- foreach (keys %submission) {
- my $Ansr = $analyzeData->{"$Id1.$Id2.foil.value.$_"};
- if($submission{$_} eq $Ansr) {
- &Decide("true", $foil_to_concept->{$_},
- $time, $ConceptData);
- } else {
- &Decide("false", $foil_to_concept->{$_},
- $time, $ConceptData);
- }
- }
- }
- }
+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);
}
}
-
- return;
+ #
+ # 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;
+ }
+ %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);
+ }
+ }
+ #
+ # 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 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 .= '';
+ $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__