File:  [LON-CAPA] / loncom / interface / statistics / lonproblemanalysis.pm
Revision 1.18: download - view: text, annotated - select for diffs
Fri Dec 13 21:39:19 2002 UTC (21 years, 6 months ago) by albertel
Branches: MAIN
CVS tags: version_0_6_2, version_0_6, HEAD
- using png now

    1: # The LearningOnline Network with CAPA
    2: # (Publication Handler
    3: #
    4: # $Id: lonproblemanalysis.pm,v 1.18 2002/12/13 21:39:19 albertel Exp $
    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
   30: # 5/12,7/26,9/7,11/22 Behrouz Minaei
   31: #
   32: ###
   33: 
   34: package Apache::lonproblemanalysis;
   35: 
   36: use strict;
   37: use Apache::lonnet();
   38: use Apache::lonhtmlcommon();
   39: use GDBM_File;
   40: 
   41: my $jr;
   42: 
   43: sub BuildProblemAnalysisPage {
   44:     my ($cacheDB, $r)=@_;
   45: 
   46:     my %cache;
   47:     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
   48:         $r->print('Unable to tie database.');
   49:         return;
   50:     }
   51: 
   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);
   68:     $r->rflush();
   69: #   $r->print($cache{'OptionResponses'}.'<br>');
   70:     $r->print(&OptionResponseTable($cache{'OptionResponses'}, \%cache, $r));
   71: 
   72:     untie(%cache);
   73: 
   74:     return;
   75: }
   76: 
   77: sub BuildAnalyzePage {
   78:     my ($cacheDB, $students, $courseID,$r)=@_;
   79: 
   80:     $jr = $r;
   81:     my $c = $r->connection;
   82: 
   83:     my $Str = '</form>';
   84:     my %cache;
   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'});
   94: 
   95:     my $studentCount = scalar @$students;
   96:     for(my $studentIndex=$studentCount-1; $studentIndex>=0;
   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:     }
  117:     unless(untie(%cache)) {
  118:         $r->print('Can not untie hash.');
  119:         $r->rflush();
  120:     }
  121: 
  122:     &Apache::lonhtmlcommon::Close_PrgWin($r);
  123: 
  124: ### jason code for checing is there data in cache
  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: #    }
  137: 
  138:     unless(tie(%cache,'GDBM_File',$cacheDB,&GDBM_READER(),0640)) {
  139:         $Str .= 'Unable to tie database.';
  140:         $r->print($Str);
  141:         return;
  142:     }
  143: 
  144:     my ($problemId, $part, $responseId)=split(':',$cache{'AnalyzeInfo'});
  145:     my $uri      = $cache{$problemId.':source'};
  146:     my $problem  = $cache{$problemId.':problem'};
  147:     my $title    = $cache{$problemId.':title'};
  148:     my $interval = $cache{'Interval'};
  149:     my $heading = 'Restore this particular Option Response Problem '.
  150:                   'Results, Please wait...';
  151: 
  152:     my %ConceptData;
  153:     $ConceptData{"Interval"} = $interval;
  154: 
  155:     #Initialize the option response true answers
  156:     my ($analyzeData) = &InitAnalysis($uri, $part, $responseId, $problem,
  157:                                       $students->[0], $courseID);
  158:     if(defined($analyzeData->{'error'})) {
  159:         $Str .= $analyzeData->{'error'}.'<br>Incorrect part requested.<br>';
  160:         $r->print($Str);
  161:         return;
  162:     }
  163: 
  164:     $r->print($Str);
  165:     $Str = '';
  166:     if($c->aborted()) {  untie(%cache); return; }
  167: 
  168:     #compute the intervals
  169:     &Interval($part, $problem, $interval, $analyzeData->{'concepts'},
  170:               \%ConceptData);
  171: 
  172:     $title =~ s/\ /"_"/eg;
  173:     $Str .= '<br><b>'.$uri.'</b>';
  174: 
  175:     $r->print($Str);
  176:     $Str = '';
  177:     if($c->aborted()) {  untie(%cache); return; }
  178: 
  179:     &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);
  180: 
  181:     my $count=0;
  182:     #Java script Progress window
  183:     for(my $index=0; $index<(scalar @$students); $index++) {
  184:         if($c->aborted()) {  untie(%cache); return; }
  185:         $count++;
  186:         my $displayString = $count.'/'.$studentCount.': '.$_;
  187:         &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);
  188: 	&OpStatus($problemId, $students->[$index], \%ConceptData,
  189:                   $analyzeData->{'foil_to_concept'}, $analyzeData,
  190: 		  \%cache, $courseID);
  191:     }
  192:     &Apache::lonhtmlcommon::Close_PrgWin($r);
  193: 
  194:     $Str .= '<br>';
  195:     for (my $k=0; $k<$interval; $k++ ) {
  196:         if($c->aborted()) {  untie(%cache); return $Str; }
  197: 	$Str .= &DrawGraph($k, $title, $analyzeData->{'concepts'},
  198:                            \%ConceptData);
  199:         $r->print($Str);
  200:         $Str = '';
  201:     }
  202:     for (my $k=0; $k<$interval; $k++ ) {
  203:         if($c->aborted()) {  untie(%cache); return $Str; }
  204: 	$Str .= &DrawTable($k, $analyzeData->{'concepts'}, \%ConceptData);
  205:         $r->print($Str);
  206:         $Str = '';
  207:     }
  208:     my $Answ=&Apache::lonnet::ssi($uri);
  209:     $Str .= '<br><b>Here you can see the Problem:</b><br>'.$Answ;
  210:     $Str .= '<form>';
  211:     $r->print($Str);
  212: 
  213:     untie(%cache);
  214: 
  215:     return;
  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: 
  230:     my $Ptr = '<select name="Interval">'."\n";
  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 {
  244:     my ($optionResponses,$cache,$r)=@_;
  245: 
  246:     my @optionResponses=split(':::', $optionResponses);
  247:     my %partCount;
  248:     my %sequences;
  249:     my @orderedSequences=();
  250:     foreach(@optionResponses) {
  251:         my ($sequence, $problemId, $part, undef)=split(':',$_);
  252:         $partCount{$problemId.':'.$part}++;
  253:         if(!defined($sequences{$sequence})) {
  254:             push(@orderedSequences, $sequence);
  255:             $sequences{$sequence} = $_;
  256:         } else {
  257:             $sequences{$sequence} .= ':::'.$_;
  258:         }
  259:     }
  260: 
  261:     my $Str = '';
  262: 
  263:     foreach my $sequence (@orderedSequences) {
  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)=
  273:                 split(':',$optionProblems[$count-1]);
  274: #                split(':',$sequences{$sequence});
  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++;
  296:         }
  297:         $Str .= '</table><br>'."\n";
  298:     }
  299: 
  300:     return $Str;
  301: }
  302: 
  303: #---- END Problem Analysis Web Page ------------------------------------------
  304: 
  305: #---- Analyze Web Page -------------------------------------------------------
  306: 
  307: # Joson code for reading data from cache
  308: =pod
  309: sub OpStatus {
  310:     my ($problemID, $student, $ConceptData, $foil_to_concept,
  311:         $analyzeData, $cache)=@_;
  312: 
  313:     my $ids = $analyzeData->{'parts'};
  314: 
  315:     my @True = ();
  316:     my @False = ();
  317:     my $flag=0;
  318: 
  319:     my $tries=0;
  320: 
  321:     foreach my $id (@$ids) {
  322: 	my ($part, $response) = split(/\./, $id);
  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) {
  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) {
  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: 
  348: 
  349: #restore the student submissions and finding the result
  350: 
  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);
  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) {
  386:                         	&Decide("true", $foil_to_concept->{$_},
  387:                                 	$time, $ConceptData);
  388:                     	    } else {
  389:                         	&Decide("false", $foil_to_concept->{$_},
  390: 					$time, $ConceptData);
  391:                     	    }
  392: 		        }
  393: 	            }
  394: 	        }
  395:             }
  396:         }
  397:     }
  398: 
  399:     return;
  400: }
  401: 
  402: 
  403: sub DrawGraph {
  404:     my ($k,$Src,$Concepts,$ConceptData)=@_;
  405:     my $Max=0;
  406:     my @data1;
  407:     my @data2;
  408: 
  409:     # Adjust Data and find the Max
  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: 
  439:     return '<IMG src="/cgi-bin/graph.png?'.$GData.'" border=1/>';
  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)});
  468: #    $Str .= '] To: ['.localtime($ConceptData->{"Int.$k"}).']</b>';
  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";
  480:         my ($currentConcept) = split('::',$Concepts->[$n]);
  481:         $Str .= '<td bgcolor="EEFFCC">'.$currentConcept;
  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;
  504:     while($time > $ConceptData->{'Int.'.($k+1)} && 
  505:            $k < $ConceptData->{'Interval'}) {
  506:         $k++;
  507:     }
  508:     $ConceptData->{$concept.'.'.$k.'.'.$type}++;
  509: 
  510:     return;
  511: }
  512: 
  513: sub InitAnalysis {
  514:     my ($uri,$part,$responseId,$problem,$student,$courseID)=@_;
  515:     my ($name,$domain)=split(/\:/,$student);
  516: 
  517:     my %analyzeData;
  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));
  525:     my ($Answer)=&Apache::lonnet::str2hashref($Answ);
  526: 
  527:     my $found = 0;
  528:     my @parts=();
  529:     if(defined($responseId)) {
  530:         foreach (@{$Answer->{'parts'}}) {
  531:             if($_ eq $part.'.'.$responseId) {
  532:                 push(@parts, $_);
  533:                 $found = 1;
  534:                 last;
  535:             }
  536:         }
  537:     } else {
  538:         foreach (@{$Answer->{'parts'}}) {
  539:             if($_ =~ /$part/) {
  540:                 push(@parts, $_);
  541:                 $found = 1;
  542:                 last;
  543:             }
  544:         }
  545:     }
  546: 
  547:     if($found == 0) {
  548:         $analyzeData{'error'} = 'No parts matching selected values';
  549:         return \%analyzeData;
  550:     }
  551: 
  552:     my @Concepts=();
  553:     my %foil_to_concept;
  554:     foreach my $currentPart (@parts) {
  555:         if(defined($Answer->{$currentPart.'.concepts'})) {
  556:             foreach my $concept (@{$Answer->{$currentPart.'.concepts'}}) {
  557:                 push(@Concepts, $concept);
  558:                 foreach my $foil (@{$Answer->{$currentPart.'.concept.'.
  559:                                             $concept}}) {
  560:                     $analyzeData{$currentPart.'.foil.value.'.$foil} =
  561:                         $Answer->{$currentPart.'.foil.value.'.$foil};
  562:                     $foil_to_concept{$foil} = $concept;
  563:                 }
  564:             }
  565:         } else {
  566:             foreach (keys(%$Answer)) {
  567:                 if(/$currentPart.foil\.value\.(.*)$/) {
  568:                     push(@Concepts, $1);
  569:                     $foil_to_concept{$1} = $1;
  570:                     $analyzeData{$currentPart.'.foil.value.'.$1} =
  571:                         $Answer->{$currentPart.'.foil.value.'.$1};
  572:                 }
  573:             }
  574:         }
  575:     }
  576: 
  577:     $analyzeData{'parts'} = \@parts;
  578:     $analyzeData{'concepts'} = \@Concepts;
  579:     $analyzeData{'foil_to_concept'} = \%foil_to_concept;
  580: 
  581:     return \%analyzeData;
  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;
  591:     for(my $i=1; $i<$Int; $i++) {
  592: 	$ConceptData->{'Int.'.$i}=$opn+$i*$add;
  593:     }
  594:     $ConceptData->{'Int.'.$Int}=$due;
  595:     for(my $i=0; $i<$Int; $i++) {
  596: 	for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
  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>