Diff for /loncom/interface/lonparmset.pm between versions 1.199 and 1.202

version 1.199, 2005/06/02 13:34:14 version 1.202, 2005/06/02 22:03:18
Line 66  use Apache::lonnavmaps; Line 66  use Apache::lonnavmaps;
   
 # --- Caches local to lonparmset  # --- Caches local to lonparmset
   
 my $courseoptid;  
 my %courseopt;  
 my $useroptid;  
 my %useropt;  
 my $parmhashid;  my $parmhashid;
 my %parmhash;  my %parmhash;
   my $symbsid;
   my %symbs;
   
 # --- end local caches  # --- end local caches
   
 #  
 # FIXME: get rid of items below  
 #  
 my @ids;  
 my %symbp;  
 my %mapp;  
 my %typep;  
 my %keyp;  
 my %uris;  
 my %maptitles;  
   
 ##################################################  ##################################################
 ##################################################  ##################################################
   
Line 116  Returns:  A list, the first item is the Line 103  Returns:  A list, the first item is the
 =cut  =cut
   
 ##################################################  ##################################################
 ##################################################  
 sub parmval {  sub parmval {
     my ($what,$id,$def,$uname,$udom,$csec)=@_;      my ($what,$id,$def,$uname,$udom,$csec)=@_;
       return &parmval_by_symb($what,&symbcache($id),$def,$uname,$udom,$csec);
   }
   
   sub parmval_by_symb {
       my ($what,$symb,$def,$uname,$udom,$csec)=@_;
 # load caches  # load caches
   
     &cacheparmhash();      &cacheparmhash();
     &cacheuseropt($uname,$udom);  
     &cachecourseopt();      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
       my $map=(&Apache::lonnet::decode_symb($symb))[0];    
   
     my $symbparm=$symbp{$id}.'.'.$what;      my $symbparm=$symb.'.'.$what;
     my $mapparm=$mapp{$id}.'___(all).'.$what;      my $mapparm=$map.'___(all).'.$what;
   
     my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;      my $seclevel=$env{'request.course.id'}.'.['.$csec.'].'.$what;
     my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;      my $seclevelr=$env{'request.course.id'}.'.['.$csec.'].'.$symbparm;
Line 143  sub parmval { Line 140  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 162  sub parmval { Line 159  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 187  sub parmval { Line 184  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;
  }   }
     }      }
Line 220  sub cacheparmhash { Line 217  sub cacheparmhash {
     }      }
 }  }
   
 sub resetuseropt {  sub symbcache {
     $useroptid='';      my $id=shift;
 }      if ($symbsid ne $env{'request.course.id'}) {
    %symbs=();
 sub cacheuseropt {      }
     my ($uname,$udom)=@_;      unless ($symbs{$id}) {
     unless ($uname) { return; }   my $navmap = Apache::lonnavmaps::navmap->new();
     if ($useroptid eq $uname.'@'.$udom) { return; }   if ($id=~/\./) {
     %useropt=&Apache::lonnet::dump('resourcedata',$udom,$uname);      my $resource=$navmap->getById($id);
     $useroptid=$uname.'@'.$udom;      $symbs{$id}=$resource->symb();
 }   } else {
       my $resource=$navmap->getByMapPc($id);
 sub resetcourseopt {      $symbs{$id}=&Apache::lonnet::declutter($resource->src());
     $courseoptid='';   }
 }   $symbsid=$env{'request.course.id'};
       }
 sub cachecourseopt {      return $symbs{$id};
     if ($courseoptid eq $env{'request.course.id'}) { return; };  
     %courseopt = &Apache::lonnet::dump  
         ('resourcedata',  
          $env{'course.'.$env{'request.course.id'}.'.domain'},  
          $env{'course.'.$env{'request.course.id'}.'.num'});  
     $courseoptid=$env{'request.course.id'};  
 }  }
   
 ##################################################  ##################################################
