Diff for /loncom/interface/lonparmset.pm between versions 1.522.2.7 and 1.522.2.16

version 1.522.2.7, 2013/06/27 18:22:41 version 1.522.2.16, 2014/06/13 02:00:30
Line 46  This module sets coursewide and assessme Line 46  This module sets coursewide and assessme
   
 =over  =over
   
 =pod  
   
 =item parmval()  =item parmval()
   
 Figure out a cascading parameter.  Figure out a cascading parameter.
Line 139  javascript function 'pjump'. Line 137  javascript function 'pjump'.
   
  extractResourceInformation extracts lots of information about all of the the course's resources into a variety of hashes.   extractResourceInformation extracts lots of information about all of the the course's resources into a variety of hashes.
   
 Input: See list below:  Input: See list below
   
   =over 4
   
 =item * B<env{'user.name'}> : Current username  =item * B<env{'user.name'}> : Current username
   
 =item * B<env{'user.domain'}> : Domain of current user.  =item * B<env{'user.domain'}> : Domain of current user.
   
 =item * b<env{"request.course.fn"} : Course  =item * B<env{"request.course.fn"}> : Course
   
   =back
   
   Outputs: See list below
   
 Outputs: See list below:  =over 4
   
 =item * B<ids> (out) : An array that will contain all of the ids in the course.  =item * B<ids> (out) : An array that will contain all of the ids in the course.
   
Line 173  Outputs: See list below: Line 177  Outputs: See list below:
   
 =item * B<defkeytype>  =item * B<defkeytype>
   
   =back
   
 =item isdateparm()  =item isdateparm()
   
 =item parmmenu()  =item parmmenu()
Line 210  Returns: nothing Line 216  Returns: nothing
   
 Variables used (guessed by Jeremy):  Variables used (guessed by Jeremy):
   
   =over
   
 =item * B<pscat>: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type.  =item * B<pscat>: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type.
   
 =item * B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?  =item * B<psprt>: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts?
Line 222  Variables used (guessed by Jeremy): Line 230  Variables used (guessed by Jeremy):
         When storing information, store as part 0          When storing information, store as part 0
         When requesting information, request from full part          When requesting information, request from full part
   
   =back
   
 =item tablestart()  =item tablestart()
   
 =item tableend()  =item tableend()
Line 288  Set portfolio metadata Line 298  Set portfolio metadata
   
 Main handler.  Calls &assessparms subroutine.  Main handler.  Calls &assessparms subroutine.
   
   
 =back  =back
   
 =cut  =cut
Line 751  sub valout { Line 760  sub valout {
             $result =              $result =
                 '<img src="/res/adm/pages/editmap.png"'                  '<img src="/res/adm/pages/editmap.png"'
                .' alt="'.&mt('Change').'"'                 .' alt="'.&mt('Change').'"'
                .' title="'.&mt('Change').'" />';                 .' title="'.&mt('Change').'" style="border:0;" />';
         } else {          } else {
             $result='&nbsp;';              $result='&nbsp;';
         }          }
Line 1373  sub lookUpTableParameter { Line 1382  sub lookUpTableParameter {
         'contentopen' => 'time_settings',          'contentopen' => 'time_settings',
         'contentclose' => 'time_settings',          'contentclose' => 'time_settings',
         'discussend' => 'time_settings',          'discussend' => 'time_settings',
  'printopendate' => 'time_settings',   'printstartdate' => 'time_settings',
  'printclosedate' => 'time_settings',   'printenddate' => 'time_settings',
         'weight' => 'grading',          'weight' => 'grading',
         'handgrade' => 'grading',          'handgrade' => 'grading',
         'maxtries' => 'tries',          'maxtries' => 'tries',
Line 1486  sub parmboxes { Line 1495  sub parmboxes {
   
     #Print parameters      #Print parameters
     for my $key (sort { $category_order{$a} <=> $category_order{$b} } keys %categoryList) {      for my $key (sort { $category_order{$a} <=> $category_order{$b} } keys %categoryList) {
         if(@{$categoryList{$key}} == 0) {          next if(@{$categoryList{$key}} == 0);
             next;          $r->print('<div class="LC_Box LC_400Box">'
         } else {                     .'<h4 class="LC_hcell">'
             $r->print('<div class="LC_Box LC_400Box">'                    .&mt($categories{$key})
                      .'<h4 class="LC_hcell">'                    .'</h4>'."\n");
                      .&mt($categories{$key})          foreach $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) {
                      .'</h4>'."\n");              $r->print('<span class="LC_nobreak">'
             foreach $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) {                       .'<label><input type="checkbox" name="pscat" '
                     $r->print('<span class="LC_nobreak">'                       .'value="'.$tempkey.'" ');
                              .'<label><input type="checkbox" name="pscat" ');              if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {
                 $r->print('value="'.$tempkey.'" ');                  $r->print(' checked="checked"');
                 if ($$pscat[0] eq "all" || grep $_ eq $tempkey, @{$pscat}) {  
                     $r->print(' checked="checked"');  
                 }  
                 $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey}  
                                                       : $tempkey)  
                         .'</label></span><br />'."\n");  
             }              }
             $r->print("</div>\n");              $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey}
                                                         : $tempkey)
                        .'</label></span><br />'."\n");
         }          }
           $r->print("</div>\n");
     }      }
   
     $r->print("</div>\n");      $r->print("</div>\n");
