[LON-CAPA-cvs] cvs: rat / lonpage.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Mon, 25 Jun 2007 23:27:11 -0000
albertel Mon Jun 25 19:27:11 2007 EDT
Modified files:
/rat lonpage.pm
Log:
- move button generation to separet subroutine
- don't show pprm button if user doesn't have opa
- elimintate duplicate symb generation
Index: rat/lonpage.pm
diff -u rat/lonpage.pm:1.82 rat/lonpage.pm:1.83
--- rat/lonpage.pm:1.82 Mon Jun 25 19:10:26 2007
+++ rat/lonpage.pm Mon Jun 25 19:27:10 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Page Handler
#
-# $Id: lonpage.pm,v 1.82 2007/06/25 23:10:26 albertel Exp $
+# $Id: lonpage.pm,v 1.83 2007/06/25 23:27:10 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -206,8 +206,6 @@
my %ssivlink=();
my %ssialink=();
- my %metalink=();
-
my %cellemb=();
my $allscript='';
@@ -230,7 +228,6 @@
if ($hash{'encrypted_'.$_}) {
$src=&Apache::lonenc::encrypted($src);
}
- $metalink{$_}=$src.'.meta';
$cellemb{$_}=
&Apache::loncommon::fileembstyle($extension);
if ($cellemb{$_} eq 'ssi') {
@@ -411,9 +408,6 @@
} else {
$r->print('<table width="100%" cols="'.$lcm.'" border="0">');
}
-# which icons do we use?
- my $extension='png';
- if ($env{'environment.icons'} eq 'classic') { $extension='gif'; }
# generate rows
for ($i=0;$i<=$#rows;$i++) {
if ($rows[$i]) {
@@ -424,55 +418,8 @@
my $avespan=$lcm/($#colcont+1);
for ($j=0;$j<=$#colcont;$j++) {
my $rid=$colcont[$j];
- my $metainfo = '';
- my $esrc=&Apache::lonnet::declutter($hash{'src_'.$rid});
- my ($mapid,$resid)=split(/\./,$rid);
- my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid});
- if ($hash{'encrypted_'.$rid}) {
- $symb=&Apache::lonenc::encrypted($symb);
- $esrc=&Apache::lonenc::encrypted($esrc);
- }
- if ($hash{'src_'.$rid} !~ m-^/uploaded/-
- && !$env{'request.enc'}
- && ($env{'request.role.adv'}
- || !$hash{'encrypted_'.$rid})) {
- $metainfo ='<a name="'.&escape($symb).'" />'.
- '<a href="'.$metalink{$rid}.'" target="LONcatInfo">'.
- '<img src="/adm/lonMisc/cat_button.'.$extension.'" class="LC_icon" />'.
- '</a>';
- }
- $metainfo .= '<a href="/adm/evaluate?postdata='.
- &escape($esrc).
- '" target="LONcatInfo">'.
- '<img src="/adm/lonMisc/eval_button.'.$extension.'" class="LC_icon" />'.
- '</a>';
- if (
- ($hash{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) &&
- (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) &&
- ($hash{'src_'.$rid} !~ m-^/uploaded/-)) {
- my ($mapid,$resid)=split(/\./,$rid);
- my $symb= &Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$hash{'src_'.$rid});
- if ($hash{'encrypted_'.$resid}) {
- $symb = &Apache::lonenc::encrypt($symb);
- }
- $metainfo.=
- '<a href="/adm/grades?symb='.&escape($symb).
-# '&command=submission" target="LONcatInfo">'.
- '&command=submission">'.
- '<img src="/adm/lonMisc/subm_button.'.$extension.'" class="LC_icon" />'.
- '</a>'.
- '<a href="/adm/grades?symb='.&escape($symb).
-# '&command=gradingmenu" target="LONcatInfo">'.
- '&command=gradingmenu">'.
- '<img src="/adm/lonMisc/pgrd_button.'.$extension.'" class="LC_icon" />'.
- '</a>'.
- '<a href="/adm/parmset?symb='.&escape($symb).
-# '" target="LONcatInfo">'.
- '" >'.
- '<img src="/adm/lonMisc/pprm_button.'.$extension.'" class="LC_icon" />'.
- '</a>';
- }
- $metainfo.='<br></br>';
+
+ my $metainfo =&get_buttons(\%hash,$rid).'<br />';
unless ($target eq 'tex') {
$r->print('<td colspan="'.$avespan.'"');
}
@@ -580,6 +527,65 @@
return OK;
}
+sub get_buttons {
+ my ($hash,$rid) = @_;
+
+ # which icons do we use?
+ my $extension='png';
+ if ($env{'environment.icons'} eq 'classic') { $extension='gif'; }
+
+ my $metainfo = '';
+ my $esrc=&Apache::lonnet::declutter($hash->{'src_'.$rid});
+ my ($mapid,$resid)=split(/\./,$rid);
+ my $symb=&Apache::lonnet::encode_symb($hash->{'map_id_'.$mapid},
+ $resid,
+ $hash->{'src_'.$rid});
+ if ($hash->{'encrypted_'.$rid}) {
+ $symb=&Apache::lonenc::encrypted($symb);
+ $esrc=&Apache::lonenc::encrypted($esrc);
+ }
+ if ($hash->{'src_'.$rid} !~ m-^/uploaded/-
+ && !$env{'request.enc'}
+ && ($env{'request.role.adv'}
+ || !$hash->{'encrypted_'.$rid})) {
+ $metainfo .='<a name="'.&escape($symb).'" />'.
+ '<a href="'.$hash->{'src_'.$rid}.'.meta'.'" target="LONcatInfo">'.
+ '<img src="/adm/lonMisc/cat_button.'.$extension.'" class="LC_icon" />'.
+ '</a>';
+ }
+ $metainfo .= '<a href="/adm/evaluate?postdata='.
+ &escape($esrc).
+ '" target="LONcatInfo">'.
+ '<img src="/adm/lonMisc/eval_button.'.$extension.'" class="LC_icon" />'.
+ '</a>';
+ if (($hash->{'src_'.$rid}=~/\.(problem|exam|quiz|assess|survey|form)$/) &&
+ ($hash->{'src_'.$rid} !~ m-^/uploaded/-)) {
+
+ if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'})) {
+ $metainfo.=
+ '<a href="/adm/grades?symb='.&escape($symb).
+# '&command=submission" target="LONcatInfo">'.
+ '&command=submission">'.
+ '<img src="/adm/lonMisc/subm_button.'.$extension.'" class="LC_icon" />'.
+ '</a>'.
+ '<a href="/adm/grades?symb='.&escape($symb).
+# '&command=gradingmenu" target="LONcatInfo">'.
+ '&command=gradingmenu">'.
+ '<img src="/adm/lonMisc/pgrd_button.'.$extension.'" class="LC_icon" />'.
+ '</a>';
+ }
+ if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) {
+ $metainfo.=
+ '<a href="/adm/parmset?symb='.&escape($symb).
+# '" target="LONcatInfo">'.
+ '" >'.
+ '<img src="/adm/lonMisc/pprm_button.'.$extension.'" class="LC_icon" />'.
+ '</a>';
+ }
+ }
+ return $metainfo;
+}
+
1;
__END__