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