Diff for /loncom/interface/lonmeta.pm between versions 1.244 and 1.254

version 1.244, 2011/11/14 00:20:34 version 1.254, 2014/06/22 19:46:48
Line 351  sub pre_select_course { Line 351  sub pre_select_course {
     if ($group) {      if ($group) {
         $group_input = '<input type="hidden" name="group" value="'.$group.'" />';          $group_input = '<input type="hidden" name="group" value="'.$group.'" />';
     }       } 
     $r->print('<br /><br /><form method="post" action="'.$port_path.'">'.      $r->print(' <form method="post" action="'.$port_path.'">'.
               '<input type="hidden" name="currentpath" value="'.$path.'" />'.                '<input type="hidden" name="currentpath" value="'.$path.'" />'.
       $group_input.        $group_input.
       '<input type="submit" name="cancel" value="'.&mt('Cancel').'" />'.        '<input type="submit" name="cancel" value="'.&mt('Cancel').'" />'.
Line 389  sub select_course { Line 389  sub select_course {
                     &mt('You can choose to transfer data from the added fields to the "Notes" field if you are planning to change the course association.').'<br /><br />'.                      &mt('You can choose to transfer data from the added fields to the "Notes" field if you are planning to change the course association.').'<br /><br />'.
                     &Apache::loncommon::start_data_table().                      &Apache::loncommon::start_data_table().
                     &Apache::loncommon::start_data_table_header_row().                      &Apache::loncommon::start_data_table_header_row().
                     '<th>Copy to notes?</th>'."\n".                      '<th>'.&mt('Copy to notes?').'</th>'."\n".
                     '<th>Field name</th>'."\n".                      '<th>'.&mt('Field Name').'</th>'."\n".
                     '<th>Values</th>'."\n".                      '<th>'.&mt('Values').'</th>'."\n".
                     &Apache::loncommon::end_data_table_header_row().                      &Apache::loncommon::end_data_table_header_row().
                     $transfernotes.                      $transfernotes.
                     &Apache::loncommon::end_data_table().'<br />';                      &Apache::loncommon::end_data_table().'<br />';
Line 455  sub prettyprint { Line 455  sub prettyprint {
     }      }
     # MIME      # MIME
     if ($type eq 'mime') {      if ($type eq 'mime') {
         return '<img src="'.&Apache::loncommon::icon($value).'" />&nbsp;'.          return '<img src="'.&Apache::loncommon::icon($value).'" alt="" />&nbsp;'.
             &Apache::loncommon::filedescription($value);              &Apache::loncommon::filedescription($value);
     }      }
     # Person      # Person
Line 763  sub pageheader { Line 763  sub pageheader {
 sub handler {  sub handler {
     my $r=shift;      my $r=shift;
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
          ['currentpath','changecourse']);           ['currentpath','changecourse','modal']);
     my $uri=$r->uri;      my $uri=$r->uri;
     #      #
     # Set document type      # Set document type
Line 778  sub handler { Line 778  sub handler {
   
     if ($env{'request.state'} eq 'construct') {      if ($env{'request.state'} eq 'construct') {
         &Apache::lonhtmlcommon::add_breadcrumb({          &Apache::lonhtmlcommon::add_breadcrumb({
             'text'  => 'Construction Space',              'text'  => 'Authoring Space',
             'href'  => &Apache::loncommon::authorspace($uri),              'href'  => &Apache::loncommon::authorspace($uri),
         });          });
     }      }
Line 829  sub handler { Line 829  sub handler {
         $r->print(&pageheader());          $r->print(&pageheader());
         &present_editable_metadata($r,$uri,'groups');              &present_editable_metadata($r,$uri,'groups');    
     } elsif ($uri=~m|^/priv|) {       } elsif ($uri=~m|^/priv|) { 
         # Construction space          # Authoring space
         &Apache::lonhtmlcommon::add_breadcrumb({          &Apache::lonhtmlcommon::add_breadcrumb({
             'text'  => 'Edit Metadata',              'text'  => 'Edit Metadata',
             'href'  => '',              'href'  => '',
Line 854  sub handler { Line 854  sub handler {
                 'only_body' => 1,})                  'only_body' => 1,})
            .'<h1>'.&mt('Metadata').'</h1>'             .'<h1>'.&mt('Metadata').'</h1>'
         );          );
           if ($env{'form.modal'}) {
               my $width = 500;
               my $height = 400;
               my $machine = &Apache::lonnet::absolute_url();
               $r->print(&Apache::loncommon::nicescroll_javascript('metadatawrapper',
                                                                   {cursorcolor => '#00F',
                                                                    railalign => 'right',
                                                                    railoffset => '{top:5,left:40}'},
                                                                    undef,1,$machine.$uri));
               $r->print('<div id="metadatawrapper" style="height:'.$height.'px; width:'.$width.'px; overflow: auto;">');
           }
         &present_uneditable_metadata($r,$uri);          &present_uneditable_metadata($r,$uri);
           if ($env{'form.modal'}) {
               $r->print('</div>');
           }
     }      }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
     return OK;      return OK;
Line 872  sub report_bombs { Line 886  sub report_bombs {
     # Set document type      # Set document type
     $uri =~ s:/adm/bombs/::;      $uri =~ s:/adm/bombs/::;
     $uri = &Apache::lonnet::declutter($uri);      $uri = &Apache::lonnet::declutter($uri);
     $r->print('<h1>'.&Apache::lonnet::clutter($uri).'</h1>');      $r->print(
           '<p>'.&mt('Folder: [_1]',
                     '<span class="LC_filename">'.&Apache::lonnet::clutter($uri).'</span>')
          .'</p>'
       );
     my ($domain,$author)=($uri=~/^($match_domain)\/($match_username)\//);      my ($domain,$author)=($uri=~/^($match_domain)\/($match_username)\//);
     if (&Apache::loncacc::constructaccess('/priv/'.$domain.'/'.$author.'/')) {      if (!&Apache::lonnet::constructaccess('/priv/'.$domain.'/'.$author.'/')) {
  if ($env{'form.clearbombs'}) {          $r->print('<p class="LC_error">'.&mt('Not authorized').'</p>');
     &Apache::lonmsg::clear_author_res_msg($uri);          return;
  }      }
         my $clear=&mt('Clear all Messages in Subdirectory');  
         my $cancel=&mt('Back to Directory');      my $showbuttons=1;
         my $cancelurl=$uri;      my $message='';
         $cancelurl=~s/^\Q$domain\E/\/priv/;      if ($env{'form.clearbombs'}) {
         $r->print(<<ENDCLEAR);          my $rc=&Apache::lonmsg::clear_author_res_msg($uri);
 <form method="post">          if ($rc eq 'ok') {
 <input type="submit" name="clearbombs" value="$clear" />                  $message=&Apache::lonhtmlcommon::confirm_success(
 <a href="$cancelurl">$cancel</a>                      &mt('Messages cleared.'));
 </form><hr />                  $showbuttons=0;
 ENDCLEAR          } else {
                   $message=&Apache::lonhtmlcommon::confirm_success(
                                &mt('Error clearing messages'),1)
                           .'<br />'.&mt('Error: [_1]',$rc);
           }
       }
   
       if ($message) {    
           $message=&Apache::loncommon::confirmwrapper($message);
           $r->print($message);
       }
   
       my $cancelurl=$uri;
       $cancelurl=~s/^\Q$domain\E/\/priv\/$domain/;
   
       if ($showbuttons) {
           $r->print(
               '<form method="post" action="">'.
               '<input type="submit" name="clearbombs" value="'.
                   &mt('Clear all Messages in Subdirectory').'" />'.
               ' <a href="'.$cancelurl.'">'.
                   &mt('Back to Source Directory').'</a>'.
               '</form><hr />'
           );
           # Display all bombs of subdirectory
         my %brokenurls =           my %brokenurls = 
             &Apache::lonmsg::all_url_author_res_msg($author,$domain);              &Apache::lonmsg::all_url_author_res_msg($author,$domain);
         foreach my $key (sort(keys(%brokenurls))) {          foreach my $key (sort(keys(%brokenurls))) {
Line 899  ENDCLEAR Line 941  ENDCLEAR
             }              }
         }          }
     } else {      } else {
         $r->print(&mt('Not authorized'));              my $functions=&Apache::lonhtmlcommon::start_funclist('Actions');
               $functions.=&Apache::lonhtmlcommon::add_item_funclist(
                               '<a href="'.$cancelurl.'">'.
                               &mt('Back to Source Directory').'</a>');
               $functions .= &Apache::lonhtmlcommon::end_funclist();
               $r->print('<p>'.$functions.'</p>');
     }      }
     return;      return;
 }  }
Line 936  sub present_uneditable_metadata { Line 983  sub present_uneditable_metadata {
  $currentversion   :   $currentversion   :
  &mt('information not available')).')';   &mt('information not available')).')';
  } else {   } else {
     $versiondisplay='Version: '.$currentversion;      $versiondisplay=&mt('Version: [_1]',$currentversion);
  }   }
     }      }
     # crumbify displayed URL               uri     target prefix form       # crumbify displayed URL               uri     target prefix form 
Line 954  sub present_uneditable_metadata { Line 1001  sub present_uneditable_metadata {
     my $table='';      my $table='';
     my $title = $content{'title'};      my $title = $content{'title'};
     if (! defined($title)) {      if (! defined($title)) {
         $title = 'Untitled Resource';          $title = &mt('Untitled Resource');
     }      }
     my @fields;      my @fields;
     if ($uploaded) {      if ($uploaded) {
Line 1089  sub print_dynamic_metadata { Line 1136  sub print_dynamic_metadata {
         if (exists($dynmeta{'stats'})) {          if (exists($dynmeta{'stats'})) {
             my $table=&Apache::loncommon::start_data_table()              my $table=&Apache::loncommon::start_data_table()
                      .&Apache::loncommon::start_data_table_header_row()                       .&Apache::loncommon::start_data_table_header_row()
        .'<th>'.&mt('Domain').'</th>'
                      .'<th>'.&mt('Course').'</th>'                       .'<th>'.&mt('Course').'</th>'
                      .'<th>'.&mt('Section(s)').'</th>'                       .'<th>'.&mt('Section(s)').'</th>'
                      .'<th>'.&mt('Num Students').'</th>'                       .'<th>'.&mt('Num Students').'</th>'
                        .'<th>'.&mt('Part').'</th>'
                      .'<th>'.&mt('Mean Tries').'</th>'                       .'<th>'.&mt('Mean Tries').'</th>'
                      .'<th>'.&mt('Degree of Difficulty').'</th>'                       .'<th>'.&mt('Degree of Difficulty').'</th>'
                      .'<th>'.&mt('Degree of Discrimination').'</th>'                       .'<th>'.&mt('Degree of Discrimination').'</th>'
Line 1108  sub print_dynamic_metadata { Line 1157  sub print_dynamic_metadata {
                     next;                      next;
                 }                  }
                 $table .= &Apache::loncommon::start_data_table_row();                  $table .= &Apache::loncommon::start_data_table_row();
    $table .=
       '<td><span class="LC_nobreak">'.$courseinfo{'domain'}.'</span></td>';
                 $table .=                   $table .= 
                     '<td><span class="LC_nobreak">'.$courseinfo{'description'}.'</span></td>';                      '<td><span class="LC_nobreak">'.$courseinfo{'description'}.'</span></td>';
                 $table .=                   $table .= 
                     '<td align="right">'.$data->{'sections'}.'</td>';                      '<td align="right">'.$data->{'sections'}.'</td>';
                 $table .=                  $table .=
                     '<td align="right">'.$data->{'stdno'}.'</td>';                      '<td align="right">'.$data->{'stdno'}.'</td>';
                   $table .=
                       '<td align="right">'.$data->{'part'}.'</td>';
                 foreach my $item ('avetries','difficulty','disc') {                  foreach my $item ('avetries','difficulty','disc') {
                     $table .= '<td align="right">';                      $table .= '<td align="right">';
                     if (exists($data->{$item})) {                      if (exists($data->{$item})) {
Line 1142  sub print_dynamic_metadata { Line 1195  sub print_dynamic_metadata {
           &mt('No Assessment Statistical Data is available for this resource').            &mt('No Assessment Statistical Data is available for this resource').
                   '</h4>');                    '</h4>');
     }      }
   
     #      #
     # Evaluation Data      # Evaluation Data
     $r->print('<h4>'.&mt('Evaluation Data').'</h4>');      $r->print('<h4>'.&mt('Evaluation Data').'</h4>');
Line 1190  sub print_dynamic_metadata { Line 1242  sub print_dynamic_metadata {
         my $bombs = &Apache::lonmsg::retrieve_author_res_msg($uri);          my $bombs = &Apache::lonmsg::retrieve_author_res_msg($uri);
         if (defined($bombs) && $bombs ne '') {          if (defined($bombs) && $bombs ne '') {
             $r->print('<a name="bombs" />'              $r->print('<a name="bombs" />'
                      .'<h4 class="LC_error">'.&mt('Error Messages').'</h4>'                       .'<h4 class="LC_warning">'.&mt('Error Messages').'</h4>'
                      .'<div>('                       .'<div>('
                      .&mt('visible to author and co-authors only')                       .&mt('visible to author and co-authors only')
                      .')</div>'                       .')</div>'
Line 1257  sub print_dynamic_metadata { Line 1309  sub print_dynamic_metadata {
 #####################################################  #####################################################
 sub present_editable_metadata {  sub present_editable_metadata {
     my ($r,$uri,$file_type) = @_;      my ($r,$uri,$file_type) = @_;
     # Construction Space Call      # Authoring Space Call
     # Header      # Header
     my $disuri=$uri;      my $disuri=$uri;
     my $fn=&Apache::lonnet::filelocation('',$uri);      my $fn=&Apache::lonnet::filelocation('',$uri);
Line 1273  sub present_editable_metadata { Line 1325  sub present_editable_metadata {
     $target=~s/\.meta$//;      $target=~s/\.meta$//;
     my $bombs=&Apache::lonmsg::retrieve_author_res_msg($target);      my $bombs=&Apache::lonmsg::retrieve_author_res_msg($target);
     if ($bombs) {      if ($bombs) {
         my $showdel=1;          # Display Bombs, not Metadata
           $r->print(
               '<h2>'.&mt('Error Messages').'</h2>'
              .'<p>'.&mt('Folder: [_1]',
                         '<span class="LC_filename">'.$disuri.'</span>')
              .'</p>'
           );
           my $showbuttons=1;
           my $message='';
           my $rc='';
         if ($env{'form.delmsg'}) {          if ($env{'form.delmsg'}) {
             if (&Apache::lonmsg::del_url_author_res_msg($target) eq 'ok') {              $rc=&Apache::lonmsg::del_url_author_res_msg($target);
                 $bombs=&mt('Messages deleted.');              if ($rc eq 'ok') {
  $showdel=0;                  $message=&Apache::lonhtmlcommon::confirm_success(
                                &mt('Messages deleted.'));
    $showbuttons=0;
             } else {              } else {
                 $bombs=&mt('Error deleting messages');                  $message=&Apache::lonhtmlcommon::confirm_success(
                                &mt('Error deleting messages'), 1)
                           .'<br />'.&mt('Error: [_1]',$rc);
             }              }
         }          }
         if ($env{'form.clearmsg'}) {          if ($env{'form.clearmsg'}) {
     my $cleardir=$target;      my $cleardir=$target;
     $cleardir=~s/\/[^\/]+$/\//;      $cleardir=~s/\/[^\/]+$/\//; # Extract dir: keep path, remove filename
             if (&Apache::lonmsg::clear_author_res_msg($cleardir) eq 'ok') {              $rc=&Apache::lonmsg::clear_author_res_msg($cleardir);
                 $bombs=&mt('Messages cleared.');              if ($rc eq 'ok') {
  $showdel=0;                  $message=&Apache::lonhtmlcommon::confirm_success(
                       &mt('Messages cleared.'));
    $showbuttons=0;
             } else {              } else {
                 $bombs=&mt('Error clearing messages');                  $message=&Apache::lonhtmlcommon::confirm_success(
                                &mt('Error clearing messages'),1)
                           .'<br />'.&mt('Error: [_1]',$rc);
             }              }
         }          }
         my $del=&mt('Delete Messages for this Resource');          if ($message) {
  my $clear=&mt('Clear all Messages in Subdirectory');              $message=&Apache::loncommon::confirmwrapper($message);
  my $goback=&mt('Back to Source File');              $r->print($message);
         $r->print(<<ENDBOMBS);          }
 <h1>$disuri</h1>  
 <form method="post" action="" name="defaultmeta">          $r->print('<form method="post" action="" name="defaultmeta">');
 ENDBOMBS          if ($showbuttons) {
         if ($showdel) {              $r->print(
     $r->print(<<ENDDEL);                  '<input type="submit" name="delmsg" value="'.
 <input type="submit" name="delmsg" value="$del" />                  &mt('Delete Messages for this Resource').'" />'.
 <input type="submit" name="clearmsg" value="$clear" />                  '<input type="submit" name="clearmsg" value="'.
 ENDDEL                  &mt('Clear all Messages in Subdirectory').'" />'
                  .'<br />'.$bombs
               );
         } else {          } else {
             $r->print('<p><a href="'.$disuri.'">'.$goback.'</a></p>');              my $functions=&Apache::lonhtmlcommon::start_funclist('Actions');
     if ($env{'form.clearmsg'}) {              $functions.=&Apache::lonhtmlcommon::add_item_funclist(
  my ($diruri) = ($disuri =~ m{(.*/)[^/]*});                              '<a href="'.$disuri.'">'.
  $r->print('<p><a href="'.$diruri.'">'.                              &mt('Back to Source File').'</a>');
   &mt('Back To Directory').'</a></p>');              my ($diruri) = ($disuri =~ m{(.*/)[^/]*});
     }              $functions.=&Apache::lonhtmlcommon::add_item_funclist(
  }                              '<a href="'.$diruri.'">'.
  $r->print('<br />'.$bombs);                              &mt('Back to Source Directory').'</a>');
               $functions .= &Apache::lonhtmlcommon::end_funclist();
               $r->print('<p>'.$functions.'</p>');
           }
     } else {      } else {
         my $displayfile=&mt('Metadata for [_1]',$disuri);  
           # Display Metadata, not Bombs
           my $displayfile =
               &mt('Metadata for [_1]'
                  ,'<span class="LC_filename">'.$disuri.'</span>');
         if ($disuri=~/\/default$/) {          if ($disuri=~/\/default$/) {
             my $dir=$disuri;              my $dir=$disuri;
             $dir=~s/default$//;              $dir=~s/default$//;
Line 1325  ENDDEL Line 1403  ENDDEL
         %Apache::lonpublisher::metadatakeys=();          %Apache::lonpublisher::metadatakeys=();
         my $result=&Apache::lonnet::getfile($fn);          my $result=&Apache::lonnet::getfile($fn);
         if ($result == -1){          if ($result == -1){
     $r->print(&mt('Creating new file [_1]'),$meta_uri);              my $message = &Apache::lonhtmlcommon::confirm_success(
                   &mt('Creating new file [_1]'
                      ,'<span class="LC_filename"'.$meta_uri.'</span>'));
               $message = &Apache::loncommon::confirmwrapper($message);
               $r->print($message);
         } else {          } else {
             &Apache::lonpublisher::metaeval($result);              &Apache::lonpublisher::metaeval($result);
         }          }
Line 1346  ENDDEL Line 1428  ENDDEL
             }              }
         }          }
         $r->print(<<ENDEDIT);          $r->print(<<ENDEDIT);
 <p>$displayfile</p>  <h2>$displayfile</h2>
 <form method="post" action="" name="defaultmeta">  <form method="post" action="" name="defaultmeta">
 ENDEDIT  ENDEDIT
         my %lt=&fieldnames($file_type);          my %lt=&fieldnames($file_type);
Line 1372  ENDEDIT Line 1454  ENDEDIT
         @fields = (split(/,/,$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'}));          @fields = (split(/,/,$env{$Apache::lonpublisher::metadatafields{'courserestricted'}.'.metadata.fieldlist'}));
     } else {      } else {
         # no saved field list, use default list          # no saved field list, use default list
         @fields =  ('author','title','subject','keywords','abstract',          @fields =  ('title','author','subject','keywords','abstract',
     'notes','lowestgradelevel',      'notes','lowestgradelevel',
                     'highestgradelevel','standards');                      'highestgradelevel','standards');
                 if ($Apache::lonpublisher::metadatafields{'courserestricted'} =~ /^course\.($match_domain\_$match_courseid)$/) {                  if ($Apache::lonpublisher::metadatafields{'courserestricted'} =~ /^course\.($match_domain\_$match_courseid)$/) {
Line 1385  ENDEDIT Line 1467  ENDEDIT
                 }                  }
     }      }
  } else {   } else {
     @fields = ('author','title','subject','keywords','abstract','notes',      @fields = ('title','author','subject','keywords','abstract','notes',
        'copyright','customdistributionfile','language',         'copyright','customdistributionfile','language',
        'standards',         'standards',
        'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',         'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
Line 1412  ENDEDIT Line 1494  ENDEDIT
     if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {      if ($Apache::lonpublisher::metadatafields{'courserestricted'} ne 'none') {
   
                 if ($file_type eq 'portfolio') {                  if ($file_type eq 'portfolio') {
     $r->print(&mt('Associated with course [_1]',                      $r->print(
         '<strong><a href="'.$uri.'?changecourse=true">'.                          &mt('Associated with course [_1]'
         $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.                             ,'<strong>'
         ".description"}.                             .$env{$Apache::lonpublisher::metadatafields{'courserestricted'}
       '</a></strong>').'<br />');                             .".description"}.'</strong>')
                          .' <a href="'.$uri.'?changecourse=true">'
                          .&mt('Change')
                          .'</a>'.'<br />'
                       );
   
                 } else {                  } else {
                     $r->print(&mt('Associated with course [_1]',                      $r->print(&mt('Associated with course [_1]',
                         '<strong>'.                          '<strong>'.
   $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.    $env{$Apache::lonpublisher::metadatafields{'courserestricted'}.
                         ".description"}.'</strong>').'<br />');                          ".description"}.'</strong>').'<br />');
                 }                  }
     } else {              } else {
  $r->print('<a href="'.$uri.'?changecourse=true">'.&mt('This resource is not associated with a course.').'</a><br />');                  $r->print(
     }                      &mt('This resource is not associated with a course.')
  }                    .' <a href="'.$uri.'?changecourse=true">'.&mt('Change').'</a><br />'
                   );
               }
           }
  if (@added_order) {   if (@added_order) {
     foreach my $field_name (@added_order) {      foreach my $field_name (@added_order) {
                 push(@fields,$field_name);                  push(@fields,$field_name);

Removed from v.1.244  
changed lines
  Added in v.1.254


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