Annotation of loncom/interface/statistics/lonstudentsubmissions.pm, revision 1.59
1.1 matthew 1: # The LearningOnline Network with CAPA
2: #
1.59 ! bisitz 3: # $Id: lonstudentsubmissions.pm,v 1.58 2010/04/12 16:19:34 bisitz Exp $
1.1 matthew 4: #
5: # Copyright Michigan State University Board of Trustees
6: #
7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
8: #
9: # LON-CAPA is free software; you can redistribute it and/or modify
10: # it under the terms of the GNU General Public License as published by
11: # the Free Software Foundation; either version 2 of the License, or
12: # (at your option) any later version.
13: #
14: # LON-CAPA is distributed in the hope that it will be useful,
15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: # GNU General Public License for more details.
18: #
19: # You should have received a copy of the GNU General Public License
20: # along with LON-CAPA; if not, write to the Free Software
21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: #
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: package Apache::lonstudentsubmissions;
28:
29: use strict;
1.40 albertel 30: use Apache::lonnet;
1.1 matthew 31: use Apache::loncommon();
32: use Apache::lonhtmlcommon();
33: use Apache::loncoursedata();
34: use Apache::lonstatistics;
35: use Apache::lonlocal;
36: use Apache::lonstathelpers;
37: use HTML::Entities();
38: use Time::Local();
39: use Spreadsheet::WriteExcel();
1.45 www 40: use lib '/home/httpd/lib/perl/';
41: use LONCAPA;
42:
1.1 matthew 43:
1.18 matthew 44: my @SubmitButtons = ({ name => 'SelectAnother',
1.1 matthew 45: text => 'Choose a different Problem' },
46: { name => 'Generate',
1.16 matthew 47: text => 'Generate Report'},
1.1 matthew 48: );
49:
50: sub BuildStudentSubmissionsPage {
51: my ($r,$c)=@_;
52: #
53: my %Saveable_Parameters = ('Status' => 'scalar',
54: 'Section' => 'array',
55: 'NumPlots' => 'scalar',
56: );
57: &Apache::loncommon::store_course_settings('student_submissions',
58: \%Saveable_Parameters);
59: &Apache::loncommon::restore_course_settings('student_submissions',
60: \%Saveable_Parameters);
61: #
62: &Apache::lonstatistics::PrepareClasslist();
63: #
64: $r->print(&CreateInterface());
65: #
66: my @Students = @Apache::lonstatistics::Students;
67: #
68: if (@Students < 1) {
1.50 bisitz 69: $r->print('<div class="LC_warning">'
70: .&mt('There are no students in the sections selected.')
71: .'</div>');
1.1 matthew 72: }
73: #
1.11 matthew 74: my @CacheButtonHTML =
1.19 matthew 75: &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status',
1.50 bisitz 76: '<div class="LC_info">'.&mt('Loading student data...').'</div>');
1.1 matthew 77: $r->rflush();
78: #
1.40 albertel 79: if (exists($env{'form.problemchoice'}) &&
80: ! exists($env{'form.SelectAnother'})) {
1.1 matthew 81: foreach my $button (@SubmitButtons) {
82: if ($button->{'name'} eq 'break') {
83: $r->print("<br />\n");
84: } else {
85: $r->print('<input type="submit" name="'.$button->{'name'}.'" '.
86: 'value="'.&mt($button->{'text'}).'" />');
87: $r->print(' 'x5);
88: }
89: }
1.11 matthew 90: foreach my $html (@CacheButtonHTML) {
91: $r->print($html.(' 'x5));
92: }
1.1 matthew 93: #
1.18 matthew 94: $r->print('<hr />'.$/);
1.1 matthew 95: $r->rflush();
96: #
1.18 matthew 97: # Determine which problems we are to analyze
98: my @Symbs =
99: &Apache::lonstathelpers::get_selected_symbs('problemchoice');
100: foreach my $selected (@Symbs) {
101: $r->print('<input type="hidden" name="problemchoice" value="'.
102: $selected.'" />'.$/);
103: }
1.1 matthew 104: #
1.18 matthew 105: # Get resource objects
106: my $navmap = Apache::lonnavmaps::navmap->new();
107: if (!defined($navmap)) {
1.50 bisitz 108: $r->print('<div class="LC_error">'.&mt("Internal error").'</div>');
1.18 matthew 109: return;
110: }
111: my %already_seen;
112: my @Problems;
113: foreach my $symb (@Symbs) {
114: my $resource = $navmap->getBySymb($symb);
115: push(@Problems,$resource);
1.1 matthew 116: }
1.25 matthew 117: #
1.37 matthew 118: $r->print('<h4>'.
119: &Apache::lonstatistics::section_and_enrollment_description().
120: '</h4>');
1.18 matthew 121: if (! scalar(@Problems) || ! defined($Problems[0])) {
1.1 matthew 122: $r->print('resource is undefined');
123: } else {
1.18 matthew 124: if (scalar(@Problems) == 1) {
125: my $resource = $Problems[0];
126: $r->print('<h1>'.$resource->title.'</h1>');
127: $r->print('<h3>'.$resource->src.'</h3>');
1.40 albertel 128: if ($env{'form.renderprob'} eq 'true') {
1.36 matthew 129: $r->print(&Apache::lonstathelpers::render_resource($resource));
1.18 matthew 130: $r->rflush();
131: }
132: }
1.40 albertel 133: if ($env{'form.output'} eq 'excel') {
1.21 matthew 134: &prepare_excel_output($r,\@Problems,\@Students);
1.40 albertel 135: } elsif ($env{'form.output'} eq 'csv') {
1.22 matthew 136: &prepare_csv_output($r,\@Problems,\@Students);
1.21 matthew 137: } else {
138: &prepare_html_output($r,\@Problems,\@Students);
139: }
1.1 matthew 140: }
141: $r->print('<hr />');
142: } else {
143: $r->print('<input type="submit" name="Generate" value="'.
1.17 matthew 144: &mt('Prepare Report').'" />');
1.1 matthew 145: $r->print(' 'x5);
1.19 matthew 146: $r->print('<p>'.
147: &mt('Computing correct answers greatly increasese the amount of time required to prepare a report.').
148: '</p>');
149: $r->print('<p>'.
1.50 bisitz 150: &mt('Please select problems and use the [_1]Prepare Report[_2] button to continue.','<b>','</b>').
1.19 matthew 151: '</p>');
1.18 matthew 152: $r->print(&Apache::lonstathelpers::MultipleProblemSelector
1.19 matthew 153: (undef,'problemchoice','Statistics'));
1.18 matthew 154: }
155: }
156:
1.30 matthew 157: ##
1.31 matthew 158: ## get_extra_response_headers
159: ##
160: sub get_extra_response_headers {
161: my @extra_resp_headers;
1.40 albertel 162: if ($env{'form.correctans'} eq 'true') {
1.31 matthew 163: push(@extra_resp_headers,'Correct');
164: }
1.40 albertel 165: if ($env{'form.prob_status'} eq 'true') {
1.31 matthew 166: push(@extra_resp_headers,'Award Detail');
167: push(@extra_resp_headers,'Time');
168: push(@extra_resp_headers,'Attempt');
169: push(@extra_resp_headers,'Awarded');
170: }
171: return @extra_resp_headers;
172: }
173:
174: ##
1.30 matthew 175: ## get_headers:
176: ## return the proper headers for the given response
177: sub get_headers {
178: my ($prob,$partid,$respid,$resptype,$analysis,$output,$purpose,
179: @basic_headers) = @_;
180: my @headers;
181: if ($resptype eq 'essay' && $purpose eq 'display' &&
182: ($output eq 'html')) {# || scalar(@{$prob->parts})!=1)) {
183: @headers = ();
184: } elsif ($resptype =~ /^(option|match|rank)$/) {
185: my $prefix = '_';
186: if ($purpose eq 'display') {
187: $prefix = '';
188: }
189: my @foils =
190: map {
191: $prefix.$_;
192: } sort(keys(%{$analysis->{$partid.'.'.$respid}->{'_Foils'}}));
193: if (scalar(@basic_headers) && $basic_headers[0] eq 'Correct') {
194: @foils = map { ($_ , $_.' Correct') } @foils;
195: shift(@basic_headers); # Get rid of 'Correct'
196: }
197: @headers = (@foils,@basic_headers);
1.42 albertel 198: } elsif (lc($resptype) eq 'task') {
199: @headers = ('Grader','Status',@basic_headers,'Submission');
1.30 matthew 200: } else {
201: @headers = ('Submission',@basic_headers);
202: }
203: return @headers;
204: }
205:
1.18 matthew 206: #########################################################
207: #########################################################
1.21 matthew 208: ##
209: ## HTML Output Routines
210: ##
211: #########################################################
212: #########################################################
213: sub prepare_html_output {
214: my ($r,$problems,$students) = @_;
215: my $c = $r->connection();
216: #
217: # Set a flag for the case when there is just one problem
218: my $single_response = 0;
219: if (scalar(@$problems) == 1 &&
220: $problems->[0]->countResponses == 1) {
221: $single_response = 1;
222: }
223: #
224: # Compute the number of columns per response
1.31 matthew 225: my @extra_resp_headers = &get_extra_response_headers();
1.21 matthew 226: #
227: # Create the table header
1.57 onken 228: my @student_columns = @Apache::lonstatistics::SelectedStudentData;
229: foreach (@student_columns) {
230: if($_ eq 'all') {
231: @student_columns = ('fullname','username','domain','id','section','status','groups','comments');
232: }
233: }
1.21 matthew 234: #
235: my %headers;
236: my $student_column_count = scalar(@student_columns);
237: $headers{'problem'} = qq{<th colspan="$student_column_count">\ </th>};
238: foreach (@student_columns) {
239: $headers{'student'}.= '<th>'.ucfirst($_).'</th>';
240: }
241: #
242: # we put the headers into the %headers hash
243: my $total_col = scalar(@student_columns);
244: my $nonempty_part_headers = 0;
1.30 matthew 245: #
246: my %problem_analysis;
1.21 matthew 247: foreach my $prob (@$problems) {
1.31 matthew 248: my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);
1.30 matthew 249: $problem_analysis{$prob->src}=\%analysis;
250: #
1.21 matthew 251: my $prob_span = 0;
252: my $single_part = 0;
253: if (scalar(@{$prob->parts}) == 1) {
254: $single_part = 1;
255: }
256: foreach my $partid (@{$prob->parts}) {
257: my $part_span = 0;
258: my $responses = [$prob->responseIds($partid)];
259: my $resptypes = [$prob->responseType($partid)];
260: for (my $i=0;$i<scalar(@$responses);$i++) {
1.30 matthew 261: my $respid = $responses->[$i];
262: my @headers = &get_headers($prob,$partid,$respid,
263: $resptypes->[$i],
264: $problem_analysis{$prob->src},
265: 'html','display',
266: @extra_resp_headers);
267: if (scalar(@headers)>0) {
268: $total_col += scalar(@headers);
269: $part_span += scalar(@headers);
1.21 matthew 270: $headers{'response'} .=
1.30 matthew 271: '<th colspan="'.scalar(@headers).'">'.
1.21 matthew 272: &mt('Response [_1]',$responses->[$i]).'</th>';
1.52 raeburn 273: $headers{'student'}.= '<th><span class="LC_nobreak">'.
274: join('</span></th><th><span class="LC_nobreak">',
1.30 matthew 275: @headers).
1.51 bisitz 276: '</span></th>';
1.21 matthew 277: }
278: }
1.41 matthew 279: if ($part_span == 0) {
280: next;
281: }
1.21 matthew 282: if (! $single_part) {
283: my $tmpname = $partid;
284: if ($partid =~/^\d+$/) {
1.24 matthew 285: $tmpname = $prob->part_display($partid);
1.21 matthew 286: }
1.35 matthew 287: if ($tmpname !~ /^part/) {
288: $tmpname = 'Part '.$tmpname;
289: }
1.21 matthew 290: $headers{'part'} .= qq{<th colspan="$part_span">$tmpname</th>};
291: $nonempty_part_headers = 1;
292: } else {
1.53 bisitz 293: $headers{'part'} .= qq{<th colspan="$part_span"> </th>};
1.21 matthew 294: }
295: $prob_span += $part_span;
296: }
1.23 matthew 297: my $title = $prob->compTitle;
1.21 matthew 298: if ($prob_span > 0) {
299: $headers{'problem'}.= qq{<th colspan="$prob_span">$title</th>};
300: } elsif ($single_response) {
301: $prob_span = scalar(@student_columns);
302: $headers{'problem'} = qq{<th colspan="$prob_span">$title</th>};
303: }
304: }
305: if (exists($headers{'part'})) {
306: $headers{'part'} = qq{<th colspan="$student_column_count">\ </th>}.
307: $headers{'part'};
308: }
309: if (exists($headers{'response'})) {
310: $headers{'response'}=
311: qq{<th colspan="$student_column_count">\ </th>}.
312: $headers{'response'};
313: }
314: my $full_header = $/.'<table>'.$/;
315: $full_header .= '<tr align="left">'.$headers{'problem'}.'</tr>'.$/;
316: if ($nonempty_part_headers) {
317: $full_header .= '<tr align="left">'.$headers{'part'}.'</tr>'.$/;
318: }
319: $full_header .= '<tr align="left">'.$headers{'response'}.'</tr>'.$/;
320: $full_header .= '<tr align="left">'.$headers{'student'}.'</tr>'.$/;
321: #
322: # Main loop
323: my $count;
324: $r->print($/.$full_header.$/);
325: my $row_class = 'odd'; # css
326: foreach my $student (@$students) {
327: my $student_row_data;
328: if ($count++ >= 30) {
329: $r->print('</table>'.$/.$full_header.$/);
330: $count = 0;
331: }
332: last if ($c->aborted());
333: foreach my $field (@student_columns) {
1.58 bisitz 334: $student_row_data .= '<td valign="top">';
1.57 onken 335: # handle comments like in lonstudentassessment.pm
336: if($field eq 'comments') {
337: $student_row_data .=
338: '<a href="/adm/'.$student->{'domain'}.'/'.
339: $student->{'username'}.'/'.'aboutme#coursecomment">'.&mt('Comments').'</a>';
340: } else {
341: $student_row_data .= $student->{$field};
342: }
343: $student_row_data .= '</td>';
1.21 matthew 344: }
345: #
346: # Figure out what it is we need to output for this student
347: my @essays;
1.30 matthew 348: my %prob_data;
1.21 matthew 349: my $maxrow;
350: foreach my $prob (@$problems) {
1.30 matthew 351: $prob_data{$prob->symb}={};
1.21 matthew 352: foreach my $partid (@{$prob->parts}) {
353: my @responses = $prob->responseIds($partid);
354: my @response_type = $prob->responseType($partid);
355: for (my $i=0;$i<=$#responses;$i++) {
1.30 matthew 356: my $respid = $responses[$i];
1.21 matthew 357: my $results =
358: &Apache::loncoursedata::get_response_data_by_student
359: ($student,$prob->symb(),$respid);
1.30 matthew 360: my $resptype = $response_type[$i];
361: my @headers = &get_headers($prob,$partid,$respid,
362: $resptype,
363: $problem_analysis{$prob->src},
364: 'html','normal',
365: @extra_resp_headers);
366: my $width = scalar(@headers);
1.41 matthew 367: next if ($width < 1);
1.30 matthew 368: my $resp_data;
1.41 matthew 369: $resp_data->{'fake'} = qq{<td colspan="$width"> </td>};
1.21 matthew 370: if (! defined($results)) {
371: $results = [];
372: }
1.30 matthew 373: #
1.21 matthew 374: if (scalar(@$results) > $maxrow && $resptype ne 'essay') {
375: $maxrow = scalar(@$results);
376: }
377: for (my $j=scalar(@$results)-1;$j>=0;$j--) {
1.40 albertel 378: if ($env{'form.all_sub'} ne 'true') {
1.21 matthew 379: next if ($j ne scalar(@$results)-1);
380: }
1.30 matthew 381: my $response = &hashify_response($results->[$j],
382: $prob,
383: $student,
384: $partid,
385: $respid);
1.21 matthew 386: if ($resptype eq 'essay') {
387: push(@essays,
1.30 matthew 388: &html_essay_results(\@headers,
1.21 matthew 389: $prob,$partid,$respid,
390: $response,
391: $single_response).
392: '</td>');
1.42 albertel 393: } elsif (lc($resptype) eq 'task') {
394: my $results =
395: &html_task_results(\@headers,
396: $prob,$partid,$respid,
397: $response,$resptype);
398: if ($results) {
399: push(@{$resp_data->{'real'}},$results);
400: }
1.21 matthew 401: } else {
402: push(@{$resp_data->{'real'}},
1.30 matthew 403: &html_non_essay_results(\@headers,
404: $prob,$partid,$respid,
405: $response,$resptype));
1.21 matthew 406: }
1.30 matthew 407: }
408: $prob_data{$prob->symb}->{$partid}->{$respid}=$resp_data;
1.21 matthew 409: } # end of $i loop
410: } # end of partid loop
411: } # end of prob loop
412: #
413: # if there is no data, skip this student.
414: next if (! $maxrow && ! scalar(@essays));
415: #
416: # Go through the problem data and output a row.
417: if ($row_class eq 'even') {
418: $row_class = 'odd';
419: } else {
420: $row_class = 'even';
421: }
422: my $printed_something;
423: for (my $rows_output = 0;$rows_output<$maxrow;$rows_output++) {
424: my $html;
425: my $no_data = 1;
426: foreach my $prob (@$problems) {
427: foreach my $partid (@{$prob->parts}) {
428: my @responses = $prob->responseIds($partid);
429: my @response_type = $prob->responseType($partid);
430: for (my $i=0;$i<=$#responses;$i++) {
431: my $respid = $responses[$i];
432: my $resp_data =
1.30 matthew 433: $prob_data{$prob->symb}->{$partid}->{$respid};
1.21 matthew 434: next if ($response_type[$i] eq 'essay');
435: if (defined($resp_data->{'real'}->[$rows_output])) {
436: $html .= $resp_data->{'real'}->[$rows_output];
437: $no_data = 0;
438: } else {
439: $html .= $resp_data->{'fake'};
440: }
441: }
442: }
443: }
444: if (! $no_data) {
445: $r->print(qq{<tr class="$row_class">$student_row_data$html</tr>}.$/);
446: $printed_something=1;
447: }
448: }
449: if (@essays) {
450: my $tr = qq{<tr class="$row_class">};
451: my $td = qq{<td valign="top" class="essay" colspan="$total_col">};
452: if (! $printed_something) {
453: $r->print($tr.$student_row_data.'</tr>'.$/);
454: }
455: $r->print($tr.$td.
456: join('</td></tr>'.$/.$tr.$td,@essays).'</td></tr>'.$/);
457: undef(@essays);
458: }
459: } # end of student loop
1.58 bisitz 460: $r->print('</table>'.$/);
1.21 matthew 461: return;
462: }
463:
1.30 matthew 464: sub hashify_response {
465: my ($response,$prob,$student,$partid,$respid) =@_;
466: my $resp_hash = {};
1.40 albertel 467: if ($env{'form.correctans'} eq 'true') {
1.30 matthew 468: $resp_hash->{'Correct'} =
469: &Apache::lonstathelpers::get_student_answer
470: ($prob,$student->{'username'},$student->{'domain'},
471: $partid,$respid);
472: }
473: $resp_hash->{'Submission'} =
474: $response->[&Apache::loncoursedata::RDs_submission()];
475: $resp_hash->{'Time'} =
476: $response->[&Apache::loncoursedata::RDs_timestamp()];
477: $resp_hash->{'Attempt'} =
478: $response->[&Apache::loncoursedata::RDs_tries()];
479: $resp_hash->{'Awarded'} =
480: $response->[&Apache::loncoursedata::RDs_awarded()];
1.42 albertel 481: if ($prob->is_task()) {
482: $resp_hash->{'Grader'} =
483: $response->[&Apache::loncoursedata::RDs_response_eval_2()];
484: if ($resp_hash->{'Attempt'} eq '0') {
485: $resp_hash->{'Attempt'} = '';
486: }
487: $resp_hash->{'Award Detail'} =
488: $response->[&Apache::loncoursedata::RDs_part_award()];
489: $resp_hash->{'Status'} =
490: $response->[&Apache::loncoursedata::RDs_response_eval()];
491: } else {
492: $resp_hash->{'Award Detail'} =
493: $response->[&Apache::loncoursedata::RDs_awarddetail()];
494: }
495:
1.30 matthew 496: return $resp_hash;
497: }
498:
1.21 matthew 499: #####################################################
500: ##
501: ## HTML helper routines
502: ##
503: #####################################################
504: sub html_essay_results {
1.30 matthew 505: my ($headers,$prob,$partid,$respid,$response,$single_response)=@_;
506: if (! ref($headers) || ref($headers) ne 'ARRAY') {
507: return '';
1.21 matthew 508: }
1.30 matthew 509: # Start of telling them what problem, part, and response
1.21 matthew 510: my $Str;
511: if (! $single_response) {
1.23 matthew 512: my $id = $prob->compTitle;
1.21 matthew 513: if (defined($partid) && $partid ne '0') {
1.24 matthew 514: $id .= ' '.$prob->part_display($partid);
1.21 matthew 515: }
516: if (defined($respid)) {
517: $id .= ' '.$respid;
518: }
1.51 bisitz 519: $Str .= '<span class="LC_nobreak">'.$id.'</span>'.(' 'x4);
1.21 matthew 520: }
1.30 matthew 521: #
522: shift(@$headers); # Get rid of the Submission header
523: my $correct = '';
524: if ($headers->[0] eq 'Correct') {
525: $correct = &html_format_essay_sub($response->{'Correct'});
526: shift(@$headers);
527: }
1.51 bisitz 528: $Str .= '<span class="LC_nobreak">'.
1.30 matthew 529: join('',
530: map {
531: (' 'x4).&mt($_.': [_1]',$response->{$_});
1.51 bisitz 532: } @$headers).'</span>';
1.30 matthew 533: if (@$headers || ! $single_response) {
534: $Str .= '<br />';
1.21 matthew 535: }
1.30 matthew 536: $Str .= &html_format_essay_sub($response->{'Submission'});
537: #
1.21 matthew 538: if (defined($correct) && $correct !~ /^\s*$/) {
539: $Str .= '<hr /><b>'.&mt('Correct').'</b>'.$correct
540: }
541: return $Str;
542: }
543:
1.30 matthew 544: sub html_format_essay_sub {
545: my ($submission) = @_;
546: return '' if (! defined($submission) || $submission eq '');
547: $submission = &HTML::Entities::decode($submission);
548: $submission =~ s/\\\"/\"/g;
549: $submission =~ s/\\\'/\'/g;
550: $submission =~ s|\\r\\n|$/|g;
551: $submission = &HTML::Entities::encode($submission,'<>&"');
552: $submission =~ s|$/\s*$/|$/</p><p>$/|g;
553: $submission =~ s|\\||g;
554: $submission = '<p>'.$submission.'</p>';
555: return $submission;
1.21 matthew 556: }
557:
1.42 albertel 558: sub html_task_results {
559: my ($headers,$prob,$partid,$respid,$response,$resptype) = @_;
560: if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
561: return '';
562: }
563:
564: my @values;
565: @values = map { $response->{$_}; } @$headers;
566:
567: my $td = '<td valign="top">';
568: my $str = $td.join('</td>'.$td,@values).'</td>';
569: return $str;
570: }
571:
1.30 matthew 572: sub html_non_essay_results {
573: my ($headers,$prob,$partid,$respid,$response,$resptype) = @_;
574: if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
575: return '';
576: }
577: #
1.45 www 578: my $submission = &HTML::Entities::decode(&unescape($response->{'Submission'}));
1.21 matthew 579: return '' if (! defined($submission) || $submission eq '');
1.25 matthew 580: $submission =~ s/\\\"/\"/g;
581: $submission =~ s/\\\'/\'/g;
1.30 matthew 582: if ($resptype eq 'radiobutton') {
1.25 matthew 583: $submission = &HTML::Entities::encode($submission,'<>&"');
1.21 matthew 584: $submission =~ s/=([^=])$//;
1.51 bisitz 585: $submission = '<span class="LC_nobreak">'.$submission.'</span>';
1.30 matthew 586: }
587: $response->{'Submission'} = $submission;
588: #
589: my @values;
590: if ($resptype =~ /^(option|match|rank)$/) {
591: my %submission =
592: map {
1.45 www 593: my ($foil,$value) = split('=',&unescape($_));
1.30 matthew 594: ($foil,$value);
595: } split('&',$response->{'Submission'});
596: my %correct;
597: if (exists($response->{'Correct'})) {
598: %correct =
599: map {
1.45 www 600: my ($foil,$value)=split('=',&unescape($_));
1.30 matthew 601: ($foil,$value);
602: } split('&',$response->{'Correct'});
603: }
604: #
605: foreach my $original_header (@$headers) {
606: if ($original_header =~ /^_/) {
607: # '_' denotes a foil column
608: my ($header) = ($original_header =~ m/^_(.*)$/);
609: my $option = '';
610: if ( my ($foil) = ($header =~ /(.*) Correct$/)) {
611: if (exists($correct{$foil})) {
612: $option = $correct{$foil};
613: }
614: } elsif (exists($submission{$header})) {
615: $option = $submission{$header};
616: }
617: push(@values,&HTML::Entities::encode($option));
1.38 matthew 618: } elsif ($original_header eq 'Time') {
619: push(@values,&Apache::lonlocal::locallocaltime($response->{$original_header}));
1.30 matthew 620: } else {
621: # A normal column
622: push(@values,$response->{$original_header});
623: }
624: }
1.25 matthew 625: } else {
1.30 matthew 626: @values = map { $response->{$_}; } @$headers;
1.21 matthew 627: }
1.30 matthew 628: my $td = '<td valign="top">';
629: my $str = $td.join('</td>'.$td,@values).'</td>';
630: return $str;
1.21 matthew 631: }
1.18 matthew 632:
1.30 matthew 633:
1.21 matthew 634: #########################################################
635: #########################################################
636: ##
637: ## Excel Output Routines
638: ##
639: #########################################################
640: #########################################################
641: sub prepare_excel_output {
1.19 matthew 642: my ($r,$Problems,$Students) = @_;
1.18 matthew 643: my $c = $r->connection();
644: #
1.19 matthew 645: #
646: # Determine the number of columns in the spreadsheet
647: my $columncount = 3; # username, domain, id
1.31 matthew 648: my @extra_resp_headers = &get_extra_response_headers();
1.20 matthew 649: my $lastprob;
1.31 matthew 650: my %problem_analysis;
1.19 matthew 651: foreach my $prob (@$Problems) {
1.31 matthew 652: my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);
653: $problem_analysis{$prob->src}=\%analysis;
654: foreach my $partid (@{$prob->parts}) {
655: my $responses = [$prob->responseIds($partid)];
656: my $resptypes = [$prob->responseType($partid)];
657: for (my $i=0;$i<scalar(@$responses);$i++) {
658: my @headers = &get_headers($prob,$partid,$responses->[$i],
659: $resptypes->[$i],
660: $problem_analysis{$prob->src},
661: 'excel','display',
662: @extra_resp_headers);
663: $columncount += scalar(@headers);
664: }
665: }
1.19 matthew 666: last if ($columncount > 255);
1.20 matthew 667: $lastprob = $prob;
1.19 matthew 668: }
669: if ($columncount > 255) {
670: $r->print('<h1>'.&mt('Unable to complete request').'</h1>'.$/.
671: '<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>'.$/.
1.20 matthew 672: '<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>'.$/.
1.23 matthew 673: '<p>'.&mt('The last problem that will fit in the current spreadsheet is [_1].',$lastprob->compTitle).'</p>');
1.19 matthew 674: $r->rflush();
675: return;
676: }
677: #
678: # Print out a message telling them what we are doing
1.18 matthew 679: if (scalar(@$Problems) > 1) {
680: $r->print('<h2>'.
681: &mt('Preparing Excel spreadsheet of student responses to [_1] problems',
682: scalar(@$Problems)).
683: '</h2>');
684: } else {
685: $r->print('<h2>'.
686: &mt('Preparing Excel spreadsheet of student responses').
687: '</h2>');
688: }
689: $r->rflush();
690: #
691: # Create the excel spreadsheet
1.36 matthew 692: my ($workbook,$filename,$format) =
693: &Apache::loncommon::create_workbook($r);
694: return if (! defined($workbook));
1.18 matthew 695: my $worksheet = $workbook->addworksheet('Student Submission Data');
696: #
697: # Add headers to the worksheet
698: my $rows_output = 0;
699: $worksheet->write($rows_output++,0,
1.40 albertel 700: $env{'course.'.$env{'request.course.id'}.'.description'},
1.18 matthew 701: $format->{'h1'});
702: $rows_output++;
703: my $cols_output = 0;
704: my $title_row = $rows_output++;
705: my $partid_row = $rows_output++;
706: my $respid_row = $rows_output++;
707: my $header_row = $rows_output++;
708: $worksheet->write($title_row ,0,'Problem Title',$format->{'bold'});
709: $worksheet->write($partid_row,0,'Part ID',$format->{'bold'});
710: $worksheet->write($respid_row,0,'Response ID',$format->{'bold'});
711: # Student headers
1.38 matthew 712: my @StudentColumns = ('username','domain','id','section');
1.18 matthew 713: foreach (@StudentColumns) {
1.19 matthew 714: $worksheet->write($header_row,$cols_output++,ucfirst($_),
715: $format->{'bold'});
1.18 matthew 716: }
717: # Problem headers
1.31 matthew 718: my %start_col;
1.18 matthew 719: foreach my $prob (@$Problems) {
1.23 matthew 720: my $title = $prob->compTitle;
1.18 matthew 721: $worksheet->write($title_row,$cols_output,
722: $title,$format->{'h3'});
723: foreach my $partid (@{$prob->parts}) {
1.24 matthew 724: $worksheet->write($partid_row,$cols_output,
725: $prob->part_display($partid));
1.18 matthew 726: my $responses = [$prob->responseIds($partid)];
727: my $resptypes = [$prob->responseType($partid)];
728: for (my $i=0;$i<scalar(@$responses);$i++) {
1.31 matthew 729: $start_col{$prob->symb}->{$partid}->{$responses->[$i]}=
730: $cols_output;
1.18 matthew 731: $worksheet->write($respid_row,$cols_output,
732: $resptypes->[$i].', '.$responses->[$i]);
1.31 matthew 733: my @headers = &get_headers($prob,$partid,$responses->[$i],
734: $resptypes->[$i],
735: $problem_analysis{$prob->src},
736: 'excel','display',
737: @extra_resp_headers);
738: foreach my $text (@headers) {
739: if ($text eq 'Time') {
740: $worksheet->set_column($cols_output,$cols_output,undef,
741: $format->{'date'});
742: }
743: $worksheet->write($header_row,$cols_output++,$text);
1.20 matthew 744: }
1.18 matthew 745: }
746: }
747: }
748: #
749: # Populate the worksheet with the student data
750: my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
751: ($r,'Excel File Compilation Status',
752: 'Excel File Compilation Progress',
753: scalar(@$Students),'inline',undef,'Statistics','stats_status');
1.20 matthew 754: my $max_row = $rows_output;
1.18 matthew 755: foreach my $student (@$Students) {
756: last if ($c->aborted());
757: $cols_output = 0;
1.20 matthew 758: my $student_row = $max_row;
1.18 matthew 759: foreach my $field (@StudentColumns) {
1.20 matthew 760: $worksheet->write($student_row,$cols_output++,
1.18 matthew 761: $student->{$field});
762: }
1.20 matthew 763: my $last_student_col = $cols_output-1;
1.18 matthew 764: foreach my $prob (@$Problems) {
765: foreach my $partid (@{$prob->parts}) {
766: my @Response = $prob->responseIds($partid);
767: my @ResponseType = $prob->responseType($partid);
768: for (my $i=0;$i<=$#Response;$i++) {
769: my $respid = $Response[$i];
770: my $resptype = $ResponseType[$i];
771: my $results =
772: &Apache::loncoursedata::get_response_data_by_student
773: ($student,$prob->symb(),$respid);
1.31 matthew 774: my @headers = &get_headers($prob,$partid,$respid,
775: $resptype,
776: $problem_analysis{$prob->src},
777: 'excel','normal',
778: @extra_resp_headers);
779:
1.20 matthew 780: if (! defined($results)) {
781: $results = [];
782: }
783: #
784: $rows_output = $student_row;
785: #
1.31 matthew 786: my $response_start_col = $start_col{$prob->symb}->{$partid}->{$respid};
1.20 matthew 787: for (my $j=scalar(@$results)-1;$j>=0;$j--) {
788: $cols_output = $response_start_col;
1.40 albertel 789: if ($env{'form.all_sub'} ne 'true') {
1.20 matthew 790: next if ($j ne scalar(@$results)-1);
791: }
1.31 matthew 792: my $response = &hashify_response($results->[$j],
793: $prob,
794: $student,
795: $partid,
796: $respid);
797: my @response_data =
1.33 matthew 798: &compile_response_data(\@headers,$response,
799: $prob,$partid,$respid,
800: $resptype,
801: \&excel_format_item);
1.31 matthew 802: $worksheet->write_row($rows_output++,$cols_output,
803: \@response_data);
804: $cols_output+=scalar(@response_data);
1.20 matthew 805: if ($rows_output > $max_row) {
806: $max_row = $rows_output;
807: }
1.19 matthew 808: }
1.18 matthew 809: }
810: }
811: }
1.28 matthew 812: # Fill in the remaining rows with the students data
1.34 matthew 813: for (my $row = $student_row+1;$row<$max_row;$row++) {
1.28 matthew 814: my $cols = 0;
815: foreach my $field (@StudentColumns) {
816: $worksheet->write($row,$cols++,
817: $student->{$field});
818: }
819: }
1.18 matthew 820: &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
821: 'last student');
822: }
823: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
824: #
825: # Close the excel file
826: $workbook->close();
827: #
828: # Write a link to allow them to download it
829: $r->print('<p><a href="'.$filename.'">'.
830: &mt('Your Excel spreadsheet.').
831: '</a></p>'."\n");
832: $r->print('<script>'.
833: 'window.document.Statistics.stats_status.value="'.
834: 'Done compiling spreadsheet. See link below to download.'.
835: '";</script>');
836: $r->rflush();
837: return;
838: }
839:
1.33 matthew 840: sub compile_response_data {
841: my ($headers,$response,$prob,$partid,$respid,$resptype,$format) = @_;
1.31 matthew 842: if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
843: return ();
844: }
1.33 matthew 845: if (ref($format) ne 'CODE') {
846: $format = sub { return $_[0]; };
847: }
1.31 matthew 848: #
1.33 matthew 849: my $submission =
850: &HTML::Entities::decode
1.45 www 851: (&unescape($response->{'Submission'}));
1.42 albertel 852: if (!$prob->is_task()) {
853: return () if (! defined($submission) || $submission eq '');
854: }
1.31 matthew 855: $submission =~ s/\\\"/\"/g;
856: $submission =~ s/\\\'/\'/g;
857: if ($resptype eq 'radiobutton') {
858: $submission =~ s/=([^=])$//;
1.20 matthew 859: }
1.31 matthew 860: $response->{'Submission'} = $submission;
861: #
862: my @values;
863: if ($resptype =~ /^(option|match|rank)$/) {
864: my %submission =
865: map {
1.45 www 866: my ($foil,$value) = split('=',&unescape($_));
1.31 matthew 867: ($foil,$value);
868: } split('&',$response->{'Submission'});
869: my %correct;
870: if (exists($response->{'Correct'})) {
871: %correct =
872: map {
1.45 www 873: my ($foil,$value)=split('=',&unescape($_));
1.31 matthew 874: ($foil,$value);
875: } split('&',$response->{'Correct'});
876: }
877: #
878: foreach my $original_header (@$headers) {
879: if ($original_header =~ /^_/) {
880: # '_' denotes a foil column
881: my ($header) = ($original_header =~ m/^_(.*)$/);
882: my $option = '';
883: if ( my ($foil) = ($header =~ /(.*) Correct$/)) {
884: if (exists($correct{$foil})) {
885: $option = $correct{$foil};
886: }
887: } elsif (exists($submission{$header})) {
888: $option = $submission{$header};
889: }
1.33 matthew 890: push(@values,&{$format}($option,$header));
1.31 matthew 891: } else {
892: # A normal column
1.33 matthew 893: push(@values,&{$format}($response->{$original_header},
1.31 matthew 894: $original_header));
895: }
896: }
897: } else {
1.33 matthew 898: @values = map { &{$format}($response->{$_},$_); } @$headers;
1.20 matthew 899: }
1.31 matthew 900: return @values;
1.20 matthew 901: }
902:
1.31 matthew 903: sub excel_format_item {
904: my ($item,$type) = @_;
905: if ($type eq 'Time') {
1.33 matthew 906: $item = &Apache::lonstathelpers::calc_serial($item);
1.31 matthew 907: } else {
908: if ($item =~ m/^=/) {
909: $item = ' '.$item;
910: }
911: $item =~ s/\\r//g;
912: $item =~ s/\\n/\n/g;
913: $item =~ s/(\s*$|^\s*)//g;
914: $item =~ s/\\\'/\'/g;
1.18 matthew 915: }
1.31 matthew 916: return $item;
1.1 matthew 917: }
918:
919: #########################################################
920: #########################################################
1.17 matthew 921: ##
922: ## CSV output of student answers
923: ##
924: #########################################################
925: #########################################################
926: sub prepare_csv_output {
1.22 matthew 927: my ($r,$problems,$students) = @_;
1.17 matthew 928: my $c = $r->connection();
929: #
930: $r->print('<h2>'.
931: &mt('Generating CSV report of student responses').'</h2>');
932: #
933: # Progress window
934: my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
935: ($r,'CSV File Compilation Status',
936: 'CSV File Compilation Progress',
1.22 matthew 937: scalar(@$students),'inline',undef,'Statistics','stats_status');
938:
1.17 matthew 939: $r->rflush();
940: #
941: # Open a file
942: my $outputfile;
943: my $filename = '/prtspool/'.
1.40 albertel 944: $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
1.17 matthew 945: time.'_'.rand(1000000000).'.csv';
946: unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) {
947: $r->log_error("Couldn't open $filename for output $!");
1.55 bisitz 948: $r->print(
949: '<p class="LC_error">'
950: .&mt('Problems occurred in writing the CSV file.')
951: .' '.&mt('This error has been logged.')
952: .' '.&mt('Please alert your LON-CAPA administrator.')
953: .'</p>'
954: );
1.17 matthew 955: $outputfile = undef;
956: }
957: #
1.22 matthew 958: # Compute the number of columns per response
1.32 matthew 959: my @extra_resp_headers = &get_extra_response_headers();
1.22 matthew 960: #
961: # Create the table header
1.38 matthew 962: my @student_columns = ('username','domain','id','section');
1.17 matthew 963: #
1.22 matthew 964: my %headers;
965: push(@{$headers{'student'}},@student_columns);
966: # Pad for the student data
967: foreach my $row ('problem','part','response') {
1.32 matthew 968: $headers{$row}=[map {''} @student_columns];
1.22 matthew 969: }
970: #
971: # we put the headers into the %headers hash
1.32 matthew 972: my %problem_analysis;
973: my %start_col;
974: my $max_column = scalar(@student_columns);
1.22 matthew 975: foreach my $prob (@$problems) {
1.32 matthew 976: my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);
977: $problem_analysis{$prob->src}=\%analysis;
978: $headers{'problem'}->[$max_column] = $prob->compTitle;
1.22 matthew 979: foreach my $partid (@{$prob->parts}) {
1.32 matthew 980: $headers{'part'}->[$max_column] = $prob->part_display($partid);
1.22 matthew 981: my $responses = [$prob->responseIds($partid)];
1.32 matthew 982: my $resptypes = [$prob->responseType($partid)];
1.22 matthew 983: for (my $i=0;$i<scalar(@$responses);$i++) {
1.32 matthew 984: my @headers = &get_headers($prob,$partid,$responses->[$i],
985: $resptypes->[$i],
986: $problem_analysis{$prob->src},
987: 'csv','display',
988: @extra_resp_headers);
989: $start_col{$prob->symb}->{$partid}->{$responses->[$i]}=
990: $max_column;
991: $headers{'response'}->[$max_column]=
1.22 matthew 992: &mt('Response [_1]',$responses->[$i]);
1.32 matthew 993: for (my $j=0;$j<=$#headers;$j++) {
994: $headers{'student'}->[$max_column+$j]=$headers[$j];
1.22 matthew 995: }
1.32 matthew 996: $max_column += scalar(@headers);
1.17 matthew 997: }
998: }
999: }
1.22 matthew 1000: foreach my $row ('problem','part','response','student') {
1.32 matthew 1001: print $outputfile '"'.
1.22 matthew 1002: join('","',
1003: map {
1004: &Apache::loncommon::csv_translate($_);
1005: } @{$headers{$row}}).'"'.$/;
1.17 matthew 1006: }
1007: #
1.22 matthew 1008: # Main loop
1009: foreach my $student (@$students) {
1.27 matthew 1010: last if ($c->aborted());
1.22 matthew 1011: my @rows;
1012: foreach my $prob (@$problems) {
1013: foreach my $partid (@{$prob->parts}) {
1014: my @responses = $prob->responseIds($partid);
1015: my @response_type = $prob->responseType($partid);
1016: for (my $i=0;$i<=$#responses;$i++) {
1017: my $respid = $responses[$i];
1.32 matthew 1018: my $resptype = $response_type[$i];
1019: my @headers = &get_headers($prob,$partid,$respid,$resptype,
1020: $problem_analysis{$prob->src},
1021: 'csv','normal',
1022: @extra_resp_headers);
1.22 matthew 1023: my $results =
1024: &Apache::loncoursedata::get_response_data_by_student
1025: ($student,$prob->symb(),$respid);
1026: if (! defined($results)) {
1027: $results = [];
1028: }
1029: for (my $j=0; $j<scalar(@$results);$j++) {
1.40 albertel 1030: if ($env{'form.all_sub'} ne 'true') {
1.22 matthew 1031: next if ($j != 0);
1032: }
1033: my $idx = scalar(@$results) - $j - 1;
1.32 matthew 1034: my $response = &hashify_response($results->[$idx],
1035: $prob,$student,
1036: $partid,$respid);
1037: my @data = &compile_response_data(\@headers,$response,
1.22 matthew 1038: $prob,$partid,
1.33 matthew 1039: $respid,$resptype,
1040: \&csv_format_item);
1.32 matthew 1041: my $resp_start_idx =
1042: $start_col{$prob->symb}->{$partid}->{$respid};
1.22 matthew 1043: for (my $k=0;$k<=$#data;$k++) {
1.32 matthew 1044: $rows[$j]->[$resp_start_idx + $k] = $data[$k];
1.22 matthew 1045: }
1046: }
1047: }
1.17 matthew 1048: }
1.22 matthew 1049: }
1050: foreach my $row (@rows) {
1051: print $outputfile '"'.join('","',
1052: map { $student->{$_}; }
1053: @student_columns).'"';
1.32 matthew 1054: for (my $i=scalar(@student_columns);$i<$max_column;$i++) {
1.22 matthew 1055: my $value = &Apache::loncommon::csv_translate($row->[$i]);
1056: $value ||='';
1057: print $outputfile ',"'.$value.'"';
1.17 matthew 1058: }
1.22 matthew 1059: print $outputfile $/;
1.17 matthew 1060: }
1.22 matthew 1061: undef(@rows);
1.17 matthew 1062: &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
1063: 'last student');
1064: }
1065: close($outputfile);
1066: #
1067: # Close the progress window
1068: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
1069: #
1.48 bisitz 1070: # Tell the user where to get their CSV file
1.17 matthew 1071: $r->print('<br />'.
1.48 bisitz 1072: '<a href="'.$filename.'">'.&mt('Your CSV file.').'</a>'."\n");
1.17 matthew 1073: $r->rflush();
1074: return;
1075: }
1076:
1.32 matthew 1077: sub csv_format_item {
1078: my ($item,$type) = @_;
1079: if ($type eq 'Time') {
1080: $item = localtime($item);
1.33 matthew 1081: }
1.32 matthew 1082: $item =&Apache::loncommon::csv_translate($item);
1083: return $item;
1.15 matthew 1084: }
1085:
1.1 matthew 1086: #########################################################
1087: #########################################################
1088: ##
1089: ## Generic Interface Routines
1090: ##
1091: #########################################################
1092: #########################################################
1093: sub CreateInterface {
1094: ##
1.16 matthew 1095: ## Output Selection
1.19 matthew 1096: my $output_selector = $/.'<select name="output">'.$/;
1.22 matthew 1097: foreach ('HTML','Excel','CSV') {
1.19 matthew 1098: $output_selector .= ' <option value="'.lc($_).'"';
1.40 albertel 1099: if ($env{'form.output'} eq lc($_)) {
1.59 ! bisitz 1100: $output_selector .= ' selected="selected"';
1.16 matthew 1101: }
1.19 matthew 1102: $output_selector .='>'.&mt($_).'</option>'.$/;
1.16 matthew 1103: }
1.19 matthew 1104: $output_selector .= '</select>'.$/;
1.16 matthew 1105: ##
1.1 matthew 1106: ## Environment variable initialization
1107: my $Str = '';
1.43 albertel 1108: $Str .= &Apache::lonhtmlcommon::breadcrumbs('Student Submission Reports');
1.59 ! bisitz 1109: $Str .= '<br />';
1.50 bisitz 1110: $Str .= &Apache::loncommon::start_data_table();
1111: $Str .= &Apache::loncommon::start_data_table_header_row();
1.16 matthew 1112: $Str .= '<th>'.&mt('Sections').'</th>';
1.44 raeburn 1113: $Str .= '<th>'.&mt('Groups').'</th>';
1.57 onken 1114: $Str .= '<th>'.&mt('Student Data').&Apache::loncommon::help_open_topic("Chart_Student_Data").'</th>';
1.46 raeburn 1115: $Str .= '<th>'.&mt('Access Status').'</th>';
1.50 bisitz 1116: $Str .= '<th>'.&mt('Options').'</th>';
1117: $Str .= '<th>'.&mt('Output Format').'</th>';
1118: $Str .= &Apache::loncommon::end_data_table_header_row();
1.11 matthew 1119: #
1.50 bisitz 1120: $Str .= &Apache::loncommon::start_data_table_row();
1121: $Str .= '<td align="center">'."\n";
1.1 matthew 1122: $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
1123: $Str .= '</td>';
1124: #
1.44 raeburn 1125: $Str .= '<td align="center">'."\n";
1126: $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
1127: $Str .= '</td>';
1128: #
1.57 onken 1129: $Str .= '<td align="center">'."\n";
1130: $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple', 5,undef);
1131: $Str .= '</td>';
1132: #
1.1 matthew 1133: $Str .= '<td align="center">';
1134: $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
1135: $Str .= '</td>';
1.6 matthew 1136: #
1.15 matthew 1137: # Render problem checkbox
1138: my $prob_checkbox = '<input type="checkbox" name="renderprob" ';
1.40 albertel 1139: if (exists($env{'form.renderprob'}) && $env{'form.renderprob'} eq 'true') {
1.50 bisitz 1140: $prob_checkbox .= 'checked="checked" ';
1.15 matthew 1141: }
1142: $prob_checkbox .= 'value="true" />';
1143: #
1144: # Compute correct answers checkbox
1145: my $ans_checkbox = '<input type="checkbox" name="correctans" ';
1.40 albertel 1146: if (exists($env{'form.correctans'}) && $env{'form.correctans'} eq 'true') {
1.50 bisitz 1147: $ans_checkbox .= 'checked="checked" ';
1.13 matthew 1148: }
1.15 matthew 1149: $ans_checkbox .= 'value="true" />';
1150: #
1.19 matthew 1151: # Show all submissions checkbox
1152: my $all_sub_checkbox = '<input type="checkbox" name="all_sub" ';
1.40 albertel 1153: if (exists($env{'form.all_sub'}) &&
1154: $env{'form.all_sub'} eq 'true') {
1.50 bisitz 1155: $all_sub_checkbox .= 'checked="checked" ';
1.15 matthew 1156: }
1.19 matthew 1157: $all_sub_checkbox.= 'value="true" />';
1.15 matthew 1158: #
1.20 matthew 1159: # problem status checkbox
1160: my $prob_status_checkbox = '<input type="checkbox" name="prob_status" ';
1.40 albertel 1161: if (exists($env{'form.prob_status'}) &&
1162: $env{'form.prob_status'} eq 'true') {
1.50 bisitz 1163: $prob_status_checkbox .= 'checked="checked" ';
1.15 matthew 1164: }
1.20 matthew 1165: $prob_status_checkbox .= 'value="true" />';
1.15 matthew 1166: #
1.56 bisitz 1167: $Str .=
1168: '<td valign="top">'
1169: .'<label>'
1170: .$prob_checkbox.&mt('Show problem')
1171: .'</label><br />'
1172: .'<label>'
1173: .' '.$ans_checkbox.&mt('Show correct answers')
1174: .'</label><br />'
1175: .'<label>'
1176: .$all_sub_checkbox.&mt('Show all submissions')
1177: .'</label><br />'
1178: .'<label>'
1179: .$prob_status_checkbox.&mt('Show problem grading')
1180: .'</label>'
1181: .'</td>';
1.13 matthew 1182: #
1.50 bisitz 1183: $Str .= '<td align="center" valign="top">'.$output_selector.'</td>';
1184: #
1185: $Str .= &Apache::loncommon::end_data_table_row();
1186: $Str .= &Apache::loncommon::end_data_table();
1.1 matthew 1187: #
1.49 bisitz 1188: $Str .= '<p><span class="LC_nobreak">'
1189: .&mt('Status: [_1]',
1190: '<input type="text" name="stats_status"'
1191: .' size="60" value="" readonly="readonly" />')
1192: .'</span></p>';
1.11 matthew 1193: ##
1.1 matthew 1194: return $Str;
1195: }
1196:
1197: 1;
1198:
1199: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>