--- loncom/interface/statistics/lonstudentsubmissions.pm 2004/06/04 21:42:18 1.11 +++ 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.11 2004/06/04 21:42:18 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('
$/|g; + $data->{'submission'} =~ s|\\||g; + $data->{'submission'} = '
'.$data->{'submission'}.'
'; + # + my $Str = ''.&mt("Unable to create new Excel file. ". + "This error has been logged. ". + "Please alert your LON-CAPA administrator"). + '
'); + return undef; + } + # + $workbook->set_tempdir('/home/httpd/perl/tmp'); + # + my $format = &Apache::loncommon::define_excel_formats($workbook); + my $worksheet = $workbook->addworksheet('Student Submission Data'); + # + # Make sure we get new weight data instead of data on a 10 minute delay + &Apache::lonnet::clear_EXT_cache_status(); + # + # Put on the standard headers and whatnot + my $rows_output=0; + $worksheet->write($rows_output++,0,$resource->{'title'},$format->{'h1'}); + $worksheet->write($rows_output++,0,$resource->{'src'},$format->{'h3'}); + $rows_output++; + $worksheet->write_row($rows_output++,0,\@Columns,$format->{'bold'}); + # + # Populate the worksheet with the student data + foreach my $student (@$Students) { + last if ($c->aborted()); + my $results = &Apache::loncoursedata::get_response_data_by_student + ($student,$resource->{'symb'},$respid); + my %row; + $row{'username'} = $student->{'username'}; + $row{'domain'} = $student->{'domain'}; + $row{'correct'} = $student->{'answer'}; + $row{'weight'} = &Apache::lonnet::EXT + ('resource.'.$partid.'.weight',$resource->{'symb'}, + undef,undef,undef); + if (! defined($results) || ref($results) ne 'ARRAY') { + $row{'score'} = '='. + &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell + ($rows_output,$awarded_col) + .'*'. + &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell + ($rows_output,$weight_col); + my $cols_output = 0; + foreach my $col (@Columns) { + if (! exists($row{$col})) { + $cols_output++; + next; + } + $worksheet->write($rows_output,$cols_output++,$row{$col}); + } + $rows_output++; + } else { + for (my $i=0;$i'. + &mt('Your Excel spreadsheet.'). + '
'."\n"); + $r->print(''); + $r->rflush(); + return; + +} + +=cut + +######################################################### +######################################################### +## ## Excel output of student answers and correct answers ## ######################################################### @@ -157,21 +587,35 @@ sub prepare_excel_output { $problem->{'part'}); $r->print(''. + &mt('See the status bar above for student answer computation progress'). + '
'); + # + if ($ENV{'form.correctans'} eq 'true') { + &Apache::lonstathelpers::GetStudentAnswers($r,$problem,$Students, + 'Statistics', + 'stats_status'); + } # $r->print(''); $r->rflush(); - my @Columns = ( 'username','domain','attempt','time', - 'submission','correct', 'grading','awarded','weight', - 'score'); - my $awarded_col = 7; - my $weight_col = 8; + my @Columns; + push(@Columns,'username'); + push(@Columns,'domain'); + push(@Columns,'attempt'); + push(@Columns,'time'); + push(@Columns,'submission'); + if ($ENV{'form.correctans'} eq 'true') { push(@Columns,'correct'); } + push(@Columns,'grading'); + push(@Columns,'awarded'); + my $awarded_col = $#Columns; + push(@Columns,'weight'); + my $weight_col = $#Columns; + push(@Columns,'score'); # # Create excel worksheet my $filename = '/prtspool/'. @@ -210,7 +654,7 @@ sub prepare_excel_output { my %row; $row{'username'} = $student->{'username'}; $row{'domain'} = $student->{'domain'}; - $row{'correct'} = $student->{'answer'}; + $row{'correct'} = $student->{'answer'}; $row{'weight'} = &Apache::lonnet::EXT ('resource.'.$partid.'.weight',$resource->{'symb'}, undef,undef,undef); @@ -231,7 +675,12 @@ sub prepare_excel_output { } $rows_output++; } else { - foreach my $response (@$results) { + for (my $i=0;$i