';
+ &finish_loading_course($r,$msg,$furl,$only_body);
}
- return OK;
+ $r->rflush();
+ return OK;
}
}
#
@@ -580,13 +1112,18 @@ ENDENTERKEY
if ($role =~ /^(au|ca|aa)$/) {
my $redirect_url = '/priv/';
if ($role eq 'au') {
- $redirect_url.=$env{'user.name'};
+ $redirect_url.=$env{'user.domain'}.'/'.$env{'user.name'};
} else {
- $where =~ /\/(.*)$/;
- $redirect_url .= $1;
+ $redirect_url .= $where;
}
$redirect_url .= '/';
- &redirect_user($r,&mt('Entering Construction Space'),
+ if ($env{'form.orgurl'} =~ /^\Q$redirect_url\E/) {
+ my ($path) = ($env{'form.orgurl'} =~ m{^(.+)/[^/]+$});
+ if (($path ne '') && (-e $Apache::lonnet::perlvar{'lonDocRoot'}.$path)) {
+ $redirect_url = $env{'form.orgurl'};
+ }
+ }
+ &redirect_user($r,&mt('Entering Authoring Space'),
$redirect_url);
return OK;
}
@@ -596,6 +1133,18 @@ ENDENTERKEY
$redirect_url);
return OK;
}
+ if ($role eq 'dh') {
+ my $redirect_url = '/adm/menu/';
+ &redirect_user($r,&mt('Loading Domain Helpdesk Menu'),
+ $redirect_url);
+ return OK;
+ }
+ if ($role eq 'da') {
+ my $redirect_url = '/adm/menu/';
+ &redirect_user($r,&mt('Loading Domain Helpdesk Assistant Menu'),
+ $redirect_url);
+ return OK;
+ }
if ($role eq 'sc') {
my $redirect_url = '/adm/grades?command=scantronupload';
&redirect_user($r,&mt('Loading Data Upload Page'),
@@ -618,22 +1167,45 @@ ENDENTERKEY
my $crumbtext = 'User Roles';
my $pagetitle = 'My Roles';
my $recent = &mt('Recent Roles');
+ my $standby = &mt('Role selected. Please stand by.');
my $show_course=&Apache::loncommon::show_course();
if ($show_course) {
$crumbtext = 'Courses';
$pagetitle = 'My Courses';
$recent = &mt('Recent Courses');
+ $standby = &mt('Course selected. Please stand by.');
+ }
+ if (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) {
+ $crumbtext = 'Access Denied';
+ $pagetitle = 'Unauthorized';
}
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}];
+
+ my %roles_in_env;
+ my $showcount = &roles_from_env(\%roles_in_env,$update);
+
my $swinfo=&Apache::lonmenu::rawconfig();
- my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
- my $standby=&mt('Role selected. Please stand by.');
- $standby=~s/\n/\\n/g;
- my $noscript=''.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').' '.&mt('As this is not the case, most functionality in the system will be unavailable.').' ';
+ my %domdefs=&Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ my $cattype = 'std';
+ if ($domdefs{'catauth'}) {
+ $cattype = $domdefs{'catauth'};
+ }
+ my ($funcs,$crumbsright);
+ unless (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) {
+ $funcs = &get_roles_functions($showcount,$cattype);
+ if ($env{'browser.mobile'}) {
+ $crumbsright = $funcs;
+ undef($funcs);
+ }
+ }
+ my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum,
+ bread_crumbs_component=>$crumbsright});
+ &js_escape(\$standby);
+ my $noscript=' '.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').' '.&mt('As this is not the case, most functionality in the system will be unavailable.').' ';
$r->print(<
+$funcs
@@ -653,8 +1225,22 @@ function enterrole (thisform,rolecode,bu
thisform.submit();
} else {
alert('$standby');
- }
+ }
}
+
+function rolesView (caller) {
+ if ((caller == 'showall') || (caller == 'noshowall')) {
+ document.rolechoice.display.value = caller;
+ } else {
+ if ((caller == 'doupdate') || (caller == 'requestauthor') ||
+ (caller == 'queued')) {
+ document.rolechoice.state.value = caller;
+ }
+ }
+ document.rolechoice.selectrole.value='';
+ document.rolechoice.submit();
+}
+
// ]]>
ENDHEADER
@@ -715,47 +1301,78 @@ ENDHEADER
}
}
}
-# -------------------------------------------------------- Choice or no choice?
if ($nochoose) {
$r->print("
".&mt('Sorry ...')."
\n".
- &mt('This action is currently not authorized.').''.
- &Apache::loncommon::end_page());
+ &mt('This action is currently not authorized.').'');
+ if ($error && $norolelist) {
+ $r->print('
'.
+ &mt('As your session was launched from a web page external to LON-CAPA some course content may be unavailable, including the resource you were trying to access.').
+ '
'.
+ '
'.
+ &mt('You may need to login to LON-CAPA directly, or re-launch from a different external system.').
+ '
');
}
$r->print(&Apache::loncommon::end_page());
return OK;
}
+sub roles_from_env {
+ my ($roleshash,$update) = @_;
+ my $count = 0;
+ if (ref($roleshash) eq 'HASH') {
+ foreach my $envkey (keys(%env)) {
+ if ($envkey =~ m{^user\.role\.(\w+)[./]}) {
+ next if ($1 eq 'gr');
+ $roleshash->{$envkey} = $env{$envkey};
+ my ($start,$end) = split(/\./,$env{$envkey});
+ unless ($end && $end<$update) {
+ $count ++;
+ }
+ }
+ }
+ }
+ return $count;
+}
+
sub gather_roles {
- my ($then,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones,$loncaparev) = @_;
+ my ($update,$refresh,$now,$reinit,$nochoose,$roles_in_env,$roletext,$sortrole,$roleclass,$futureroles,
+ $timezones,$loncaparev) = @_;
my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,'');
my $advanced = $env{'user.adv'};
my $tryagain = $env{'form.tryagain'};
my @ids = &Apache::lonnet::current_machine_ids();
- foreach my $envkey (sort(keys(%env))) {
- my $button = 1;
- my $switchserver='';
- my $switchwarning;
- my ($role_text,$role_text_end,$sortkey);
- if ($envkey=~/^user\.role\./) {
- my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend);
- &Apache::lonnet::role_status($envkey,$then,$refresh,$now,\$role,\$where,
+ if (ref($roles_in_env) eq 'HASH') {
+ my %adhocdesc;
+ foreach my $envkey (sort(keys(%{$roles_in_env}))) {
+ my $button = 1;
+ my $switchserver='';
+ my $switchwarning;
+ my ($role_text,$role_text_end,$sortkey,$role,$where,$trolecode,$tstart,
+ $tend,$tremark,$tstatus,$tpstart,$tpend);
+ &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
\$trolecode,\$tstatus,\$tstart,\$tend);
next if (!defined($role) || $role eq '' || $role =~ /^gr/);
- my $timezone = &role_timezone($where,$timezones);
$tremark='';
$tpstart=' ';
$tpend=' ';
- if ($tstart) {
- $tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone);
- }
- if ($tend) {
- $tpend=&Apache::lonlocal::locallocaltime($tend,$timezone);
- }
if ($env{'request.role'} eq $trolecode) {
$tstatus='selected';
}
@@ -948,7 +1605,14 @@ sub gather_roles {
if (($tstatus eq 'is')
|| ($tstatus eq 'selected')
|| ($tstatus eq 'future')
- || ($env{'form.showall'})) {
+ || ($env{'form.display'} eq 'showall')) {
+ my $timezone = &role_timezone($where,$timezones);
+ if ($tstart) {
+ $tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone);
+ }
+ if ($tend) {
+ $tpend=&Apache::lonlocal::locallocaltime($tend,$timezone);
+ }
if ($tstatus eq 'is') {
$tbg='LC_roles_is';
$possiblerole=$trolecode;
@@ -973,12 +1637,15 @@ sub gather_roles {
my $trole;
if ($role =~ /^cr\//) {
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
- if ($tremark) { $tremark.=' '; }
- $tremark.=&mt('Customrole defined by [_1].',$rauthor.':'.$rdomain);
+ unless ($rauthor eq $rdomain.'-domainconfig') {
+ if ($tremark) { $tremark.=' '; }
+ $tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);
+ }
}
$trole=Apache::lonnet::plaintext($role);
my $ttype;
my $twhere;
+ my $skipcal;
my ($tdom,$trest,$tsection)=
split(/\//,Apache::lonnet::declutter($where));
# First, Co-Authorship roles
@@ -992,7 +1659,7 @@ sub gather_roles {
}
#next if ($home eq 'no_host');
$home = &Apache::lonnet::hostname($home);
- $ttype='Construction Space';
+ $ttype='Authoring Space';
$twhere=&mt('User').': '.$trest.' '.&mt('Domain').
': '.$tdom.' '.
' '.&mt('Server').': '.$home;
@@ -1011,7 +1678,7 @@ sub gather_roles {
}
#next if ($home eq 'no_host');
$home = &Apache::lonnet::hostname($home);
- $ttype='Construction Space';
+ $ttype='Authoring Space';
$twhere=&mt('Domain').': '.$tdom.' '.&mt('Server').
': '.$home;
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
@@ -1020,7 +1687,32 @@ sub gather_roles {
} elsif ($trest) {
my $tcourseid=$tdom.'_'.$trest;
$ttype = &Apache::loncommon::course_type($tcourseid);
- $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
+ if ($role !~ /^cr/) {
+ $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
+ } elsif ($role =~ m{^\Qcr/$tdom/$tdom\E\-domainconfig/(\w+)$}) {
+ my $rolename = $1;
+ my $desc;
+ if (ref($adhocdesc{$tdom}) eq 'HASH') {
+ $desc = $adhocdesc{$tdom}{$rolename};
+ } else {
+ my %domdef = &Apache::lonnet::get_domain_defaults($tdom);
+ if (ref($domdef{'adhocroles'}) eq 'HASH') {
+ foreach my $rolename (sort(keys(%{$domdef{'adhocroles'}}))) {
+ if (ref($domdef{'adhocroles'}{$rolename}) eq 'HASH') {
+ $adhocdesc{$tdom}{$rolename} = $domdef{'adhocroles'}{$rolename}{'desc'};
+ }
+ }
+ $desc = $adhocdesc{$tdom}{$rolename};
+ }
+ }
+ if ($desc ne '') {
+ $trole = $desc;
+ } else {
+ $trole = &mt('Helpdesk[_1]',' '.$rolename);
+ }
+ } else {
+ $trole = (split(/\//,$role,4))[-1];
+ }
if ($env{'course.'.$tcourseid.'.description'}) {
my $home=$env{'course.'.$tcourseid.'.home'};
$twhere=$env{'course.'.$tcourseid.'.description'};
@@ -1032,10 +1724,12 @@ sub gather_roles {
'';
unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') {
my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};
- ($switchserver,$switchwarning) =
- &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
- if ($switchserver || $switchwarning) {
- $button = 0;
+ if ($required ne '') {
+ ($switchserver,$switchwarning) =
+ &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ if ($switchserver || $switchwarning) {
+ $button = 0;
+ }
}
}
}
@@ -1053,10 +1747,12 @@ sub gather_roles {
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,$required);
- if ($switchserver || $switchwarning) {
- $button = 0;
+ if ($required ne '') {
+ ($switchserver,$switchwarning) =
+ &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ if ($switchserver || $switchwarning) {
+ $button = 0;
+ }
}
}
} else {
@@ -1064,6 +1760,7 @@ sub gather_roles {
$env{'course.'.$tcourseid.'.description'}=$twhere;
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
$ttype = 'Unavailable';
+ $skipcal = 1;
}
}
if ($tsection) {
@@ -1082,7 +1779,8 @@ sub gather_roles {
($role_text,$role_text_end) =
&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,
$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,
- $tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning);
+ $tpend,$nochoose,$button,$switchserver,$reinit,
+ $switchwarning,$skipcal);
$roletext->{$envkey}=[$role_text,$role_text_end];
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
$sortrole->{$sortkey}=$envkey;
@@ -1102,9 +1800,15 @@ sub role_timezone {
my $cnum = $2;
if ($cdom && $cnum) {
if (!exists($timezones->{$cdom.'_'.$cnum})) {
- my %timehash =
- &Apache::lonnet::get('environment',['timezone'],$cdom,$cnum);
- if ($timehash{'timezone'} eq '') {
+ my $tz;
+ if ($env{'course.'.$cdom.'_'.$cnum.'.description'}) {
+ $tz = $env{'course.'.$cdom.'_'.$cnum.'.timezone'};
+ } else {
+ my %timehash =
+ &Apache::lonnet::get('environment',['timezone'],$cdom,$cnum);
+ $tz = $timehash{'timezone'};
+ }
+ if ($tz eq '') {
if (!exists($timezones->{$cdom})) {
my %domdefaults =
&Apache::lonnet::get_domain_defaults($cdom);
@@ -1117,7 +1821,7 @@ sub role_timezone {
$timezones->{$cdom.'_'.$cnum} = $timezones->{$cdom};
} else {
$timezones->{$cdom.'_'.$cnum} =
- &Apache::lonlocal::gettimezone($timehash{'timezone'});
+ &Apache::lonlocal::gettimezone($tz);
}
}
$timezone = $timezones->{$cdom.'_'.$cnum};
@@ -1148,7 +1852,7 @@ sub roletable_headers {
my $doheaders;
if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) {
$r->print(' '
- .&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table('LC_textsize_mobile')
.&Apache::loncommon::start_data_table_header_row()
);
if (!$nochoose) { $r->print('
'); }
@@ -1174,12 +1878,12 @@ sub roletable_headers {
}
sub roletypes {
- my @types = ('Domain','Construction Space','Course','Community','Unavailable','System');
+ my @types = ('Domain','Authoring Space','Course','Community','Unavailable','System');
return @types;
}
sub print_rolerows {
- my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext) = @_;
+ my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext,$update,$then) = @_;
if ((ref($roleclass) eq 'HASH') && (ref($sortrole) eq 'HASH')) {
my @types = &roletypes();
foreach my $type (@types) {
@@ -1197,12 +1901,14 @@ sub print_rolerows {
&Apache::loncommon::end_data_table_row();
}
}
- if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) {
+ if ($sortrole->{$which} =~ m{^user\.role\.dc\./($match_domain)/}) {
if (ref($dcroles) eq 'HASH') {
if ($dcroles->{$1}) {
$output .= &adhoc_roles_row($1,'');
}
}
+ } elsif ($sortrole->{$which} =~ m{^user\.role\.(dh|da)\./($match_domain)/}) {
+ $output .= &adhoc_customroles_row($1,$2,'',$update,$then);
}
}
}
@@ -1223,52 +1929,57 @@ sub print_rolerows {
}
sub findcourse_advice {
- my ($r) = @_;
+ my ($r,$cattype,$elapsed) = @_;
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
if (&Apache::lonnet::auto_run(undef,$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).'
+ $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).'
'.&mt('The course has yet to be created.').'
'.&mt('Automatic enrollment of registered students has not been enabled for the course.').'
'.&mt('You are in a section of course for which automatic enrollment in the corresponding LON-CAPA course is not active.').'
'.&mt('The start date for automated enrollment has yet to be reached.').'
'.&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.').'
-
');
+
'.&mt('Automated enrollment added you to the course in the time since you last logged-in.').' '.&mt('If that is the case you can use the "Check for changes" link in the gray Functions bar to update the list of your available course roles.').'
+ ');
} 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.').' ');
+ $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.').'
');
+ if ($elapsed > 600) {
+ $r->print('
'.&mt('You may also have been assigned to a course in the time since you last logged-in, or checked for changes.').
+ ' '.
+ &mt('If that is the case you can use the "Check for changes" link in the gray Functions bar to update the list of your available course roles.').'
'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','','',$domdesc).' ');
+ $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'
'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','','',$domdesc).' ');
- $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'
'.
- &Apache::loncoursequeueadmin::queued_selfenrollment());
return;
}
sub requestcourse_advice {
- my ($r) = @_;
+ my ($r,$cattype,$inrole,$elapsed) = @_;
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
- my (%can_request,%request_doms);
+ my (%can_request,%request_doms,$output);
&Apache::lonnet::check_can_request($env{'user.domain'},\%can_request,\%request_doms);
if (keys(%request_doms) > 0) {
my ($types,$typename) = &Apache::loncommon::course_types();
if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {
- $r->print('
'.&mt('Request creation of a course or community').'
'.
- '
'.&mt('You have rights to request the creation of courses and/or communities in the following domain(s):').'
');
my (@reqdoms,@reqtypes);
foreach my $type (sort(keys(%request_doms))) {
push(@reqtypes,$type);
if (ref($request_doms{$type}) eq 'ARRAY') {
my $domstr = join(', ',map { &Apache::lonnet::domain($_) } sort(@{$request_doms{$type}}));
- $r->print(
+ $output .=
'
'
.&mt('[_1]'.$typename->{$type}.'[_2] in domain: [_3]',
'',
'',
''.$domstr.'')
- .'
'.&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.','','').'');
+ }
+ if ($output) {
+ $r->print('
'.&mt('Request creation of a course or community').'
'.
+ '
'.
+ &mt('You have rights to request the creation of courses and/or communities in the following domain(s):').
+ '
'.
+ $output.
+ '
'.
+ &mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.',
+ '','').
+ '');
+ }
+ }
+ } elsif (!$env{'user.adv'}) {
+ if ($inrole) {
+ $r->print('
'.&mt('Currently no additional roles, courses or communities').'
');
+ } else {
+ $r->print('
'.&mt('Currently no active roles, courses or communities').'
');
}
+ &findcourse_advice($r,$cattype,$elapsed);
}
return;
}
@@ -1313,7 +2041,7 @@ sub privileges_info {
my (undef,$tdom,$trest,$tsec)=split(m{/},$where);
if ($trest) {
if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {
- $ttype='Construction Space';
+ $ttype='Authoring Space';
$twhere='User: '.$trest.', Domain: '.$tdom;
} else {
$ttype= &Apache::loncommon::course_type($tdom.'_'.$trest);
@@ -1354,10 +2082,13 @@ sub privileges_info {
}
sub build_roletext {
- my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning) = @_;
- my ($roletext,$roletext_end);
- my $is_dc=($trolecode =~ m/^dc\./);
- my $rowspan=($is_dc) ? ''
+ my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,
+ $tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning,$skipcal) = @_;
+ my ($roletext,$roletext_end,$poss_adhoc);
+ if ($trolecode =~ m/^d(c|h|a)\./) {
+ $poss_adhoc = 1;
+ }
+ my $rowspan=($poss_adhoc) ? ''
: ' rowspan="2" ';
unless ($nochoose) {
@@ -1410,7 +2141,7 @@ sub build_roletext {
$trolecode."','".$buttonname.'\');" />';
}
}
- if ($trolecode !~ m/^(dc|ca|au|aa)\./) {
+ if (($trolecode !~ m/^(ca|aa)\./) && ($trest ne '') && (!$skipcal)) {
$tremark.=&Apache::lonannounce::showday(time,1,
&Apache::lonannounce::readcalendar($tdom.'_'.$trest));
}
@@ -1418,7 +2149,7 @@ sub build_roletext {
.'