Diff for /loncom/interface/lonparmset.pm between versions 1.350.2.6 and 1.354

version 1.350.2.6, 2007/01/18 21:14:04 version 1.354, 2006/12/14 20:34:33
Line 3189  ENDMAINFORMHEAD Line 3189  ENDMAINFORMHEAD
 ### Set portfolio metadata  ### Set portfolio metadata
 sub output_row {  sub output_row {
     my ($r, $field_name, $field_text, $added_flag) = @_;      my ($r, $field_name, $field_text, $added_flag) = @_;
     my $row_class;  
     my $output;      my $output;
     my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};      my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'};
     my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};      my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'};
Line 3198  sub output_row { Line 3197  sub output_row {
         $values = '';          $values = '';
     }      }
     if (!($options =~ /deleted/)) {      if (!($options =~ /deleted/)) {
         $output = &Apache::loncommon::start_data_table_row();  
         $output .= '<td><span class="LC_metadata"><strong>'.$field_text.':</strong></span></td>';  
         # $output .= '<td><strong>'.$field_text.':</strong></td>';  
         $output .= '<td><span class="LC_metadata"><input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></span></td>';  
         $output .= &Apache::loncommon::end_data_table_row();  
         my @options= ( ['active', 'Show to student'],          my @options= ( ['active', 'Show to student'],
    ['onlyone','Student may select only one choice'],                      ['stuadd', 'Provide text area for students to type catalog information'],
    ['stuadd', 'Student may type choices']);                      ['choices','Provide choices for students to select from']);
   #   ['onlyone','Student may select only one choice']);
         if ($added_flag) {          if ($added_flag) {
             push @options,['deleted', 'Delete Metadata Field'];              push @options,['deleted', 'Delete Metadata Field'];
         }          }
          $output = &Apache::loncommon::start_data_table_row();
           $output .= '<td><span class="LC_metadata"><strong>'.$field_text.':</strong></span></td>';
           $output .= &Apache::loncommon::end_data_table_row();
         foreach my $opt (@options) {          foreach my $opt (@options) {
     my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;      my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ;
     $output .= &Apache::loncommon::continue_data_table_row();      $output .= &Apache::loncommon::continue_data_table_row();
     $output .= '<td colspan="2">'.('&nbsp;' x 5).'<span class="LC_metadata"><label><input type="checkbox" name="'.      $output .= '<td>'.('&nbsp;' x 5).'<span class="LC_metadata"><label>
         $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.                 <input type="checkbox" name="'.
         &mt($opt->[1]).'</label></span> </td>';                 $field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'.
                  &mt($opt->[1]).'</label></span> </td>';
     $output .= &Apache::loncommon::end_data_table_row();      $output .= &Apache::loncommon::end_data_table_row();
  }   }
           $output .= &Apache::loncommon::continue_data_table_row();
           $output .= '<td>'.('&nbsp;' x 10).'<span class="LC_metadata"><input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /></span></td>';
           $output .= &Apache::loncommon::end_data_table_row();
           my $multiple_checked;
           my $single_checked;
           if ($options =~ m/onlyone/) {
               $multiple_checked = "";
               $single_checked = " CHECKED ";
           } else {
               $multiple_checked = " CHECKED ";
               $single_checked = "";
           }
    $output .= &Apache::loncommon::continue_data_table_row();
    $output .= '<td>'.('&nbsp;' x 10).'<span class="LC_metadata">
               <input type="radio" name="'.$field_name.'_onlyone" value="multiple" '.$multiple_checked .'/>
               Student may select multiple choices from list</span></td>';
    $output .= &Apache::loncommon::end_data_table_row();
    $output .= &Apache::loncommon::continue_data_table_row();
    $output .= '<td>'.('&nbsp;' x 10).'<span class="LC_metadata">
               <input type="radio" name="'.$field_name.'_onlyone"  value="single" '.$single_checked.'/>
               Student may select only one choice from list</span></td>';
    $output .= &Apache::loncommon::end_data_table_row();
     }      }
     return ($output);      return ($output);
 }  }
