Diff for /loncom/interface/lonmeta.pm between versions 1.234 and 1.246

version 1.234, 2009/05/27 14:36:11 version 1.246, 2012/05/21 19:01:12
Line 425  sub select_course { Line 425  sub select_course {
 # Pretty printing of metadata field  # Pretty printing of metadata field
   
 sub prettyprint {  sub prettyprint {
     my ($type,$value,$target,$prefix,$form,$noformat)=@_;      my ($type,$value,$target,$prefix,$form)=@_;
 # $target,$prefix,$form are optional and for filecrumbs only  # $target,$prefix,$form are optional and for filecrumbs only
     if (! defined($value)) {       if (! defined($value)) { 
         return ' ';           return ' '; 
Line 500  sub prettyprint { Line 500  sub prettyprint {
                 }                   } 
             }              }
             $_ = '<li>'.$title.' '.              $_ = '<li>'.$title.' '.
  &Apache::lonhtmlcommon::crumbs($url,$target,$prefix,$form,'0',$noformat).                   &Apache::lonhtmlcommon::crumbs($url,$target,$prefix,$form).
                 '</li>'                   '</li>'
     } split(/\s*\,\s*/,$value)).'</ul>';      } split(/\s*\,\s*/,$value)).'</ul>';
     }      }
     # Evaluations      # Evaluations