Line 1673  function group_or_section(caller) { Line 1679  function group_or_section(caller) {
 # This function shows on table Mode the available Parameters for the selected Resources  # This function shows on table Mode the available Parameters for the selected Resources
 #  #
 sub displaymenu {  sub displaymenu {
     my ($r,$allparms,$pscat,$psprt,$keyorder)=@_;      my ($r,$allparms,$pscat,$psprt,$keyorder,$divid)=@_;
   
     $r->print(&Apache::lonhtmlcommon::start_pick_box());      $r->print(&Apache::lonhtmlcommon::start_pick_box());
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View')));      $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View')));
   
     &parmmenu($r,$allparms,$pscat,$keyorder);      &parmmenu($r,$allparms,$pscat,$keyorder);
     $r->print(&Apache::loncommon::start_scrollbox());      $r->print(&Apache::loncommon::start_scrollbox('480px','440px','200px',$divid));
     &parmboxes($r,$allparms,$pscat,$keyorder);      &parmboxes($r,$allparms,$pscat,$keyorder);
     $r->print(&Apache::loncommon::end_scrollbox());      $r->print(&Apache::loncommon::end_scrollbox());
   
Line 1753  sub mapmenu { Line 1759  sub mapmenu {
            .'</div>'             .'</div>'
         );          );
   
         $r->print(&Apache::loncommon::start_scrollbox(undef,undef,undef,'mapmenuscroll'));          $r->print(&Apache::loncommon::start_scrollbox('700px','680px','400px','mapmenuscroll'));
         $r->print(&Apache::loncommon::start_data_table(undef,'mapmenuinner'));          $r->print(&Apache::loncommon::start_data_table(undef,'mapmenuinner'));
   
         # Display row: "All Maps or Folders"          # Display row: "All Maps or Folders"
Line 1964  sub standardkeyorder { Line 1970  sub standardkeyorder {
         'parameter_0_discussend' => 19,          'parameter_0_discussend' => 19,
         'parameter_0_discusshide' => 20,          'parameter_0_discusshide' => 20,
         'parameter_0_discussvote' => 21,          'parameter_0_discussvote' => 21,
  'parameter_0_printopendate'  =>  22,   'parameter_0_printstartdate'  =>  22,
  'parameter_0_printclosedate' =>  23);   'parameter_0_printenddate' =>  23);
 }  }
   
   
