Annotation of loncom/interface/statistics/lonproblemstatistics.pm, revision 1.127
1.1 stredwic 1: # The LearningOnline Network with CAPA
2: #
1.127 ! raeburn 3: # $Id: lonproblemstatistics.pm,v 1.126 2014/02/28 19:20:17 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: #
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.126 bisitz 186: long_title => 'Minimum Number of Tries',
1.76 matthew 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',
1.126 bisitz 442: long_title => 'Minimum Sequence Score',
1.79 matthew 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',
1.126 bisitz 497: long_title => 'Minimum Number of Correct Problems',
1.79 matthew 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.127 ! raeburn 762: my $include_tools = 1;
1.97 matthew 763: foreach my $seq (@sequences) {
1.117 bisitz 764: my @resources =
1.127 ! raeburn 765: &Apache::lonstathelpers::get_resources($navmap,$seq,$include_tools);
1.97 matthew 766: $count += scalar(@resources);
1.75 matthew 767: }
768: if ($count > 10) {
1.123 bisitz 769: $r->print('<p>'.
770: &mt('Compiling statistics for [quant,_1,problem]',$count).
771: '</p>');
1.75 matthew 772: if ($count > 30) {
1.123 bisitz 773: $r->print('<p class="LC_info">'.&mt('This will take some time.').'</p>');
1.75 matthew 774: }
775: $r->rflush();
776: }
777: #
1.104 albertel 778: my $sortby = $env{'form.sortby'};
1.73 matthew 779: $sortby = 'container' if (! defined($sortby) || $sortby =~ /^\s*$/);
1.104 albertel 780: my $plot = $env{'form.plot'};
1.75 matthew 781: if ($plot eq '' || $plot eq 'none') {
782: undef($plot);
783: }
1.73 matthew 784: if ($sortby eq 'container' && ! defined($plot)) {
1.79 matthew 785: &output_sequence_statistics($r);
1.73 matthew 786: &output_html_by_sequence($r);
787: } else {
788: if (defined($plot)) {
789: &make_plot($r,$plot);
790: }
791: &output_html_stats($r);
1.79 matthew 792: &output_sequence_statistics($r);
1.73 matthew 793: }
794: }
1.105 albertel 795: &clean_up();
1.73 matthew 796: return;
797: }
798:
1.79 matthew 799: sub output_sequence_statistics {
800: my ($r) = @_;
801: my $c=$r->connection();
1.90 matthew 802: $r->print('<h2>'.&mt('Sequence Statistics').
803: &Apache::loncommon::help_open_topic('Statistics_Sequence').
804: '</h2>');
1.125 bisitz 805: $r->print(&Apache::loncommon::start_data_table());
1.79 matthew 806: $r->print(&sequence_html_header());
1.117 bisitz 807: foreach my $seq (@sequences) {
1.79 matthew 808: last if ($c->aborted);
809: &compute_sequence_statistics($seq);
810: $r->print(&sequence_html_output($seq));
811: }
1.122 golterma 812: $r->print(&Apache::loncommon::end_data_table());
1.79 matthew 813: $r->rflush();
814: return;
815: }
816:
817:
1.73 matthew 818: ##########################################################
819: ##########################################################
820: ##
821: ## HTML output routines
822: ##
823: ##########################################################
824: ##########################################################
825: sub output_html_by_sequence {
826: my ($r) = @_;
827: my $c = $r->connection();
1.125 bisitz 828: $r->print('<br />'.&html_preamble());
1.41 matthew 829: #
1.97 matthew 830: foreach my $seq (@sequences) {
1.73 matthew 831: last if ($c->aborted);
1.97 matthew 832: $r->print("<h3>".$seq->compTitle."</h3>".
1.122 golterma 833: &Apache::loncommon::start_data_table().
834: &Apache::loncommon::start_data_table_header_row().
835: &statistics_table_header('no container').
836: &Apache::loncommon::end_data_table_header_row()."\n");
1.73 matthew 837: my @Data = &compute_statistics_on_sequence($seq);
838: foreach my $data (@Data) {
1.122 golterma 839: $r->print(&Apache::loncommon::start_data_table_row().
840: &statistics_html_table_data($data,'no container').
841: &Apache::loncommon::end_data_table_row()."\n");
1.70 matthew 842: }
1.122 golterma 843: $r->print(&Apache::loncommon::end_data_table()."\n");
1.41 matthew 844: $r->rflush();
1.28 stredwic 845: }
1.41 matthew 846: return;
847: }
1.21 stredwic 848:
1.73 matthew 849: sub output_html_stats {
850: my ($r)=@_;
851: &compute_all_statistics($r);
852: $r->print(&html_preamble());
1.104 albertel 853: &sort_data($env{'form.sortby'});
1.73 matthew 854: #
855: my $count=0;
856: foreach my $data (@StatsArray) {
857: if ($count++ % 50 == 0) {
1.122 golterma 858: $r->print(&Apache::loncommon::end_data_table());
859: $r->print(&Apache::loncommon::start_data_table().
860: &Apache::loncommon::start_data_table_row().
861: &statistics_table_header().
862: &Apache::loncommon::end_data_table_row());
863: }
864: $r->print(&Apache::loncommon::start_data_table_row().
865: &statistics_html_table_data($data).
866: &Apache::loncommon::end_data_table_row());
1.73 matthew 867: }
1.122 golterma 868: $r->print(&Apache::loncommon::end_data_table_row());
1.73 matthew 869: return;
870: }
1.47 matthew 871:
1.73 matthew 872: sub html_preamble {
873: my $Str='';
874: $Str .= "<h2>".
1.104 albertel 875: $env{'course.'.$env{'request.course.id'}.'.description'}.
1.73 matthew 876: "</h2>\n";
877: my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
878: if (defined($starttime) || defined($endtime)) {
879: # Inform the user what the time limits on the data are.
880: $Str .= '<h3>'.&mt('Statistics on submissions from [_1] to [_2]',
881: &Apache::lonlocal::locallocaltime($starttime),
882: &Apache::lonlocal::locallocaltime($endtime)
883: ).'</h3>';
884: }
1.122 golterma 885: $Str .= "<p>".&mt('Compiled on [_1]',
886: &Apache::lonlocal::locallocaltime(time))."</p>";
1.73 matthew 887: return $Str;
888: }
1.47 matthew 889:
890:
1.44 matthew 891: ###############################################
892: ###############################################
1.73 matthew 893: ##
894: ## Misc HTML output routines
895: ##
896: ###############################################
897: ###############################################
898: sub statistics_html_table_data {
899: my ($data,$options) = @_;
900: my $row = '';
901: foreach my $field (@Fields) {
902: next if ($options =~ /no $field->{'name'}/);
1.76 matthew 903: next if ($field->{'selected'} ne 'yes');
1.122 golterma 904: $row .= '<td style="background-color:'.$field->{'color'}.'"';
1.73 matthew 905: if (exists($field->{'align'})) {
906: $row .= ' align="'.$field->{'align'}.'"';
1.41 matthew 907: }
1.73 matthew 908: $row .= '>';
909: if (exists($field->{'special'}) && $field->{'special'} eq 'link') {
910: $row .= '<a href="'.$data->{$field->{'name'}.'.link'}.'">';
1.41 matthew 911: }
1.92 matthew 912: if (exists($field->{'format'}) && $data->{$field->{'name'}} !~ /[A-Z]/i) {
1.73 matthew 913: $row .= sprintf($field->{'format'},$data->{$field->{'name'}});
914: } else {
915: $row .= $data->{$field->{'name'}};
916: }
917: if (exists($field->{'special'}) && $field->{'special'} eq 'link') {
918: $row.= '</a>';
919: }
920: $row .= '</td>';
1.21 stredwic 921: }
1.73 matthew 922: return $row;
1.41 matthew 923: }
1.25 stredwic 924:
1.73 matthew 925: sub statistics_table_header {
926: my ($options) = @_;
927: my $header_row;
928: foreach my $field (@Fields) {
929: next if ($options =~ /no $field->{'name'}/);
1.76 matthew 930: next if ($field->{'selected'} ne 'yes');
1.73 matthew 931: $header_row .= '<th>';
1.125 bisitz 932: my $header_row_text = &mt($field->{'title'});
1.73 matthew 933: if (exists($field->{'sortable'}) && $field->{'sortable'} eq 'yes') {
1.125 bisitz 934: $header_row .=
935: '<a href="javascript:'.
1.73 matthew 936: 'document.Statistics.sortby.value='."'".$field->{'name'}."'".
1.125 bisitz 937: ';document.Statistics.submit();">'.
938: $header_row_text.
939: '</a>';
940: } else {
941: $header_row .= $header_row_text;
1.73 matthew 942: }
943: if ($options !~ /no plots/ &&
944: exists($field->{'graphable'}) &&
945: $field->{'graphable'} eq 'yes') {
946: $header_row.=' (';
947: $header_row .= '<a href="javascript:'.
948: "document.Statistics.plot.value='$field->{'name'}'".
949: ';document.Statistics.submit();">';
950: $header_row .= &mt('plot').'</a>)';
951: }
952: $header_row .= '</th>';
953: }
954: return $header_row;
955: }
1.26 stredwic 956:
1.79 matthew 957: sub sequence_html_header {
1.125 bisitz 958: my $Str .= &Apache::loncommon::start_data_table_header_row();
1.79 matthew 959: foreach my $field (@SeqFields) {
960: # next if ($field->{'selected'} ne 'yes');
961: $Str .= '<th bgcolor="'.$field->{'color'}.'"';
1.125 bisitz 962: $Str .= '>'.&mt($field->{'title'}).'</th>';
1.79 matthew 963: }
1.125 bisitz 964: $Str .= &Apache::loncommon::end_data_table_header_row();
1.79 matthew 965: return $Str;
966: }
967:
968:
969: sub sequence_html_output {
970: my ($seq) = @_;
1.97 matthew 971: my $data = $SeqStat{$seq->symb};
1.125 bisitz 972: my $row = &Apache::loncommon::start_data_table_row();
1.79 matthew 973: foreach my $field (@SeqFields) {
1.82 matthew 974: next if ($field->{'selected'} ne 'yes');
1.79 matthew 975: $row .= '<td bgcolor="'.$field->{'color'}.'"';
976: if (exists($field->{'align'})) {
977: $row .= ' align="'.$field->{'align'}.'"';
978: }
979: $row .= '>';
980: if (exists($field->{'format'})) {
981: $row .= sprintf($field->{'format'},$data->{$field->{'name'}});
982: } else {
983: $row .= $data->{$field->{'name'}};
984: }
985: $row .= '</td>';
986: }
1.125 bisitz 987: $row .= &Apache::loncommon::end_data_table_row()."\n";
1.79 matthew 988: return $row;
989: }
990:
1.73 matthew 991: ####################################################
992: ####################################################
993: ##
994: ## Plotting Routines
995: ##
996: ####################################################
997: ####################################################
998: sub make_plot {
999: my ($r,$plot) = @_;
1000: &compute_all_statistics($r);
1.104 albertel 1001: &sort_data($env{'form.sortby'});
1.73 matthew 1002: if ($plot eq 'degrees') {
1003: °rees_plot($r);
1.74 matthew 1004: } elsif ($plot eq 'tries statistics') {
1005: &tries_data_plot($r);
1.73 matthew 1006: } else {
1007: &make_single_stat_plot($r,$plot);
1008: }
1009: return;
1010: }
1.47 matthew 1011:
1.73 matthew 1012: sub make_single_stat_plot {
1013: my ($r,$datafield) = @_;
1.41 matthew 1014: #
1.73 matthew 1015: my $title; my $yaxis;
1016: foreach my $field (@Fields) {
1017: next if ($field->{'name'} ne $datafield);
1.123 bisitz 1018: $title = &mt($field->{'long_title'});
1019: $yaxis = &mt($field->{'title'});
1.73 matthew 1020: last;
1021: }
1022: if ($title eq '' || $yaxis eq '') {
1023: # datafield is something we do not know enough about to plot
1.123 bisitz 1024: $r->print('<p class="LC_warning">'.
1.73 matthew 1025: &mt('Unable to plot the requested statistic.').
1.123 bisitz 1026: '</p>');
1.73 matthew 1027: return;
1.49 matthew 1028: }
1029: #
1.73 matthew 1030: # Build up the data sets to plot
1.117 bisitz 1031: my @Labels;
1.73 matthew 1032: my @Data;
1033: my $max = 1;
1034: foreach my $data (@StatsArray) {
1035: push(@Labels,$data->{'problem_num'});
1036: push(@Data,$data->{$datafield});
1037: if ($data->{$datafield}>$max) {
1038: $max = $data->{$datafield};
1039: }
1040: }
1041: foreach (1,2,3,4,5,10,15,20,25,40,50,75,100,150,200,250,300,500,600,750,
1042: 1000,1500,2000,2500,3000,3500,4000,5000,7500,10000,15000,20000) {
1043: if ($max <= $_) {
1044: $max = $_;
1045: last;
1.42 matthew 1046: }
1047: }
1.73 matthew 1048: if ($max > 20000) {
1049: $max = 10000*(int($max/10000)+1);
1.42 matthew 1050: }
1.73 matthew 1051: #
1052: $r->print("<p>".&Apache::loncommon::DrawBarGraph($title,
1.123 bisitz 1053: &mt('Problem Number'),
1.73 matthew 1054: $yaxis,
1055: $max,
1056: undef, # colors
1057: \@Labels,
1058: \@Data)."</p>\n");
1059: return;
1060: }
1061:
1062: sub degrees_plot {
1063: my ($r)=@_;
1064: my $count = scalar(@StatsArray);
1065: my $width = 50 + 10*$count;
1066: $width = 300 if ($width < 300);
1067: my $height = 300;
1068: my $plot = '';
1069: my $ymax = 0;
1070: my $ymin = 0;
1.117 bisitz 1071: my @Disc; my @Diff; my @Labels;
1.73 matthew 1072: foreach my $data (@StatsArray) {
1073: push(@Labels,$data->{'problem_num'});
1074: my $disc = $data->{'deg_of_disc'};
1075: my $diff = $data->{'deg_of_diff'};
1076: push(@Disc,$disc);
1077: push(@Diff,$diff);
1078: #
1079: $ymin = $disc if ($ymin > $disc);
1080: $ymin = $diff if ($ymin > $diff);
1081: $ymax = $disc if ($ymax < $disc);
1082: $ymax = $diff if ($ymax < $diff);
1083: }
1084: #
1085: # Make sure we show relevant information.
1086: if ($ymin < 0) {
1087: if (abs($ymin) < 0.05) {
1088: $ymin = 0;
1089: } else {
1090: $ymin = -1;
1.42 matthew 1091: }
1092: }
1.73 matthew 1093: if ($ymax > 0) {
1094: if (abs($ymax) < 0.05) {
1095: $ymax = 0;
1.42 matthew 1096: } else {
1.73 matthew 1097: $ymax = 1;
1.42 matthew 1098: }
1.43 matthew 1099: }
1.49 matthew 1100: #
1.73 matthew 1101: my $xmax = $Labels[-1];
1102: if ($xmax > 50) {
1103: if ($xmax % 10 != 0) {
1104: $xmax = 10 * (int($xmax/10)+1);
1105: }
1106: } else {
1107: if ($xmax % 5 != 0) {
1108: $xmax = 5 * (int($xmax/5)+1);
1.49 matthew 1109: }
1.26 stredwic 1110: }
1.41 matthew 1111: #
1.73 matthew 1112: my $discdata .= '<data>'.join(',',@Labels).'</data>'.$/.
1113: '<data>'.join(',',@Disc).'</data>'.$/;
1114: #
1115: my $diffdata .= '<data>'.join(',',@Labels).'</data>'.$/.
1116: '<data>'.join(',',@Diff).'</data>'.$/;
1117: #
1.123 bisitz 1118: my $title = &mt('Degree of Discrimination[_1]and Degree of Difficulty','\n');
1.81 matthew 1119: if ($xmax > 50) {
1.123 bisitz 1120: $title = &mt('Degree of Discrimination and Degree of Difficulty');
1.81 matthew 1121: }
1.123 bisitz 1122: my %lt = &Apache::lonlocal::texthash(
1123: 'alttag' => 'Degree of Discrimination and Degree of Difficulty Plot',
1124: 'xlabel' => 'Problem Number',
1125: );
1.81 matthew 1126: #
1.73 matthew 1127: $plot=<<"END";
1128: <gnuplot
1129: texfont="10"
1130: fgcolor="x000000"
1131: plottype="Cartesian"
1132: font="large"
1133: grid="on"
1134: align="center"
1135: border="on"
1136: transparent="on"
1.123 bisitz 1137: alttag="$lt{'alttag'}"
1.73 matthew 1138: samples="100"
1139: bgcolor="xffffff"
1140: height="$height"
1141: width="$width">
1142: <key
1143: pos="top right"
1144: title=""
1145: box="off" />
1.81 matthew 1146: <title>$title</title>
1.73 matthew 1147: <axis xmin="0" ymin="$ymin" xmax="$xmax" ymax="$ymax" color="x000000" />
1.123 bisitz 1148: <xlabel>$lt{'xlabel'}</xlabel>
1.73 matthew 1149: <curve
1150: linestyle="linespoints"
1151: name="DoDisc"
1152: pointtype="0"
1153: color="x000000">
1154: $discdata
1155: </curve>
1156: <curve
1157: linestyle="linespoints"
1158: name="DoDiff"
1159: pointtype="0"
1160: color="xFF0000">
1161: $diffdata
1162: </curve>
1163: </gnuplot>
1164: END
1.117 bisitz 1165: my $plotresult =
1.73 matthew 1166: '<p>'.&Apache::lonxml::xmlparse($r,'web',$plot).'</p>'.$/;
1167: $r->print($plotresult);
1.41 matthew 1168: return;
1.42 matthew 1169: }
1170:
1.74 matthew 1171: sub tries_data_plot {
1172: my ($r)=@_;
1173: my $count = scalar(@StatsArray);
1174: my $width = 50 + 10*$count;
1175: $width = 300 if ($width < 300);
1176: my $height = 300;
1177: my $plot = '';
1178: my @STD; my @Mean; my @Max; my @Min;
1179: my @Labels;
1180: my $ymax = 5;
1181: foreach my $data (@StatsArray) {
1182: my $max = $data->{'mean_tries'} + $data->{'std_tries'};
1183: $ymax = $max if ($ymax < $max);
1184: $ymax = $max if ($ymax < $max);
1185: push(@Labels,$data->{'problem_num'});
1186: push(@STD,$data->{'std_tries'});
1187: push(@Mean,$data->{'mean_tries'});
1188: }
1189: #
1190: # Make sure we show relevant information.
1191: my $xmax = $Labels[-1];
1192: if ($xmax > 50) {
1193: if ($xmax % 10 != 0) {
1194: $xmax = 10 * (int($xmax/10)+1);
1195: }
1196: } else {
1197: if ($xmax % 5 != 0) {
1198: $xmax = 5 * (int($xmax/5)+1);
1199: }
1200: }
1201: $ymax = int($ymax)+1+2;
1202: #
1203: my $std_data .= '<data>'.join(',',@Labels).'</data>'.$/.
1204: '<data>'.join(',',@Mean).'</data>'.$/;
1205: #
1206: my $std_error_data .= '<data>'.join(',',@Labels).'</data>'.$/.
1207: '<data>'.join(',',@Mean).'</data>'.$/.
1208: '<data>'.join(',',@STD).'</data>'.$/;
1209: #
1.123 bisitz 1210: my $title = &mt('Mean and S.D. of Tries');
1211: if ($xmax > 30) {
1212: $title = &mt('Mean and Standard Deviation of Tries');
1.81 matthew 1213: }
1214: #
1.123 bisitz 1215: my %lt = &Apache::lonlocal::texthash(
1216: 'alttag' => 'Mean and S.D of Tries Plot',
1217: 'xlabel' => 'Problem Number',
1218: 'ylabel' => 'Number of Tries',
1219: );
1.74 matthew 1220: $plot=<<"END";
1221: <gnuplot
1222: texfont="10"
1223: fgcolor="x000000"
1224: plottype="Cartesian"
1225: font="large"
1226: grid="on"
1227: align="center"
1228: border="on"
1229: transparent="on"
1.123 bisitz 1230: alttag="$lt{'alttag'}"
1.74 matthew 1231: samples="100"
1232: bgcolor="xffffff"
1233: height="$height"
1234: width="$width">
1.81 matthew 1235: <title>$title</title>
1.74 matthew 1236: <axis xmin="0" ymin="0" xmax="$xmax" ymax="$ymax" color="x000000" />
1.123 bisitz 1237: <xlabel>$lt{'xlabel'}</xlabel>
1238: <ylabel>$lt{'ylabel'}</ylabel>
1.74 matthew 1239: <curve
1240: linestyle="yerrorbars"
1241: name="S.D. Tries"
1242: pointtype="1"
1243: color="x666666">
1244: $std_error_data
1245: </curve>
1246: <curve
1247: linestyle="points"
1248: name="Mean Tries"
1249: pointtype="1"
1250: color="xCC4444">
1251: $std_data
1252: </curve>
1253: </gnuplot>
1254: END
1.117 bisitz 1255: my $plotresult =
1.74 matthew 1256: '<p>'.&Apache::lonxml::xmlparse($r,'web',$plot).'</p>'.$/;
1257: $r->print($plotresult);
1258: return;
1259: }
1260:
1.73 matthew 1261: sub plot_dropdown {
1262: my $current = '';
1.123 bisitz 1263: my $title;
1.73 matthew 1264: #
1.104 albertel 1265: if (defined($env{'form.plot'})) {
1266: $current = $env{'form.plot'};
1.73 matthew 1267: }
1268: #
1269: my @Additional_Plots = (
1270: { graphable=>'yes',
1271: name => 'degrees',
1.81 matthew 1272: title => 'Difficulty Indexes' },
1.74 matthew 1273: { graphable=>'yes',
1274: name => 'tries statistics',
1.81 matthew 1275: title => 'Tries Statistics' });
1.73 matthew 1276: #
1277: my $Str= "\n".'<select name="plot" size="1">';
1278: $Str .= '<option name="none"></option>'."\n";
1.123 bisitz 1279: $Str .= '<option name="none2">'.&mt('none').'</option>'."\n";
1.81 matthew 1280: foreach my $field (@Additional_Plots,@Fields) {
1.73 matthew 1281: if (! exists($field->{'graphable'}) ||
1282: $field->{'graphable'} ne 'yes') {
1283: next;
1284: }
1285: $Str .= '<option value="'.$field->{'name'}.'"';
1286: if ($field->{'name'} eq $current) {
1.123 bisitz 1287: $Str .= ' selected="selected"';
1.73 matthew 1288: }
1.123 bisitz 1289: $title = &mt($field->{'long_title'});
1290: $title = &mt($field->{'title'}) if (!$title);
1291: $Str.= '>'.$title.'</option>'."\n";
1.73 matthew 1292: }
1293: $Str .= '</select>'."\n";
1294: return $Str;
1295: }
1296:
1.41 matthew 1297: ###############################################
1298: ###############################################
1.73 matthew 1299: ##
1300: ## Excel output routines
1301: ##
1.41 matthew 1302: ###############################################
1303: ###############################################
1.73 matthew 1304: sub Excel_output {
1.44 matthew 1305: my ($r) = @_;
1.73 matthew 1306: $r->print('<h2>'.&mt('Preparing Excel Spreadsheet').'</h2>');
1307: ##
1308: ## Compute the statistics
1309: &compute_all_statistics($r);
1310: my $c = $r->connection;
1311: return if ($c->aborted());
1.101 matthew 1312: #
1313: my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
1.73 matthew 1314: ##
1315: ## Create the excel workbook
1.101 matthew 1316: my ($excel_workbook,$filename,$format) =
1317: &Apache::loncommon::create_workbook($r);
1318: return if (! defined($excel_workbook));
1.44 matthew 1319: #
1320: # Add a worksheet
1.104 albertel 1321: my $sheetname = $env{'course.'.$env{'request.course.id'}.'.description'};
1.44 matthew 1322: if (length($sheetname) > 31) {
1323: $sheetname = substr($sheetname,0,31);
1324: }
1.73 matthew 1325: my $excel_sheet = $excel_workbook->addworksheet(
1326: &Apache::loncommon::clean_excel_name($sheetname));
1327: ##
1328: ## Begin creating excel sheet
1329: ##
1330: my ($rows_output,$cols_output) = (0,0);
1.44 matthew 1331: #
1332: # Put the course description in the header
1333: $excel_sheet->write($rows_output,$cols_output++,
1.104 albertel 1334: $env{'course.'.$env{'request.course.id'}.'.description'},
1.82 matthew 1335: $format->{'h1'});
1.44 matthew 1336: $cols_output += 3;
1337: #
1338: # Put a description of the sections listed
1339: my $sectionstring = '';
1.82 matthew 1340: $excel_sheet->write($rows_output,$cols_output++,
1.103 matthew 1341: &Apache::lonstatistics::section_and_enrollment_description('plaintext'),
1.82 matthew 1342: $format->{'h3'});
1.102 matthew 1343: $cols_output += scalar(&Apache::lonstatistics::get_selected_sections());
1.108 raeburn 1344: $cols_output += scalar(&Apache::lonstatistics::get_selected_groups());
1.44 matthew 1345: #
1.70 matthew 1346: # Time restrictions
1347: my $time_string;
1348: if (defined($starttime)) {
1349: if (defined($endtime)) {
1.125 bisitz 1350: $time_string .= &mt('Data collected from [_1] to [_2]',
1351: &Apache::lonlocal::locallocaltime($starttime),
1352: &Apache::lonlocal::locallocaltime($endtime));
1353: } else {
1354: $time_string .= &mt('Data collected from [_1]',
1355: &Apache::lonlocal::locallocaltime($starttime));
1.70 matthew 1356: }
1357: } elsif (defined($endtime)) {
1.125 bisitz 1358: $time_string .= &mt('Data collected before [_1]',
1359: &Apache::lonlocal::locallocaltime($endtime));
1.70 matthew 1360: }
1.82 matthew 1361: if (defined($time_string)) {
1362: $excel_sheet->write($rows_output,$cols_output++,$time_string);
1363: $cols_output+= 5;
1364: }
1.70 matthew 1365: #
1.44 matthew 1366: # Put the date in there too
1367: $excel_sheet->write($rows_output,$cols_output++,
1.125 bisitz 1368: &mt('Compiled on [_1]',&Apache::lonlocal::locallocaltime(time)));
1.44 matthew 1369: #
1.117 bisitz 1370: $rows_output++;
1.44 matthew 1371: $cols_output=0;
1.82 matthew 1372: ##
1373: ## Sequence Statistics
1.117 bisitz 1374: ##
1.82 matthew 1375: &write_headers($excel_sheet,$format,\$rows_output,\$cols_output,
1376: \@SeqFields);
1.97 matthew 1377: foreach my $seq (@sequences) {
1378: my $data = $SeqStat{$seq->symb};
1.82 matthew 1379: $cols_output=0;
1380: foreach my $field (@SeqFields) {
1381: next if ($field->{'selected'} ne 'yes');
1.85 matthew 1382: my $fieldformat = undef;
1383: if (exists($field->{'excel_format'})) {
1384: $fieldformat = $format->{$field->{'excel_format'}};
1385: }
1.55 matthew 1386: $excel_sheet->write($rows_output,$cols_output++,
1.85 matthew 1387: $data->{$field->{'name'}},$fieldformat);
1.55 matthew 1388: }
1.82 matthew 1389: $rows_output++;
1390: $cols_output=0;
1.55 matthew 1391: }
1.82 matthew 1392: ##
1393: ## Resource Statistics
1394: ##
1.55 matthew 1395: $rows_output++;
1396: $cols_output=0;
1.82 matthew 1397: &write_headers($excel_sheet,$format,\$rows_output,\$cols_output,
1398: \@Fields);
1399: #
1.73 matthew 1400: foreach my $data (@StatsArray) {
1401: $cols_output=0;
1402: foreach my $field (@Fields) {
1.76 matthew 1403: next if ($field->{'selected'} ne 'yes');
1.73 matthew 1404: next if ($field->{'name'} eq 'problem_num');
1.85 matthew 1405: my $fieldformat = undef;
1406: if (exists($field->{'excel_format'})) {
1407: $fieldformat = $format->{$field->{'excel_format'}};
1408: }
1.73 matthew 1409: $excel_sheet->write($rows_output,$cols_output++,
1.85 matthew 1410: $data->{$field->{'name'}},$fieldformat);
1.44 matthew 1411: }
1.73 matthew 1412: $rows_output++;
1.82 matthew 1413: $cols_output=0;
1.44 matthew 1414: }
1415: #
1416: $excel_workbook->close();
1.73 matthew 1417: #
1.44 matthew 1418: # Tell the user where to get their excel file
1419: $r->print('<br />'.
1.59 matthew 1420: '<a href="'.$filename.'">'.
1421: &mt('Your Excel Spreadsheet').'</a>'."\n");
1.44 matthew 1422: $r->rflush();
1423: return;
1424: }
1425:
1.82 matthew 1426: ##
1427: ## &write_headers
1428: ##
1429: sub write_headers {
1430: my ($excel_sheet,$format,$rows_output,$cols_output,$Fields) = @_;
1431: ##
1432: ## First the long titles
1433: foreach my $field (@{$Fields}) {
1434: next if ($field->{'name'} eq 'problem_num');
1435: next if ($field->{'selected'} ne 'yes');
1436: if (exists($field->{'long_title'})) {
1437: $excel_sheet->write($$rows_output,${$cols_output},
1438: $field->{'long_title'},
1439: $format->{'bold'});
1440: } else {
1441: $excel_sheet->write($$rows_output,${$cols_output},'');
1442: }
1443: ${$cols_output}+= 1;
1444: }
1445: ${$cols_output} =0;
1446: ${$rows_output}+=1;
1447: ##
1448: ## Then the short titles
1449: foreach my $field (@{$Fields}) {
1450: next if ($field->{'selected'} ne 'yes');
1451: next if ($field->{'name'} eq 'problem_num');
1.117 bisitz 1452: # Use english for excel as I am not sure how well excel handles
1.82 matthew 1453: # other character sets....
1454: $excel_sheet->write($$rows_output,$$cols_output,
1455: $field->{'title'},
1456: $format->{'bold'});
1457: $$cols_output+=1;
1458: }
1459: ${$cols_output} =0;
1460: ${$rows_output}+=1;
1461: return;
1462: }
1463:
1.73 matthew 1464: ##################################################
1465: ##################################################
1466: ##
1467: ## Statistics Gathering and Manipulation Routines
1468: ##
1469: ##################################################
1470: ##################################################
1471: sub compute_statistics_on_sequence {
1472: my ($seq) = @_;
1.127 ! raeburn 1473: my $include_tools = 1;
1.73 matthew 1474: my @Data;
1.127 ! raeburn 1475: foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq,$include_tools)) {
1.97 matthew 1476: foreach my $part (@{$res->parts}) {
1.118 raeburn 1477: next if (($res->is_survey($part)) || ($res->is_anonsurvey($part))) ;
1.73 matthew 1478: #
1479: # This is where all the work happens
1480: my $data = &get_statistics($seq,$res,$part,scalar(@StatsArray)+1);
1481: push (@Data,$data);
1482: push (@StatsArray,$data);
1.49 matthew 1483: }
1.26 stredwic 1484: }
1.73 matthew 1485: return @Data;
1.41 matthew 1486: }
1.26 stredwic 1487:
1.73 matthew 1488: sub compute_all_statistics {
1489: my ($r) = @_;
1490: if (@StatsArray > 0) {
1491: # Assume we have already computed the statistics
1492: return;
1493: }
1494: my $c = $r->connection;
1.97 matthew 1495: foreach my $seq (@sequences) {
1.73 matthew 1496: last if ($c->aborted);
1.82 matthew 1497: &compute_sequence_statistics($seq);
1.73 matthew 1498: &compute_statistics_on_sequence($seq);
1.49 matthew 1499: }
1500: }
1501:
1.73 matthew 1502: sub sort_data {
1503: my ($sortkey) = @_;
1504: return if (! @StatsArray);
1.45 matthew 1505: #
1.73 matthew 1506: # Sort the data
1507: my $sortby = undef;
1.49 matthew 1508: foreach my $field (@Fields) {
1.73 matthew 1509: if ($sortkey eq $field->{'name'}) {
1510: $sortby = $field->{'name'};
1.45 matthew 1511: }
1.26 stredwic 1512: }
1.73 matthew 1513: if (! defined($sortby) || $sortby eq '' || $sortby eq 'problem_num') {
1514: $sortby = 'container';
1515: }
1516: if ($sortby ne 'container') {
1517: # $sortby is already defined, so we can charge ahead
1518: if ($sortby =~ /^(title|part)$/i) {
1519: # Alpha comparison
1520: @StatsArray = sort {
1521: lc($a->{$sortby}) cmp lc($b->{$sortby}) ||
1522: lc($a->{'title'}) cmp lc($b->{'title'}) ||
1523: lc($a->{'part'}) cmp lc($b->{'part'});
1524: } @StatsArray;
1.24 stredwic 1525: } else {
1.73 matthew 1526: # Numerical comparison
1527: @StatsArray = sort {
1528: my $retvalue = 0;
1529: if ($b->{$sortby} eq 'nan') {
1530: if ($a->{$sortby} ne 'nan') {
1531: $retvalue = -1;
1532: } else {
1533: $retvalue = 0;
1534: }
1535: }
1536: if ($a->{$sortby} eq 'nan') {
1537: if ($b->{$sortby} ne 'nan') {
1538: $retvalue = 1;
1539: }
1540: }
1541: if ($retvalue eq '0') {
1542: $retvalue = $b->{$sortby} <=> $a->{$sortby} ||
1543: lc($a->{'title'}) <=> lc($b->{'title'}) ||
1544: lc($a->{'part'}) <=> lc($b->{'part'});
1545: }
1546: $retvalue;
1547: } @StatsArray;
1.24 stredwic 1548: }
1549: }
1.45 matthew 1550: #
1.73 matthew 1551: # Renumber the data set
1552: my $count;
1553: foreach my $data (@StatsArray) {
1554: $data->{'problem_num'} = ++$count;
1555: }
1.24 stredwic 1556: return;
1.48 matthew 1557: }
1558:
1.70 matthew 1559: ########################################################
1560: ########################################################
1561:
1562: =pod
1563:
1564: =item &get_statistics()
1565:
1.117 bisitz 1566: Wrapper routine from the call to loncoursedata::get_problem_statistics.
1.73 matthew 1567: Calls lonstathelpers::get_time_limits() to limit the data set by time
1568: and &compute_discrimination_factor
1.70 matthew 1569:
1570: Inputs: $sequence, $resource, $part, $problem_num
1571:
1.117 bisitz 1572: Returns: Hash reference with statistics data from
1.70 matthew 1573: loncoursedata::get_problem_statistics.
1574:
1575: =cut
1576:
1577: ########################################################
1578: ########################################################
1.48 matthew 1579: sub get_statistics {
1.49 matthew 1580: my ($sequence,$resource,$part,$problem_num) = @_;
1.48 matthew 1581: #
1.70 matthew 1582: my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
1.97 matthew 1583: my $symb = $resource->symb;
1.104 albertel 1584: my $courseid = $env{'request.course.id'};
1.48 matthew 1585: #
1.49 matthew 1586: my $data = &Apache::loncoursedata::get_problem_statistics
1.102 matthew 1587: ([&Apache::lonstatistics::get_selected_sections()],
1.108 raeburn 1588: [&Apache::lonstatistics::get_selected_groups()],
1.66 matthew 1589: $Apache::lonstatistics::enrollment_status,
1.70 matthew 1590: $symb,$part,$courseid,$starttime,$endtime);
1.85 matthew 1591: $data->{'symb'} = $symb;
1.49 matthew 1592: $data->{'part'} = $part;
1593: $data->{'problem_num'} = $problem_num;
1.97 matthew 1594: $data->{'container'} = $sequence->compTitle;
1595: $data->{'title'} = $resource->compTitle;
1596: $data->{'title.link'} = $resource->src.'?symb='.
1.109 www 1597: &escape($resource->symb);
1.49 matthew 1598: #
1.76 matthew 1599: if ($SelectedFields{'deg_of_disc'}) {
1.117 bisitz 1600: $data->{'deg_of_disc'} =
1.76 matthew 1601: &compute_discrimination_factor($resource,$part,$sequence);
1602: }
1.83 matthew 1603: #
1604: # Store in metadata if computations were done for all students
1.84 matthew 1605: if ($data->{'num_students'} > 1) {
1.102 matthew 1606: my @Sections = &Apache::lonstatistics::get_selected_sections();
1.84 matthew 1607: my $sections = '"'.join(' ',@Sections).'"';
1608: $sections =~ s/&+/_/g; # Ensure no special characters
1609: $data->{'sections'}=$sections;
1.104 albertel 1610: $data->{'course'} = $env{'request.course.id'};
1.97 matthew 1611: my $urlres=(&Apache::lonnet::decode_symb($resource->symb))[2];
1.117 bisitz 1612: my %storestats =
1.84 matthew 1613: &LONCAPA::lonmetadata::dynamic_metadata_storage($data);
1.117 bisitz 1614: my ($dom,$user) = ($urlres=~m{^($LONCAPA::domain_re)/($LONCAPA::username_re)});
1.83 matthew 1615: &Apache::lonnet::put('nohist_resevaldata',\%storestats,$dom,$user);
1616: }
1.85 matthew 1617: #
1.95 matthew 1618: $data->{'tries_per_correct'} = $data->{'tries'} /
1619: ($data->{'num_solved'}+0.1);
1620: #
1.85 matthew 1621: # Get the due date for research purposes (commented out most of the time)
1.112 raeburn 1622: # my $duedate = &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb);;
1623: # my $opendate = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb);
1624: # my $maxtries = &Apache::lonnet::EXT('resource.'.$part.'.maxtries',$symb);
1625: # my $hinttries = &Apache::lonnet::EXT('resource.'.$part.'.hinttries',$symb);
1626: my $weight = &Apache::lonnet::EXT('resource.'.$part.'.weight',$symb);
1627: $data->{'weight'} = $weight;
1.117 bisitz 1628: # $data->{'duedate'} = $duedate;
1.112 raeburn 1629: # $data->{'opendate'} = $opendate;
1630: # $data->{'maxtries'} = $maxtries;
1631: # $data->{'hinttries'} = $hinttries;
1.86 matthew 1632: # $data->{'resptypes'} = join(',',@{$resource->{'partdata'}->{$part}->{'ResponseTypes'}});
1.49 matthew 1633: return $data;
1.71 matthew 1634: }
1635:
1636: ###############################################
1637: ###############################################
1638:
1639: =pod
1640:
1641: =item &compute_discrimination_factor()
1642:
1643: Inputs: $Resource, $Sequence
1644:
1645: Returns: integer between -1 and 1
1646:
1647: =cut
1648:
1649: ###############################################
1650: ###############################################
1651: sub compute_discrimination_factor {
1.97 matthew 1652: my ($resource,$part,$seq) = @_;
1.127 ! raeburn 1653: my $include_tools = 1;
1.97 matthew 1654: my $symb = $resource->symb;
1.71 matthew 1655: my @Resources;
1.127 ! raeburn 1656: foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq,$include_tools)){
1.97 matthew 1657: next if ($res->symb eq $symb);
1658: push (@Resources,$res->symb);
1.71 matthew 1659: }
1660: #
1661: # rank
1.83 matthew 1662: my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
1.117 bisitz 1663: my $ranking =
1.71 matthew 1664: &Apache::loncoursedata::rank_students_by_scores_on_resources
1665: (\@Resources,
1.102 matthew 1666: [&Apache::lonstatistics::get_selected_sections()],
1.108 raeburn 1667: [&Apache::lonstatistics::get_selected_groups()],
1.83 matthew 1668: $Apache::lonstatistics::enrollment_status,undef,
1.106 bowersj2 1669: $starttime,$endtime, $symb);
1.71 matthew 1670: #
1671: # compute their percent scores on the problems in the sequence,
1672: my $number_to_grab = int(scalar(@{$ranking})/4);
1673: my $num_students = scalar(@{$ranking});
1.117 bisitz 1674: my @BottomSet = map { $_->[&Apache::loncoursedata::RNK_student()];
1.71 matthew 1675: } @{$ranking}[0..$number_to_grab];
1.117 bisitz 1676: my @TopSet =
1677: map {
1678: $_->[&Apache::loncoursedata::RNK_student()];
1.106 bowersj2 1679: } @{$ranking}[-$number_to_grab..0];
1.91 matthew 1680: if (! @BottomSet || (@BottomSet == 1 && $BottomSet[0] eq '') ||
1681: ! @TopSet || (@TopSet == 1 && $TopSet[0] eq '')) {
1682: return 'nan';
1683: }
1.117 bisitz 1684: my ($bottom_sum,$bottom_max) =
1.97 matthew 1685: &Apache::loncoursedata::get_sum_of_scores($symb,$part,\@BottomSet,
1.83 matthew 1686: undef,$starttime,$endtime);
1.117 bisitz 1687: my ($top_sum,$top_max) =
1.97 matthew 1688: &Apache::loncoursedata::get_sum_of_scores($symb,$part,\@TopSet,
1.83 matthew 1689: undef,$starttime,$endtime);
1.71 matthew 1690: my $deg_of_disc;
1691: if ($top_max == 0 || $bottom_max==0) {
1692: $deg_of_disc = 'nan';
1693: } else {
1694: $deg_of_disc = ($top_sum/$top_max) - ($bottom_sum/$bottom_max);
1695: }
1696: #&Apache::lonnet::logthis(' '.$top_sum.'/'.$top_max.
1697: # ' - '.$bottom_sum.'/'.$bottom_max);
1698: return $deg_of_disc;
1.1 stredwic 1699: }
1.12 minaeibi 1700:
1.45 matthew 1701: ###############################################
1702: ###############################################
1.79 matthew 1703: ##
1704: ## Compute KR-21
1705: ##
1706: ## To compute KR-21, you need the following information:
1707: ##
1708: ## K=the number of items in your test
1709: ## M=the mean score on the test
1.117 bisitz 1710: ## s=the standard deviation of the scores on your test
1.79 matthew 1711: ##
1712: ## then:
1.117 bisitz 1713: ##
1.79 matthew 1714: ## KR-21 rk= [K/(K-1)] * [1- (M*(K-M))/(K*s^2))]
1715: ##
1716: ###############################################
1717: ###############################################
1718: sub compute_sequence_statistics {
1719: my ($seq) = @_;
1.127 ! raeburn 1720: my $include_tools = 1;
1.97 matthew 1721: my $symb = $seq->symb;
1.79 matthew 1722: my @Resources;
1.97 matthew 1723: my $part_count;
1.127 ! raeburn 1724: foreach my $res (&Apache::lonstathelpers::get_resources($navmap,$seq,$include_tools)) {
1.97 matthew 1725: push (@Resources,$res->symb);
1726: $part_count += scalar(@{$res->parts});
1.79 matthew 1727: }
1728: my ($starttime,$endtime) = &Apache::lonstathelpers::get_time_limits();
1729: #
1730: # First compute statistics based on student scores
1.117 bisitz 1731: my ($smin,$smax,$sMean,$sSTD,$scount,$sMAX) =
1.79 matthew 1732: &Apache::loncoursedata::score_stats
1.102 matthew 1733: ([&Apache::lonstatistics::get_selected_sections()],
1.108 raeburn 1734: [&Apache::lonstatistics::get_selected_groups()],
1.79 matthew 1735: $Apache::lonstatistics::enrollment_status,
1736: \@Resources,$starttime,$endtime,undef);
1.97 matthew 1737: $SeqStat{$symb}->{'title'} = $seq->compTitle;
1.79 matthew 1738: $SeqStat{$symb}->{'scoremax'} = $smax;
1739: $SeqStat{$symb}->{'scoremin'} = $smin;
1740: $SeqStat{$symb}->{'scoremean'} = $sMean;
1741: $SeqStat{$symb}->{'scorestd'} = $sSTD;
1742: $SeqStat{$symb}->{'scorecount'} = $scount;
1743: $SeqStat{$symb}->{'max_possible'} = $sMAX;
1744: #
1745: # Compute statistics based on the number of correct problems
1.117 bisitz 1746: # 'correct' is taken to mean
1.79 matthew 1747: my ($cmin,$cmax,$cMean,$cSTD,$ccount)=
1748: &Apache::loncoursedata::count_stats
1.102 matthew 1749: ([&Apache::lonstatistics::get_selected_sections()],
1.108 raeburn 1750: [&Apache::lonstatistics::get_selected_groups()],
1.79 matthew 1751: $Apache::lonstatistics::enrollment_status,
1752: \@Resources,$starttime,$endtime,undef);
1.97 matthew 1753: my $K = $part_count;
1.79 matthew 1754: my $kr_21;
1755: if ($K > 1 && $cSTD > 0) {
1756: $kr_21 = ($K/($K-1)) * (1 - $cMean*($K-$cMean)/($K*$cSTD**2));
1757: } else {
1758: $kr_21 = 'nan';
1759: }
1760: $SeqStat{$symb}->{'countmax'} = $cmax;
1761: $SeqStat{$symb}->{'countmin'} = $cmin;
1762: $SeqStat{$symb}->{'countstd'} = $cSTD;
1.82 matthew 1763: $SeqStat{$symb}->{'countmean'} = $cMean;
1.79 matthew 1764: $SeqStat{$symb}->{'count'} = $ccount;
1765: $SeqStat{$symb}->{'items'} = $K;
1766: $SeqStat{$symb}->{'KR-21'}=$kr_21;
1767: return;
1768: }
1769:
1770:
1.47 matthew 1771:
1772: =pod
1773:
1.73 matthew 1774: =item ProblemStatisticsLegend
1775:
1776: =over 4
1777:
1778: =item #Stdnts
1779: Total number of students attempted the problem.
1780:
1781: =item Tries
1782: Total number of tries for solving the problem.
1.59 matthew 1783:
1.73 matthew 1784: =item Max Tries
1785: Largest number of tries for solving the problem by a student.
1786:
1787: =item Mean
1788: Average number of tries. [ Tries / #Stdnts ]
1789:
1790: =item #YES
1791: Number of students solved the problem correctly.
1792:
1793: =item #yes
1794: Number of students solved the problem by override.
1795:
1796: =item %Wrong
1797: Percentage of students who tried to solve the problem
1798: but is still incorrect. [ 100*((#Stdnts-(#YES+#yes))/#Stdnts) ]
1799:
1800: =item DoDiff
1801: Degree of Difficulty of the problem.
1802: [ 1 - ((#YES+#yes) / Tries) ]
1803:
1804: =item S.D.
1805: Standard Deviation of the tries.
1806: [ sqrt(sum((Xi - Mean)^2)) / (#Stdnts-1)
1807: where Xi denotes every student\'s tries ]
1808:
1809: =item Skew.
1810: Skewness of the students tries.
1811: [(sqrt( sum((Xi - Mean)^3) / #Stdnts)) / (S.D.^3)]
1812:
1813: =item Dis.F.
1814: Discrimination Factor: A Standard for evaluating the
1815: problem according to a Criterion<br>
1816:
1817: =item [Criterion to group students into %27 Upper Students -
1818: and %27 Lower Students]
1819: 1st Criterion for Sorting the Students:
1820: Sum of Partial Credit Awarded / Total Number of Tries
1821: 2nd Criterion for Sorting the Students:
1822: Total number of Correct Answers / Total Number of Tries
1823:
1824: =item Disc.
1825: Number of Students had at least one discussion.
1826:
1827: =back
1.47 matthew 1828:
1829: =cut
1.73 matthew 1830:
1831: ############################################################
1832: ############################################################
1.4 minaeibi 1833:
1.1 stredwic 1834: 1;
1835: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>