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