--- loncom/interface/statistics/lonstudentassessment.pm 2004/02/10 19:08:02 1.81.2.1 +++ loncom/interface/statistics/lonstudentassessment.pm 2004/02/20 16:38:49 1.93 @@ -1,6 +1,6 @@ # The LearningOnline Network with CAPA # -# $Id: lonstudentassessment.pm,v 1.81.2.1 2004/02/10 19:08:02 albertel Exp $ +# $Id: lonstudentassessment.pm,v 1.93 2004/02/20 16:38:49 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -88,12 +88,6 @@ my $Statistics; =item $show 'all', 'totals', or 'scores' determines how much data is output -=item $data determines what performance data is shown - -=item $datadescription A short description of the output data selected. - -=item $base 'tries' or 'scores' determines the base of the performance shown - =item $single_student_mode evaluates to true if we are showing only one student. @@ -103,9 +97,7 @@ student. ####################################################### my $show_links; my $output_mode; -my $data; -my $base; -my $datadescription; +my $chosen_output; my $single_student_mode; ####################################################### @@ -145,9 +137,7 @@ sub BuildStudentAssessmentPage { undef($Statistics); undef($show_links); undef($output_mode); - undef($data); - undef($base); - undef($datadescription); + undef($chosen_output); undef($single_student_mode); # my %Saveable_Parameters = ('Status' => 'scalar', @@ -316,6 +306,7 @@ the chart page. ####################################################### sub CreateInterface { my $Str = ''; + $Str .= &Apache::lonhtmlcommon::breadcrumbs(undef,&mt('Chart')); # $Str .= &CreateLegend(); $Str .= '
'.$seq->{'title'}.' | '. - ''.$ave.' | '. - ''.$max.' | '.$ave.' | '. + ''.$max.' '.' | '."\n"; } - $total_ave = int(100*$total_ave)/100; # only two digit + $total_ave = sprintf('%.2f',$total_ave); # only two digit $Str .= "
Number of Students | Average | '. "Maximum |
---|---|---|
'.($num_students-$nodata_count).' | '. - ''.$total_ave.' | '.$total_max.' | '; + $Str .= '
'.($num_students-$nodata_count).' | '. + ''.$total_ave.' '.' | '. + ''.$total_max.' '.' | '; $Str .= "
@@ -897,7 +906,7 @@ summary data (Parts Correct or 255) {
+ if ($chosen_output->{'base'} eq 'scores' && $total_columns > 255) {
$r->print(<
@@ -914,15 +923,6 @@ LON-CAPA can produce CSV files of
END
$request_aborted = 1;
}
- if ($data =~ /^final table/) {
- $r->print(<
-The Summary Table (Scores) option is not available for non-HTML output.
-
@@ -1313,7 +1425,12 @@ END
$request_aborted = 1;
}
return if ($request_aborted);
-
+ #
+ # Initialize progress window
+ my $studentcount = scalar(@Apache::lonstatistics::Students);
+ %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
+ ($r,'CSV File Compilation Status',
+ 'CSV File Compilation Progress', $studentcount);
#
# Open a file
$filename = '/prtspool/'.
@@ -1334,55 +1451,54 @@ END
"\n";
#
# Print out the headings
- my $Str = '';
- my $Str2 = undef;
+ my $sequence_row = '';
+ my $resource_row = undef;
foreach my $field (&get_student_fields_to_show()) {
- if ($data eq 'sum only') {
- $Str .= '"'.&Apache::loncommon::csv_translate($field).'",';
- } elsif ($data eq 'sum and total' || $data eq 'parts correct total') {
- $Str .= '"",'; # first row empty on the student fields
- $Str2 .= '"'.&Apache::loncommon::csv_translate($field).'",';
- } elsif ($data eq 'scores' || $data eq 'tries' ||
- $data eq 'parts correct') {
- $Str .= '"",';
- $Str2 .= '"'.&Apache::loncommon::csv_translate($field).'",';
- }
+ $sequence_row .='"",';
+ $resource_row .= '"'.&Apache::loncommon::csv_translate($field).'",';
}
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
- if ($data eq 'sum only' || $data eq 'parts correct') {
- $Str .= '"'.&Apache::loncommon::csv_translate($seq->{'title'}).
- '",';
- } elsif ($data eq 'sum and total' || $data eq 'parts correct total') {
- $Str .= '"'.&Apache::loncommon::csv_translate($seq->{'title'}).
- '","",';
- $Str2 .= '"score","total possible",';
- } elsif ($data eq 'scores' || $data eq 'tries') {
- $Str .= '"'.&Apache::loncommon::csv_translate($seq->{'title'}).
- '",';
- $Str .= '"",'x($seq->{'num_assess_parts'}-1+2);
+ $sequence_row .= '"'.
+ &Apache::loncommon::csv_translate($seq->{'title'}).'",';
+ my $count = 0;
+ if ($chosen_output->{'every_problem'}) {
foreach my $res (@{$seq->{'contents'}}) {
- next if ($res->{'type'} ne 'assessment');
+ if ($res->{'type'} ne 'assessment' ||
+ ! exists($res->{'parts'}) ||
+ ref($res->{'parts'}) ne 'ARRAY' ||
+ scalar(@{$res->{'parts'}}) < 1) {
+ next;
+ }
foreach my $part (@{$res->{'parts'}}) {
- $Str2 .= '"'.&Apache::loncommon::csv_translate($res->{'title'}.', Part '.$part).'",';
+ $resource_row .= '"'.
+ &Apache::loncommon::csv_translate($res->{'title'}.
+ ', Part '.$part
+ ).'",';
+ $count++;
}
}
- $Str2 .= '"score","total possible",';
+ }
+ $sequence_row.='"",'x$count;
+ if ($chosen_output->{'sequence_sum'}) {
+ if($chosen_output->{'correct'}) {
+ $resource_row .= '"sum",';
+ } else {
+ $resource_row .= '"score",';
+ }
+ }
+ if ($chosen_output->{'sequence_max'}) {
+ $sequence_row.= '"",';
+ $resource_row .= '"maximum possible",';
}
}
- chop($Str);
- $Str .= "\n";
- print $outputfile $Str;
- if (defined($Str2)) {
- chop($Str2);
- $Str2 .= "\n";
- print $outputfile $Str2;
- }
- #
- # Initialize progress window
- my $studentcount = scalar(@Apache::lonstatistics::Students);
- %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
- ($r,'CSV File Compilation Status',
- 'CSV File Compilation Progress', $studentcount);
+ if ($chosen_output->{'grand_total'}) {
+ $sequence_row.= '"",';
+ $resource_row.= '"Total",';
+ }
+ chomp($sequence_row);
+ chomp($resource_row);
+ print $outputfile $sequence_row."\n";
+ print $outputfile $resource_row."\n";
return;
}
@@ -1409,9 +1525,10 @@ sub csv_outputstudent {
}
#
# Output performance data
+ my $total = 0;
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
my ($performance,$performance_length,$score,$seq_max,$rawdata);
- if ($base eq 'tries') {
+ if ($chosen_output->{'tries'}){
($performance,$performance_length,$score,$seq_max,$rawdata) =
&StudentTriesOnSequence($student,\%StudentsData,
$seq,'no');
@@ -1420,13 +1537,31 @@ sub csv_outputstudent {
&StudentPerformanceOnSequence($student,\%StudentsData,
$seq,'no');
}
- if ($data eq 'sum only' || $data eq 'parts correct') {
+ if ($chosen_output->{'every_problem'}) {
+ if ($chosen_output->{'correct'}) {
+ $score = 0;
+ # Deal with number of parts correct data
+ $Str .= '"'.join('","',( map { if ($_>0) {
+ $score += 1;
+ 1;
+ } else {
+ 0;
+ }
+ } @$rawdata)).'",';
+ } else {
+ $Str .= '"'.join('","',(@$rawdata)).'",';
+ }
+ }
+ if ($chosen_output->{'sequence_sum'}) {
$Str .= '"'.$score.'",';
- } elsif ($data eq 'sum and total' || $data eq 'parts correct total') {
- $Str .= '"'.$score.'","'.$seq_max.'",';
- } elsif ($data eq 'scores' || $data eq 'tries') {
- $Str .= '"'.join('","',(@$rawdata,$score,$seq_max)).'",';
+ }
+ if ($chosen_output->{'sequence_max'}) {
+ $Str .= '"'.$seq_max.'",';
}
+ $total+=$score;
+ }
+ if ($chosen_output->{'grand_total'}) {
+ $Str .= '"'.$total.'",';
}
chop($Str);
$Str .= "\n";
Compiling Excel spreadsheet for ".
- $studentcount.' student');
- $r->print('s') if ($studentcount > 1);
- $r->print("
\n");
+ if ($ENV{'form.SelectedStudent'}) {
+ $studentcount = '1';
+ }
+ if ($studentcount > 1) {
+ $r->print(''.&mt('Compiling Excel spreadsheet for [_1] students',
+ $studentcount)."
\n");
+ } else {
+ $r->print(''.
+ &mt('Compiling Excel spreadsheet for 1 student').
+ "
\n");
+ }
$r->rflush();
#
# Initialize progress window
@@ -1184,13 +1285,14 @@ sub excel_outputstudent {
# Write out sequence scores and totals data
my %total_cell_translation;
foreach my $seq (&Apache::lonstatistics::Sequences_with_Assess()) {
+ $cols_output = $seq->{'Excel:startcol'};
# Keep track of cells to translate in total cell
$total_cell_translation{$seq->{'Excel:scorecell'}} =
&Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
($rows_output,$seq->{'Excel:scorecol'});
#
my ($performance,$performance_length,$score,$seq_max,$rawdata);
- if ($base eq 'tries') {
+ if ($chosen_output->{'tries'} || $chosen_output->{'correct'}){
($performance,$performance_length,$score,$seq_max,$rawdata) =
&StudentTriesOnSequence($student,\%StudentsData,
$seq,'no');
@@ -1198,11 +1300,23 @@ sub excel_outputstudent {
($performance,$performance_length,$score,$seq_max,$rawdata) =
&StudentPerformanceOnSequence($student,\%StudentsData,
$seq,'no');
- }
- if ($data eq 'tries' || $data eq 'scores') {
- foreach my $value (@$rawdata) {
- $excel_sheet->write($rows_output,$cols_output++,$value);
+ }
+ if ($chosen_output->{'every_problem'}) {
+ if ($chosen_output->{'correct'}) {
+ # only indiciate if each item is correct or not
+ foreach my $value (@$rawdata) {
+ # nonzero means correct
+ $value = 1 if ($value > 0);
+ $excel_sheet->write($rows_output,$cols_output++,$value);
+ }
+ } else {
+ foreach my $value (@$rawdata) {
+ $excel_sheet->write($rows_output,$cols_output++,$value);
+ }
}
+ }
+ if ($chosen_output->{'sequence_sum'} &&
+ $chosen_output->{'every_problem'}) {
# Write a formula for the sum of this sequence
my %replaceCells;
$replaceCells{$seq->{'Excel:startcell'}} =
@@ -1221,21 +1335,19 @@ sub excel_outputstudent {
$seq->{'Excel:sum'},undef,
%replaceCells);
}
- #
- $excel_sheet->write($rows_output,$cols_output++,$seq_max);
- } elsif ($data eq 'sum and total' || $data eq 'sum only' ||
- $data eq 'parts correct' || $data eq 'parts correct total') {
+ } elsif ($chosen_output->{'sequence_sum'}) {
$excel_sheet->write($rows_output,$cols_output++,$score);
}
- if ($data eq 'sum and total' || $data eq 'parts correct total') {
+ if ($chosen_output->{'sequence_max'}) {
$excel_sheet->write($rows_output,$cols_output++,$seq_max);
}
}
#
- $excel_sheet->repeat_formula($rows_output,$cols_output++,
- $total_formula,undef,
- %total_cell_translation);
-
+ if ($chosen_output->{'grand_total'}) {
+ $excel_sheet->repeat_formula($rows_output,$cols_output++,
+ $total_formula,undef,
+ %total_cell_translation);
+ }
#
# Bookkeeping
$rows_output++;
@@ -1303,7 +1415,7 @@ sub csv_initialize{
#
# Deal with unimplemented requests
$request_aborted = undef;
- if ($data =~ /final table/) {
+ if ($chosen_output->{'base'} =~ /final table/) {
$r->print(<