'.
+ &mt('Computing correct answers greatly increasese the amount of time required to prepare a report.').
+ '
');
+ $r->print('
'.
+ &mt('please select problems and use the Prepare Report button to continue.').
+ '
');
$r->print(&Apache::lonstathelpers::MultipleProblemSelector
- (undef,'.','problemchoice','Statistics'));
+ (undef,'problemchoice','Statistics'));
}
}
@@ -164,9 +146,31 @@ sub BuildStudentSubmissionsPage {
#########################################################
sub new_excel_output {
- my ($r,$Problems,$Students,$ProblemData) = @_;
+ my ($r,$Problems,$Students) = @_;
my $c = $r->connection();
#
+ #
+ # Determine the number of columns in the spreadsheet
+ my $columncount = 3; # username, domain, id
+ my $response_multiplier = 1;
+ $response_multiplier ++ if ($ENV{'form.correctans'} eq 'true');
+ $response_multiplier += 4 if ($ENV{'form.prob_status'} eq 'true');
+ my $lastprob;
+ foreach my $prob (@$Problems) {
+ $columncount += ($response_multiplier * $prob->countResponses);
+ last if ($columncount > 255);
+ $lastprob = $prob;
+ }
+ if ($columncount > 255) {
+ $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)).'
');
+ $r->rflush();
+ return;
+ }
+ #
+ # Print out a message telling them what we are doing
if (scalar(@$Problems) > 1) {
$r->print('
'.
&mt('Preparing Excel spreadsheet of student responses to [_1] problems',
@@ -215,7 +219,8 @@ sub new_excel_output {
# Student headers
my @StudentColumns = ('username','domain','id');
foreach (@StudentColumns) {
- $worksheet->write($header_row,$cols_output++,$_,$format->{'bold'});
+ $worksheet->write($header_row,$cols_output++,ucfirst($_),
+ $format->{'bold'});
}
# Problem headers
foreach my $prob (@$Problems) {
@@ -231,6 +236,17 @@ sub new_excel_output {
$resptypes->[$i].', '.$responses->[$i]);
$worksheet->write($header_row,$cols_output,'Submission');
$cols_output++;
+ if ($ENV{'form.correctans'} eq 'true') {
+ $worksheet->write($header_row,$cols_output,'Correct');
+ $cols_output++;
+ }
+ if ($ENV{'form.prob_status'} eq 'true') {
+ $worksheet->write($header_row,$cols_output++,
+ 'Award Detail');
+ $worksheet->write($header_row,$cols_output++,'Attempt');
+ $worksheet->write($header_row,$cols_output++,'Time');
+ $worksheet->write($header_row,$cols_output++,'Awarded');
+ }
}
}
}
@@ -240,31 +256,52 @@ sub new_excel_output {
($r,'Excel File Compilation Status',
'Excel File Compilation Progress',
scalar(@$Students),'inline',undef,'Statistics','stats_status');
+ my $max_row = $rows_output;
foreach my $student (@$Students) {
last if ($c->aborted());
$cols_output = 0;
+ my $student_row = $max_row;
foreach my $field (@StudentColumns) {
- $worksheet->write($rows_output,$cols_output++,
+ $worksheet->write($student_row,$cols_output++,
$student->{$field});
}
+ my $last_student_col = $cols_output-1;
+ my $response_count;
foreach my $prob (@$Problems) {
foreach my $partid (@{$prob->parts}) {
my @Response = $prob->responseIds($partid);
my @ResponseType = $prob->responseType($partid);
for (my $i=0;$i<=$#Response;$i++) {
+ my $response_start_col = $last_student_col +
+ $response_count * $response_multiplier + 1;
+ $response_count++;
my $respid = $Response[$i];
my $resptype = $ResponseType[$i];
my $results =
&Apache::loncoursedata::get_response_data_by_student
($student,$prob->symb(),$respid);
- my $final_response = $results->[-1];
- my $submission =
- $final_response->[
- &Apache::loncoursedata::RDs_submission()
- ];
- $submission=&excel_format_response($submission,$resptype);
- $worksheet->write($rows_output,$cols_output++,
- $submission);
+ if (! defined($results)) {
+ $results = [];
+ }
+ #
+ $rows_output = $student_row;
+ #
+ for (my $j=scalar(@$results)-1;$j>=0;$j--) {
+ $cols_output = $response_start_col;
+ my $response = $results->[$j];
+ if ($ENV{'form.all_sub'} ne 'true') {
+ next if ($j ne scalar(@$results)-1);
+ }
+ my $cols_output = &write_excel_row
+ ($worksheet,
+ $rows_output++,$cols_output,
+ $response,$student,
+ $prob,$partid,$respid,
+ $format,$resptype);
+ if ($rows_output > $max_row) {
+ $max_row = $rows_output;
+ }
+ }
}
}
}
@@ -289,6 +326,37 @@ sub new_excel_output {
return;
}
+sub write_excel_row {
+ my ($worksheet,$row,$col,$response,$student,$prob,$partid,$respid,
+ $format,$resptype) = @_;
+ #
+ my $submission =$response->[&Apache::loncoursedata::RDs_submission()];
+ $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
+ ($prob,$student->{'username'},$student->{'domain'},
+ $partid,$respid);
+ $correct =&excel_format_response($correct,$resptype);
+ $worksheet->write($row,$col++,$correct);
+ }
+ if ($ENV{'form.prob_status'} eq 'true') {
+ $worksheet->write
+ ($row,$col++,
+ $response->[&Apache::loncoursedata::RDs_awarddetail()]);
+ $worksheet->write
+ ($row,$col++,$response->[&Apache::loncoursedata::RDs_tries()]);
+ $worksheet->write
+ ($row,$col++,
+ &Apache::lonstathelpers::calc_serial
+ ($response->[&Apache::loncoursedata::RDs_timestamp()]),
+ $format->{'date'});
+ $worksheet->write
+ ($row,$col++,$response->[&Apache::loncoursedata::RDs_awarded()]);
+ }
+ return $col;
+}
+
sub get_title {
my ($title,$src) = @_;
if ($title eq '') {
@@ -303,7 +371,7 @@ sub excel_format_response {
my ($answer,$responsetype) = @_;
if ($responsetype eq 'radiobutton') {
$answer =~ s/=([^=])$//;
- } elsif ($responsetype eq 'option') {
+ } elsif ($responsetype =~ /^(option|match)$/) {
$answer = join("\n",
map {
&Apache::lonnet::unescape($_) ;
@@ -316,25 +384,40 @@ sub excel_format_response {
return $answer;
}
-
-=pod
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+##
+## Currently not used
+sub get_problem_data {
+ my ($r,$Problems) = @_;
+ #
+ # Analyze
+ my %Data;
+ if (scalar(@$Problems) > 5) {
+ # progress window
+ my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
+ ($r,'Problem Analysis Status',
+ 'Problem Analysis Progress',
+ scalar(@$Problems),
+ 'inline',undef,'Statistics','stats_status');
+ foreach my $problem (@$Problems) {
+ $Data{$problem->symb} =
+ {&Apache::lonstathelpers::get_problem_data
+ ($problem->src)};
+ &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
+ 'last problem');
+ }
+ &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
+ } else {
+ foreach my $problem (@$Problems) {
+ $Data{$problem->symb} =
+ {&Apache::lonstathelpers::get_problem_data
+ ($problem->src)};
+ }
+ }
+ return \%Data;
+}
+=pod
#########################################################
#########################################################
@@ -841,14 +924,6 @@ sub prepare_excel_output {
$r->rflush();
-
-
-
-
-
-
-
-
my @ColumnLabels;
my @Columns = @DefaultColumns;
my %seen;
@@ -1020,15 +1095,15 @@ sub prepare_excel_output {
sub CreateInterface {
##
## Output Selection
- my $OutputSelector = $/.''.$/;
##
## Environment variable initialization
my $Str = '';
@@ -1064,31 +1139,33 @@ sub CreateInterface {
}
$ans_checkbox .= 'value="true" />';
#
- # Only show last submission checkbox
- my $last_sub_checkbox = '';
+ #
+ # problem status checkbox
+ my $prob_status_checkbox = '';
- #
- # Concise view checkbox
- my $concise_view_checkbox = ''.&mt('Output Format: [_1]',$OutputSelector).' '.$/.
' '.
+ &mt('Show problem [_1]',$prob_checkbox).' '.
+ ' '.
+ ' '.
' '.
-# ' '.
-# ' '.
+ &mt('Show problem grading [_1]',$prob_status_checkbox).
+ ' '.
'';
#
$Str .= ''."\n";