Line 2132  sub assessparms { Line 2138  sub assessparms {
         my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};          my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
         my ($got_chostname,$chostname,$cmajor,$cminor);          my ($got_chostname,$chostname,$cmajor,$cminor);
         my $totalstored = 0;          my $totalstored = 0;
           my $now = time;
   
         for (my $i=0;$i<=$#markers;$i++) {          for (my $i=0;$i<=$#markers;$i++) {
             my ($needsrelease,$needsnewer,$name);              my ($needsrelease,$needsnewer,$name);
Line 2166  sub assessparms { Line 2172  sub assessparms {
                         }                          }
                     }                      }
                 }                  }
             } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote|examcode)\&\d+$/) {              } elsif ($markers[$i] =~ /_(type|lenient|retrypartial|discussvote|examcode|printstartdate|printenddate)\&\d+$/) {
                 $name = $1;                  $name = $1;
                 my $val = $values[$i];                  my $val = $values[$i];
                 if ($name eq 'examcode') {                  if ($name eq 'examcode') {
                    if (&Apache::lonnet::validCODE($values[$i])) {                      if (&Apache::lonnet::validCODE($values[$i])) {
                        $val = 'valid';                          $val = 'valid';
                    }                      }
                   } elsif ($name eq 'printstartdate') {
                       if ($val =~ /^\d+$/) {
                           if ($val > $now) {
                               $val = 'future';
                           }
                       }
                   } elsif ($name eq 'printenddate') {
                       if ($val =~ /^\d+$/) {
                           if ($val < $now) {
                               $val = 'past';
                           }
                       }
                 }                  }
                 $needsrelease =                  $needsrelease =
                     $Apache::lonnet::needsrelease{"parameter:$name:$val"};                      $Apache::lonnet::needsrelease{"parameter:$name:$val"};
Line 2183  sub assessparms { Line 2201  sub assessparms {
                     }                      }
                     $needsnewer = &parameter_releasecheck($name,$val,                      $needsnewer = &parameter_releasecheck($name,$val,
                                                           $needsrelease,                                                            $needsrelease,
                                                           $chostname,  
                                                           $cmajor,$cminor);                                                            $cmajor,$cminor);
                 }                  }
             }              }
Line 2264  ENDPARMSELSCRIPT Line 2281  ENDPARMSELSCRIPT
   
         # Step 2          # Step 2
         $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));          $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));
         &displaymenu($r,\%allparms,\@pscat,\@psprt,\%keyorder);          &displaymenu($r,\%allparms,\@pscat,\@psprt,\%keyorder,'parmmenuscroll');
   
         # Step 3          # Step 3
         $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));          $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
