');
if (! scalar(@Problems) || ! defined($Problems[0])) {
$r->print('resource is undefined');
+ } elsif (!$show_named && @Students < $threshold) {
+ $r->print(&mt('The number of students matching the selection criteria is too few for display of submission data for anonymous surveys.').' '.&mt('There must be at least [quant,_1,student].',$threshold).' '.&mt('Contact a Domain Coordinator if you need the threshold to be changed for this course.'));
} else {
if (scalar(@Problems) == 1) {
my $resource = $Problems[0];
@@ -131,11 +155,11 @@ sub BuildStudentSubmissionsPage {
}
}
if ($env{'form.output'} eq 'excel') {
- &prepare_excel_output($r,\@Problems,\@Students);
+ &prepare_excel_output($r,\@Problems,\@Students,$show_named);
} elsif ($env{'form.output'} eq 'csv') {
- &prepare_csv_output($r,\@Problems,\@Students);
+ &prepare_csv_output($r,\@Problems,\@Students,$show_named);
} else {
- &prepare_html_output($r,\@Problems,\@Students);
+ &prepare_html_output($r,\@Problems,\@Students,$show_named);
}
}
$r->print('');
@@ -154,19 +178,37 @@ sub BuildStudentSubmissionsPage {
}
}
+sub array_shuffle {
+ my $array = shift;
+ return unless (ref($array) eq 'ARRAY');
+ my $i = scalar(@$array);
+ my $j;
+ foreach my $item (@$array) {
+ --$i;
+ $j = int(rand($i+1));
+ next if($i == $j);
+ @$array [$i,$j] = @$array[$j,$i];
+ }
+ return @$array;
+}
+
##
## get_extra_response_headers
##
+
sub get_extra_response_headers {
+ my ($show_named) = @_;
my @extra_resp_headers;
if ($env{'form.correctans'} eq 'true') {
push(@extra_resp_headers,'Correct');
- }
- if ($env{'form.prob_status'} eq 'true') {
- push(@extra_resp_headers,'Award Detail');
- push(@extra_resp_headers,'Time');
- push(@extra_resp_headers,'Attempt');
- push(@extra_resp_headers,'Awarded');
+ }
+ if ($show_named) {
+ if ($env{'form.prob_status'} eq 'true') {
+ push(@extra_resp_headers,'Award Detail');
+ push(@extra_resp_headers,'Time');
+ push(@extra_resp_headers,'Attempt');
+ push(@extra_resp_headers,'Awarded');
+ }
}
return @extra_resp_headers;
}
@@ -211,8 +253,9 @@ sub get_headers {
#########################################################
#########################################################
sub prepare_html_output {
- my ($r,$problems,$students) = @_;
+ my ($r,$problems,$students,$show_named) = @_;
my $c = $r->connection();
+ my $salt = '$1$'.$Apache::lonnet::perlvar{'AnonymousSalt'};
#
# Set a flag for the case when there is just one problem
my $single_response = 0;
@@ -222,10 +265,18 @@ sub prepare_html_output {
}
#
# Compute the number of columns per response
- my @extra_resp_headers = &get_extra_response_headers();
+ my @extra_resp_headers = &get_extra_response_headers($show_named);
#
# Create the table header
- my @student_columns = ('username','domain','id','section');
+ my @student_columns;
+ if ($show_named) {
+ @student_columns = @Apache::lonstatistics::SelectedStudentData;
+ if (grep(/^all$/,@student_columns)) {
+ @student_columns = qw(fullname username domain id section status groups comments);
+ }
+ } else {
+ @student_columns = ('username');
+ }
#
my %headers;
my $student_column_count = scalar(@student_columns);
@@ -325,9 +376,25 @@ sub prepare_html_output {
$count = 0;
}
last if ($c->aborted());
- foreach my $field (@student_columns) {
- $student_row_data .=
- '
'.$student->{$field}.'
';
+ if ($show_named) {
+ foreach my $field (@student_columns) {
+ $student_row_data .= '