--- loncom/interface/statistics/lonstudentsubmissions.pm 2004/08/31 15:52:13 1.14
+++ loncom/interface/statistics/lonstudentsubmissions.pm 2004/09/01 21:13:04 1.15
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: lonstudentsubmissions.pm,v 1.14 2004/08/31 15:52:13 matthew Exp $
+# $Id: lonstudentsubmissions.pm,v 1.15 2004/09/01 21:13:04 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -122,15 +122,19 @@ sub BuildStudentSubmissionsPage {
my $resource = $current_problem->{'resource'};
$r->print('
'.$resource->{'title'}.'
');
$r->print(''.$resource->{'src'}.'
');
- $r->print(&Apache::lonstathelpers::render_resource($resource));
+ if ($ENV{'form.renderprob'} eq 'true') {
+ $r->print(&Apache::lonstathelpers::render_resource($resource));
+ }
$r->rflush();
my %Data = &Apache::lonstathelpers::get_problem_data
($resource->{'src'});
my $ProblemData = $Data{$current_problem->{'part'}.
'.'.
$current_problem->{'respid'}};
- &prepare_excel_output($r,$current_problem,
+ &prepare_html_output($r,$current_problem,
$ProblemData,\@Students);
+# &prepare_excel_output($r,$current_problem,
+# $ProblemData,\@Students);
}
$r->print('
');
} else {
@@ -145,6 +149,432 @@ sub BuildStudentSubmissionsPage {
#########################################################
#########################################################
##
+## prepare_html_output
+##
+#########################################################
+#########################################################
+sub prepare_html_output {
+ my ($r,$problem,$ProblemData,$Students) = @_;
+ my $c = $r->connection();
+ my ($resource,$respid,$partid) = ($problem->{'resource'},
+ $problem->{'respid'},
+ $problem->{'part'});
+ $r->print(''.&mt('Student Responses').'
');
+ #
+ if ($ENV{'form.correctans'} eq 'true') {
+ &Apache::lonstathelpers::GetStudentAnswers($r,$problem,$Students,
+ 'Statistics',
+ 'stats_status');
+ }
+ #
+ $r->rflush();
+ my $response_type;
+ for (my $i=0;
+ $i{'partdata'}->{$partid}->{'ResponseIds'}});
+ $i++) {
+ if($resource->{'partdata'}->{$partid}->{'ResponseIds'}->[$i] eq $respid){
+ $response_type =
+ $resource->{'partdata'}->{$partid}->{'ResponseTypes'}->[$i];
+ last;
+ }
+ }
+ if (! defined($response_type)) {
+ $r->print(''.&mt('Unable to determine response type').'
');
+ } else {
+ my $count = 0;
+ my $header;
+ if ($response_type eq 'essay') {
+ $header = &html_essay_header();
+ } elsif ($response_type eq 'radiobutton') {
+ $header = &html_radiobutton_header();
+ } elsif ($response_type eq 'option') {
+ $header = &html_option_header();
+ } else {
+ $header = &html_generic_header();
+ }
+ $header = ''.$header.'
';
+ #
+ $r->print($/.''.$/.$header.$/);
+ foreach my $student (@$Students) {
+ if ($count >= 50) {
+ $r->print('
'.$/.''.$/.$header.$/);
+ $count = 0;
+ }
+ last if ($c->aborted());
+ my $results = &Apache::loncoursedata::get_response_data_by_student
+ ($student,$resource->{'symb'},$respid);
+ next if (! defined($results) || ref($results) ne 'ARRAY');
+ for (my $i=0;$i[$i];
+ if ($ENV{'form.last_sub_only'} eq 'true' &&
+ $i < (scalar(@$results)-1)) {
+ next;
+ }
+ my $data;
+ $data->{'sname'} = $student->{'username'}.'@'.
+ $student->{'domain'};
+ $data->{'time'} = &Apache::lonlocal::locallocaltime
+ ($response->[&Apache::loncoursedata::RDs_timestamp()]);
+ $data->{'attempt'} =
+ $response->[&Apache::loncoursedata::RDs_tries()];
+ $data->{'submission'} =
+ $response->[&Apache::loncoursedata::RDs_submission()];
+ $data->{'correct'} = $student->{'answer'};
+ my $row;
+ if ($response_type eq 'essay') {
+ $row = &html_essay($data);
+ } elsif ($response_type eq 'radiobutton') {
+ $row = &html_radiobutton($data);
+ } elsif ($response_type eq 'option') {
+ $row = &html_option($data);
+ } else {
+ $row = &html_generic($data);
+ }
+ $r->print($row.$/);
+ $count++;
+ }
+ }
+ $r->print('
'.$/);
+ }
+ return;
+}
+
+#####################################################
+##
+## HTML helper routines
+##
+#####################################################
+my @FullHeaders = (
+ {name=>'sname',
+ display=>'Student'},
+ {name => 'id',
+ display => 'Id'},
+ {name => 'time',
+ display =>'Time'},
+ {name => 'attempt',
+ display =>'Attempt'},
+ {name => 'grading',
+ display =>'Grading'},
+ );
+
+sub html_essay_header {
+ my $header;
+ if ($ENV{'form.subdata'} eq 'true') {
+ foreach (@FullHeaders) {
+ $header .= ''.&mt($_->{'display'}).' | ';
+ }
+ } else {
+ $header = ''.&mt('Username and Submission').' | ';
+ }
+ return $header;
+}
+
+sub html_essay {
+ my ($data)=@_;
+ #
+ $data->{'submission'} =~ s|\\r\\n|$/|g;
+ $data->{'submission'} =
+ &HTML::Entities::encode($data->{'submission'},'<>&"');
+ $data->{'submission'} =~ s|$/\s*$/|$/$/|g;
+ $data->{'submission'} =~ s|\\||g;
+ $data->{'submission'} = '
'.$data->{'submission'}.'
';
+ #
+ my $Str = '';
+ if ($ENV{'form.subdata'} eq 'true') {
+ $Str .=
+ ''.$data->{'sname'}.' | '.
+ ''.$data->{'time'}.' | '.
+ ''.$data->{'attempt'}.' | ';
+ $Str .= '
';
+ $Str .= ''.
+ $data->{'submission'}.' | ';
+ } else {
+ $Str .= ''.$data->{'sname'}.''.
+ $data->{'submission'}.' | ';
+ }
+ if ($ENV{'form.correctans'} eq 'true') {
+ $Str .= '
';
+ if (defined($data->{'correct'}) && $data->{'correct'} !~ /^\s*$/) {
+ $Str .= ''.
+ ''.&mt('Correct Answer:').''.$data->{'correct'}.' | ';
+ }
+ }
+ $Str .= '
';
+ #
+ return $Str;
+}
+
+sub html_radiobutton_header {
+ my $header;
+ if ($ENV{'form.subdata'} eq 'true') {
+ foreach (@FullHeaders) {
+ $header .= ''.&mt($_->{'display'}).' | ';
+ }
+ } else {
+ $header =
+ ''.&mt('Username').' | ';
+ }
+ $header .=''.&mt('Submission').' | ';
+ if ($ENV{'form.correctans'} eq 'true') {
+ $header .= ''.&mt('Correct').' | ';
+ }
+ return $header;
+}
+
+sub html_radiobutton {
+ my ($data)=@_;
+ #
+ $data->{'submission'} =~ s/=([^=])$//;
+ #
+ my $Str = '';
+ if ($ENV{'form.subdata'} eq 'true') {
+ $Str .=
+ ''.''.$data->{'sname'}.' | '.
+ ''.$data->{'time'}.' | '.
+ ''.$data->{'attempt'}.' | ';
+ $Str .= ''.$data->{'submission'}.' | ';
+ if ($ENV{'form.correctans'} eq 'true') {
+ $Str .= ''.$data->{'correct'}.' | ';
+ }
+ } else {
+ $Str .= ''.$data->{'sname'}.' | ';
+ $Str .= ''.$data->{'submission'}.' | ';
+ if ($ENV{'form.correctans'} eq 'true') {
+ $Str .= ''.$data->{'correct'}.' | ';
+ }
+ }
+ $Str .= '
';
+ #
+ return $Str;
+}
+
+sub html_generic_header {
+ my $header;
+ if ($ENV{'form.subdata'} eq 'true') {
+ foreach (@FullHeaders) {
+ $header .= ''.&mt($_->{'display'}).' | ';
+ }
+ } else {
+ $header =
+ ''.&mt('Username').' | ';
+ }
+ $header .= ''.&mt('Submission').' | ';
+ if ($ENV{'form.correctans'} eq 'true') {
+ $header .= ''.&mt('Correct').' | ';
+ }
+ return $header;
+}
+
+sub html_generic {
+ my ($data)=@_;
+ $data->{'submission'} = &Apache::lonnet::unescape($data->{'submission'});
+ my $Str = '';
+ if ($ENV{'form.subdata'} eq 'true') {
+ $Str .=
+ ''.$data->{'sname'}.' | '.
+ ''.$data->{'time'}.' | '.
+ ''.$data->{'attempt'}.' | ';
+ } else {
+ $Str .= ''.$data->{'sname'}.' | ';
+ }
+ $Str .= ''.$data->{'submission'}.' | ';
+ if ($ENV{'form.correctans'} eq 'true') {
+ $Str .= ''.$data->{'correct'}.' | ';
+ }
+ $Str .= '
';
+ return $Str;
+}
+
+sub html_option_header {
+ my $header;
+ if ($ENV{'form.subdata'} eq 'true') {
+ foreach (@FullHeaders) {
+ $header .= ''.&mt($_->{'display'}).' | ';
+ }
+ } else {
+ $header =
+ ''.&mt('Username').' | ';
+ }
+ $header .= ''.&mt('Submission').' | ';
+ if ($ENV{'form.correctans'} eq 'true') {
+ $header .= ''.&mt('Correct').' | ';
+ }
+ return $header;
+}
+
+sub html_option {
+ my ($data)=@_;
+ $data->{'submission'} = '