Diff for /loncom/interface/lonparmset.pm between versions 1.197 and 1.200

version 1.197, 2005/06/01 21:44:00 version 1.200, 2005/06/02 16:35:32
Line 64  use Apache::lonxml; Line 64  use Apache::lonxml;
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonnavmaps;  use Apache::lonnavmaps;
   
 my %courseopt;  # --- Caches local to lonparmset
 my %useropt;  
   my $parmhashid;
 my %parmhash;  my %parmhash;
   
   # --- end local caches
   
   #
   # FIXME: get rid of items below
   #
 my @ids;  my @ids;
 my %symbp;  my %symbp;
 my %mapp;  my %mapp;
Line 109  Returns:  A list, the first item is the Line 115  Returns:  A list, the first item is the
 ##################################################  ##################################################
 sub parmval {  sub parmval {
     my ($what,$id,$def,$uname,$udom,$csec)=@_;      my ($what,$id,$def,$uname,$udom,$csec)=@_;
   # load caches
   
       &cacheparmhash();
   
       my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
       my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
       my $useropt=&Apache::lonnet::get_userresdata($uname,$udom);
       my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom);
   
   
     my $result='';      my $result='';
     my @outpar=();      my @outpar=();
 # ----------------------------------------------------- Cascading lookup scheme  # ----------------------------------------------------- Cascading lookup scheme
Line 128  sub parmval { Line 144  sub parmval {
   
 # --------------------------------------------------------- first, check course  # --------------------------------------------------------- first, check course
   
     if (defined($courseopt{$courselevel})) {      if (defined($$courseopt{$courselevel})) {
  $outpar[11]=$courseopt{$courselevel};   $outpar[11]=$$courseopt{$courselevel};
  $result=11;   $result=11;
     }      }
   
     if (defined($courseopt{$courselevelm})) {      if (defined($$courseopt{$courselevelm})) {
  $outpar[10]=$courseopt{$courselevelm};   $outpar[10]=$$courseopt{$courselevelm};
  $result=10;   $result=10;
     }      }
   
Line 147  sub parmval { Line 163  sub parmval {
     my $thisparm=$parmhash{$symbparm};      my $thisparm=$parmhash{$symbparm};
     if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; }      if (defined($thisparm)) { $outpar[8]=$thisparm; $result=8; }
   
     if (defined($courseopt{$courselevelr})) {      if (defined($$courseopt{$courselevelr})) {
  $outpar[7]=$courseopt{$courselevelr};   $outpar[7]=$$courseopt{$courselevelr};
  $result=7;   $result=7;
     }      }
   
 # ------------------------------------------------------ fourth, back to course  # ------------------------------------------------------ fourth, back to course
     if (defined($csec)) {      if (defined($csec)) {
         if (defined($courseopt{$seclevel})) {          if (defined($$courseopt{$seclevel})) {
     $outpar[6]=$courseopt{$seclevel};      $outpar[6]=$$courseopt{$seclevel};
     $result=6;      $result=6;
  }   }
         if (defined($courseopt{$seclevelm})) {          if (defined($$courseopt{$seclevelm})) {
     $outpar[5]=$courseopt{$seclevelm};      $outpar[5]=$$courseopt{$seclevelm};
     $result=5;      $result=5;
  }   }
   
         if (defined($courseopt{$seclevelr})) {          if (defined($$courseopt{$seclevelr})) {
     $outpar[4]=$courseopt{$seclevelr};      $outpar[4]=$$courseopt
   {$seclevelr};
     $result=4;      $result=4;
  }   }
     }      }
Line 172  sub parmval { Line 189  sub parmval {
 # ---------------------------------------------------------- fifth, check user  # ---------------------------------------------------------- fifth, check user
   
     if (defined($uname)) {      if (defined($uname)) {
  if (defined($useropt{$courselevel})) {   if (defined($$useropt{$courselevel})) {
     $outpar[3]=$useropt{$courselevel};      $outpar[3]=$$useropt{$courselevel};
     $result=3;      $result=3;
  }   }
   
  if (defined($useropt{$courselevelm})) {   if (defined($$useropt{$courselevelm})) {
     $outpar[2]=$useropt{$courselevelm};      $outpar[2]=$$useropt{$courselevelm};
     $result=2;      $result=2;
  }   }
   
  if (defined($useropt{$courselevelr})) {   if (defined($$useropt{$courselevelr})) {
     $outpar[1]=$useropt{$courselevelr};      $outpar[1]=$$useropt{$courselevelr};
     $result=1;      $result=1;
  }   }
     }      }
     return ($result,@outpar);      return ($result,@outpar);
 }  }
   
   sub resetparmhash {
       $parmhashid='';
   }
   
   sub cacheparmhash {
       if ($parmhashid eq  $env{'request.course.fn'}) { return; }
       my %parmhashfile;
       if (tie(%parmhashfile,'GDBM_File',
         $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) {
    %parmhash=%parmhashfile;
    untie %parmhashfile;
    $parmhashid=$env{'request.course.fn'};
       }
   }
   
 ##################################################  ##################################################
 ##################################################  ##################################################
Line 262  sub storeparm_by_symb { Line 293  sub storeparm_by_symb {
     if ($snum>3) {      if ($snum>3) {
 # ---------------------------------------------------------------- Store Course  # ---------------------------------------------------------------- Store Course
 #  #
    my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
    my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
 # Expire sheets  # Expire sheets
  &Apache::lonnet::expirespread('','','studentcalc');   &Apache::lonnet::expirespread('','','studentcalc');
  if (($snum==7) || ($snum==4)) {   if (($snum==7) || ($snum==4)) {
Line 274  sub storeparm_by_symb { Line 307  sub storeparm_by_symb {
 # Store parameter  # Store parameter
  if ($delete) {   if ($delete) {
     $reply=&Apache::lonnet::del      $reply=&Apache::lonnet::del
  ('resourcedata',[keys(%storecontent)],   ('resourcedata',[keys(%storecontent)],$cdom,$cnum);
  $env{'course.'.$env{'request.course.id'}.'.domain'},  
  $env{'course.'.$env{'request.course.id'}.'.num'});  
  } else {   } else {
     $reply=&Apache::lonnet::cput      $reply=&Apache::lonnet::cput
  ('resourcedata',\%storecontent,   ('resourcedata',\%storecontent,$cdom,$cnum);
  $env{'course.'.$env{'request.course.id'}.'.domain'},  
  $env{'course.'.$env{'request.course.id'}.'.num'});  
  }   }
    &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
     } else {      } else {
 # ------------------------------------------------------------------ Store User  # ------------------------------------------------------------------ Store User
 #  #
Line 825  sub assessparms { Line 855  sub assessparms {
     my %allparts;      my %allparts;
   
     my %defp;      my %defp;
     %courseopt=();  
     %useropt=();  
   
     @ids=();      @ids=();
     %symbp=();      %symbp=();
Line 928  sub assessparms { Line 956  sub assessparms {
     my $fcat=$env{'form.fcat'};      my $fcat=$env{'form.fcat'};
     unless ($fcat) { $fcat=''; }      unless ($fcat) { $fcat=''; }
   
 # ------------------------------------------------------------------- Tie hashs  
   
     if (!(tie(%parmhash,'GDBM_File',  
       $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640))) {  
  $r->print("Unable to access parameter data. (File $env{'request.course.fn'}_parms.db not tieable)");  
  return ;  
     }  
   
 # --------------------------------------------------------- Get all assessments  # --------------------------------------------------------- Get all assessments
     &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris);      &extractResourceInformation(\@ids, \%typep,\%keyp, \%allparms, \%allparts, \%allkeys, \%allmaps, $fcat, \%defp, \%mapp, \%symbp,\%maptitles,\%uris);
   
Line 951  sub assessparms { Line 971  sub assessparms {
 # ---------------------------------------------------------------- Done storing  # ---------------------------------------------------------------- Done storing
  $message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';   $message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
     }      }
 # --------------------------------------------- Devalidate cache for this child  
     &Apache::lonnet::devalidatecourseresdata(  
                  $env{'course.'.$env{'request.course.id'}.'.num'},  
                  $env{'course.'.$env{'request.course.id'}.'.domain'});  
     #&Apache::lonnet::clear_EXT_cache_status();  
 # -------------------------------------------------------------- Get coursedata  
     %courseopt = &Apache::lonnet::dump  
         ('resourcedata',  
          $env{'course.'.$env{'request.course.id'}.'.domain'},  
          $env{'course.'.$env{'request.course.id'}.'.num'});  
 # --------------------------------------------------- Get userdata (if present)  
     if ($uname) {  
         %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);  
     }  
   
 # ------------------------------------------------------------------- Sort this  # ------------------------------------------------------------------- Sort this
   
     @ids=sort  {      @ids=sort  {
Line 990  sub assessparms { Line 995  sub assessparms {
     $trimheader = 'yes';      $trimheader = 'yes';
     &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);      &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);
   
     if (!$have_assesments) {  
  untie(%parmhash);  
  return '';  
     }  
 #    if ($env{'form.url'}) {  #    if ($env{'form.url'}) {
 # $r->print('<input type="hidden" value="'.$env{'form.url'}.  # $r->print('<input type="hidden" value="'.$env{'form.url'}.
 #  '" name="url"><input type="hidden" name="command" value="set">');  #  '" name="url"><input type="hidden" name="command" value="set">');
Line 1503  ENDMAPONE Line 1504  ENDMAPONE
         } # end of $parmlev eq general          } # end of $parmlev eq general
     }      }
     $r->print('</form></body></html>');      $r->print('</form></body></html>');
     untie(%parmhash);  
 } # end sub assessparms  } # end sub assessparms
   
   
Line 2186  sub handler { Line 2186  sub handler {
   
 # ----------------------------------------------------------- Clear out garbage  # ----------------------------------------------------------- Clear out garbage
   
     %courseopt=();  
     %useropt=();  
     %parmhash=();  
   
     @ids=();      @ids=();
     %symbp=();      %symbp=();

Removed from v.1.197  
changed lines
  Added in v.1.200


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>