version 1.39, 2005/03/17 18:50:06
|
version 1.43, 2006/05/01 19:29:13
|
Line 27
|
Line 27
|
package Apache::lonstudentsubmissions; |
package Apache::lonstudentsubmissions; |
|
|
use strict; |
use strict; |
use Apache::lonnet(); |
use Apache::lonnet; |
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::loncoursedata(); |
use Apache::loncoursedata(); |
Line 71 sub BuildStudentSubmissionsPage {
|
Line 71 sub BuildStudentSubmissionsPage {
|
'<h3>'.&mt('Loading student data').'</h3>'); |
'<h3>'.&mt('Loading student data').'</h3>'); |
$r->rflush(); |
$r->rflush(); |
# |
# |
if (exists($ENV{'form.problemchoice'}) && |
if (exists($env{'form.problemchoice'}) && |
! exists($ENV{'form.SelectAnother'})) { |
! exists($env{'form.SelectAnother'})) { |
foreach my $button (@SubmitButtons) { |
foreach my $button (@SubmitButtons) { |
if ($button->{'name'} eq 'break') { |
if ($button->{'name'} eq 'break') { |
$r->print("<br />\n"); |
$r->print("<br />\n"); |
Line 120 sub BuildStudentSubmissionsPage {
|
Line 120 sub BuildStudentSubmissionsPage {
|
my $resource = $Problems[0]; |
my $resource = $Problems[0]; |
$r->print('<h1>'.$resource->title.'</h1>'); |
$r->print('<h1>'.$resource->title.'</h1>'); |
$r->print('<h3>'.$resource->src.'</h3>'); |
$r->print('<h3>'.$resource->src.'</h3>'); |
if ($ENV{'form.renderprob'} eq 'true') { |
if ($env{'form.renderprob'} eq 'true') { |
$r->print(&Apache::lonstathelpers::render_resource($resource)); |
$r->print(&Apache::lonstathelpers::render_resource($resource)); |
$r->rflush(); |
$r->rflush(); |
} |
} |
} |
} |
if ($ENV{'form.output'} eq 'excel') { |
if ($env{'form.output'} eq 'excel') { |
&prepare_excel_output($r,\@Problems,\@Students); |
&prepare_excel_output($r,\@Problems,\@Students); |
} elsif ($ENV{'form.output'} eq 'csv') { |
} elsif ($env{'form.output'} eq 'csv') { |
&prepare_csv_output($r,\@Problems,\@Students); |
&prepare_csv_output($r,\@Problems,\@Students); |
} else { |
} else { |
&prepare_html_output($r,\@Problems,\@Students); |
&prepare_html_output($r,\@Problems,\@Students); |
Line 154 sub BuildStudentSubmissionsPage {
|
Line 154 sub BuildStudentSubmissionsPage {
|
## |
## |
sub get_extra_response_headers { |
sub get_extra_response_headers { |
my @extra_resp_headers; |
my @extra_resp_headers; |
if ($ENV{'form.correctans'} eq 'true') { |
if ($env{'form.correctans'} eq 'true') { |
push(@extra_resp_headers,'Correct'); |
push(@extra_resp_headers,'Correct'); |
} |
} |
if ($ENV{'form.prob_status'} eq 'true') { |
if ($env{'form.prob_status'} eq 'true') { |
push(@extra_resp_headers,'Award Detail'); |
push(@extra_resp_headers,'Award Detail'); |
push(@extra_resp_headers,'Time'); |
push(@extra_resp_headers,'Time'); |
push(@extra_resp_headers,'Attempt'); |
push(@extra_resp_headers,'Attempt'); |
Line 190 sub get_headers {
|
Line 190 sub get_headers {
|
shift(@basic_headers); # Get rid of 'Correct' |
shift(@basic_headers); # Get rid of 'Correct' |
} |
} |
@headers = (@foils,@basic_headers); |
@headers = (@foils,@basic_headers); |
|
} elsif (lc($resptype) eq 'task') { |
|
@headers = ('Grader','Status',@basic_headers,'Submission'); |
} else { |
} else { |
@headers = ('Submission',@basic_headers); |
@headers = ('Submission',@basic_headers); |
} |
} |
Line 263 sub prepare_html_output {
|
Line 265 sub prepare_html_output {
|
'</nobr></th>'; |
'</nobr></th>'; |
} |
} |
} |
} |
|
if ($part_span == 0) { |
|
next; |
|
} |
if (! $single_part) { |
if (! $single_part) { |
my $tmpname = $partid; |
my $tmpname = $partid; |
if ($partid =~/^\d+$/) { |
if ($partid =~/^\d+$/) { |
Line 340 sub prepare_html_output {
|
Line 345 sub prepare_html_output {
|
'html','normal', |
'html','normal', |
@extra_resp_headers); |
@extra_resp_headers); |
my $width = scalar(@headers); |
my $width = scalar(@headers); |
|
next if ($width < 1); |
my $resp_data; |
my $resp_data; |
$resp_data->{'fake'} = qq{<td colspan="$width"> </td>}; |
$resp_data->{'fake'} = qq{<td colspan="$width"> </td>}; |
if (! defined($results)) { |
if (! defined($results)) { |
$results = []; |
$results = []; |
} |
} |
Line 350 sub prepare_html_output {
|
Line 356 sub prepare_html_output {
|
$maxrow = scalar(@$results); |
$maxrow = scalar(@$results); |
} |
} |
for (my $j=scalar(@$results)-1;$j>=0;$j--) { |
for (my $j=scalar(@$results)-1;$j>=0;$j--) { |
if ($ENV{'form.all_sub'} ne 'true') { |
if ($env{'form.all_sub'} ne 'true') { |
next if ($j ne scalar(@$results)-1); |
next if ($j ne scalar(@$results)-1); |
} |
} |
my $response = &hashify_response($results->[$j], |
my $response = &hashify_response($results->[$j], |
Line 365 sub prepare_html_output {
|
Line 371 sub prepare_html_output {
|
$response, |
$response, |
$single_response). |
$single_response). |
'</td>'); |
'</td>'); |
|
} elsif (lc($resptype) eq 'task') { |
|
my $results = |
|
&html_task_results(\@headers, |
|
$prob,$partid,$respid, |
|
$response,$resptype); |
|
if ($results) { |
|
push(@{$resp_data->{'real'}},$results); |
|
} |
} else { |
} else { |
push(@{$resp_data->{'real'}}, |
push(@{$resp_data->{'real'}}, |
&html_non_essay_results(\@headers, |
&html_non_essay_results(\@headers, |
Line 430 sub prepare_html_output {
|
Line 444 sub prepare_html_output {
|
sub hashify_response { |
sub hashify_response { |
my ($response,$prob,$student,$partid,$respid) =@_; |
my ($response,$prob,$student,$partid,$respid) =@_; |
my $resp_hash = {}; |
my $resp_hash = {}; |
if ($ENV{'form.correctans'} eq 'true') { |
if ($env{'form.correctans'} eq 'true') { |
$resp_hash->{'Correct'} = |
$resp_hash->{'Correct'} = |
&Apache::lonstathelpers::get_student_answer |
&Apache::lonstathelpers::get_student_answer |
($prob,$student->{'username'},$student->{'domain'}, |
($prob,$student->{'username'},$student->{'domain'}, |
Line 438 sub hashify_response {
|
Line 452 sub hashify_response {
|
} |
} |
$resp_hash->{'Submission'} = |
$resp_hash->{'Submission'} = |
$response->[&Apache::loncoursedata::RDs_submission()]; |
$response->[&Apache::loncoursedata::RDs_submission()]; |
$resp_hash->{'Award Detail'} = |
|
$response->[&Apache::loncoursedata::RDs_awarddetail()]; |
|
$resp_hash->{'Time'} = |
$resp_hash->{'Time'} = |
$response->[&Apache::loncoursedata::RDs_timestamp()]; |
$response->[&Apache::loncoursedata::RDs_timestamp()]; |
$resp_hash->{'Attempt'} = |
$resp_hash->{'Attempt'} = |
$response->[&Apache::loncoursedata::RDs_tries()]; |
$response->[&Apache::loncoursedata::RDs_tries()]; |
$resp_hash->{'Awarded'} = |
$resp_hash->{'Awarded'} = |
$response->[&Apache::loncoursedata::RDs_awarded()]; |
$response->[&Apache::loncoursedata::RDs_awarded()]; |
|
if ($prob->is_task()) { |
|
$resp_hash->{'Grader'} = |
|
$response->[&Apache::loncoursedata::RDs_response_eval_2()]; |
|
if ($resp_hash->{'Attempt'} eq '0') { |
|
$resp_hash->{'Attempt'} = ''; |
|
} |
|
$resp_hash->{'Award Detail'} = |
|
$response->[&Apache::loncoursedata::RDs_part_award()]; |
|
$resp_hash->{'Status'} = |
|
$response->[&Apache::loncoursedata::RDs_response_eval()]; |
|
} else { |
|
$resp_hash->{'Award Detail'} = |
|
$response->[&Apache::loncoursedata::RDs_awarddetail()]; |
|
} |
|
|
return $resp_hash; |
return $resp_hash; |
} |
} |
|
|
Line 508 sub html_format_essay_sub {
|
Line 535 sub html_format_essay_sub {
|
return $submission; |
return $submission; |
} |
} |
|
|
|
sub html_task_results { |
|
my ($headers,$prob,$partid,$respid,$response,$resptype) = @_; |
|
if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) { |
|
return ''; |
|
} |
|
|
|
my @values; |
|
@values = map { $response->{$_}; } @$headers; |
|
|
|
my $td = '<td valign="top">'; |
|
my $str = $td.join('</td>'.$td,@values).'</td>'; |
|
return $str; |
|
} |
|
|
sub html_non_essay_results { |
sub html_non_essay_results { |
my ($headers,$prob,$partid,$respid,$response,$resptype) = @_; |
my ($headers,$prob,$partid,$respid,$response,$resptype) = @_; |
if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) { |
if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) { |
return ''; |
return ''; |
} |
} |
# |
# |
my $submission = &HTML::Entities::decode($response->{'Submission'}); |
my $submission = &HTML::Entities::decode(&Apache::lonnet::unescape($response->{'Submission'})); |
return '' if (! defined($submission) || $submission eq ''); |
return '' if (! defined($submission) || $submission eq ''); |
$submission =~ s/\\\"/\"/g; |
$submission =~ s/\\\"/\"/g; |
$submission =~ s/\\\'/\'/g; |
$submission =~ s/\\\'/\'/g; |
Line 636 sub prepare_excel_output {
|
Line 677 sub prepare_excel_output {
|
# Add headers to the worksheet |
# Add headers to the worksheet |
my $rows_output = 0; |
my $rows_output = 0; |
$worksheet->write($rows_output++,0, |
$worksheet->write($rows_output++,0, |
$ENV{'course.'.$ENV{'request.course.id'}.'.description'}, |
$env{'course.'.$env{'request.course.id'}.'.description'}, |
$format->{'h1'}); |
$format->{'h1'}); |
$rows_output++; |
$rows_output++; |
my $cols_output = 0; |
my $cols_output = 0; |
Line 725 sub prepare_excel_output {
|
Line 766 sub prepare_excel_output {
|
my $response_start_col = $start_col{$prob->symb}->{$partid}->{$respid}; |
my $response_start_col = $start_col{$prob->symb}->{$partid}->{$respid}; |
for (my $j=scalar(@$results)-1;$j>=0;$j--) { |
for (my $j=scalar(@$results)-1;$j>=0;$j--) { |
$cols_output = $response_start_col; |
$cols_output = $response_start_col; |
if ($ENV{'form.all_sub'} ne 'true') { |
if ($env{'form.all_sub'} ne 'true') { |
next if ($j ne scalar(@$results)-1); |
next if ($j ne scalar(@$results)-1); |
} |
} |
my $response = &hashify_response($results->[$j], |
my $response = &hashify_response($results->[$j], |
Line 788 sub compile_response_data {
|
Line 829 sub compile_response_data {
|
my $submission = |
my $submission = |
&HTML::Entities::decode |
&HTML::Entities::decode |
(&Apache::lonnet::unescape($response->{'Submission'})); |
(&Apache::lonnet::unescape($response->{'Submission'})); |
return () if (! defined($submission) || $submission eq ''); |
if (!$prob->is_task()) { |
|
return () if (! defined($submission) || $submission eq ''); |
|
} |
$submission =~ s/\\\"/\"/g; |
$submission =~ s/\\\"/\"/g; |
$submission =~ s/\\\'/\'/g; |
$submission =~ s/\\\'/\'/g; |
if ($resptype eq 'radiobutton') { |
if ($resptype eq 'radiobutton') { |
Line 878 sub prepare_csv_output {
|
Line 921 sub prepare_csv_output {
|
# Open a file |
# Open a file |
my $outputfile; |
my $outputfile; |
my $filename = '/prtspool/'. |
my $filename = '/prtspool/'. |
$ENV{'user.name'}.'_'.$ENV{'user.domain'}.'_'. |
$env{'user.name'}.'_'.$env{'user.domain'}.'_'. |
time.'_'.rand(1000000000).'.csv'; |
time.'_'.rand(1000000000).'.csv'; |
unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) { |
unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) { |
$r->log_error("Couldn't open $filename for output $!"); |
$r->log_error("Couldn't open $filename for output $!"); |
Line 960 sub prepare_csv_output {
|
Line 1003 sub prepare_csv_output {
|
$results = []; |
$results = []; |
} |
} |
for (my $j=0; $j<scalar(@$results);$j++) { |
for (my $j=0; $j<scalar(@$results);$j++) { |
if ($ENV{'form.all_sub'} ne 'true') { |
if ($env{'form.all_sub'} ne 'true') { |
next if ($j != 0); |
next if ($j != 0); |
} |
} |
my $idx = scalar(@$results) - $j - 1; |
my $idx = scalar(@$results) - $j - 1; |
Line 1029 sub CreateInterface {
|
Line 1072 sub CreateInterface {
|
my $output_selector = $/.'<select name="output">'.$/; |
my $output_selector = $/.'<select name="output">'.$/; |
foreach ('HTML','Excel','CSV') { |
foreach ('HTML','Excel','CSV') { |
$output_selector .= ' <option value="'.lc($_).'"'; |
$output_selector .= ' <option value="'.lc($_).'"'; |
if ($ENV{'form.output'} eq lc($_)) { |
if ($env{'form.output'} eq lc($_)) { |
$output_selector .= ' selected '; |
$output_selector .= ' selected '; |
} |
} |
$output_selector .='>'.&mt($_).'</option>'.$/; |
$output_selector .='>'.&mt($_).'</option>'.$/; |
Line 1038 sub CreateInterface {
|
Line 1081 sub CreateInterface {
|
## |
## |
## Environment variable initialization |
## Environment variable initialization |
my $Str = ''; |
my $Str = ''; |
$Str .= &Apache::lonhtmlcommon::breadcrumbs |
$Str .= &Apache::lonhtmlcommon::breadcrumbs('Student Submission Reports'); |
(undef,'Student Submission Reports'); |
|
$Str .= '<p>'; |
$Str .= '<p>'; |
$Str .= '<table cellspacing="5">'."\n"; |
$Str .= '<table cellspacing="5">'."\n"; |
$Str .= '<tr>'; |
$Str .= '<tr>'; |
Line 1058 sub CreateInterface {
|
Line 1100 sub CreateInterface {
|
# |
# |
# Render problem checkbox |
# Render problem checkbox |
my $prob_checkbox = '<input type="checkbox" name="renderprob" '; |
my $prob_checkbox = '<input type="checkbox" name="renderprob" '; |
if (exists($ENV{'form.renderprob'}) && $ENV{'form.renderprob'} eq 'true') { |
if (exists($env{'form.renderprob'}) && $env{'form.renderprob'} eq 'true') { |
$prob_checkbox .= 'checked '; |
$prob_checkbox .= 'checked '; |
} |
} |
$prob_checkbox .= 'value="true" />'; |
$prob_checkbox .= 'value="true" />'; |
# |
# |
# Compute correct answers checkbox |
# Compute correct answers checkbox |
my $ans_checkbox = '<input type="checkbox" name="correctans" '; |
my $ans_checkbox = '<input type="checkbox" name="correctans" '; |
if (exists($ENV{'form.correctans'}) && $ENV{'form.correctans'} eq 'true') { |
if (exists($env{'form.correctans'}) && $env{'form.correctans'} eq 'true') { |
$ans_checkbox .= 'checked '; |
$ans_checkbox .= 'checked '; |
} |
} |
$ans_checkbox .= 'value="true" />'; |
$ans_checkbox .= 'value="true" />'; |
# |
# |
# Show all submissions checkbox |
# Show all submissions checkbox |
my $all_sub_checkbox = '<input type="checkbox" name="all_sub" '; |
my $all_sub_checkbox = '<input type="checkbox" name="all_sub" '; |
if (exists($ENV{'form.all_sub'}) && |
if (exists($env{'form.all_sub'}) && |
$ENV{'form.all_sub'} eq 'true') { |
$env{'form.all_sub'} eq 'true') { |
$all_sub_checkbox .= 'checked '; |
$all_sub_checkbox .= 'checked '; |
} |
} |
$all_sub_checkbox.= 'value="true" />'; |
$all_sub_checkbox.= 'value="true" />'; |
# |
# |
# problem status checkbox |
# problem status checkbox |
my $prob_status_checkbox = '<input type="checkbox" name="prob_status" '; |
my $prob_status_checkbox = '<input type="checkbox" name="prob_status" '; |
if (exists($ENV{'form.prob_status'}) && |
if (exists($env{'form.prob_status'}) && |
$ENV{'form.prob_status'} eq 'true') { |
$env{'form.prob_status'} eq 'true') { |
$prob_status_checkbox .= 'checked '; |
$prob_status_checkbox .= 'checked '; |
} |
} |
$prob_status_checkbox .= 'value="true" />'; |
$prob_status_checkbox .= 'value="true" />'; |
Line 1102 sub CreateInterface {
|
Line 1144 sub CreateInterface {
|
$Str .= '</tr>'."\n"; |
$Str .= '</tr>'."\n"; |
$Str .= '</table>'."\n"; |
$Str .= '</table>'."\n"; |
# |
# |
$Str .= '<nobr>'.&mt('Status: [_1]', |
$Str .= '<p><nobr>'.&mt('Status: [_1]', |
'<input type="text" '. |
'<input type="text" '. |
'name="stats_status" size="60" value="" />'). |
'name="stats_status" size="60" value="" />'). |
'</nobr>'.'</p>'; |
'</nobr>'.'</p>'; |