[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /interface groupsort.pm loncommon.pm
raeburn
raeburn at source.lon-capa.org
Sat Jun 30 19:02:25 EDT 2012
raeburn Sat Jun 30 23:02:25 2012 EDT
Modified files:
/loncom/interface groupsort.pm loncommon.pm
/loncom/auth lonroles.pm
Log:
- Facilitate code re-use.
- Move &update_content_constraints() from lonroles.pm to loncommon.pm
- Move &parse_supplemental_title() from londocs.pm to loncommon.pm
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.68 loncom/interface/groupsort.pm:1.69
--- loncom/interface/groupsort.pm:1.68 Mon Jul 4 09:24:58 2011
+++ loncom/interface/groupsort.pm Sat Jun 30 23:02:20 2012
@@ -2,7 +2,7 @@
# The LON-CAPA group sort handler
# Allows for sorting prior to import into RAT.
#
-# $Id: groupsort.pm,v 1.68 2011/07/04 09:24:58 foxr Exp $
+# $Id: groupsort.pm,v 1.69 2012/06/30 23:02:20 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -37,7 +37,7 @@
use Apache::loncommon;
use Apache::lonlocal;
use Apache::lonnet;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
my $iconpath; # variable to be accessible to multiple subroutines
my %hash; # variable to tie to user specific database
@@ -411,7 +411,14 @@
$r->print("<td>");
$r->print("<img src='$iconname' />");
$r->print("</td><td>");
- $r->print($resource->{'title'}.$resource->{'notes'}."</td><td>\n");
+ if (($env{'form.recover'}) &&
+ ($resource->{'url'} =~ m{/uploaded/$match_domain/$match_courseid/supplemental/})) {
+ my $title = &Apache::loncommon::parse_supplemental_title($resource->{'title'});
+ $r->print($title);
+ } else {
+ $r->print($resource->{'title'});
+ }
+ $r->print($resource->{'notes'}."</td><td>\n");
$r->print($resource->{'url'}."</td>"
.&Apache::loncommon::end_data_table_row()
."\n");
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1082 loncom/interface/loncommon.pm:1.1083
--- loncom/interface/loncommon.pm:1.1082 Fri Jun 8 21:24:16 2012
+++ loncom/interface/loncommon.pm Sat Jun 30 23:02:20 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1082 2012/06/08 21:24:16 raeburn Exp $
+# $Id: loncommon.pm,v 1.1083 2012/06/30 23:02:20 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -13847,6 +13847,66 @@
return;
}
+sub update_content_constraints {
+ my ($cdom,$cnum,$chome,$cid) = @_;
+ my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired');
+ my ($reqdmajor,$reqdminor) = split(/\./,$curr_reqd_hash{'internal.releaserequired'});
+ my %checkresponsetypes;
+ foreach my $key (keys(%Apache::lonnet::needsrelease)) {
+ my ($item,$name,$value) = split(/:/,$key);
+ if ($item eq 'resourcetag') {
+ if ($name eq 'responsetype') {
+ $checkresponsetypes{$value} = $Apache::lonnet::needsrelease{$key}
+ }
+ }
+ }
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (defined($navmap)) {
+ my %allresponses;
+ foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
+ my %responses = $res->responseTypes();
+ foreach my $key (keys(%responses)) {
+ next unless(exists($checkresponsetypes{$key}));
+ $allresponses{$key} += $responses{$key};
+ }
+ }
+ foreach my $key (keys(%allresponses)) {
+ my ($major,$minor) = split(/\./,$checkresponsetypes{$key});
+ if (($major > $reqdmajor) || ($major == $reqdmajor && $minor > $reqdminor)) {
+ ($reqdmajor,$reqdminor) = ($major,$minor);
+ }
+ }
+ undef($navmap);
+ }
+ unless (($reqdmajor eq '') && ($reqdminor eq '')) {
+ &Apache::lonnet::update_released_required($reqdmajor.'.'.$reqdminor,$cdom,$cnum,$chome,$cid);
+ }
+ return;
+}
+
+sub parse_supplemental_title {
+ my ($title) = @_;
+
+ my ($foldertitle,$renametitle);
+ if ($title =~ /&&&/) {
+ $title = &HTML::Entites::decode($title);
+ }
+ if ($title =~ m/^(\d+)___&&&___($match_username)___&&&___($match_domain)___&&&___(.*)$/) {
+ $renametitle=$4;
+ my ($time,$uname,$udom) = ($1,$2,$3);
+ $foldertitle=&Apache::lontexconvert::msgtexconverted($4);
+ my $name = &plainname($uname,$udom);
+ $name = &HTML::Entities::encode($name,'"<>&\'');
+ $renametitle = &HTML::Entities::encode($renametitle,'"<>&\'');
+ $title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
+ $name.': <br />'.$foldertitle;
+ }
+ if (wantarray) {
+ return ($title,$foldertitle,$renametitle);
+ }
+ return $title;
+}
+
=pod
=back
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.267 loncom/auth/lonroles.pm:1.268
--- loncom/auth/lonroles.pm:1.267 Fri Jun 1 16:00:29 2012
+++ loncom/auth/lonroles.pm Sat Jun 30 23:02:25 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.267 2012/06/01 16:00:29 bisitz Exp $
+# $Id: lonroles.pm,v 1.268 2012/06/30 23:02:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -519,7 +519,8 @@
if ($dest =~ m{^/adm/coursedocs\?folderpath}) {
if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {
my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
- &update_content_constraints($cdom,$cnum,$chome,$cdom.'_'.$cnum);
+ &Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,
+ $cdom.'_'.$cnum);
}
}
$r->internal_redirect($dest);
@@ -1686,43 +1687,6 @@
return ($switchserver,$warning);
}
-sub update_content_constraints {
- my ($cdom,$cnum,$chome,$cid) = @_;
- my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired');
- my ($reqdmajor,$reqdminor) = split(/\./,$curr_reqd_hash{'internal.releaserequired'});
- my %checkresponsetypes;
- foreach my $key (keys(%Apache::lonnet::needsrelease)) {
- my ($item,$name,$value) = split(/:/,$key);
- if ($item eq 'resourcetag') {
- if ($name eq 'responsetype') {
- $checkresponsetypes{$value} = $Apache::lonnet::needsrelease{$key}
- }
- }
- }
- my $navmap = Apache::lonnavmaps::navmap->new();
- if (defined($navmap)) {
- my %allresponses;
- foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) {
- my %responses = $res->responseTypes();
- foreach my $key (keys(%responses)) {
- next unless(exists($checkresponsetypes{$key}));
- $allresponses{$key} += $responses{$key};
- }
- }
- foreach my $key (keys(%allresponses)) {
- my ($major,$minor) = split(/\./,$checkresponsetypes{$key});
- if (($major > $reqdmajor) || ($major == $reqdmajor && $minor > $reqdminor)) {
- ($reqdmajor,$reqdminor) = ($major,$minor);
- }
- }
- undef($navmap);
- }
- unless (($reqdmajor eq '') && ($reqdminor eq '')) {
- &Apache::lonnet::update_released_required($reqdmajor.'.'.$reqdminor,$cdom,$cnum,$chome,$cid);
- }
- return;
-}
-
sub courselink {
my ($dcdom,$rowtype) = @_;
my $courseform=&Apache::loncommon::selectcourse_link
@@ -2293,7 +2257,7 @@
}
if (keys(%deletedroles) > 0) {
$changemsg .= '<li>'.
- &mt('Existing roles deleted').'</li>'.
+ &mt('Existing roles now expired').'</li>'.
'<ul>';
foreach my $item (sort(keys(%deletedroles))) {
$changemsg .= '<li>'.$item.'</li>';
More information about the LON-CAPA-cvs
mailing list