--- loncom/interface/statistics/lonsurveyreports.pm 2005/03/17 19:02:45 1.6 +++ loncom/interface/statistics/lonsurveyreports.pm 2008/10/23 09:07:51 1.18 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonsurveyreports.pm,v 1.6 2005/03/17 19:02:45 matthew Exp $ +# $Id: lonsurveyreports.pm,v 1.18 2008/10/23 09:07:51 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,7 +27,7 @@ package Apache::lonsurveyreports; use strict; -use Apache::lonnet(); +use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::loncoursedata(); @@ -37,14 +37,19 @@ 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'}, ); @@ -68,15 +73,16 @@ sub BuildSurveyReportsPage { my @Students = @Apache::lonstatistics::Students; # if (@Students < 1) { - $r->print('
'.&mt('There are no students in the sections selected.').'
'); } # my @CacheButtonHTML = &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("'. + &mt('There are no survey problems in this course.'). + '
'.$/; return $Str; } $Str .= ''. ''.' | '. '
'. + &mt('Your text file'). + '
'."\n"); + $r->print(''); + } else { + $r->print('' + .&mt('There is no essay or string response data to output for this survey.') + .''); + } + $r->rflush(); + return; +} + + ######################################################### ######################################################### ## @@ -281,7 +362,7 @@ sub make_Excel_report { # my $rows_output=0; $worksheet->write($rows_output++,0, - $ENV{'course.'.$ENV{'request.course.id'}.'.description'}, + $env{'course.'.$env{'request.course.id'}.'.description'}, $format->{'h1'}); $rows_output++; # @@ -306,8 +387,8 @@ sub make_Excel_report { my $warned_about_size = 0; foreach my $data (@{$data->{'responses'}}) { if (length($data) > 255 && ! $warned_about_size) { - $r->print('
'. - &mt('[_1]:[_2] responses to [_3] may be too long to fit Excel spreadsheet.', + $r->print('
'. + &mt('[_1]:[_2] responses to [_3] may be too long to fit Excel spreadsheet.', $resource->compTitle, $resource->part_display($partid), $respid). @@ -325,7 +406,7 @@ sub make_Excel_report { $worksheet->write_row($rows_output++,0, \@rowdata,$format->{'h4'}); # - my @foils = sort(keys(%{$data->{'foil_responses'}})); + my @foils = sort(keys(%{$respdata->{'_Foils'}})); foreach my $foilid (@foils) { my $foil_count = $data->{'foil_count'}->{$foilid}; my $foiltext = $respdata->{'_Foils'}->{$foilid}->{'text'}; @@ -353,9 +434,10 @@ sub make_Excel_report { my @rowdata = ('Foil Name','Foil Text','Frequency'); $worksheet->write_row($rows_output++,0, \@rowdata,$format->{'h4'}); - foreach my $value (sort(keys(%{$data->{'foil_values'}}))) { + my @foils = sort(keys(%{$respdata->{'_Foils'}})); + foreach my $foilid (@foils) { undef(@rowdata); - my $foilid = $data->{'map'}->{$value}; + my $value = $data->{'map_fv'}->{$foilid}; push(@rowdata,$respdata->{'_Foils'}->{$foilid}->{'name'}); push(@rowdata,$respdata->{'_Foils'}->{$foilid}->{'text'}); push(@rowdata,$data->{'foil_values'}->{$value}); @@ -366,12 +448,12 @@ sub make_Excel_report { } #response ids } # partids $workbook->close(); - $r->print('
'.
+ $r->print(' '.
&mt('Your Excel spreadsheet.').
' ';
$Str .= ''.
' ';
if (exists($data->{'responses'}) &&
ref($data->{'responses'}) eq 'ARRAY') {
@@ -424,22 +507,25 @@ sub make_HTML_report {
}
} elsif (exists($data->{'foil_count'}) &&
exists($data->{'foil_responses'})) {
- $Str.=''.&mt('Total').' '.
''.$data->{'_count'}.' '.
- ''.&mt('Part [_1], Response [_2]',$partid,$respid).' '.
+ ''.&mt('Part [_1], Response [_2]',
+ $resource->part_display($partid),$respid).' '.
' ';
+ $Str.=$tmp.&Apache::loncommon::end_data_table()
+ .'';
} elsif (exists($data->{'_count'}) &&
exists($data->{'foil_values'}) &&
exists($data->{'map'})) {
@@ -464,28 +551,30 @@ sub make_HTML_report {
my $total = $data->{'_count'};
my $sum = 0;
my $tmp;
- foreach my $value (sort(keys(%{$data->{'foil_values'}}))) {
+ my @foils = sort(keys(%{$ProblemData->{$partid.'.'.$respid}
+ ->{'_Foils'}}));
+ foreach my $foilid (@foils) {
+ my $value = $data->{'map_fv'}->{$foilid};
my $count = $data->{'foil_values'}->{$value};
- my $foilid = $data->{'map'}->{$value};
my $foiltext = $ProblemData->{$partid.'.'.$respid}->{'_Foils'}->{$foilid}->{'text'};
my $foilname = $ProblemData->{$partid.'.'.$respid}->{'_Foils'}->{$foilid}->{'name'};
- $tmp .= ''.
- ' ';
+ $Str.=' '
+ .' ';
- my @foils = sort(keys(%{$data->{'foil_responses'}}));
+ &mt('Percent'))).''
+ .&Apache::loncommon::end_data_table_header_row();
+ my @foils = sort(keys(%{$ProblemData->{$partid.'.'.$respid}->{'_Foils'}}));
foreach my $foilid (@foils) {
my $prob_data = $ProblemData->{$partid.'.'.$respid};
my $foil_count = $data->{'foil_count'}->{$foilid};
my $foiltext = $prob_data->{'_Foils'}->{$foilid}->{'text'};
my $foilname = $prob_data->{'_Foils'}->{$foilid}->{'name'};
my $rowspan = scalar(@{$prob_data->{'_Options'}});
- my $preamble = ''
+ .&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table_header_row();
my $tmp = ' '.join(' ',
(&mt('Foil Name'),
&mt('Foil Text'),
&mt('Option'),
&mt('Frequency'),
- &mt('Percent'))).' '.
+ my $preamble = &Apache::loncommon::start_data_table_row().
' '.$/;
- $preamble = ''.
$foilname.' '.
''.
@@ -452,11 +538,12 @@ sub make_HTML_report {
' '.$count.' '.
''.
sprintf('%.2f',100*$count/$foil_count).'%'.
- ' ';
+ ''.&Apache::loncommon::end_data_table_row().$/;
+ $preamble = &Apache::loncommon::continue_data_table_row(); #&Apache::loncommon::start_data_table_row();
}
}
- $Str.=$tmp.' '.
+ $tmp .= &Apache::loncommon::start_data_table_row().
' '.$/;
+ &Apache::loncommon::end_data_table_row().$/;
}
- $Str .= ''.$foilname.' '.
''.$foiltext.' '.
''.$count.' '.
''.
sprintf("%.2f",$count/$total*100).'% '.
- ''.
+ $Str .= &Apache::loncommon::start_data_table_row().
' '.$/.
+ &Apache::loncommon::end_data_table_row().$/.
$tmp;
}
- $Str.= ''.&mt('Foil Name').' '.
''.&mt('Text').' '.
''.&mt('Freq').' '.
''.&mt('Percent').' '.
- '
';
+ $Str.= &Apache::loncommon::end_data_table().'
';
$r->print($Str);
$r->rflush();
}
@@ -515,25 +604,27 @@ sub CreateInterface {
## Environment variable initialization
my $Str = '';
my $output_selector = ''.$/;
- $Str .= &Apache::lonhtmlcommon::breadcrumbs
- (undef,'Student Submission Reports');
+ $Str .= &Apache::lonhtmlcommon::breadcrumbs('Student Submission Reports');
$Str .= '
'.&mt('Sections').' | '; - $Str .= ''.&mt('Enrollment Status').' | '; + $Str .= ''.&mt('Groups').' | '; + $Str .= ''.&mt('Access Status').' | '; $Str .= ''.&mt('Output Format').' | '; $Str .= ''.' '.' | '; $Str .= ''."\n"; + $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5); + $Str .= ' | '; + # $Str .= ''; $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5); $Str .= ' | '; @@ -550,7 +645,7 @@ sub CreateInterface { # # Render problem checkbox my $prob_checkbox = ''). - ''.''; + $Str .= '
---|