Annotation of loncom/interface/statistics/lonproblemanalysis.pm, revision 1.18
1.1 stredwic 1: # The LearningOnline Network with CAPA
2: # (Publication Handler
3: #
1.18 ! albertel 4: # $Id: lonproblemanalysis.pm,v 1.17 2002/12/11 21:39:57 minaeibi Exp $
1.1 stredwic 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28: # (Navigate problems for statistical reports
29: # YEAR=2002
1.11 minaeibi 30: # 5/12,7/26,9/7,11/22 Behrouz Minaei
1.1 stredwic 31: #
32: ###
33:
1.11 minaeibi 34: package Apache::lonproblemanalysis;
1.1 stredwic 35:
36: use strict;
37: use Apache::lonnet();
1.7 stredwic 38: use Apache::lonhtmlcommon();
1.1 stredwic 39: use GDBM_File;
40:
1.5 stredwic 41: my $jr;
1.2 stredwic 42:
1.1 stredwic 43: sub BuildProblemAnalysisPage {
1.4 stredwic 44: my ($cacheDB, $r)=@_;
1.1 stredwic 45:
46: my %cache;
1.3 stredwic 47: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
1.7 stredwic 48: $r->print('Unable to tie database.');
1.4 stredwic 49: return;
1.1 stredwic 50: }
51:
1.7 stredwic 52: my $Ptr = '';
53: $Ptr .= '<table border="0"><tbody>';
54: $Ptr .= '<tr><td align="right"><b>Select Sections</b>';
55: $Ptr .= '</td>'."\n";
56: $Ptr .= '<td align="left">'."\n";
57: my @sectionsSelected = split(':',$cache{'sectionsSelected'});
58: my @sections = split(':',$cache{'sectionList'});
59: $Ptr .= &Apache::lonhtmlcommon::MultipleSectionSelect(\@sections,
60: \@sectionsSelected,
61: 'Statistics');
62: $Ptr .= '</td></tr>'."\n";
63: $Ptr .= '<tr><td align="right"><b>Intervals</b></td>'."\n";
64: $Ptr .= '<td align="left">';
65: $Ptr .= &IntervalOptions($cache{'Interval'});
66: $Ptr .= '</td></tr></table><br>';
67: $r->print($Ptr);
1.4 stredwic 68: $r->rflush();
1.17 minaeibi 69: # $r->print($cache{'OptionResponses'}.'<br>');
1.10 minaeibi 70: $r->print(&OptionResponseTable($cache{'OptionResponses'}, \%cache, $r));
1.1 stredwic 71:
72: untie(%cache);
73:
1.4 stredwic 74: return;
1.1 stredwic 75: }
76:
77: sub BuildAnalyzePage {
1.2 stredwic 78: my ($cacheDB, $students, $courseID,$r)=@_;
79:
1.5 stredwic 80: $jr = $r;
1.2 stredwic 81: my $c = $r->connection;
1.1 stredwic 82:
1.2 stredwic 83: my $Str = '</form>';
1.1 stredwic 84: my %cache;
1.7 stredwic 85:
86: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
87: $Str .= 'Unable to tie database.';
88: $r->print($Str);
89: return;
90: }
91:
92: # Remove students who don't have the proper section.
93: my @sectionsSelected = split(':',$cache{'sectionsSelected'});
1.14 minaeibi 94:
95: my $studentCount = scalar @$students;
96: for(my $studentIndex=$studentCount-1; $studentIndex>=0;
1.7 stredwic 97: $studentIndex--) {
98: my $value = $cache{$students->[$studentIndex].':section'};
99: my $found = 0;
100: foreach (@sectionsSelected) {
101: if($_ eq 'none') {
102: if($value eq '' || !defined($value) || $value eq ' ') {
103: $found = 1;
104: last;
105: }
106: } else {
107: if($value eq $_) {
108: $found = 1;
109: last;
110: }
111: }
112: }
113: if($found == 0) {
114: splice(@$students, $studentIndex, 1);
115: }
116: }
1.9 stredwic 117: unless(untie(%cache)) {
118: $r->print('Can not untie hash.');
119: $r->rflush();
120: }
1.14 minaeibi 121:
1.16 minaeibi 122: &Apache::lonhtmlcommon::Close_PrgWin($r);
1.7 stredwic 123:
1.16 minaeibi 124: ### jason code for checing is there data in cache
1.13 minaeibi 125: # my $error =
126: # &Apache::loncoursedata::DownloadStudentCourseDataSeparate($students,
127: # 'true',
128: # $cacheDB,
129: # 'true',
130: # 'true',
131: # $courseID,
132: # $r, $c);
133: # if($error ne 'OK') {
134: # $r->print($error.'<br>Error downloading course data<br>');
135: # return;
136: # }
1.5 stredwic 137:
1.3 stredwic 138: unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
1.7 stredwic 139: $Str .= 'Unable to tie database.';
1.5 stredwic 140: $r->print($Str);
141: return;
1.1 stredwic 142: }
143:
1.2 stredwic 144: my ($problemId, $part, $responseId)=split(':',$cache{'AnalyzeInfo'});
145: my $uri = $cache{$problemId.':source'};
1.11 minaeibi 146: my $problem = $cache{$problemId.':problem'};
1.2 stredwic 147: my $title = $cache{$problemId.':title'};
148: my $interval = $cache{'Interval'};
1.14 minaeibi 149: my $heading = 'Restore this particular Option Response Problem '.
150: 'Results, Please wait...';
151:
1.1 stredwic 152: my %ConceptData;
153: $ConceptData{"Interval"} = $interval;
154:
155: #Initialize the option response true answers
1.11 minaeibi 156: my ($analyzeData) = &InitAnalysis($uri, $part, $responseId, $problem,
1.2 stredwic 157: $students->[0], $courseID);
158: if(defined($analyzeData->{'error'})) {
1.5 stredwic 159: $Str .= $analyzeData->{'error'}.'<br>Incorrect part requested.<br>';
160: $r->print($Str);
161: return;
1.2 stredwic 162: }
1.1 stredwic 163:
1.5 stredwic 164: $r->print($Str);
165: $Str = '';
166: if($c->aborted()) { untie(%cache); return; }
1.3 stredwic 167:
1.1 stredwic 168: #compute the intervals
1.11 minaeibi 169: &Interval($part, $problem, $interval, $analyzeData->{'concepts'},
1.2 stredwic 170: \%ConceptData);
1.1 stredwic 171:
172: $title =~ s/\ /"_"/eg;
173: $Str .= '<br><b>'.$uri.'</b>';
1.3 stredwic 174:
1.5 stredwic 175: $r->print($Str);
176: $Str = '';
177: if($c->aborted()) { untie(%cache); return; }
1.11 minaeibi 178:
1.14 minaeibi 179: &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);
180:
181: my $count=0;
1.1 stredwic 182: #Java script Progress window
1.2 stredwic 183: for(my $index=0; $index<(scalar @$students); $index++) {
1.5 stredwic 184: if($c->aborted()) { untie(%cache); return; }
1.14 minaeibi 185: $count++;
186: my $displayString = $count.'/'.$studentCount.': '.$_;
187: &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);
1.11 minaeibi 188: &OpStatus($problemId, $students->[$index], \%ConceptData,
1.14 minaeibi 189: $analyzeData->{'foil_to_concept'}, $analyzeData,
1.11 minaeibi 190: \%cache, $courseID);
1.1 stredwic 191: }
1.14 minaeibi 192: &Apache::lonhtmlcommon::Close_PrgWin($r);
1.1 stredwic 193:
194: $Str .= '<br>';
195: for (my $k=0; $k<$interval; $k++ ) {
1.3 stredwic 196: if($c->aborted()) { untie(%cache); return $Str; }
1.11 minaeibi 197: $Str .= &DrawGraph($k, $title, $analyzeData->{'concepts'},
1.2 stredwic 198: \%ConceptData);
1.5 stredwic 199: $r->print($Str);
200: $Str = '';
1.1 stredwic 201: }
202: for (my $k=0; $k<$interval; $k++ ) {
1.3 stredwic 203: if($c->aborted()) { untie(%cache); return $Str; }
1.2 stredwic 204: $Str .= &DrawTable($k, $analyzeData->{'concepts'}, \%ConceptData);
1.5 stredwic 205: $r->print($Str);
206: $Str = '';
1.1 stredwic 207: }
208: my $Answ=&Apache::lonnet::ssi($uri);
209: $Str .= '<br><b>Here you can see the Problem:</b><br>'.$Answ;
1.5 stredwic 210: $Str .= '<form>';
211: $r->print($Str);
1.1 stredwic 212:
213: untie(%cache);
214:
1.5 stredwic 215: return;
1.1 stredwic 216: }
217:
218: #---- Problem Analysis Web Page ----------------------------------------------
219:
220: sub IntervalOptions {
221: my ($selectedInterval)=@_;
222:
223: my $interval = 1;
224: for(my $n=1; $n<=7; $n++) {
225: if($selectedInterval == $n) {
226: $interval = $n;
227: }
228: }
229:
1.7 stredwic 230: my $Ptr = '<select name="Interval">'."\n";
1.1 stredwic 231: for(my $n=1; $n<=7;$ n++) {
232: $Ptr .= '<option';
233: if($interval == $n) {
234: $Ptr .= ' selected';
235: }
236: $Ptr .= '>'.$n."</option>"."\n";
237: }
238: $Ptr .= '</select>'."\n";
239:
240: return $Ptr;
241: }
242:
243: sub OptionResponseTable {
1.10 minaeibi 244: my ($optionResponses,$cache,$r)=@_;
1.1 stredwic 245:
1.2 stredwic 246: my @optionResponses=split(':::', $optionResponses);
247: my %partCount;
1.7 stredwic 248: my %sequences;
1.8 stredwic 249: my @orderedSequences=();
1.7 stredwic 250: foreach(@optionResponses) {
251: my ($sequence, $problemId, $part, undef)=split(':',$_);
1.2 stredwic 252: $partCount{$problemId.':'.$part}++;
1.7 stredwic 253: if(!defined($sequences{$sequence})) {
1.8 stredwic 254: push(@orderedSequences, $sequence);
1.7 stredwic 255: $sequences{$sequence} = $_;
256: } else {
257: $sequences{$sequence} .= ':::'.$_;
258: }
1.2 stredwic 259: }
1.11 minaeibi 260:
1.7 stredwic 261: my $Str = '';
262:
1.8 stredwic 263: foreach my $sequence (@orderedSequences) {
1.7 stredwic 264: my @optionProblems = split(':::', $sequences{$sequence});
265:
266: $Str .= '<b>'.$cache->{$sequence.':title'}.'</b>'."\n";
267: $Str .= "<table border=2><tr><th> \# </th><th> Problem Title </th>";
268: $Str .= '<th> Resource </th><th> Analysis </th></tr>'."\n";
269:
270: my $count = 1;
271: foreach(@optionProblems) {
272: my (undef, $problemId, $part, $response)=
1.10 minaeibi 273: split(':',$optionProblems[$count-1]);
274: # split(':',$sequences{$sequence});
1.7 stredwic 275: my $uri = $cache->{$problemId.':source'};
276: my $title = $cache->{$problemId.':title'};
277:
278: my $Temp = '<a href="'.$uri.'" target="_blank">'.$title.'</a>';
279: $Str .= '<tr>';
280: $Str .= '<td> '.$count.' </td>';
281: $Str .= '<td bgcolor="#DDFFDD">'.$Temp.'</td>';
282: $Str .= '<td bgcolor="#EEFFCC">'.$uri.'</td>';
283: if($partCount{$problemId.':'.$part} < 2) {
284: $Str .= '<td><input type="submit" name="Analyze:::';
285: $Str .= $problemId.':'.$part.'" value="';
286: $Str .= 'Part '.$part;
287: $Str .= '" /></td></tr>'."\n";
288: } else {
289: my $value = $problemId.':'.$part.':'.$response;
290: $Str .= '<td><input type="submit" name="Analyze:::'.$value;
291: $Str .= '" value="';
292: $Str .= 'Part '.$part.' Response '.$response;
293: $Str .= '" /></td></tr>'."\n";
294: }
295: $count++;
1.2 stredwic 296: }
1.7 stredwic 297: $Str .= '</table><br>'."\n";
1.1 stredwic 298: }
299:
300: return $Str;
301: }
302:
303: #---- END Problem Analysis Web Page ------------------------------------------
304:
305: #---- Analyze Web Page -------------------------------------------------------
306:
1.15 minaeibi 307: # Joson code for reading data from cache
1.11 minaeibi 308: =pod
1.1 stredwic 309: sub OpStatus {
1.11 minaeibi 310: my ($problemID, $student, $ConceptData, $foil_to_concept,
1.2 stredwic 311: $analyzeData, $cache)=@_;
312:
313: my $ids = $analyzeData->{'parts'};
1.11 minaeibi 314:
1.1 stredwic 315: my @True = ();
316: my @False = ();
317: my $flag=0;
1.2 stredwic 318:
319: my $tries=0;
320:
1.5 stredwic 321: foreach my $id (@$ids) {
1.11 minaeibi 322: my ($part, $response) = split(/\./, $id);
1.5 stredwic 323: my $time=$cache->{$student.':'.$problemID.':'.$part.':timestamp'};
324: my @submissions = split(':::', $cache->{$student.':'.$problemID.':'.
325: $part.':'.$response.
326: ':submission'});
327: foreach my $Resp (@submissions) {
1.2 stredwic 328: my %submission=&Apache::lonnet::str2hash($Resp);
329: foreach (keys(%submission)) {
330: if($submission{$_}) {
331: my $answer = $analyzeData->{$id.'.foil.value.'.$_};
332: if($submission{$_} eq $answer) {
1.11 minaeibi 333: &Decide("true", $foil_to_concept->{$_},
334: $time, $ConceptData);
335: } else {
336: &Decide("false", $foil_to_concept->{$_},
337: $time, $ConceptData);
338: }
339: }
340: }
341: }
342: }
343:
344: return;
345: }
346: =cut
347:
1.15 minaeibi 348:
349: #restore the student submissions and finding the result
350:
1.11 minaeibi 351: sub OpStatus {
352: my ($problemID, $student, $ConceptData, $foil_to_concept,
353: $analyzeData, $cache, $courseID)=@_;
354:
355: my $ids = $analyzeData->{'parts'};
356: my ($uname,$udom)=split(/\:/,$student);
357: my $symb = $cache->{$problemID.':problem'};
358:
359: my @True = ();
360: my @False = ();
361: my $flag=0;
362: my $tries=0;
363:
364: foreach my $id (@$ids) {
365: my ($part, $response) = split(/\./, $id);
1.15 minaeibi 366: my %reshash=&Apache::lonnet::restore($symb,$courseID,$udom,$uname);
367: if ($reshash{'version'}) {
368: my $tries=0;
369: for (my $version=1;$version<=$reshash{'version'};$version++) {
370: my $time=$reshash{"$version:timestamp"};
371: foreach my $key (sort(split(/\:/,$reshash{$version.':keys'}))) {
372: if (($key=~/\.(\w+)\.(\w+)\.submission$/)) {
373: my $Id1 = $1; my $Id2 = $2;
374: #check if this is a repeat submission, if so skip it
375: if ($reshash{"$version:resource.$Id1.previous"}) { next; }
376: #if no solved this wasn't a real submission, ignore it
377: if (!defined($reshash{"$version:resource.$Id1.solved"})) {
378: &Apache::lonxml::debug("skipping ");
379: next;
380: }
381: my $Resp = $reshash{"$version:$key"};
382: my %submission=&Apache::lonnet::str2hash($Resp);
383: foreach (keys %submission) {
384: my $Ansr = $analyzeData->{"$Id1.$Id2.foil.value.$_"};
385: if($submission{$_} eq $Ansr) {
1.12 minaeibi 386: &Decide("true", $foil_to_concept->{$_},
387: $time, $ConceptData);
1.15 minaeibi 388: } else {
1.12 minaeibi 389: &Decide("false", $foil_to_concept->{$_},
390: $time, $ConceptData);
1.15 minaeibi 391: }
392: }
393: }
1.11 minaeibi 394: }
1.2 stredwic 395: }
1.1 stredwic 396: }
397: }
1.2 stredwic 398:
399: return;
1.1 stredwic 400: }
401:
1.11 minaeibi 402:
1.1 stredwic 403: sub DrawGraph {
404: my ($k,$Src,$Concepts,$ConceptData)=@_;
405: my $Max=0;
406: my @data1;
407: my @data2;
408:
1.11 minaeibi 409: # Adjust Data and find the Max
1.1 stredwic 410: for (my $n=0; $n<(scalar @$Concepts); $n++ ) {
411: my $tmp=$Concepts->[$n];
412: $data1[$n]=$ConceptData->{$tmp.'.'.$k.'.true'};
413: $data2[$n]=$ConceptData->{$tmp.'.'.$k.'.false'};
414: my $Sum=$data1[$n]+$data2[$n];
415: if($Max < $Sum) {
416: $Max=$Sum;
417: }
418: }
419: for (my $n=0; $n<(scalar @$Concepts); $n++ ) {
420: if ($data1[$n]+$data2[$n]<$Max) {
421: $data2[$n]+=$Max-($data1[$n]+$data2[$n]);
422: }
423: }
424: my $P_No = (scalar @data1);
425:
426: if($Max > 1) {
427: $Max += (10 - $Max % 10);
428: $Max = int($Max);
429: } else {
430: $Max = 1;
431: }
432:
433: my $Titr=($ConceptData->{'Interval'}>1) ? $Src.'_interval_'.($k+1) : $Src;
434: # $GData=$Titr.'&Concepts'.'&'.'Answers'.'&'.$Max.'&'.$P_No.'&'.$data1.'&'.$data2;
435: my $GData = '';
436: $GData = $Titr.'&Concepts&Answers&'.$Max.'&'.$P_No.'&';
437: $GData .= (join(',',@data1)).'&'.(join(',',@data2));
438:
1.18 ! albertel 439: return '<IMG src="/cgi-bin/graph.png?'.$GData.'" border=1/>';
1.1 stredwic 440: }
441:
442: sub DrawTable {
443: my ($k,$Concepts,$ConceptData)=@_;
444: my $Max=0;
445: my @data1;
446: my @data2;
447: my $Correct=0;
448: my $Wrong=0;
449: for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
450: my $tmp=$Concepts->[$n];
451: $data1[$n]=$ConceptData->{$tmp.'.'.$k.'.true'};
452: $Correct+=$data1[$n];
453: $data2[$n]=$ConceptData->{$tmp.'.'.$k.'.false'};
454: $Wrong+=$data2[$n];
455: my $Sum=$data1[$n]+$data2[$n];
456: if($Max < $Sum) {
457: $Max=$Sum;
458: }
459: }
460: for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
461: if ($data1[$n]+$data2[$n]<$Max) {
462: $data2[$n]+=$Max-($data1[$n]+$data2[$n]);
463: }
464: }
465: my $P_No = (scalar @data1);
466: my $Str = '';
467: # $Str .= '<br><b>From: ['.localtime($ConceptData->{'Int.'.($k-1)});
1.11 minaeibi 468: # $Str .= '] To: ['.localtime($ConceptData->{"Int.$k"}).']</b>';
1.1 stredwic 469: $Str .= "\n".'<table border=2>'.
470: "\n".'<tr>'.
471: "\n".'<th> # </th>'.
472: "\n".'<th> Concept </th>'.
473: "\n".'<th> Correct </th>'.
474: "\n".'<th> Wrong </th>'.
475: "\n".'</tr>';
476:
477: for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
478: $Str .= '<tr>'."\n";
479: $Str .= '<td>'.($n+1).'</td>'."\n";
1.2 stredwic 480: my ($currentConcept) = split('::',$Concepts->[$n]);
481: $Str .= '<td bgcolor="EEFFCC">'.$currentConcept;
1.1 stredwic 482: $Str .= '</td>'."\n";
483: $Str .= '<td bgcolor="DDFFDD">'.$data1[$n].'</td>'."\n";
484: $Str .= '<td bgcolor="FFDDDD">'.$data2[$n].'</td>'."\n";
485: $Str .= '</tr>'."\n";
486: }
487: $Str .= '<td></td><td><b>From:['.localtime($ConceptData->{'Int.'.$k});
488: $Str .= '] To: ['.localtime($ConceptData->{'Int.'.($k+1)}-1);
489: $Str .= ']</b></td><td>'.$Correct.'</td><td>'.$Wrong.'</td>';
490: $Str .= '</table>'."\n";
491:
492: return $Str;
493: #$Apache::lonxml::debug=1;
494: #&Apache::lonhomework::showhash(%ConceptData);
495: #$Apache::lonxml::debug=0;
496: }
497:
498: #---- END Analyze Web Page ----------------------------------------------
499:
500: sub Decide {
501: #deciding the true or false answer belongs to each interval
502: my ($type,$concept,$time,$ConceptData)=@_;
503: my $k=0;
1.2 stredwic 504: while($time > $ConceptData->{'Int.'.($k+1)} &&
505: $k < $ConceptData->{'Interval'}) {
506: $k++;
507: }
1.1 stredwic 508: $ConceptData->{$concept.'.'.$k.'.'.$type}++;
509:
510: return;
511: }
512:
513: sub InitAnalysis {
1.2 stredwic 514: my ($uri,$part,$responseId,$problem,$student,$courseID)=@_;
1.1 stredwic 515: my ($name,$domain)=split(/\:/,$student);
516:
1.2 stredwic 517: my %analyzeData;
1.1 stredwic 518: # Render the student's view of the problem. $Answ is the problem
519: # Stringafied
520: my $Answ=&Apache::lonnet::ssi($uri,('grade_target' => 'analyze',
521: 'grade_username' => $name,
522: 'grade_domain' => $domain,
523: 'grade_courseid' => $courseID,
524: 'grade_symb' => $problem));
1.6 stredwic 525: my ($Answer)=&Apache::lonnet::str2hashref($Answ);
1.1 stredwic 526:
1.2 stredwic 527: my $found = 0;
528: my @parts=();
529: if(defined($responseId)) {
1.5 stredwic 530: foreach (@{$Answer->{'parts'}}) {
1.2 stredwic 531: if($_ eq $part.'.'.$responseId) {
532: push(@parts, $_);
533: $found = 1;
534: last;
535: }
536: }
537: } else {
1.5 stredwic 538: foreach (@{$Answer->{'parts'}}) {
1.2 stredwic 539: if($_ =~ /$part/) {
540: push(@parts, $_);
541: $found = 1;
542: last;
543: }
544: }
1.1 stredwic 545: }
546:
1.2 stredwic 547: if($found == 0) {
548: $analyzeData{'error'} = 'No parts matching selected values';
549: return \%analyzeData;
1.1 stredwic 550: }
551:
1.2 stredwic 552: my @Concepts=();
1.1 stredwic 553: my %foil_to_concept;
1.2 stredwic 554: foreach my $currentPart (@parts) {
1.5 stredwic 555: if(defined($Answer->{$currentPart.'.concepts'})) {
556: foreach my $concept (@{$Answer->{$currentPart.'.concepts'}}) {
1.2 stredwic 557: push(@Concepts, $concept);
1.5 stredwic 558: foreach my $foil (@{$Answer->{$currentPart.'.concept.'.
1.2 stredwic 559: $concept}}) {
560: $analyzeData{$currentPart.'.foil.value.'.$foil} =
1.5 stredwic 561: $Answer->{$currentPart.'.foil.value.'.$foil};
1.2 stredwic 562: $foil_to_concept{$foil} = $concept;
563: }
564: }
565: } else {
1.5 stredwic 566: foreach (keys(%$Answer)) {
1.2 stredwic 567: if(/$currentPart.foil\.value\.(.*)$/) {
568: push(@Concepts, $1);
569: $foil_to_concept{$1} = $1;
570: $analyzeData{$currentPart.'.foil.value.'.$1} =
1.5 stredwic 571: $Answer->{$currentPart.'.foil.value.'.$1};
1.2 stredwic 572: }
573: }
574: }
1.1 stredwic 575: }
576:
1.2 stredwic 577: $analyzeData{'parts'} = \@parts;
578: $analyzeData{'concepts'} = \@Concepts;
579: $analyzeData{'foil_to_concept'} = \%foil_to_concept;
580:
581: return \%analyzeData;
1.1 stredwic 582: }
583:
584: sub Interval {
585: my ($part,$symb,$interval,$Concepts,$ConceptData)=@_;
586: my $Int=$interval;
587: my $due = &Apache::lonnet::EXT('resource.'.$part.'.duedate',$symb);
588: my $opn = &Apache::lonnet::EXT('resource.'.$part.'.opendate',$symb);
589: my $add=int(($due-$opn)/$Int);
590: $ConceptData->{'Int.0'}=$opn;
1.2 stredwic 591: for(my $i=1; $i<$Int; $i++) {
1.1 stredwic 592: $ConceptData->{'Int.'.$i}=$opn+$i*$add;
593: }
1.11 minaeibi 594: $ConceptData->{'Int.'.$Int}=$due;
1.2 stredwic 595: for(my $i=0; $i<$Int; $i++) {
596: for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
1.1 stredwic 597: my $tmp=$Concepts->[$n];
598: $ConceptData->{$tmp.'.'.$i.'.true'}=0;
599: $ConceptData->{$tmp.'.'.$i.'.false'}=0;
600: }
601: }
602: }
603: 1;
604: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>