[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Wed, 14 May 2008 23:52:52 -0000
This is a MIME encoded message
--raeburn1210809172
Content-Type: text/plain
raeburn Wed May 14 19:52:52 2008 EDT
Modified files:
/loncom/auth lonroles.pm
Log:
- If user has no active roles, now display any future roles, and a link to the course catalog.
- if automated enrollment is in use in the user's domain, display a message about reasons why enrollment might not have occurred so far.
- moved some code from handler() into subroutines - roletable_headers(), print_rolerows() and roletypes().
--raeburn1210809172
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20080514195252.txt"
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.190 loncom/auth/lonroles.pm:1.191
--- loncom/auth/lonroles.pm:1.190 Wed May 14 18:26:48 2008
+++ loncom/auth/lonroles.pm Wed May 14 19:52:52 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.190 2008/05/14 22:26:48 www Exp $
+# $Id: lonroles.pm,v 1.191 2008/05/14 23:52:52 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -530,8 +530,12 @@
my (%roletext,%sortrole,%roleclass);
my $countactive=0;
+ my $countfuture=0;
+ my $countwill=0;
my $inrole=0;
my $possiblerole='';
+ my %futureroles;
+ my %roles_nextlogin;
foreach $envkey (sort keys %env) {
my $button = 1;
my $switchserver='';
@@ -568,9 +572,13 @@
} elsif ($tstatus eq 'future') {
$tbg='#FFFF77';
$button=0;
+ $futureroles{$trolecode} = $tstart.':'.$tend;
+ $countfuture ++;
} elsif ($tstatus eq 'will') {
$tbg='#FFAA77';
$tremark.=&mt('Active at next login. ');
+ $roles_nextlogin{$trolecode} = $tstart.':'.$tend;
+ $countwill ++;
} elsif ($tstatus eq 'expired') {
$tbg='#FF7777';
$tfont='#330000';
@@ -693,7 +701,30 @@
} else {
$r->print('<h2>'.&mt('Currently no active roles or courses').'</h2>');
}
- $r->print('</form>'.&Apache::loncommon::end_page());
+ &findcourse_advice($r);
+ $r->print('</form>');
+ if ($countfuture) {
+ $r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
+ my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,
+ $nochoose);
+ &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,
+ \%roletext);
+ my $tremark='';
+ my $tfont='#003300';
+ if ($env{'request.role'} eq 'cm') {
+ $r->print('<tr bgcolor="#11CC55">');
+ $tremark=&mt('Currently selected. ');
+ $tfont='#002200';
+ } else {
+ $r->print('<tr bgcolor="#77FF77">');
+ }
+ $r->print('<td></td><td colspan="3"><font color="'.$tfont.'"><span class="LC_rolesinfo">'.&mt('No role specified').
+ '</font></span></td><td><font color="'.$tfont.'">'.$tremark.
+ ' </font></td></tr>'."\n");
+
+ $r->print('</table>');
+ }
+ $r->print(&Apache::loncommon::end_page());
return OK;
# Is there only one choice?
} elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) {
@@ -711,21 +742,7 @@
unless ((!&Apache::lonmenu::show_course()) || ($nochoose)) {
$r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
}
- $r->print('<br /><table id="LC_rolesmenu"><tr>');
- unless ($nochoose) { $r->print('<th> </th>'); }
- $r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent').
- '</th><th>'.&mt('Start').'</th><th>'.&mt('End').'</th></tr>'."\n");
- my $doheaders=-1;
- foreach my $type ('Domain','Construction Space','Course','Unavailable','System') {
- my $haverole=0;
- foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
- if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {
- $haverole=1;
- }
- }
- if ($haverole) { $doheaders++; }
- }
-
+ my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose);
if ($env{'environment.recentroles'}) {
my %recent_roles =
&Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
@@ -757,27 +774,7 @@
$r->print(&coursepick_jscript());
$r->print(&Apache::loncommon::coursebrowser_javascript());
}
- foreach my $type ('Construction Space','Domain','Course','Unavailable','System') {
- my $output;
- foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
- if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) {
- $output.=$roletext{$sortrole{$which}};
- if ($sortrole{$which} =~ m-dc\./($match_domain)/-) {
- if ($dcroles{$1}) {
- $output .= &allcourses_row($1,'').
- &allcoauthors_row($1,'');
- }
- }
- }
- }
- if ($output) {
- if ($doheaders > 0) {
- $r->print("<tr>".
- "<td align='center' colspan='5'><font face='arial'>".&mt($type)."</font></td></tr>");
- }
- $r->print($output);
- }
- }
+ &print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext);
my $tremark='';
my $tfont='#003300';
if ($env{'request.role'} eq 'cm') {
@@ -818,6 +815,88 @@
return OK;
}
+sub roletable_headers {
+ my ($r,$roleclass,$sortrole,$nochoose) = @_;
+ my $doheaders;
+ if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) {
+ $r->print('<br /><table id="LC_rolesmenu"><tr>');
+ if (!$nochoose) { $r->print('<th> </th>'); }
+ $r->print('<th>'.&mt('User Role').'</th><th>'.&mt('Extent')
+ .'</th><th>'.&mt('Start').'</th><th>'.&mt('End')
+ .'</th></tr>'."\n");
+ $doheaders=-1;
+ my @roletypes = &roletypes();
+ foreach my $type (@roletypes) {
+ my $haverole=0;
+ foreach my $which (sort {uc($a) cmp uc($b)} (keys(%{$sortrole}))) {
+ if ($roleclass->{$sortrole->{$which}} =~ /^\Q$type\E/) {
+ $haverole=1;
+ }
+ }
+ if ($haverole) { $doheaders++; }
+ }
+ }
+ return $doheaders;
+}
+
+sub roletypes {
+ my @types = ('Domain','Construction Space','Course','Unavailable','System');
+ return @types;
+}
+
+sub print_rolerows {
+ my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext) = @_;
+ if ((ref($roleclass) eq 'HASH') && (ref($sortrole) eq 'HASH')) {
+ my @types = &roletypes();
+ foreach my $type (@types) {
+ my $output;
+ foreach my $which (sort {uc($a) cmp uc($b)} (keys(%{$sortrole}))) {
+ if ($roleclass->{$sortrole->{$which}} =~ /^\Q$type\E/) {
+ if (ref($roletext) eq 'HASH') {
+ $output.=$roletext->{$sortrole->{$which}};
+ if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) {
+ if (ref($dcroles) eq 'HASH') {
+ if ($dcroles->{$1}) {
+ $output .= &allcourses_row($1,'').
+ &allcoauthors_row($1,'');
+ }
+ }
+ }
+ }
+ }
+ }
+ if ($output) {
+ if ($doheaders > 0) {
+ $r->print("<tr>".
+ "<td align='center' colspan='5'><font face='arial'>".
+ &mt($type)."</font></td></tr>");
+ }
+ $r->print($output);
+ }
+ }
+ }
+}
+
+sub findcourse_advice {
+ my ($r) = @_;
+ my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
+ if (&check_autoenroll($env{'user.domain'})) {
+ $r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).'
+<ul>
+ <li>'.&mt('The course has yet to be created.').'</li>
+ <li>'.&mt('Automatic enrollment of registered students has not been enabled for the course.').'</li>
+ <li>'.&mt('You are in a section of course for which automatic enrollment in the corresponding LON-CAPA course is not active.').'</li>
+ <li>'.&mt('The start date for automated enrollment has yet to be reached.').'</li>
+ <li>'.&mt('You registered for the course recently and there is a time lag between the time you register, and the time this information becomes available for the update of LON-CAPA course rosters.').'</li>
+ </ul>');
+ } else {
+ $r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').'<br />');
+ }
+ $r->print('<p>'.&mt('The [_1]Course Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created.','<a href="/adm/coursecatalog">','</a>',$domdesc).'<br />');
+ $r->print(&mt('You can search the course catalog for courses which permit self-enrollment, if you would like to enroll in a course.').'</p>');
+ return;
+}
+
sub privileges_info {
my ($which) = @_;
my $output;
@@ -1219,6 +1298,24 @@
return $startpage;
}
+sub check_autoenroll {
+ my ($dom) = @_;
+ my $run_enroll = 0;
+ my $settings;
+ my %domconfig =
+ &Apache::lonnet::get_dom('configuration',['autoenroll'],$dom);
+ if (ref($domconfig{'autoenroll'}) eq 'HASH') {
+ $settings = $domconfig{'autoenroll'};
+ if ($settings->{'run'} eq '1') {
+ $run_enroll = 1;
+ }
+ } else {
+ $run_enroll = &localenroll::run($dom);
+ }
+ return $run_enroll;
+}
+
+
1;
__END__
--raeburn1210809172--