Line 638  sub prettyinput { Line 638  sub prettyinput {
                           
             if ($values) {              if ($values) {
                 if ($only_one) {                  if ($only_one) {
                     $output .= (&Apache::loncommon::select_form($cur_values_inst[0],'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 744  sub prettyinput { Line 744  sub prettyinput {
   
 # Create pageheader  # Create pageheader
 sub pageheader {  sub pageheader {
     return &Apache::lonhtmlcommon::breadcrumbs()      my $output = '';
           .&Apache::loncommon::head_subbox(      # No CSTR? Include breadcrumbs
                &Apache::loncommon::CSTR_pageheader());      if ($env{'request.state'} ne 'construct') {
           # loncommon::bodytag already includes breadcrumbs for CSTR
           # by calling lonmenu::innerregister
           $output = &Apache::lonhtmlcommon::breadcrumbs();
       }
       # CSTR? Include CSTR header
       if ($env{'request.state'} eq 'construct') {
             $output .= &Apache::loncommon::head_subbox(
                            &Apache::loncommon::CSTR_pageheader());
       }
       return $output;
 }  }
   
 # Main Handler  # Main Handler
Line 765  sub handler { Line 775  sub handler {
   
     # Breadcrumbs      # Breadcrumbs
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb({  
         'text'  => 'Construction Space',      if ($env{'request.state'} eq 'construct') {
         'href'  => '', # FIXME Add link to /priv/[user]          &Apache::lonhtmlcommon::add_breadcrumb({
     });              'text'  => 'Construction Space',
               'href'  => &Apache::loncommon::authorspace($uri),
           });
       }
   
     if ($uri=~m:/adm/bombs/(.*)$:) {      if ($uri=~m:/adm/bombs/(.*)$:) {
         &Apache::lonhtmlcommon::add_breadcrumb({          &Apache::lonhtmlcommon::add_breadcrumb({
Line 815  sub handler { Line 828  sub handler {
  {'domain' => $resdomain,}));   {'domain' => $resdomain,}));
         $r->print(&pageheader());          $r->print(&pageheader());
         &present_editable_metadata($r,$uri,'groups');              &present_editable_metadata($r,$uri,'groups');    
     } elsif ($uri=~m|^/~|) {       } elsif ($uri=~m|^/priv|) { 
         # Construction space          # Construction space
         &Apache::lonhtmlcommon::add_breadcrumb({          &Apache::lonhtmlcommon::add_breadcrumb({
             'text'  => 'Edit Metadata',              'text'  => 'Edit Metadata',
Line 833  sub handler { Line 846  sub handler {
             'text'  => 'Metadata',              'text'  => 'Metadata',
             'href'  => '',              'href'  => '',
         });          });
         $r->print(&Apache::loncommon::start_page('Metadata',          $r->print(
  undef,              &Apache::loncommon::start_page(
  {'domain' => $resdomain,}));                  'Metadata',
         $r->print(&pageheader());                  undef,
                   {'domain' => $resdomain,
                   'only_body' => 1,})
              .'<h1>'.&mt('Metadata').'</h1>'
           );
         &present_uneditable_metadata($r,$uri);          &present_uneditable_metadata($r,$uri);
     }      }
     $r->print(&Apache::loncommon::end_page());      $r->print(&Apache::loncommon::end_page());
Line 857  sub report_bombs { Line 874  sub report_bombs {
     $uri = &Apache::lonnet::declutter($uri);      $uri = &Apache::lonnet::declutter($uri);
     $r->print('<h1>'.&Apache::lonnet::clutter($uri).'</h1>');      $r->print('<h1>'.&Apache::lonnet::clutter($uri).'</h1>');
     my ($domain,$author)=($uri=~/^($match_domain)\/($match_username)\//);      my ($domain,$author)=($uri=~/^($match_domain)\/($match_username)\//);
     if (&Apache::loncacc::constructaccess('/~'.$author.'/',$domain)) {      if (!&Apache::loncacc::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 882  ENDCLEAR Line 923  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 922  sub present_uneditable_metadata { Line 968  sub present_uneditable_metadata {
     $versiondisplay='Version: '.$currentversion;      $versiondisplay='Version: '.$currentversion;
  }   }
     }      }
     # crumbify displayed URL               uri     target prefix form  size      # crumbify displayed URL               uri     target prefix form 
     $disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef,'+1');      $disuri=&Apache::lonhtmlcommon::crumbs($disuri,undef, undef, undef);
     $disuri =~ s:<br />::g;  
     # obsolete      # obsolete
     my $obsolete=$content{'obsolete'};      my $obsolete=$content{'obsolete'};
     my $obsoletewarning='';      my $obsoletewarning='';
Line 1037  sub print_dynamic_metadata { Line 1082  sub print_dynamic_metadata {
     }      }
     #      #
     # Assessment statistics      # Assessment statistics
     if ($uri=~/\.(problem|exam|quiz|assess|survey|form)$/) {      if ($uri=~/$LONCAPA::assess_re/) {
         if (exists($dynmeta{'stdno'}) ||          if (exists($dynmeta{'stdno'}) ||
             exists($dynmeta{'avetries'}) ||              exists($dynmeta{'avetries'}) ||
             exists($dynmeta{'difficulty'}) ||              exists($dynmeta{'difficulty'}) ||
Line 1076  sub print_dynamic_metadata { Line 1121  sub print_dynamic_metadata {
                      .'<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 1098  sub print_dynamic_metadata { Line 1144  sub print_dynamic_metadata {
                     '<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 1174  sub print_dynamic_metadata { Line 1222  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 present_editable_metadata { Line 1305  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("<h1>$disuri</h1>");
           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');              }
  my $clear=&mt('Clear all Messages in Subdirectory');          }
  my $goback=&mt('Back to Source File');          if ($message) {
         $r->print(<<ENDBOMBS);              $message=&Apache::loncommon::confirmwrapper($message);
 <h1>$disuri</h1>              $r->print($message);
 <form method="post" action="" name="defaultmeta">          }
 ENDBOMBS  
         if ($showdel) {          $r->print('<form method="post" action="" name="defaultmeta">');
     $r->print(<<ENDDEL);          if ($showbuttons) {
 <input type="submit" name="delmsg" value="$del" />              $r->print(
 <input type="submit" name="clearmsg" value="$clear" />                  '<input type="submit" name="delmsg" value="'.
 ENDDEL                  &mt('Delete Messages for this Resource').'" />'.
                   '<input type="submit" name="clearmsg" value="'.
                   &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 {
   
           # Display Metadata, not Bombs
         my $displayfile=&mt('Metadata for [_1]',$disuri);          my $displayfile=&mt('Metadata for [_1]',$disuri);
         if ($disuri=~/\/default$/) {          if ($disuri=~/\/default$/) {
             my $dir=$disuri;              my $dir=$disuri;

Removed from v.1.234  
changed lines
  Added in v.1.246


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