version 1.8, 2004/03/16 16:30:31
|
version 1.10, 2004/03/31 05:24:00
|
Line 345 sub get_prev_curr_next {
|
Line 345 sub get_prev_curr_next {
|
|
|
=pod |
=pod |
|
|
|
=item GetStudentAnswers($r,$problem,$Students) |
|
|
|
Determines the correct answer for a set of students on a given problem. |
|
The students answers are stored in the student hashes pointed to by the |
|
array @$Students under the key 'answer'. |
|
|
|
Inputs: $r |
|
$problem: hash reference containing the keys 'resource', 'part', and 'respid'. |
|
$Students: reference to array containing student hashes (need 'username', |
|
'domain'). |
|
|
|
Returns: nothing |
|
|
|
=cut |
|
|
|
##################################################### |
|
##################################################### |
|
sub GetStudentAnswers { |
|
my ($r,$problem,$Students) = @_; |
|
my $c = $r->connection(); |
|
my %Answers; |
|
my ($resource,$partid,$respid) = ($problem->{'resource'}, |
|
$problem->{'part'}, |
|
$problem->{'respid'}); |
|
# Read in the cache (if it exists) before we start timing things. |
|
&Apache::lonstathelpers::ensure_proper_cache($resource->{'symb'}); |
|
# Open progress window |
|
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin |
|
($r,'Student Answer Compilation Status', |
|
'Student Answer Compilation Progress', scalar(@$Students)); |
|
$r->rflush(); |
|
foreach my $student (@$Students) { |
|
last if ($c->aborted()); |
|
my $sname = $student->{'username'}; |
|
my $sdom = $student->{'domain'}; |
|
my $answer = &Apache::lonstathelpers::analyze_problem_as_student |
|
($resource,$sname,$sdom,$partid,$respid); |
|
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
|
&mt('last student')); |
|
$student->{'answer'} = $answer; |
|
} |
|
&Apache::lonstathelpers::write_answer_cache(); |
|
return if ($c->aborted()); |
|
$r->rflush(); |
|
# close progress window |
|
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
|
return; |
|
} |
|
|
|
##################################################### |
|
##################################################### |
|
|
|
=pod |
|
|
=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 and returns the correct answer |
Line 424 sub get_answer {
|
Line 478 sub get_answer {
|
} |
} |
foreach my $foil (@{$Answer{$prefix.'.shown'}}) { |
foreach my $foil (@{$Answer{$prefix.'.shown'}}) { |
if (ref($values{$foil}) eq 'ARRAY') { |
if (ref($values{$foil}) eq 'ARRAY') { |
$returnvalue.=&HTML::Entities::encode($foil).'='. |
$returnvalue.=&HTML::Entities::encode($foil,'<>&"').'='. |
join(',',map {&HTML::Entities::encode($_)} @{$values{$foil}}).'&'; |
join(',',map {&HTML::Entities::encode($_,'<>&"')} @{$values{$foil}}).'&'; |
} else { |
} else { |
$returnvalue.=&HTML::Entities::encode($foil).'='. |
$returnvalue.=&HTML::Entities::encode($foil,'<>&"').'='. |
&HTML::Entities::encode($values{$foil}).'&'; |
&HTML::Entities::encode($values{$foil},'<>&"').'&'; |
} |
} |
} |
} |
$returnvalue =~ s/ /\%20/g; |
$returnvalue =~ s/ /\%20/g; |