Line 2808  sub storedata { Line 2825  sub storedata {
     my @deldata=();      my @deldata=();
     undef @deldata;      undef @deldata;
     my ($got_chostname,$chostname,$cmajor,$cminor);      my ($got_chostname,$chostname,$cmajor,$cminor);
       my $now = time;
     foreach my $key (keys(%env)) {       foreach my $key (keys(%env)) { 
     if ($key =~ /^form\.([a-z]+)\_(.+)$/) {      if ($key =~ /^form\.([a-z]+)\_(.+)$/) {
         my $cmd=$1;          my $cmd=$1;
Line 2818  sub storedata { Line 2836  sub storedata {
         $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;          $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
         }          }
         if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {          if ($cmd eq 'set' || $cmd eq 'datepointer' || $cmd eq 'dateinterval') {
         my ($data, $typeof, $text, $name);          my ($data, $typeof, $text, $name, $valchk);
         if ($cmd eq 'set') {          if ($cmd eq 'set') {
             $data=$env{$key};              $data=$env{$key};
               $valchk = $data;
             $typeof=$env{'form.typeof_'.$thiskey};              $typeof=$env{'form.typeof_'.$thiskey};
             $text = &mt('Saved modified parameter for');              $text = &mt('Saved modified parameter for');
             if ($typeof eq 'string_questiontype') {              if ($typeof eq 'string_questiontype') {
Line 2831  sub storedata { Line 2850  sub storedata {
                 $name = 'discussvote';                  $name = 'discussvote';
             } elsif ($typeof eq 'string_examcode') {              } elsif ($typeof eq 'string_examcode') {
                 $name = 'examcode';                  $name = 'examcode';
                   if (&Apache::lonnet::validCODE($data)) {
                       $valchk = 'valid';
                   }
             } elsif ($typeof eq 'string_yesno') {              } elsif ($typeof eq 'string_yesno') {
                 if ($thiskey =~ /\.retrypartial$/) {                  if ($thiskey =~ /\.retrypartial$/) {
                     $name = 'retrypartial';                      $name = 'retrypartial';
                 }                  }
             }              }
             if ($name ne '') {          } elsif ($cmd eq 'datepointer') {
                 my ($needsrelease,$needsnewer);              $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});
                 $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$data"};              $typeof=$env{'form.typeof_'.$thiskey};
                 if ($needsrelease) {              $text = &mt('Saved modified date for');
                     unless ($got_chostname) {              if ($typeof eq 'date_start') {
                         ($chostname,$cmajor,$cminor)=&parameter_release_vars();                  if ($thiskey =~ /\.printstartdate$/) {
                         $got_chostname = 1;                      $name = 'printstartdate';
                       if (($data) && ($data > $now)) {
                           $valchk = 'future';
                     }                      }
                     $needsnewer = &parameter_releasecheck($name,$data,  
                                                           $needsrelease,  
                                                           $chostname,$cmajor,  
                                                           $cminor);  
                 }                  }
               } elsif ($typeof eq 'date_end') {
                   if ($thiskey =~ /\.printenddate$/) {
                       $name = 'printenddate';
                       if (($data) && ($data < $now)) {
                           $valchk = 'past';
                       }
                   }
               }
           } elsif ($cmd eq 'dateinterval') {
               $data=&get_date_interval_from_form($thiskey);
               $typeof=$env{'form.typeof_'.$thiskey};
               $text = &mt('Saved modified date for');
           }
           if ($name ne '') {
               my ($needsrelease,$needsnewer);
               $needsrelease = $Apache::lonnet::needsrelease{"parameter:$name:$valchk"};
               if ($needsrelease) {
                   unless ($got_chostname) {
                       ($chostname,$cmajor,$cminor)=&parameter_release_vars();
                       $got_chostname = 1;
                   }
                   $needsnewer = &parameter_releasecheck($name,$valchk,
                                                         $needsrelease,
                                                         $cmajor,$cminor);
                 if ($needsnewer) {                  if ($needsnewer) {
                     $r->print('<br />'.&oldversion_warning($name,$data,                      $r->print('<br />'.&oldversion_warning($name,$data,
                                                            $chostname,$cmajor,                                                             $chostname,$cmajor,
Line 2856  sub storedata { Line 2900  sub storedata {
                     next;                      next;
                 }                  }
             }              }
         } elsif ($cmd eq 'datepointer') {  
             $data=&Apache::lonhtmlcommon::get_date_from_form($env{$key});  
             $typeof=$env{'form.typeof_'.$thiskey};  
             $text = &mt('Saved modified date for');  
         } elsif ($cmd eq 'dateinterval') {  
             $data=&get_date_interval_from_form($thiskey);  
             $typeof=$env{'form.typeof_'.$thiskey};  
             $text = &mt('Saved modified date for');  
         }          }
         if (defined($data) and $$olddata{$thiskey} ne $data) {          if (defined($data) and $$olddata{$thiskey} ne $data) {
             if ($tuname) {              if ($tuname) {
Line 3201  sub string_selector { Line 3237  sub string_selector {
                     $got_chostname = 1;                      $got_chostname = 1;
                 }                  }
                 my $needsnewer=&parameter_releasecheck($name,$parmval,$needsrelease,                  my $needsnewer=&parameter_releasecheck($name,$parmval,$needsrelease,
                                                        $chostname,$cmajor,                                                         $cmajor,$cminor);
                                                        $cminor);  
                 if ($needsnewer) {                  if ($needsnewer) {
                     $skiptype{$parmval} = 1;                      $skiptype{$parmval} = 1;
                 }                  }
Line 3613  sub date_shift_one { Line 3648  sub date_shift_one {
     my $start_page=&Apache::loncommon::start_page('Shift Dates');      my $start_page=&Apache::loncommon::start_page('Shift Dates');
     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');      my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
     $r->print($start_page.$breadcrumbs);      $r->print($start_page.$breadcrumbs);
     $r->print('<form name="shiftform" method="post">'.      $r->print('<form name="shiftform" method="post" action="">'.
               '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.                '<table><tr><td>'.&mt('Currently set date:').'</td><td>'.
               &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.                &Apache::lonlocal::locallocaltime($env{'form.timebase'}).'</td></tr>'.
               '<tr><td>'.&mt('Shifted date:').'</td><td>'.                '<tr><td>'.&mt('Shifted date:').'</td><td>'.
                     &Apache::lonhtmlcommon::dshowerfuck.net                      &Apache::lonhtmlcommon::date_setter('shiftform',
 ate_setter('shiftform',  
                                                         'timeshifted',                                                          'timeshifted',
                                                         $env{'form.timebase'},,                                                          $env{'form.timebase'},,
                                                         '').                                                          '').
Line 3639  sub date_shift_two { Line 3673  sub date_shift_two {
     my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');      my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Shift');
     $r->print($start_page.$breadcrumbs);      $r->print($start_page.$breadcrumbs);
     my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');      my $timeshifted=&Apache::lonhtmlcommon::get_date_from_form('timeshifted');
     $r->print(&mt('Shifting all dates such that [_1] becomes [_2]',      $r->print('<h2>'.&mt('Shift Dates').'</h2>'.
                 '<p>'.&mt('Shifting all dates such that [_1] becomes [_2]',
               &Apache::lonlocal::locallocaltime($env{'form.timebase'}),                &Apache::lonlocal::locallocaltime($env{'form.timebase'}),
               &Apache::lonlocal::locallocaltime($timeshifted)));                &Apache::lonlocal::locallocaltime($timeshifted)).'</p>');
     my $delta=$timeshifted-$env{'form.timebase'};      my $delta=$timeshifted-$env{'form.timebase'};
     &dateshift($delta);      &dateshift($delta);
       $r->print(
           &Apache::lonhtmlcommon::confirm_success(&mt('Done')).
           '<br /><br />'.
           &Apache::lonhtmlcommon::actionbox(
               ['<a href="/adm/parmset">'.&mt('Content and Problem Settings').'</a>']));
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
 }  }
   
Line 3783  ENDMAINFORMHEAD Line 3823  ENDMAINFORMHEAD
             }]}              }]}
           );            );
     $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));      $r->print(&Apache::lonhtmlcommon::generate_menu(@menu));
       $r->print('</form>'.&Apache::loncommon::end_page());
     return;      return;
 }  }
   
Line 3911  sub order_meta_fields { Line 3952  sub order_meta_fields {
     foreach my $key (@fields_in_order) {      foreach my $key (@fields_in_order) {
         $r->print('<tr><td>');          $r->print('<tr><td>');
         $r->print('<form method="post" action="">');          $r->print('<form method="post" action="">');
         $r->print('<select name="newpos" onChange="this.form.submit()">');          $r->print('<select name="newpos" onchange="this.form.submit()">');
         for (my $i = 1;$i le $num_fields;$i ++) {          for (my $i = 1;$i le $num_fields;$i ++) {
             if ($i eq $idx) {              if ($i eq $idx) {
                 $r->print('<option value="'.$i.'"  SELECTED>('.$i.')</option>');                  $r->print('<option value="'.$i.'"  SELECTED>('.$i.')</option>');
Line 4635  sub parameter_release_vars { Line 4676  sub parameter_release_vars {
 }  }
   
 sub parameter_releasecheck {  sub parameter_releasecheck {
     my ($name,$value,$needsrelease,$chostname,$cmajor,$cminor) = @_;      my ($name,$value,$needsrelease,$cmajor,$cminor) = @_;
     my $needsnewer;      my $needsnewer;
     my ($needsmajor,$needsminor) = split(/\./,$needsrelease);      my ($needsmajor,$needsminor) = split(/\./,$needsrelease);
     if (($cmajor < $needsmajor) ||       if (($cmajor < $needsmajor) || 
Line 4670  sub oldversion_warning { Line 4711  sub oldversion_warning {
                 }                  }
             }              }
         }          }
       } elsif (($name eq 'printstartdate') || ($name eq 'printenddate')) {
           my $now = time;
           if ($value =~ /^\d+$/) {
               if ($name eq 'printstartdate') {
                   if ($value > $now) {
                       $desc = &Apache::lonlocal::locallocaltime($value);
                   }
               } elsif ($name eq 'printenddate') {
                   if ($value < $now) {
                       $desc = &Apache::lonlocal::locallocaltime($value);
                   }
               }
           }
     }      }
     my $standard_name = &standard_parameter_names($name);      my $standard_name = &standard_parameter_names($name);
     return '<p class="LC_warning">'.      return '<p class="LC_warning">'.

Removed from v.1.522.2.7  
changed lines
  Added in v.1.522.2.16


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.