version 1.29, 2004/11/03 16:13:08
|
version 1.33, 2004/12/03 21:20:28
|
Line 150 sub ProblemSelector {
|
Line 150 sub ProblemSelector {
|
$seq_str .= &mt('response').' '.$respid; |
$seq_str .= &mt('response').' '.$respid; |
} |
} |
$seq_str .= (' 'x2). |
$seq_str .= (' 'x2). |
qq{<a target="preview" href="$res->{'src'}">view</a>}; |
qq{<a target="preview" href="$res->{'src'}?symb=$res->{'symb'}">view</a>}; |
$seq_str .= "</td></tr>\n"; |
$seq_str .= "</td></tr>\n"; |
$rb_count++; |
$rb_count++; |
} |
} |
Line 555 Returns: nothing
|
Line 555 Returns: nothing
|
##################################################### |
##################################################### |
sub GetStudentAnswers { |
sub GetStudentAnswers { |
my ($r,$problem,$Students,$formname,$inputname) = @_; |
my ($r,$problem,$Students,$formname,$inputname) = @_; |
|
my %answers; |
my $status_type; |
my $status_type; |
if (defined($formname)) { |
if (defined($formname)) { |
$status_type = 'inline'; |
$status_type = 'inline'; |
Line 578 sub GetStudentAnswers {
|
Line 579 sub GetStudentAnswers {
|
last if ($c->aborted()); |
last if ($c->aborted()); |
my $sname = $student->{'username'}; |
my $sname = $student->{'username'}; |
my $sdom = $student->{'domain'}; |
my $sdom = $student->{'domain'}; |
my $answer = &Apache::lonstathelpers::analyze_problem_as_student |
my $answer = &Apache::lonstathelpers::get_student_answer |
($resource,$sname,$sdom,$partid,$respid); |
($resource,$sname,$sdom,$partid,$respid); |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
&mt('last student')); |
&mt('last student')); |
|
$answers{$answer}++; |
$student->{'answer'} = $answer; |
$student->{'answer'} = $answer; |
} |
} |
&Apache::lonstathelpers::write_analysis_cache(); |
&Apache::lonstathelpers::write_analysis_cache(); |
Line 589 sub GetStudentAnswers {
|
Line 591 sub GetStudentAnswers {
|
$r->rflush(); |
$r->rflush(); |
# close progress window |
# close progress window |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
return; |
return \%answers; |
} |
} |
|
|
##################################################### |
##################################################### |
Line 599 sub GetStudentAnswers {
|
Line 601 sub GetStudentAnswers {
|
|
|
=item analyze_problem_as_student |
=item analyze_problem_as_student |
|
|
Analyzes a homework problem for a student and returns the correct answer |
Analyzes a homework problem for a student |
for the student. Attempts to put together an answer for problem types |
|
that do not natively support it. |
|
|
|
Inputs: $resource: a resource object |
Inputs: $resource: a resource object |
$sname, $sdom, $partid, $respid |
$sname, $sdom, $partid, $respid |
|
|
Returns: $answer |
Returns: the problem analysis hash |
|
|
If $partid and $respid are specified, $answer is simply a scalar containing |
|
the correct answer for the response. |
|
|
|
If $partid or $respid are undefined, $answer will be a hash reference with |
|
keys $partid.'.'.$respid.'.answer'. |
|
|
|
=cut |
=cut |
|
|
##################################################### |
##################################################### |
##################################################### |
##################################################### |
sub analyze_problem_as_student { |
sub analyze_problem_as_student { |
my ($resource,$sname,$sdom,$partid,$respid) = @_; |
my ($resource,$sname,$sdom) = @_; |
if (ref($resource) ne 'HASH') { |
if (ref($resource) ne 'HASH') { |
my $res = $resource; |
my $res = $resource; |
$resource = { 'src' => $res->src, |
$resource = { 'src' => $res->src, |
Line 630 sub analyze_problem_as_student {
|
Line 624 sub analyze_problem_as_student {
|
[$res->responseIds($part)]; |
[$res->responseIds($part)]; |
} |
} |
} |
} |
my $returnvalue; |
|
my $url = $resource->{'src'}; |
my $url = $resource->{'src'}; |
my $symb = $resource->{'symb'}; |
my $symb = $resource->{'symb'}; |
my $analysis = &get_from_analysis_cache($sname,$sdom,$symb); |
my $analysis = &get_from_analysis_cache($sname,$sdom,$symb); |
if (! defined($analysis)) { |
if (! defined($analysis)) { |
&Apache::lonnet::logthis('uncached analysis'); |
|
my $courseid = $ENV{'request.course.id'}; |
my $courseid = $ENV{'request.course.id'}; |
my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze', |
my $Answ=&Apache::lonnet::ssi($url,('grade_target' => 'analyze', |
'grade_domain' => $sdom, |
'grade_domain' => $sdom, |
Line 647 sub analyze_problem_as_student {
|
Line 639 sub analyze_problem_as_student {
|
} |
} |
my %Answer=&Apache::lonnet::str2hash($analysis); |
my %Answer=&Apache::lonnet::str2hash($analysis); |
# |
# |
|
return \%Answer; |
|
} |
|
|
|
##################################################### |
|
##################################################### |
|
|
|
=pod |
|
|
|
=item get_student_answer |
|
|
|
Analyzes a homework problem for a particular student and returns the correct |
|
answer. Attempts to put together an answer for problem types |
|
that do not natively support it. |
|
|
|
Inputs: $resource: a resource object (from navmaps or hash from loncoursedata) |
|
$sname, $sdom, $partid, $respid |
|
|
|
Returns: $answer |
|
|
|
If $partid and $respid are specified, $answer is simply a scalar containing |
|
the correct answer for the response. |
|
|
|
If $partid or $respid are undefined, $answer will be a hash reference with |
|
keys $partid.'.'.$respid.'.answer'. |
|
|
|
=cut |
|
|
|
##################################################### |
|
##################################################### |
|
sub get_student_answer { |
|
my ($resource,$sname,$sdom,$partid,$respid) = @_; |
|
# |
|
if (ref($resource) ne 'HASH') { |
|
my $res = $resource; |
|
$resource = { 'src' => $res->src, |
|
'symb' => $res->symb, |
|
'parts' => $res->parts }; |
|
foreach my $part (@{$resource->{'parts'}}) { |
|
$resource->{'partdata'}->{$part}->{'ResponseIds'}= |
|
[$res->responseIds($part)]; |
|
} |
|
} |
|
# |
|
my $analysis = |
|
&analyze_problem_as_student($resource,$sname,$sdom); |
my $answer; |
my $answer; |
foreach my $partid (@{$resource->{'parts'}}) { |
foreach my $partid (@{$resource->{'parts'}}) { |
my $partdata = $resource->{'partdata'}->{$partid}; |
my $partdata = $resource->{'partdata'}->{$partid}; |
foreach my $respid (@{$partdata->{'ResponseIds'}}) { |
foreach my $respid (@{$partdata->{'ResponseIds'}}) { |
my $prefix = $partid.'.'.$respid; |
my $prefix = $partid.'.'.$respid; |
my $key = $prefix.'.answer'; |
my $key = $prefix.'.answer'; |
$answer->{$partid}->{$respid} = &get_answer($prefix,$key,%Answer); |
$answer->{$partid}->{$respid} = |
|
&get_answer($prefix,$key,%$analysis); |
} |
} |
} |
} |
|
my $returnvalue; |
if (! defined($partid)) { |
if (! defined($partid)) { |
$returnvalue = $answer; |
$returnvalue = $answer; |
} elsif (! defined($respid)) { |
} elsif (! defined($respid)) { |
Line 1093 sub get_problem_data {
|
Line 1132 sub get_problem_data {
|
$Partdata{$part}->{'_Foils'}->{$foil}->{'_Concept'}= |
$Partdata{$part}->{'_Foils'}->{$foil}->{'_Concept'}= |
$concept; |
$concept; |
} |
} |
} elsif ($key =~ /^(incorrect|answer|ans_low|ans_high|str_type)$/) { |
} elsif ($key =~ /^(unit|incorrect|answer|ans_low|ans_high|str_type)$/) { |
$Partdata{$part}->{$key}=$value; |
$Partdata{$part}->{$key}=$value; |
} |
} |
} else { |
} else { |