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