File:
[LON-CAPA] /
loncom /
interface /
statistics /
lonsurveyreports.pm
Revision
1.26.4.1:
download - view:
text,
annotated -
select for diffs
Sat May 12 03:59:53 2012 UTC (12 years, 3 months ago) by
raeburn
Branches:
version_2_11_X
CVS tags:
version_2_11_5_msu,
version_2_11_5,
version_2_11_4_uiuc,
version_2_11_4_msu,
version_2_11_4,
version_2_11_3_uiuc,
version_2_11_3_msu,
version_2_11_3,
version_2_11_2_uiuc,
version_2_11_2_msu,
version_2_11_2_educog,
version_2_11_2,
version_2_11_1,
version_2_11_0_RC3,
version_2_11_0_RC2,
version_2_11_0_RC1,
version_2_11_0
Diff to branchpoint 1.26:
preferred,
unified
- For 2.11
- Reverse changes in 1.25 - they require "3.0" grading interface.
1: # The LearningOnline Network with CAPA
2: #
3: # $Id: lonsurveyreports.pm,v 1.26.4.1 2012/05/12 03:59:53 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::lonsurveyreports;
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 Spreadsheet::WriteExcel;
38: use HTML::Entities();
39: use Time::Local();
40: use lib '/home/httpd/lib/perl/';
41: use LONCAPA;
42:
43:
44: my @SubmitButtons = (
45: { name => 'break'},
46: { name => 'PrevProblem',
47: text => 'Previous Survey' },
48: { name => 'NextProblem',
49: text => 'Next Survey' },
50: { name => 'SelectAnother',
51: text => 'Choose a different Survey' },
52: { name => 'break'},
53: { name => 'Generate',
54: text => 'Generate Report'},
55: );
56:
57: sub BuildSurveyReportsPage {
58: my ($r,$c)=@_;
59: #
60: my %Saveable_Parameters = ('Status' => 'scalar',
61: 'Section' => 'array',
62: 'NumPlots' => 'scalar',
63: );
64: &Apache::loncommon::store_course_settings('survey_reports',
65: \%Saveable_Parameters);
66: &Apache::loncommon::restore_course_settings('survey_reports',
67: \%Saveable_Parameters);
68: #
69: &Apache::lonstatistics::PrepareClasslist();
70: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Student Submission Reports'));
71:
72: #
73: $r->print(&CreateInterface());
74: #
75: my @Students = @Apache::lonstatistics::Students;
76: #
77: if (@Students < 1) {
78: $r->print('<p class="LC_warning">'.&mt('There are no students in the sections selected.').'</p>');
79: }
80: #
81: my @CacheButtonHTML =
82: &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status');
83: $r->rflush();
84: #
85: if (exists($env{'form.problemchoice'}) &&
86: ! exists($env{'form.SelectAnother'})) {
87: $r->print(' 'x3);
88: foreach my $button (@SubmitButtons) {
89: if ($button->{'name'} eq 'break') {
90: $r->print("<br />\n");
91: } else {
92: $r->print('<input type="submit" name="'.$button->{'name'}.'" '.
93: 'value="'.&mt($button->{'text'}).'" />');
94: $r->print(' 'x5);
95: }
96: }
97: foreach my $html (@CacheButtonHTML) {
98: $r->print($html.(' 'x5));
99: }
100: #
101: $r->print('<hr />');
102: $r->print('<h4>'.
103: &Apache::lonlocal::locallocaltime(time).', '.
104: &Apache::lonstatistics::section_and_enrollment_description().
105: '</h4>');
106: $r->rflush();
107: #
108: # Determine which problem we are to analyze
109: my $current_problem = &Apache::lonstathelpers::get_target_from_id
110: ($env{'form.problemchoice'});
111: #
112: my ($navmap,$prev,$curr,$next) =
113: &Apache::lonstathelpers::get_prev_curr_next($current_problem,
114: '.',
115: 'part_survey',
116: );
117: if (exists($env{'form.PrevProblem'}) && defined($prev)) {
118: $current_problem = $prev;
119: } elsif (exists($env{'form.NextProblem'}) && defined($next)) {
120: $current_problem = $next;
121: } else {
122: $current_problem = $curr;
123: }
124: #
125: # Store the current problem choice and send it out in the form
126: $env{'form.problemchoice'} =
127: &Apache::lonstathelpers::make_target_id($current_problem);
128: $r->print('<input type="hidden" name="problemchoice" value="'.
129: $env{'form.problemchoice'}.'" />');
130: #
131: if (! defined($current_problem->{'resource'})) {
132: $r->print('resource is undefined');
133: } else {
134: my $resource = $current_problem->{'resource'};
135: $r->print('<h1>'.$resource->compTitle.'</h1>');
136: $r->print('<h3>'.$resource->src.'</h3>');
137: if ($env{'form.renderprob'} eq 'true') {
138: $r->print('<hr />'
139: .&Apache::lonstathelpers::render_resource($resource)
140: .'<hr />'
141: );
142: }
143: $r->rflush();
144: my %Data = &Apache::lonstathelpers::get_problem_data
145: ($resource->src);
146: &compile_student_answers($r,$current_problem,\%Data,\@Students);
147: if ($env{'form.output'} eq 'HTML' ||
148: ! defined($env{'form.output'})) {
149: &make_HTML_report($r,$current_problem,\%Data,\@Students);
150: } elsif ($env{'form.output'} eq 'Excel') {
151: &make_Excel_report($r,$current_problem,\%Data,\@Students);
152: } elsif ($env{'form.output'} eq 'TXT') {
153: &make_text_report($r,$current_problem,\%Data,\@Students);
154: }
155: }
156: $r->print('<hr />');
157: } else {
158: $r->print('<input type="submit" name="Generate" value="'.
159: &mt('Generate Survey Report').'" />');
160: $r->print(' 'x5);
161: $r->print('<h3>'.&mt('Please select a Survey to analyze').'</h3>');
162: $r->print(&SurveyProblemSelector());
163: }
164: }
165:
166: ##########################################################
167: ##########################################################
168: ##
169: ## SurveyProblemSelector
170: ##
171: ##########################################################
172: ##########################################################
173: sub SurveyProblemSelector {
174: my $Str = '';
175: my @SurveyProblems;
176: my ($navmap,@sequences) =
177: &Apache::lonstatistics::selected_sequences_with_assessments('all');
178: foreach my $seq (@sequences) {
179: my @resources = &Apache::lonstathelpers::get_resources($navmap,$seq);
180: foreach my $res (@resources) {
181: foreach my $part (@{$res->parts}) {
182: if (($res->is_survey($part)) || ($res->is_anonsurvey($part))) {
183: push(@SurveyProblems,{res=>$res,seq=>$seq,part=>$part});
184: last;
185: }
186: }
187: }
188: }
189: if (! scalar(@SurveyProblems)) {
190: $Str = '<p class="LC_warning">'.
191: &mt('There are no survey problems in this course.').
192: '</p>'.$/;
193: return $Str;
194: }
195: $Str .= '<table>'.$/;
196: $Str .= '<tr>'.'<td></td>'.
197: '<th>'.&mt('Survey').'</th>'.
198: '</tr>'.$/;
199: my $id;
200: foreach my $problem (@SurveyProblems) {
201: $id++;
202: my $value = &Apache::lonstathelpers::make_target_id
203: ({symb=>$problem->{'res'}->symb,
204: part=>$problem->{'part'},
205: respid=>undef,
206: resptype=>undef});
207: my $checked = '';
208: if ($env{'form.problemchoice'} eq $value) {
209: $checked = 'checked="checked" ';
210: }
211: my $link = $problem->{'res'}->link.
212: '?symb='.&escape($problem->{'res'}->shown_symb);
213: $Str .= '<tr><td>'.
214: '<input type="radio" name="problemchoice" id="'.$id.'" '.
215: 'value="'.$value.'" '.$checked.'/>'.'</td>'.
216: '<td><span class="LC_nobreak">'.
217: '<label for="'.$id.'">'.$problem->{'res'}->compTitle.' ('.$problem->{'seq'}->compTitle.')'.'</label>'.
218: (' 'x2).
219: '<a target="preview" href="'.$link.'">'.&mt('View survey').'</a></span></td></tr>'.$/;
220: }
221: $Str .= '</table>';
222: return $Str;
223: }
224:
225: #########################################################
226: #########################################################
227: ##
228: ## Compile Student Answers
229: ##
230: #########################################################
231: #########################################################
232: sub compile_student_answers {
233: my ($r,$problem,$ProblemData,$Students) = @_;
234: my $resource = $problem->{'resource'};
235: my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,scalar(@$Students));
236: foreach my $student (@$Students) {
237: foreach my $partid (@{$resource->parts}) {
238: my @response_ids = $resource->responseIds($partid);
239: my @response_types = $resource->responseType($partid);
240: for (my $i=0;$i<=$#response_ids;$i++) {
241: my $respid = $response_ids[$i];
242: my $resptype = $response_types[$i];
243: my $results =
244: &Apache::loncoursedata::get_response_data_by_student
245: ($student,$resource->symb,$respid);
246: next if (! defined($results) || ref($results) ne 'ARRAY' ||
247: ref($results->[0]) ne 'ARRAY');
248: my $student_response =
249: $results->[0]->[&Apache::loncoursedata::RDs_submission()];
250: $problem->{'responsedata'}->{$partid}->{$respid}->{'_count'}++;
251: my $data = $problem->{'responsedata'}->{$partid}->{$respid};
252: if ($resptype =~ /^(option|match)$/) {
253: my @responses = split('&',$student_response);
254: foreach my $response (@responses) {
255: my ($foilid,$option) =
256: map {
257: &unescape($_);
258: } split('=',$response);
259: $data->{'foil_count'}->{$foilid}++;
260: $data->{'foil_responses'}->{$foilid}->{$option}++;
261: }
262: } elsif ($resptype =~ /^(radiobutton)$/) {
263: my ($foil,$value) = map { &unescape($_); } split('=',$student_response);
264: $value += 1; # explicitly increment it...
265: $data->{'foil_responses'}->{$foil}++;
266: $data->{'foil_values'}->{$value}++;
267: if (! exists($data->{'map'}->{$value})) {
268: $data->{'map'}->{$value} = $foil;
269: $data->{'map_fv'}->{$foil} = $value;
270: }
271: } else {
272: # Variable stuff (essays, raw numbers, strings) go here
273: push(@{$data->{'responses'}},$student_response);
274: }
275: }
276: }
277: &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student');
278: }
279: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
280: return;
281: }
282:
283:
284: #########################################################
285: #########################################################
286: ##
287: ## make_text_report
288: ##
289: #########################################################
290: #########################################################
291: sub make_text_report {
292: my ($r,$problem,$problem_data,$students) = @_;
293: my ($file,$filename) = &Apache::loncommon::create_text_file($r,'txt');
294: if (! defined($file)) { return '';}
295: $r->print('<script>'.
296: 'window.document.Statistics.stats_status.value="'.
297: &mt('Building text document.').
298: '";</script>');
299: my $resource = $problem->{'resource'};
300: print $file $resource->compTitle.$/;
301: print $file &Apache::lonstatistics::section_and_enrollment_description().
302: ' '.&mt('Generated on [_1]',&Apache::lonlocal::locallocaltime(time)).
303: $/;
304: my $something_has_been_output = 0;
305: foreach my $partid (@{$resource->parts}) {
306: my @response_ids = $resource->responseIds($partid);
307: my @response_types = $resource->responseType($partid);
308: for (my $i=0;$i<=$#response_ids;$i++) {
309: my $respid = $response_ids[$i];
310: my $resptype = $response_types[$i];
311: my $data = $problem->{'responsedata'}->{$partid}->{$respid};
312: if (exists($data->{'responses'}) &&
313: ref($data->{'responses'}) eq 'ARRAY') {
314: # Essay type response
315: print $file ('-'x40).$/;
316: print $file
317: $resource->part_display($partid).', '.$respid.':'.$resptype.$/;
318: foreach my $submission (@{$data->{'responses'}}) {
319: print $file ('-'x20).$/;
320: $submission =~ s/(\\r\\n|\\n)/\n/g;
321: $submission =~ s/\\(\'|\"|\`)/$1/g;
322: print $file $submission.$/.$/;
323: $something_has_been_output=1;
324: }
325: }
326: }
327: }
328: close($file);
329: if($something_has_been_output) {
330: $r->print('<p class="LC_info"><a href="'.$filename.'">'.
331: &mt('Your text file').
332: '</a></p>'."\n");
333: $r->print('<script>'.
334: 'window.document.Statistics.stats_status.value="'.
335: &mt('Done compiling text file. See link below to download.').
336: '";</script>');
337: } else {
338: $r->print('<p class="LC_warning">'
339: .&mt('There is no essay or string response data to output for this survey.')
340: .'</p>');
341: }
342: $r->rflush();
343: return;
344: }
345:
346:
347: #########################################################
348: #########################################################
349: ##
350: ## make_Excel_report
351: ##
352: #########################################################
353: #########################################################
354: sub make_Excel_report {
355: my ($r,$problem,$problem_data,$students) = @_;
356: my ($workbook,$filename,$format) = &Apache::loncommon::create_workbook($r);
357: if (! defined($workbook)) { return '';}
358: $r->print('<script>'.
359: 'window.document.Statistics.stats_status.value="'.
360: &mt('Building spreadsheet.').
361: '";</script>');
362: my $worksheet = $workbook->addworksheet('Survey Reports');
363: #
364: my $rows_output=0;
365: $worksheet->write($rows_output++,0,
366: $env{'course.'.$env{'request.course.id'}.'.description'},
367: $format->{'h1'});
368: $rows_output++;
369: #
370: my $resource = $problem->{'resource'};
371: $worksheet->write($rows_output++,0,$resource->compTitle,$format->{'h2'});
372: foreach my $partid (@{$resource->parts}) {
373: my @response_ids = $resource->responseIds($partid);
374: my @response_types = $resource->responseType($partid);
375: for (my $i=0;$i<=$#response_ids;$i++) {
376: my $respid = $response_ids[$i];
377: my $resptype = $response_types[$i];
378: my $data = $problem->{'responsedata'}->{$partid}->{$respid};
379: my $cols_output=0;
380: $worksheet->write($rows_output,$cols_output++,
381: $resource->part_display($partid),$format->{'h3'});
382: $worksheet->write($rows_output,$cols_output++,
383: 'Response '.$respid.', '.$resptype,
384: $format->{'h3'});
385: $rows_output++;
386: if (exists($data->{'responses'}) &&
387: ref($data->{'responses'}) eq 'ARRAY') {
388: my $warned_about_size = 0;
389: foreach my $data (@{$data->{'responses'}}) {
390: if (length($data) > 255 && ! $warned_about_size) {
391: $r->print('<p class="LC_warning">'.
392: &mt('[_1]:[_2] responses to [_3] may be too long to fit Excel spreadsheet.',
393: $resource->compTitle,
394: $resource->part_display($partid),
395: $respid).
396: '</p>');
397: $r->rflush();
398: $warned_about_size=1;
399: }
400: $worksheet->write($rows_output++,0,$data);
401: }
402: } elsif (exists($data->{'foil_count'}) &&
403: exists($data->{'foil_responses'})) {
404: my $respdata = $problem_data->{$partid.'.'.$respid};
405: my @rowdata = ('Foil Name','Foil Text','Option',
406: 'Frequency');
407: $worksheet->write_row($rows_output++,0,
408: \@rowdata,$format->{'h4'});
409: #
410: my @foils = sort(keys(%{$respdata->{'_Foils'}}));
411: foreach my $foilid (@foils) {
412: my $foil_count = $data->{'foil_count'}->{$foilid};
413: my $foiltext = $respdata->{'_Foils'}->{$foilid}->{'text'};
414: my $foilname = $respdata->{'_Foils'}->{$foilid}->{'name'};
415: $foiltext = &HTML::Entities::decode($foilname);
416: my $cols_output=0;
417: $worksheet->write($rows_output,$cols_output++,$foilname);
418: $worksheet->write($rows_output,$cols_output++,$foiltext);
419: my $option_start_col = $cols_output;
420: #
421: foreach my $option (sort(@{$respdata->{'_Options'}})){
422: $cols_output= $option_start_col;
423: $worksheet->write($rows_output,$cols_output++,
424: $option);
425: my $count=
426: $data->{'foil_responses'}->{$foilid}->{$option};
427: $worksheet->write($rows_output,$cols_output++,$count);
428: $rows_output++;
429: }
430: }
431: } elsif (exists($data->{'_count'}) &&
432: exists($data->{'foil_values'}) &&
433: exists($data->{'map'})) {
434: my $respdata = $problem_data->{$partid.'.'.$respid};
435: my @rowdata = ('Foil Name','Foil Text','Frequency');
436: $worksheet->write_row($rows_output++,0,
437: \@rowdata,$format->{'h4'});
438: my @foils = sort(keys(%{$respdata->{'_Foils'}}));
439: foreach my $foilid (@foils) {
440: undef(@rowdata);
441: my $value = $data->{'map_fv'}->{$foilid};
442: push(@rowdata,$respdata->{'_Foils'}->{$foilid}->{'name'});
443: push(@rowdata,$respdata->{'_Foils'}->{$foilid}->{'text'});
444: push(@rowdata,$data->{'foil_values'}->{$value});
445: $worksheet->write_row($rows_output++,0,\@rowdata);
446: }
447: }
448: $rows_output++;
449: } #response ids
450: } # partids
451: $workbook->close();
452: $r->print('<p class="LC_info"><a href="'.$filename.'">'.
453: &mt('Your Excel spreadsheet.').
454: '</a></p>'."\n");
455: $r->print('<script>'.
456: 'window.document.Statistics.stats_status.value="'.
457: &mt('Done compiling spreadsheet. See link below to download.').
458: '";</script>');
459: $r->rflush();
460: return;
461: }
462:
463: #########################################################
464: #########################################################
465: ##
466: ## make_HTML_report
467: ##
468: #########################################################
469: #########################################################
470: sub make_HTML_report {
471: my ($r,$problem,$ProblemData,$Students) = @_;
472: my $resource = $problem->{'resource'};
473: foreach my $partid (@{$resource->parts}) {
474: my @response_ids = $resource->responseIds($partid);
475: my @response_types = $resource->responseType($partid);
476: for (my $i=0;$i<=$#response_ids;$i++) {
477: my $Str = '<table>'.$/;
478: my $respid = $response_ids[$i];
479: my $resptype = $response_types[$i];
480: my $data = $problem->{'responsedata'}->{$partid}->{$respid};
481: if (! defined($data) || ref($data) ne 'HASH') {
482: next;
483: }
484: # Debugging code
485: # $Str .= '<tr>'.
486: # '<td>'.$partid.'</td>'.
487: # '<td>'.$respid.'</td>'.
488: # '<td>'.$resptype.'</td>'.
489: # '</tr>'.$/;
490: $Str .= '<tr>'.
491: '<td><b>'.&mt('Total').'</b></td>'.
492: '<td>'.$data->{'_count'}.'</td>'.
493: '<td>'.&mt('Part [_1], Response [_2]',
494: $resource->part_display($partid),$respid).'</td>'.
495: '</tr>';
496: if (exists($data->{'responses'}) &&
497: ref($data->{'responses'}) eq 'ARRAY') {
498: &randomize_array($data->{'responses'});
499: foreach my $response (@{$data->{'responses'}}) {
500: $response =~ s/\\r\\n/\n/g;
501: $response =~ s/\\'/'/g;
502: $response =~ s/\\"/"/g;
503: $Str .= '<tr>'.
504: '<td colspan="3"><pre>'.
505: &HTML::Entities::encode($response,'<>&').
506: '</pre><hr /></td>'.
507: '</tr>'.$/;
508: }
509: } elsif (exists($data->{'foil_count'}) &&
510: exists($data->{'foil_responses'})) {
511: $Str.='<tr>'
512: .'<td colspan="3">'
513: .&Apache::loncommon::start_data_table()
514: .&Apache::loncommon::start_data_table_header_row();
515: my $tmp = '<th>'.join('</th><th>',
516: (&mt('Foil Name'),
517: &mt('Foil Text'),
518: &mt('Option'),
519: &mt('Frequency'),
520: &mt('Percent'))).'</th>'
521: .&Apache::loncommon::end_data_table_header_row();
522: my @foils = sort(keys(%{$ProblemData->{$partid.'.'.$respid}->{'_Foils'}}));
523: foreach my $foilid (@foils) {
524: my $prob_data = $ProblemData->{$partid.'.'.$respid};
525: my $foil_count = $data->{'foil_count'}->{$foilid};
526: my $foiltext = $prob_data->{'_Foils'}->{$foilid}->{'text'};
527: my $foilname = $prob_data->{'_Foils'}->{$foilid}->{'name'};
528: my $rowspan = scalar(@{$prob_data->{'_Options'}});
529: my $preamble = &Apache::loncommon::start_data_table_row().
530: '<td valign="top" rowspan="'.$rowspan.'">'.
531: $foilname.'</td>'.
532: '<td valign="top" rowspan="'.$rowspan.'">'.
533: $foiltext.'</td>';
534: foreach my $option (sort(@{$prob_data->{'_Options'}})){
535: my $count =
536: $data->{'foil_responses'}->{$foilid}->{$option};
537: $tmp .= $preamble.
538: '<td>'.$option.'</td>'.
539: '<td align="right">'.$count.'</td>'.
540: '<td align="right">'.
541: sprintf('%.2f',100*$count/$foil_count).'%'.
542: '</td>'.&Apache::loncommon::end_data_table_row().$/;
543: $preamble = &Apache::loncommon::continue_data_table_row(); #&Apache::loncommon::start_data_table_row();
544: }
545: }
546: $Str.=$tmp.&Apache::loncommon::end_data_table()
547: .'</td></tr>';
548: } elsif (exists($data->{'_count'}) &&
549: exists($data->{'foil_values'}) &&
550: exists($data->{'map'})) {
551: # This is an option or radiobutton survey response
552: my $total = $data->{'_count'};
553: my $sum = 0;
554: my $tmp;
555: my @foils = sort(keys(%{$ProblemData->{$partid.'.'.$respid}
556: ->{'_Foils'}}));
557: foreach my $foilid (@foils) {
558: my $value = $data->{'map_fv'}->{$foilid};
559: my $count = $data->{'foil_values'}->{$value};
560: my $foiltext = $ProblemData->{$partid.'.'.$respid}->{'_Foils'}->{$foilid}->{'text'};
561: my $foilname = $ProblemData->{$partid.'.'.$respid}->{'_Foils'}->{$foilid}->{'name'};
562: $tmp .= &Apache::loncommon::start_data_table_row().
563: '<td>'.$foilname.'</td>'.
564: '<td>'.$foiltext.'</td>'.
565: '<td align="right">'.$count.'</td>'.
566: '<td align="right">'.
567: sprintf("%.2f",$count/$total*100).'%</td>'.
568: &Apache::loncommon::end_data_table_row().$/;
569: }
570: $Str.='<tr>'
571: .'<td colspan="3">'
572: .&Apache::loncommon::start_data_table()
573: .&Apache::loncommon::start_data_table_header_row()
574: .'<th>'.&mt('Foil Name').'</th>'
575: .'<th>'.&mt('Text').'</th>'
576: .'<th>'.&mt('Frequency').'</th>'
577: .'<th>'.&mt('Percent').'</th>'
578: .&Apache::loncommon::end_data_table_header_row().$/
579: .$tmp
580: .&Apache::loncommon::end_data_table()
581: .'</td></tr>';
582: }
583: $Str.= '</table>';
584: $r->print($Str);
585: $r->rflush();
586: }
587: }
588: return;
589: }
590:
591: sub randomize_array {
592: # Fisher Yates shuffle, lifted from p 121 of "The Perl Cookbook"
593: my ($array) = @_;
594: for (my $i=scalar(@$array);--$i;) {
595: my $j = int(rand($i+1));
596: next if ($i == $j);
597: @$array[$i,$j]=@$array[$j,$i];
598: }
599: }
600:
601: #########################################################
602: #########################################################
603: ##
604: ## Generic Interface Routines
605: ##
606: #########################################################
607: #########################################################
608: sub CreateInterface {
609: ##
610: ## Environment variable initialization
611: my $Str = '';
612: my $output_selector = '<select name="output" size="5">'.$/;
613: if (! exists($env{'form.output'})) {
614: $env{'form.output'} = 'HTML';
615: }
616: foreach my $output_format ( {name=>'HTML',text=>&mt("HTML") },
617: {name=>'Excel',text=>&mt("Excel") },
618: {name=>'TXT',text=>&mt("Text (essays only)") },
619: ) {
620: $output_selector.='<option value="'.$output_format->{'name'}.'"';
621: if ($env{'form.output'} eq $output_format->{'name'}) {
622: $output_selector.=' selected="selected"';
623: }
624: $output_selector.= '>'.$output_format->{'text'}.'</option>'.$/;
625: }
626: $output_selector .= '</select>'.$/;
627: $Str .= '<p>';
628: $Str .= &Apache::loncommon::start_data_table();
629: $Str .= &Apache::loncommon::start_data_table_header_row();
630: $Str .= '<th>'.&mt('Sections').'</th>';
631: $Str .= '<th>'.&mt('Groups').'</th>';
632: $Str .= '<th>'.&mt('Access Status').'</th>';
633: $Str .= '<th>'.&mt('Output Format').'</th>';
634: $Str .= '<th>'.&mt('Options').'</th>';
635: $Str .= &Apache::loncommon::end_data_table_header_row();
636: #
637: $Str .= &Apache::loncommon::start_data_table_row();
638: $Str .= '<td align="center">'."\n";
639: $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
640: $Str .= '</td>';
641: #
642: $Str .= '<td align="center">'."\n";
643: $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
644: $Str .= '</td>';
645: #
646: $Str .= '<td align="center">';
647: $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
648: $Str .= '</td>';
649: #
650: $Str .= '<td align="center">'.$output_selector.'</td>';
651: #
652: # Render problem checkbox
653: my $prob_checkbox = '<input type="checkbox" name="renderprob" ';
654: if (exists($env{'form.renderprob'}) && $env{'form.renderprob'} eq 'true') {
655: $prob_checkbox .= 'checked="checked" ';
656: }
657: $prob_checkbox .= 'value="true" />';
658: $Str .=
659: '<td valign="top">'
660: .'<label>'
661: .$prob_checkbox.&mt('Show problem')
662: .'</label>'
663: .'</td>';
664: #
665: $Str .= &Apache::loncommon::end_data_table_row();
666: $Str .= &Apache::loncommon::end_data_table();
667: #
668: $Str .= '</p>';
669: ##
670: return $Str;
671: }
672:
673: 1;
674:
675: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>