Line 3303  sub order_meta_fields { Line 3323  sub order_meta_fields {
     $r->print('</table>');      $r->print('</table>');
     return 'ok';      return 'ok';
 }  }
 sub continue {  
     my $output;  
     $output .= '<form action="" method="post">';  
     $output .= '<input type="hidden" name="action" value="setrestrictmeta" />';  
     $output .= '<input type="submit" value="Continue" />';  
     return ($output);  
 }  
 sub addmetafield {  sub addmetafield {
     my ($r)=@_;      my ($r)=@_;
     $r->print(&Apache::loncommon::start_page('Add Metadata Field'));      $r->print(&Apache::loncommon::start_page('Add Metadata Field'));
Line 3317  sub addmetafield { Line 3330  sub addmetafield {
     my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};      my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
     my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};      my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
     if (exists($env{'form.undelete'})) {      if (exists($env{'form.undelete'})) {
         my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield');          my @meta_fields = &Apache::loncommon::get_env_multiple('form.undelete');
         foreach my $meta_field(@meta_fields) {          foreach my $meta_field(@meta_fields) {
             my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};              my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'};
             $options =~ s/deleted//;              $options =~ s/deleted//;
Line 3327  sub addmetafield { Line 3340  sub addmetafield {
                                                                                   
             $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');              $r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />');
         }          }
         $r->print(&continue());          $r->print('<form action="" method="post">');
           $r->print('<input type="hidden" name="action" value="setrestrictmeta" />');
           $r->print('<input type="submit" value="Continue" />');
     } elsif (exists($env{'form.fieldname'})) {      } elsif (exists($env{'form.fieldname'})) {
         my $meta_field = $env{'form.fieldname'};          my $meta_field = $env{'form.fieldname'};
         my $display_field = $env{'form.fieldname'};          my $display_field = $env{'form.fieldname'};
Line 3337  sub addmetafield { Line 3352  sub addmetafield {
                             {'metadata.'.$meta_field.'.values'=>"",                              {'metadata.'.$meta_field.'.values'=>"",
                              'metadata.'.$meta_field.'.added'=>"$display_field",                               'metadata.'.$meta_field.'.added'=>"$display_field",
                              'metadata.'.$meta_field.'.options'=>""},$dom,$crs);                               'metadata.'.$meta_field.'.options'=>""},$dom,$crs);
         $r->print('Added new Metadata Field <strong>'.$env{'form.fieldname'}."</strong> with result ".$put_result.'<br />');          $r->print('Added new Metadata Field '.$env{'form.fieldname'}." with result ".$put_result);
         $r->print(&continue());  
     } else {      } else {
         my $fields = &get_deleted_meta_fieldnames();          my $fields = &get_deleted_meta_fieldnames();
         if ($fields) {          if ($fields) {
             $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');              $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
             $r->print('<form method="post" action="">');              $r->print('<form method="post" action="">');
             foreach my $key(keys(%$fields)) {              foreach my $key(keys(%$fields)) {
                 $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');                  $r->print('<input type="checkbox" name="undelete" value="'.$key.'" />'.$$fields{$key}.'<br /');
             }              }
             $r->print('<input type="submit" name="undelete" value="Undelete" />');              $r->print('<input type="submit" name="undelete" value="Undelete" />');
             $r->print('</form>');              $r->print('</form>');
Line 3379  sub setrestrictmeta { Line 3393  sub setrestrictmeta {
                if ($env{'form.'.$meta_field.'_stuadd'}) {                 if ($env{'form.'.$meta_field.'_stuadd'}) {
                    $options.='stuadd,';                     $options.='stuadd,';
                }                  } 
                if ($env{'form.'.$meta_field.'_onlyone'}) {                 if ($env{'form.'.$meta_field.'_choices'}) {
                      $options.='choices,';
                  } 
                  if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') {
                    $options.='onlyone,';                     $options.='onlyone,';
                }                  } 
                if ($env{'form.'.$meta_field.'_active'}) {                 if ($env{'form.'.$meta_field.'_active'}) {
Line 3388  sub setrestrictmeta { Line 3405  sub setrestrictmeta {
                if ($env{'form.'.$meta_field.'_deleted'}) {                 if ($env{'form.'.$meta_field.'_deleted'}) {
                    $options.='deleted,';                     $options.='deleted,';
                }                 }
                  
                     my $name = $save_field;                      my $name = $save_field;
                      $put_result = &Apache::lonnet::put('environment',                       $put_result = &Apache::lonnet::put('environment',
                                                   {'metadata.'.$meta_field.'.options'=>$options,                                                    {'metadata.'.$meta_field.'.options'=>$options,
Line 3412  sub setrestrictmeta { Line 3428  sub setrestrictmeta {
     $output.= &output_row($r, $field, $metadata_fields{$field});      $output.= &output_row($r, $field, $metadata_fields{$field});
  }   }
     }      }
       my $buttons = (<<ENDButtons);
           <input type="submit" name="restrictmeta" value="Save" />
           </form><br />
           <form method="post" action="/adm/parmset?action=addmetadata" name="form1">
           <input type="submit" name="restrictmeta" value="Add a Metadata Field" />
           </form>
           <br />
           <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">
           <input type="submit" name="restrictmeta" value="Order Metadata Fields" />
   ENDButtons
     my $added_flag = 1;      my $added_flag = 1;
     foreach my $field (sort(keys(%$added_metadata_fields))) {      foreach my $field (sort(keys(%$added_metadata_fields))) {
         $row_alt = $row_alt ? 0 : 1;          $row_alt = $row_alt ? 0 : 1;
Line 3421  sub setrestrictmeta { Line 3447  sub setrestrictmeta {
     $r->print(<<ENDenv);             $r->print(<<ENDenv);       
         <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">          <form method="post" action="/adm/parmset?action=setrestrictmeta" name="form">
         $output          $output
         <input type="submit" name="restrictmeta" value="Update Metadata Restrictions" />          $buttons
         </form><br />  
         <form method="post" action="/adm/parmset?action=addmetadata" name="form1">  
         <input type="submit" name="restrictmeta" value="Add a Metadata Field" />  
         </form>  
         <br />  
         <form method="post" action="/adm/parmset?action=ordermetadata" name="form2">  
         <input type="submit" name="restrictmeta" value="Order Metadata Fields" />  
         </form>          </form>
 ENDenv  ENDenv
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
Line 3734  sub parm_change_log { Line 3753  sub parm_change_log {
  }   }
  if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }   if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
     }      }
     foreach my $id (sort       foreach my $id (sort { $parmlog{$b}{'exe_time'}<=>$parmlog{$a}{'exe_time'} } (keys(%parmlog))) {
     {  
  if ($parmlog{$b}{'exe_time'} ne $parmlog{$a}{'exe_time'}) {  
     return $parmlog{$b}{'exe_time'} <=>$parmlog{$a}{'exe_time'}  
  }  
  my $aid = (split('00000',$a))[-1];  
  my $bid = (split('00000',$b))[-1];  
  return $bid<=>$aid;  
     } (keys(%parmlog))) {  
         my @changes=keys(%{$parmlog{$id}{'logentry'}});          my @changes=keys(%{$parmlog{$id}{'logentry'}});
  my $count = 0;   my $count = 0;
  my $time =   my $time =
Line 3850  sub parm_change_log { Line 3861  sub parm_change_log {
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
 }  }
   
 sub check_for_course_info {  
     my $navmap = Apache::lonnavmaps::navmap->new();  
     return 1 if ($navmap);  
     return 0;  
 }  
   
 ##################################################  ##################################################
 ##################################################  ##################################################
   
Line 3899  sub handler { Line 3904  sub handler {
  (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||   (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) ||
  &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.   &Apache::lonnet::allowed('opa',$env{'request.course.id'}.'/'.
   $env{'request.course.sec'}));    $env{'request.course.sec'}));
     my $exists = &check_for_course_info();      if ($env{'request.course.id'} &&  $parm_permission) {
   
     if ($env{'request.course.id'} &&  $parm_permission && $exists) {  
   
         # Start Page          # Start Page
         &Apache::loncommon::content_type($r,'text/html');          &Apache::loncommon::content_type($r,'text/html');
Line 3971  sub handler { Line 3974  sub handler {
  }          }       
     } else {      } else {
 # ----------------------------- Not in a course, or not allowed to modify parms  # ----------------------------- Not in a course, or not allowed to modify parms
  if ($exists) {   $env{'user.error.msg'}=
     $env{'user.error.msg'}=      "/adm/parmset:opa:0:0:Cannot modify assessment parameters";
  "/adm/parmset:opa:0:0:Cannot modify assessment parameters";  
  } else {  
     $env{'user.error.msg'}=  
  "/adm/parmset::0:1:Course environment gone, reinitialize the course";  
  }  
  return HTTP_NOT_ACCEPTABLE;   return HTTP_NOT_ACCEPTABLE;
     }      }
     return OK;      return OK;

Removed from v.1.350.2.6  
changed lines
  Added in v.1.354


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