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