version 1.18, 2004/09/15 21:08:50
|
version 1.19, 2004/09/16 21:54:22
|
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 $multiplier = 1; |
|
$multiplier ++ if ($ENV{'form.correctans'} eq 'true'); |
|
foreach my $prob (@$Problems) { |
|
$columncount += ($multiplier * $prob->countResponses); |
|
last if ($columncount > 255); |
|
} |
|
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>'.$/); |
|
$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 215 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 232 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++; |
|
} |
} |
} |
} |
} |
} |
} |
Line 265 sub new_excel_output {
|
Line 270 sub new_excel_output {
|
$submission=&excel_format_response($submission,$resptype); |
$submission=&excel_format_response($submission,$resptype); |
$worksheet->write($rows_output,$cols_output++, |
$worksheet->write($rows_output,$cols_output++, |
$submission); |
$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($rows_output,$cols_output++, |
|
$correct); |
|
} |
} |
} |
} |
} |
} |
} |
Line 303 sub excel_format_response {
|
Line 317 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 330 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 1020 sub prepare_excel_output {
|
Line 1049 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 1093 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 '; |
} |
} |
$last_sub_checkbox.= 'value="true" />'; |
$all_sub_checkbox.= 'value="true" />'; |
# |
# |
# Concise view checkbox |
# Concise view checkbox |
my $concise_view_checkbox = '<input type="checkbox" name="concise" '; |
my $concise_view_checkbox = '<input type="checkbox" name="concise" '; |
Line 1080 sub CreateInterface {
|
Line 1109 sub CreateInterface {
|
$concise_view_checkbox .= 'value="true" />'; |
$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 />'.$/. |
# '<b>'.&mt('Output Format: [_1]',$output_selector).'</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>'. |
'<label><b>'. |
&mt('compute correct answers [_1]',$ans_checkbox).'</b></label><br />'. |
&mt('compute correct answers [_1]',$ans_checkbox).'</b></label><br />'. |
# '<label><b>'. |
# '<label><b>'. |
# &mt('final answer only [_1]',$last_sub_checkbox).'</b></label><br />'. |
# &mt('All submission [_1]',$all_sub_checkbox).'</b></label><br />'. |
# '<label><b>'. |
# '<label><b>'. |
# &mt('concise view [_1]',$concise_view_checkbox).'</b></label><br />'. |
# &mt('concise view [_1]',$concise_view_checkbox).'</b></label><br />'. |
'</td>'; |
'</td>'; |