[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm
raeburn
raeburn@source.lon-capa.org
Fri, 30 Jul 2010 20:35:16 -0000
This is a MIME encoded message
--raeburn1280522116
Content-Type: text/plain
raeburn Fri Jul 30 20:35:16 2010 EDT
Modified files:
/loncom/auth lonroles.pm
Log:
- Check if required LON-CAPA release needs updating
when re-initializing course after editing course.
- When processing selected role in a course, check if
server's LON-CAPA version is compatible with version
required for course.
--raeburn1280522116
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20100730203516.txt"
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.254 loncom/auth/lonroles.pm:1.255
--- loncom/auth/lonroles.pm:1.254 Mon Jul 26 21:52:15 2010
+++ loncom/auth/lonroles.pm Fri Jul 30 20:35:16 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.254 2010/07/26 21:52:15 raeburn Exp $
+# $Id: lonroles.pm,v 1.255 2010/07/30 20:35:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -210,7 +210,7 @@
my %dcroles = ();
my $numdc = &check_fordc(\%dcroles,$then);
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
- my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'};
+ my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'};
# ================================================================== Roles Init
if ($env{'form.selectrole'}) {
@@ -324,6 +324,41 @@
if ($tstatus eq 'is') {
$where=~s/^\///;
my ($cdom,$cnum,$csec)=split(/\//,$where);
+ if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
+ my $home = $env{'course.'.$cdom.'_'.$cnum.'.home'};
+ my @ids = &Apache::lonnet::current_machine_ids();
+ unless ($loncaparev eq '' && $home && grep(/^\Q$home\E$/,@ids)) {
+ my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired');
+ if ($curr_reqd_hash{'internal.releaserequired'} &&
+ $curr_reqd_hash{'internal.releaserequired'} > $loncaparev) {
+ my ($switchserver,$switchwarning) =
+ &check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode,$curr_reqd_hash{'internal.releaserequired'});
+ &Apache::loncommon::content_type($r,'text/html');
+ &Apache::loncommon::no_cache($r);
+ $r->send_http_header;
+ my $end_page=&Apache::loncommon::end_page();
+ $r->print(&Apache::loncommon::start_page('Selected course unavailable on this server').
+ '<p class="LC_warning">');
+ if ($switchwarning) {
+ $r->print($switchwarning.'<br /><a href="/adm/roles">');
+ if (&Apache::loncommon::show_course()) {
+ $r->print(&mt('Display courses'));
+ } else {
+ $r->print(&mt('Display roles'));
+ }
+ $r->print('</a>');
+ } elsif ($switchserver) {
+ $r->print(&mt('This course requires a newer version of LON-CAPA than is installed on this server.').
+ '<br />'.
+ '<a href="/adm/switchserver?'.$switchserver.'">'.
+ &mt('Switch Server').
+ '</a>');
+ }
+ $r->print('</p>'.&Apache::loncommon::end_page());
+ return OK;
+ }
+ }
+ }
# check for course groups
my %coursegroups = &Apache::lonnet::get_active_groups(
$env{'user.domain'},$env{'user.name'},$cdom, $cnum);
@@ -459,6 +494,12 @@
if (($ferr) && ($tadv)) {
&error_page($r,$ferr,$dest);
} else {
+ 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);
+ }
+ }
$r->internal_redirect($dest);
}
return OK;
@@ -989,8 +1030,9 @@
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
'</span>';
unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') {
+ my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};
($switchserver,$switchwarning) =
- &check_release_required($loncaparev,$tcourseid,$trolecode);
+ &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
if ($switchserver || $switchwarning) {
$button = 0;
}
@@ -1009,8 +1051,9 @@
$trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
my $home = $newhash{'home'};
unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') {
+ my $required = $newhash{'internal.releaserequired'};
($switchserver,$switchwarning) =
- &check_release_required($loncaparev,$tcourseid,$trolecode);
+ &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
if ($switchserver || $switchwarning) {
$button = 0;
}
@@ -1328,7 +1371,13 @@
} else {
$roletext.=('<td'.$rowspan.' class="'.$tbg.'"> </td>');
}
- $tremark .= $switchwarning;
+ if ($switchwarning) {
+ if ($tremark eq '') {
+ $tremark = $switchwarning;
+ } else {
+ $tremark .= '<br />'.$switchwarning;
+ }
+ }
} elsif ($tstatus eq 'is') {
$roletext.='<td'.$rowspan.' class="'.$tbg.'">'.
'<input name="'.$buttonname.'" type="button" value="'.
@@ -1510,10 +1559,10 @@
}
sub check_release_required {
- my ($loncaparev,$tcourseid,$trolecode) = @_;
+ my ($loncaparev,$tcourseid,$trolecode,$required) = @_;
my ($switchserver,$warning);
- if ($env{'course.'.$tcourseid.'.internal.releaserequired'} ne '') {
- my ($reqdmajor,$reqdminor) = ($env{'course.'.$tcourseid.'.internal.releaserequired'} =~ /^(\d+)\.(\d+)$/);
+ if ($required ne '') {
+ my ($reqdmajor,$reqdminor) = ($required =~ /^(\d+)\.(\d+)$/);
my ($major,$minor) = ($loncaparev =~ /^\'?(\d+)\.(\d+)\.[\d.\-]+\'?$/);
if ($reqdmajor ne '' && $reqdminor ne '') {
my $otherserver;
@@ -1561,6 +1610,43 @@
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
--raeburn1280522116--