Diff for /loncom/interface/lonmeta.pm between versions 1.132 and 1.137

version 1.132, 2005/11/22 19:43:53 version 1.137, 2005/12/13 11:52:37
Line 243  sub fieldnames { Line 243  sub fieldnames {
          'authorspace' => 'Author Space',           'authorspace' => 'Author Space',
          'modifyinguser' => 'Last Modifying User',           'modifyinguser' => 'Last Modifying User',
          'subject' => 'Subject',           'subject' => 'Subject',
            'standards' => 'Standards',
          'keywords' => 'Keyword(s)',           'keywords' => 'Keyword(s)',
          'notes' => 'Notes',           'notes' => 'Notes',
          'abstract' => 'Abstract',           'abstract' => 'Abstract',
Line 254  sub fieldnames { Line 255  sub fieldnames {
         %fields =           %fields = 
         (%fields,          (%fields,
          'domain' => 'Domain',           'domain' => 'Domain',
          'standards' => 'Standards',  
          'mime' => 'MIME Type',           'mime' => 'MIME Type',
          'language' => 'Language',           'language' => 'Language',
          'creationdate' => 'Creation Date',           'creationdate' => 'Creation Date',
Line 284  sub fieldnames { Line 284  sub fieldnames {
          'stdno'      => 'Total number of students who have worked on this problem',           'stdno'      => 'Total number of students who have worked on this problem',
          'difficulty' => 'Degree of difficulty',           'difficulty' => 'Degree of difficulty',
          'disc'       => 'Degree of discrimination',           'disc'       => 'Degree of discrimination',
  'dependencies' => 'Resources used by this resource',       'dependencies' => 'Resources used by this resource',
          );           );
     }      }
     return &Apache::lonlocal::texthash(%fields);      return &Apache::lonlocal::texthash(%fields);
 }  }
   
 sub select_course {  sub select_course {
     my ($r)=@_;  
     my %courses;      my %courses;
       my $output;
     foreach my $key (keys (%env)) {       foreach my $key (keys (%env)) { 
         if ($key =~ m/\.metadata\./) {          if ($key =~ m/\.metadata\./) {
             $key =~ m/^course\.(.+)(\.metadata.+$)/;              $key =~ m/^course\.(.+)(\.metadata.+$)/;
Line 302  sub select_course { Line 302  sub select_course {
             $courses{$coursekey} = $value;              $courses{$coursekey} = $value;
         }          }
     }      }
     $r->print('<h3>Course Related Meta-Data</h3><br />');      $output = '<h3>Associate resource with a course</h3><br />';
     $r->print('<form action="" method="post">');      $output .= '<form action="" method="post">';
     $r->print('Select course restrictions<br />');      $output .= 'Select course <br />';
     $r->print('<select name="metacourse" >');      $output .= '<select name="metacourse" >';
     my $meta_not_found = 1;      my $meta_not_found = 1;
     foreach my $key (keys (%courses)) {          foreach my $key (keys (%courses)) {    
         if ($meta_not_found) {          if ($meta_not_found) {
             undef($meta_not_found);              undef($meta_not_found);
             $r->print('<h3>Portfolio Meta-Data</h3><br />');              $output .= '<h3>Portfolio Meta-Data</h3><br />';
             $r->print('<form action="" method="post">');              $output .= '<form action="" method="post">';
             $r->print('Select your course<br />');              $output .= 'Select your course<br />';
             $r->print('<select name="metacourse" >');              $output .= '<select name="metacourse" >';
         }          }
         $key =~ m/(^.+)\.description$/;          $key =~ m/(^.+)\.description$/;
         $r->print('<option value="'.$1.'">');          $output .= '<option value="'.$1.'">';
         $r->print($courses{$key});          $output .= $courses{$key};
         $r->print('</option>');          $output .= '</option>';
     }      }
     unless ($meta_not_found) {      unless ($meta_not_found) {
         $r->print('</select><br />');          $output .= '</select><br />';
         $r->print('<input type="submit" value="Assign Portfolio Metadata" />');          $output .= '<input type="submit" value="Associate" />';
         $r->print('</form>');          $output .= '</form>';
     }      }
     return 'ok';      return ($output);
 }  }
 # Pretty printing of metadata field  # Pretty printing of metadata field
   
Line 499  sub prettyinput { Line 499  sub prettyinput {
         }          }
         # need to take instructor values out of list where instructor and student          # need to take instructor values out of list where instructor and student
         # values may be mixed.          # values may be mixed.
         if ($values && $stu_add) {          if ($values) {
             foreach my $item (split(/,/,$values)) {              foreach my $item (split(/,/,$values)) {
                 $item =~ s/^\s+//;                  $item =~ s/^\s+//;
                 $meta_options{$item} = $type;                  $meta_options{$item} = $item;
             }              }
             foreach my $item (split(/,/,$value)) {              foreach my $item (split(/,/,$value)) {
                 $item =~ s/^\s+//;                  $item =~ s/^\s+//;
Line 520  sub prettyinput { Line 520  sub prettyinput {
         }          }
         if (($type eq 'keywords') || ($type eq 'subject')          if (($type eq 'keywords') || ($type eq 'subject')
              || ($type eq 'author')||($type eq  'notes')               || ($type eq 'author')||($type eq  'notes')
              || ($type eq  'abstract')|| ($type eq  'title')) {               || ($type eq  'abstract')|| ($type eq  'title')|| ($type eq  'standards')) {
             if ($values) {              if ($values) {
                 if ($only_one) {                  if ($only_one) {
                     $output .= (&Apache::loncommon::select_form($value,'new_'.$type,%meta_options));                      $output .= (&Apache::loncommon::select_form($cur_values_inst[0],'new_'.$type,%meta_options));
                 } else {                  } else {
                     $output .= (&Apache::loncommon::multiple_select_form('new_'.$type,\@cur_values_inst,undef,\%meta_options));                      $output .= (&Apache::loncommon::multiple_select_form('new_'.$type,\@cur_values_inst,undef,\%meta_options));
                 }                  }
Line 603  sub prettyinput { Line 603  sub prettyinput {
     ",'rights')\">".&mt('Select').'</a>'.      ",'rights')\">".&mt('Select').'</a>'.
             &relatedfield(0,$relatedsearchflag,$relatedsep);               &relatedfield(0,$relatedsearchflag,$relatedsep); 
     }      }
       if ($type eq 'courserestricted') {
               return ('<input type="hidden" name="new_courserestricted" value="'.$course_key.'" />');
       }
   
     # Dates      # Dates
     if (($type eq 'creationdate') ||      if (($type eq 'creationdate') ||
  ($type eq 'lastrevisiondate')) {   ($type eq 'lastrevisiondate')) {
Line 649  sub handler { Line 653  sub handler {
         $r->print(&Apache::loncommon::bodytag          $r->print(&Apache::loncommon::bodytag
           ('Edit Portfolio File Information','','','',$resdomain));            ('Edit Portfolio File Information','','','',$resdomain));
         &present_editable_metadata($r,$uri,'portfolio');          &present_editable_metadata($r,$uri,'portfolio');
         &select_course($r);  
     } elsif ($uri=~/^\/\~/) {       } elsif ($uri=~/^\/\~/) { 
         # Construction space          # Construction space
         $r->print(&Apache::loncommon::bodytag          $r->print(&Apache::loncommon::bodytag
Line 999  sub present_editable_metadata { Line 1002  sub present_editable_metadata {
     # Header      # Header
     my $disuri=$uri;      my $disuri=$uri;
     my $fn=&Apache::lonnet::filelocation('',$uri);      my $fn=&Apache::lonnet::filelocation('',$uri);
       my $metacourse;
     $disuri=~s/^\/\~/\/priv\//;      $disuri=~s/^\/\~/\/priv\//;
     $disuri=~s/\.meta$//;      $disuri=~s/\.meta$//;
     $disuri=~s|^/editupload||;      $disuri=~s|^/editupload||;
Line 1071  ENDEDIT Line 1075  ENDEDIT
  my @fields;   my @fields;
  if ($file_type eq 'portfolio') {   if ($file_type eq 'portfolio') {
     @fields =  ('author','title','subject','keywords','abstract','notes','lowestgradelevel',      @fields =  ('author','title','subject','keywords','abstract','notes','lowestgradelevel',
                 'highestgradelevel','courserestricted');                  'highestgradelevel','standards','courserestricted');
  } else {   } else {
     @fields = ('author','title','subject','keywords','abstract','notes',      @fields = ('author','title','subject','keywords','abstract','notes',
                  'copyright','customdistributionfile','language',                   'copyright','customdistributionfile','language',
Line 1079  ENDEDIT Line 1083  ENDEDIT
                  'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',                   'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
                  'obsolete','obsoletereplacement');                   'obsolete','obsoletereplacement');
         }          }
         my $metacourse;  
         if ($env{'form.metacourse'} ) {          if ($env{'form.metacourse'} ) {
             $Apache::lonpublisher::metadatafields{'courserestricted'} = $env{'form.metacourse'};              $Apache::lonpublisher::metadatafields{'courserestricted'} = $env{'form.metacourse'};
             $metacourse = $env{'form.metacourse'};              $metacourse = $env{'form.metacourse'};
Line 1097  ENDEDIT Line 1100  ENDEDIT
                 'default';                  'default';
         }          }
         if ($metacourse ne 'none') {          if ($metacourse ne 'none') {
              $r->print('Document metadata restricted by :<strong> '.$env{$metacourse.".description"}."</strong><br />");              $r->print('Using: <strong> '.$env{$metacourse.".description"}.
                           "</strong> metadata framework<br />");
           } else {
               $r->print("This resources is not associated with a metadata framework<br />");
         }          }
         foreach my $field_name(@fields) {          foreach my $field_name(@fields) {
   
Line 1131  ENDEDIT Line 1137  ENDEDIT
                 }                  }
             }              }
         }          }
   
         if ($env{'form.store'}) {          if ($env{'form.store'}) {
             my $mfh;              my $mfh;
             my $formname='store';               my $formname='store'; 
Line 1152  ENDEDIT Line 1159  ENDEDIT
                              $Apache::lonpublisher::metadatakeys{$unikey})                               $Apache::lonpublisher::metadatakeys{$unikey})
                          ) {                           ) {
                     my $value=                      my $value=
                      $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};                      $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
                     $value=~s/\"/\'\'/g;                      $value=~s/\"/\'\'/g;
                     $file_content.=' '.$_.'="'.$value.'"' ;                      $file_content.=' '.$_.'="'.$value.'"' ;
                     # print $mfh ' '.$_.'="'.$value.'"';                      # print $mfh ' '.$_.'="'.$value.'"';
Line 1166  ENDEDIT Line 1173  ENDEDIT
             if ($fn =~ /\/portfolio\//) {              if ($fn =~ /\/portfolio\//) {
                 $fn =~ /\/portfolio\/(.*)$/;                  $fn =~ /\/portfolio\/(.*)$/;
                 my $new_fn = '/'.$1;                  my $new_fn = '/'.$1;
                 $env{'form.'.$formname}=$file_content;                  $env{'form.'.$formname}=$file_content."\n";
                 $env{'form.'.$formname.'.filename'}=$new_fn;                  $env{'form.'.$formname.'.filename'}=$new_fn;
                 &Apache::lonnet::userfileupload('uploaddoc','',                  &Apache::lonnet::userfileupload('uploaddoc','',
          'portfolio'.$env{'form.currentpath'});           'portfolio'.$env{'form.currentpath'});
Line 1192  ENDEDIT Line 1199  ENDEDIT
                 }                  }
             }              }
         }          }
  $r->print($output.'<br /><input type="submit" name="store" value="'.      $r->print($output.'<br /><input type="submit" name="store" value="'.
                   &mt('Store Catalog Information').'">');                    &mt('Store Catalog Information').'">');
           
     }      }
     $r->print('</form>');      $r->print('</form>');
       if ($metacourse eq 'none') {
           $r->print(&select_course());
       }
     return;      return;
 }  }
   

Removed from v.1.132  
changed lines
  Added in v.1.137


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