version 1.69, 2004/02/18 17:33:12
|
version 1.70, 2004/02/18 19:16:55
|
Line 191 sub BuildProblemAnalysisPage {
|
Line 191 sub BuildProblemAnalysisPage {
|
######################################################### |
######################################################### |
sub prepare_excel_output { |
sub prepare_excel_output { |
my ($r,$problem,$ProblemData,$Students) = @_; |
my ($r,$problem,$ProblemData,$Students) = @_; |
my ($resource,$respid) = ($problem->{'resource'}, |
my ($resource,$respid,$partid) = ($problem->{'resource'}, |
$problem->{'respid'}); |
$problem->{'respid'}, |
|
$problem->{'part'}); |
$r->print('<h2>'. |
$r->print('<h2>'. |
&mt('Preparing Excel spreadsheet of student responses'). |
&mt('Preparing Excel spreadsheet of student responses'). |
'</h2>'); |
'</h2>'); |
Line 200 sub prepare_excel_output {
|
Line 201 sub prepare_excel_output {
|
&GetStudentAnswers($r,$problem,$Students); |
&GetStudentAnswers($r,$problem,$Students); |
# |
# |
my @Columns = ( 'username','domain','attempt','time', |
my @Columns = ( 'username','domain','attempt','time', |
'submission','correct', 'grading'); |
'submission','correct', 'grading','awarded','weight', |
|
'score'); |
|
my $awarded_col = 7; |
|
my $weight_col = 8; |
# |
# |
# Create excel worksheet |
# Create excel worksheet |
my $filename = '/prtspool/'. |
my $filename = '/prtspool/'. |
Line 221 sub prepare_excel_output {
|
Line 225 sub prepare_excel_output {
|
my $format = &Apache::loncommon::define_excel_formats($workbook); |
my $format = &Apache::loncommon::define_excel_formats($workbook); |
my $worksheet = $workbook->addworksheet('Student Submission Data'); |
my $worksheet = $workbook->addworksheet('Student Submission Data'); |
# |
# |
|
# Make sure we get new weight data instead of data on a 10 minute delay |
|
&Apache::lonnet::clear_EXT_cache_status(); |
|
# |
# Put on the standard headers and whatnot |
# Put on the standard headers and whatnot |
my $rows_output=0; |
my $rows_output=0; |
$worksheet->write($rows_output++,0,$resource->{'title'},$format->{'h1'}); |
$worksheet->write($rows_output++,0,$resource->{'title'},$format->{'h1'}); |
Line 230 sub prepare_excel_output {
|
Line 237 sub prepare_excel_output {
|
# |
# |
# Populate the worksheet with the student data |
# Populate the worksheet with the student data |
foreach my $student (@$Students) { |
foreach my $student (@$Students) { |
# For each attempt |
|
# write the username, domain, attempt number, timestamp, |
|
# submission, correct answer, grading |
|
my $results = &Apache::loncoursedata::get_response_data_by_student |
my $results = &Apache::loncoursedata::get_response_data_by_student |
($student,$resource->{'symb'},$respid); |
($student,$resource->{'symb'},$respid); |
|
my %row; |
|
$row{'username'} = $student->{'username'}; |
|
$row{'domain'} = $student->{'domain'}; |
|
$row{'correct'} = $student->{'answer'}; |
|
$row{'weight'} = &Apache::lonnet::EXT |
|
('resource.'.$partid.'.weight',$resource->{'symb'}, |
|
undef,undef,undef); |
if (! defined($results) || ref($results) ne 'ARRAY') { |
if (! defined($results) || ref($results) ne 'ARRAY') { |
my %row; |
$row{'score'} = '='. |
$row{'username'} = $student->{'username'}; |
&Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell |
$row{'domain'} = $student->{'domain'}; |
($rows_output,$awarded_col) |
$row{'correct'} = $student->{'answer'}; |
.'*'. |
|
&Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell |
|
($rows_output,$weight_col); |
my $cols_output = 0; |
my $cols_output = 0; |
foreach my $col (@Columns) { |
foreach my $col (@Columns) { |
if (! exists($row{$col})) { |
if (! exists($row{$col})) { |
Line 251 sub prepare_excel_output {
|
Line 264 sub prepare_excel_output {
|
$rows_output++; |
$rows_output++; |
} else { |
} else { |
foreach my $response (@$results) { |
foreach my $response (@$results) { |
|
delete($row{'time'}); |
|
delete($row{'attempt'}); |
|
delete($row{'submission'}); |
|
delete($row{'awarded'}); |
|
delete($row{'grading'}); |
|
delete($row{'score'}); |
my %row_format; |
my %row_format; |
my %row; |
|
# |
# |
# Time is handled differently |
# Time is handled differently |
$row{'time'} = &calc_serial( |
$row{'time'} = &calc_serial( |
$response->[&Apache::loncoursedata::RDs_timestamp()]); |
$response->[&Apache::loncoursedata::RDs_timestamp()]); |
$row_format{'time'}=$format->{'date'}; |
$row_format{'time'}=$format->{'date'}; |
# |
# |
$row{'username'} = $student->{'username'}; |
|
$row{'domain'} = $student->{'domain'}; |
|
$row{'attempt'} = $response->[ |
$row{'attempt'} = $response->[ |
&Apache::loncoursedata::RDs_tries()]; |
&Apache::loncoursedata::RDs_tries()]; |
$row{'submission'} = $response->[ |
$row{'submission'} = $response->[ |
&Apache::loncoursedata::RDs_submission()]; |
&Apache::loncoursedata::RDs_submission()]; |
$row{'correct'} = $student->{'answer'}; |
|
$row{'grading'} = $response->[ |
$row{'grading'} = $response->[ |
&Apache::loncoursedata::RDs_awarddetail()]; |
&Apache::loncoursedata::RDs_awarddetail()]; |
|
$row{'awarded'} = $response->[ |
|
&Apache::loncoursedata::RDs_awarded()]; |
|
$row{'score'} = '='. |
|
&Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell |
|
($rows_output,$awarded_col) |
|
.'*'. |
|
&Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell |
|
($rows_output,$weight_col); |
my $cols_output = 0; |
my $cols_output = 0; |
foreach my $col (@Columns) { |
foreach my $col (@Columns) { |
$worksheet->write($rows_output,$cols_output++,$row{$col}, |
$worksheet->write($rows_output,$cols_output++,$row{$col}, |