--- loncom/interface/statistics/lonproblemanalysis.pm 2003/10/21 16:00:30 1.44 +++ loncom/interface/statistics/lonproblemanalysis.pm 2003/10/30 16:24:36 1.47 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemanalysis.pm,v 1.44 2003/10/21 16:00:30 matthew Exp $ +# $Id: lonproblemanalysis.pm,v 1.47 2003/10/30 16:24:36 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,6 +43,34 @@ my $plotcolors = ['#33ff00', '#66ccff', '#ff9999', '#cccc33', '#660000', '#33cc66', ]; +my @SubmitButtons = ({ name => 'ProblemAnalyis', + text => 'Analyze Problem Again' }, + { name => 'ClearCache', + text => 'Clear Caches' }, + { name => 'updatecaches', + text => 'Update Student Data' }, + { name => 'SelectAnother', + text => 'Choose a different resource' }, + { name => 'ExcelOutput', + text => 'Produce Excel Output' }); + +sub render_resource { + my ($resource) = @_; + ## + ## Render the problem + my $base; + ($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|); + $base = "http://".$ENV{'SERVER_NAME'}.$base; + my $rendered_problem = + &Apache::lonnet::ssi_body($resource->{'src'}); + $rendered_problem =~ s/<\s*form\s*/)|<\/nop>|g; + return '
'. + ''. + $rendered_problem. + '
'; +} + sub BuildProblemAnalysisPage { my ($r,$c)=@_; $r->print('

'.&mt('Option Response Problem Analysis').'

'); @@ -50,6 +78,11 @@ sub BuildProblemAnalysisPage { # my @Students = @Apache::lonstatistics::Students; # + if (@Students < 1) { + $r->print('

There are no students in the sections selected

'); + } + # + &Apache::loncoursedata::clear_internal_caches(); if (exists($ENV{'form.ClearCache'}) || exists($ENV{'form.updatecaches'}) || (exists($ENV{'form.firstanalysis'}) && @@ -62,94 +95,45 @@ sub BuildProblemAnalysisPage { $r->print(''); } $r->rflush(); + # if (exists($ENV{'form.problemchoice'}) && ! exists($ENV{'form.SelectAnother'})) { - $r->print(''); - $r->print(' 'x5); - $r->print(''); - $r->print(' 'x5); - $r->print(''); - $r->print(' 'x5); + foreach my $button (@SubmitButtons) { + $r->print(''); + $r->print(' 'x5); + } $r->print(''); - $r->print(''); - $r->print(' 'x5); - $r->print(''); - $r->print(' 'x5); # $r->print('
'); # - my ($symb,$part,$resid) = &get_problem_symb( - &Apache::lonnet::unescape($ENV{'form.problemchoice'}) - ); + my ($symb,$part,$resid,$resptype) = &get_problem_symb( + &Apache::lonnet::unescape($ENV{'form.problemchoice'})); $r->rflush(); # my $resource = &get_resource_from_symb($symb); - if (defined($resource)) { + if (! defined($resource) || ! defined($resptype)) { + $r->print('resource is undefined'); + } else { $r->print('

'.$resource->{'title'}.'

'); $r->print('

'.$resource->{'src'}.'

'); + $r->print(&render_resource($resource)); $r->rflush(); - my %Data = &get_problem_data($resource->{'src'}); - my $PerformanceData = - &Apache::loncoursedata::get_optionresponse_data - (\@Students,$symb,$resid); - my $ORdata = $Data{$part.'.'.$resid}; - if (exists($ENV{'form.ExcelOutput'}) && - defined($PerformanceData)) { - my $result = &prepare_excel_sheet($r,$resource, - $PerformanceData,$ORdata); - $r->print($result); - $r->rflush(); - } - ## - ## Render the problem - my $base; - ($base,undef) = ($resource->{'src'} =~ m|(.*/)[^/]*$|); - $base = "http://".$ENV{'SERVER_NAME'}.$base; - my $rendered_problem = - &Apache::lonnet::ssi_body($resource->{'src'}); - $rendered_problem =~ s/<\s*form\s*/)|<\/nop>|g; - $r->print('
'. - ''. - $rendered_problem. - '
'); - $r->rflush(); - if (! exists($ENV{'form.ExcelOutput'})) { - ## - ## Analyze the problem - if (defined($PerformanceData) && - ref($PerformanceData) eq 'ARRAY') { - if ($ENV{'form.AnalyzeOver'} eq 'Tries') { - my $analysis_html = &tries_analysis($r, - $PerformanceData, - $ORdata); - $r->print($analysis_html); - $r->rflush(); - } elsif ($ENV{'form.AnalyzeOver'} eq 'Time') { - my $analysis_html = &time_analysis($PerformanceData, - $ORdata); - $r->print($analysis_html); - $r->rflush(); - } else { - $r->print('

