[LON-CAPA-cvs] cvs: loncom /interface/statistics lonproblemanalysis.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Thu, 30 Oct 2003 16:24:36 -0000
This is a MIME encoded message
--matthew1067531076
Content-Type: text/plain
matthew Thu Oct 30 11:24:36 2003 EDT
Modified files:
/loncom/interface/statistics lonproblemanalysis.pm
Log:
Works with new version of loncoursedata.pm. Radio response analysis is
not fully functional, although you can select those resources.
--matthew1067531076
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20031030112436.txt"
Index: loncom/interface/statistics/lonproblemanalysis.pm
diff -u loncom/interface/statistics/lonproblemanalysis.pm:1.46 loncom/interface/statistics/lonproblemanalysis.pm:1.47
--- loncom/interface/statistics/lonproblemanalysis.pm:1.46 Fri Oct 24 09:38:06 2003
+++ loncom/interface/statistics/lonproblemanalysis.pm Thu Oct 30 11:24:36 2003
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonproblemanalysis.pm,v 1.46 2003/10/24 13:38:06 matthew Exp $
+# $Id: lonproblemanalysis.pm,v 1.47 2003/10/30 16:24:36 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -108,21 +108,32 @@
#
$r->print('<hr />');
#
- my ($symb,$part,$resid) = &get_problem_symb(
+ 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('<h1>'.$resource->{'title'}.'</h1>');
$r->print('<h3>'.$resource->{'src'}.'</h3>');
+ $r->print(&render_resource($resource));
$r->rflush();
- my %Data = &get_problem_data($resource->{'src'});
- my $ProblemData = $Data{$part.'.'.$resid};
- &OptionResponseAnalysis($r,$resource,$resid,$ProblemData,
- \@Students);
+ 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('<h2>This analysis is not supported</h2>');
+ my %Data = &get_Radio_problem_data($resource->{'src'});
+ my $ProblemData = $Data{$part.'.'.$resid};
+ &RadioResponseAnalysis($r,$resource,$resid,$ProblemData,
+ \@Students);
+ } else {
+ $r->print('<h2>This analysis is not supported</h2>');
+ }
}
$r->print('<hr />');
} else {
@@ -134,6 +145,28 @@
}
}
+
+#########################################################
+#########################################################
+##
+## Radio Response Routines
+##
+#########################################################
+#########################################################
+sub RadioResponseAnalysis {
+ my ($r,$resource,$resid,$ProblemData,$Students) = @_;
+ my $PerformanceData =
+ &Apache::loncoursedata::get_response_data
+ ($Students,$resource->{'symb'},$resid);
+ if (! ref($PerformanceData)) {
+ $r->print('<h2>There is no submission data for this resource</h2>');
+ return;
+ }
+# foreach my $row (@$PerformanceData) {
+# &Apache::lonnet::logthis('row = '.join(',',@$row));
+# }
+ return;
+}
#########################################################
#########################################################
##
@@ -143,9 +176,8 @@
#########################################################
sub OptionResponseAnalysis {
my ($r,$resource,$resid,$ProblemData,$Students) = @_;
- &Apache::lonnet::logthis('resid = '.$resid);
my $PerformanceData =
- &Apache::loncoursedata::get_optionresponse_data
+ &Apache::loncoursedata::get_response_data
($Students,$resource->{'symb'},$resid);
if (! defined($PerformanceData) ||
ref($PerformanceData) ne 'ARRAY' ) {
@@ -153,7 +185,6 @@
&mt('There is no student data for this problem.').
'</h2>');
} else {
- $r->print(&render_resource($resource));
$r->rflush();
if (exists($ENV{'form.ExcelOutput'})) {
my $result = &prepare_optionresponse_excel_sheet($r,$resource,
@@ -368,7 +399,7 @@
$maxtries = $mintries if (! defined($maxtries) || $maxtries < $mintries);
foreach my $row (@$PerformanceData) {
next if (! defined($row));
- my $tries = &get_tries_from_OR_row($row);
+ my $tries = &get_tries_from_row($row);
my %Row = &Process_OR_Row($row);
next if (! %Row);
while (my ($foilid,$href) = each(%Row)) {
@@ -412,14 +443,14 @@
('enddate_'.$i);
if (! defined($starttime) || ! defined($endtime)) {
my $sec_in_day = 86400;
- my $last_sub_time = &get_time_from_OR_row($PerformanceData->[-1]);
+ my $last_sub_time = &get_time_from_row($PerformanceData->[-1]);
my ($sday,$smon,$syear);
(undef,undef,undef,$sday,$smon,$syear) =
localtime($last_sub_time - $sec_in_day*$i);
$starttime = &Time::Local::timelocal(0,0,0,$sday,$smon,$syear);
$endtime = $starttime + $sec_in_day;
if ($i == ($num_plots -1 )) {
- $starttime = &get_time_from_OR_row($PerformanceData->[0]);
+ $starttime = &get_time_from_row($PerformanceData->[0]);
}
}
my $startdateform = &Apache::lonhtmlcommon::date_setter
@@ -431,12 +462,12 @@
my $end_index;
my $j;
while (++$j < scalar(@$PerformanceData)) {
- last if (&get_time_from_OR_row($PerformanceData->[$j])
+ last if (&get_time_from_row($PerformanceData->[$j])
> $starttime);
}
$begin_index = $j;
while (++$j < scalar(@$PerformanceData)) {
- last if (&get_time_from_OR_row($PerformanceData->[$j]) > $endtime);
+ last if (&get_time_from_row($PerformanceData->[$j]) > $endtime);
}
$end_index = $j;
##
@@ -1254,15 +1285,25 @@
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<scalar(@{$partdata->{'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 ';
@@ -1270,7 +1311,7 @@
$seq_str .= '<tr><td>'.
'<input type="radio" name="problemchoice" value="'.$value.'" '.$checked.'/>'.
'</td><td>'.
- '<a href="'.$res->{'src'}.'">'.$res->{'title'}.'</a> ';
+ '<a href="'.$res->{'src'}.'">'.$resptype.' '.$res->{'title'}.'</a> ';
if ($partdata->{'option'} > 1) {
$seq_str .= &mt('response').' '.$respid;
}
@@ -1297,8 +1338,9 @@
#########################################################
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 {
@@ -1313,18 +1355,26 @@
return undef;
}
-sub get_time_from_OR_row {
+
+#########################################################
+#########################################################
+##
+## Misc Option Response functions
+##
+#########################################################
+#########################################################
+sub get_time_from_row {
my ($row) = @_;
if (ref($row)) {
- return $row->[4];
+ return $row->[&Apache::loncoursedata::RD_timestamp()];
}
return undef;
}
-sub get_tries_from_OR_row {
+sub get_tries_from_row {
my ($row) = @_;
if (ref($row)) {
- return $row->[5];
+ return $row->[&Apache::loncoursedata::RD_tries()];
}
return undef;
}
@@ -1332,7 +1382,12 @@
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;
@@ -1359,7 +1414,7 @@
## 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);
@@ -1392,6 +1447,50 @@
my $foil = $1;
$Partdata{$part}->{'Foils'}->{$foil}->{'value'}=$value;
}
+ }
+ }
+ }
+ 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;
}
}
}
--matthew1067531076--