'.&mt('LON-CAPA is unable to produce your Excel spreadsheet because your selections will result in more than 255 columns. Excel allows only 255 columns in a spreadsheet.').'
'.$/.
+ 'Unable to Complete Request
@@ -1174,7 +1482,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/'.
@@ -1195,55 +1508,58 @@ 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",';
}
- }
- 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);
+ $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",';
+ }
+ }
+ if ($chosen_output->{'grand_total'}) {
+ $sequence_row.= '"",';
+ $resource_row.= '"Total",';
+ }
+ if ($chosen_output->{'grand_maximum'}) {
+ $sequence_row.= '"",';
+ $resource_row.= '"Maximum",';
+ }
+ chomp($sequence_row);
+ chomp($resource_row);
+ print $outputfile $sequence_row."\n";
+ print $outputfile $resource_row."\n";
return;
}
@@ -1256,7 +1572,12 @@ sub csv_outputstudent {
# Output student fields
my @to_show = &get_student_fields_to_show();
foreach my $field (@to_show) {
- $Str .= '"'.&Apache::loncommon::csv_translate($student->{$field}).'",';
+ my $value = $student->{$field};
+ if ($field eq 'comments') {
+ $value = &Apache::lonmsg::retrieve_instructor_comments
+ ($student->{'username'},$student->{'domain'});
+ }
+ $Str .= '"'.&Apache::loncommon::csv_translate($value).'",';
}
#
# Get student assessment data
@@ -1270,9 +1591,11 @@ sub csv_outputstudent {
}
#
# Output performance data
+ my $total = 0;
+ my $maximum = 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');
@@ -1281,13 +1604,35 @@ 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;
+ $maximum += $seq_max;
+ }
+ if ($chosen_output->{'grand_total'}) {
+ $Str .= '"'.$total.'",';
+ }
+ if ($chosen_output->{'grand_maximum'}) {
+ $Str .= '"'.$maximum.'",';
}
chop($Str);
$Str .= "\n";
@@ -1312,7 +1657,7 @@ sub csv_finish {
#
# Tell the user where to get their csv file
$r->print('
'.
- 'Your csv file.'."\n");
+ ''.&mt('Your csv file.').''."\n");
$r->rflush();
return;
@@ -1353,6 +1698,7 @@ sub StudentTriesOnSequence {
my $performance_length = 0;
my @TriesData = ();
my $tries;
+ my $hasdata = 0; # flag - true if the student has any data on the sequence
foreach my $resource (@{$seq->{'contents'}}) {
next if ($resource->{'type'} ne 'assessment');
my $resource_data = $studentdata->{$resource->{'symb'}};
@@ -1363,47 +1709,61 @@ sub StudentTriesOnSequence {
$performance_length++;
my $symbol = ' '; # default to space
#
+ my $awarded = 0;
+ if (exists($resource_data->{'resource.'.$partnum.'.awarded'})) {
+ $awarded = $resource_data->{'resource.'.$partnum.'.awarded'};
+ $awarded = 0 if (! $awarded);
+ }
+ #
+ my $status = '';
if (exists($resource_data->{'resource.'.$partnum.'.solved'})) {
- my $status = $resource_data->{'resource.'.$partnum.'.solved'};
- if ($status eq 'correct_by_override') {
- $symbol = '+';
- $sum++;
- } elsif ($status eq 'incorrect_by_override') {
- $symbol = '-';
- } elsif ($status eq 'ungraded_attempted') {
- $symbol = '#';
- } elsif ($status eq 'incorrect_attempted') {
- $symbol = '.';
- } elsif ($status eq 'excused') {
+ $status = $resource_data->{'resource.'.$partnum.'.solved'};
+ }
+ #
+ my $tries = 0;
+ if(exists($resource_data->{'resource.'.$partnum.'.tries'})) {
+ $tries = $resource_data->{'resource.'.$partnum.'.tries'};
+ $hasdata =1;
+ }
+ #
+ if ($awarded > 0) {
+ # The student has gotten the problem correct to some degree
+ if ($status eq 'excused') {
$symbol = 'x';
$max--;
- } elsif ($status eq 'correct_by_student' &&
- exists($resource_data->{'resource.'.$partnum.'.tries'})){
- $tries = $resource_data->{'resource.'.$partnum.'.tries'};
+ } elsif ($status eq 'correct_by_override') {
+ $symbol = '+';
+ $sum++;
+ } elsif ($tries > 0) {
if ($tries > 9) {
$symbol = '*';
- } elsif ($tries > 0) {
- $symbol = $tries;
} else {
- $symbol = ' ';
+ $symbol = $tries;
}
$sum++;
- } elsif (exists($resource_data->{'resource.'.
- $partnum.'.tries'})){
- $symbol = '.';
} else {
- $symbol = ' ';
+ $symbol = '+';
+ $sum++;
}
} else {
- # Unsolved. Did they try?
- if (exists($resource_data->{'resource.'.$partnum.'.tries'})){
+ # The student has the problem incorrect or it is ungraded
+ if ($status eq 'excused') {
+ $symbol = 'x';
+ $max--;
+ } elsif ($status eq 'incorrect_by_override') {
+ $symbol = '-';
+ } elsif ($status eq 'ungraded_attempted') {
+ $symbol = '#';
+ } elsif ($status eq 'incorrect_attempted' ||
+ $tries > 0) {
$symbol = '.';
} else {
- $symbol = ' ';
+ # Problem is wrong and has not been attempted.
+ $symbol=' ';
}
}
#
- if (! defined($tries)) {
+ if (! defined($tries) || $symbol eq '.') {
$tries = $symbol;
}
push (@TriesData,$tries);
@@ -1416,7 +1776,7 @@ sub StudentTriesOnSequence {
$symbol = ''.$symbol.'';
}
$value .= $symbol;
@@ -1426,6 +1786,9 @@ sub StudentTriesOnSequence {
if ($seq->{'randompick'}) {
$max = $seq->{'randompick'};
}
+ if (! $hasdata && $sum == 0) {
+ $sum = ' ';
+ }
return ($Str,$performance_length,$sum,$max,\@TriesData);
}
@@ -1463,6 +1826,7 @@ sub StudentPerformanceOnSequence {
my $symbol;
my @ScoreData = ();
my $partscore;
+ my $hasdata = 0; # flag, 0 if there were no submissions on the sequence
foreach my $resource (@{$seq->{'contents'}}) {
next if ($resource->{'type'} ne 'assessment');
my $resource_data = $studentdata->{$resource->{'symb'}};
@@ -1481,14 +1845,22 @@ sub StudentPerformanceOnSequence {
$performance_length++; # one character per part
$symbol = ' '; # default to space
#
- my $awarded = 0;
+ my $awarded;
if (exists($resource_data->{'resource.'.$part.'.awarded'})) {
$awarded = $resource_data->{'resource.'.$part.'.awarded'};
+ $awarded = 0 if (! $awarded);
+ $hasdata = 1;
}
#
$partscore = $weight*$awarded;
+ if (! defined($awarded)) {
+ $partscore = undef;
+ }
$score += $partscore;
- $symbol = $weight;
+ $symbol = $partscore;
+ if (abs($symbol - sprintf("%.0f",$symbol)) < 0.001) {
+ $symbol = sprintf("%.0f",$symbol);
+ }
if (length($symbol) > 1) {
$symbol = '*';
}
@@ -1498,28 +1870,34 @@ sub StudentPerformanceOnSequence {
$symbol = 'x';
$max -= $weight; # Do not count 'excused' problems.
}
+ $hasdata = 1;
} else {
# Unsolved. Did they try?
if (exists($resource_data->{'resource.'.$part.'.tries'})){
$symbol = '.';
+ $hasdata = 1;
} else {
$symbol = ' ';
}
}
#
+ if (! defined($partscore)) {
+ $partscore = $symbol;
+ }
+ push (@ScoreData,$partscore);
+ #
if ( ($links eq 'yes' && $symbol ne ' ') || ($links eq 'all')) {
$symbol = ''.$symbol.'';
}
- if (! defined($partscore)) {
- $partscore = $symbol;
- }
- push (@ScoreData,$partscore);
+ $Str .= $symbol;
}
- $Str .= $symbol;
+ }
+ if (! $hasdata && $score == 0) {
+ $score = ' ';
}
return ($Str,$performance_length,$score,$max,\@ScoreData);
}