--- loncom/interface/statistics/lonstudentsubmissions.pm 2004/09/23 13:50:45 1.22
+++ loncom/interface/statistics/lonstudentsubmissions.pm 2004/11/08 15:21:38 1.27
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonstudentsubmissions.pm,v 1.22 2004/09/23 13:50:45 matthew Exp $
+# $Id: lonstudentsubmissions.pm,v 1.27 2004/11/08 15:21:38 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 {
@@ -219,7 +219,7 @@ sub prepare_html_output {
if (! $single_part) {
my $tmpname = $partid;
if ($partid =~/^\d+$/) {
- $tmpname = &mt('Part [_1]',$partid);
+ $tmpname = $prob->part_display($partid);
}
$headers{'part'} .= qq{
$tmpname | };
$nonempty_part_headers = 1;
@@ -228,7 +228,7 @@ sub prepare_html_output {
}
$prob_span += $part_span;
}
- my $title = &get_title($prob->title,$prob->src);
+ my $title = $prob->compTitle;
if ($prob_span > 0) {
$headers{'problem'}.= qq{$title | };
} elsif ($single_response) {
@@ -383,16 +383,16 @@ 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');
}
my $Str;
if (! $single_response) {
- my $id = &get_title($prob->title,$prob->src);
+ my $id = $prob->compTitle;
if (defined($partid) && $partid ne '0') {
- $id .= ' '.$partid;
+ $id .= ' '.$prob->part_display($partid);
}
if (defined($respid)) {
$id .= ' '.$respid;
@@ -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;
}
@@ -506,7 +513,7 @@ sub prepare_excel_output {
$r->print(''.&mt('Unable to complete request').'
'.$/.
''.&mt('LON-CAPA is unable to produce your Excel spreadsheet because your selections will result in more than 255 columns. Excel allows only 255 columns in a spreadsheet.').'
'.$/.
''.&mt('Consider selecting fewer problems to generate reports on, or reducing the number of items per problem. Or use HTML or CSV output.').'
'.$/.
- ''.&mt('The last problem that will fit in the current spreadsheet is [_1].',&get_title($lastprob->title,$lastprob->src)).'
');
+ ''.&mt('The last problem that will fit in the current spreadsheet is [_1].',$lastprob->compTitle).'
');
$r->rflush();
return;
}
@@ -565,11 +572,12 @@ sub prepare_excel_output {
}
# Problem headers
foreach my $prob (@$Problems) {
- my $title = &get_title($prob->title,$prob->src);
+ my $title = $prob->compTitle;
$worksheet->write($title_row,$cols_output,
$title,$format->{'h3'});
foreach my $partid (@{$prob->parts}) {
- $worksheet->write($partid_row,$cols_output,$partid);
+ $worksheet->write($partid_row,$cols_output,
+ $prob->part_display($partid));
my $responses = [$prob->responseIds($partid)];
my $resptypes = [$prob->responseType($partid)];
for (my $i=0;$iwrite($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);
@@ -698,16 +706,6 @@ sub write_excel_row {
return $col;
}
-sub get_title {
- my ($title,$src) = @_;
- if ($title eq '') {
- ($title) = ($src =~ m|/([^/]+)$|);
- } else {
- $title =~ s/\:/:/g;
- }
- return $title;
-}
-
sub excel_format_response {
my ($answer,$responsetype) = @_;
if ($responsetype eq 'radiobutton') {
@@ -718,6 +716,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;
@@ -788,11 +790,10 @@ sub prepare_csv_output {
# we put the headers into the %headers hash
my $prob_start_idx = 0;
foreach my $prob (@$problems) {
- $headers{'problem'}->[$prob_start_idx] =
- &get_title($prob->title,$prob->src);
+ $headers{'problem'}->[$prob_start_idx] = $prob->compTitle;
my $part_start_idx = $prob_start_idx;
foreach my $partid (@{$prob->parts}) {
- $headers{'part'}->[$part_start_idx] = &mt('Part [_1]',$partid);
+ $headers{'part'}->[$part_start_idx] = $prob->part_display($partid);
my $responses = [$prob->responseIds($partid)];
for (my $i=0;$iaborted());
my @rows;
my $prob_start_idx = 0;
foreach my $prob (@$problems) {
@@ -884,7 +886,7 @@ sub compile_response_data {
my @rowdata;
push(@rowdata,$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);