Annotation of loncom/interface/statistics/lonproblemstatistics.pm, revision 1.125
1.1 stredwic 1: # The LearningOnline Network with CAPA
2: #
1.125 ! bisitz 3: # $Id: lonproblemstatistics.pm,v 1.124 2013/12/30 13:51:37 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: #
9: # LON-CAPA is free software; you can redistribute it and/or modify
10: # it under the terms of the GNU General Public License as published by
11: # the Free Software Foundation; either version 2 of the License, or
12: # (at your option) any later version.
13: #
14: # LON-CAPA is distributed in the hope that it will be useful,
15: # but WITHOUT ANY WARRANTY; without even the implied warranty of
16: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17: # GNU General Public License for more details.
18: #
19: # You should have received a copy of the GNU General Public License
20: # along with LON-CAPA; if not, write to the Free Software
21: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: #
23: # /home/httpd/html/adm/gpl.txt
24: #
25: # http://www.lon-capa.org/
26: #
27: # (Navigate problems for statistical reports
28: #
1.47 matthew 29: ###############################################
30: ###############################################
31:
32: =pod
33:
34: =head1 NAME
35:
36: lonproblemstatistics
37:
38: =head1 SYNOPSIS
39:
40: Routines to present problem statistics to instructors via tables,
41: Excel files, and plots.
42:
43: =over 4
44:
45: =cut
46:
47: ###############################################
48: ###############################################
1.1 stredwic 49:
1.36 minaeibi 50: package Apache::lonproblemstatistics;
1.1 stredwic 51:
52: use strict;
1.104 albertel 53: use Apache::lonnet;
1.62 matthew 54: use Apache::loncommon();
1.119 www 55: use Apache::lonquickgrades();
1.1 stredwic 56: use Apache::lonhtmlcommon;
57: use Apache::loncoursedata;
1.41 matthew 58: use Apache::lonstatistics;
1.84 matthew 59: use LONCAPA::lonmetadata();
1.59 matthew 60: use Apache::lonlocal;
1.44 matthew 61: use Spreadsheet::WriteExcel;
1.70 matthew 62: use Apache::lonstathelpers();
1.71 matthew 63: use Time::HiRes;
1.109 www 64: use LONCAPA;
65:
1.73 matthew 66:
67: my @StatsArray;
1.79 matthew 68: my %SeqStat; # keys are symbs, values are hash refs
1.73 matthew 69:
1.59 matthew 70: ##
71: ## Localization notes:
72: ##
73: ## in @Fields[0]->{'long_title'} is placed in Excel files and is used as the
74: ## header for plots created with Graph.pm, both of which more than likely do
75: ## not support localization.
76: ##
1.123 bisitz 77: ## Additional Notes:
78: ## Localization can be done and is done before passing the phrases
79: ## to the output.
80: ## This might conflict with special characters, e.g. German Umlaute or
81: ## chinese characters. Do not use such characters in this case.
82: ## If this failed, consider that the sequence and folder names
83: ## are also passed to the output and would fail the same way.
84: ##
1.79 matthew 85: #
86: #
87: ##
88: ## Description of Field attributes
89: ##
90: ## Attribute Required Value Meaning or Use
91: ##
92: ## name yes any scalar Used to uniquely identify field
93: ## title yes any scalar This is what the user sees to identify
94: ## the field. Passed through &mt().
95: ## long_title yes any scalar Used as graph heading and in excel
1.123 bisitz 96: ## output. Passed through &mt().
1.79 matthew 97: ## align no (left|right|center) HTML cell contents alignment
98: ## color yes html color HTML cell background color
99: ## used to visually group statistics
100: ## special no (link) Indicates a link, target is name.link
101: ## Currently set in &get_statistics()
102: ## graphable no (yes|no) Can a bar graph of the field be
103: ## produced?
104: ## sortable no (yes|no) Should a sort link be put in the
105: ## column header?
106: ## selectable yes (yes|no) Can the column be removed from the
107: ## statistics display?
108: ## selected yes (yes|no) Is the column selected by default?
109: ##
1.85 matthew 110: ## format no sprintf format string
111: ##
112: ## excel_format no excel format type
113: ## (see &Apache::loncommon::define_excel_formats
1.49 matthew 114: my @Fields = (
115: { name => 'problem_num',
116: title => 'P#',
117: align => 'right',
1.76 matthew 118: color => '#FFFFE6',
119: selectable => 'no',
1.80 matthew 120: defaultselected => 'yes',
1.76 matthew 121: },
1.49 matthew 122: { name => 'container',
1.51 matthew 123: title => 'Sequence or Folder',
1.49 matthew 124: align => 'left',
125: color => '#FFFFE6',
1.76 matthew 126: sortable => 'yes',
127: selectable => 'no',
1.80 matthew 128: defaultselected => 'yes',
1.76 matthew 129: },
1.49 matthew 130: { name => 'title',
131: title => 'Title',
132: align => 'left',
133: color => '#FFFFE6',
134: special => 'link',
1.117 bisitz 135: sortable => 'yes',
1.76 matthew 136: selectable => 'no',
1.80 matthew 137: defaultselected => 'yes',
1.76 matthew 138: },
1.117 bisitz 139: { name => 'part',
1.49 matthew 140: title => 'Part',
141: align => 'left',
1.55 matthew 142: color => '#FFFFE6',
1.76 matthew 143: selectable => 'no',
1.80 matthew 144: defaultselected => 'yes',
1.76 matthew 145: },
1.49 matthew 146: { name => 'num_students',
147: title => '#Stdnts',
148: align => 'right',
149: color => '#EEFFCC',
150: format => '%d',
151: sortable => 'yes',
152: graphable => 'yes',
1.76 matthew 153: long_title => 'Number of Students Attempting Problem',
154: selectable => 'yes',
1.80 matthew 155: defaultselected => 'yes',
1.76 matthew 156: },
1.49 matthew 157: { name => 'tries',
158: title => 'Tries',
159: align => 'right',
160: color => '#EEFFCC',
161: format => '%d',
162: sortable => 'yes',
163: graphable => 'yes',
1.76 matthew 164: long_title => 'Total Number of Tries',
165: selectable => 'yes',
1.80 matthew 166: defaultselected => 'yes',
1.76 matthew 167: },
1.49 matthew 168: { name => 'max_tries',
169: title => 'Max Tries',
170: align => 'right',
171: color => '#DDFFFF',
172: format => '%d',
173: sortable => 'yes',
174: graphable => 'yes',
1.76 matthew 175: long_title => 'Maximum Number of Tries',
176: selectable => 'yes',
1.80 matthew 177: defaultselected => 'yes',
1.76 matthew 178: },
1.73 matthew 179: { name => 'min_tries',
180: title => 'Min Tries',
181: align => 'right',
182: color => '#DDFFFF',
183: format => '%d',
184: sortable => 'yes',
185: graphable => 'yes',
1.76 matthew 186: long_title => 'Minumum Number of Tries',
187: selectable => 'yes',
1.80 matthew 188: defaultselected => 'yes',
1.76 matthew 189: },
1.49 matthew 190: { name => 'mean_tries',
191: title => 'Mean Tries',
192: align => 'right',
193: color => '#DDFFFF',
194: format => '%5.2f',
195: sortable => 'yes',
196: graphable => 'yes',
1.76 matthew 197: long_title => 'Average Number of Tries',
198: selectable => 'yes',
1.80 matthew 199: defaultselected => 'yes',
1.76 matthew 200: },
1.49 matthew 201: { name => 'std_tries',
202: title => 'S.D. tries',
203: align => 'right',
204: color => '#DDFFFF',
205: format => '%5.2f',
206: sortable => 'yes',
207: graphable => 'yes',
1.76 matthew 208: long_title => 'Standard Deviation of Number of Tries',
209: selectable => 'yes',
1.80 matthew 210: defaultselected => 'yes',
1.76 matthew 211: },
1.49 matthew 212: { name => 'skew_tries',
213: title => 'Skew Tries',
214: align => 'right',
215: color => '#DDFFFF',
216: format => '%5.2f',
217: sortable => 'yes',
218: graphable => 'yes',
1.76 matthew 219: long_title => 'Skew of Number of Tries',
220: selectable => 'yes',
1.80 matthew 221: defaultselected => 'no',
1.76 matthew 222: },
1.49 matthew 223: { name => 'num_solved',
224: title => '#YES',
225: align => 'right',
226: color => '#FFDDDD',
1.63 matthew 227: format => '%4.1f',# format => '%d',
1.49 matthew 228: sortable => 'yes',
229: graphable => 'yes',
1.76 matthew 230: long_title => 'Number of Students able to Solve',
1.77 matthew 231: selectable => 'yes',
1.80 matthew 232: defaultselected => 'yes',
1.76 matthew 233: },
1.49 matthew 234: { name => 'num_override',
235: title => '#yes',
236: align => 'right',
237: color => '#FFDDDD',
1.63 matthew 238: format => '%4.1f',# format => '%d',
1.49 matthew 239: sortable => 'yes',
240: graphable => 'yes',
1.76 matthew 241: long_title => 'Number of Students given Override',
242: selectable => 'yes',
1.80 matthew 243: defaultselected => 'yes',
1.76 matthew 244: },
1.95 matthew 245: { name => 'tries_per_correct',
246: title => 'tries/correct',
247: align => 'right',
248: color => '#FFDDDD',
249: format => '%4.1f',
250: sortable => 'yes',
251: graphable => 'yes',
252: long_title => 'Tries per Correct Answer',
253: selectable => 'yes',
254: defaultselected => 'yes',
255: },
1.73 matthew 256: { name => 'num_wrong',
257: title => '#Wrng',
1.49 matthew 258: align => 'right',
1.73 matthew 259: color => '#FFDDDD',
1.49 matthew 260: format => '%4.1f',
261: sortable => 'yes',
262: graphable => 'yes',
1.93 matthew 263: long_title => 'Number of students whose final answer is wrong',
264: selectable => 'yes',
265: defaultselected => 'yes',
266: },
267: { name => 'per_wrong',
268: title => '%Wrng',
269: align => 'right',
270: color => '#FFDDDD',
271: format => '%4.1f',
272: sortable => 'yes',
273: graphable => 'yes',
1.76 matthew 274: long_title => 'Percent of students whose final answer is wrong',
275: selectable => 'yes',
1.80 matthew 276: defaultselected => 'yes',
1.76 matthew 277: },
1.73 matthew 278: { name => 'deg_of_diff',
279: title => 'DoDiff',
280: align => 'right',
281: color => '#FFFFE6',
282: format => '%5.2f',
283: sortable => 'yes',
284: graphable => 'yes',
285: long_title => 'Degree of Difficulty'.
1.124 raeburn 286: ' ~[ 1 - ((#YES+#yes) / Tries) ~]',
1.76 matthew 287: selectable => 'yes',
1.80 matthew 288: defaultselected => 'yes',
1.76 matthew 289: },
1.71 matthew 290: { name => 'deg_of_disc',
1.73 matthew 291: title => 'DoDisc',
1.71 matthew 292: align => 'right',
293: color => '#FFFFE6',
294: format => '%4.2f',
295: sortable => 'yes',
296: graphable => 'yes',
1.76 matthew 297: long_title => 'Degree of Discrimination',
298: selectable => 'yes',
1.89 matthew 299: defaultselected => 'yes',
1.76 matthew 300: },
1.85 matthew 301: ## duedate included for research purposes. Commented out most of the time.
302: # { name => 'duedate',
303: # title => 'Due Date',
304: # align => 'left',
305: # color => '#FFFFFF',
306: # sortable => 'yes',
307: # graphable => 'no',
308: # long_title => 'Due date of resource for instructor',
309: # selectable => 'no',
310: # defaultselected => 'yes',
311: # },
312: ## opendate included for research purposes. Commented out most of the time.
313: # { name => 'opendate',
314: # title => 'Open Date',
315: # align => 'left',
316: # color => '#FFFFFF',
317: # sortable => 'yes',
318: # graphable => 'no',
319: # long_title => 'date resource became answerable',
320: # selectable => 'no',
321: # defaultselected => 'yes',
322: # },
323: ## symb included for research purposes. Commented out most of the time.
324: # { name => 'symb',
325: # title => 'Symb',
326: # align => 'left',
327: # color => '#FFFFFF',
328: # sortable => 'yes',
329: # graphable => 'no',
330: # long_title => 'Unique LON-CAPA identifier for problem',
331: # selectable => 'no',
332: # defaultselected => 'yes',
333: # },
1.86 matthew 334: ## resptypes included for research purposes. Commented out most of the time.
335: # { name => 'resptypes',
336: # title => 'Response Types',
337: # align => 'left',
338: # color => '#FFFFFF',
339: # sortable => 'no',
340: # graphable => 'no',
341: # long_title => 'Response Types used in this problem',
342: # selectable => 'no',
343: # defaultselected => 'yes',
344: # },
1.94 matthew 345: ## maxtries included for research purposes. Commented out most of the time.
346: # { name => 'maxtries',
347: # title => 'Maxtries',
348: # align => 'left',
349: # color => '#FFFFFF',
350: # sortable => 'no',
351: # graphable => 'no',
352: # long_title => 'Maximum number of tries',
353: # selectable => 'no',
354: # defaultselected => 'yes',
355: # },
356: ## hinttries included for research purposes. Commented out most of the time.
357: # { name => 'hinttries',
358: # title => 'hinttries',
359: # align => 'left',
360: # color => '#FFFFFF',
361: # sortable => 'no',
362: # graphable => 'no',
363: # long_title => 'Number of tries before a hint appears',
364: # selectable => 'no',
365: # defaultselected => 'yes',
366: # },
1.98 matthew 367: #
368: ## problem weight for instructor
369: { name => 'weight',
370: title => 'weight',
371: align => 'right',
372: color => '#FFFFFF',
373: sortable => 'no',
374: graphable => 'no',
375: long_title => 'Problem weight (for instructor)',
1.100 matthew 376: selectable => 'yes',
1.98 matthew 377: defaultselected => 'yes',
378: },
1.49 matthew 379: );
380:
1.79 matthew 381: my @SeqFields = (
382: { name => 'title',
383: title => 'Sequence',
384: align => 'left',
385: color => '#FFFFE6',
386: special => 'no',
1.117 bisitz 387: sortable => 'no',
1.79 matthew 388: selectable => 'yes',
1.80 matthew 389: defaultselected => 'no',
1.79 matthew 390: },
391: { name => 'items',
392: title => '#Items',
393: align => 'right',
394: color => '#FFFFE6',
395: format => '%4d',
396: sortable => 'no',
397: graphable => 'no',
398: long_title => 'Number of Items in Sequence',
399: selectable => 'yes',
1.80 matthew 400: defaultselected => 'no',
1.79 matthew 401: },
402: { name => 'scoremean',
403: title => 'Score Mean',
404: align => 'right',
405: color => '#FFFFE6',
406: format => '%4.2f',
407: sortable => 'no',
408: graphable => 'no',
409: long_title => 'Mean Sequence Score',
410: selectable => 'yes',
1.80 matthew 411: defaultselected => 'no',
1.79 matthew 412: },
413: { name => 'scorestd',
414: title => 'Score STD',
415: align => 'right',
416: color => '#FFFFE6',
417: format => '%4.2f',
418: sortable => 'no',
419: graphable => 'no',
420: long_title => 'Standard Deviation of Sequence Scores',
421: selectable => 'yes',
1.80 matthew 422: defaultselected => 'no',
1.79 matthew 423: },
424: { name => 'scoremax',
425: title => 'Score Max',
426: align => 'right',
427: color => '#FFFFE6',
428: format => '%4.2f',
429: sortable => 'no',
430: graphable => 'no',
431: long_title => 'Maximum Sequence Score',
432: selectable => 'yes',
1.80 matthew 433: defaultselected => 'no',
1.79 matthew 434: },
435: { name => 'scoremin',
436: title => 'Score Min',
437: align => 'right',
438: color => '#FFFFE6',
439: format => '%4.2f',
440: sortable => 'no',
441: graphable => 'no',
442: long_title => 'Minumum Sequence Score',
443: selectable => 'yes',
1.80 matthew 444: defaultselected => 'no',
1.79 matthew 445: },
446: { name => 'scorecount',
447: title => 'Score N',
448: align => 'right',
449: color => '#FFFFE6',
450: format => '%4d',
451: sortable => 'no',
452: graphable => 'no',
453: long_title => 'Number of Students in score computations',
454: selectable => 'yes',
1.80 matthew 455: defaultselected => 'no',
1.79 matthew 456: },
457: { name => 'countmean',
458: title => 'Count Mean',
459: align => 'right',
460: color => '#FFFFFF',
461: format => '%4.2f',
462: sortable => 'no',
463: graphable => 'no',
464: long_title => 'Mean Sequence Score',
465: selectable => 'yes',
1.80 matthew 466: defaultselected => 'no',
1.79 matthew 467: },
468: { name => 'countstd',
469: title => 'Count STD',
470: align => 'right',
471: color => '#FFFFFF',
472: format => '%4.2f',
473: sortable => 'no',
474: graphable => 'no',
475: long_title => 'Standard Deviation of Sequence Scores',
476: selectable => 'yes',
1.80 matthew 477: defaultselected => 'no',
1.79 matthew 478: },
479: { name => 'countmax',
480: title => 'Count Max',
481: align => 'right',
482: color => '#FFFFFF',
483: format => '%4.2f',
484: sortable => 'no',
485: graphable => 'no',
486: long_title => 'Maximum Number of Correct Problems',
487: selectable => 'yes',
1.80 matthew 488: defaultselected => 'no',
1.79 matthew 489: },
490: { name => 'countmin',
491: title => 'Count Min',
492: align => 'right',
493: color => '#FFFFFF',
494: format => '%4.2f',
495: sortable => 'no',
496: graphable => 'no',
497: long_title => 'Minumum Number of Correct Problems',
498: selectable => 'yes',
1.80 matthew 499: defaultselected => 'no',
1.79 matthew 500: },
501: { name => 'count',
502: title => 'Count N',
503: align => 'right',
504: color => '#FFFFFF',
505: format => '%4d',
506: sortable => 'no',
507: graphable => 'no',
508: long_title => 'Number of Students in score computations',
509: selectable => 'yes',
1.80 matthew 510: defaultselected => 'no',
1.79 matthew 511: },
512: { name => 'KR-21',
513: title => 'KR-21',
514: align => 'right',
515: color => '#FFAAAA',
516: format => '%4.2f',
517: sortable => 'no',
518: graphable => 'no',
519: long_title => 'KR-21 reliability statistic',
520: selectable => 'yes',
1.80 matthew 521: defaultselected => 'no',
1.117 bisitz 522: },
1.79 matthew 523: );
524:
1.76 matthew 525: my %SelectedFields;
526:
527: sub parse_field_selection {
528: #
529: # Pull out the defaults
1.104 albertel 530: if (! defined($env{'form.fieldselections'})) {
531: $env{'form.fieldselections'} = [];
1.76 matthew 532: foreach my $field (@Fields) {
533: next if ($field->{'selectable'} ne 'yes');
1.80 matthew 534: if ($field->{'defaultselected'} eq 'yes') {
1.104 albertel 535: push(@{$env{'form.fieldselections'}},$field->{'name'});
1.76 matthew 536: }
537: }
538: }
539: #
1.80 matthew 540: # Make sure the data we are plotting is there
541: my %NeededFields;
1.104 albertel 542: if (exists($env{'form.plot'}) && $env{'form.plot'} ne '' &&
543: $env{'form.plot'} ne 'none') {
544: if ($env{'form.plot'} eq 'degrees') {
1.80 matthew 545: $NeededFields{'deg_of_diff'}++;
546: $NeededFields{'deg_of_disc'}++;
1.104 albertel 547: } elsif ($env{'form.plot'} eq 'tries statistics') {
1.80 matthew 548: $NeededFields{'mean_tries'}++;
549: $NeededFields{'std_tries'}++;
550: $NeededFields{'problem_num'}++;
551: } else {
1.104 albertel 552: $NeededFields{$env{'form.plot'}}++;
1.80 matthew 553: }
554: }
555: #
1.76 matthew 556: # This should not happen, but in case it does...
1.104 albertel 557: if (ref($env{'form.fieldselections'}) ne 'ARRAY') {
558: $env{'form.fieldselections'} = [$env{'form.fieldselections'}];
1.76 matthew 559: }
560: #
561: # Set the field data and the selected fields (for easier checking)
562: undef(%SelectedFields);
563: foreach my $field (@Fields) {
1.80 matthew 564: if ($field->{'selectable'} ne 'yes') {
565: $field->{'selected'} = 'yes';
566: } else {
567: $field->{'selected'} = 'no';
568: }
569: if (exists($NeededFields{$field->{'name'}})) {
570: $field->{'selected'} = 'yes';
571: $SelectedFields{$field->{'name'}}++;
572: }
1.104 albertel 573: foreach my $selection (@{$env{'form.fieldselections'}}) {
1.76 matthew 574: if ($selection eq $field->{'name'} || $selection eq 'all') {
575: $field->{'selected'} = 'yes';
576: $SelectedFields{$field->{'name'}}++;
577: }
578: }
579: }
1.82 matthew 580: #
581: # Always show all the sequence statistics (for now)
582: foreach my $field (@SeqFields) {
583: $field->{'selected'} = 'yes';
584: }
1.76 matthew 585: return;
586: }
587:
588: sub field_selection_input {
1.116 bisitz 589: my $Str = '<select name="fieldselections" multiple="multiple" size="5">'."\n";
1.125 ! bisitz 590: $Str .= '<option value="all">'.&mt('all').'</option>'."\n";
1.76 matthew 591: foreach my $field (@Fields) {
592: next if ($field->{'selectable'} ne 'yes');
593: $Str .= ' <option value="'.$field->{'name'}.'" ';
594: if ($field->{'selected'} eq 'yes') {
1.125 ! bisitz 595: $Str .= 'selected="selected" ';
1.76 matthew 596: }
1.125 ! bisitz 597: $Str .= '>'.&mt($field->{'title'}).'</option>'."\n";
1.76 matthew 598: }
599: $Str .= "</select>\n";
600: }
601:
1.47 matthew 602: ###############################################
603: ###############################################
604:
605: =pod
606:
607: =item &CreateInterface()
608:
609: Create the main intereface for the statistics page. Allows the user to
610: select sections, maps, and output.
611:
612: =cut
1.1 stredwic 613:
1.47 matthew 614: ###############################################
615: ###############################################
1.41 matthew 616: sub CreateInterface {
1.87 matthew 617: my ($r) = @_;
1.80 matthew 618: #
1.76 matthew 619: &parse_field_selection();
1.80 matthew 620: #
1.41 matthew 621: my $Str = '';
1.115 bisitz 622: $Str .= &Apache::loncommon::start_data_table();
623: $Str .= &Apache::loncommon::start_data_table_header_row();
624: $Str .= '<th>'.&mt('Sections').'</th>';
625: $Str .= '<th>'.&mt('Groups').'</th>';
626: $Str .= '<th>'.&mt('Access Status').'</th>';
627: $Str .= '<th>'.&mt('Sequences and Folders').'</th>';
628: $Str .= '<th>'.&mt('Statistics').'</th>';
629: $Str .= '<th>'.&mt('Plot Graph').'</th>';
630: $Str .= '<th>'.&mt('Time Period').'</th>';
631: $Str .= &Apache::loncommon::end_data_table_header_row();
1.41 matthew 632: #
1.115 bisitz 633: $Str .= &Apache::loncommon::start_data_table_row();
634: $Str .= '<td align="center" valign="top">'."\n";
1.41 matthew 635: $Str .= &Apache::lonstatistics::SectionSelect('Section','multiple',5);
1.115 bisitz 636: $Str .= '</td><td align="center" valign="top">';
1.108 raeburn 637: $Str .= &Apache::lonstatistics::GroupSelect('Group','multiple',5);
1.115 bisitz 638: $Str .= '</td><td align="center" valign="top">';
1.50 matthew 639: $Str .= &Apache::lonhtmlcommon::StatusOptions(undef,undef,5);
1.115 bisitz 640: $Str .= '</td><td align="center" valign="top">';
1.41 matthew 641: #
1.97 matthew 642: $Str .= &Apache::lonstatistics::map_select('Maps','multiple,all',5);
1.115 bisitz 643: $Str .= '</td><td align="center" valign="top">';
644: $Str .= &field_selection_input();
645: $Str .= '</td><td align="center" valign="top">';
646: $Str .= &plot_dropdown();
1.125 ! bisitz 647: $Str .= "\n";
1.115 bisitz 648: $Str .= '</td><td align="center" valign="top">';
649: $Str .= &Apache::lonstathelpers::limit_by_time_form();
650: $Str .= '</td>'."\n";
651: $Str .= &Apache::loncommon::end_data_table_row();
652: $Str .= &Apache::loncommon::end_data_table();
1.87 matthew 653: #
1.59 matthew 654: $Str .= '<input type="submit" name="GenerateStatistics" value="'.
655: &mt('Generate Statistics').'" />';
1.115 bisitz 656: $Str .= (' 'x10);
1.87 matthew 657: #
1.73 matthew 658: return $Str;
1.41 matthew 659: }
1.25 stredwic 660:
1.41 matthew 661: ###############################################
662: ###############################################
1.28 stredwic 663:
1.47 matthew 664: =pod
665:
666: =item &BuildProblemStatisticsPage()
667:
668: Main interface to problem statistics.
669:
670: =cut
671:
1.41 matthew 672: ###############################################
673: ###############################################
1.97 matthew 674: my $navmap;
675: my @sequences;
676:
1.105 albertel 677: sub clean_up {
678: undef($navmap);
679: undef(@sequences);
680: }
681:
1.41 matthew 682: sub BuildProblemStatisticsPage {
683: my ($r,$c)=@_;
1.97 matthew 684: undef($navmap);
685: undef(@sequences);
1.61 matthew 686: #
687: my %Saveable_Parameters = ('Status' => 'scalar',
688: 'statsoutputmode' => 'scalar',
689: 'Section' => 'array',
1.108 raeburn 690: 'Groups' => 'array',
1.61 matthew 691: 'StudentData' => 'array',
1.77 matthew 692: 'Maps' => 'array',
693: 'fieldselections'=> 'array');
1.61 matthew 694: &Apache::loncommon::store_course_settings('statistics',
695: \%Saveable_Parameters);
696: &Apache::loncommon::restore_course_settings('statistics',
697: \%Saveable_Parameters);
698: #
699: &Apache::lonstatistics::PrepareClasslist();
1.41 matthew 700: #
1.73 matthew 701: # Clear the package variables
702: undef(@StatsArray);
1.79 matthew 703: undef(%SeqStat);
1.71 matthew 704: #
1.73 matthew 705: # Finally let the user know we are here
1.119 www 706: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Overall Problem Statistics',
707: 'Statistics_Overall_Key'));
708: &Apache::lonquickgrades::startGradeScreen($r,'statistics');
709:
1.87 matthew 710: my $interface = &CreateInterface($r);
1.57 matthew 711: $r->print($interface);
1.104 albertel 712: $r->print('<input type="hidden" name="sortby" value="'.$env{'form.sortby'}.
1.41 matthew 713: '" />');
1.73 matthew 714: #
1.117 bisitz 715: my @CacheButtonHTML =
1.87 matthew 716: &Apache::lonstathelpers::manage_caches($r,'Statistics','stats_status');
717: my $Str;
718: foreach my $html (@CacheButtonHTML) {
719: $Str.=$html.(' 'x5);
720: }
721: #
722: $r->print($Str);
1.104 albertel 723: if (! exists($env{'form.firstrun'})) {
1.117 bisitz 724: $r->print('<p class="LC_info"><b>'.
1.73 matthew 725: &mt('Press "Generate Statistics" when you are ready.').
1.117 bisitz 726: '</b></p>'.
727: '<p class="LC_info">'.
1.73 matthew 728: &mt('It may take some time to update the student data '.
1.117 bisitz 729: 'for the first analysis. Future analysis this session '.
1.113 bisitz 730: 'will not have this delay.').
1.73 matthew 731: '</p>');
1.105 albertel 732: &clean_up();
1.41 matthew 733: return;
1.28 stredwic 734: }
1.73 matthew 735: $r->rflush();
1.41 matthew 736: #
1.73 matthew 737: # This probably does not need to be done each time we are called, but
738: # it does not slow things down noticably.
739: &Apache::loncoursedata::populate_weight_table();
1.75 matthew 740: #
1.117 bisitz 741: ($navmap,@sequences) =
1.99 matthew 742: &Apache::lonstatistics::selected_sequences_with_assessments();
743: if (! ref($navmap)) {
1.115 bisitz 744: $r->print('<div class="LC_error">'.&mt('A course-wide error occurred.').'</div>'.
1.99 matthew 745: '<h3>'.$navmap.'</h3>');
1.105 albertel 746: &clean_up();
1.99 matthew 747: return;
748: }
1.104 albertel 749: if (exists($env{'form.Excel'})) {
1.122 golterma 750: $r->print('<p>'.
1.102 matthew 751: &Apache::lonstatistics::section_and_enrollment_description().
1.122 golterma 752: '</p>');
1.73 matthew 753: &Excel_output($r);
1.117 bisitz 754: } else {
1.87 matthew 755: $r->print('<input type="submit" name="Excel" value="'.
756: &mt('Produce Excel Output').'" />'.' 'x5);
757: $r->rflush();
1.122 golterma 758: $r->print('<p>'.
1.102 matthew 759: &Apache::lonstatistics::section_and_enrollment_description().
1.122 golterma 760: '</p>');
1.75 matthew 761: my $count = 0;
1.97 matthew 762: foreach my $seq (@sequences) {
1.117 bisitz 763: my @resources =
1.97 matthew 764: &Apache::lonstathelpers::get_resources($navmap,$seq);
765: $count += scalar(@resources);
1.75 matthew 766: }
767: if ($count > 10) {
1.123 bisitz 768: $r->print('<p>'.
769: &mt('Compiling statistics for [quant,_1,problem]',$count).
770: '</p>');
1.75 matthew 771: if ($count > 30) {
1.123 bisitz 772: $r->print('<p class="LC_info">'.&mt('This will take some time.').'</p>');
1.75 matthew 773: }
774: $r->rflush();
775: }
776: #
1.104 albertel 777: my $sortby = $env{'form.sortby'};
1.73 matthew 778: $sortby = 'container' if (! defined($sortby) || $sortby =~ /^\s*$/);
1.104 albertel 779: my $plot = $env{'form.plot'};
1.75 matthew 780: if ($plot eq '' || $plot eq 'none') {
781: undef($plot);
782: }
1.73 matthew 783: if ($sortby eq 'container' && ! defined($plot)) {
1.79 matthew 784: &output_sequence_statistics($r);
1.73 matthew 785: &output_html_by_sequence($r);
786: } else {
787: if (defined($plot)) {
788: &make_plot($r,$plot);
789: }
790: &output_html_stats($r);
1.79 matthew 791: &output_sequence_statistics($r);
1.73 matthew 792: }
793: }
1.105 albertel 794: &clean_up();
1.73 matthew 795: return;
796: }
797:
1.79 matthew 798: sub output_sequence_statistics {
799: my ($r) = @_;
800: my $c=$r->connection();
1.90 matthew 801: $r->print('<h2>'.&mt('Sequence Statistics').
802: &Apache::loncommon::help_open_topic('Statistics_Sequence').
803: '</h2>');
1.125 ! bisitz 804: $r->print(&Apache::loncommon::start_data_table());
1.79 matthew 805: $r->print(&sequence_html_header());
1.117 bisitz 806: foreach my $seq (@sequences) {
1.79 matthew 807: last if ($c->aborted);
808: &compute_sequence_statistics($seq);
809: $r->print(&sequence_html_output($seq));
810: }
1.122 golterma 811: $r->print(&Apache::loncommon::end_data_table());
1.79 matthew 812: $r->rflush();
813: return;
814: }
815:
816:
1.73 matthew 817: ##########################################################
818: ##########################################################
819: ##
820: ## HTML output routines
821: ##
822: ##########################################################
823: ##########################################################
824: sub output_html_by_sequence {
825: my ($r) = @_;
826: my $c = $r->connection();
1.125 ! bisitz 827: $r->print('<br />'.&html_preamble());
1.41 matthew 828: #
1.97 matthew 829: foreach my $seq (@sequences) {
1.73 matthew 830: last if ($c->aborted);
1.97 matthew 831: $r->print("<h3>".$seq->compTitle."</h3>".
1.122 golterma 832: &Apache::loncommon::start_data_table().
833: &Apache::loncommon::start_data_table_header_row().
834: &statistics_table_header('no container').
835: &Apache::loncommon::end_data_table_header_row()."\n");
1.73 matthew 836: my @Data = &compute_statistics_on_sequence($seq);
837: foreach my $data (@Data) {
1.122 golterma 838: $r->print(&Apache::loncommon::start_data_table_row().
839: &statistics_html_table_data($data,'no container').
840: &Apache::loncommon::end_data_table_row()."\n");
1.70 matthew 841: }
1.122 golterma 842: $r->print(&Apache::loncommon::end_data_table()."\n");
1.41 matthew 843: $r->rflush();
1.28 stredwic 844: }
1.41 matthew 845: return;
846: }
1.21 stredwic 847:
1.73 matthew 848: sub output_html_stats {
849: my ($r)=@_;
850: &compute_all_statistics($r);
851: $r->print(&html_preamble());
1.104 albertel 852: &sort_data($env{'form.sortby'});
1.73 matthew 853: #
854: my $count=0;
855: foreach my $data (@StatsArray) {
856: if ($count++ % 50 == 0) {
1.122 golterma 857: $r->print(&Apache::loncommon::end_data_table());
858: $r->print(&Apache::loncommon::start_data_table().
859: &Apache::loncommon::start_data_table_row().
860: &statistics_table_header().
861: &Apache::loncommon::end_data_table_row());
862: }
863: $r->print(&Apache::loncommon::start_data_table_row().
864: &statistics_html_table_data($data).
865: &Apache::loncommon::end_data_table_row());
1.73 matthew 866: }
1.122 golterma 867: $r->print(&Apache::loncommon::end_data_table_row());
1.73 matthew 868: return;
869: }
1.47 matthew 870:
1.73 matthew 871: sub html_preamble {
872: my $Str='';
873: $Str .= "<h2>".
1.104 albertel 874: $env{'course.'.$env{'request.course.id'}.'.description'}.
1.73 matthew 875: "</h2>\n";
876: my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
877: if (defined($starttime) || defined($endtime)) {
878: # Inform the user what the time limits on the data are.
879: $Str .= '<h3>'.&mt('Statistics on submissions from [_1] to [_2]',
880: &Apache::lonlocal::locallocaltime($starttime),
881: &Apache::lonlocal::locallocaltime($endtime)
882: ).'</h3>';
883: }
1.122 golterma 884: $Str .= "<p>".&mt('Compiled on [_1]',
885: &Apache::lonlocal::locallocaltime(time))."</p>";
1.73 matthew 886: return $Str;
887: }
1.47 matthew 888:
889:
1.44 matthew 890: ###############################################
891: ###############################################
1.73 matthew 892: ##
893: ## Misc HTML output routines
894: ##
895: ###############################################
896: ###############################################
897: sub statistics_html_table_data {
898: my ($data,$options) = @_;
899: my $row = '';
900: foreach my $field (@Fields) {
901: next if ($options =~ /no $field->{'name'}/);
1.76 matthew 902: next if ($field->{'selected'} ne 'yes');
1.122 golterma 903: $row .= '<td style="background-color:'.$field->{'color'}.'"';
1.73 matthew 904: if (exists($field->{'align'})) {
905: $row .= ' align="'.$field->{'align'}.'"';
1.41 matthew 906: }
1.73 matthew 907: $row .= '>';
908: if (exists($field->{'special'}) && $field->{'special'} eq 'link') {
909: $row .= '<a href="'.$data->{$field->{'name'}.'.link'}.'">';
1.41 matthew 910: }
1.92 matthew 911: if (exists($field->{'format'}) && $data->{$field->{'name'}} !~ /[A-Z]/i) {
1.73 matthew 912: $row .= sprintf($field->{'format'},$data->{$field->{'name'}});
913: } else {
914: $row .= $data->{$field->{'name'}};
915: }
916: if (exists($field->{'special'}) && $field->{'special'} eq 'link') {
917: $row.= '</a>';
918: }
919: $row .= '</td>';
1.21 stredwic 920: }
1.73 matthew 921: return $row;
1.41 matthew 922: }
1.25 stredwic 923:
1.73 matthew 924: sub statistics_table_header {
925: my ($options) = @_;
926: my $header_row;
927: foreach my $field (@Fields) {
928: next if ($options =~ /no $field->{'name'}/);
1.76 matthew 929: next if ($field->{'selected'} ne 'yes');
1.73 matthew 930: $header_row .= '<th>';
1.125 ! bisitz 931: my $header_row_text = &mt($field->{'title'});
1.73 matthew 932: if (exists($field->{'sortable'}) && $field->{'sortable'} eq 'yes') {
1.125 ! bisitz 933: $header_row .=
! 934: '<a href="javascript:'.
1.73 matthew 935: 'document.Statistics.sortby.value='."'".$field->{'name'}."'".
1.125 ! bisitz 936: ';document.Statistics.submit();">'.
! 937: $header_row_text.
! 938: '</a>';
! 939: } else {
! 940: $header_row .= $header_row_text;
1.73 matthew 941: }
942: if ($options !~ /no plots/ &&
943: exists($field->{'graphable'}) &&
944: $field->{'graphable'} eq 'yes') {
945: $header_row.=' (';
946: $header_row .= '<a href="javascript:'.
947: "document.Statistics.plot.value='$field->{'name'}'".
948: ';document.Statistics.submit();">';
949: $header_row .= &mt('plot').'</a>)';
950: }
951: $header_row .= '</th>';
952: }
953: return $header_row;
954: }
1.26 stredwic 955:
1.79 matthew 956: sub sequence_html_header {
1.125 ! bisitz 957: my $Str .= &Apache::loncommon::start_data_table_header_row();
1.79 matthew 958: foreach my $field (@SeqFields) {
959: # next if ($field->{'selected'} ne 'yes');
960: $Str .= '<th bgcolor="'.$field->{'color'}.'"';
1.125 ! bisitz 961: $Str .= '>'.&mt($field->{'title'}).'</th>';
1.79 matthew 962: }
1.125 ! bisitz 963: $Str .= &Apache::loncommon::end_data_table_header_row();
1.79 matthew 964: return $Str;
965: }
966:
967:
968: sub sequence_html_output {
969: my ($seq) = @_;
1.97 matthew 970: my $data = $SeqStat{$seq->symb};
1.125 ! bisitz 971: my $row = &Apache::loncommon::start_data_table_row();
1.79 matthew 972: foreach my $field (@SeqFields) {
1.82 matthew 973: next if ($field->{'selected'} ne 'yes');
1.79 matthew 974: $row .= '<td bgcolor="'.$field->{'color'}.'"';
975: if (exists($field->{'align'})) {
976: $row .= ' align="'.$field->{'align'}.'"';
977: }
978: $row .= '>';
979: if (exists($field->{'format'})) {
980: $row .= sprintf($field->{'format'},$data->{$field->{'name'}});
981: } else {
982: $row .= $data->{$field->{'name'}};
983: }
984: $row .= '</td>';
985: }
1.125 ! bisitz 986: $row .= &Apache::loncommon::end_data_table_row()."\n";
1.79 matthew 987: return $row;
988: }
989:
1.73 matthew 990: ####################################################
991: ####################################################
992: ##
993: ## Plotting Routines
994: ##
995: ####################################################
996: ####################################################
997: sub make_plot {
998: my ($r,$plot) = @_;
999: &compute_all_statistics($r);
1.104 albertel 1000: &sort_data($env{'form.sortby'});
1.73 matthew 1001: if ($plot eq 'degrees') {
1002: °rees_plot($r);
1.74 matthew 1003: } elsif ($plot eq 'tries statistics') {
1004: &tries_data_plot($r);
1.73 matthew 1005: } else {
1006: &make_single_stat_plot($r,$plot);
1007: }
1008: return;
1009: }
1.47 matthew 1010:
1.73 matthew 1011: sub make_single_stat_plot {
1012: my ($r,$datafield) = @_;
1.41 matthew 1013: #
1.73 matthew 1014: my $title; my $yaxis;
1015: foreach my $field (@Fields) {
1016: next if ($field->{'name'} ne $datafield);
1.123 bisitz 1017: $title = &mt($field->{'long_title'});
1018: $yaxis = &mt($field->{'title'});
1.73 matthew 1019: last;
1020: }
1021: if ($title eq '' || $yaxis eq '') {
1022: # datafield is something we do not know enough about to plot
1.123 bisitz 1023: $r->print('<p class="LC_warning">'.
1.73 matthew 1024: &mt('Unable to plot the requested statistic.').
1.123 bisitz 1025: '</p>');
1.73 matthew 1026: return;
1.49 matthew 1027: }
1028: #
1.73 matthew 1029: # Build up the data sets to plot
1.117 bisitz 1030: my @Labels;
1.73 matthew 1031: my @Data;
1032: my $max = 1;
1033: foreach my $data (@StatsArray) {
1034: push(@Labels,$data->{'problem_num'});
1035: push(@Data,$data->{$datafield});
1036: if ($data->{$datafield}>$max) {
1037: $max = $data->{$datafield};
1038: }
1039: }
1040: foreach (1,2,3,4,5,10,15,20,25,40,50,75,100,150,200,250,300,500,600,750,
1041: 1000,1500,2000,2500,3000,3500,4000,5000,7500,10000,15000,20000) {
1042: if ($max <= $_) {
1043: $max = $_;
1044: last;
1.42 matthew 1045: }
1046: }
1.73 matthew 1047: if ($max > 20000) {
1048: $max = 10000*(int($max/10000)+1);
1.42 matthew 1049: }
1.73 matthew 1050: #
1051: $r->print("<p>".&Apache::loncommon::DrawBarGraph($title,
1.123 bisitz 1052: &mt('Problem Number'),
1.73 matthew 1053: $yaxis,
1054: $max,
1055: undef, # colors
1056: \@Labels,
1057: \@Data)."</p>\n");
1058: return;
1059: }
1060:
1061: sub degrees_plot {
1062: my ($r)=@_;
1063: my $count = scalar(@StatsArray);
1064: my $width = 50 + 10*$count;
1065: $width = 300 if ($width < 300);
1066: my $height = 300;
1067: my $plot = '';
1068: my $ymax = 0;
1069: my $ymin = 0;
1.117 bisitz 1070: my @Disc; my @Diff; my @Labels;
1.73 matthew 1071: foreach my $data (@StatsArray) {
1072: push(@Labels,$data->{'problem_num'});
1073: my $disc = $data->{'deg_of_disc'};
1074: my $diff = $data->{'deg_of_diff'};
1075: push(@Disc,$disc);
1076: push(@Diff,$diff);
1077: #
1078: $ymin = $disc if ($ymin > $disc);
1079: $ymin = $diff if ($ymin > $diff);
1080: $ymax = $disc if ($ymax < $disc);
1081: $ymax = $diff if ($ymax < $diff);
1082: }
1083: #
1084: # Make sure we show relevant information.
1085: if ($ymin < 0) {
1086: if (abs($ymin) < 0.05) {
1087: $ymin = 0;
1088: } else {
1089: $ymin = -1;
1.42 matthew 1090: }
1091: }
1.73 matthew 1092: if ($ymax > 0) {
1093: if (abs($ymax) < 0.05) {
1094: $ymax = 0;
1.42 matthew 1095: } else {
1.73 matthew 1096: $ymax = 1;
1.42 matthew 1097: }
1.43 matthew 1098: }
1.49 matthew 1099: #
1.73 matthew 1100: my $xmax = $Labels[-1];
1101: if ($xmax > 50) {
1102: if ($xmax % 10 != 0) {
1103: $xmax = 10 * (int($xmax/10)+1);
1104: }
1105: } else {
1106: if ($xmax % 5 != 0) {
1107: $xmax = 5 * (int($xmax/5)+1);
1.49 matthew 1108: }
1.26 stredwic 1109: }
1.41 matthew 1110: #
1.73 matthew 1111: my $discdata .= '<data>'.join(',',@Labels).'</data>'.$/.
1112: '<data>'.join(',',@Disc).'</data>'.$/;
1113: #
1114: my $diffdata .= '<data>'.join(',',@Labels).'</data>'.$/.
1115: '<data>'.join(',',@Diff).'</data>'.$/;
1116: #
1.123 bisitz 1117: my $title = &mt('Degree of Discrimination[_1]and Degree of Difficulty','\n');
1.81 matthew 1118: if ($xmax > 50) {
1.123 bisitz 1119: $title = &mt('Degree of Discrimination and Degree of Difficulty');
1.81 matthew 1120: }
1.123 bisitz 1121: my %lt = &Apache::lonlocal::texthash(
1122: 'alttag' => 'Degree of Discrimination and Degree of Difficulty Plot',
1123: 'xlabel' => 'Problem Number',
1124: );
1.81 matthew 1125: #
1.73 matthew 1126: $plot=<<"END";
1127: <gnuplot
1128: texfont="10"
1129: fgcolor="x000000"
1130: plottype="Cartesian"
1131: font="large"
1132: grid="on"
1133: align="center"
1134: border="on"
1135: transparent="on"
1.123 bisitz 1136: alttag="$lt{'alttag'}"
1.73 matthew 1137: samples="100"
1138: bgcolor="xffffff"
1139: height="$height"
1140: width="$width">
1141: <key
1142: pos="top right"
1143: title=""
1144: box="off" />
1.81 matthew 1145: <title>$title</title>
1.73 matthew 1146: <axis xmin="0" ymin="$ymin" xmax="$xmax" ymax="$ymax" color="x000000" />
1.123 bisitz 1147: <xlabel>$lt{'xlabel'}</xlabel>
1.73 matthew 1148: <curve
1149: linestyle="linespoints"
1150: name="DoDisc"
1151: pointtype="0"
1152: color="x000000">
1153: $discdata
1154: </curve>
1155: <curve
1156: linestyle="linespoints"
1157: name="DoDiff"
1158: pointtype="0"
1159: color="xFF0000">
1160: $diffdata
1161: </curve>
1162: </gnuplot>
1163: END
1.117 bisitz 1164: my $plotresult =
1.73 matthew 1165: '<p>'.&Apache::lonxml::xmlparse($r,'web',$plot).'</p>'.$/;
1166: $r->print($plotresult);
1.41 matthew 1167: return;
1.42 matthew 1168: }
1169:
1.74 matthew 1170: sub tries_data_plot {
1171: my ($r)=@_;
1172: my $count = scalar(@StatsArray);
1173: my $width = 50 + 10*$count;
1174: $width = 300 if ($width < 300);
1175: my $height = 300;
1176: my $plot = '';
1177: my @STD; my @Mean; my @Max; my @Min;
1178: my @Labels;
1179: my $ymax = 5;
1180: foreach my $data (@StatsArray) {
1181: my $max = $data->{'mean_tries'} + $data->{'std_tries'};
1182: $ymax = $max if ($ymax < $max);
1183: $ymax = $max if ($ymax < $max);
1184: push(@Labels,$data->{'problem_num'});
1185: push(@STD,$data->{'std_tries'});
1186: push(@Mean,$data->{'mean_tries'});
1187: }
1188: #
1189: # Make sure we show relevant information.
1190: my $xmax = $Labels[-1];
1191: if ($xmax > 50) {
1192: if ($xmax % 10 != 0) {
1193: $xmax = 10 * (int($xmax/10)+1);
1194: }
1195: } else {
1196: if ($xmax % 5 != 0) {
1197: $xmax = 5 * (int($xmax/5)+1);
1198: }
1199: }
1200: $ymax = int($ymax)+1+2;
1201: #
1202: my $std_data .= '<data>'.join(',',@Labels).'</data>'.$/.
1203: '<data>'.join(',',@Mean).'</data>'.$/;
1204: #
1205: my $std_error_data .= '<data>'.join(',',@Labels).'</data>'.$/.
1206: '<data>'.join(',',@Mean).'</data>'.$/.
1207: '<data>'.join(',',@STD).'</data>'.$/;
1208: #
1.123 bisitz 1209: my $title = &mt('Mean and S.D. of Tries');
1210: if ($xmax > 30) {
1211: $title = &mt('Mean and Standard Deviation of Tries');
1.81 matthew 1212: }
1213: #
1.123 bisitz 1214: my %lt = &Apache::lonlocal::texthash(
1215: 'alttag' => 'Mean and S.D of Tries Plot',
1216: 'xlabel' => 'Problem Number',
1217: 'ylabel' => 'Number of Tries',
1218: );
1.74 matthew 1219: $plot=<<"END";
1220: <gnuplot
1221: texfont="10"
1222: fgcolor="x000000"
1223: plottype="Cartesian"
1224: font="large"
1225: grid="on"
1226: align="center"
1227: border="on"
1228: transparent="on"
1.123 bisitz 1229: alttag="$lt{'alttag'}"
1.74 matthew 1230: samples="100"
1231: bgcolor="xffffff"
1232: height="$height"
1233: width="$width">
1.81 matthew 1234: <title>$title</title>
1.74 matthew 1235: <axis xmin="0" ymin="0" xmax="$xmax" ymax="$ymax" color="x000000" />
1.123 bisitz 1236: <xlabel>$lt{'xlabel'}</xlabel>
1237: <ylabel>$lt{'ylabel'}</ylabel>
1.74 matthew 1238: <curve
1239: linestyle="yerrorbars"
1240: name="S.D. Tries"
1241: pointtype="1"
1242: color="x666666">
1243: $std_error_data
1244: </curve>
1245: <curve
1246: linestyle="points"
1247: name="Mean Tries"
1248: pointtype="1"
1249: color="xCC4444">
1250: $std_data
1251: </curve>
1252: </gnuplot>
1253: END
1.117 bisitz 1254: my $plotresult =
1.74 matthew 1255: '<p>'.&Apache::lonxml::xmlparse($r,'web',$plot).'</p>'.$/;
1256: $r->print($plotresult);
1257: return;
1258: }
1259:
1.73 matthew 1260: sub plot_dropdown {
1261: my $current = '';
1.123 bisitz 1262: my $title;
1.73 matthew 1263: #
1.104 albertel 1264: if (defined($env{'form.plot'})) {
1265: $current = $env{'form.plot'};
1.73 matthew 1266: }
1267: #
1268: my @Additional_Plots = (
1269: { graphable=>'yes',
1270: name => 'degrees',
1.81 matthew 1271: title => 'Difficulty Indexes' },
1.74 matthew 1272: { graphable=>'yes',
1273: name => 'tries statistics',
1.81 matthew 1274: title => 'Tries Statistics' });
1.73 matthew 1275: #
1276: my $Str= "\n".'<select name="plot" size="1">';
1277: $Str .= '<option name="none"></option>'."\n";
1.123 bisitz 1278: $Str .= '<option name="none2">'.&mt('none').'</option>'."\n";
1.81 matthew 1279: foreach my $field (@Additional_Plots,@Fields) {
1.73 matthew 1280: if (! exists($field->{'graphable'}) ||
1281: $field->{'graphable'} ne 'yes') {
1282: next;
1283: }
1284: $Str .= '<option value="'.$field->{'name'}.'"';
1285: if ($field->{'name'} eq $current) {
1.123 bisitz 1286: $Str .= ' selected="selected"';
1.73 matthew 1287: }
1.123 bisitz 1288: $title = &mt($field->{'long_title'});
1289: $title = &mt($field->{'title'}) if (!$title);
1290: $Str.= '>'.$title.'</option>'."\n";
1.73 matthew 1291: }
1292: $Str .= '</select>'."\n";
1293: return $Str;
1294: }
1295:
1.41 matthew 1296: ###############################################
1297: ###############################################
1.73 matthew 1298: ##
1299: ## Excel output routines
1300: ##
1.41 matthew 1301: ###############################################
1302: ###############################################
1.73 matthew 1303: sub Excel_output {
1.44 matthew 1304: my ($r) = @_;
1.73 matthew 1305: $r->print('<h2>'.&mt('Preparing Excel Spreadsheet').'</h2>');
1306: ##
1307: ## Compute the statistics
1308: &compute_all_statistics($r);
1309: my $c = $r->connection;
1310: return if ($c->aborted());
1.101 matthew 1311: #
1312: my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
1.73 matthew 1313: ##
1314: ## Create the excel workbook
1.101 matthew 1315: my ($excel_workbook,$filename,$format) =
1316: &Apache::loncommon::create_workbook($r);
1317: return if (! defined($excel_workbook));
1.44 matthew 1318: #
1319: # Add a worksheet
1.104 albertel 1320: my $sheetname = $env{'course.'.$env{'request.course.id'}.'.description'};
1.44 matthew 1321: if (length($sheetname) > 31) {
1322: $sheetname = substr($sheetname,0,31);
1323: }
1.73 matthew 1324: my $excel_sheet = $excel_workbook->addworksheet(
1325: &Apache::loncommon::clean_excel_name($sheetname));
1326: ##
1327: ## Begin creating excel sheet
1328: ##
1329: my ($rows_output,$cols_output) = (0,0);
1.44 matthew 1330: #
1331: # Put the course description in the header
1332: $excel_sheet->write($rows_output,$cols_output++,
1.104 albertel 1333: $env{'course.'.$env{'request.course.id'}.'.description'},
1.82 matthew 1334: $format->{'h1'});
1.44 matthew 1335: $cols_output += 3;
1336: #
1337: # Put a description of the sections listed
1338: my $sectionstring = '';
1.82 matthew 1339: $excel_sheet->write($rows_output,$cols_output++,
1.103 matthew 1340: &Apache::lonstatistics::section_and_enrollment_description('plaintext'),
1.82 matthew 1341: $format->{'h3'});
1.102 matthew 1342: $cols_output += scalar(&Apache::lonstatistics::get_selected_sections());
1.108 raeburn 1343: $cols_output += scalar(&Apache::lonstatistics::get_selected_groups());
1.44 matthew 1344: #
1.70 matthew 1345: # Time restrictions
1346: my $time_string;
1347: if (defined($starttime)) {
1348: if (defined($endtime)) {
1.125 ! bisitz 1349: $time_string .= &mt('Data collected from [_1] to [_2]',
! 1350: &Apache::lonlocal::locallocaltime($starttime),
! 1351: &Apache::lonlocal::locallocaltime($endtime));
! 1352: } else {
! 1353: $time_string .= &mt('Data collected from [_1]',
! 1354: &Apache::lonlocal::locallocaltime($starttime));
1.70 matthew 1355: }
1356: } elsif (defined($endtime)) {
1.125 ! bisitz 1357: $time_string .= &mt('Data collected before [_1]',
! 1358: &Apache::lonlocal::locallocaltime($endtime));
1.70 matthew 1359: }
1.82 matthew 1360: if (defined($time_string)) {
1361: $excel_sheet->write($rows_output,$cols_output++,$time_string);
1362: $cols_output+= 5;
1363: }
1.70 matthew 1364: #
1.44 matthew 1365: # Put the date in there too
1366: $excel_sheet->write($rows_output,$cols_output++,
1.125 ! bisitz 1367: &mt('Compiled on [_1]',&Apache::lonlocal::locallocaltime(time)));
1.44 matthew 1368: #
1.117 bisitz 1369: $rows_output++;
1.44 matthew 1370: $cols_output=0;
1.82 matthew 1371: ##
1372: ## Sequence Statistics
1.117 bisitz 1373: ##
1.82 matthew 1374: &write_headers($excel_sheet,$format,\$rows_output,\$cols_output,
1375: \@SeqFields);
1.97 matthew 1376: foreach my $seq (@sequences) {
1377: my $data = $SeqStat{$seq->symb};
1.82 matthew 1378: $cols_output=0;
1379: foreach my $field (@SeqFields) {
1380: next if ($field->{'selected'} ne 'yes');
1.85 matthew 1381: my $fieldformat = undef;
1382: if (exists($field->{'excel_format'})) {
1383: $fieldformat = $format->{$field->{'excel_format'}};
1384: }
1.55 matthew 1385: $excel_sheet->write($rows_output,$cols_output++,
1.85 matthew 1386: $data->{$field->{'name'}},$fieldformat);
1.55 matthew 1387: }
1.82 matthew 1388: $rows_output++;
1389: $cols_output=0;
1.55 matthew 1390: }
1.82 matthew 1391: ##
1392: ## Resource Statistics
1393: ##
1.55 matthew 1394: $rows_output++;
1395: $cols_output=0;
1.82 matthew 1396: &write_headers($excel_sheet,$format,\$rows_output,\$cols_output,
1397: \@Fields);
1398: #
1.73 matthew 1399: foreach my $data (@StatsArray) {
1400: $cols_output=0;
1401: foreach my $field (@Fields) {
1.76 matthew 1402: next if ($field->{'selected'} ne 'yes');
1.73 matthew 1403: next if ($field->{'name'} eq 'problem_num');
1.85 matthew 1404: my $fieldformat = undef;
1405: if (exists($field->{'excel_format'})) {
1406: $fieldformat = $format->{$field->{'excel_format'}};
1407: }
1.73 matthew 1408: $excel_sheet->write($rows_output,$cols_output++,
1.85 matthew 1409: $data->{$field->{'name'}},$fieldformat);
1.44 matthew 1410: }
1.73 matthew 1411: $rows_output++;
1.82 matthew 1412: $cols_output=0;
1.44 matthew 1413: }
1414: #
1415: $excel_workbook->close();
1.73 matthew 1416: #
1.44 matthew 1417: # Tell the user where to get their excel file
1418: $r->print('<br />'.
1.59 matthew 1419: '<a href="'.$filename.'">'.
1420: &mt('Your Excel Spreadsheet').'</a>'."\n");
1.44 matthew 1421: $r->rflush();
1422: return;
1423: }
1424:
1.82 matthew 1425: ##
1426: ## &write_headers
1427: ##
1428: sub write_headers {
1429: my ($excel_sheet,$format,$rows_output,$cols_output,$Fields) = @_;
1430: ##
1431: ## First the long titles
1432: foreach my $field (@{$Fields}) {
1433: next if ($field->{'name'} eq 'problem_num');
1434: next if ($field->{'selected'} ne 'yes');
1435: if (exists($field->{'long_title'})) {
1436: $excel_sheet->write($$rows_output,${$cols_output},
1437: $field->{'long_title'},
1438: $format->{'bold'});
1439: } else {
1440: $excel_sheet->write($$rows_output,${$cols_output},'');
1441: }
1442: ${$cols_output}+= 1;
1443: }
1444: ${$cols_output} =0;
1445: ${$rows_output}+=1;
1446: ##
1447: ## Then the short titles
1448: foreach my $field (@{$Fields}) {
1449: next if ($field->{'selected'} ne 'yes');
1450: next if ($field->{'name'} eq 'problem_num');
1.117 bisitz 1451: # Use english for excel as I am not sure how well excel handles
1.82 matthew 1452: # other character sets....
1453: $excel_sheet->write($$rows_output,$$cols_output,
1454: $field->{'title'},
1455: $format->{'bold'});
1456: $$cols_output+=1;
1457: }
1458: ${$cols_output} =0;
1459: ${$rows_output}+=1;
1460: return;
1461: }
1462:
1.73 matthew 1463: ##################################################
1464: ##################################################
1465: ##
1466: ## Statistics Gathering and Manipulation Routines
1467: ##
1468: ##################################################
1469: ##################################################
1470: sub compute_statistics_on_sequence {
1471: my ($seq) = @_;
1472: my @Data;
1.97 matthew 1473: foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq)) {
1474: foreach my $part (@{$res->parts}) {
1.118 raeburn 1475: next if (($res->is_survey($part)) || ($res->is_anonsurvey($part))) ;
1.73 matthew 1476: #
1477: # This is where all the work happens
1478: my $data = &get_statistics($seq,$res,$part,scalar(@StatsArray)+1);
1479: push (@Data,$data);
1480: push (@StatsArray,$data);
1.49 matthew 1481: }
1.26 stredwic 1482: }
1.73 matthew 1483: return @Data;
1.41 matthew 1484: }
1.26 stredwic 1485:
1.73 matthew 1486: sub compute_all_statistics {
1487: my ($r) = @_;
1488: if (@StatsArray > 0) {
1489: # Assume we have already computed the statistics
1490: return;
1491: }
1492: my $c = $r->connection;
1.97 matthew 1493: foreach my $seq (@sequences) {
1.73 matthew 1494: last if ($c->aborted);
1.82 matthew 1495: &compute_sequence_statistics($seq);
1.73 matthew 1496: &compute_statistics_on_sequence($seq);
1.49 matthew 1497: }
1498: }
1499:
1.73 matthew 1500: sub sort_data {
1501: my ($sortkey) = @_;
1502: return if (! @StatsArray);
1.45 matthew 1503: #
1.73 matthew 1504: # Sort the data
1505: my $sortby = undef;
1.49 matthew 1506: foreach my $field (@Fields) {
1.73 matthew 1507: if ($sortkey eq $field->{'name'}) {
1508: $sortby = $field->{'name'};
1.45 matthew 1509: }
1.26 stredwic 1510: }
1.73 matthew 1511: if (! defined($sortby) || $sortby eq '' || $sortby eq 'problem_num') {
1512: $sortby = 'container';
1513: }
1514: if ($sortby ne 'container') {
1515: # $sortby is already defined, so we can charge ahead
1516: if ($sortby =~ /^(title|part)$/i) {
1517: # Alpha comparison
1518: @StatsArray = sort {
1519: lc($a->{$sortby}) cmp lc($b->{$sortby}) ||
1520: lc($a->{'title'}) cmp lc($b->{'title'}) ||
1521: lc($a->{'part'}) cmp lc($b->{'part'});
1522: } @StatsArray;
1.24 stredwic 1523: } else {
1.73 matthew 1524: # Numerical comparison
1525: @StatsArray = sort {
1526: my $retvalue = 0;
1527: if ($b->{$sortby} eq 'nan') {
1528: if ($a->{$sortby} ne 'nan') {
1529: $retvalue = -1;
1530: } else {
1531: $retvalue = 0;
1532: }
1533: }
1534: if ($a->{$sortby} eq 'nan') {
1535: if ($b->{$sortby} ne 'nan') {
1536: $retvalue = 1;
1537: }
1538: }
1539: if ($retvalue eq '0') {
1540: $retvalue = $b->{$sortby} <=> $a->{$sortby} ||
1541: lc($a->{'title'}) <=> lc($b->{'title'}) ||
1542: lc($a->{'part'}) <=> lc($b->{'part'});
1543: }
1544: $retvalue;
1545: } @StatsArray;
1.24 stredwic 1546: }
1547: }
1.45 matthew 1548: #
1.73 matthew 1549: # Renumber the data set
1550: my $count;
1551: foreach my $data (@StatsArray) {
1552: $data->{'problem_num'} = ++$count;
1553: }
1.24 stredwic 1554: return;
1.48 matthew 1555: }
1556:
1.70 matthew 1557: ########################################################
1558: ########################################################
1559:
1560: =pod
1561:
1562: =item &get_statistics()
1563:
1.117 bisitz 1564: Wrapper routine from the call to loncoursedata::get_problem_statistics.
1.73 matthew 1565: Calls lonstathelpers::get_time_limits() to limit the data set by time
1566: and &compute_discrimination_factor
1.70 matthew 1567:
1568: Inputs: $sequence, $resource, $part, $problem_num
1569:
1.117 bisitz 1570: Returns: Hash reference with statistics data from
1.70 matthew 1571: loncoursedata::get_problem_statistics.
1572:
1573: =cut
1574:
1575: ########################################################
1576: ########################################################
1.48 matthew 1577: sub get_statistics {
1.49 matthew 1578: my ($sequence,$resource,$part,$problem_num) = @_;
1.48 matthew 1579: #
1.70 matthew 1580: my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
1.97 matthew 1581: my $symb = $resource->symb;
1.104 albertel 1582: my $courseid = $env{'request.course.id'};
1.48 matthew 1583: #
1.49 matthew 1584: my $data = &Apache::loncoursedata::get_problem_statistics
1.102 matthew 1585: ([&Apache::lonstatistics::get_selected_sections()],
1.108 raeburn 1586: [&Apache::lonstatistics::get_selected_groups()],
1.66 matthew 1587: $Apache::lonstatistics::enrollment_status,
1.70 matthew 1588: $symb,$part,$courseid,$starttime,$endtime);
1.85 matthew 1589: $data->{'symb'} = $symb;
1.49 matthew 1590: $data->{'part'} = $part;
1591: $data->{'problem_num'} = $problem_num;
1.97 matthew 1592: $data->{'container'} = $sequence->compTitle;
1593: $data->{'title'} = $resource->compTitle;
1594: $data->{'title.link'} = $resource->src.'?symb='.
1.109 www 1595: &escape($resource->symb);
1.49 matthew 1596: #
1.76 matthew 1597: if ($SelectedFields{'deg_of_disc'}) {
1.117 bisitz 1598: $data->{'deg_of_disc'} =
1.76 matthew 1599: &compute_discrimination_factor($resource,$part,$sequence);
1600: }
1.83 matthew 1601: #
1602: # Store in metadata if computations were done for all students
1.84 matthew 1603: if ($data->{'num_students'} > 1) {
1.102 matthew 1604: my @Sections = &Apache::lonstatistics::get_selected_sections();
1.84 matthew 1605: my $sections = '"'.join(' ',@Sections).'"';
1606: $sections =~ s/&+/_/g; # Ensure no special characters
1607: $data->{'sections'}=$sections;
1.104 albertel 1608: $data->{'course'} = $env{'request.course.id'};
1.97 matthew 1609: my $urlres=(&Apache::lonnet::decode_symb($resource->symb))[2];
1.117 bisitz 1610: my %storestats =
1.84 matthew 1611: &LONCAPA::lonmetadata::dynamic_metadata_storage($data);
1.117 bisitz 1612: my ($dom,$user) = ($urlres=~m{^($LONCAPA::domain_re)/($LONCAPA::username_re)});
1.83 matthew 1613: &Apache::lonnet::put('nohist_resevaldata',\%storestats,$dom,$user);
1614: }
1.85 matthew 1615: #
1.95 matthew 1616: $data->{'tries_per_correct'} = $data->{'tries'} /
1617: ($data->{'num_solved'}+0.1);
1618: #
1.85 matthew 1619: # Get the due date for research purposes (commented out most of the time)
1.112 raeburn 1620: # my $duedate = &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb);;
1621: # my $opendate = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb);
1622: # my $maxtries = &Apache::lonnet::EXT('resource.'.$part.'.maxtries',$symb);
1623: # my $hinttries = &Apache::lonnet::EXT('resource.'.$part.'.hinttries',$symb);
1624: my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',$symb);
1625: $data->{'weight'} = $weight;
1.117 bisitz 1626: # $data->{'duedate'} = $duedate;
1.112 raeburn 1627: # $data->{'opendate'} = $opendate;
1628: # $data->{'maxtries'} = $maxtries;
1629: # $data->{'hinttries'} = $hinttries;
1.86 matthew 1630: # $data->{'resptypes'} = join(',',@{$resource->{'partdata'}->{$part}->{'ResponseTypes'}});
1.49 matthew 1631: return $data;
1.71 matthew 1632: }
1633:
1634: ###############################################
1635: ###############################################
1636:
1637: =pod
1638:
1639: =item &compute_discrimination_factor()
1640:
1641: Inputs: $Resource, $Sequence
1642:
1643: Returns: integer between -1 and 1
1644:
1645: =cut
1646:
1647: ###############################################
1648: ###############################################
1649: sub compute_discrimination_factor {
1.97 matthew 1650: my ($resource,$part,$seq) = @_;
1651: my $symb = $resource->symb;
1.71 matthew 1652: my @Resources;
1.97 matthew 1653: foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq)){
1654: next if ($res->symb eq $symb);
1655: push (@Resources,$res->symb);
1.71 matthew 1656: }
1657: #
1658: # rank
1.83 matthew 1659: my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
1.117 bisitz 1660: my $ranking =
1.71 matthew 1661: &Apache::loncoursedata::rank_students_by_scores_on_resources
1662: (\@Resources,
1.102 matthew 1663: [&Apache::lonstatistics::get_selected_sections()],
1.108 raeburn 1664: [&Apache::lonstatistics::get_selected_groups()],
1.83 matthew 1665: $Apache::lonstatistics::enrollment_status,undef,
1.106 bowersj2 1666: $starttime,$endtime, $symb);
1.71 matthew 1667: #
1668: # compute their percent scores on the problems in the sequence,
1669: my $number_to_grab = int(scalar(@{$ranking})/4);
1670: my $num_students = scalar(@{$ranking});
1.117 bisitz 1671: my @BottomSet = map { $_->[&Apache::loncoursedata::RNK_student()];
1.71 matthew 1672: } @{$ranking}[0..$number_to_grab];
1.117 bisitz 1673: my @TopSet =
1674: map {
1675: $_->[&Apache::loncoursedata::RNK_student()];
1.106 bowersj2 1676: } @{$ranking}[-$number_to_grab..0];
1.91 matthew 1677: if (! @BottomSet || (@BottomSet == 1 && $BottomSet[0] eq '') ||
1678: ! @TopSet || (@TopSet == 1 && $TopSet[0] eq '')) {
1679: return 'nan';
1680: }
1.117 bisitz 1681: my ($bottom_sum,$bottom_max) =
1.97 matthew 1682: &Apache::loncoursedata::get_sum_of_scores($symb,$part,\@BottomSet,
1.83 matthew 1683: undef,$starttime,$endtime);
1.117 bisitz 1684: my ($top_sum,$top_max) =
1.97 matthew 1685: &Apache::loncoursedata::get_sum_of_scores($symb,$part,\@TopSet,
1.83 matthew 1686: undef,$starttime,$endtime);
1.71 matthew 1687: my $deg_of_disc;
1688: if ($top_max == 0 || $bottom_max==0) {
1689: $deg_of_disc = 'nan';
1690: } else {
1691: $deg_of_disc = ($top_sum/$top_max) - ($bottom_sum/$bottom_max);
1692: }
1693: #&Apache::lonnet::logthis(' '.$top_sum.'/'.$top_max.
1694: # ' - '.$bottom_sum.'/'.$bottom_max);
1695: return $deg_of_disc;
1.1 stredwic 1696: }
1.12 minaeibi 1697:
1.45 matthew 1698: ###############################################
1699: ###############################################
1.79 matthew 1700: ##
1701: ## Compute KR-21
1702: ##
1703: ## To compute KR-21, you need the following information:
1704: ##
1705: ## K=the number of items in your test
1706: ## M=the mean score on the test
1.117 bisitz 1707: ## s=the standard deviation of the scores on your test
1.79 matthew 1708: ##
1709: ## then:
1.117 bisitz 1710: ##
1.79 matthew 1711: ## KR-21 rk= [K/(K-1)] * [1- (M*(K-M))/(K*s^2))]
1712: ##
1713: ###############################################
1714: ###############################################
1715: sub compute_sequence_statistics {
1716: my ($seq) = @_;
1.97 matthew 1717: my $symb = $seq->symb;
1.79 matthew 1718: my @Resources;
1.97 matthew 1719: my $part_count;
1720: foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq)) {
1721: push (@Resources,$res->symb);
1722: $part_count += scalar(@{$res->parts});
1.79 matthew 1723: }
1724: my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
1725: #
1726: # First compute statistics based on student scores
1.117 bisitz 1727: my ($smin,$smax,$sMean,$sSTD,$scount,$sMAX) =
1.79 matthew 1728: &Apache::loncoursedata::score_stats
1.102 matthew 1729: ([&Apache::lonstatistics::get_selected_sections()],
1.108 raeburn 1730: [&Apache::lonstatistics::get_selected_groups()],
1.79 matthew 1731: $Apache::lonstatistics::enrollment_status,
1732: \@Resources,$starttime,$endtime,undef);
1.97 matthew 1733: $SeqStat{$symb}->{'title'} = $seq->compTitle;
1.79 matthew 1734: $SeqStat{$symb}->{'scoremax'} = $smax;
1735: $SeqStat{$symb}->{'scoremin'} = $smin;
1736: $SeqStat{$symb}->{'scoremean'} = $sMean;
1737: $SeqStat{$symb}->{'scorestd'} = $sSTD;
1738: $SeqStat{$symb}->{'scorecount'} = $scount;
1739: $SeqStat{$symb}->{'max_possible'} = $sMAX;
1740: #
1741: # Compute statistics based on the number of correct problems
1.117 bisitz 1742: # 'correct' is taken to mean
1.79 matthew 1743: my ($cmin,$cmax,$cMean,$cSTD,$ccount)=
1744: &Apache::loncoursedata::count_stats
1.102 matthew 1745: ([&Apache::lonstatistics::get_selected_sections()],
1.108 raeburn 1746: [&Apache::lonstatistics::get_selected_groups()],
1.79 matthew 1747: $Apache::lonstatistics::enrollment_status,
1748: \@Resources,$starttime,$endtime,undef);
1.97 matthew 1749: my $K = $part_count;
1.79 matthew 1750: my $kr_21;
1751: if ($K > 1 && $cSTD > 0) {
1752: $kr_21 = ($K/($K-1)) * (1 - $cMean*($K-$cMean)/($K*$cSTD**2));
1753: } else {
1754: $kr_21 = 'nan';
1755: }
1756: $SeqStat{$symb}->{'countmax'} = $cmax;
1757: $SeqStat{$symb}->{'countmin'} = $cmin;
1758: $SeqStat{$symb}->{'countstd'} = $cSTD;
1.82 matthew 1759: $SeqStat{$symb}->{'countmean'} = $cMean;
1.79 matthew 1760: $SeqStat{$symb}->{'count'} = $ccount;
1761: $SeqStat{$symb}->{'items'} = $K;
1762: $SeqStat{$symb}->{'KR-21'}=$kr_21;
1763: return;
1764: }
1765:
1766:
1.47 matthew 1767:
1768: =pod
1769:
1.73 matthew 1770: =item ProblemStatisticsLegend
1771:
1772: =over 4
1773:
1774: =item #Stdnts
1775: Total number of students attempted the problem.
1776:
1777: =item Tries
1778: Total number of tries for solving the problem.
1.59 matthew 1779:
1.73 matthew 1780: =item Max Tries
1781: Largest number of tries for solving the problem by a student.
1782:
1783: =item Mean
1784: Average number of tries. [ Tries / #Stdnts ]
1785:
1786: =item #YES
1787: Number of students solved the problem correctly.
1788:
1789: =item #yes
1790: Number of students solved the problem by override.
1791:
1792: =item %Wrong
1793: Percentage of students who tried to solve the problem
1794: but is still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]
1795:
1796: =item DoDiff
1797: Degree of Difficulty of the problem.
1798: [ 1 - ((#YES+#yes) / Tries) ]
1799:
1800: =item S.D.
1801: Standard Deviation of the tries.
1802: [ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1)
1803: where Xi denotes every student\'s tries ]
1804:
1805: =item Skew.
1806: Skewness of the students tries.
1807: [(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]
1808:
1809: =item Dis.F.
1810: Discrimination Factor: A Standard for evaluating the
1811: problem according to a Criterion<br>
1812:
1813: =item [Criterion to group students into %27 Upper Students -
1814: and %27 Lower Students]
1815: 1st Criterion for Sorting the Students:
1816: Sum of Partial Credit Awarded / Total Number of Tries
1817: 2nd Criterion for Sorting the Students:
1818: Total number of Correct Answers / Total Number of Tries
1819:
1820: =item Disc.
1821: Number of Students had at least one discussion.
1822:
1823: =back
1.47 matthew 1824:
1825: =cut
1.73 matthew 1826:
1827: ############################################################
1828: ############################################################
1.4 minaeibi 1829:
1.1 stredwic 1830: 1;
1831: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>