--- loncom/interface/statistics/lonstudentsubmissions.pm 2004/09/23 14:55:24 1.24
+++ loncom/interface/statistics/lonstudentsubmissions.pm 2004/12/06 16:53:39 1.29
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonstudentsubmissions.pm,v 1.24 2004/09/23 14:55:24 matthew Exp $
+# $Id: lonstudentsubmissions.pm,v 1.29 2004/12/06 16:53:39 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -109,7 +109,7 @@ sub BuildStudentSubmissionsPage {
my $resource = $navmap->getBySymb($symb);
push(@Problems,$resource);
}
- #
+ #
if (! scalar(@Problems) || ! defined($Problems[0])) {
$r->print('resource is undefined');
} else {
@@ -383,7 +383,7 @@ sub html_essay_results {
#
my $correct = '';
if ($ENV{'form.correctans'} eq 'true') {
- $correct = &Apache::lonstathelpers::analyze_problem_as_student
+ $correct = &Apache::lonstathelpers::get_student_answer
($prob,$student->{'username'},$student->{'domain'},
$partid,$respid);
$correct = &html_format_sub($correct,'essay');
@@ -427,7 +427,7 @@ sub html_results {
$submission = &html_format_sub($submission,$resptype);
my $correct = '';
if ($ENV{'form.correctans'} eq 'true') {
- $correct = &Apache::lonstathelpers::analyze_problem_as_student
+ $correct = &Apache::lonstathelpers::get_student_answer
($prob,$student->{'username'},$student->{'domain'},
$partid,$respid);
$correct = &html_format_sub($correct,$resptype);
@@ -458,6 +458,9 @@ sub html_results {
sub html_format_sub {
my ($submission,$resptype) = @_;
return '' if (! defined($submission) || $submission eq '');
+ $submission = &HTML::Entities::decode($submission);
+ $submission =~ s/\\\"/\"/g;
+ $submission =~ s/\\\'/\'/g;
if ($resptype eq 'essay') {
$submission =~ s|\\r\\n|$/|g;
$submission = &HTML::Entities::encode($submission,'<>&"');
@@ -465,16 +468,20 @@ sub html_format_sub {
$submission =~ s|\\||g;
$submission = '
'.$submission.'
';
} elsif ($resptype eq 'radiobutton') {
+ $submission = &HTML::Entities::encode($submission,'<>&"');
$submission =~ s/=([^=])$//;
} elsif ($resptype =~ /^(option|match|rank)$/) {
$submission =
''.
'- '.join('
- ',
- map {
- &Apache::lonnet::unescape($_) ;
- } sort split('&',$submission)
+ map { &HTML::Entities::encode($_,'<>&"');
+ } map {
+ &Apache::lonnet::unescape($_) ;
+ } sort split('&',$submission)
).
'
';
+ } else {
+ $submission = &HTML::Entities::encode($submission,'<>&"');
}
return $submission;
}
@@ -647,6 +654,14 @@ sub prepare_excel_output {
}
}
}
+ # Fill in the remaining rows with the students data
+ for (my $row = $student_row+1;$row<=$max_row;$row++) {
+ my $cols = 0;
+ foreach my $field (@StudentColumns) {
+ $worksheet->write($row,$cols++,
+ $student->{$field});
+ }
+ }
$rows_output++;
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
'last student');
@@ -676,7 +691,7 @@ sub write_excel_row {
$submission = &excel_format_response($submission,$resptype);
$worksheet->write($row,$col++,$submission);
if ($ENV{'form.correctans'} eq 'true') {
- my $correct = &Apache::lonstathelpers::analyze_problem_as_student
+ my $correct = &Apache::lonstathelpers::get_student_answer
($prob,$student->{'username'},$student->{'domain'},
$partid,$respid);
$correct =&excel_format_response($correct,$resptype);
@@ -709,6 +724,10 @@ sub excel_format_response {
&Apache::lonnet::unescape($_) ;
} sort split('&',$answer)
);
+ } elsif ($responsetype eq 'string') {
+ $answer =~ s/\\(n|r)/\n/g;
+ $answer =~ s/(\s*$|^\s*)//g;
+ $answer =~ s/\\\'/\'/g;
}
if ($answer =~ m/^=/) {
$answer = ' '.$answer;
@@ -806,6 +825,7 @@ sub prepare_csv_output {
#
# Main loop
foreach my $student (@$students) {
+ last if ($c->aborted());
my @rows;
my $prob_start_idx = 0;
foreach my $prob (@$problems) {
@@ -872,9 +892,9 @@ sub prepare_csv_output {
sub compile_response_data {
my ($response,$student,$prob,$partid,$respid) = @_;
my @rowdata;
- push(@rowdata,$response->[&Apache::loncoursedata::RDs_submission()]);
+ push(@rowdata,&Apache::lonnet::unescape($response->[&Apache::loncoursedata::RDs_submission()]));
if ($ENV{'form.correctans'} eq 'true') {
- my $correct = &Apache::lonstathelpers::analyze_problem_as_student
+ my $correct = &Apache::lonstathelpers::get_student_answer
($prob,$student->{'username'},$student->{'domain'},
$partid,$respid);
push(@rowdata,$correct);