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