version 1.18, 2004/09/15 21:08:50
|
version 1.20, 2004/09/20 19:24:02
|
Line 67 sub BuildStudentSubmissionsPage {
|
Line 67 sub BuildStudentSubmissionsPage {
|
} |
} |
# |
# |
my @CacheButtonHTML = |
my @CacheButtonHTML = |
&Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status'); |
&Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status', |
|
'<h3>'.&mt('Loading student data').'</h3>'); |
$r->rflush(); |
$r->rflush(); |
# |
# |
if (exists($ENV{'form.problemchoice'}) && |
if (exists($ENV{'form.problemchoice'}) && |
Line 123 sub BuildStudentSubmissionsPage {
|
Line 124 sub BuildStudentSubmissionsPage {
|
$r->rflush(); |
$r->rflush(); |
} |
} |
} |
} |
my %Data; |
&new_excel_output($r,\@Problems,\@Students); |
if (scalar(@Problems) > 5) { |
|
# progress window |
|
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin |
|
($r,'Problem Analysis Status', |
|
'Problem Analysis Progress', |
|
scalar(@Problems), |
|
'inline',undef,'Statistics','stats_status'); |
|
foreach my $problem (@Problems) { |
|
$Data{$problem->symb} = |
|
{&Apache::lonstathelpers::get_problem_data |
|
($problem->src)}; |
|
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
|
'last problem'); |
|
|
|
} |
|
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
|
} else { |
|
foreach my $problem (@Problems) { |
|
$Data{$problem->symb} = |
|
{&Apache::lonstathelpers::get_problem_data |
|
($problem->src)}; |
|
} |
|
} |
|
&new_excel_output($r,\@Problems,\@Students,\%Data); |
|
} |
} |
$r->print('<hr />'); |
$r->print('<hr />'); |
} else { |
} else { |
$r->print('<input type="submit" name="Generate" value="'. |
$r->print('<input type="submit" name="Generate" value="'. |
&mt('Prepare Report').'" />'); |
&mt('Prepare Report').'" />'); |
$r->print(' 'x5); |
$r->print(' 'x5); |
$r->print('<h3>'.&mt('Please select a problem to analyze').'</h3>'); |
$r->print('<p>'. |
|
&mt('Computing correct answers greatly increasese the amount of time required to prepare a report.'). |
|
'</p>'); |
|
$r->print('<p>'. |
|
&mt('please select problems and use the <b>Prepare Report</b> button to continue.'). |
|
'</p>'); |
$r->print(&Apache::lonstathelpers::MultipleProblemSelector |
$r->print(&Apache::lonstathelpers::MultipleProblemSelector |
(undef,'.','problemchoice','Statistics')); |
(undef,'problemchoice','Statistics')); |
} |
} |
} |
} |
|
|
Line 164 sub BuildStudentSubmissionsPage {
|
Line 146 sub BuildStudentSubmissionsPage {
|
######################################################### |
######################################################### |
|
|
sub new_excel_output { |
sub new_excel_output { |
my ($r,$Problems,$Students,$ProblemData) = @_; |
my ($r,$Problems,$Students) = @_; |
my $c = $r->connection(); |
my $c = $r->connection(); |
# |
# |
|
# |
|
# Determine the number of columns in the spreadsheet |
|
my $columncount = 3; # username, domain, id |
|
my $response_multiplier = 1; |
|
$response_multiplier ++ if ($ENV{'form.correctans'} eq 'true'); |
|
$response_multiplier += 4 if ($ENV{'form.prob_status'} eq 'true'); |
|
my $lastprob; |
|
foreach my $prob (@$Problems) { |
|
$columncount += ($response_multiplier * $prob->countResponses); |
|
last if ($columncount > 255); |
|
$lastprob = $prob; |
|
} |
|
if ($columncount > 255) { |
|
$r->print('<h1>'.&mt('Unable to complete request').'</h1>'.$/. |
|
'<p>'.&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.').'</p>'.$/. |
|
'<p>'.&mt('Consider selecting fewer problems to generate reports on, or reducing the number of items per problem. Or use HTML or CSV output.').'</p>'.$/. |
|
'<p>'.&mt('The last problem that will fit in the current spreadsheet is [_1].',&get_title($lastprob->title,$lastprob->src)).'</p>'); |
|
$r->rflush(); |
|
return; |
|
} |
|
# |
|
# Print out a message telling them what we are doing |
if (scalar(@$Problems) > 1) { |
if (scalar(@$Problems) > 1) { |
$r->print('<h2>'. |
$r->print('<h2>'. |
&mt('Preparing Excel spreadsheet of student responses to [_1] problems', |
&mt('Preparing Excel spreadsheet of student responses to [_1] problems', |
Line 215 sub new_excel_output {
|
Line 219 sub new_excel_output {
|
# Student headers |
# Student headers |
my @StudentColumns = ('username','domain','id'); |
my @StudentColumns = ('username','domain','id'); |
foreach (@StudentColumns) { |
foreach (@StudentColumns) { |
$worksheet->write($header_row,$cols_output++,$_,$format->{'bold'}); |
$worksheet->write($header_row,$cols_output++,ucfirst($_), |
|
$format->{'bold'}); |
} |
} |
# Problem headers |
# Problem headers |
foreach my $prob (@$Problems) { |
foreach my $prob (@$Problems) { |
Line 231 sub new_excel_output {
|
Line 236 sub new_excel_output {
|
$resptypes->[$i].', '.$responses->[$i]); |
$resptypes->[$i].', '.$responses->[$i]); |
$worksheet->write($header_row,$cols_output,'Submission'); |
$worksheet->write($header_row,$cols_output,'Submission'); |
$cols_output++; |
$cols_output++; |
|
if ($ENV{'form.correctans'} eq 'true') { |
|
$worksheet->write($header_row,$cols_output,'Correct'); |
|
$cols_output++; |
|
} |
|
if ($ENV{'form.prob_status'} eq 'true') { |
|
$worksheet->write($header_row,$cols_output++, |
|
'Award Detail'); |
|
$worksheet->write($header_row,$cols_output++,'Attempt'); |
|
$worksheet->write($header_row,$cols_output++,'Time'); |
|
$worksheet->write($header_row,$cols_output++,'Awarded'); |
|
} |
} |
} |
} |
} |
} |
} |
Line 240 sub new_excel_output {
|
Line 256 sub new_excel_output {
|
($r,'Excel File Compilation Status', |
($r,'Excel File Compilation Status', |
'Excel File Compilation Progress', |
'Excel File Compilation Progress', |
scalar(@$Students),'inline',undef,'Statistics','stats_status'); |
scalar(@$Students),'inline',undef,'Statistics','stats_status'); |
|
my $max_row = $rows_output; |
foreach my $student (@$Students) { |
foreach my $student (@$Students) { |
last if ($c->aborted()); |
last if ($c->aborted()); |
$cols_output = 0; |
$cols_output = 0; |
|
my $student_row = $max_row; |
foreach my $field (@StudentColumns) { |
foreach my $field (@StudentColumns) { |
$worksheet->write($rows_output,$cols_output++, |
$worksheet->write($student_row,$cols_output++, |
$student->{$field}); |
$student->{$field}); |
} |
} |
|
my $last_student_col = $cols_output-1; |
|
my $response_count; |
foreach my $prob (@$Problems) { |
foreach my $prob (@$Problems) { |
foreach my $partid (@{$prob->parts}) { |
foreach my $partid (@{$prob->parts}) { |
my @Response = $prob->responseIds($partid); |
my @Response = $prob->responseIds($partid); |
my @ResponseType = $prob->responseType($partid); |
my @ResponseType = $prob->responseType($partid); |
for (my $i=0;$i<=$#Response;$i++) { |
for (my $i=0;$i<=$#Response;$i++) { |
|
my $response_start_col = $last_student_col + |
|
$response_count * $response_multiplier + 1; |
|
$response_count++; |
my $respid = $Response[$i]; |
my $respid = $Response[$i]; |
my $resptype = $ResponseType[$i]; |
my $resptype = $ResponseType[$i]; |
my $results = |
my $results = |
&Apache::loncoursedata::get_response_data_by_student |
&Apache::loncoursedata::get_response_data_by_student |
($student,$prob->symb(),$respid); |
($student,$prob->symb(),$respid); |
my $final_response = $results->[-1]; |
if (! defined($results)) { |
my $submission = |
$results = []; |
$final_response->[ |
} |
&Apache::loncoursedata::RDs_submission() |
# |
]; |
$rows_output = $student_row; |
$submission=&excel_format_response($submission,$resptype); |
# |
$worksheet->write($rows_output,$cols_output++, |
for (my $j=scalar(@$results)-1;$j>=0;$j--) { |
$submission); |
$cols_output = $response_start_col; |
|
my $response = $results->[$j]; |
|
if ($ENV{'form.all_sub'} ne 'true') { |
|
next if ($j ne scalar(@$results)-1); |
|
} |
|
my $cols_output = &write_excel_row |
|
($worksheet, |
|
$rows_output++,$cols_output, |
|
$response,$student, |
|
$prob,$partid,$respid, |
|
$format,$resptype); |
|
if ($rows_output > $max_row) { |
|
$max_row = $rows_output; |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 289 sub new_excel_output {
|
Line 326 sub new_excel_output {
|
return; |
return; |
} |
} |
|
|
|
sub write_excel_row { |
|
my ($worksheet,$row,$col,$response,$student,$prob,$partid,$respid, |
|
$format,$resptype) = @_; |
|
# |
|
my $submission =$response->[&Apache::loncoursedata::RDs_submission()]; |
|
$submission = &excel_format_response($submission,$resptype); |
|
$worksheet->write($row,$col++,$submission); |
|
if ($ENV{'form.correctans'} eq 'true') { |
|
my $correct = &Apache::lonstathelpers::analyze_problem_as_student |
|
($prob,$student->{'username'},$student->{'domain'}, |
|
$partid,$respid); |
|
$correct =&excel_format_response($correct,$resptype); |
|
$worksheet->write($row,$col++,$correct); |
|
} |
|
if ($ENV{'form.prob_status'} eq 'true') { |
|
$worksheet->write |
|
($row,$col++, |
|
$response->[&Apache::loncoursedata::RDs_awarddetail()]); |
|
$worksheet->write |
|
($row,$col++,$response->[&Apache::loncoursedata::RDs_tries()]); |
|
$worksheet->write |
|
($row,$col++, |
|
&Apache::lonstathelpers::calc_serial |
|
($response->[&Apache::loncoursedata::RDs_timestamp()]), |
|
$format->{'date'}); |
|
$worksheet->write |
|
($row,$col++,$response->[&Apache::loncoursedata::RDs_awarded()]); |
|
} |
|
return $col; |
|
} |
|
|
sub get_title { |
sub get_title { |
my ($title,$src) = @_; |
my ($title,$src) = @_; |
if ($title eq '') { |
if ($title eq '') { |
Line 303 sub excel_format_response {
|
Line 371 sub excel_format_response {
|
my ($answer,$responsetype) = @_; |
my ($answer,$responsetype) = @_; |
if ($responsetype eq 'radiobutton') { |
if ($responsetype eq 'radiobutton') { |
$answer =~ s/=([^=])$//; |
$answer =~ s/=([^=])$//; |
} elsif ($responsetype eq 'option') { |
} elsif ($responsetype =~ /^(option|match)$/) { |
$answer = join("\n", |
$answer = join("\n", |
map { |
map { |
&Apache::lonnet::unescape($_) ; |
&Apache::lonnet::unescape($_) ; |
Line 316 sub excel_format_response {
|
Line 384 sub excel_format_response {
|
return $answer; |
return $answer; |
} |
} |
|
|
|
## |
=pod |
## Currently not used |
|
sub get_problem_data { |
|
my ($r,$Problems) = @_; |
|
# |
|
# Analyze |
|
my %Data; |
|
if (scalar(@$Problems) > 5) { |
|
# progress window |
|
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin |
|
($r,'Problem Analysis Status', |
|
'Problem Analysis Progress', |
|
scalar(@$Problems), |
|
'inline',undef,'Statistics','stats_status'); |
|
foreach my $problem (@$Problems) { |
|
$Data{$problem->symb} = |
|
{&Apache::lonstathelpers::get_problem_data |
|
($problem->src)}; |
|
&Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state, |
|
'last problem'); |
|
} |
|
&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); |
|
} else { |
|
foreach my $problem (@$Problems) { |
|
$Data{$problem->symb} = |
|
{&Apache::lonstathelpers::get_problem_data |
|
($problem->src)}; |
|
} |
|
} |
|
return \%Data; |
|
} |
|
|
|
|
|
=pod |
|
|
######################################################### |
######################################################### |
######################################################### |
######################################################### |
Line 841 sub prepare_excel_output {
|
Line 924 sub prepare_excel_output {
|
$r->rflush(); |
$r->rflush(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my @ColumnLabels; |
my @ColumnLabels; |
my @Columns = @DefaultColumns; |
my @Columns = @DefaultColumns; |
my %seen; |
my %seen; |
Line 1020 sub prepare_excel_output {
|
Line 1095 sub prepare_excel_output {
|
sub CreateInterface { |
sub CreateInterface { |
## |
## |
## Output Selection |
## Output Selection |
my $OutputSelector = $/.'<select name="output">'.$/; |
my $output_selector = $/.'<select name="output">'.$/; |
foreach ('HTML','Excel','CSV') { |
foreach ('HTML','Excel','CSV') { |
$OutputSelector .= ' <option value="'.lc($_).'"'; |
$output_selector .= ' <option value="'.lc($_).'"'; |
if ($ENV{'form.output'} eq lc($_)) { |
if ($ENV{'form.output'} eq lc($_)) { |
$OutputSelector .= ' selected '; |
$output_selector .= ' selected '; |
} |
} |
$OutputSelector .='>'.&mt($_).'</option>'.$/; |
$output_selector .='>'.&mt($_).'</option>'.$/; |
} |
} |
$OutputSelector .= '</select>'.$/; |
$output_selector .= '</select>'.$/; |
## |
## |
## Environment variable initialization |
## Environment variable initialization |
my $Str = ''; |
my $Str = ''; |
Line 1064 sub CreateInterface {
|
Line 1139 sub CreateInterface {
|
} |
} |
$ans_checkbox .= 'value="true" />'; |
$ans_checkbox .= 'value="true" />'; |
# |
# |
# Only show last submission checkbox |
# Show all submissions checkbox |
my $last_sub_checkbox = '<input type="checkbox" name="last_sub_only" '; |
my $all_sub_checkbox = '<input type="checkbox" name="all_sub" '; |
if (exists($ENV{'form.last_sub_only'}) && |
if (exists($ENV{'form.all_sub'}) && |
$ENV{'form.last_sub_only'} eq 'true') { |
$ENV{'form.all_sub'} eq 'true') { |
$last_sub_checkbox .= 'checked '; |
$all_sub_checkbox .= 'checked '; |
|
} |
|
$all_sub_checkbox.= 'value="true" />'; |
|
# |
|
# problem status checkbox |
|
my $prob_status_checkbox = '<input type="checkbox" name="prob_status" '; |
|
if (exists($ENV{'form.prob_status'}) && |
|
$ENV{'form.prob_status'} eq 'true') { |
|
$prob_status_checkbox .= 'checked '; |
} |
} |
$last_sub_checkbox.= 'value="true" />'; |
$prob_status_checkbox .= 'value="true" />'; |
# |
|
# Concise view checkbox |
|
my $concise_view_checkbox = '<input type="checkbox" name="concise" '; |
|
if (exists($ENV{'form.concise'}) && $ENV{'form.concise'} eq 'true') { |
|
$concise_view_checkbox .= 'checked '; |
|
} |
|
$concise_view_checkbox .= 'value="true" />'; |
|
# |
# |
$Str .= '<td align="right" halign="top">'. |
$Str .= '<td align="right" halign="top">'. |
# '<b>'.&mt('Output Format: [_1]',$OutputSelector).'</b><br />'.$/. |
|
'<label><b>'. |
'<label><b>'. |
&mt('show problem [_1]',$prob_checkbox).'</b></label><br />'. |
&mt('Show problem [_1]',$prob_checkbox).'</b></label><br />'. |
|
'<label><b>'. |
|
&mt('Show correct answers [_1]',$ans_checkbox).'</b></label><br />'. |
|
'<label><b>'. |
|
&mt('Show all submissions [_1]',$all_sub_checkbox). |
|
'</b></label><br />'. |
'<label><b>'. |
'<label><b>'. |
&mt('compute correct answers [_1]',$ans_checkbox).'</b></label><br />'. |
&mt('Show problem grading [_1]',$prob_status_checkbox). |
# '<label><b>'. |
'</b></label><br />'. |
# &mt('final answer only [_1]',$last_sub_checkbox).'</b></label><br />'. |
|
# '<label><b>'. |
|
# &mt('concise view [_1]',$concise_view_checkbox).'</b></label><br />'. |
|
'</td>'; |
'</td>'; |
# |
# |
$Str .= '</tr>'."\n"; |
$Str .= '</tr>'."\n"; |