'. - &mt('The analysis you have selected is '. - 'not supported at this time'). - '

'); - } - } else { - $r->print('

'. - &mt('There is no student data for this problem.'). - '

'); - } + if ($resptype eq 'option') { + my %Data = &get_OR_problem_data($resource->{'src'}); + my $ProblemData = $Data{$part.'.'.$resid}; + &OptionResponseAnalysis($r,$resource,$resid,$ProblemData, + \@Students); + } elsif ($resptype eq 'radiobutton') { + $r->print('

This analysis is not supported

'); + my %Data = &get_Radio_problem_data($resource->{'src'}); + my $ProblemData = $Data{$part.'.'.$resid}; + &RadioResponseAnalysis($r,$resource,$resid,$ProblemData, + \@Students); + } else { + $r->print('

This analysis is not supported

'); } - } else { - $r->print('resource is undefined'); } $r->print('
'); } else { @@ -157,154 +141,83 @@ sub BuildProblemAnalysisPage { &mt('Analyze Problem').'" />'); $r->print(' 'x5); $r->print('

'.&mt('Please select a problem to analyze').'

'); - $r->print(&OptionResponseProblemSelector()); + $r->print(&ProblemSelector()); } } + ######################################################### ######################################################### ## -## Misc interface routines use by analysis code +## Radio Response Routines ## ######################################################### ######################################################### -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{$a})) { - $a1 = $Numbers{$a}; - } - if (exists($Numbers{$b})) { - $b1 = $Numbers{$b}; - } - $a1 cmp $b1; - }; - my @Concepts; - foreach my $concept (sort $sortfunction (keys(%Concepts))) { - push(@Concepts,{ name => $concept, - foils => [@{$Concepts{$concept}}]}); - push(@Foils,(@{$Concepts{$concept}})); - } - # - # Build up the table of row labels. - my $table = ''."\n"; - if (@Concepts > 1) { - $table .= ''. - ''. - ''. - ''. - ''. - ''. - ''. - "\n"; - } else { - $table .= ''. - ''. - ''. - ''. - ''. - "\n"; - } - my $conceptindex = 1; - my $foilindex = 1; - foreach my $concept (@Concepts) { - my @FoilsInConcept = @{$concept->{'foils'}}; - my $firstfoil = shift(@FoilsInConcept); - if (@Concepts > 1) { - $table .= ''. - ''. - ''. - ''. - ''. - ''. - ''. - "\n"; +sub RadioResponseAnalysis { + my ($r,$resource,$resid,$ProblemData,$Students) = @_; + my $PerformanceData = + &Apache::loncoursedata::get_response_data + ($Students,$resource->{'symb'},$resid); + if (! ref($PerformanceData)) { + $r->print('

There is no submission data for this resource

'); + return; + } +# foreach my $row (@$PerformanceData) { +# &Apache::lonnet::logthis('row = '.join(',',@$row)); +# } + return; +} +######################################################### +######################################################### +## +## Option Response Routines +## +######################################################### +######################################################### +sub OptionResponseAnalysis { + my ($r,$resource,$resid,$ProblemData,$Students) = @_; + my $PerformanceData = + &Apache::loncoursedata::get_response_data + ($Students,$resource->{'symb'},$resid); + if (! defined($PerformanceData) || + ref($PerformanceData) ne 'ARRAY' ) { + $r->print('

