--- loncom/interface/loncoursedata.pm 2002/07/09 15:43:49 1.1 +++ loncom/interface/loncoursedata.pm 2002/07/17 12:38:25 1.2 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # (Publication Handler # -# $Id: loncoursedata.pm,v 1.1 2002/07/09 15:43:49 stredwic Exp $ +# $Id: loncoursedata.pm,v 1.2 2002/07/17 12:38:25 stredwic Exp $ # # Copyright Michigan State University Board of Trustees # @@ -309,8 +309,13 @@ sub ProcessTopResourceMap { ':'.$currentResourceID; } - # Get Parts for problem my $meta=$hash{'src_'.$currentResourceID}; +# $cache->{$currentResourceID.':title'}= +# &Apache::lonnet::metdata($meta,'title'); + $cache->{$currentResourceID.':title'}= + $hash{'title_'.$currentResourceID}; + + # Get Parts for problem foreach (split(/\,/,&Apache::lonnet::metadata($meta,'keys'))) { if($_=~/^stores\_(\d+)\_tries$/) { my $Part=&Apache::lonnet::metadata($meta,$_.'.part'); @@ -322,7 +327,23 @@ sub ProcessTopResourceMap { $cache->{$currentSequence.':'.$currentResourceID. ':parts'}.=':'.$Part; } - } + foreach (split(/\,/, + &Apache::lonnet::metadata($meta,'packages'))) { + if($_=~/^optionresponse\_($Part)\_(\w+)$/) { + if(defined($cache->{'OptionResponses'})) { + $cache->{'OptionResponses'}.= ':::'. + $hash{'src_'.$currentResourceID}.'::'. + $hash{'title_'.$currentResourceID}.'::'. + $Part.'::'.$Problem; + } else { + $cache->{'OptionResponses'}= + $hash{'src_'.$currentResourceID}.'::'. + $hash{'title_'.$currentResourceID}.'::'. + $Part.'::'.$Problem; + } + } + } + } } } @@ -336,6 +357,8 @@ sub ProcessTopResourceMap { # Capture sequence information here $cache->{$currentSequence.':title'}= $hash{'title_'.$currentResourceID}; + $cache->{$currentSequence.':source'}= + $hash{'src_'.$currentResourceID}; my $totalProblems=0; foreach my $currentProblem (split(/\:/, @@ -442,40 +465,41 @@ sub ProcessSection { if($key eq $courseid.'_st') { $section=''; } + my ($dummy,$end,$start)=split(/\_/,$value); my $now=time; - my $notactive=0; - if ($start) { - if($now<$start) { - $notactive=1; - } - } - if($end) { - if ($now>$end) { - $notactive=1; - } - } - if($notactive == 0) { - $status='Active'; - $cursection=$section; - last; - } - if($notactive == 1) { - $oldsection=$section; - } + my $notactive=0; + if ($start) { + if($now<$start) { + $notactive=1; + } + } + if($end) { + if ($now>$end) { + $notactive=1; + } + } + if($notactive == 0) { + $status='Active'; + $cursection=$section; + last; + } + if($notactive == 1) { + $oldsection=$section; + } } } if($status eq $ActiveFlag) { - if($cursection eq '-1') { - return $oldsection; - } - return $cursection; + if($cursection eq '-1') { + return $oldsection; + } + return $cursection; } if($ActiveFlag eq 'Any') { - if($cursection eq '-1') { - return $oldsection; - } - return $cursection; + if($cursection eq '-1') { + return $oldsection; + } + return $cursection; } return '-1'; } @@ -539,12 +563,11 @@ sub ProcessStudentNamePIDSection { $cache->{$name.':id'}=$studentInformation->{'id'}; } - # Get student's section number my $sec=&ProcessSection($section, $courseID, $status); if($sec != -1) { - $cache->{$name.':section'}=$sec; + $cache->{$name.':section'}=$sec; } else { - $cache->{$name.':section'}=''; + $cache->{$name.':section'}=''; } return; @@ -792,6 +815,35 @@ sub TestCacheData { return $isCached; } +#sub CheckStatus { +# my ($name, $data, $status)=@_; + +# if($status eq 'Any') { +# my $section = ' '; +# foreach (split(':',$data->{$name.':Sections'})) { +# if($data->{$name.':'.$_.'Status'} eq 'Active') { +# return $_; +# } +# $section = $_; +# } +# return $_; +# } + +# foreach (split(':',$data->{$name.':Sections'})) { +# if($data->{$name.':'.$_.'Status'} eq $status) { +# return $_; +# } +# } + +# foreach (split(':',$data->{$name.':Sections'})) { +# if($data->{$name.':'.$_.'Status'} eq 'Any') { +# return $_; +# } +# } + +# return 'not found'; +#} + # ----- END HELPER FUNCTIONS -------------------------------------------- 1;