[prev in list] [next in list] [prev in thread] [next in thread]
List: lon-capa-cvs
Subject: [LON-CAPA-cvs] cvs: loncom /interface loncommon.pm
From: raeburn <lon-capa-cvs-allow () mail ! lon-capa ! org>
Date: 2007-12-23 4:11:22
Message-ID: cvsraeburn1198383082 () cvsserver
[Download RAW message or body]
raeburn Sat Dec 22 23:11:22 2007 EDT
Modified files:
/loncom/interface loncommon.pm
Log:
- For section-specific 'cst' role for which dropping an "old" section role is \
refused, retrieve roles information for user and check if role for section in \
question was actually already expired. If so, override the "refused" and add the new \
role.
- Modify some logging messages in recognition of the possibility of changes \
involving student roles with no section.
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.627 loncom/interface/loncommon.pm:1.628
--- loncom/interface/loncommon.pm:1.627 Fri Dec 21 00:19:04 2007
+++ loncom/interface/loncommon.pm Sat Dec 22 23:11:21 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.627 2007/12/21 05:19:04 raeburn Exp $
+# $Id: loncommon.pm,v 1.628 2007/12/23 04:11:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -7816,16 +7816,36 @@
my $secchange = 0;
my $expire_role_result;
my $modify_section_result;
- unless ($oldsec eq '-1') {
- unless ($sec eq $oldsec) {
+ if ($oldsec ne '-1') {
+ if ($oldsec ne $sec) {
$secchange = 1;
+ my $now = time;
my $uurl='/'.$cid;
$uurl=~s/\_/\//g;
if ($oldsec) {
$uurl.='/'.$oldsec;
}
$oldsecurl = $uurl;
- $expire_role_result = \
&Apache::lonnet::assignrole($udom,$uname,$uurl,'st',time); + \
$expire_role_result = + \
&Apache::lonnet::assignrole($udom,$uname,$uurl,'st',$now); + if \
($env{'request.course.sec'} ne '') { + if ($expire_role_result eq \
'refused') { + my @roles = ('st');
+ my @statuses = ('previous');
+ my @roledoms = ($one);
+ my $withsec = 1;
+ my %roleshash =
+ &Apache::lonnet::get_my_roles($uname,$udom,'userroles',
+ \
\@statuses,\@roles,\@roledoms,$withsec); + if (defined \
($roleshash{$two.':'.$one.':st:'.$oldsec})) { + my \
($oldstart,$oldend) = + \
split(':',$roleshash{$two.':'.$one.':st:'.$oldsec}); + if \
($oldend > 0 && $oldend <= $now) { + \
$expire_role_result = 'ok'; + }
+ }
+ }
+ }
$result = $expire_role_result;
}
}
@@ -7833,18 +7853,38 @@
$modify_section_result = \
&Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid);
if ($modify_section_result =~ /^ok/) {
if ($secchange == 1) {
- $$logmsg .= &mt('Section for [_1] switched from old section: \
[_2] to new section: [_3].',$uname,$oldsec,$sec).$linefeed; + if \
($sec eq '') { + $$logmsg .= &mt('Section for [_1] switched \
from (possibly expired) old section: [_2] to student role without a \
section.',$uname,$oldsec).$linefeed; + } else {
+ $$logmsg .= &mt('Section for [_1] switched from (possibly \
expired) old section: [_2] to new section: [_3].',$uname,$oldsec,$sec).$linefeed; + \
} } elsif ($oldsec eq '-1') {
- $$logmsg .= &mt('New student role for [_1] in section [_2] in \
course [_3].',$uname,$sec,$cid).$linefeed; + if ($sec eq '') {
+ $$logmsg .= &mt('New student role without a section for [_1] \
in course [_2].',$uname,$cid).$linefeed; + } else {
+ $$logmsg .= &mt('New student role for [_1] in section [_2] \
in course [_3].',$uname,$sec,$cid).$linefeed; + }
} else {
- $$logmsg .= &mt('Student [_1] assigned to unchanged section [_2] \
in course [_3].',$uname,$sec,$cid).$linefeed; + if ($sec eq '') {
+ $$logmsg .= &mt('Student [_1] assigned to course [_2] \
without a section.',$uname,$cid).$linefeed; + } else {
+ $$logmsg .= &mt('Student [_1] assigned to section [_2] in \
course [_3].',$uname,$sec,$cid).$linefeed; + }
}
} else {
- $$logmsg .= &mt('Error when attempting section change for [_1] from \
old section [_2] to new section: [_3] in course [_4] \
-error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed; + \
if ($secchange) { + $$logmsg .= &mt('Error when attempting \
section change for [_1] from old section "[_2]" to new section: "[_3]" in course [_4] \
-error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed; + \
} else { + $$logmsg .= &mt('Error when attempting to modify role \
for [_1] for section: "[_2]" in course [_3] -error:',$uname,$sec,$cid).' \
'.$modify_section_result.$linefeed; + }
}
$result = $modify_section_result;
} elsif ($secchange == 1) {
- $$logmsg .= &mt('Error when attempting to expire role for [_1] in old \
section [_2] in course [_3] -error: ',$uname,$oldsec,$cid).' \
'.$expire_role_result.$linefeed; + if ($oldsec eq '') {
+ $$logmsg .= &mt('Error when attempting to expire existing role \
without a section for [_1] in course [_3] -error: ',$uname,$cid).' \
'.$expire_role_result.$linefeed; + } else {
+ $$logmsg .= &mt('Error when attempting to expire existing role for \
[_1] in section [_2] in course [_3] -error: ',$uname,$oldsec,$cid).' \
'.$expire_role_result.$linefeed; + }
if ($expire_role_result eq 'refused') {
my $newsecurl = '/'.$cid;
$newsecurl =~ s/\_/\//g;
_______________________________________________
LON-CAPA-cvs mailing list
LON-CAPA-cvs@mail.lon-capa.org
http://mail.lon-capa.org/mailman/listinfo/lon-capa-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic