--- loncom/interface/statistics/lonstudentsubmissions.pm 2004/09/15 21:08:50 1.18 +++ loncom/interface/statistics/lonstudentsubmissions.pm 2004/09/16 21:54:22 1.19 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstudentsubmissions.pm,v 1.18 2004/09/15 21:08:50 matthew Exp $ +# $Id: lonstudentsubmissions.pm,v 1.19 2004/09/16 21:54:22 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -67,7 +67,8 @@ sub BuildStudentSubmissionsPage { } # my @CacheButtonHTML = - &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status'); + &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status', + '

'.&mt('Loading student data').'

'); $r->rflush(); # if (exists($ENV{'form.problemchoice'}) && @@ -123,40 +124,21 @@ sub BuildStudentSubmissionsPage { $r->rflush(); } } - 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)}; - } - } - &new_excel_output($r,\@Problems,\@Students,\%Data); + &new_excel_output($r,\@Problems,\@Students); } $r->print('
'); } else { $r->print(''); $r->print(' 'x5); - $r->print('

'.&mt('Please select a problem to analyze').'

'); + $r->print('

'. + &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,27 @@ 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 $multiplier = 1; + $multiplier ++ if ($ENV{'form.correctans'} eq 'true'); + foreach my $prob (@$Problems) { + $columncount += ($multiplier * $prob->countResponses); + last if ($columncount > 255); + } + 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.').'

'.$/); + $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 +215,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 +232,10 @@ 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++; + } } } } @@ -265,6 +270,15 @@ sub new_excel_output { $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); + } } } } @@ -303,7 +317,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 +330,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 ######################################################### ######################################################### @@ -1020,15 +1049,15 @@ sub prepare_excel_output { sub CreateInterface { ## ## Output Selection - my $OutputSelector = $/.''.$/; foreach ('HTML','Excel','CSV') { - $OutputSelector .= ' '.$/; } - $OutputSelector .= ''.$/; + $output_selector .= ''.$/; ## ## Environment variable initialization my $Str = ''; @@ -1064,13 +1093,13 @@ sub CreateInterface { } $ans_checkbox .= 'value="true" />'; # - # Only show last submission checkbox - my $last_sub_checkbox = ''.&mt('Output Format: [_1]',$OutputSelector).'
'.$/. +# ''.&mt('Output Format: [_1]',$output_selector).'
'.$/. '
'. '
'. # '
'. +# &mt('All submission [_1]',$all_sub_checkbox).'
'. # '
'. '';