--- loncom/interface/statistics/lonstudentsubmissions.pm 2004/09/16 21:54:22 1.19 +++ loncom/interface/statistics/lonstudentsubmissions.pm 2004/09/20 19:24:02 1.20 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstudentsubmissions.pm,v 1.19 2004/09/16 21:54:22 matthew Exp $ +# $Id: lonstudentsubmissions.pm,v 1.20 2004/09/20 19:24:02 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -152,16 +152,20 @@ sub new_excel_output { # # Determine the number of columns in the spreadsheet my $columncount = 3; # username, domain, id - my $multiplier = 1; - $multiplier ++ if ($ENV{'form.correctans'} eq 'true'); + 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 += ($multiplier * $prob->countResponses); + $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('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; } @@ -236,6 +240,13 @@ sub new_excel_output { $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'); + } } } } @@ -245,39 +256,51 @@ 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 ($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($rows_output,$cols_output++, - $correct); + 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; + } } } } @@ -303,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 '') { @@ -870,14 +924,6 @@ sub prepare_excel_output { $r->rflush(); - - - - - - - - my @ColumnLabels; my @Columns = @DefaultColumns; my %seen; @@ -1101,23 +1147,25 @@ sub CreateInterface { } $all_sub_checkbox.= 'value="true" />'; # - # Concise view checkbox - my $concise_view_checkbox = ''.&mt('Output Format: [_1]',$output_selector).'
'.$/. '
'. + &mt('Show problem [_1]',$prob_checkbox).'
'. + '
'. + '
'. '
'. -# '
'. -# '
'. + &mt('Show problem grading [_1]',$prob_status_checkbox). + '
'. ''; # $Str .= ''."\n";