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