'. + &mt('There is no student data for this problem.'). + '

'); + } else { + $r->rflush(); + if (exists($ENV{'form.ExcelOutput'})) { + my $result = &prepare_optionresponse_excel_sheet($r,$resource, + $PerformanceData, + $ProblemData); + $r->print($result); + $r->rflush(); } else { - $table .= ''. - ''. - ''. - ''. - ''. - "\n"; - } - foreach my $foilid (@FoilsInConcept) { - if (@Concepts > 1) { - $table .= ''. - ''. - ''. - ''. - ''. - ''. - ''. - "\n"; + if ($ENV{'form.AnalyzeOver'} eq 'Tries') { + my $analysis_html = &tries_analysis($r, + $PerformanceData, + $ProblemData); + $r->print($analysis_html); + $r->rflush(); + } elsif ($ENV{'form.AnalyzeOver'} eq 'Time') { + my $analysis_html = &time_analysis($PerformanceData, + $ProblemData); + $r->print($analysis_html); + $r->rflush(); } else { - $table .= ''. - ''. - ''. - ''. - ''. - "\n"; - } - } continue { - $foilindex++; + $r->print('

'. + &mt('The analysis you have selected is '. + 'not supported at this time'). + '

'); + } } - } continue { - $conceptindex++; } - $table .= "
'.&mt('Concept Number').''.&mt('Concept').''.&mt('Foil Number').''.&mt('Foil Name').''.&mt('Foil Text').''.&mt('Correct Value').'
'.&mt('Foil Number').''.&mt('Foil Name').''.&mt('Foil Text').''.&mt('Correct Value').'
'.$conceptindex.''.$concept->{'name'}.''.$foilindex++.''.$Foildata{$firstfoil}->{'name'}.''.$Foildata{$firstfoil}->{'text'}.''.$Foildata{$firstfoil}->{'value'}.'
'.$foilindex++.''.$Foildata{$firstfoil}->{'name'}.''.$Foildata{$firstfoil}->{'text'}.''.$Foildata{$firstfoil}->{'value'}.'
'.$foilindex.''.$Foildata{$foilid}->{'name'}.''.$Foildata{$foilid}->{'text'}.''.$Foildata{$foilid}->{'value'}.'
'.$foilindex.''.$Foildata{$foilid}->{'name'}.''.$Foildata{$foilid}->{'text'}.''.$Foildata{$foilid}->{'value'}.'
\n"; - # - # 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'}}) { - push (@Rows, - ''. - ''. - ''. - "\n"); - } - shift(@Rows); # Throw away 'correct option chosen' color - $table .= join('',reverse(@Rows)); - $table .= "
'. - (' 'x4).''.$option.'
\n"; -} - -######################################################### -######################################################### -## -## Tries Analysis -## ######################################################### +# +# Option Response: Tries Analysis +# ######################################################### sub tries_analysis { my ($r,$PerformanceData,$ORdata) = @_; @@ -385,7 +298,7 @@ sub Tries_Foil_Analysis { next if (! exists($PlotData[$i]->{$option})); push(@Datasets,$PlotData[$i]->{$option}); } - my $correctgraph = &Apache::loncommon::DrawGraph + my $correctgraph = &Apache::loncommon::DrawBarGraph ($title,'Foil Number','Percent Correct', 100,$plotcolors,$Datasets[0]); $analysis_html.= ''.$correctgraph.''; @@ -403,7 +316,7 @@ sub Tries_Foil_Analysis { $count = $count.' submissions'; } $title = 'Attempt '.$i.', '.$count; - my $incorrectgraph = &Apache::loncommon::DrawGraph + my $incorrectgraph = &Apache::loncommon::DrawBarGraph ($title,'Foil Number','% Option Chosen Incorrectly', 100,$plotcolors,@Datasets); $analysis_html.= ''.$incorrectgraph.''; @@ -470,7 +383,7 @@ sub Tries_Concept_Analysis { $count = $count.' submissions'; } $title = 'Attempt '.$i.', '.$count; - my $graphlink = &Apache::loncommon::DrawGraph + my $graphlink = &Apache::loncommon::DrawBarGraph ($title,'Concept Number','Percent Correct', 100,$plotcolors,$PlotData[$i]->{'_correct'}); $analysis_html.= ''.$graphlink."\n"; @@ -487,7 +400,7 @@ sub analyze_option_data_by_tries { foreach my $row (@$PerformanceData) { next if (! defined($row)); my $tries = &get_tries_from_row($row); - my %Row = &Process_Row($row); + my %Row = &Process_OR_Row($row); next if (! %Row); while (my ($foilid,$href) = each(%Row)) { if (! ref($href)) { @@ -503,11 +416,9 @@ sub analyze_option_data_by_tries { } ######################################################### -######################################################### -## -## Time Analysis -## -######################################################### +# +# Option Response: Time Analysis +# ######################################################### sub time_analysis { my ($PerformanceData,$ORdata) = @_; @@ -551,7 +462,8 @@ sub time_analysis { my $end_index; my $j; while (++$j < scalar(@$PerformanceData)) { - last if (&get_time_from_row($PerformanceData->[$j]) > $starttime); + last if (&get_time_from_row($PerformanceData->[$j]) + > $starttime); } $begin_index = $j; while (++$j < scalar(@$PerformanceData)) { @@ -589,7 +501,7 @@ sub Foil_Time_Analysis { for (my $j=$begin_index;$j<=$end_index;$j++) { my $row = $PerformanceData->[$j]; next if (! defined($row)); - my %Row = &Process_Row($row); + my %Row = &Process_OR_Row($row); while (my ($foilid,$href) = each(%Row)) { if (! ref($href)) { $TimeData{$foilid} += $href; @@ -633,12 +545,12 @@ sub Foil_Time_Analysis { } else { $title = $count.' submissions'; } - my $correctplot = &Apache::loncommon::DrawGraph($title, - 'Foil Number', - 'Percent Correct', - 100, - $plotcolors, - $Plotdata[0]); + my $correctplot = &Apache::loncommon::DrawBarGraph($title, + 'Foil Number', + 'Percent Correct', + 100, + $plotcolors, + $Plotdata[0]); for (my $j=0; $j< scalar(@{$Plotdata[0]});$j++) { $Plotdata[0]->[$j]=0; } @@ -650,7 +562,7 @@ sub Foil_Time_Analysis { } else { $title = $count.' submissions'; } - my $incorrectplot = &Apache::loncommon::DrawGraph($title, + my $incorrectplot = &Apache::loncommon::DrawBarGraph($title, 'Foil Number', 'Incorrect Option Choice', 100, @@ -685,7 +597,7 @@ sub Concept_Time_Analysis { for (my $j=$begin_index;$j<=$end_index;$j++) { my $row = $PerformanceData->[$j]; next if (! defined($row)); - my %Row = &Process_Row($row); + my %Row = &Process_OR_Row($row); while (my ($foilid,$href) = each(%Row)) { if (! ref($href)) { $TimeData{$foilid} += $href; @@ -714,7 +626,7 @@ sub Concept_Time_Analysis { # # Create the plot my $title = ($end_index - $begin_index).' submissions'; - my $correctplot = &Apache::loncommon::DrawGraph($title, + my $correctplot = &Apache::loncommon::DrawBarGraph($title, 'Concept Number', 'Percent Correct', 100, @@ -740,7 +652,7 @@ sub Concept_Time_Analysis { ## ######################################################### ######################################################### -sub prepare_excel_sheet { +sub prepare_optionresponse_excel_sheet { my ($r,$resource,$PerformanceData,$ORdata) = @_; my $response = ''; my (undef,$Foils,$Concepts) = &build_foil_index($ORdata); @@ -1130,10 +1042,141 @@ sub _adjustment { return $adjust; } +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{$a})) { + $a1 = $Numbers{$a}; + } + if (exists($Numbers{$b})) { + $b1 = $Numbers{$b}; + } + $a1 cmp $b1; + }; + my @Concepts; + foreach my $concept (sort $sortfunction (keys(%Concepts))) { + push(@Concepts,{ name => $concept, + foils => [@{$Concepts{$concept}}]}); + push(@Foils,(@{$Concepts{$concept}})); + } + # + # Build up the table of row labels. + my $table = ''."\n"; + if (@Concepts > 1) { + $table .= ''. + ''. + ''. + ''. + ''. + ''. + ''. + "\n"; + } else { + $table .= ''. + ''. + ''. + ''. + ''. + "\n"; + } + my $conceptindex = 1; + my $foilindex = 1; + foreach my $concept (@Concepts) { + my @FoilsInConcept = @{$concept->{'foils'}}; + my $firstfoil = shift(@FoilsInConcept); + if (@Concepts > 1) { + $table .= ''. + ''. + ''. + ''. + ''. + ''. + ''. + "\n"; + } else { + $table .= ''. + ''. + ''. + ''. + ''. + "\n"; + } + foreach my $foilid (@FoilsInConcept) { + if (@Concepts > 1) { + $table .= ''. + ''. + ''. + ''. + ''. + ''. + ''. + "\n"; + } else { + $table .= ''. + ''. + ''. + ''. + ''. + "\n"; + } + } continue { + $foilindex++; + } + } continue { + $conceptindex++; + } + $table .= "
'.&mt('Concept Number').''.&mt('Concept').''.&mt('Foil Number').''.&mt('Foil Name').''.&mt('Foil Text').''.&mt('Correct Value').'
'.&mt('Foil Number').''.&mt('Foil Name').''.&mt('Foil Text').''.&mt('Correct Value').'
'.$conceptindex.''.$concept->{'name'}.''.$foilindex++.''.$Foildata{$firstfoil}->{'name'}.''.$Foildata{$firstfoil}->{'text'}.''.$Foildata{$firstfoil}->{'value'}.'
'.$foilindex++.''.$Foildata{$firstfoil}->{'name'}.''.$Foildata{$firstfoil}->{'text'}.''.$Foildata{$firstfoil}->{'value'}.'
'.$foilindex.''.$Foildata{$foilid}->{'name'}.''.$Foildata{$foilid}->{'text'}.''.$Foildata{$foilid}->{'value'}.'
'.$foilindex.''.$Foildata{$foilid}->{'name'}.''.$Foildata{$foilid}->{'text'}.''.$Foildata{$foilid}->{'value'}.'
\n"; + # + # 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'}}) { + push (@Rows, + ''. + ''. + ''. + "\n"); + } + shift(@Rows); # Throw away 'correct option chosen' color + $table .= join('',reverse(@Rows)); + $table .= "
'. + (' 'x4).''.$option.'
\n"; +} + ######################################################### ######################################################### ## -## Interface +## Generic Interface Routines ## ######################################################### ######################################################### @@ -1232,7 +1275,7 @@ sub CreateInterface { return $Str; } -sub OptionResponseProblemSelector { +sub ProblemSelector { my $Str; $Str = "\n\n"; foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) { @@ -1242,15 +1285,25 @@ sub OptionResponseProblemSelector { next if ($res->{'type'} ne 'assessment'); foreach my $part (@{$res->{'parts'}}) { my $partdata = $res->{'partdata'}->{$part}; - if (! exists($partdata->{'option'}) || - $partdata->{'option'} == 0) { +# &Apache::lonnet::logthis('----------------'); +# while (my ($k,$v)=each(%$partdata)) { +# if (ref($v) eq 'ARRAY') { +# &Apache::lonnet::logthis($k.' = '.join(',',@$v)); +# } else { +# &Apache::lonnet::logthis($k.' = '.$v); +# } +# } + if ((! exists($partdata->{'option'}) || + $partdata->{'option'} == 0 ) && + (! exists($partdata->{'radiobutton'}) || + $partdata->{'radiobutton'} == 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); + if ($resptype eq 'option' || $resptype eq 'radiobutton') { + my $value = &Apache::lonnet::escape($res->{'symb'}.':'.$part.':'.$respid.':'.$resptype); my $checked = ''; if ($ENV{'form.problemchoice'} eq $value) { $checked = 'checked '; @@ -1258,7 +1311,7 @@ sub OptionResponseProblemSelector { $seq_str .= '
'. ''. ''. - ''.$res->{'title'}.' '; + ''.$resptype.' '.$res->{'title'}.' '; if ($partdata->{'option'} > 1) { $seq_str .= &mt('response').' '.$respid; } @@ -1285,8 +1338,9 @@ sub OptionResponseProblemSelector { ######################################################### sub get_problem_symb { my $problemstring = shift(); - my ($symb,$partid,$resid) = ($problemstring=~ /^(.*):([^:]*):([^:]*)$/); - return ($symb,$partid,$resid); + my ($symb,$partid,$resid,$resptype) = + ($problemstring=~ /^(.*):([^:]*):([^:]*):([^:]*)$/); + return ($symb,$partid,$resid,$resptype); } sub get_resource_from_symb { @@ -1301,10 +1355,18 @@ sub get_resource_from_symb { return undef; } + +######################################################### +######################################################### +## +## Misc Option Response functions +## +######################################################### +######################################################### sub get_time_from_row { my ($row) = @_; if (ref($row)) { - return $row->[3]; + return $row->[&Apache::loncoursedata::RD_timestamp()]; } return undef; } @@ -1312,15 +1374,20 @@ sub get_time_from_row { sub get_tries_from_row { my ($row) = @_; if (ref($row)) { - return $row->[5]; + return $row->[&Apache::loncoursedata::RD_tries()]; } return undef; } -sub Process_Row { +sub Process_OR_Row { my ($row) = @_; my %RowData; - my ($student_id,$award,$grading,$submission,$time,$tries) = @$row; + 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 ($award =~ /(APPROX_ANS|EXACT_ANS)/) { $RowData{'_correct'} = 1; @@ -1347,7 +1414,7 @@ sub Process_Row { ## note: we must force each foil and option to not begin or end with ## spaces as they are stored without such data. ## -sub get_problem_data { +sub get_OR_problem_data { my ($url) = @_; my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze')); (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2); @@ -1383,6 +1450,50 @@ sub get_problem_data { } } } + return %Partdata; +} + +######################################################### +######################################################### +## +## Misc Radio Response functions +## +######################################################### +######################################################### +sub get_Radio_problem_student_data { + my ($row) = @_; +} + +sub get_Radio_problem_data { + my ($url) = @_; + my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze')); + (my $garbage,$Answ)=split(/_HASH_REF__/,$Answ,2); + my %Answer; + %Answer=&Apache::lonnet::str2hash($Answ); + my %Partdata; + &Apache::lonnet::logthis('url = '.$url); + foreach my $part (@{$Answer{'parts'}}) { + while (my($key,$value) = each(%Answer)) { + if (ref($value) eq 'ARRAY') { + &Apache::lonnet::logthis('is ref part:'.$part.' '.$key.'='.join(',',@$value)); + } else { + &Apache::lonnet::logthis('notref part:'.$part.' '.$key.'='.$value); + } + next if ($key !~ /^$part/); + $key =~ s/^$part\.//; + if ($key eq 'foils') { + $Partdata{$part}->{'_Foils'}=$value; + } elsif ($key eq 'options') { + $Partdata{$part}->{'_Options'}=$value; + } elsif ($key eq 'shown') { + $Partdata{$part}->{'_Shown'}=$value; + } elsif ($key =~ /^foil.value.(.*)$/) { + $Partdata{$part}->{$1}->{'value'}=$value; + } elsif ($key =~ /^foil.text.(.*)$/) { + $Partdata{$part}->{$1}->{'text'}=$value; + } + } + } return %Partdata; }