Annotation of loncom/interface/statistics/lonstudentassessment.pm, revision 1.165
1.1 stredwic 1: # The LearningOnline Network with CAPA
2: #
1.165 ! www 3: # $Id: lonstudentassessment.pm,v 1.164 2011/10/05 18:56:00 raeburn Exp $
1.1 stredwic 4: #
5: # Copyright Michigan State University Board of Trustees
6: #
7: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
8: # LON-CAPA is free software; you can redistribute it and/or modify
9: # it under the terms of the GNU General Public License as published by
10: # the Free Software Foundation; either version 2 of the License, or
11: # (at your option) any later version.
12: #
13: # LON-CAPA is distributed in the hope that it will be useful,
14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: # GNU General Public License for more details.
17: #
18: # You should have received a copy of the GNU General Public License
19: # along with LON-CAPA; if not, write to the Free Software
20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21: #
22: # /home/httpd/html/adm/gpl.txt
23: #
24: # http://www.lon-capa.org/
25: #
26: # (Navigate problems for statistical reports
1.28 matthew 27: #
28: #######################################################
29: #######################################################
30:
31: =pod
32:
33: =head1 NAME
34:
35: lonstudentassessment
36:
37: =head1 SYNOPSIS
38:
39: Presents assessment data about a student or a group of students.
40:
41: =head1 Subroutines
42:
43: =over 4
44:
45: =cut
46:
47: #######################################################
48: #######################################################
1.1 stredwic 49:
1.21 minaeibi 50: package Apache::lonstudentassessment;
1.1 stredwic 51:
52: use strict;
1.136 albertel 53: use Apache::lonstatistics();
1.163 www 54: use Apache::lonquickgrades();
1.136 albertel 55: use Apache::lonhtmlcommon();
1.77 matthew 56: use Apache::loncommon();
1.1 stredwic 57: use Apache::loncoursedata;
1.28 matthew 58: use Apache::lonnet; # for logging porpoises
1.75 matthew 59: use Apache::lonlocal;
1.136 albertel 60: use Apache::grades();
61: use Apache::lonmsgdisplay();
1.112 matthew 62: use Time::HiRes;
1.31 matthew 63: use Spreadsheet::WriteExcel;
1.76 matthew 64: use Spreadsheet::WriteExcel::Utility();
1.140 www 65: use lib '/home/httpd/lib/perl/';
66: use LONCAPA;
67:
1.31 matthew 68:
69: #######################################################
70: #######################################################
71: =pod
72:
73: =item Package Variables
74:
75: =over 4
76:
77: =item $Statistics Hash ref to store student data. Indexed by symb,
78: contains hashes with keys 'score' and 'max'.
79:
80: =cut
81:
82: #######################################################
83: #######################################################
1.1 stredwic 84:
1.30 matthew 85: my $Statistics;
86:
1.28 matthew 87: #######################################################
88: #######################################################
89:
90: =pod
91:
1.31 matthew 92: =item $show_links 'yes' or 'no' for linking to student performance data
93:
94: =item $output_mode 'html', 'excel', or 'csv' for output mode
95:
1.32 matthew 96: =item $show 'all', 'totals', or 'scores' determines how much data is output
1.31 matthew 97:
1.49 matthew 98: =item $single_student_mode evaluates to true if we are showing only one
99: student.
100:
1.31 matthew 101: =cut
102:
103: #######################################################
104: #######################################################
105: my $show_links;
106: my $output_mode;
1.87 matthew 107: my $chosen_output;
1.49 matthew 108: my $single_student_mode;
1.28 matthew 109:
1.31 matthew 110: #######################################################
111: #######################################################
112: # End of package variable declarations
1.28 matthew 113:
1.31 matthew 114: =pod
1.28 matthew 115:
1.31 matthew 116: =back
1.28 matthew 117:
1.31 matthew 118: =cut
1.28 matthew 119:
1.31 matthew 120: #######################################################
121: #######################################################
1.28 matthew 122:
1.31 matthew 123: =pod
1.28 matthew 124:
1.31 matthew 125: =item &BuildStudentAssessmentPage()
1.28 matthew 126:
1.31 matthew 127: Inputs:
1.4 stredwic 128:
1.31 matthew 129: =over 4
1.28 matthew 130:
131: =item $r Apache Request
132:
133: =item $c Apache Connection
134:
135: =back
136:
137: =cut
138:
139: #######################################################
140: #######################################################
1.1 stredwic 141: sub BuildStudentAssessmentPage {
1.30 matthew 142: my ($r,$c)=@_;
1.74 matthew 143: #
1.30 matthew 144: undef($Statistics);
1.66 matthew 145: undef($show_links);
146: undef($output_mode);
1.87 matthew 147: undef($chosen_output);
1.66 matthew 148: undef($single_student_mode);
1.74 matthew 149: #
150: my %Saveable_Parameters = ('Status' => 'scalar',
151: 'chartoutputmode' => 'scalar',
152: 'chartoutputdata' => 'scalar',
153: 'Section' => 'array',
1.139 raeburn 154: 'Groups' => 'array',
1.74 matthew 155: 'StudentData' => 'array',
156: 'Maps' => 'array');
157: &Apache::loncommon::store_course_settings('chart',\%Saveable_Parameters);
158: &Apache::loncommon::restore_course_settings('chart',\%Saveable_Parameters);
159: #
160: &Apache::lonstatistics::PrepareClasslist();
161: #
1.65 matthew 162: $single_student_mode = 0;
1.121 albertel 163: $single_student_mode = 1 if ($env{'form.SelectedStudent'});
1.100 matthew 164: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
165: ['selectstudent']);
1.121 albertel 166: if ($env{'form.selectstudent'}) {
1.59 matthew 167: &Apache::lonstatistics::DisplayClasslist($r);
168: return;
169: }
1.163 www 170: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Chart','Chart_Description:Chart_Sections:Chart_Student_Data:Chart_Enrollment_Status:Chart_Sequences:Chart_Output_Formats:Chart_Output_Data'));
171: &Apache::lonquickgrades::startGradeScreen($r,'chart');
172:
1.30 matthew 173: #
1.31 matthew 174: # Print out the HTML headers for the interface
175: # This also parses the output mode selector
1.54 matthew 176: # This step must *always* be done.
1.30 matthew 177: $r->print(&CreateInterface());
1.31 matthew 178: $r->print('<input type="hidden" name="notfirstrun" value="true" />');
1.49 matthew 179: $r->print('<input type="hidden" name="sort" value="'.
1.121 albertel 180: $env{'form.sort'}.'" />');
1.7 stredwic 181: $r->rflush();
1.58 matthew 182: #
1.121 albertel 183: if (! exists($env{'form.notfirstrun'}) && ! $single_student_mode) {
1.31 matthew 184: return;
185: }
1.119 matthew 186: $r->print('<h4>'.
187: &Apache::lonstatistics::section_and_enrollment_description().
188: '</h4>');
1.31 matthew 189: #
190: my $initialize = \&html_initialize;
191: my $output_student = \&html_outputstudent;
192: my $finish = \&html_finish;
193: #
194: if ($output_mode eq 'excel') {
195: $initialize = \&excel_initialize;
196: $output_student = \&excel_outputstudent;
197: $finish = \&excel_finish;
198: } elsif ($output_mode eq 'csv') {
199: $initialize = \&csv_initialize;
200: $output_student = \&csv_outputstudent;
201: $finish = \&csv_finish;
202: }
1.30 matthew 203: #
204: if($c->aborted()) { return ; }
1.31 matthew 205: #
1.49 matthew 206: # Determine which students we want to look at
207: my @Students;
208: if ($single_student_mode) {
209: @Students = (&Apache::lonstatistics::current_student());
210: $r->print(&next_and_previous_buttons());
211: $r->rflush();
212: } else {
213: @Students = @Apache::lonstatistics::Students;
214: }
1.56 matthew 215: #
216: # Perform generic initialization tasks
217: # Since we use lonnet::EXT to retrieve problem weights,
218: # to ensure current data we must clear the caches out.
219: # This makes sure that parameter changes at the student level
220: # are immediately reflected in the chart.
221: &Apache::lonnet::clear_EXT_cache_status();
1.69 matthew 222: #
223: # Clean out loncoursedata's package data, just to be safe.
224: &Apache::loncoursedata::clear_internal_caches();
1.49 matthew 225: #
1.31 matthew 226: # Call the initialize routine selected above
227: $initialize->($r);
1.49 matthew 228: foreach my $student (@Students) {
1.31 matthew 229: if($c->aborted()) {
230: $finish->($r);
231: return ;
1.1 stredwic 232: }
1.31 matthew 233: # Call the output_student routine selected above
234: $output_student->($r,$student);
235: }
236: # Call the "finish" routine selected above
1.163 www 237: &Apache::lonquickgrades::endGradeScreen($r);
1.31 matthew 238: $finish->($r);
239: #
240: return;
241: }
242:
243: #######################################################
244: #######################################################
1.49 matthew 245: sub next_and_previous_buttons {
246: my $Str = '';
247: $Str .= '<input type="hidden" name="SelectedStudent" value="'.
1.121 albertel 248: $env{'form.SelectedStudent'}.'" />';
1.49 matthew 249: #
250: # Build the previous student link
251: my $previous = &Apache::lonstatistics::previous_student();
252: my $previousbutton = '';
253: if (defined($previous)) {
254: my $sname = $previous->{'username'}.':'.$previous->{'domain'};
255: $previousbutton .= '<input type="button" value="'.
1.155 bisitz 256: &mt('Previous Student ([_1])',
257: $previous->{'username'}.':'.$previous->{'domain'}).
1.49 matthew 258: '" onclick="document.Statistics.SelectedStudent.value='.
259: "'".$sname."'".';'.
260: 'document.Statistics.submit();" />';
261: } else {
262: $previousbutton .= '<input type="button" value="'.
1.155 bisitz 263: &mt('Previous Student').'" disabled="disabled" />';
1.49 matthew 264: }
265: #
266: # Build the next student link
267: my $next = &Apache::lonstatistics::next_student();
268: my $nextbutton = '';
269: if (defined($next)) {
270: my $sname = $next->{'username'}.':'.$next->{'domain'};
271: $nextbutton .= '<input type="button" value="'.
1.155 bisitz 272: &mt('Next Student ([_1])',
273: $next->{'username'}.':'.$next->{'domain'}).
1.49 matthew 274: '" onclick="document.Statistics.SelectedStudent.value='.
275: "'".$sname."'".';'.
276: 'document.Statistics.submit();" />';
277: } else {
278: $nextbutton .= '<input type="button" value="'.
1.155 bisitz 279: &mt('Next Student').'" disabled="disabled" />';
1.49 matthew 280: }
281: #
282: # Build the 'all students' button
283: my $all = '';
1.155 bisitz 284: $all .= '<input type="button" value="'.&mt('All Students').'" '.
1.49 matthew 285: '" onclick="document.Statistics.SelectedStudent.value='.
286: "''".';'.'document.Statistics.submit();" />';
287: $Str .= $previousbutton.(' 'x5).$all.(' 'x5).$nextbutton;
288: return $Str;
289: }
290:
291: #######################################################
292: #######################################################
1.30 matthew 293:
1.31 matthew 294: sub get_student_fields_to_show {
295: my @to_show = @Apache::lonstatistics::SelectedStudentData;
296: foreach (@to_show) {
297: if ($_ eq 'all') {
298: @to_show = @Apache::lonstatistics::StudentDataOrder;
299: last;
300: }
301: }
302: return @to_show;
303: }
304:
1.28 matthew 305: #######################################################
306: #######################################################
307:
308: =pod
1.2 stredwic 309:
1.28 matthew 310: =item &CreateInterface()
1.21 minaeibi 311:
1.28 matthew 312: Called by &BuildStudentAssessmentPage to create the top part of the
313: page which displays the chart.
314:
1.30 matthew 315: Inputs: None
1.28 matthew 316:
317: Returns: A string containing the HTML for the headers and top table for
318: the chart page.
319:
320: =cut
321:
322: #######################################################
323: #######################################################
1.2 stredwic 324: sub CreateInterface {
1.4 stredwic 325: my $Str = '';
1.30 matthew 326: $Str .= '<table cellspacing="5">'."\n";
327: $Str .= '<tr>';
1.141 albertel 328: $Str .= '<td align="center"><b>'.&mt('Sections').'</b>'.
329: &Apache::loncommon::help_open_topic("Chart_Sections").
330: '</td>';
331: $Str .= '<td align="center"><b>'.&mt('Groups').'</b>'.
332: '</td>';
1.157 bisitz 333: $Str .= '<td align="center"><b>'.&mt('Student Data').'</b>'.
1.141 albertel 334: &Apache::loncommon::help_open_topic("Chart_Student_Data").
335: '</td>';
1.143 raeburn 336: $Str .= '<td align="center"><b>'.&mt('Access Status').'</b>'.
1.141 albertel 337: &Apache::loncommon::help_open_topic("Chart_Enrollment_Status").
338: '</td>';
339: $Str .= '<td align="center"><b>'.&mt('Sequences and Folders').'</b>'.
340: &Apache::loncommon::help_open_topic("Chart_Sequences").
341: '</td>';
1.75 matthew 342: $Str .= '<td align="center"><b>'.&mt('Output Format').'</b>'.
1.58 matthew 343: &Apache::loncommon::help_open_topic("Chart_Output_Formats").
344: '</td>';
1.75 matthew 345: $Str .= '<td align="center"><b>'.&mt('Output Data').'</b>'.
1.58 matthew 346: &Apache::loncommon::help_open_topic("Chart_Output_Data").
347: '</td>';
1.30 matthew 348: $Str .= '</tr>'."\n";
349: #
1.4 stredwic 350: $Str .= '<tr><td align="center">'."\n";
1.29 matthew 351: $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
1.4 stredwic 352: $Str .= '</td><td align="center">';
1.139 raeburn 353: $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
354: $Str .= '</td><td align="center">';
1.30 matthew 355: $Str .= &Apache::lonstatistics::StudentDataSelect('StudentData','multiple',
356: 5,undef);
1.46 matthew 357: $Str .= '</td><td>'."\n";
358: $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
1.4 stredwic 359: $Str .= '</td><td>'."\n";
1.112 matthew 360: $Str .= &Apache::lonstatistics::map_select('Maps','multiple,all',5);
1.31 matthew 361: $Str .= '</td><td>'."\n";
362: $Str .= &CreateAndParseOutputSelector();
1.54 matthew 363: $Str .= '</td><td>'."\n";
364: $Str .= &CreateAndParseOutputDataSelector();
1.30 matthew 365: $Str .= '</td></tr>'."\n";
366: $Str .= '</table>'."\n";
1.156 bisitz 367: $Str .= '<p>'
368: .&mt('Status:').' '
369: .'<input type="text" name="stats_status" size="60" value="" readonly="readonly" />'
370: .'</p>';
1.75 matthew 371: $Str .= '<input type="submit" name="selectstudent" value="'.
372: &mt('Select One Student').'" />';
1.59 matthew 373: $Str .= ' 'x5;
1.75 matthew 374: $Str .= '<input type="submit" name="ClearCache" value="'.
375: &mt('Clear Caches').'" />';
1.156 bisitz 376: $Str .= '<p>'
377: .'<input type="submit" name="Generate Chart"'
378: .' value="'.&mt('Generate Chart').'" />'
379: .'</p>';
1.4 stredwic 380: return $Str;
1.1 stredwic 381: }
1.30 matthew 382:
383: #######################################################
384: #######################################################
385:
386: =pod
387:
1.31 matthew 388: =item &CreateAndParseOutputSelector()
1.30 matthew 389:
390: =cut
391:
392: #######################################################
393: #######################################################
1.32 matthew 394: my @OutputOptions =
395: ({ name => 'HTML, with links',
396: value => 'html, with links',
1.33 matthew 397: description => 'Output HTML with each symbol linked to the problem '.
1.35 matthew 398: 'which generated it.',
399: mode => 'html',
400: show_links => 'yes',
401: },
1.47 matthew 402: { name => 'HTML, with all links',
403: value => 'html, with all links',
404: description => 'Output HTML with each symbol linked to the problem '.
405: 'which generated it. '.
406: 'This includes links for unattempted problems.',
407: mode => 'html',
408: show_links => 'all',
409: },
1.32 matthew 410: { name => 'HTML, without links',
411: value => 'html, without links',
1.33 matthew 412: description => 'Output HTML. By not including links, the size of the'.
413: ' web page is greatly reduced. If your browser crashes on the '.
1.35 matthew 414: 'full display, try this.',
415: mode => 'html',
416: show_links => 'no',
417: },
1.54 matthew 418: { name => 'Excel',
419: value => 'excel',
420: description => 'Output an Excel file (compatable with Excel 95).',
1.35 matthew 421: mode => 'excel',
422: show_links => 'no',
1.54 matthew 423: },
424: { name => 'CSV',
425: value => 'csv',
1.96 www 426: description => 'Output a comma separated values file suitable for '.
1.57 matthew 427: 'import into a spreadsheet program. Using this method as opposed '.
428: 'to Excel output allows you to organize your data before importing'.
429: ' it into a spreadsheet program.',
1.35 matthew 430: mode => 'csv',
431: show_links => 'no',
432: },
1.32 matthew 433: );
434:
1.33 matthew 435: sub OutputDescriptions {
436: my $Str = '';
1.58 matthew 437: $Str .= "<h2>Output Formats</h2>\n";
1.33 matthew 438: $Str .= "<dl>\n";
439: foreach my $outputmode (@OutputOptions) {
440: $Str .=" <dt>".$outputmode->{'name'}."</dt>\n";
441: $Str .=" <dd>".$outputmode->{'description'}."</dd>\n";
442: }
443: $Str .= "</dl>\n";
444: return $Str;
445: }
446:
1.31 matthew 447: sub CreateAndParseOutputSelector {
448: my $Str = '';
1.44 matthew 449: my $elementname = 'chartoutputmode';
1.73 matthew 450: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
451: [$elementname]);
1.31 matthew 452: #
453: # Format for output options is 'mode, restrictions';
1.122 albertel 454: my $selected = (&Apache::loncommon::get_env_multiple('form.'.$elementname))[0];
455: $selected = 'html, without links' if (!$selected);
456:
1.31 matthew 457: #
458: # Set package variables describing output mode
459: $show_links = 'no';
460: $output_mode = 'html';
1.35 matthew 461: foreach my $option (@OutputOptions) {
462: next if ($option->{'value'} ne $selected);
463: $output_mode = $option->{'mode'};
464: $show_links = $option->{'show_links'};
1.31 matthew 465: }
1.35 matthew 466:
1.31 matthew 467: #
468: # Build the form element
469: $Str = qq/<select size="5" name="$elementname">/;
1.32 matthew 470: foreach my $option (@OutputOptions) {
471: $Str .= "\n".' <option value="'.$option->{'value'}.'"';
472: $Str .= " selected " if ($option->{'value'} eq $selected);
1.75 matthew 473: $Str .= ">".&mt($option->{'name'})."<\/option>";
1.31 matthew 474: }
475: $Str .= "\n</select>";
476: return $Str;
477: }
1.30 matthew 478:
1.54 matthew 479: ##
480: ## Data selector stuff
481: ##
482: my @OutputDataOptions =
1.57 matthew 483: (
1.72 matthew 484: { name => 'Scores Summary',
1.57 matthew 485: base => 'scores',
486: value => 'sum and total',
1.87 matthew 487: scores => 1,
488: tries => 0,
489: every_problem => 0,
490: sequence_sum => 1,
491: sequence_max => 1,
492: grand_total => 1,
1.101 matthew 493: grand_maximum => 1,
1.89 matthew 494: summary_table => 1,
1.90 matthew 495: maximum_row => 1,
1.129 bowersj2 496: ignore_weight => 0,
1.57 matthew 497: shortdesc => 'Total Score and Maximum Possible for each '.
498: 'Sequence or Folder',
499: longdesc => 'The score of each student as well as the '.
500: ' maximum possible on each Sequence or Folder.',
501: },
1.71 matthew 502: { name => 'Scores Per Problem',
1.57 matthew 503: base => 'scores',
1.71 matthew 504: value => 'scores',
1.87 matthew 505: scores => 1,
506: tries => 0,
507: correct => 0,
508: every_problem => 1,
509: sequence_sum => 1,
510: sequence_max => 1,
511: grand_total => 1,
1.101 matthew 512: grand_maximum => 1,
1.89 matthew 513: summary_table => 1,
1.90 matthew 514: maximum_row => 1,
1.129 bowersj2 515: ignore_weight => 0,
1.71 matthew 516: shortdesc => 'Score on each Problem Part',
517: longdesc =>'The students score on each problem part, computed as'.
518: 'the part weight * part awarded',
1.57 matthew 519: },
520: { name =>'Tries',
521: base =>'tries',
522: value => 'tries',
1.87 matthew 523: scores => 0,
524: tries => 1,
525: correct => 0,
526: every_problem => 1,
527: sequence_sum => 0,
528: sequence_max => 0,
529: grand_total => 0,
1.101 matthew 530: grand_maximum => 0,
1.90 matthew 531: summary_table => 0,
532: maximum_row => 0,
1.129 bowersj2 533: ignore_weight => 0,
1.57 matthew 534: shortdesc => 'Number of Tries before success on each Problem Part',
535: longdesc =>'The number of tries before success on each problem part.',
1.109 matthew 536: non_html_notes => 'negative values indicate an incorrect problem',
1.57 matthew 537: },
538: { name =>'Parts Correct',
539: base =>'tries',
540: value => 'parts correct total',
1.87 matthew 541: scores => 0,
542: tries => 0,
543: correct => 1,
544: every_problem => 1,
545: sequence_sum => 1,
546: sequence_max => 1,
547: grand_total => 1,
1.101 matthew 548: grand_maximum => 1,
1.89 matthew 549: summary_table => 1,
1.90 matthew 550: maximum_row => 0,
1.129 bowersj2 551: ignore_weight => 1,
1.157 bisitz 552: shortdesc => 'Number of Problem Parts completed successfully',
1.57 matthew 553: longdesc => 'The Number of Problem Parts completed successfully and '.
554: 'the maximum possible for each student',
555: },
556: );
557:
558: sub HTMLifyOutputDataDescriptions {
559: my $Str = '';
1.160 raeburn 560: $Str .= '<h2>'.&mt('Output Data').'</h2>'."\n";
1.57 matthew 561: $Str .= "<dl>\n";
562: foreach my $option (@OutputDataOptions) {
563: $Str .= ' <dt>'.$option->{'name'}.'</dt>';
564: $Str .= '<dd>'.$option->{'longdesc'}.'</dd>'."\n";
565: }
566: $Str .= "</dl>\n";
567: return $Str;
568: }
1.54 matthew 569:
570: sub CreateAndParseOutputDataSelector {
571: my $Str = '';
572: my $elementname = 'chartoutputdata';
573: #
1.122 albertel 574: my $selected = (&Apache::loncommon::get_env_multiple('form.'.$elementname))[0];
575: $selected = 'scores' if (!$selected);
576:
1.54 matthew 577: #
1.87 matthew 578: $chosen_output = $OutputDataOptions[0];
1.54 matthew 579: foreach my $option (@OutputDataOptions) {
580: if ($option->{'value'} eq $selected) {
1.87 matthew 581: $chosen_output = $option;
1.54 matthew 582: }
583: }
584: #
585: # Build the form element
586: $Str = qq/<select size="5" name="$elementname">/;
587: foreach my $option (@OutputDataOptions) {
588: $Str .= "\n".' <option value="'.$option->{'value'}.'"';
1.87 matthew 589: $Str .= " selected " if ($option->{'value'} eq $chosen_output->{'value'});
1.75 matthew 590: $Str .= ">".&mt($option->{'name'})."<\/option>";
1.54 matthew 591: }
592: $Str .= "\n</select>";
593: return $Str;
594:
595: }
596:
1.28 matthew 597: #######################################################
598: #######################################################
1.115 matthew 599: sub count_parts {
600: my ($navmap,$sequence) = @_;
601: my @resources = &get_resources($navmap,$sequence);
602: my $count = 0;
603: foreach my $res (@resources) {
604: $count += scalar(@{$res->parts});
605: }
606: return $count;
607: }
608:
609: sub get_resources {
610: my ($navmap,$sequence) = @_;
611: my @resources = $navmap->retrieveResources($sequence,
612: sub { shift->is_problem(); },
613: 0,0,0);
614: return @resources;
615: }
616:
617: #######################################################
618: #######################################################
1.1 stredwic 619:
1.28 matthew 620: =pod
621:
1.31 matthew 622: =head2 HTML output routines
1.28 matthew 623:
1.31 matthew 624: =item &html_initialize($r)
1.28 matthew 625:
1.31 matthew 626: Create labels for the columns of student data to show.
1.28 matthew 627:
1.31 matthew 628: =item &html_outputstudent($r,$student)
1.28 matthew 629:
1.31 matthew 630: Return a line of the chart for a student.
1.28 matthew 631:
1.31 matthew 632: =item &html_finish($r)
1.28 matthew 633:
634: =cut
635:
636: #######################################################
637: #######################################################
1.31 matthew 638: {
639: my $padding;
640: my $count;
641:
1.39 matthew 642: my $nodata_count; # The number of students for which there is no data
643: my %prog_state; # progress state used by loncommon PrgWin routines
1.102 matthew 644: my $total_sum_width;
1.39 matthew 645:
1.112 matthew 646: my %width; # Holds sequence width information
647: my @sequences;
648: my $navmap; # Have to keep this around since weakref is a bit zealous
649:
1.125 albertel 650: sub html_cleanup {
651: undef(%prog_state);
652: undef(%width);
653: #
654: undef($navmap);
655: undef(@sequences);
656: }
657:
1.31 matthew 658: sub html_initialize {
659: my ($r) = @_;
1.30 matthew 660: #
661: $padding = ' 'x3;
1.35 matthew 662: $count = 0;
1.39 matthew 663: $nodata_count = 0;
1.125 albertel 664: &html_cleanup();
1.115 matthew 665: ($navmap,@sequences) =
666: &Apache::lonstatistics::selected_sequences_with_assessments();
667: if (! ref($navmap)) {
668: # Unable to get data, so bail out
1.156 bisitz 669: $r->print('<p class="LC_error">'
670: .&mt('Unable to retrieve course information.')
671: .'</p>');
1.115 matthew 672: }
1.134 bowersj2 673:
674: # If we're showing links, show a checkbox to open in new
675: # windows.
676: if ($show_links ne 'no') {
1.159 bisitz 677: my $labeltext = &mt('Show links in new window');
1.134 bowersj2 678: $r->print(<<NEW_WINDOW_CHECKBOX);
1.135 albertel 679: <script type="text/javascript">new_window = true;</script>
1.159 bisitz 680: <p><label>
1.152 bisitz 681: <input type="checkbox" checked="checked" onclick="new_window=this.checked" />
1.159 bisitz 682: $labeltext
1.135 albertel 683: </label></p>
1.134 bowersj2 684: NEW_WINDOW_CHECKBOX
685: }
686:
1.30 matthew 687: #
1.121 albertel 688: $r->print("<h3>".$env{'course.'.$env{'request.course.id'}.'.description'}.
1.156 bisitz 689: " ".&Apache::lonlocal::locallocaltime(time)."</h3>");
1.112 matthew 690: #
1.87 matthew 691: if ($chosen_output->{'base'} !~ /^final table/) {
1.146 bisitz 692: $r->print("<h3>".&mt($chosen_output->{'shortdesc'})."</h3>");
1.39 matthew 693: }
1.31 matthew 694: my $Str = "<pre>\n";
1.30 matthew 695: # First, the @StudentData fields need to be listed
1.31 matthew 696: my @to_show = &get_student_fields_to_show();
1.30 matthew 697: foreach my $field (@to_show) {
698: my $title=$Apache::lonstatistics::StudentData{$field}->{'title'};
699: my $base =$Apache::lonstatistics::StudentData{$field}->{'base_width'};
700: my $width=$Apache::lonstatistics::StudentData{$field}->{'width'};
701: $Str .= $title.' 'x($width-$base).$padding;
702: }
1.89 matthew 703: #
704: # Compute the column widths and output the sequence titles
1.102 matthew 705: my $total_count;
1.112 matthew 706: #
707: # Compute sequence widths
708: my $starttime = Time::HiRes::time;
709: foreach my $seq (@sequences) {
710: my $symb = $seq->symb;
711: my $title = $seq->compTitle;
712: $width{$symb}->{'width_sum'} = 0;
713: # Compute width of sum
1.89 matthew 714: if ($chosen_output->{'sequence_sum'}) {
1.99 matthew 715: if ($chosen_output->{'every_problem'}) {
716: # Use 1 digit for a space
1.112 matthew 717: $width{$symb}->{'width_sum'} += 1;
1.99 matthew 718: }
1.118 matthew 719: $total_count += &count_parts($navmap,$seq);
1.151 www 720: # Use 6 digits for the sum
721: $width{$symb}->{'width_sum'} += 6;
1.89 matthew 722: }
1.112 matthew 723: # Compute width of maximum
1.89 matthew 724: if ($chosen_output->{'sequence_max'}) {
1.112 matthew 725: if ($width{$symb}->{'width_sum'}>0) {
1.89 matthew 726: # One digit for the '/'
1.112 matthew 727: $width{$symb}->{'width_sum'} +=1;
1.89 matthew 728: }
1.151 www 729: # Use 6 digits for the total
730: $width{$symb}->{'width_sum'}+=6;
1.89 matthew 731: }
1.94 matthew 732: #
1.89 matthew 733: if ($chosen_output->{'every_problem'}) {
734: # one problem per digit
1.115 matthew 735: $width{$symb}->{'width_parts'}= &count_parts($navmap,$seq);
736: $width{$symb}->{'width_problem'} += $width{$symb}->{'width_parts'};
1.89 matthew 737: } else {
1.112 matthew 738: $width{$symb}->{'width_problem'} = 0;
1.89 matthew 739: }
1.112 matthew 740: $width{$symb}->{'width_total'} = $width{$symb}->{'width_problem'} +
741: $width{$symb}->{'width_sum'};
742: if ($width{$symb}->{'width_total'} < length(&HTML::Entities::decode($title))) {
743: $width{$symb}->{'width_total'} = length(&HTML::Entities::decode($title));
1.89 matthew 744: }
745: #
746: # Output the sequence titles
1.112 matthew 747: $Str .= $title.(' 'x($width{$symb}->{'width_total'}-
748: length($title)
749: )).$padding;
1.30 matthew 750: }
1.102 matthew 751: $total_sum_width = length($total_count)+1;
752: $Str .= " total</pre>\n";
1.31 matthew 753: $Str .= "<pre>";
754: $r->print($Str);
755: $r->rflush();
1.132 bowersj2 756:
757: $r->print(<<JS);
1.142 albertel 758: <script type="text/javascript">
1.132 bowersj2 759: // get the left offset of a given widget as an absolute position
760: function getLeftOffset (element) {
761: return collect(element, "offsetLeft");
762: }
763:
764: // get the top offset of a given widget as an absolute position
765: function getTopOffset (element) {
766: return collect(element, "offsetTop");
767: }
768:
769: function collect(element, att) {
770: var val = 0;
771: while(element) {
772: val += element[att];
773: element = element.offsetParent;
774: }
775: return val;
776: }
777:
778: var currentDiv;
779: var currentElement;
780: function popup_score(element, score) {
781: popdown_score();
782: var left = getLeftOffset(element);
783: var top = getTopOffset(element);
784: var div = document.createElement("div");
1.142 albertel 785: div.className = "LC_chrt_popup";
1.132 bowersj2 786: div.appendChild(document.createTextNode(score));
787: div.style.position = "absolute";
788: div.style.top = (top - 25) + "px";
789: div.style.left = (left - 10) + "px";
790: currentDiv = div;
1.133 bowersj2 791: document.body.insertBefore(div, document.body.childNodes[0]);
1.142 albertel 792: element.className = "LC_chrt_popup_up";
1.132 bowersj2 793: currentElement = element;
794: }
795:
796: function popdown_score() {
797: if (currentDiv) {
798: document.body.removeChild(currentDiv);
799: }
800: if (currentElement) {
1.142 albertel 801: currentElement.className = 'LC_chrt_popup_exists';
1.132 bowersj2 802: }
803: currentDiv = undefined;
804: }
805: </script>
806: JS
807:
1.123 albertel 808: #
809: # Let the user know what we are doing
810: my $studentcount = scalar(@Apache::lonstatistics::Students);
811: if ($env{'form.SelectedStudent'}) {
812: $studentcount = '1';
813: }
814: #
815: # Initialize progress window
1.165 ! www 816: %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,$studentcount);
1.123 albertel 817: #
818: &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,
819: 'Processing first student');
1.31 matthew 820: return;
1.30 matthew 821: }
822:
1.31 matthew 823: sub html_outputstudent {
824: my ($r,$student) = @_;
1.2 stredwic 825: my $Str = '';
1.112 matthew 826: return if (! defined($navmap));
1.35 matthew 827: #
1.87 matthew 828: if($count++ % 5 == 0 && $count > 0) {
1.158 bisitz 829: # $r->print("</pre><pre>");
830: $r->print('</pre>');
831: &Apache::lonhtmlcommon::Increment_PrgWin(
1.162 bisitz 832: $r,\%prog_state,'last five students',5);
1.158 bisitz 833: $r->rflush();
834: $r->print('<pre>');
1.35 matthew 835: }
1.30 matthew 836: # First, the @StudentData fields need to be listed
1.31 matthew 837: my @to_show = &get_student_fields_to_show();
1.30 matthew 838: foreach my $field (@to_show) {
839: my $title=$student->{$field};
1.103 matthew 840: # Deal with 'comments' - how I love special cases
841: if ($field eq 'comments') {
842: $title = '<a href="/adm/'.$student->{'domain'}.'/'.$student->{'username'}.'/'.'aboutme#coursecomment">'.&mt('Comments').'</a>';
843: }
1.31 matthew 844: my $base = length($title);
1.30 matthew 845: my $width=$Apache::lonstatistics::StudentData{$field}->{'width'};
846: $Str .= $title.' 'x($width-$base).$padding;
847: }
848: # Get ALL the students data
849: my %StudentsData;
850: my @tmp = &Apache::loncoursedata::get_current_state
851: ($student->{'username'},$student->{'domain'},undef,
1.121 albertel 852: $env{'request.course.id'});
1.144 albertel 853: if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:(.*)/)) {
1.30 matthew 854: %StudentsData = @tmp;
1.144 albertel 855: } else {
856: my $error = $1;
857: if (scalar(@tmp) < 1) {
1.149 bisitz 858: $Str .= '<span class="LC_warning">'
859: .&mt('No Course Data')
860: .'</span>'."\n";
1.144 albertel 861: } else {
1.149 bisitz 862: $Str .= '<span class="LC_error">'
863: .&mt('Error getting student data ([_1])',$error)
864: .'</span>'."\n";
1.144 albertel 865: }
1.39 matthew 866: $nodata_count++;
1.31 matthew 867: $r->print($Str);
868: $r->rflush();
869: return;
1.30 matthew 870: }
871: #
872: # By sequence build up the data
873: my $studentstats;
1.31 matthew 874: my $PerformanceStr = '';
1.112 matthew 875: foreach my $seq (@sequences) {
1.118 matthew 876: my $symb = $seq->symb;
1.164 raeburn 877: my $randompick = $seq->randompick();
1.54 matthew 878: my ($performance,$performance_length,$score,$seq_max,$rawdata);
1.87 matthew 879: if ($chosen_output->{'tries'}) {
1.54 matthew 880: ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.112 matthew 881: &student_tries_on_sequence($student,\%StudentsData,
1.164 raeburn 882: $navmap,$seq,$show_links,$randompick);
1.54 matthew 883: } else {
884: ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.112 matthew 885: &student_performance_on_sequence($student,\%StudentsData,
1.129 bowersj2 886: $navmap,$seq,$show_links,
1.164 raeburn 887: $chosen_output->{ignore_weight},
888: $randompick);
1.54 matthew 889: }
1.89 matthew 890: my $ratio='';
1.118 matthew 891: if ($chosen_output->{'every_problem'} &&
892: $chosen_output->{'sequence_sum'}) {
1.99 matthew 893: $ratio .= ' ';
894: }
1.97 matthew 895: if ($chosen_output->{'sequence_sum'} && $score ne ' ') {
1.151 www 896: my $score .= sprintf("%3.2f",$score);
897: $ratio .= (' 'x(6-length($score))).$score;
1.98 matthew 898: } elsif($chosen_output->{'sequence_sum'}) {
1.151 www 899: $ratio .= ' 'x6;
1.89 matthew 900: }
901: if ($chosen_output->{'sequence_max'}) {
902: if ($chosen_output->{'sequence_sum'}) {
903: $ratio .= '/';
904: }
1.151 www 905: my $sequence_total=sprintf("%3.2f",$seq_max);
906: $ratio .= $sequence_total.(' 'x(6-length($sequence_total)));
1.89 matthew 907: }
1.31 matthew 908: #
1.89 matthew 909: if (! $chosen_output->{'every_problem'}) {
910: $performance = '';
1.94 matthew 911: $performance_length=0;
1.30 matthew 912: }
1.118 matthew 913: $performance .= ' 'x($width{$symb}->{'width_total'} -
1.112 matthew 914: $performance_length -
1.118 matthew 915: $width{$symb}->{'width_sum'}).
1.89 matthew 916: $ratio;
1.31 matthew 917: #
918: $Str .= $performance.$padding;
919: #
1.118 matthew 920: $studentstats->{$symb}->{'score'}= $score;
921: $studentstats->{$symb}->{'max'} = $seq_max;
1.30 matthew 922: }
923: #
924: # Total it up and store the statistics info.
1.97 matthew 925: my ($score,$max);
1.30 matthew 926: while (my ($symb,$seq_stats) = each (%{$studentstats})) {
927: $Statistics->{$symb}->{'score'} += $seq_stats->{'score'};
1.54 matthew 928: if ($Statistics->{$symb}->{'max'} < $seq_stats->{'max'}) {
929: $Statistics->{$symb}->{'max'} = $seq_stats->{'max'};
930: }
1.97 matthew 931: if ($seq_stats->{'score'} ne ' ') {
932: $score += $seq_stats->{'score'};
933: $Statistics->{$symb}->{'num_students'}++;
934: }
1.30 matthew 935: $max += $seq_stats->{'max'};
936: }
1.97 matthew 937: if (! defined($score)) {
1.102 matthew 938: $score = ' ' x $total_sum_width;
1.105 matthew 939: } else {
1.151 www 940: $score = sprintf("%.2f",$score);
941: $score = (' 'x(6-length($score))).$score;
1.97 matthew 942: }
1.102 matthew 943: $Str .= ' '.' 'x($total_sum_width-length($score)).$score.' / '.$max;
1.30 matthew 944: $Str .= " \n";
1.39 matthew 945: #
1.31 matthew 946: $r->print($Str);
947: #
1.158 bisitz 948: # $r->rflush();
949: # &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student');
1.31 matthew 950: return;
1.30 matthew 951: }
1.2 stredwic 952:
1.31 matthew 953: sub html_finish {
954: my ($r) = @_;
1.112 matthew 955: return if (! defined($navmap));
1.39 matthew 956: #
957: # Check for suppressed output and close the progress window if so
1.87 matthew 958: $r->print("</pre>\n");
1.90 matthew 959: if ($chosen_output->{'summary_table'}) {
960: if ($single_student_mode) {
961: $r->print(&SingleStudentTotal());
962: } else {
963: $r->print(&StudentAverageTotal());
964: }
1.49 matthew 965: }
1.31 matthew 966: $r->rflush();
1.123 albertel 967: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
1.125 albertel 968: &html_cleanup();
1.31 matthew 969: return;
970: }
971:
1.39 matthew 972: sub StudentAverageTotal {
1.105 matthew 973: my $Str = '<h3>'.&mt('Summary Tables').'</h3>'.$/;
1.150 bisitz 974: $Str .= &Apache::loncommon::start_data_table();
975: $Str .= &Apache::loncommon::start_data_table_header_row().
1.105 matthew 976: '<th>'.&mt('Title').'</th>'.
977: '<th>'.&mt('Average').'</th>'.
978: '<th>'.&mt('Maximum').'</th>'.
1.150 bisitz 979: &Apache::loncommon::end_data_table_header_row().$/;
1.112 matthew 980: foreach my $seq (@sequences) {
981: my $symb = $seq->symb;
1.42 matthew 982: my $ave;
1.112 matthew 983: my $num_students = $Statistics->{$symb}->{'num_students'};
1.97 matthew 984: if ($num_students > 0) {
985: $ave = int(100*
1.112 matthew 986: ($Statistics->{$symb}->{'score'}/$num_students)
1.97 matthew 987: )/100;
1.42 matthew 988: } else {
989: $ave = 0;
990: }
1.112 matthew 991: my $max = $Statistics->{$symb}->{'max'};
1.82 matthew 992: $ave = sprintf("%.2f",$ave);
1.150 bisitz 993: $Str .= &Apache::loncommon::start_data_table_row().
994: '<td>'.$seq->compTitle.'</td>'.
1.82 matthew 995: '<td align="right">'.$ave.' </td>'.
1.150 bisitz 996: '<td align="right">'.$max.' '.'</td>'.
997: &Apache::loncommon::end_data_table_row()."\n";
1.39 matthew 998: }
1.150 bisitz 999: $Str .= &Apache::loncommon::end_data_table()."\n";
1.39 matthew 1000: return $Str;
1001: }
1002:
1.49 matthew 1003: sub SingleStudentTotal {
1.115 matthew 1004: return if (! defined($navmap));
1.49 matthew 1005: my $student = &Apache::lonstatistics::current_student();
1.157 bisitz 1006: my $Str = '<h3>'.&mt('Summary table for [_1] ([_2])',
1.105 matthew 1007: $student->{'fullname'},
1.157 bisitz 1008: $student->{'username'}.':'.$student->{'domain'}).'</h3>';
1.105 matthew 1009: $Str .= $/;
1.150 bisitz 1010: $Str .= &Apache::loncommon::start_data_table()."\n";
1.49 matthew 1011: $Str .=
1.150 bisitz 1012: &Apache::loncommon::start_data_table_header_row().
1.105 matthew 1013: '<th>'.&mt('Sequence or Folder').'</th>';
1014: if ($chosen_output->{'base'} eq 'tries') {
1015: $Str .= '<th>'.&mt('Parts Correct').'</th>';
1016: } else {
1017: $Str .= '<th>'.&mt('Score').'</th>';
1018: }
1.150 bisitz 1019: $Str .= '<th>'.&mt('Maximum').'</th>'.
1020: &Apache::loncommon::end_data_table_header_row()."\n";
1.49 matthew 1021: my $total = 0;
1022: my $total_max = 0;
1.115 matthew 1023: foreach my $seq (@sequences) {
1.112 matthew 1024: my $value = $Statistics->{$seq->symb}->{'score'};
1025: my $max = $Statistics->{$seq->symb}->{'max'};
1.150 bisitz 1026: $Str .= &Apache::loncommon::start_data_table_row().
1027: '<td>'.&HTML::Entities::encode($seq->compTitle).'</td>'.
1.49 matthew 1028: '<td align="right">'.$value.'</td>'.
1.150 bisitz 1029: '<td align="right">'.$max.'</td>'.
1030: &Apache::loncommon::end_data_table_row()."\n";
1.49 matthew 1031: $total += $value;
1032: $total_max +=$max;
1033: }
1.150 bisitz 1034: $Str .= &Apache::loncommon::start_data_table_row().
1035: '<td><b>'.&mt('Total').'</b></td>'.
1.49 matthew 1036: '<td align="right">'.$total.'</td>'.
1.150 bisitz 1037: '<td align="right">'.$total_max.'</td>'.
1038: &Apache::loncommon::end_data_table_row()."\n";
1039: $Str .= &Apache::loncommon::end_data_table()."\n";
1.49 matthew 1040: return $Str;
1041: }
1042:
1.31 matthew 1043: }
1044:
1045: #######################################################
1046: #######################################################
1047:
1048: =pod
1049:
1050: =head2 EXCEL subroutines
1051:
1052: =item &excel_initialize($r)
1053:
1054: =item &excel_outputstudent($r,$student)
1055:
1056: =item &excel_finish($r)
1057:
1058: =cut
1059:
1060: #######################################################
1061: #######################################################
1062: {
1063:
1064: my $excel_sheet;
1.32 matthew 1065: my $excel_workbook;
1.117 matthew 1066: my $format;
1.32 matthew 1067:
1068: my $filename;
1069: my $rows_output;
1070: my $cols_output;
1071:
1.36 matthew 1072: my %prog_state; # progress window state
1.54 matthew 1073: my $request_aborted;
1.31 matthew 1074:
1.76 matthew 1075: my $total_formula;
1.101 matthew 1076: my $maximum_formula;
1.115 matthew 1077: my %formula_data;
1078:
1079: my $navmap;
1080: my @sequences;
1.76 matthew 1081:
1.125 albertel 1082: sub excel_cleanup {
1.31 matthew 1083: #
1.66 matthew 1084: undef ($excel_sheet);
1085: undef ($excel_workbook);
1086: undef ($filename);
1087: undef ($rows_output);
1088: undef ($cols_output);
1089: undef (%prog_state);
1090: undef ($request_aborted);
1.76 matthew 1091: undef ($total_formula);
1.101 matthew 1092: undef ($maximum_formula);
1.66 matthew 1093: #
1.115 matthew 1094: undef(%formula_data);
1095: #
1096: undef($navmap);
1097: undef(@sequences);
1.125 albertel 1098: }
1099:
1100: sub excel_initialize {
1101: my ($r) = @_;
1102:
1103: &excel_cleanup();
1.115 matthew 1104: ($navmap,@sequences) =
1105: &Apache::lonstatistics::selected_sequences_with_assessments();
1106: if (! ref($navmap)) {
1107: # Unable to get data, so bail out
1108: $r->print("<h3>".
1109: &mt('Unable to retrieve course information.').
1110: '</h3>');
1111: }
1112: #
1.54 matthew 1113: my $total_columns = scalar(&get_student_fields_to_show());
1.90 matthew 1114: my $num_students = scalar(@Apache::lonstatistics::Students);
1115: #
1.115 matthew 1116: foreach my $seq (@sequences) {
1.88 matthew 1117: if ($chosen_output->{'every_problem'}) {
1.115 matthew 1118: $total_columns+=&count_parts($navmap,$seq);
1.88 matthew 1119: }
1.87 matthew 1120: # Add 2 because we need a 'sequence_sum' and 'total' column for each
1.88 matthew 1121: $total_columns += 2;
1.54 matthew 1122: }
1.105 matthew 1123: my $too_many_cols_error_message =
1124: '<h2>'.&mt('Unable to Complete Request').'</h2>'.$/.
1125: '<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>'.$/.
1126: '<p>'.&mt('You may consider reducing the number of <b>Sequences or Folders</b> you have selected.').'</p>'.$/.
1127: '<p>'.&mt('LON-CAPA can produce <b>CSV</b> files of this data or Excel files of the <b>Scores Summary</b> data.').'</p>'.$/;
1.87 matthew 1128: if ($chosen_output->{'base'} eq 'tries' && $total_columns > 255) {
1.105 matthew 1129: $r->print($too_many_cols_error_message);
1130: $request_aborted = 1;
1.54 matthew 1131: }
1.87 matthew 1132: if ($chosen_output->{'base'} eq 'scores' && $total_columns > 255) {
1.105 matthew 1133: $r->print($too_many_cols_error_message);
1134: $request_aborted = 1;
1.54 matthew 1135: }
1136: return if ($request_aborted);
1137: #
1.32 matthew 1138: #
1139: $excel_workbook = undef;
1140: $excel_sheet = undef;
1141: #
1142: $rows_output = 0;
1143: $cols_output = 0;
1144: #
1.90 matthew 1145: # Determine rows
1146: my $header_row = $rows_output++;
1147: my $description_row = $rows_output++;
1.109 matthew 1148: my $notes_row = $rows_output++;
1.90 matthew 1149: $rows_output++; # blank row
1150: my $summary_header_row;
1151: if ($chosen_output->{'summary_table'}) {
1152: $summary_header_row = $rows_output++;
1.115 matthew 1153: $rows_output+= scalar(@sequences);
1.90 matthew 1154: $rows_output++;
1155: }
1156: my $sequence_name_row = $rows_output++;
1157: my $resource_name_row = $rows_output++;
1158: my $maximum_data_row = $rows_output++;
1159: if (! $chosen_output->{'maximum_row'}) {
1160: $rows_output--;
1161: }
1162: my $first_data_row = $rows_output++;
1163: #
1.32 matthew 1164: # Create sheet
1.117 matthew 1165: ($excel_workbook,$filename,$format)=
1166: &Apache::loncommon::create_workbook($r);
1167: return if (! defined($excel_workbook));
1.91 matthew 1168: #
1.32 matthew 1169: # Add a worksheet
1.121 albertel 1170: my $sheetname = $env{'course.'.$env{'request.course.id'}.'.description'};
1.67 matthew 1171: $sheetname = &Apache::loncommon::clean_excel_name($sheetname);
1.33 matthew 1172: $excel_sheet = $excel_workbook->addworksheet($sheetname);
1.85 matthew 1173: #
1.34 matthew 1174: # Put the course description in the header
1.90 matthew 1175: $excel_sheet->write($header_row,$cols_output++,
1.121 albertel 1176: $env{'course.'.$env{'request.course.id'}.'.description'},
1.85 matthew 1177: $format->{'h1'});
1.34 matthew 1178: $cols_output += 3;
1179: #
1180: # Put a description of the sections listed
1181: my $sectionstring = '';
1.119 matthew 1182: my @Sections = &Apache::lonstatistics::get_selected_sections();
1.120 matthew 1183: $excel_sheet->write($header_row,$cols_output++,
1.124 matthew 1184: &Apache::lonstatistics::section_and_enrollment_description('plaintext'),
1.85 matthew 1185: $format->{'h3'});
1.34 matthew 1186: #
1187: # Put the date in there too
1.90 matthew 1188: $excel_sheet->write($header_row,$cols_output++,
1.157 bisitz 1189: &mt('Compiled on [_1]',&Apache::lonlocal::locallocaltime(time)),$format->{'h3'});
1.34 matthew 1190: #
1.54 matthew 1191: $cols_output = 0;
1.90 matthew 1192: $excel_sheet->write($description_row,$cols_output++,
1.157 bisitz 1193: &mt($chosen_output->{'shortdesc'}),
1.109 matthew 1194: $format->{'b'});
1195: #
1196: $cols_output = 0;
1197: $excel_sheet->write($notes_row,$cols_output++,
1198: $chosen_output->{'non_html_notes'},
1199: $format->{'i'});
1200:
1.90 matthew 1201: ##############################################
1202: # Output headings for the raw data
1203: ##############################################
1.86 matthew 1204: #
1.32 matthew 1205: # Add the student headers
1.34 matthew 1206: $cols_output = 0;
1.32 matthew 1207: foreach my $field (&get_student_fields_to_show()) {
1.86 matthew 1208: $excel_sheet->write($resource_name_row,$cols_output++,$field,
1.85 matthew 1209: $format->{'bold'});
1.32 matthew 1210: }
1211: #
1.54 matthew 1212: # Add the remaining column headers
1.76 matthew 1213: my $total_formula_string = '=0';
1.101 matthew 1214: my $maximum_formula_string = '=0';
1.115 matthew 1215: foreach my $seq (@sequences) {
1216: my $symb = $seq->symb;
1.86 matthew 1217: $excel_sheet->write($sequence_name_row,,
1.115 matthew 1218: $cols_output,$seq->compTitle,$format->{'bold'});
1.86 matthew 1219: # Determine starting cell
1.115 matthew 1220: $formula_data{$symb}->{'Excel:startcell'}=
1.86 matthew 1221: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90 matthew 1222: ($first_data_row,$cols_output);
1.115 matthew 1223: $formula_data{$symb}->{'Excel:startcol'}=$cols_output;
1.87 matthew 1224: my $count = 0;
1225: if ($chosen_output->{'every_problem'}) {
1.76 matthew 1226: # Put the names of the problems and parts into the sheet
1.115 matthew 1227: foreach my $res (&get_resources($navmap,$seq)) {
1228: if (scalar(@{$res->parts}) > 1) {
1229: foreach my $part (@{$res->parts}) {
1.86 matthew 1230: $excel_sheet->write($resource_name_row,
1.54 matthew 1231: $cols_output++,
1.115 matthew 1232: $res->compTitle.' part '.$res->part_display($part),
1.85 matthew 1233: $format->{'bold'});
1.106 matthew 1234: $count++;
1.54 matthew 1235: }
1236: } else {
1.86 matthew 1237: $excel_sheet->write($resource_name_row,
1.54 matthew 1238: $cols_output++,
1.115 matthew 1239: $res->compTitle,$format->{'bold'});
1.106 matthew 1240: $count++;
1.54 matthew 1241: }
1242: }
1.79 matthew 1243: }
1.87 matthew 1244: # Determine ending cell
1245: if ($count <= 1) {
1.115 matthew 1246: $formula_data{$symb}->{'Excel:endcell'} = $formula_data{$symb}->{'Excel:startcell'};
1247: $formula_data{$symb}->{'Excel:endcol'} = $formula_data{$symb}->{'Excel:startcol'};
1.87 matthew 1248: } else {
1.115 matthew 1249: $formula_data{$symb}->{'Excel:endcell'} =
1.87 matthew 1250: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90 matthew 1251: ($first_data_row,$cols_output-1);
1.115 matthew 1252: $formula_data{$symb}->{'Excel:endcol'} = $cols_output-1;
1.87 matthew 1253: }
1254: # Create the formula for summing up this sequence
1.115 matthew 1255: if (! exists($formula_data{$symb}->{'Excel:endcell'}) ||
1256: ! defined($formula_data{$symb}->{'Excel:endcell'})) {
1257: $formula_data{$symb}->{'Excel:endcell'} = $formula_data{$symb}->{'Excel:startcell'};
1258: }
1.128 bowersj2 1259:
1.127 bowersj2 1260: my $start = $formula_data{$symb}->{'Excel:startcell'};
1261: my $end = $formula_data{$symb}->{'Excel:endcell'};
1.115 matthew 1262: $formula_data{$symb}->{'Excel:sum'}= $excel_sheet->store_formula
1.127 bowersj2 1263: ("=IF(COUNT($start\:$end),SUM($start\:$end),\"\")");
1.79 matthew 1264: # Determine cell the score is held in
1.115 matthew 1265: $formula_data{$symb}->{'Excel:scorecell'} =
1.79 matthew 1266: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90 matthew 1267: ($first_data_row,$cols_output);
1.115 matthew 1268: $formula_data{$symb}->{'Excel:scorecol'}=$cols_output;
1.87 matthew 1269: if ($chosen_output->{'base'} eq 'parts correct total') {
1.86 matthew 1270: $excel_sheet->write($resource_name_row,$cols_output++,
1.157 bisitz 1271: &mt('parts correct'),
1.85 matthew 1272: $format->{'bold'});
1.87 matthew 1273: } elsif ($chosen_output->{'sequence_sum'}) {
1274: if ($chosen_output->{'correct'}) {
1275: # Only reporting the number correct, so do not call it score
1276: $excel_sheet->write($resource_name_row,$cols_output++,
1.157 bisitz 1277: &mt('sum'),
1.87 matthew 1278: $format->{'bold'});
1279: } else {
1280: $excel_sheet->write($resource_name_row,$cols_output++,
1.157 bisitz 1281: &mt('score'),
1.87 matthew 1282: $format->{'bold'});
1283: }
1.32 matthew 1284: }
1.79 matthew 1285: #
1286: $total_formula_string.='+'.
1287: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.90 matthew 1288: ($first_data_row,$cols_output-1);
1.87 matthew 1289: if ($chosen_output->{'sequence_max'}) {
1.101 matthew 1290: $excel_sheet->write($resource_name_row,$cols_output,
1.157 bisitz 1291: &mt('maximum'),
1.87 matthew 1292: $format->{'bold'});
1.115 matthew 1293: $formula_data{$symb}->{'Excel:maxcell'} =
1.101 matthew 1294: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1295: ($first_data_row,$cols_output);
1.115 matthew 1296: $formula_data{$symb}->{'Excel:maxcol'}=$cols_output;
1.101 matthew 1297: $maximum_formula_string.='+'.
1298: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1299: ($first_data_row,$cols_output);
1300: $cols_output++;
1301:
1.87 matthew 1302: }
1303: }
1304: if ($chosen_output->{'grand_total'}) {
1.157 bisitz 1305: $excel_sheet->write($resource_name_row,$cols_output++,&mt('Total'),
1.85 matthew 1306: $format->{'bold'});
1.32 matthew 1307: }
1.101 matthew 1308: if ($chosen_output->{'grand_maximum'}) {
1.157 bisitz 1309: $excel_sheet->write($resource_name_row,$cols_output++,&mt('Max. Total'),
1.101 matthew 1310: $format->{'bold'});
1311: }
1.76 matthew 1312: $total_formula = $excel_sheet->store_formula($total_formula_string);
1.101 matthew 1313: $maximum_formula = $excel_sheet->store_formula($maximum_formula_string);
1.90 matthew 1314: ##############################################
1.87 matthew 1315: # Output a row for MAX, if appropriate
1.90 matthew 1316: ##############################################
1317: if ($chosen_output->{'maximum_row'}) {
1.87 matthew 1318: $cols_output = 0;
1319: foreach my $field (&get_student_fields_to_show()) {
1320: if ($field eq 'username' || $field eq 'fullname' ||
1321: $field eq 'id') {
1322: $excel_sheet->write($maximum_data_row,$cols_output++,'Maximum',
1323: $format->{'bold'});
1324: } else {
1325: $excel_sheet->write($maximum_data_row,$cols_output++,'');
1326: }
1.54 matthew 1327: }
1.87 matthew 1328: #
1329: # Add the maximums for each sequence or assessment
1330: my %total_cell_translation;
1.101 matthew 1331: my %maximum_cell_translation;
1.115 matthew 1332: foreach my $seq (@sequences) {
1333: my $symb = $seq->symb;
1334: $cols_output=$formula_data{$symb}->{'Excel:startcol'};
1335: $total_cell_translation{$formula_data{$symb}->{'Excel:scorecell'}}=
1.87 matthew 1336: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115 matthew 1337: ($maximum_data_row,$formula_data{$symb}->{'Excel:scorecol'});
1338: $maximum_cell_translation{$formula_data{$symb}->{'Excel:maxcell'}}=
1.101 matthew 1339: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115 matthew 1340: ($maximum_data_row,$formula_data{$symb}->{'Excel:maxcol'});
1.87 matthew 1341: my $weight;
1342: my $max = 0;
1.115 matthew 1343: foreach my $resource (&get_resources($navmap,$seq)) {
1344: foreach my $part (@{$resource->parts}){
1.87 matthew 1345: $weight = 1;
1346: if ($chosen_output->{'scores'}) {
1347: $weight = &Apache::lonnet::EXT
1.128 bowersj2 1348: ('resource.'.$part.'.weight',$resource->symb,
1.87 matthew 1349: undef,undef,undef);
1350: if (!defined($weight) || ($weight eq '')) {
1351: $weight=1;
1352: }
1353: }
1354: if ($chosen_output->{'scores'} &&
1355: $chosen_output->{'every_problem'}) {
1356: $excel_sheet->write($maximum_data_row,$cols_output++,
1357: $weight);
1.54 matthew 1358: }
1.87 matthew 1359: $max += $weight;
1.54 matthew 1360: }
1.87 matthew 1361: }
1362: #
1363: if ($chosen_output->{'sequence_sum'} &&
1364: $chosen_output->{'every_problem'}) {
1.110 albertel 1365: my %replaceCells=
1.115 matthew 1366: ('^'.$formula_data{$symb}->{'Excel:startcell'}.':'.
1367: $formula_data{$symb}->{'Excel:endcell'}.'$' =>
1368: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($maximum_data_row,$formula_data{$symb}->{'Excel:startcol'}).':'.
1369: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($maximum_data_row,$formula_data{$symb}->{'Excel:endcol'}));
1.87 matthew 1370: $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
1.115 matthew 1371: $formula_data{$symb}->{'Excel:sum'},undef,
1.127 bowersj2 1372: %replaceCells, %replaceCells);
1.110 albertel 1373:
1.87 matthew 1374: } elsif ($chosen_output->{'sequence_sum'}) {
1375: $excel_sheet->write($maximum_data_row,$cols_output++,$max);
1376: }
1377: if ($chosen_output->{'sequence_max'}) {
1378: $excel_sheet->write($maximum_data_row,$cols_output++,$max);
1.45 matthew 1379: }
1.87 matthew 1380: #
1.45 matthew 1381: }
1.87 matthew 1382: if ($chosen_output->{'grand_total'}) {
1.86 matthew 1383: $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
1.87 matthew 1384: $total_formula,undef,
1385: %total_cell_translation);
1.79 matthew 1386: }
1.101 matthew 1387: if ($chosen_output->{'grand_maximum'}) {
1388: $excel_sheet->repeat_formula($maximum_data_row,$cols_output++,
1389: $maximum_formula,undef,
1.107 matthew 1390: %maximum_cell_translation);
1.101 matthew 1391: }
1.90 matthew 1392: } # End of MAXIMUM row output if ($chosen_output->{'maximum_row'}) {
1.86 matthew 1393: $rows_output = $first_data_row;
1.90 matthew 1394: ##############################################
1395: # Output summary table, which actually is above the sequence name row.
1396: ##############################################
1397: if ($chosen_output->{'summary_table'}) {
1398: $cols_output = 0;
1399: $excel_sheet->write($summary_header_row,$cols_output++,
1.157 bisitz 1400: &mt('Summary Table'),$format->{'bold'});
1.90 matthew 1401: if ($chosen_output->{'maximum_row'}) {
1402: $excel_sheet->write($summary_header_row,$cols_output++,
1.157 bisitz 1403: &mt('Maximum'),$format->{'bold'});
1.90 matthew 1404: }
1405: $excel_sheet->write($summary_header_row,$cols_output++,
1.157 bisitz 1406: &mt('Average'),$format->{'bold'});
1.90 matthew 1407: $excel_sheet->write($summary_header_row,$cols_output++,
1.157 bisitz 1408: &mt('Median'),$format->{'bold'});
1.90 matthew 1409: $excel_sheet->write($summary_header_row,$cols_output++,
1.157 bisitz 1410: &mt('Std Dev'),$format->{'bold'});
1.90 matthew 1411: my $row = $summary_header_row+1;
1.115 matthew 1412: foreach my $seq (@sequences) {
1413: my $symb = $seq->symb;
1.90 matthew 1414: $cols_output = 0;
1415: $excel_sheet->write($row,$cols_output++,
1.115 matthew 1416: $seq->compTitle,
1.90 matthew 1417: $format->{'bold'});
1418: if ($chosen_output->{'maximum_row'}) {
1419: $excel_sheet->write
1420: ($row,$cols_output++,
1421: '='.
1422: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115 matthew 1423: ($maximum_data_row,$formula_data{$symb}->{'Excel:scorecol'})
1.90 matthew 1424: );
1425: }
1426: my $range =
1427: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115 matthew 1428: ($first_data_row,$formula_data{$symb}->{'Excel:scorecol'}).
1.90 matthew 1429: ':'.
1430: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115 matthew 1431: ($first_data_row+$num_students-1,$formula_data{$symb}->{'Excel:scorecol'});
1.90 matthew 1432: $excel_sheet->write($row,$cols_output++,
1433: '=AVERAGE('.$range.')');
1434: $excel_sheet->write($row,$cols_output++,
1435: '=MEDIAN('.$range.')');
1436: $excel_sheet->write($row,$cols_output++,
1437: '=STDEV('.$range.')');
1438: $row++;
1439: }
1440: }
1441: ##############################################
1442: # Take care of non-excel initialization
1443: ##############################################
1.32 matthew 1444: #
1445: # Let the user know what we are doing
1446: my $studentcount = scalar(@Apache::lonstatistics::Students);
1.121 albertel 1447: if ($env{'form.SelectedStudent'}) {
1.85 matthew 1448: $studentcount = '1';
1449: }
1.153 bisitz 1450: $r->print('<p>'
1451: .&mt('Compiling Excel spreadsheet for [quant,_1,student]...',$studentcount)
1452: ."</p>\n"
1453: );
1.32 matthew 1454: $r->rflush();
1.31 matthew 1455: #
1.36 matthew 1456: # Initialize progress window
1.165 ! www 1457: %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,$studentcount);
1.36 matthew 1458: #
1.62 matthew 1459: &Apache::lonhtmlcommon::Update_PrgWin($r,\%prog_state,
1460: 'Processing first student');
1.31 matthew 1461: return;
1462: }
1463:
1464: sub excel_outputstudent {
1465: my ($r,$student) = @_;
1.115 matthew 1466: if ($request_aborted || ! defined($navmap) || ! defined($excel_sheet)) {
1467: return;
1468: }
1.32 matthew 1469: $cols_output=0;
1470: #
1471: # Write out student data
1472: my @to_show = &get_student_fields_to_show();
1473: foreach my $field (@to_show) {
1.103 matthew 1474: my $value = $student->{$field};
1475: if ($field eq 'comments') {
1.136 albertel 1476: $value = &Apache::lonmsgdisplay::retrieve_instructor_comments
1.103 matthew 1477: ($student->{'username'},$student->{'domain'});
1478: }
1479: $excel_sheet->write($rows_output,$cols_output++,$value);
1.32 matthew 1480: }
1481: #
1482: # Get student assessment data
1483: my %StudentsData;
1484: my @tmp = &Apache::loncoursedata::get_current_state($student->{'username'},
1485: $student->{'domain'},
1486: undef,
1.121 albertel 1487: $env{'request.course.id'});
1.32 matthew 1488: if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
1489: %StudentsData = @tmp;
1490: }
1491: #
1492: # Write out sequence scores and totals data
1.76 matthew 1493: my %total_cell_translation;
1.101 matthew 1494: my %maximum_cell_translation;
1.115 matthew 1495: foreach my $seq (@sequences) {
1496: my $symb = $seq->symb;
1.164 raeburn 1497: my $randompick = $seq->randompick();
1.115 matthew 1498: $cols_output = $formula_data{$symb}->{'Excel:startcol'};
1.76 matthew 1499: # Keep track of cells to translate in total cell
1.115 matthew 1500: $total_cell_translation{$formula_data{$symb}->{'Excel:scorecell'}} =
1.76 matthew 1501: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115 matthew 1502: ($rows_output,$formula_data{$symb}->{'Excel:scorecol'});
1.107 matthew 1503: # and maximum cell
1.115 matthew 1504: $maximum_cell_translation{$formula_data{$symb}->{'Excel:maxcell'}} =
1.107 matthew 1505: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell
1.115 matthew 1506: ($rows_output,$formula_data{$symb}->{'Excel:maxcol'});
1.76 matthew 1507: #
1.54 matthew 1508: my ($performance,$performance_length,$score,$seq_max,$rawdata);
1.87 matthew 1509: if ($chosen_output->{'tries'} || $chosen_output->{'correct'}){
1.54 matthew 1510: ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.115 matthew 1511: &student_tries_on_sequence($student,\%StudentsData,
1.164 raeburn 1512: $navmap,$seq,'no',$randompick);
1.54 matthew 1513: } else {
1514: ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.115 matthew 1515: &student_performance_on_sequence($student,\%StudentsData,
1.129 bowersj2 1516: $navmap,$seq,'no',
1.164 raeburn 1517: $chosen_output->{ignore_weight},
1518: $randompick);
1.87 matthew 1519: }
1520: if ($chosen_output->{'every_problem'}) {
1521: if ($chosen_output->{'correct'}) {
1522: # only indiciate if each item is correct or not
1523: foreach my $value (@$rawdata) {
1.126 bowersj2 1524: # positive means correct, 0 or negative means
1525: # incorrect
1526: $value = $value > 0 ? 1 : 0;
1.87 matthew 1527: $excel_sheet->write($rows_output,$cols_output++,$value);
1528: }
1529: } else {
1530: foreach my $value (@$rawdata) {
1.97 matthew 1531: if ($score eq ' ' || !defined($value)) {
1532: $cols_output++;
1533: } else {
1534: $excel_sheet->write($rows_output,$cols_output++,
1535: $value);
1536: }
1.87 matthew 1537: }
1538: }
1.54 matthew 1539: }
1.87 matthew 1540: if ($chosen_output->{'sequence_sum'} &&
1541: $chosen_output->{'every_problem'}) {
1.76 matthew 1542: # Write a formula for the sum of this sequence
1.110 albertel 1543: my %replaceCells=
1.115 matthew 1544: ('^'.$formula_data{$symb}->{'Excel:startcell'}.':'.$formula_data{$symb}->{'Excel:endcell'}.'$'
1.110 albertel 1545: =>
1.115 matthew 1546: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($rows_output,$formula_data{$symb}->{'Excel:startcol'}).':'.
1547: &Spreadsheet::WriteExcel::Utility::xl_rowcol_to_cell($rows_output,$formula_data{$symb}->{'Excel:endcol'})
1.110 albertel 1548: );
1549: # The undef is for the format
1550: $excel_sheet->repeat_formula($rows_output,$cols_output++,
1.115 matthew 1551: $formula_data{$symb}->{'Excel:sum'},undef,
1.127 bowersj2 1552: %replaceCells, %replaceCells);
1.87 matthew 1553: } elsif ($chosen_output->{'sequence_sum'}) {
1.97 matthew 1554: if ($score eq ' ') {
1555: $cols_output++;
1556: } else {
1557: $excel_sheet->write($rows_output,$cols_output++,$score);
1558: }
1.32 matthew 1559: }
1.87 matthew 1560: if ($chosen_output->{'sequence_max'}) {
1.32 matthew 1561: $excel_sheet->write($rows_output,$cols_output++,$seq_max);
1562: }
1563: }
1.76 matthew 1564: #
1.87 matthew 1565: if ($chosen_output->{'grand_total'}) {
1566: $excel_sheet->repeat_formula($rows_output,$cols_output++,
1567: $total_formula,undef,
1568: %total_cell_translation);
1569: }
1.101 matthew 1570: if ($chosen_output->{'grand_maximum'}) {
1571: $excel_sheet->repeat_formula($rows_output,$cols_output++,
1572: $maximum_formula,undef,
1.107 matthew 1573: %maximum_cell_translation);
1.101 matthew 1574: }
1.32 matthew 1575: #
1576: # Bookkeeping
1577: $rows_output++;
1578: $cols_output=0;
1579: #
1.36 matthew 1580: # Update the progress window
1581: &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student');
1.32 matthew 1582: return;
1.31 matthew 1583: }
1584:
1585: sub excel_finish {
1586: my ($r) = @_;
1.115 matthew 1587: if ($request_aborted || ! defined($navmap) || ! defined($excel_sheet)) {
1.125 albertel 1588: &excel_cleanup();
1.115 matthew 1589: return;
1590: }
1.32 matthew 1591: #
1592: # Write the excel file
1593: $excel_workbook->close();
1594: #
1.36 matthew 1595: # Close the progress window
1596: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
1597: #
1.32 matthew 1598: # Tell the user where to get their excel file
1.36 matthew 1599: $r->print('<br />'.
1.153 bisitz 1600: '<a href="'.$filename.'">'.&mt('Your Excel spreadsheet').'</a>'."\n");
1.32 matthew 1601: $r->rflush();
1.125 albertel 1602: &excel_cleanup();
1.32 matthew 1603: return;
1.31 matthew 1604: }
1605:
1606: }
1.30 matthew 1607: #######################################################
1608: #######################################################
1609:
1610: =pod
1611:
1.31 matthew 1612: =head2 CSV output routines
1613:
1614: =item &csv_initialize($r)
1615:
1616: =item &csv_outputstudent($r,$student)
1617:
1618: =item &csv_finish($r)
1.30 matthew 1619:
1620: =cut
1621:
1622: #######################################################
1623: #######################################################
1.31 matthew 1624: {
1625:
1.37 matthew 1626: my $outputfile;
1627: my $filename;
1.54 matthew 1628: my $request_aborted;
1.37 matthew 1629: my %prog_state; # progress window state
1.115 matthew 1630: my $navmap;
1631: my @sequences;
1.37 matthew 1632:
1.125 albertel 1633: sub csv_cleanup {
1.66 matthew 1634: undef($outputfile);
1635: undef($filename);
1636: undef($request_aborted);
1.37 matthew 1637: undef(%prog_state);
1638: #
1.115 matthew 1639: undef($navmap);
1640: undef(@sequences);
1.125 albertel 1641: }
1642:
1643: sub csv_initialize{
1644: my ($r) = @_;
1645:
1646: &csv_cleanup();
1.115 matthew 1647: ($navmap,@sequences) =
1648: &Apache::lonstatistics::selected_sequences_with_assessments();
1649: if (! ref($navmap)) {
1650: # Unable to get data, so bail out
1651: $r->print("<h3>".
1652: &mt('Unable to retrieve course information.').
1653: '</h3>');
1654: }
1655: #
1.54 matthew 1656: # Deal with unimplemented requests
1657: $request_aborted = undef;
1.87 matthew 1658: if ($chosen_output->{'base'} =~ /final table/) {
1.54 matthew 1659: $r->print(<<END);
1660: <h2>Unable to Complete Request</h2>
1661: <p>
1662: The <b>Summary Table (Scores)</b> option is not available for non-HTML output.
1663: </p>
1664: END
1665: $request_aborted = 1;
1666: }
1667: return if ($request_aborted);
1.87 matthew 1668: #
1669: # Initialize progress window
1670: my $studentcount = scalar(@Apache::lonstatistics::Students);
1.165 ! www 1671: %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,$studentcount);
1.54 matthew 1672: #
1.37 matthew 1673: # Open a file
1.120 matthew 1674: ($outputfile,$filename) = &Apache::loncommon::create_text_file($r,'csv');
1675: if (! defined($outputfile)) { return ''; }
1.38 matthew 1676: #
1677: # Datestamp
1.121 albertel 1678: my $description = $env{'course.'.$env{'request.course.id'}.'.description'};
1.38 matthew 1679: print $outputfile '"'.&Apache::loncommon::csv_translate($description).'",'.
1.161 raeburn 1680: '"'.&Apache::loncommon::csv_translate(scalar(&Apache::lonlocal::locallocaltime(time))).'"'.
1.38 matthew 1681: "\n";
1.120 matthew 1682: print $outputfile '"'.
1683: &Apache::loncommon::csv_translate
1684: (&Apache::lonstatistics::section_and_enrollment_description()).
1685: '"'."\n";
1.109 matthew 1686: foreach my $item ('shortdesc','non_html_notes') {
1687: next if (! exists($chosen_output->{$item}));
1688: print $outputfile
1689: '"'.&Apache::loncommon::csv_translate($chosen_output->{$item}).'"'.
1690: "\n";
1691: }
1.37 matthew 1692: #
1693: # Print out the headings
1.87 matthew 1694: my $sequence_row = '';
1695: my $resource_row = undef;
1.37 matthew 1696: foreach my $field (&get_student_fields_to_show()) {
1.87 matthew 1697: $sequence_row .='"",';
1698: $resource_row .= '"'.&Apache::loncommon::csv_translate($field).'",';
1.37 matthew 1699: }
1.115 matthew 1700: foreach my $seq (@sequences) {
1.87 matthew 1701: $sequence_row .= '"'.
1.115 matthew 1702: &Apache::loncommon::csv_translate($seq->compTitle).'",';
1.87 matthew 1703: my $count = 0;
1704: if ($chosen_output->{'every_problem'}) {
1.116 matthew 1705: foreach my $res (&get_resources($navmap,$seq)) {
1.115 matthew 1706: if (scalar(@{$res->parts}) < 1) {
1.87 matthew 1707: next;
1708: }
1.115 matthew 1709: foreach my $part (@{$res->parts}) {
1.87 matthew 1710: $resource_row .= '"'.
1.115 matthew 1711: &Apache::loncommon::csv_translate
1712: ($res->compTitle.', Part '.$res->part_display($part)).'",';
1.87 matthew 1713: $count++;
1.53 matthew 1714: }
1715: }
1.37 matthew 1716: }
1.87 matthew 1717: $sequence_row.='"",'x$count;
1718: if ($chosen_output->{'sequence_sum'}) {
1719: if($chosen_output->{'correct'}) {
1.157 bisitz 1720: $resource_row .= '"'.&mt('sum').'",';
1.87 matthew 1721: } else {
1.157 bisitz 1722: $resource_row .= '"'.&mt('score').'",';
1.87 matthew 1723: }
1724: }
1725: if ($chosen_output->{'sequence_max'}) {
1726: $sequence_row.= '"",';
1.157 bisitz 1727: $resource_row .= '"'.&mt('maximum possible').'",';
1.87 matthew 1728: }
1.37 matthew 1729: }
1.87 matthew 1730: if ($chosen_output->{'grand_total'}) {
1731: $sequence_row.= '"",';
1.157 bisitz 1732: $resource_row.= '"'.&mt('Total').'",';
1.87 matthew 1733: }
1.101 matthew 1734: if ($chosen_output->{'grand_maximum'}) {
1735: $sequence_row.= '"",';
1.157 bisitz 1736: $resource_row.= '"'.&mt('Maximum').'",';
1.101 matthew 1737: }
1.87 matthew 1738: chomp($sequence_row);
1739: chomp($resource_row);
1740: print $outputfile $sequence_row."\n";
1741: print $outputfile $resource_row."\n";
1.31 matthew 1742: return;
1743: }
1744:
1745: sub csv_outputstudent {
1746: my ($r,$student) = @_;
1.115 matthew 1747: if ($request_aborted || ! defined($navmap) || ! defined($outputfile)) {
1748: return;
1749: }
1.37 matthew 1750: my $Str = '';
1751: #
1752: # Output student fields
1753: my @to_show = &get_student_fields_to_show();
1754: foreach my $field (@to_show) {
1.103 matthew 1755: my $value = $student->{$field};
1756: if ($field eq 'comments') {
1.136 albertel 1757: $value = &Apache::lonmsgdisplay::retrieve_instructor_comments
1.103 matthew 1758: ($student->{'username'},$student->{'domain'});
1759: }
1760: $Str .= '"'.&Apache::loncommon::csv_translate($value).'",';
1.37 matthew 1761: }
1762: #
1763: # Get student assessment data
1764: my %StudentsData;
1765: my @tmp = &Apache::loncoursedata::get_current_state($student->{'username'},
1766: $student->{'domain'},
1767: undef,
1.121 albertel 1768: $env{'request.course.id'});
1.37 matthew 1769: if ((scalar @tmp > 0) && ($tmp[0] !~ /^error:/)) {
1770: %StudentsData = @tmp;
1771: }
1772: #
1773: # Output performance data
1.87 matthew 1774: my $total = 0;
1.101 matthew 1775: my $maximum = 0;
1.115 matthew 1776: foreach my $seq (@sequences) {
1.164 raeburn 1777: my $randompick = $seq->randompick();
1.54 matthew 1778: my ($performance,$performance_length,$score,$seq_max,$rawdata);
1.87 matthew 1779: if ($chosen_output->{'tries'}){
1.54 matthew 1780: ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.115 matthew 1781: &student_tries_on_sequence($student,\%StudentsData,
1.164 raeburn 1782: $navmap,$seq,'no',$randompick);
1.54 matthew 1783: } else {
1784: ($performance,$performance_length,$score,$seq_max,$rawdata) =
1.115 matthew 1785: &student_performance_on_sequence($student,\%StudentsData,
1.129 bowersj2 1786: $navmap,$seq,'no',
1.164 raeburn 1787: $chosen_output->{ignore_weight},
1788: $randompick);
1.54 matthew 1789: }
1.87 matthew 1790: if ($chosen_output->{'every_problem'}) {
1791: if ($chosen_output->{'correct'}) {
1792: $score = 0;
1793: # Deal with number of parts correct data
1794: $Str .= '"'.join('","',( map { if ($_>0) {
1795: $score += 1;
1796: 1;
1797: } else {
1798: 0;
1799: }
1800: } @$rawdata)).'",';
1801: } else {
1802: $Str .= '"'.join('","',(@$rawdata)).'",';
1803: }
1804: }
1805: if ($chosen_output->{'sequence_sum'}) {
1.37 matthew 1806: $Str .= '"'.$score.'",';
1.87 matthew 1807: }
1808: if ($chosen_output->{'sequence_max'}) {
1809: $Str .= '"'.$seq_max.'",';
1.37 matthew 1810: }
1.87 matthew 1811: $total+=$score;
1.101 matthew 1812: $maximum += $seq_max;
1.87 matthew 1813: }
1814: if ($chosen_output->{'grand_total'}) {
1815: $Str .= '"'.$total.'",';
1.101 matthew 1816: }
1817: if ($chosen_output->{'grand_maximum'}) {
1818: $Str .= '"'.$maximum.'",';
1.37 matthew 1819: }
1820: chop($Str);
1821: $Str .= "\n";
1822: print $outputfile $Str;
1823: #
1824: # Update the progress window
1825: &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,'last student');
1826: return;
1.31 matthew 1827: }
1828:
1829: sub csv_finish {
1830: my ($r) = @_;
1.115 matthew 1831: if ($request_aborted || ! defined($navmap) || ! defined($outputfile)) {
1.125 albertel 1832: &csv_cleanup();
1.115 matthew 1833: return;
1834: }
1.37 matthew 1835: close($outputfile);
1836: #
1837: # Close the progress window
1838: &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
1839: #
1840: # Tell the user where to get their csv file
1841: $r->print('<br />'.
1.147 bisitz 1842: '<a href="'.$filename.'">'.&mt('Your CSV file.').'</a>'."\n");
1.37 matthew 1843: $r->rflush();
1.125 albertel 1844: &csv_cleanup();
1.37 matthew 1845: return;
1846:
1.31 matthew 1847: }
1.2 stredwic 1848:
1849: }
1850:
1.132 bowersj2 1851: # This function will return an HTML string including a star, with
1852: # a mouseover popup showing the "real" value. An optional second
1853: # argument lets you show something other than a star.
1854: sub show_star {
1855: my $popup = shift;
1856: my $symbol = shift || '*';
1857: # Escape the popup for JS.
1858: $popup =~ s/([^-a-zA-Z0-9:;,._ ()|!\/?=&*])/'\\' . sprintf("%lo", ord($1))/ge;
1859:
1.142 albertel 1860: return "<span class=\"LC_chrt_popup_exists\" onmouseover='popup_score(this, \"$popup\");return false;' onmouseout='popdown_score();return false;'>$symbol</span>";
1.132 bowersj2 1861: }
1862:
1.28 matthew 1863: #######################################################
1864: #######################################################
1865:
1.2 stredwic 1866: =pod
1867:
1.54 matthew 1868: =item &StudentTriesOnSequence()
1.2 stredwic 1869:
1.30 matthew 1870: Inputs:
1.2 stredwic 1871:
1872: =over 4
1873:
1.30 matthew 1874: =item $student
1.28 matthew 1875:
1.30 matthew 1876: =item $studentdata Hash ref to all student data
1.2 stredwic 1877:
1.30 matthew 1878: =item $seq Hash ref, the sequence we are working on
1.2 stredwic 1879:
1.30 matthew 1880: =item $links if defined we will output links to each resource.
1.2 stredwic 1881:
1.28 matthew 1882: =back
1.2 stredwic 1883:
1884: =cut
1.1 stredwic 1885:
1.28 matthew 1886: #######################################################
1887: #######################################################
1.112 matthew 1888: sub student_tries_on_sequence {
1.164 raeburn 1889: my ($student,$studentdata,$navmap,$seq,$links,$randompick) = @_;
1.31 matthew 1890: $links = 'no' if (! defined($links));
1.1 stredwic 1891: my $Str = '';
1.30 matthew 1892: my ($sum,$max) = (0,0);
1.51 matthew 1893: my $performance_length = 0;
1.54 matthew 1894: my @TriesData = ();
1895: my $tries;
1.97 matthew 1896: my $hasdata = 0; # flag - true if the student has any data on the sequence
1.115 matthew 1897: foreach my $resource (&get_resources($navmap,$seq)) {
1.112 matthew 1898: my $resource_data = $studentdata->{$resource->symb};
1.30 matthew 1899: my $value = '';
1.112 matthew 1900: foreach my $partnum (@{$resource->parts()}) {
1.54 matthew 1901: $tries = undef;
1.30 matthew 1902: $max++;
1.51 matthew 1903: $performance_length++;
1.30 matthew 1904: my $symbol = ' '; # default to space
1905: #
1.78 matthew 1906: my $awarded = 0;
1907: if (exists($resource_data->{'resource.'.$partnum.'.awarded'})) {
1908: $awarded = $resource_data->{'resource.'.$partnum.'.awarded'};
1909: $awarded = 0 if (! $awarded);
1910: }
1911: #
1912: my $status = '';
1.30 matthew 1913: if (exists($resource_data->{'resource.'.$partnum.'.solved'})) {
1.78 matthew 1914: $status = $resource_data->{'resource.'.$partnum.'.solved'};
1915: }
1916: #
1917: my $tries = 0;
1918: if(exists($resource_data->{'resource.'.$partnum.'.tries'})) {
1919: $tries = $resource_data->{'resource.'.$partnum.'.tries'};
1.97 matthew 1920: $hasdata =1;
1.78 matthew 1921: }
1922: #
1923: if ($awarded > 0) {
1924: # The student has gotten the problem correct to some degree
1925: if ($status eq 'excused') {
1926: $symbol = 'x';
1927: $max--;
1.137 albertel 1928: } elsif ($status eq 'correct_by_override' && !$resource->is_task()) {
1.30 matthew 1929: $symbol = '+';
1930: $sum++;
1.78 matthew 1931: } elsif ($tries > 0) {
1.54 matthew 1932: if ($tries > 9) {
1.132 bowersj2 1933: $symbol = show_star($tries);
1.78 matthew 1934: } else {
1.54 matthew 1935: $symbol = $tries;
1.30 matthew 1936: }
1937: $sum++;
1938: } else {
1.78 matthew 1939: $symbol = '+';
1940: $sum++;
1.2 stredwic 1941: }
1.30 matthew 1942: } else {
1.78 matthew 1943: # The student has the problem incorrect or it is ungraded
1944: if ($status eq 'excused') {
1945: $symbol = 'x';
1946: $max--;
1947: } elsif ($status eq 'incorrect_by_override') {
1948: $symbol = '-';
1949: } elsif ($status eq 'ungraded_attempted') {
1.124 matthew 1950: $symbol = 'u';
1.78 matthew 1951: } elsif ($status eq 'incorrect_attempted' ||
1952: $tries > 0) {
1.30 matthew 1953: $symbol = '.';
1954: } else {
1.78 matthew 1955: # Problem is wrong and has not been attempted.
1956: $symbol=' ';
1.18 matthew 1957: }
1.2 stredwic 1958: }
1.54 matthew 1959: #
1.109 matthew 1960: if (! defined($tries)) {
1961: $tries = 0;
1962: }
1963: if ($status =~ /^(incorrect|ungraded)/) {
1964: # Bug 3390: show '-' for tries on incorrect problems
1965: # (csv & excel only)
1966: push(@TriesData,-$tries);
1967: } else {
1968: push (@TriesData,$tries);
1.54 matthew 1969: }
1.30 matthew 1970: #
1.47 matthew 1971: if ( ($links eq 'yes' && $symbol ne ' ') ||
1972: ($links eq 'all')) {
1.134 bowersj2 1973: my $link = '/adm/grades'.
1.148 raeburn 1974: '?symb='.&escape($resource->shown_symb).
1.30 matthew 1975: '&student='.$student->{'username'}.
1.64 albertel 1976: '&userdom='.$student->{'domain'}.
1.134 bowersj2 1977: '&command=submission';
1978: $symbol = &link($symbol, $link);
1.30 matthew 1979: }
1980: $value .= $symbol;
1.2 stredwic 1981: }
1.30 matthew 1982: $Str .= $value;
1.17 minaeibi 1983: }
1.164 raeburn 1984: if ($randompick) {
1985: $max = $randompick;
1.51 matthew 1986: }
1.97 matthew 1987: if (! $hasdata && $sum == 0) {
1988: $sum = ' ';
1989: }
1.54 matthew 1990: return ($Str,$performance_length,$sum,$max,\@TriesData);
1991: }
1992:
1.134 bowersj2 1993: =pod
1994:
1995: =item &link
1996:
1997: Inputs:
1998:
1999: =over 4
2000:
2001: =item $text
2002:
2003: =item $target
2004:
2005: =back
2006:
2007: Takes the text and creates a link to the $text that honors
2008: the value of 'new window' if clicked on, but uses a real
2009: 'href' so middle and right clicks still work.
2010:
2011: $target and $text are assumed to be already correctly escaped; i.e., it
2012: can be dumped out directly into the output stream as-is.
2013:
2014: =cut
2015:
2016: sub link {
2017: my ($text,$target) = @_;
2018: return
2019: "<a href='$target' onclick=\"t=this.href;if(new_window)"
2020: ."{window.open(t)}else{return void(window."
2021: ."location=t)};return false;\">$text</a>";
2022: }
2023:
1.54 matthew 2024: #######################################################
2025: #######################################################
2026:
2027: =pod
2028:
1.115 matthew 2029: =item &student_performance_on_sequence
1.54 matthew 2030:
2031: Inputs:
2032:
2033: =over 4
2034:
2035: =item $student
2036:
2037: =item $studentdata Hash ref to all student data
2038:
2039: =item $seq Hash ref, the sequence we are working on
2040:
2041: =item $links if defined we will output links to each resource.
2042:
2043: =back
2044:
2045: =cut
2046:
2047: #######################################################
2048: #######################################################
1.112 matthew 2049: sub student_performance_on_sequence {
1.164 raeburn 2050: my ($student,$studentdata,$navmap,$seq,$links,$awarded_only,$randompick) = @_;
1.54 matthew 2051: $links = 'no' if (! defined($links));
2052: my $Str = ''; # final result string
2053: my ($score,$max) = (0,0);
2054: my $performance_length = 0;
2055: my $symbol;
2056: my @ScoreData = ();
2057: my $partscore;
1.97 matthew 2058: my $hasdata = 0; # flag, 0 if there were no submissions on the sequence
1.164 raeburn 2059: my %ptsfreq;
1.115 matthew 2060: foreach my $resource (&get_resources($navmap,$seq)) {
1.112 matthew 2061: my $symb = $resource->symb;
2062: my $resource_data = $studentdata->{$symb};
1.164 raeburn 2063: my $resmax = 0;
1.112 matthew 2064: foreach my $part (@{$resource->parts()}) {
1.54 matthew 2065: $partscore = undef;
1.129 bowersj2 2066: my $weight;
2067: if (!$awarded_only){
2068: $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',
2069: $symb,
2070: $student->{'domain'},
2071: $student->{'username'},
2072: $student->{'section'});
2073: }
1.54 matthew 2074: if (!defined($weight) || ($weight eq '')) {
2075: $weight=1;
2076: }
2077: #
2078: $max += $weight; # see the 'excused' branch below...
1.164 raeburn 2079: $resmax += $weight;
1.54 matthew 2080: $performance_length++; # one character per part
2081: $symbol = ' '; # default to space
2082: #
1.97 matthew 2083: my $awarded;
1.54 matthew 2084: if (exists($resource_data->{'resource.'.$part.'.awarded'})) {
2085: $awarded = $resource_data->{'resource.'.$part.'.awarded'};
1.67 matthew 2086: $awarded = 0 if (! $awarded);
1.97 matthew 2087: $hasdata = 1;
1.54 matthew 2088: }
2089: #
1.131 albertel 2090: $partscore = &Apache::grades::compute_points($weight,$awarded);
1.97 matthew 2091: if (! defined($awarded)) {
2092: $partscore = undef;
2093: }
1.54 matthew 2094: $score += $partscore;
1.63 matthew 2095: $symbol = $partscore;
1.70 matthew 2096: if (abs($symbol - sprintf("%.0f",$symbol)) < 0.001) {
2097: $symbol = sprintf("%.0f",$symbol);
2098: }
1.54 matthew 2099: if (length($symbol) > 1) {
1.132 bowersj2 2100: $symbol = show_star($symbol);
1.54 matthew 2101: }
1.124 matthew 2102: if (exists($resource_data->{'resource.'.$part.'.solved'}) &&
2103: $resource_data->{'resource.'.$part.'.solved'} ne '') {
1.54 matthew 2104: my $status = $resource_data->{'resource.'.$part.'.solved'};
2105: if ($status eq 'excused') {
2106: $symbol = 'x';
2107: $max -= $weight; # Do not count 'excused' problems.
1.124 matthew 2108: } elsif ($status eq 'ungraded_attempted') {
2109: $symbol = 'u';
1.54 matthew 2110: }
1.97 matthew 2111: $hasdata = 1;
1.124 matthew 2112: } elsif ($resource_data->{'resource.'.$part.'.award'} eq 'DRAFT') {
2113: $symbol = 'd';
2114: $hasdata = 1;
1.111 matthew 2115: } elsif (!exists($resource_data->{'resource.'.$part.'.awarded'})){
1.54 matthew 2116: # Unsolved. Did they try?
2117: if (exists($resource_data->{'resource.'.$part.'.tries'})){
2118: $symbol = '.';
1.97 matthew 2119: $hasdata = 1;
1.54 matthew 2120: } else {
2121: $symbol = ' ';
2122: }
2123: }
2124: #
1.60 matthew 2125: if (! defined($partscore)) {
2126: $partscore = $symbol;
2127: }
2128: push (@ScoreData,$partscore);
2129: #
1.54 matthew 2130: if ( ($links eq 'yes' && $symbol ne ' ') || ($links eq 'all')) {
1.134 bowersj2 2131: my $link = '/adm/grades' .
1.148 raeburn 2132: '?symb='.&escape($resource->shown_symb).
1.54 matthew 2133: '&student='.$student->{'username'}.
1.64 albertel 2134: '&userdom='.$student->{'domain'}.
1.134 bowersj2 2135: '&command=submission';
2136: $symbol = &link($symbol, $link);
1.54 matthew 2137: }
1.60 matthew 2138: $Str .= $symbol;
1.54 matthew 2139: }
1.164 raeburn 2140: if ($ptsfreq{$resmax}) {
2141: $ptsfreq{$resmax} ++;
2142: } else {
2143: $ptsfreq{$resmax} = 1;
2144: }
2145: }
2146: if ($randompick) {
2147: my @uniquetotals = keys(%ptsfreq);
2148: if ((@uniquetotals = 1) && ($ptsfreq{$uniquetotals[0]} > 0)) {
2149: $max = $max * $randompick/$ptsfreq{$uniquetotals[0]};
2150: }
1.97 matthew 2151: }
2152: if (! $hasdata && $score == 0) {
2153: $score = ' ';
1.54 matthew 2154: }
2155: return ($Str,$performance_length,$score,$max,\@ScoreData);
1.1 stredwic 2156: }
1.23 minaeibi 2157:
1.28 matthew 2158: #######################################################
2159: #######################################################
1.23 minaeibi 2160:
1.2 stredwic 2161: =pod
2162:
2163: =item &CreateLegend()
2164:
2165: This function returns a formatted string containing the legend for the
2166: chart. The legend describes the symbols used to represent grades for
2167: problems.
2168:
2169: =cut
2170:
1.28 matthew 2171: #######################################################
2172: #######################################################
1.2 stredwic 2173: sub CreateLegend {
2174: my $Str = "<p><pre>".
1.124 matthew 2175: " digit score or number of tries to get correct ".
1.12 minaeibi 2176: " * correct by student in more than 9 tries\n".
1.20 minaeibi 2177: " + correct by hand grading or override\n".
1.12 minaeibi 2178: " - incorrect by override\n".
2179: " . incorrect attempted\n".
1.124 matthew 2180: " u ungraded attempted\n".
2181: " d draft answer saved but not submitted\n".
1.13 minaeibi 2182: " not attempted (blank field)\n".
1.12 minaeibi 2183: " x excused".
1.17 minaeibi 2184: "</pre><p>";
1.2 stredwic 2185: return $Str;
2186: }
2187:
1.28 matthew 2188: #######################################################
2189: #######################################################
2190:
1.30 matthew 2191: =pod
1.2 stredwic 2192:
2193: =back
2194:
2195: =cut
2196:
1.28 matthew 2197: #######################################################
2198: #######################################################
1.2 stredwic 2199:
1.28 matthew 2200: 1;
1.2 stredwic 2201:
1.1 stredwic 2202: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>