--- loncom/interface/statistics/lonproblemanalysis.pm 2003/10/20 20:42:39 1.43 +++ loncom/interface/statistics/lonproblemanalysis.pm 2012/05/03 11:21:33 1.142 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonproblemanalysis.pm,v 1.43 2003/10/20 20:42:39 matthew Exp $ +# $Id: lonproblemanalysis.pm,v 1.142 2012/05/03 11:21:33 goltermann Exp $ # # Copyright Michigan State University Board of Trustees # @@ -24,466 +24,1430 @@ # # http://www.lon-capa.org/ # - package Apache::lonproblemanalysis; use strict; -use Apache::lonnet(); +use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::loncoursedata(); +use Apache::lonquickgrades(); use Apache::lonstatistics; use Apache::lonlocal; +use Apache::lonstathelpers(); +use Apache::lonstudentsubmissions(); use HTML::Entities(); use Time::Local(); -use Spreadsheet::WriteExcel(); +use capa; +use lib '/home/httpd/lib/perl/'; +use LONCAPA; + my $plotcolors = ['#33ff00', '#0033cc', '#990000', '#aaaa66', '#663399', '#ff9933', '#66ccff', '#ff9999', '#cccc33', '#660000', '#33cc66', ]; +my @SubmitButtons = ({ name => 'PrevProblemAnalysis', + text => 'Previous Problem' }, + { name => 'ProblemAnalysis', + text => 'Analyze Problem Again' }, + { name => 'NextProblemAnalysis', + text => 'Next Problem' }, + { name => 'break'}, + { name => 'SelectAnother', + text => 'Choose a different Problem' }); + sub BuildProblemAnalysisPage { my ($r,$c)=@_; - $r->print('
'.
- ' |
'.&Apache::lonstatistics::section_and_enrollment_description().'
'); + if ($env{'form.show_prob'} eq 'true') { + $r->print(''.
+ &mt($no_data_message,$plot_num,@extra_data).
+ ' | |
'. + &mt($header_message,$plot_num,@extra_data). + ' | |
'. + &mt($stats_message, + $stats->{'submission_count'}, + $stats->{'correct_count'}, + $stats->{'incorrect_count'}, + $stats->{'students'}, + @extra_data). + ' | |
'. + &numerical_plot_percent($r,$responses,$stats).' | '. + ''. + &numerical_plot_differences($r,$responses,$stats).' | '. + '
'.$post_message.' |
'.&mt('Concept Number').' | '. - ''.&mt('Concept').' | '. - ''.&mt('Foil Number').' | '. - ''.&mt('Foil Name').' | '. - ''.&mt('Foil Text').' | '. - ''.&mt('Correct Value').' | '. - "|
---|---|---|---|---|---|---|
'.&mt('Foil Number').' | '. - ''.&mt('Foil Name').' | '. - ''.&mt('Foil Text').' | '. - ''.&mt('Correct Value').' | '. - "|||
'.$conceptindex.' | '. - ''.$concept->{'name'}.' | '. - ''.$foilindex++.' | '. - ''.$Foildata{$firstfoil}->{'name'}.' | '. - ''.$Foildata{$firstfoil}->{'text'}.' | '. - ''.$Foildata{$firstfoil}->{'value'}.' | '. - "
'.&mt('Bar').' | '. + ''.&mt('Range').' | '. + ''.&mt('Incorrect').' | '. + ''.&mt('Correct').' | '. + ''.&mt('Count').' | '. + '||
---|---|---|---|---|---|---|
'.$labels->[$i].' | '. + ''.$lownum.' | '. + '- | '. + ''.$highnum.' | '. + ''.$incorrect->[$i].' | '. + ''.$correct->[$i].' | '. + ''.$count->[$i].' | '. + '
'.
+ ''.&mt('Distribution of correct answers').''.
+ ' '.&mt('[_1] students, [_2] distinct correct answers', + $n,scalar(keys(%$data))). + ' '.&mt('Maximum number of coinciding values: [_1]',$max_y). + ' | ||
'.$min_x.' | '. + ''.$plotresult.' | '. + ''.$max_x.' | '. + '
'.$foilindex++.' | '. - ''.$Foildata{$firstfoil}->{'name'}.' | '. - ''.$Foildata{$firstfoil}->{'text'}.' | '. - ''.$Foildata{$firstfoil}->{'value'}.' | '. - "||
'. - ' | '. - ' | '.$foilindex.' | '. - ''.$Foildata{$foilid}->{'name'}.' | '. - ''.$Foildata{$foilid}->{'text'}.' | '. - ''.$Foildata{$foilid}->{'value'}.' | '. - "
'. + ''. + &mt($pre_graph_text, + $plot_num,$foil_choice_data->{'_count'}, + $correct, + $incorrect, + $foil_choice_data->{'_students'}, + @extra_data). + ' | |||||
'.$concept_plot.' | '. + ''.$choice_plot.' | '; + if ($stacked_plot ne '') { + $analysis_html .= + ''.$stacked_plot.' | '. + ''.&build_foil_key($foils,$count_by_foil).' | '; } else { - $table .= '||
'.$foilindex.' | '. - ''.$Foildata{$foilid}->{'name'}.' | '. - ''.$Foildata{$foilid}->{'text'}.' | '. - ''.$Foildata{$foilid}->{'value'}.' | '. - "'x2); + } + $analysis_html.=''.$/; + if (defined($post_graph_text)) { + $analysis_html.= ' | |
'. + $post_graph_text.' | |||||
'.
+ ' '.
+ &mt($no_data_text,
+ $plot_num,$foil_choice_data->{'_count'},
+ $correct,
+ $foil_choice_data->{'_count'}-$correct,
+ @extra_data).
+ ' ';
+ if (defined($post_graph_text)) {
+ $analysis_html.=''.$post_graph_text; + } + $analysis_html.=' |
'. - (' 'x4).' | '. - ''.$option.' | '. - "
'
+ .' '
+ .&mt('None of the selected students attempted the problem more than [quant,_1,time].'
+ ,$try-1)
+ .' '
+ .' | |||
'
+ .' '
+ .&mt('None of the selected students have attempted the problem.')
+ .' '
+ .' | |||
'.$correctgraph.' | '; - ## - ## - for (my $i=0; $i< scalar(@{$Datasets[0]});$i++) { - $Datasets[0]->[$i]=0; + foreach my $option ('_correct',@{$ORdata->{'_Options'}}) { + next if (! exists($foil_plot[$try]->{$option})); + push(@Datasets,$foil_plot[$try]->{$option}); } - $count = $ResponseData{'_total'}->[$i]-$ResponseData{'_correct'}->[$i]; - if ($count == 0) { - $count = 'no submissions'; - } elsif ($count == 1) { - $count = '1 submission'; - } else { - $count = $count.' submissions'; + # + # Put a blank in the data set between concepts + for (my $set =0;$set<=$#Datasets;$set++) { + my @Data = @{$Datasets[$set]}; + my $idx = 0; + foreach my $concept (@{$Concepts}) { + foreach my $foilid (@{$concept->{'foils'}}) { + $Datasets[$set]->[$idx++]=shift(@Data); + } + if ($concept->{'name'} ne $Concepts->[-1]->{'name'}) { + $Datasets[$set]->[$idx++] = 0; + } + } } - $title = 'Attempt '.$i.', '.$count; - my $incorrectgraph = &Apache::loncommon::DrawGraph - ($title,'Foil Number','% Option Chosen Incorrectly', - 100,$plotcolors,@Datasets); - $analysis_html.= ''.$incorrectgraph.' | '; - $analysis_html.= ''.$foilkey." |
'.$graphlink." | ||||
'. + ''. + &mt('Attempt [_1], [_2] submissions, [_3] correct, [_4] incorrect', + $try,$data_count,$correct,$data_count-$correct). + ''.' | ||||
'.$concept_graph.' | '. + ''.$correct_graph.' | '. + ''.$incorrect_graph.' | '. + ''.$optionkey.' | '. + ' |
'. + &mt('Data from [_1] to [_2]', + &Apache::lonlocal::locallocaltime($starttime), + &Apache::lonlocal::locallocaltime($endtime)). + ' | |||
'. + &mt('[_1] submissions from [_2] students, [_3] correct, [_4] incorrect', + $data_count,$student_count,$correct,$data_count-$correct). + ' | |||
'.$concept_correct_plot.' | '. + ''.$foil_correct_plot.' | '. + ''.$foil_incorrect_plot.' | '. + ''.$foilkey.' |
'.
+ &mt('Start time: [_1]',$startdateform).' '. + &mt('End time: [_1]',$enddateform).' | |||
'.&mt("Unable to create new Excel file. ". - "This error has been logged. ". - "Please alert your LON-CAPA administrator"). - '
'); + return &Apache::loncommon::DrawBarGraph('Correct Concepts', + 'Concept Number', + 'Percent Correct', + 100, + $plotcolors, + undef, + \@plotdata,{xskip=>1}); +} + +sub OR_time_process_data { + my ($performance_data,$begin_index,$end_index)=@_; + my %processed_time_data; + my %distinct_students; + my ($correct,$data_count); + if (($begin_index == $end_index) && + ($end_index != scalar(@$performance_data)-1)) { return undef; } - # - $workbook->set_tempdir('/home/httpd/perl/tmp'); - # - # Define some potentially useful formats - my $format; - $format->{'header'} = $workbook->add_format(bold => 1, - bottom => 1, -# text_wrap => 1, - align => 'center'); - $format->{'bold'} = $workbook->add_format(bold=>1); - $format->{'h1'} = $workbook->add_format(bold=>1, size=>18); - $format->{'h2'} = $workbook->add_format(bold=>1, size=>16); - $format->{'h3'} = $workbook->add_format(bold=>1, size=>14); - $format->{'date'} = $workbook->add_format(num_format=> - 'mmm d yyyy hh:mm AM/PM'); - # - # Create and populate main worksheets - my $problem_data_sheet = $workbook->addworksheet('Problem Data'); - my $student_data_sheet = $workbook->addworksheet('Student Data'); - my $response_data_sheet = $workbook->addworksheet('Response Data'); - foreach my $sheet ($problem_data_sheet,$student_data_sheet, - $response_data_sheet) { - $sheet->write(0,0,$resource->{'title'},$format->{'h2'}); - $sheet->write(1,0,$resource->{'src'},$format->{'h3'}); - } - # - my $result; - $result = &build_problem_data_worksheet($problem_data_sheet,$format, - $Concepts,$ORdata); - if ($result ne 'okay') { - # Do something useful - } - $result = &build_student_data_worksheet($student_data_sheet,$format); - if ($result ne 'okay') { - # Do something useful - } - $result = &build_response_data_worksheet($response_data_sheet,$format, - $PerformanceData,$Foils, - $ORdata); - if ($result ne 'okay') { - # Do something useful - } - $response_data_sheet->activate(); - # - # Close the excel file - $workbook->close(); - # - # Write a link to allow them to download it - $result .= ''. + ''.('*'x3).''.' | '. + ''.&HTML::Entities::encode($option,'<>&"').' | '. + "
'. + ''.('*'x4).' | '. + ''.&HTML::Entities::encode($foil,'<>&"'). + (' 'x2).$extra_data->{$foil}.' | '. + "
'.&mt('Sections').' | '; - $Str .= ''.&mt('Enrollment Status').' | '; -# $Str .= ''.&mt('Sequences and Folders').' | '; - $Str .= ''; - $Str .= ' | '.&mt('Sections').' | '; + $Str .= ''.&mt('Groups').' | '; + $Str .= ''.&mt('Access Status').' | '; + $Str .= ''.&mt('Options').' | '; + $Str .= &Apache::loncommon::end_data_table_header_row(); ## ## - $Str .= '
---|---|---|---|---|---|---|
'."\n"; + $Str .= &Apache::loncommon::start_data_table_row(); + $Str .= ' | '."\n"; $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5); $Str .= ' | '; # + $Str .= ''."\n"; + $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5); + $Str .= ' | '; + # $Str .= ''; $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5); $Str .= ' | '; # -# $Str .= ''; - my $only_seq_with_assessments = sub { - my $s=shift; - if ($s->{'num_assess'} < 1) { - return 0; - } else { - return 1; - } - }; - &Apache::lonstatistics::MapSelect('Maps','multiple,all',5, - $only_seq_with_assessments); ## ## - $Str .= ' | ';
- { # These braces are here to organize the code, not scope it.
- {
- $Str .= ' '; - } - { - $Str .= ' '; - } - { - $Str .= ' | ';
+ ##
+ my $showprob_checkbox =
+ '';
+ $Str.= ' '; + ## + my $analyze_selector = ''; + $Str .= ' '.$/; + ## + my $numplots_selector = ''; + $Str .= ' '; + ## $Str .= ' | ';
##
##
- $Str .= '
'. - ''. - ' | '. - ''.$res->{'title'}.' '; - if ($partdata->{'option'} > 1) { - $seq_str .= &mt('response').' '.$respid; - } - $seq_str .= " |
  | '.$seq->{'title'}.' | '. - "