Line 261  sub cachecourseopt { Line 252  sub cachecourseopt {
   
 sub storeparm {  sub storeparm {
     my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;      my ($sresid,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec)=@_;
     my $navmap = Apache::lonnavmaps::navmap->new();      &storeparm_by_symb(&symbcache($sresid),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);
     if ($sresid=~/\./) {  
  my $resource=$navmap->getById($sresid);  
  &storeparm_by_symb($resource->symb(),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);  
     } else {  
         my $resource=$navmap->getByMapPc($sresid);  
  &storeparm_by_symb(&Apache::lonnet::declutter($resource->src()),$spnam,$snum,$nval,$ntype,$uname,$udom,$csec);  
     }  
 }  }
   
 #  #
Line 316  sub storeparm_by_symb { Line 300  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 325  sub storeparm_by_symb { Line 311  sub storeparm_by_symb {
  } else {   } else {
     &Apache::lonnet::expirespread('','','assesscalc');      &Apache::lonnet::expirespread('','','assesscalc');
  }   }
  &resetcourseopt();  
 # 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 352  sub storeparm_by_symb { Line 334  sub storeparm_by_symb {
  } else {   } else {
     &Apache::lonnet::expirespread($uname,$udom,'assesscalc');      &Apache::lonnet::expirespread($uname,$udom,'assesscalc');
  }   }
  &resetuseropt();  
 # Store parameter  # Store parameter
  if ($delete) {   if ($delete) {
     $reply=&Apache::lonnet::del      $reply=&Apache::lonnet::del
Line 461  sub plink { Line 442  sub plink {
  &valout($value,$type).'</a><a name="'.$marker.'"></a>';   &valout($value,$type).'</a><a name="'.$marker.'"></a>';
 }  }
   
   
 sub startpage {  sub startpage {
     my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_;      my ($r,$id,$udom,$csec,$uname,$have_assessments)=@_;
   
     my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',      my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','',
                                             'onUnload="pclose()"');                                              'onUnload="pclose()"');
Line 473  sub startpage { Line 453  sub startpage {
     my $selscript=&Apache::loncommon::studentbrowser_javascript();      my $selscript=&Apache::loncommon::studentbrowser_javascript();
     my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();      my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
     my %lt=&Apache::lonlocal::texthash(      my %lt=&Apache::lonlocal::texthash(
     'cep'   => "Course Environment Parameters",  
     'scep'  => "Set Course Environment Parameters",  
     'smcap' => "Set/Modify Course Assessment Parameter",  
     'mcap'  => "Modify Course Assessment Parameters",  
     'caphm' => "Course Assessment Parameter - Helper Mode",  
     'capom' => "Course Assessment Parameters - Overview Mode",  
                     'captm' => "Course Assessments Parameters - Table Mode",                      'captm' => "Course Assessments Parameters - Table Mode",
     'sg'    => "Section/Group",      'sg'    => "Section/Group",
     'fu'    => "For User",      'fu'    => "For User",
Line 540  $bodytag Line 514  $bodytag
 $breadcrumbs  $breadcrumbs
 $overallhelp  $overallhelp
 ENDHEAD  ENDHEAD
   
     unless ($trimheader) {$r->print(<<ENDHEAD2);  
 <form method="post" action="/adm/parmset" name="envform">  
 <h4>$lt{'cep'}</h4>  
 <input type="submit" name="crsenv" value="$lt{'scep'}" />  
 </form>  
 <hr />  
 $assessparmhelp  
 <form method="post" action="/adm/helper/parameter.helper" name="helpform">  
 <h4>$lt{'caphm'}</h4>  
 <input type="submit" value="$lt{'smcap'}" />  
 </form>  
 <hr />  
 <form method="post" action="/adm/parmset" name="overview">  
 <h4>$lt{'capom'}</h4>  
 <input type="submit" name="overview" value="$lt{'mcap'}" />  
 </form>  
 <hr />  
 ENDHEAD2  
     }  
     my %sectionhash=();      my %sectionhash=();
     my $sections='';      my $sections='';
     if (&Apache::loncommon::get_sections(      if (&Apache::loncommon::get_sections(
Line 578  ENDHEAD2 Line 532  ENDHEAD2
 <h4>$lt{'captm'}</h4>  <h4>$lt{'captm'}</h4>
 ENDHEAD3  ENDHEAD3
   
     if (!$have_assesments) {      if (!$have_assessments) {
  $r->print('<font color="red">'.&mt('There are no assesment parameters in this course to set.').'</font><br />');   $r->print('<font color="red">'.&mt('There are no assessment parameters in this course to set.').'</font><br />');
     } else {      } else {
  $r->print(<<ENDHEAD);   $r->print(<<ENDHEAD);
 <b>  <b>
Line 600  ENDHEAD Line 554  ENDHEAD
 }  }
   
 sub print_row {  sub print_row {
     my ($r,$which,$part,$name,$rid,$default,$defaulttype,$display,$defbgone,      my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone,
  $defbgtwo,$parmlev,$uname,$udom,$csec)=@_;   $defbgtwo,$parmlev,$uname,$udom,$csec)=@_;
 # get the values for the parameter in cascading order  # get the values for the parameter in cascading order
 # empty levels will remain empty  # empty levels will remain empty
Line 692  sub print_row { Line 646  sub print_row {
   
     if ($parmlev eq 'full' || $parmlev eq 'brief') {      if ($parmlev eq 'full' || $parmlev eq 'brief') {
         my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.          my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
                                         '.'.$$name{$which},$symbp{$rid});                                          '.'.$$name{$which},$$symbp{$rid});
   
 # this doesn't seem to work, and I don't think is correct  # this doesn't seem to work, and I don't think is correct
 #    my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}.  #    my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}.
Line 722  sub print_td { Line 676  sub print_td {
     $r->print('</td>'."\n");      $r->print('</td>'."\n");
 }  }
   
   
 =pod  =pod
   
 =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.  =item B<extractResourceInformation>: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes.
Line 861  Variables used (guessed by Jeremy): Line 816  Variables used (guessed by Jeremy):
 sub assessparms {  sub assessparms {
   
     my $r=shift;      my $r=shift;
   
       my @ids=();
       my %symbp=();
       my %mapp=();
       my %typep=();
       my %keyp=();
       my %uris=();
       my %maptitles=();
   
 # -------------------------------------------------------- Variable declaration  # -------------------------------------------------------- Variable declaration
     my %allkeys=();      my %allkeys=();
     my %allmaps=();      my %allmaps=();
Line 905  sub assessparms { Line 869  sub assessparms {
   
     my $pssymb='';      my $pssymb='';
     my $parmlev='';      my $parmlev='';
     my $trimheader='';  
     my $prevvisit=$env{'form.prevvisit'};      my $prevvisit=$env{'form.prevvisit'};
     
     unless ($env{'form.parmlev'}) {      unless ($env{'form.parmlev'}) {
Line 924  sub assessparms { Line 887  sub assessparms {
  if (!@pscat) { @pscat=('all'); }   if (!@pscat) { @pscat=('all'); }
  $pschp='';   $pschp='';
         $parmlev = 'full';          $parmlev = 'full';
         $trimheader='yes';  
     } elsif ($env{'form.symb'}) {      } elsif ($env{'form.symb'}) {
  $pssymb=$env{'form.symb'};   $pssymb=$env{'form.symb'};
  if (!@pscat) { @pscat=('all'); }   if (!@pscat) { @pscat=('all'); }
  $pschp='';   $pschp='';
         $parmlev = 'full';          $parmlev = 'full';
         $trimheader='yes';  
     } else {      } else {
  $env{'form.url'}='';   $env{'form.url'}='';
     }      }
Line 997  sub assessparms { Line 958  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();  
   
 # ------------------------------------------------------------------- Sort this  # ------------------------------------------------------------------- Sort this
   
     @ids=sort  {      @ids=sort  {
Line 1021  sub assessparms { Line 976  sub assessparms {
     if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}      if ($psprt[0] eq "all" || !@psprt) {@psprt = (keys %allparts);}
 # ------------------------------------------------------------------ Start page  # ------------------------------------------------------------------ Start page
   
     my $have_assesments=1;      &startpage($r,$id,$udom,$csec,$uname,scalar(keys(%allkeys)));
     if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; }  
   
     $trimheader = 'yes';  
     &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader);  
   
 #    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'}.
Line 1342  ENDTABLEHEADFOUR Line 1293  ENDTABLEHEADFOUR
                                 undef $firstrow;                                  undef $firstrow;
                             }                              }
   
                             &print_row($r,$_,\%part,\%name,$rid,\%default,                              &print_row($r,$_,\%part,\%name,\%symbp,$rid,\%default,
                                        \%type,\%display,$defbgone,$defbgtwo,                                         \%type,\%display,$defbgone,$defbgtwo,
                                        $parmlev,$uname,$udom,$csec);                                         $parmlev,$uname,$udom,$csec);
                         }                          }
Line 1450  ENDMAPONE Line 1401  ENDMAPONE
   
         foreach (sort keys %name) {          foreach (sort keys %name) {
                     $r->print('<tr>');                      $r->print('<tr>');
                     &print_row($r,$_,\%part,\%name,$mapid,\%default,                      &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
                            \%type,\%display,$defbgone,$defbgtwo,                             \%type,\%display,$defbgone,$defbgtwo,
                            $parmlev,$uname,$udom,$csec);                             $parmlev,$uname,$udom,$csec);
 #                    $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");  #                    $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
Line 1528  ENDMAPONE Line 1479  ENDMAPONE
   
     foreach (sort keys %name) {      foreach (sort keys %name) {
                 $r->print('<tr>');                  $r->print('<tr>');
                 &print_row($r,$_,\%part,\%name,$mapid,\%default,                  &print_row($r,$_,\%part,\%name,\%symbp,$mapid,\%default,
                        \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec);                         \%type,\%display,$defbgone,$defbgtwo,$parmlev,$uname,$udom,$csec);
 #                    $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");  #                    $r->print("<tr><td>resource.$part{$_}.$name{$_},$symbp{$mapid}</td></tr>\n");
             }              }
Line 2216  sub handler { Line 2167  sub handler {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
     ['action','state']);      ['action','state']);
   
 # ----------------------------------------------------------- Clear out garbage  
   
   
     @ids=();  
     %symbp=();  
     %mapp=();  
     %typep=();  
     %keyp=();  
   
     %maptitles=();  
   
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",      &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset",

Removed from v.1.199  
changed lines
  Added in v.1.202


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