--- loncom/interface/statistics/lonproblemstatistics.pm 2005/03/01 00:07:21 1.97 +++ loncom/interface/statistics/lonproblemstatistics.pm 2005/03/14 20:28:22 1.102 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemstatistics.pm,v 1.97 2005/03/01 00:07:21 matthew Exp $ +# $Id: lonproblemstatistics.pm,v 1.102 2005/03/14 20:28:22 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -353,17 +353,18 @@ my @Fields = ( # selectable => 'no', # defaultselected => 'yes', # }, -## weight included for research purposes. Commented out most of the time. -# { name => 'weight', -# title => 'weight', -# align => 'right', -# color => '#FFFFFF', -# sortable => 'no', -# graphable => 'no', -# long_title => 'Problem weight (for instructor)', -# selectable => 'no', -# defaultselected => 'yes', -# }, +# +## problem weight for instructor + { name => 'weight', + title => 'weight', + align => 'right', + color => '#FFFFFF', + sortable => 'no', + graphable => 'no', + long_title => 'Problem weight (for instructor)', + selectable => 'yes', + defaultselected => 'yes', + }, ); my @SeqFields = ( @@ -712,20 +713,26 @@ sub BuildProblemStatisticsPage { # it does not slow things down noticably. &Apache::loncoursedata::populate_weight_table(); # + ($navmap,@sequences) = + &Apache::lonstatistics::selected_sequences_with_assessments(); + if (! ref($navmap)) { + $r->print('

'.&mt('A course-wide error occured.').'

'. + '

'.$navmap.'

'); + return; + } if (exists($ENV{'form.Excel'})) { + $r->print('

'. + &Apache::lonstatistics::section_and_enrollment_description(). + '

'); &Excel_output($r); } else { $r->print(''.' 'x5); $r->rflush(); + $r->print('

'. + &Apache::lonstatistics::section_and_enrollment_description(). + '

'); my $count = 0; - ($navmap,@sequences) = - &Apache::lonstatistics::selected_sequences_with_assessments(); - if (! ref($navmap)) { - $r->print('

'.&mt('A course-wide error occured.').'

'. - '

'.$navmap.'

'); - return; - } foreach my $seq (@sequences) { my @resources = &Apache::lonstathelpers::get_resources($navmap,$seq); @@ -1263,30 +1270,13 @@ sub Excel_output { &compute_all_statistics($r); my $c = $r->connection; return if ($c->aborted()); + # + my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); ## ## Create the excel workbook - my $filename = '/prtspool/'. - $ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. - time.'_'.rand(1000000000).'.xls'; - my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits(); - # - # Create sheet - my $excel_workbook = Spreadsheet::WriteExcel->new('/home/httpd'.$filename); - # - # Check for errors - if (! defined($excel_workbook)) { - $r->log_error("Error creating excel spreadsheet $filename: $!"); - $r->print(&mt("Problems creating new Excel file. ". - "This error has been logged. ". - "Please alert your LON-CAPA administrator.")); - return 0; - } - # - # The excel spreadsheet stores temporary data in files, then put them - # together. If needed we should be able to disable this (memory only). - # The temporary directory must be specified before calling 'addworksheet'. - # File::Temp is used to determine the temporary directory. - $excel_workbook->set_tempdir($Apache::lonnet::tmpdir); + my ($excel_workbook,$filename,$format) = + &Apache::loncommon::create_workbook($r); + return if (! defined($excel_workbook)); # # Add a worksheet my $sheetname = $ENV{'course.'.$ENV{'request.course.id'}.'.description'}; @@ -1295,8 +1285,6 @@ sub Excel_output { } my $excel_sheet = $excel_workbook->addworksheet( &Apache::loncommon::clean_excel_name($sheetname)); - # - my $format = &Apache::loncommon::define_excel_formats($excel_workbook); ## ## Begin creating excel sheet ## @@ -1312,9 +1300,9 @@ sub Excel_output { my $sectionstring = ''; $excel_sheet->write($rows_output,$cols_output++, &Apache::lonstathelpers::sections_description - (@Apache::lonstatistics::SelectedSections), + (&Apache::lonstatistics::get_selected_sections()), $format->{'h3'}); - $cols_output += scalar(@Apache::lonstatistics::SelectedSections); + $cols_output += scalar(&Apache::lonstatistics::get_selected_sections()); # # Time restrictions my $time_string; @@ -1555,7 +1543,7 @@ sub get_statistics { my $courseid = $ENV{'request.course.id'}; # my $data = &Apache::loncoursedata::get_problem_statistics - (\@Apache::lonstatistics::SelectedSections, + ([&Apache::lonstatistics::get_selected_sections()], $Apache::lonstatistics::enrollment_status, $symb,$part,$courseid,$starttime,$endtime); $data->{'symb'} = $symb; @@ -1573,7 +1561,7 @@ sub get_statistics { # # Store in metadata if computations were done for all students if ($data->{'num_students'} > 1) { - my @Sections = @Apache::lonstatistics::SelectedSections; + my @Sections = &Apache::lonstatistics::get_selected_sections(); my $sections = '"'.join(' ',@Sections).'"'; $sections =~ s/&+/_/g; # Ensure no special characters $data->{'sections'}=$sections; @@ -1598,8 +1586,8 @@ sub get_statistics { # &Apache::lonnet::EXT('resource.'.$part.'.maxtries',$symb); # $data->{'hinttries'} = # &Apache::lonnet::EXT('resource.'.$part.'.hinttries',$symb); -# $data->{'weight'} = -# &Apache::lonnet::EXT('resource.'.$part.'.weight',$symb); + $data->{'weight'} = + &Apache::lonnet::EXT('resource.'.$part.'.weight',$symb); # $data->{'resptypes'} = join(',',@{$resource->{'partdata'}->{$part}->{'ResponseTypes'}}); return $data; } @@ -1633,7 +1621,7 @@ sub compute_discrimination_factor { my $ranking = &Apache::loncoursedata::rank_students_by_scores_on_resources (\@Resources, - \@Apache::lonstatistics::SelectedSections, + [&Apache::lonstatistics::get_selected_sections()], $Apache::lonstatistics::enrollment_status,undef, $starttime,$endtime); # @@ -1698,7 +1686,7 @@ sub compute_sequence_statistics { # First compute statistics based on student scores my ($smin,$smax,$sMean,$sSTD,$scount,$sMAX) = &Apache::loncoursedata::score_stats - (\@Apache::lonstatistics::SelectedSections, + ([&Apache::lonstatistics::get_selected_sections()], $Apache::lonstatistics::enrollment_status, \@Resources,$starttime,$endtime,undef); $SeqStat{$symb}->{'title'} = $seq->compTitle; @@ -1713,7 +1701,7 @@ sub compute_sequence_statistics { # 'correct' is taken to mean my ($cmin,$cmax,$cMean,$cSTD,$ccount)= &Apache::loncoursedata::count_stats - (\@Apache::lonstatistics::SelectedSections, + ([&Apache::lonstatistics::get_selected_sections()], $Apache::lonstatistics::enrollment_status, \@Resources,$starttime,$endtime,undef); my $K = $part_count;