Annotation of loncom/interface/statistics/lonstudentsubmissions.pm, revision 1.57
1.1 matthew 1: # The LearningOnline Network with CAPA
2: #
1.57 ! onken 3: # $Id: lonstudentsubmissions.pm,v 1.56 2010/01/14 17:20:51 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.57 ! onken 334: $student_row_data .= '<td valign="center">';
! 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
460: return;
461: }
462:
1.30 matthew 463: sub hashify_response {
464: my ($response,$prob,$student,$partid,$respid) =@_;
465: my $resp_hash = {};
1.40 albertel 466: if ($env{'form.correctans'} eq 'true') {
1.30 matthew 467: $resp_hash->{'Correct'} =
468: &Apache::lonstathelpers::get_student_answer
469: ($prob,$student->{'username'},$student->{'domain'},
470: $partid,$respid);
471: }
472: $resp_hash->{'Submission'} =
473: $response->[&Apache::loncoursedata::RDs_submission()];
474: $resp_hash->{'Time'} =
475: $response->[&Apache::loncoursedata::RDs_timestamp()];
476: $resp_hash->{'Attempt'} =
477: $response->[&Apache::loncoursedata::RDs_tries()];
478: $resp_hash->{'Awarded'} =
479: $response->[&Apache::loncoursedata::RDs_awarded()];
1.42 albertel 480: if ($prob->is_task()) {
481: $resp_hash->{'Grader'} =
482: $response->[&Apache::loncoursedata::RDs_response_eval_2()];
483: if ($resp_hash->{'Attempt'} eq '0') {
484: $resp_hash->{'Attempt'} = '';
485: }
486: $resp_hash->{'Award Detail'} =
487: $response->[&Apache::loncoursedata::RDs_part_award()];
488: $resp_hash->{'Status'} =
489: $response->[&Apache::loncoursedata::RDs_response_eval()];
490: } else {
491: $resp_hash->{'Award Detail'} =
492: $response->[&Apache::loncoursedata::RDs_awarddetail()];
493: }
494:
1.30 matthew 495: return $resp_hash;
496: }
497:
1.21 matthew 498: #####################################################
499: ##
500: ## HTML helper routines
501: ##
502: #####################################################
503: sub html_essay_results {
1.30 matthew 504: my ($headers,$prob,$partid,$respid,$response,$single_response)=@_;
505: if (! ref($headers) || ref($headers) ne 'ARRAY') {
506: return '';
1.21 matthew 507: }
1.30 matthew 508: # Start of telling them what problem, part, and response
1.21 matthew 509: my $Str;
510: if (! $single_response) {
1.23 matthew 511: my $id = $prob->compTitle;
1.21 matthew 512: if (defined($partid) && $partid ne '0') {
1.24 matthew 513: $id .= ' '.$prob->part_display($partid);
1.21 matthew 514: }
515: if (defined($respid)) {
516: $id .= ' '.$respid;
517: }
1.51 bisitz 518: $Str .= '<span class="LC_nobreak">'.$id.'</span>'.(' 'x4);
1.21 matthew 519: }
1.30 matthew 520: #
521: shift(@$headers); # Get rid of the Submission header
522: my $correct = '';
523: if ($headers->[0] eq 'Correct') {
524: $correct = &html_format_essay_sub($response->{'Correct'});
525: shift(@$headers);
526: }
1.51 bisitz 527: $Str .= '<span class="LC_nobreak">'.
1.30 matthew 528: join('',
529: map {
530: (' 'x4).&mt($_.': [_1]',$response->{$_});
1.51 bisitz 531: } @$headers).'</span>';
1.30 matthew 532: if (@$headers || ! $single_response) {
533: $Str .= '<br />';
1.21 matthew 534: }
1.30 matthew 535: $Str .= &html_format_essay_sub($response->{'Submission'});
536: #
1.21 matthew 537: if (defined($correct) && $correct !~ /^\s*$/) {
538: $Str .= '<hr /><b>'.&mt('Correct').'</b>'.$correct
539: }
540: return $Str;
541: }
542:
1.30 matthew 543: sub html_format_essay_sub {
544: my ($submission) = @_;
545: return '' if (! defined($submission) || $submission eq '');
546: $submission = &HTML::Entities::decode($submission);
547: $submission =~ s/\\\"/\"/g;
548: $submission =~ s/\\\'/\'/g;
549: $submission =~ s|\\r\\n|$/|g;
550: $submission = &HTML::Entities::encode($submission,'<>&"');
551: $submission =~ s|$/\s*$/|$/</p><p>$/|g;
552: $submission =~ s|\\||g;
553: $submission = '<p>'.$submission.'</p>';
554: return $submission;
1.21 matthew 555: }
556:
1.42 albertel 557: sub html_task_results {
558: my ($headers,$prob,$partid,$respid,$response,$resptype) = @_;
559: if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
560: return '';
561: }
562:
563: my @values;
564: @values = map { $response->{$_}; } @$headers;
565:
566: my $td = '<td valign="top">';
567: my $str = $td.join('</td>'.$td,@values).'</td>';
568: return $str;
569: }
570:
1.30 matthew 571: sub html_non_essay_results {
572: my ($headers,$prob,$partid,$respid,$response,$resptype) = @_;
573: if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
574: return '';
575: }
576: #
1.45 www 577: my $submission = &HTML::Entities::decode(&unescape($response->{'Submission'}));
1.21 matthew 578: return '' if (! defined($submission) || $submission eq '');
1.25 matthew 579: $submission =~ s/\\\"/\"/g;
580: $submission =~ s/\\\'/\'/g;
1.30 matthew 581: if ($resptype eq 'radiobutton') {
1.25 matthew 582: $submission = &HTML::Entities::encode($submission,'<>&"');
1.21 matthew 583: $submission =~ s/=([^=])$//;
1.51 bisitz 584: $submission = '<span class="LC_nobreak">'.$submission.'</span>';
1.30 matthew 585: }
586: $response->{'Submission'} = $submission;
587: #
588: my @values;
589: if ($resptype =~ /^(option|match|rank)$/) {
590: my %submission =
591: map {
1.45 www 592: my ($foil,$value) = split('=',&unescape($_));
1.30 matthew 593: ($foil,$value);
594: } split('&',$response->{'Submission'});
595: my %correct;
596: if (exists($response->{'Correct'})) {
597: %correct =
598: map {
1.45 www 599: my ($foil,$value)=split('=',&unescape($_));
1.30 matthew 600: ($foil,$value);
601: } split('&',$response->{'Correct'});
602: }
603: #
604: foreach my $original_header (@$headers) {
605: if ($original_header =~ /^_/) {
606: # '_' denotes a foil column
607: my ($header) = ($original_header =~ m/^_(.*)$/);
608: my $option = '';
609: if ( my ($foil) = ($header =~ /(.*) Correct$/)) {
610: if (exists($correct{$foil})) {
611: $option = $correct{$foil};
612: }
613: } elsif (exists($submission{$header})) {
614: $option = $submission{$header};
615: }
616: push(@values,&HTML::Entities::encode($option));
1.38 matthew 617: } elsif ($original_header eq 'Time') {
618: push(@values,&Apache::lonlocal::locallocaltime($response->{$original_header}));
1.30 matthew 619: } else {
620: # A normal column
621: push(@values,$response->{$original_header});
622: }
623: }
1.25 matthew 624: } else {
1.30 matthew 625: @values = map { $response->{$_}; } @$headers;
1.21 matthew 626: }
1.30 matthew 627: my $td = '<td valign="top">';
628: my $str = $td.join('</td>'.$td,@values).'</td>';
629: return $str;
1.21 matthew 630: }
1.18 matthew 631:
1.30 matthew 632:
1.21 matthew 633: #########################################################
634: #########################################################
635: ##
636: ## Excel Output Routines
637: ##
638: #########################################################
639: #########################################################
640: sub prepare_excel_output {
1.19 matthew 641: my ($r,$Problems,$Students) = @_;
1.18 matthew 642: my $c = $r->connection();
643: #
1.19 matthew 644: #
645: # Determine the number of columns in the spreadsheet
646: my $columncount = 3; # username, domain, id
1.31 matthew 647: my @extra_resp_headers = &get_extra_response_headers();
1.20 matthew 648: my $lastprob;
1.31 matthew 649: my %problem_analysis;
1.19 matthew 650: foreach my $prob (@$Problems) {
1.31 matthew 651: my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);
652: $problem_analysis{$prob->src}=\%analysis;
653: foreach my $partid (@{$prob->parts}) {
654: my $responses = [$prob->responseIds($partid)];
655: my $resptypes = [$prob->responseType($partid)];
656: for (my $i=0;$i<scalar(@$responses);$i++) {
657: my @headers = &get_headers($prob,$partid,$responses->[$i],
658: $resptypes->[$i],
659: $problem_analysis{$prob->src},
660: 'excel','display',
661: @extra_resp_headers);
662: $columncount += scalar(@headers);
663: }
664: }
1.19 matthew 665: last if ($columncount > 255);
1.20 matthew 666: $lastprob = $prob;
1.19 matthew 667: }
668: if ($columncount > 255) {
669: $r->print('<h1>'.&mt('Unable to complete request').'</h1>'.$/.
670: '<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 671: '<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 672: '<p>'.&mt('The last problem that will fit in the current spreadsheet is [_1].',$lastprob->compTitle).'</p>');
1.19 matthew 673: $r->rflush();
674: return;
675: }
676: #
677: # Print out a message telling them what we are doing
1.18 matthew 678: if (scalar(@$Problems) > 1) {
679: $r->print('<h2>'.
680: &mt('Preparing Excel spreadsheet of student responses to [_1] problems',
681: scalar(@$Problems)).
682: '</h2>');
683: } else {
684: $r->print('<h2>'.
685: &mt('Preparing Excel spreadsheet of student responses').
686: '</h2>');
687: }
688: $r->rflush();
689: #
690: # Create the excel spreadsheet
1.36 matthew 691: my ($workbook,$filename,$format) =
692: &Apache::loncommon::create_workbook($r);
693: return if (! defined($workbook));
1.18 matthew 694: my $worksheet = $workbook->addworksheet('Student Submission Data');
695: #
696: # Add headers to the worksheet
697: my $rows_output = 0;
698: $worksheet->write($rows_output++,0,
1.40 albertel 699: $env{'course.'.$env{'request.course.id'}.'.description'},
1.18 matthew 700: $format->{'h1'});
701: $rows_output++;
702: my $cols_output = 0;
703: my $title_row = $rows_output++;
704: my $partid_row = $rows_output++;
705: my $respid_row = $rows_output++;
706: my $header_row = $rows_output++;
707: $worksheet->write($title_row ,0,'Problem Title',$format->{'bold'});
708: $worksheet->write($partid_row,0,'Part ID',$format->{'bold'});
709: $worksheet->write($respid_row,0,'Response ID',$format->{'bold'});
710: # Student headers
1.38 matthew 711: my @StudentColumns = ('username','domain','id','section');
1.18 matthew 712: foreach (@StudentColumns) {
1.19 matthew 713: $worksheet->write($header_row,$cols_output++,ucfirst($_),
714: $format->{'bold'});
1.18 matthew 715: }
716: # Problem headers
1.31 matthew 717: my %start_col;
1.18 matthew 718: foreach my $prob (@$Problems) {
1.23 matthew 719: my $title = $prob->compTitle;
1.18 matthew 720: $worksheet->write($title_row,$cols_output,
721: $title,$format->{'h3'});
722: foreach my $partid (@{$prob->parts}) {
1.24 matthew 723: $worksheet->write($partid_row,$cols_output,
724: $prob->part_display($partid));
1.18 matthew 725: my $responses = [$prob->responseIds($partid)];
726: my $resptypes = [$prob->responseType($partid)];
727: for (my $i=0;$i<scalar(@$responses);$i++) {
1.31 matthew 728: $start_col{$prob->symb}->{$partid}->{$responses->[$i]}=
729: $cols_output;
1.18 matthew 730: $worksheet->write($respid_row,$cols_output,
731: $resptypes->[$i].', '.$responses->[$i]);
1.31 matthew 732: my @headers = &get_headers($prob,$partid,$responses->[$i],
733: $resptypes->[$i],
734: $problem_analysis{$prob->src},
735: 'excel','display',
736: @extra_resp_headers);
737: foreach my $text (@headers) {
738: if ($text eq 'Time') {
739: $worksheet->set_column($cols_output,$cols_output,undef,
740: $format->{'date'});
741: }
742: $worksheet->write($header_row,$cols_output++,$text);
1.20 matthew 743: }
1.18 matthew 744: }
745: }
746: }
747: #
748: # Populate the worksheet with the student data
749: my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
750: ($r,'Excel File Compilation Status',
751: 'Excel File Compilation Progress',
752: scalar(@$Students),'inline',undef,'Statistics','stats_status');
1.20 matthew 753: my $max_row = $rows_output;
1.18 matthew 754: foreach my $student (@$Students) {
755: last if ($c->aborted());
756: $cols_output = 0;
1.20 matthew 757: my $student_row = $max_row;
1.18 matthew 758: foreach my $field (@StudentColumns) {
1.20 matthew 759: $worksheet->write($student_row,$cols_output++,
1.18 matthew 760: $student->{$field});
761: }
1.20 matthew 762: my $last_student_col = $cols_output-1;
1.18 matthew 763: foreach my $prob (@$Problems) {
764: foreach my $partid (@{$prob->parts}) {
765: my @Response = $prob->responseIds($partid);
766: my @ResponseType = $prob->responseType($partid);
767: for (my $i=0;$i<=$#Response;$i++) {
768: my $respid = $Response[$i];
769: my $resptype = $ResponseType[$i];
770: my $results =
771: &Apache::loncoursedata::get_response_data_by_student
772: ($student,$prob->symb(),$respid);
1.31 matthew 773: my @headers = &get_headers($prob,$partid,$respid,
774: $resptype,
775: $problem_analysis{$prob->src},
776: 'excel','normal',
777: @extra_resp_headers);
778:
1.20 matthew 779: if (! defined($results)) {
780: $results = [];
781: }
782: #
783: $rows_output = $student_row;
784: #
1.31 matthew 785: my $response_start_col = $start_col{$prob->symb}->{$partid}->{$respid};
1.20 matthew 786: for (my $j=scalar(@$results)-1;$j>=0;$j--) {
787: $cols_output = $response_start_col;
1.40 albertel 788: if ($env{'form.all_sub'} ne 'true') {
1.20 matthew 789: next if ($j ne scalar(@$results)-1);
790: }
1.31 matthew 791: my $response = &hashify_response($results->[$j],
792: $prob,
793: $student,
794: $partid,
795: $respid);
796: my @response_data =
1.33 matthew 797: &compile_response_data(\@headers,$response,
798: $prob,$partid,$respid,
799: $resptype,
800: \&excel_format_item);
1.31 matthew 801: $worksheet->write_row($rows_output++,$cols_output,
802: \@response_data);
803: $cols_output+=scalar(@response_data);
1.20 matthew 804: if ($rows_output > $max_row) {
805: $max_row = $rows_output;
806: }
1.19 matthew 807: }
1.18 matthew 808: }
809: }
810: }
1.28 matthew 811: # Fill in the remaining rows with the students data
1.34 matthew 812: for (my $row = $student_row+1;$row<$max_row;$row++) {
1.28 matthew 813: my $cols = 0;
814: foreach my $field (@StudentColumns) {
815: $worksheet->write($row,$cols++,
816: $student->{$field});
817: }
818: }
1.18 matthew 819: &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
820: 'last student');
821: }
822: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
823: #
824: # Close the excel file
825: $workbook->close();
826: #
827: # Write a link to allow them to download it
828: $r->print('<p><a href="'.$filename.'">'.
829: &mt('Your Excel spreadsheet.').
830: '</a></p>'."\n");
831: $r->print('<script>'.
832: 'window.document.Statistics.stats_status.value="'.
833: 'Done compiling spreadsheet. See link below to download.'.
834: '";</script>');
835: $r->rflush();
836: return;
837: }
838:
1.33 matthew 839: sub compile_response_data {
840: my ($headers,$response,$prob,$partid,$respid,$resptype,$format) = @_;
1.31 matthew 841: if (! ref($headers) || ref($headers) ne 'ARRAY' || ! scalar(@$headers)) {
842: return ();
843: }
1.33 matthew 844: if (ref($format) ne 'CODE') {
845: $format = sub { return $_[0]; };
846: }
1.31 matthew 847: #
1.33 matthew 848: my $submission =
849: &HTML::Entities::decode
1.45 www 850: (&unescape($response->{'Submission'}));
1.42 albertel 851: if (!$prob->is_task()) {
852: return () if (! defined($submission) || $submission eq '');
853: }
1.31 matthew 854: $submission =~ s/\\\"/\"/g;
855: $submission =~ s/\\\'/\'/g;
856: if ($resptype eq 'radiobutton') {
857: $submission =~ s/=([^=])$//;
1.20 matthew 858: }
1.31 matthew 859: $response->{'Submission'} = $submission;
860: #
861: my @values;
862: if ($resptype =~ /^(option|match|rank)$/) {
863: my %submission =
864: map {
1.45 www 865: my ($foil,$value) = split('=',&unescape($_));
1.31 matthew 866: ($foil,$value);
867: } split('&',$response->{'Submission'});
868: my %correct;
869: if (exists($response->{'Correct'})) {
870: %correct =
871: map {
1.45 www 872: my ($foil,$value)=split('=',&unescape($_));
1.31 matthew 873: ($foil,$value);
874: } split('&',$response->{'Correct'});
875: }
876: #
877: foreach my $original_header (@$headers) {
878: if ($original_header =~ /^_/) {
879: # '_' denotes a foil column
880: my ($header) = ($original_header =~ m/^_(.*)$/);
881: my $option = '';
882: if ( my ($foil) = ($header =~ /(.*) Correct$/)) {
883: if (exists($correct{$foil})) {
884: $option = $correct{$foil};
885: }
886: } elsif (exists($submission{$header})) {
887: $option = $submission{$header};
888: }
1.33 matthew 889: push(@values,&{$format}($option,$header));
1.31 matthew 890: } else {
891: # A normal column
1.33 matthew 892: push(@values,&{$format}($response->{$original_header},
1.31 matthew 893: $original_header));
894: }
895: }
896: } else {
1.33 matthew 897: @values = map { &{$format}($response->{$_},$_); } @$headers;
1.20 matthew 898: }
1.31 matthew 899: return @values;
1.20 matthew 900: }
901:
1.31 matthew 902: sub excel_format_item {
903: my ($item,$type) = @_;
904: if ($type eq 'Time') {
1.33 matthew 905: $item = &Apache::lonstathelpers::calc_serial($item);
1.31 matthew 906: } else {
907: if ($item =~ m/^=/) {
908: $item = ' '.$item;
909: }
910: $item =~ s/\\r//g;
911: $item =~ s/\\n/\n/g;
912: $item =~ s/(\s*$|^\s*)//g;
913: $item =~ s/\\\'/\'/g;
1.18 matthew 914: }
1.31 matthew 915: return $item;
1.1 matthew 916: }
917:
918: #########################################################
919: #########################################################
1.17 matthew 920: ##
921: ## CSV output of student answers
922: ##
923: #########################################################
924: #########################################################
925: sub prepare_csv_output {
1.22 matthew 926: my ($r,$problems,$students) = @_;
1.17 matthew 927: my $c = $r->connection();
928: #
929: $r->print('<h2>'.
930: &mt('Generating CSV report of student responses').'</h2>');
931: #
932: # Progress window
933: my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin
934: ($r,'CSV File Compilation Status',
935: 'CSV File Compilation Progress',
1.22 matthew 936: scalar(@$students),'inline',undef,'Statistics','stats_status');
937:
1.17 matthew 938: $r->rflush();
939: #
940: # Open a file
941: my $outputfile;
942: my $filename = '/prtspool/'.
1.40 albertel 943: $env{'user.name'}.'_'.$env{'user.domain'}.'_'.
1.17 matthew 944: time.'_'.rand(1000000000).'.csv';
945: unless ($outputfile = Apache::File->new('>/home/httpd'.$filename)) {
946: $r->log_error("Couldn't open $filename for output $!");
1.55 bisitz 947: $r->print(
948: '<p class="LC_error">'
949: .&mt('Problems occurred in writing the CSV file.')
950: .' '.&mt('This error has been logged.')
951: .' '.&mt('Please alert your LON-CAPA administrator.')
952: .'</p>'
953: );
1.17 matthew 954: $outputfile = undef;
955: }
956: #
1.22 matthew 957: # Compute the number of columns per response
1.32 matthew 958: my @extra_resp_headers = &get_extra_response_headers();
1.22 matthew 959: #
960: # Create the table header
1.38 matthew 961: my @student_columns = ('username','domain','id','section');
1.17 matthew 962: #
1.22 matthew 963: my %headers;
964: push(@{$headers{'student'}},@student_columns);
965: # Pad for the student data
966: foreach my $row ('problem','part','response') {
1.32 matthew 967: $headers{$row}=[map {''} @student_columns];
1.22 matthew 968: }
969: #
970: # we put the headers into the %headers hash
1.32 matthew 971: my %problem_analysis;
972: my %start_col;
973: my $max_column = scalar(@student_columns);
1.22 matthew 974: foreach my $prob (@$problems) {
1.32 matthew 975: my %analysis = &Apache::lonstathelpers::get_problem_data($prob->src);
976: $problem_analysis{$prob->src}=\%analysis;
977: $headers{'problem'}->[$max_column] = $prob->compTitle;
1.22 matthew 978: foreach my $partid (@{$prob->parts}) {
1.32 matthew 979: $headers{'part'}->[$max_column] = $prob->part_display($partid);
1.22 matthew 980: my $responses = [$prob->responseIds($partid)];
1.32 matthew 981: my $resptypes = [$prob->responseType($partid)];
1.22 matthew 982: for (my $i=0;$i<scalar(@$responses);$i++) {
1.32 matthew 983: my @headers = &get_headers($prob,$partid,$responses->[$i],
984: $resptypes->[$i],
985: $problem_analysis{$prob->src},
986: 'csv','display',
987: @extra_resp_headers);
988: $start_col{$prob->symb}->{$partid}->{$responses->[$i]}=
989: $max_column;
990: $headers{'response'}->[$max_column]=
1.22 matthew 991: &mt('Response [_1]',$responses->[$i]);
1.32 matthew 992: for (my $j=0;$j<=$#headers;$j++) {
993: $headers{'student'}->[$max_column+$j]=$headers[$j];
1.22 matthew 994: }
1.32 matthew 995: $max_column += scalar(@headers);
1.17 matthew 996: }
997: }
998: }
1.22 matthew 999: foreach my $row ('problem','part','response','student') {
1.32 matthew 1000: print $outputfile '"'.
1.22 matthew 1001: join('","',
1002: map {
1003: &Apache::loncommon::csv_translate($_);
1004: } @{$headers{$row}}).'"'.$/;
1.17 matthew 1005: }
1006: #
1.22 matthew 1007: # Main loop
1008: foreach my $student (@$students) {
1.27 matthew 1009: last if ($c->aborted());
1.22 matthew 1010: my @rows;
1011: foreach my $prob (@$problems) {
1012: foreach my $partid (@{$prob->parts}) {
1013: my @responses = $prob->responseIds($partid);
1014: my @response_type = $prob->responseType($partid);
1015: for (my $i=0;$i<=$#responses;$i++) {
1016: my $respid = $responses[$i];
1.32 matthew 1017: my $resptype = $response_type[$i];
1018: my @headers = &get_headers($prob,$partid,$respid,$resptype,
1019: $problem_analysis{$prob->src},
1020: 'csv','normal',
1021: @extra_resp_headers);
1.22 matthew 1022: my $results =
1023: &Apache::loncoursedata::get_response_data_by_student
1024: ($student,$prob->symb(),$respid);
1025: if (! defined($results)) {
1026: $results = [];
1027: }
1028: for (my $j=0; $j<scalar(@$results);$j++) {
1.40 albertel 1029: if ($env{'form.all_sub'} ne 'true') {
1.22 matthew 1030: next if ($j != 0);
1031: }
1032: my $idx = scalar(@$results) - $j - 1;
1.32 matthew 1033: my $response = &hashify_response($results->[$idx],
1034: $prob,$student,
1035: $partid,$respid);
1036: my @data = &compile_response_data(\@headers,$response,
1.22 matthew 1037: $prob,$partid,
1.33 matthew 1038: $respid,$resptype,
1039: \&csv_format_item);
1.32 matthew 1040: my $resp_start_idx =
1041: $start_col{$prob->symb}->{$partid}->{$respid};
1.22 matthew 1042: for (my $k=0;$k<=$#data;$k++) {
1.32 matthew 1043: $rows[$j]->[$resp_start_idx + $k] = $data[$k];
1.22 matthew 1044: }
1045: }
1046: }
1.17 matthew 1047: }
1.22 matthew 1048: }
1049: foreach my $row (@rows) {
1050: print $outputfile '"'.join('","',
1051: map { $student->{$_}; }
1052: @student_columns).'"';
1.32 matthew 1053: for (my $i=scalar(@student_columns);$i<$max_column;$i++) {
1.22 matthew 1054: my $value = &Apache::loncommon::csv_translate($row->[$i]);
1055: $value ||='';
1056: print $outputfile ',"'.$value.'"';
1.17 matthew 1057: }
1.22 matthew 1058: print $outputfile $/;
1.17 matthew 1059: }
1.22 matthew 1060: undef(@rows);
1.17 matthew 1061: &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
1062: 'last student');
1063: }
1064: close($outputfile);
1065: #
1066: # Close the progress window
1067: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
1068: #
1.48 bisitz 1069: # Tell the user where to get their CSV file
1.17 matthew 1070: $r->print('<br />'.
1.48 bisitz 1071: '<a href="'.$filename.'">'.&mt('Your CSV file.').'</a>'."\n");
1.17 matthew 1072: $r->rflush();
1073: return;
1074: }
1075:
1.32 matthew 1076: sub csv_format_item {
1077: my ($item,$type) = @_;
1078: if ($type eq 'Time') {
1079: $item = localtime($item);
1.33 matthew 1080: }
1.32 matthew 1081: $item =&Apache::loncommon::csv_translate($item);
1082: return $item;
1.15 matthew 1083: }
1084:
1.1 matthew 1085: #########################################################
1086: #########################################################
1087: ##
1088: ## Generic Interface Routines
1089: ##
1090: #########################################################
1091: #########################################################
1092: sub CreateInterface {
1093: ##
1.16 matthew 1094: ## Output Selection
1.19 matthew 1095: my $output_selector = $/.'<select name="output">'.$/;
1.22 matthew 1096: foreach ('HTML','Excel','CSV') {
1.19 matthew 1097: $output_selector .= ' <option value="'.lc($_).'"';
1.40 albertel 1098: if ($env{'form.output'} eq lc($_)) {
1.19 matthew 1099: $output_selector .= ' selected ';
1.16 matthew 1100: }
1.19 matthew 1101: $output_selector .='>'.&mt($_).'</option>'.$/;
1.16 matthew 1102: }
1.19 matthew 1103: $output_selector .= '</select>'.$/;
1.16 matthew 1104: ##
1.1 matthew 1105: ## Environment variable initialization
1106: my $Str = '';
1.43 albertel 1107: $Str .= &Apache::lonhtmlcommon::breadcrumbs('Student Submission Reports');
1.11 matthew 1108: $Str .= '<p>';
1.50 bisitz 1109: $Str .= &Apache::loncommon::start_data_table();
1110: $Str .= &Apache::loncommon::start_data_table_header_row();
1.16 matthew 1111: $Str .= '<th>'.&mt('Sections').'</th>';
1.44 raeburn 1112: $Str .= '<th>'.&mt('Groups').'</th>';
1.57 ! onken 1113: $Str .= '<th>'.&mt('Student Data').&Apache::loncommon::help_open_topic("Chart_Student_Data").'</th>';
1.46 raeburn 1114: $Str .= '<th>'.&mt('Access Status').'</th>';
1.50 bisitz 1115: $Str .= '<th>'.&mt('Options').'</th>';
1116: $Str .= '<th>'.&mt('Output Format').'</th>';
1117: $Str .= &Apache::loncommon::end_data_table_header_row();
1.11 matthew 1118: #
1.50 bisitz 1119: $Str .= &Apache::loncommon::start_data_table_row();
1120: $Str .= '<td align="center">'."\n";
1.1 matthew 1121: $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
1122: $Str .= '</td>';
1123: #
1.44 raeburn 1124: $Str .= '<td align="center">'."\n";
1125: $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
1126: $Str .= '</td>';
1127: #
1.57 ! onken 1128: $Str .= '<td align="center">'."\n";
! 1129: $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple', 5,undef);
! 1130: $Str .= '</td>';
! 1131: #
1.1 matthew 1132: $Str .= '<td align="center">';
1133: $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
1134: $Str .= '</td>';
1.6 matthew 1135: #
1.15 matthew 1136: # Render problem checkbox
1137: my $prob_checkbox = '<input type="checkbox" name="renderprob" ';
1.40 albertel 1138: if (exists($env{'form.renderprob'}) && $env{'form.renderprob'} eq 'true') {
1.50 bisitz 1139: $prob_checkbox .= 'checked="checked" ';
1.15 matthew 1140: }
1141: $prob_checkbox .= 'value="true" />';
1142: #
1143: # Compute correct answers checkbox
1144: my $ans_checkbox = '<input type="checkbox" name="correctans" ';
1.40 albertel 1145: if (exists($env{'form.correctans'}) && $env{'form.correctans'} eq 'true') {
1.50 bisitz 1146: $ans_checkbox .= 'checked="checked" ';
1.13 matthew 1147: }
1.15 matthew 1148: $ans_checkbox .= 'value="true" />';
1149: #
1.19 matthew 1150: # Show all submissions checkbox
1151: my $all_sub_checkbox = '<input type="checkbox" name="all_sub" ';
1.40 albertel 1152: if (exists($env{'form.all_sub'}) &&
1153: $env{'form.all_sub'} eq 'true') {
1.50 bisitz 1154: $all_sub_checkbox .= 'checked="checked" ';
1.15 matthew 1155: }
1.19 matthew 1156: $all_sub_checkbox.= 'value="true" />';
1.15 matthew 1157: #
1.20 matthew 1158: # problem status checkbox
1159: my $prob_status_checkbox = '<input type="checkbox" name="prob_status" ';
1.40 albertel 1160: if (exists($env{'form.prob_status'}) &&
1161: $env{'form.prob_status'} eq 'true') {
1.50 bisitz 1162: $prob_status_checkbox .= 'checked="checked" ';
1.15 matthew 1163: }
1.20 matthew 1164: $prob_status_checkbox .= 'value="true" />';
1.15 matthew 1165: #
1.56 bisitz 1166: $Str .=
1167: '<td valign="top">'
1168: .'<label>'
1169: .$prob_checkbox.&mt('Show problem')
1170: .'</label><br />'
1171: .'<label>'
1172: .' '.$ans_checkbox.&mt('Show correct answers')
1173: .'</label><br />'
1174: .'<label>'
1175: .$all_sub_checkbox.&mt('Show all submissions')
1176: .'</label><br />'
1177: .'<label>'
1178: .$prob_status_checkbox.&mt('Show problem grading')
1179: .'</label>'
1180: .'</td>';
1.13 matthew 1181: #
1.50 bisitz 1182: $Str .= '<td align="center" valign="top">'.$output_selector.'</td>';
1183: #
1184: $Str .= &Apache::loncommon::end_data_table_row();
1185: $Str .= &Apache::loncommon::end_data_table();
1.1 matthew 1186: #
1.49 bisitz 1187: $Str .= '<p><span class="LC_nobreak">'
1188: .&mt('Status: [_1]',
1189: '<input type="text" name="stats_status"'
1190: .' size="60" value="" readonly="readonly" />')
1191: .'</span></p>';
1.52 raeburn 1192: $Str .= '</p>';
1.11 matthew 1193: ##
1.1 matthew 1194: return $Str;
1195: }
1196:
1197: 1;
1198:
1199: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>