File:  [LON-CAPA] / loncom / interface / statistics / lonproblemanalysis.pm
Revision 1.15: download - view: text, annotated - select for diffs
Mon Nov 25 18:12:52 2002 UTC (21 years, 7 months ago) by minaeibi
Branches: MAIN
CVS tags: HEAD
Cleaning the source.

    1: # The LearningOnline Network with CAPA
    2: # (Publication Handler
    3: #
    4: # $Id: lonproblemanalysis.pm,v 1.15 2002/11/25 18:12:52 minaeibi 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(&OptionResponseTable($cache{'OptionResponses'}, \%cache, $r));
   70: 
   71:     untie(%cache);
   72: 
   73:     return;
   74: }
   75: 
   76: sub BuildAnalyzePage {
   77:     my ($cacheDB, $students, $courseID,$r)=@_;
   78: 
   79:     $jr = $r;
   80:     my $c = $r->connection;
   81: 
   82:     my $Str = '</form>';
   83:     my %cache;
   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'});
   93: 
   94:     my $studentCount = scalar @$students;
   95:     for(my $studentIndex=$studentCount-1; $studentIndex>=0;
   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:     }
  116:     unless(untie(%cache)) {
  117:         $r->print('Can not untie hash.');
  118:         $r->rflush();
  119:     }
  120:     #if($status eq 'true')
  121:     { &Apache::lonhtmlcommon::Close_PrgWin($r); }
  122: 
  123: 
  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: #    }
  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: 
  150: #    my $title = 'LON-CAPA Statistics';
  151:     my $heading = 'Restore this particular Option Response Problem '.
  152:                   'Results, Please wait...';
  153: 
  154:     my %ConceptData;
  155:     $ConceptData{"Interval"} = $interval;
  156: 
  157:     #Initialize the option response true answers
  158:     my ($analyzeData) = &InitAnalysis($uri, $part, $responseId, $problem,
  159:                                       $students->[0], $courseID);
  160:     if(defined($analyzeData->{'error'})) {
  161:         $Str .= $analyzeData->{'error'}.'<br>Incorrect part requested.<br>';
  162:         $r->print($Str);
  163:         return;
  164:     }
  165: 
  166:     $r->print($Str);
  167:     $Str = '';
  168:     if($c->aborted()) {  untie(%cache); return; }
  169: 
  170:     #compute the intervals
  171:     &Interval($part, $problem, $interval, $analyzeData->{'concepts'},
  172:               \%ConceptData);
  173: 
  174:     $title =~ s/\ /"_"/eg;
  175:     $Str .= '<br><b>'.$uri.'</b>';
  176: 
  177:     $r->print($Str);
  178:     $Str = '';
  179:     if($c->aborted()) {  untie(%cache); return; }
  180: 
  181:     &Apache::lonhtmlcommon::Create_PrgWin($r, $title, $heading);
  182: 
  183:     my $count=0;
  184:     #Java script Progress window
  185:     for(my $index=0; $index<(scalar @$students); $index++) {
  186:         if($c->aborted()) {  untie(%cache); return; }
  187:         $count++;
  188:         my $displayString = $count.'/'.$studentCount.': '.$_;
  189:         &Apache::lonhtmlcommon::Update_PrgWin($displayString, $r);
  190: 	&OpStatus($problemId, $students->[$index], \%ConceptData,
  191:                   $analyzeData->{'foil_to_concept'}, $analyzeData,
  192: 		  \%cache, $courseID);
  193:     }
  194:     &Apache::lonhtmlcommon::Close_PrgWin($r);
  195: 
  196:     $Str .= '<br>';
  197:     for (my $k=0; $k<$interval; $k++ ) {
  198:         if($c->aborted()) {  untie(%cache); return $Str; }
  199: 	$Str .= &DrawGraph($k, $title, $analyzeData->{'concepts'},
  200:                            \%ConceptData);
  201:         $r->print($Str);
  202:         $Str = '';
  203:     }
  204:     for (my $k=0; $k<$interval; $k++ ) {
  205:         if($c->aborted()) {  untie(%cache); return $Str; }
  206: 	$Str .= &DrawTable($k, $analyzeData->{'concepts'}, \%ConceptData);
  207:         $r->print($Str);
  208:         $Str = '';
  209:     }
  210:     my $Answ=&Apache::lonnet::ssi($uri);
  211:     $Str .= '<br><b>Here you can see the Problem:</b><br>'.$Answ;
  212:     $Str .= '<form>';
  213:     $r->print($Str);
  214: 
  215:     untie(%cache);
  216: 
  217:     return;
  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: 
  232:     my $Ptr = '<select name="Interval">'."\n";
  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 {
  246:     my ($optionResponses,$cache,$r)=@_;
  247: 
  248:     my @optionResponses=split(':::', $optionResponses);
  249:     my %partCount;
  250:     my %sequences;
  251:     my @orderedSequences=();
  252:     foreach(@optionResponses) {
  253:         my ($sequence, $problemId, $part, undef)=split(':',$_);
  254:         $partCount{$problemId.':'.$part}++;
  255:         if(!defined($sequences{$sequence})) {
  256:             push(@orderedSequences, $sequence);
  257:             $sequences{$sequence} = $_;
  258:         } else {
  259:             $sequences{$sequence} .= ':::'.$_;
  260:         }
  261:     }
  262: 
  263:     my $Str = '';
  264: 
  265:     foreach my $sequence (@orderedSequences) {
  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)=
  275:                 split(':',$optionProblems[$count-1]);
  276: #                split(':',$sequences{$sequence});
  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++;
  298:         }
  299:         $Str .= '</table><br>'."\n";
  300:     }
  301: 
  302:     return $Str;
  303: }
  304: 
  305: #---- END Problem Analysis Web Page ------------------------------------------
  306: 
  307: #---- Analyze Web Page -------------------------------------------------------
  308: 
  309: # Joson code for reading data from cache
  310: =pod
  311: sub OpStatus {
  312:     my ($problemID, $student, $ConceptData, $foil_to_concept,
  313:         $analyzeData, $cache)=@_;
  314: 
  315:     my $ids = $analyzeData->{'parts'};
  316: 
  317:     my @True = ();
  318:     my @False = ();
  319:     my $flag=0;
  320: 
  321:     my $tries=0;
  322: 
  323:     foreach my $id (@$ids) {
  324: 	my ($part, $response) = split(/\./, $id);
  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) {
  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) {
  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: 
  350: 
  351: #restore the student submissions and finding the result
  352: 
  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);
  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) {
  388:                         	&Decide("true", $foil_to_concept->{$_},
  389:                                 	$time, $ConceptData);
  390:                     	    } else {
  391:                         	&Decide("false", $foil_to_concept->{$_},
  392: 					$time, $ConceptData);
  393:                     	    }
  394: 		        }
  395: 	            }
  396: 	        }
  397:             }
  398:         }
  399:     }
  400: 
  401:     return;
  402: }
  403: 
  404: 
  405: sub DrawGraph {
  406:     my ($k,$Src,$Concepts,$ConceptData)=@_;
  407:     my $Max=0;
  408:     my @data1;
  409:     my @data2;
  410: 
  411:     # Adjust Data and find the Max
  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)});
  470: #    $Str .= '] To: ['.localtime($ConceptData->{"Int.$k"}).']</b>';
  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";
  482:         my ($currentConcept) = split('::',$Concepts->[$n]);
  483:         $Str .= '<td bgcolor="EEFFCC">'.$currentConcept;
  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;
  506:     while($time > $ConceptData->{'Int.'.($k+1)} && 
  507:            $k < $ConceptData->{'Interval'}) {
  508:         $k++;
  509:     }
  510:     $ConceptData->{$concept.'.'.$k.'.'.$type}++;
  511: 
  512:     return;
  513: }
  514: 
  515: sub InitAnalysis {
  516:     my ($uri,$part,$responseId,$problem,$student,$courseID)=@_;
  517:     my ($name,$domain)=split(/\:/,$student);
  518: 
  519:     my %analyzeData;
  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));
  527:     my ($Answer)=&Apache::lonnet::str2hashref($Answ);
  528: 
  529:     my $found = 0;
  530:     my @parts=();
  531:     if(defined($responseId)) {
  532:         foreach (@{$Answer->{'parts'}}) {
  533:             if($_ eq $part.'.'.$responseId) {
  534:                 push(@parts, $_);
  535:                 $found = 1;
  536:                 last;
  537:             }
  538:         }
  539:     } else {
  540:         foreach (@{$Answer->{'parts'}}) {
  541:             if($_ =~ /$part/) {
  542:                 push(@parts, $_);
  543:                 $found = 1;
  544:                 last;
  545:             }
  546:         }
  547:     }
  548: 
  549:     if($found == 0) {
  550:         $analyzeData{'error'} = 'No parts matching selected values';
  551:         return \%analyzeData;
  552:     }
  553: 
  554:     my @Concepts=();
  555:     my %foil_to_concept;
  556:     foreach my $currentPart (@parts) {
  557:         if(defined($Answer->{$currentPart.'.concepts'})) {
  558:             foreach my $concept (@{$Answer->{$currentPart.'.concepts'}}) {
  559:                 push(@Concepts, $concept);
  560:                 foreach my $foil (@{$Answer->{$currentPart.'.concept.'.
  561:                                             $concept}}) {
  562:                     $analyzeData{$currentPart.'.foil.value.'.$foil} =
  563:                         $Answer->{$currentPart.'.foil.value.'.$foil};
  564:                     $foil_to_concept{$foil} = $concept;
  565:                 }
  566:             }
  567:         } else {
  568:             foreach (keys(%$Answer)) {
  569:                 if(/$currentPart.foil\.value\.(.*)$/) {
  570:                     push(@Concepts, $1);
  571:                     $foil_to_concept{$1} = $1;
  572:                     $analyzeData{$currentPart.'.foil.value.'.$1} =
  573:                         $Answer->{$currentPart.'.foil.value.'.$1};
  574:                 }
  575:             }
  576:         }
  577:     }
  578: 
  579:     $analyzeData{'parts'} = \@parts;
  580:     $analyzeData{'concepts'} = \@Concepts;
  581:     $analyzeData{'foil_to_concept'} = \%foil_to_concept;
  582: 
  583:     return \%analyzeData;
  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;
  593:     for(my $i=1; $i<$Int; $i++) {
  594: 	$ConceptData->{'Int.'.$i}=$opn+$i*$add;
  595:     }
  596:     $ConceptData->{'Int.'.$Int}=$due;
  597:     for(my $i=0; $i<$Int; $i++) {
  598: 	for(my $n=0; $n<(scalar @$Concepts); $n++ ) {
  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>