--- loncom/interface/statistics/lonsurveyreports.pm 2005/03/01 22:04:55 1.3 +++ loncom/interface/statistics/lonsurveyreports.pm 2006/05/30 12:46:50 1.13 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonsurveyreports.pm,v 1.3 2005/03/01 22:04:55 matthew Exp $ +# $Id: lonsurveyreports.pm,v 1.13 2006/05/30 12:46:50 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,23 +27,29 @@ package Apache::lonsurveyreports; use strict; -use Apache::lonnet(); +use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::loncoursedata(); use Apache::lonstatistics; use Apache::lonlocal; use Apache::lonstathelpers; +use Spreadsheet::WriteExcel; use HTML::Entities(); use Time::Local(); +use lib '/home/httpd/lib/perl/'; +use LONCAPA; + -my @SubmitButtons = ({ name => 'PrevProblem', +my @SubmitButtons = ( + { name => 'break'}, + { name => 'PrevProblem', text => 'Previous Survey' }, { name => 'NextProblem', text => 'Next Survey' }, - { name => 'break'}, { name => 'SelectAnother', - text => 'Choose a different Survey Problem' }, + text => 'Choose a different Survey' }, + { name => 'break'}, { name => 'Generate', text => 'Generate Report'}, ); @@ -74,8 +80,9 @@ sub BuildSurveyReportsPage { &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status'); $r->rflush(); # - if (exists($ENV{'form.problemchoice'}) && - ! exists($ENV{'form.SelectAnother'})) { + if (exists($env{'form.problemchoice'}) && + ! exists($env{'form.SelectAnother'})) { + $r->print(' 'x3); foreach my $button (@SubmitButtons) { if ($button->{'name'} eq 'break') { $r->print("
\n"); @@ -90,30 +97,34 @@ sub BuildSurveyReportsPage { } # $r->print('
'); + $r->print('

'. + &Apache::lonlocal::locallocaltime(time).','. + &Apache::lonstatistics::section_and_enrollment_description(). + '

'); $r->rflush(); # # Determine which problem we are to analyze my $current_problem = &Apache::lonstathelpers::get_target_from_id - ($ENV{'form.problemchoice'}); + ($env{'form.problemchoice'}); # my ($navmap,$prev,$curr,$next) = &Apache::lonstathelpers::get_prev_curr_next($current_problem, '.', 'part_survey', ); - if (exists($ENV{'form.PrevProblem'}) && defined($prev)) { + if (exists($env{'form.PrevProblem'}) && defined($prev)) { $current_problem = $prev; - } elsif (exists($ENV{'form.NextProblem'}) && defined($next)) { + } elsif (exists($env{'form.NextProblem'}) && defined($next)) { $current_problem = $next; } else { $current_problem = $curr; } # # Store the current problem choice and send it out in the form - $ENV{'form.problemchoice'} = + $env{'form.problemchoice'} = &Apache::lonstathelpers::make_target_id($current_problem); $r->print(''); + $env{'form.problemchoice'}.'" />'); # if (! defined($current_problem->{'resource'})) { $r->print('resource is undefined'); @@ -121,11 +132,21 @@ sub BuildSurveyReportsPage { my $resource = $current_problem->{'resource'}; $r->print('

'.$resource->compTitle.'

'); $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); - &make_HTML_report($r,$current_problem,\%Data,\@Students); + &compile_student_answers($r,$current_problem,\%Data,\@Students); + if ($env{'form.output'} eq 'HTML' || + ! defined($env{'form.output'})) { + &make_HTML_report($r,$current_problem,\%Data,\@Students); + } elsif ($env{'form.output'} eq 'Excel') { + &make_Excel_report($r,$current_problem,\%Data,\@Students); + } elsif ($env{'form.output'} eq 'TXT') { + &make_text_report($r,$current_problem,\%Data,\@Students); + } } $r->print('
'); } else { @@ -179,16 +200,16 @@ sub SurveyProblemSelector { respid=>undef, resptype=>undef}); my $checked = ''; - if ($ENV{'form.problemchoice'} eq $value) { + if ($env{'form.problemchoice'} eq $value) { $checked = 'checked '; } my $link = $problem->{'res'}->src. - '?symb='.&Apache::lonnet::escape($problem->{'res'}->symb); + '?symb='.&escape($problem->{'res'}->symb); $Str .= ''. ''.''. ''. - '