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