";
+ }
+ my $end_page = &Apache::loncommon::end_page();
# Note to style police:
# This must only replace the spaces, nothing else, or it bombs elsewhere.
$url=~s/ /\%20/g;
$r->print(<$msg
$end_page
ENDREDIR
return;
@@ -171,35 +238,36 @@ ENDREDIR
sub error_page {
my ($r,$error,$dest)=@_;
- &Apache::loncommon::content_type($r,'text/html');
- &Apache::loncommon::no_cache($r);
- $r->send_http_header;
- return OK if $r->header_only;
- # Breadcrumbs
- my $brcrum = [{'href' => $dest,
- 'text' => 'Problems during Course Initialization'},];
- $r->print(&Apache::loncommon::start_page('Problems during Course Initialization',
- undef,
- {'bread_crumbs' => $brcrum,})
- );
- $r->print(
- ''.
- '
';
+ &finish_loading_course($r,$msg,$furl);
+ }
}
+ $r->rflush();
return OK;
}
}
@@ -630,7 +1102,7 @@ ENDENTERKEY
$redirect_url .= $where;
}
$redirect_url .= '/';
- &redirect_user($r,&mt('Entering Construction Space'),
+ &redirect_user($r,&mt('Entering Authoring Space'),
$redirect_url);
return OK;
}
@@ -640,6 +1112,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'),
@@ -662,11 +1146,17 @@ 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}];
@@ -674,10 +1164,48 @@ ENDENTERKEY
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 $funcs = &get_roles_functions($showcount);
- my $standby=&mt('Role selected. Please stand by.');
- $standby=~s/\n/\\n/g;
+ my %domdefs=&Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ my $cattype = 'std';
+ if ($domdefs{'catauth'}) {
+ $cattype = $domdefs{'catauth'};
+ }
+ my $placementonly;
+ if ($showcount == 1) {
+ if ($env{'request.course.id'}) {
+ if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Placement') {
+ $placementonly = 1;
+ }
+ } else {
+ foreach my $rolecode (keys(%roles_in_env)) {
+ my ($cid) = ($rolecode =~ m{^\Quser.role.st./\E($match_domain/$match_courseid)(?:/|$)});
+ if ($cid) {
+ my %coursedescription =
+ &Apache::lonnet::coursedescription($cid,{'one_time' => '1'});
+ if ($coursedescription{'type'} eq 'Placement') {
+ $placementonly = 1;
+ }
+ last;
+ }
+ }
+ }
+ }
+ my ($start_page,$funcs);
+ if ($placementonly) {
+ $start_page=&Apache::loncommon::start_page($pagetitle,undef,
+ {bread_crumbs=>$brcrum,crstype=>'Placement'});
+ } else {
+ my $crumbsright;
+ unless (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) {
+ $funcs = &get_roles_functions($showcount,$cattype);
+ if ($env{'browser.mobile'}) {
+ $crumbsright = $funcs;
+ undef($funcs);
+ }
+ }
+ $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(<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.').
+ '
'.
+ &mt('The [_1] you selected is not available for access with a [_2] role from your current IP address: [_3].',
+ lc($blocked_type),$blocked_role,$clientip).
+ '
'
- .&mt('[_1]Visit the [_2]Course/Community Catalog[_3]'
- .' to view all [_4] LON-CAPA courses and communities.'
+ .&mt('[_1]Visit the [_2]Course/Community Catalog[_3][_4]'
+ .' to view all [_5] LON-CAPA courses and communities.'
,''
,''
- ,'',$domdesc)
+ ,''
+ ,''
+ ,'"'.$domdesc.'"')
.' '
.&mt('If a course or community is [_1]not[_2] in your list of current courses and communities below,'
.' you may be able to enroll if self-enrollment is permitted.'
@@ -839,22 +1401,40 @@ ENDHEADER
}
}
+ if ($norolelist) {
+ if ($env{'request.role'}) {
+ my ($roletext,$role_text_end) = &display_curr_role($env{'request.role'});
+ if ($roletext) {
+ $r->print(&Apache::loncommon::start_data_table('LC_textsize_mobile').
+ &Apache::loncommon::start_data_table_row().
+ $roletext.
+ &Apache::loncommon::end_data_table_row());
+ if ($role_text_end) {
+ $r->print(&Apache::loncommon::continue_data_table_row().
+ $role_text_end.
+ &Apache::loncommon::end_data_table_row());
+ }
+ $r->print(&Apache::loncommon::end_data_table());
+ }
+ }
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ }
+
# No active roles
if ($countactive==0) {
- 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);
- &requestcourse_advice($r);
+ my $elapsed = 0;
+ if ($now && $update) {
+ $elapsed = $now - $update;
+ }
+ &requestcourse_advice($r,$cattype,$inrole,$elapsed);
$r->print('');
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);
+ \%roletext,$update,$then);
my $tremark='';
my $tbg;
if ($env{'request.role'} eq 'cm') {
@@ -876,13 +1456,25 @@ ENDHEADER
}
$r->print(&Apache::loncommon::end_page());
return OK;
+ } elsif (($placementonly) && ($env{'request.role'} eq 'cm')) {
+ $r->print('
');
+ .'');
}
$r->print(&Apache::loncommon::end_page());
return OK;
@@ -1023,7 +1613,9 @@ sub gather_roles {
my $advanced = $env{'user.adv'};
my $tryagain = $env{'form.tryagain'};
my @ids = &Apache::lonnet::current_machine_ids();
+ my (%willtrust,%trustchecked);
if (ref($roles_in_env) eq 'HASH') {
+ my %adhocdesc;
foreach my $envkey (sort(keys(%{$roles_in_env}))) {
my $button = 1;
my $switchserver='';
@@ -1075,31 +1667,49 @@ 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
if (($role eq 'ca') || ($role eq 'aa')) {
my $home = &Apache::lonnet::homeserver($trest,$tdom);
my $allowed=0;
+ my $prohibited;
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
$button=0;
- $switchserver='otherserver='.$home.'&role='.$trolecode;
+ unless ($trustchecked{$tdom}) {
+ if ((&Apache::lonnet::will_trust('othcoau',$env{'user.domain'},$tdom)) &&
+ (&Apache::lonnet::will_trust('coaurem',$tdom,$env{'user.domain'}))) {
+ $willtrust{$tdom} = 1;
+ $trustchecked{$tdom} = 1;
+ }
+ }
+ if ($willtrust{$tdom}) {
+ $switchserver='otherserver='.$home.'&role='.$trolecode;
+ } else {
+ $prohibited = 1;
+ $tremark .= &mt('Session switch required but prohibited.');
+ }
}
#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;
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
- $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
+ unless ($prohibited) {
+ $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
+ }
$sortkey=$role."$trest:$tdom";
} elsif ($role eq 'au') {
# Authors
@@ -1113,7 +1723,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';
@@ -1122,7 +1732,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'};
@@ -1136,7 +1771,7 @@ sub gather_roles {
my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};
if ($required ne '') {
($switchserver,$switchwarning) =
- &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
if ($switchserver || $switchwarning) {
$button = 0;
}
@@ -1159,7 +1794,7 @@ sub gather_roles {
my $required = $newhash{'internal.releaserequired'};
if ($required ne '') {
($switchserver,$switchwarning) =
- &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
if ($switchserver || $switchwarning) {
$button = 0;
}
@@ -1170,8 +1805,12 @@ sub gather_roles {
$env{'course.'.$tcourseid.'.description'}=$twhere;
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
$ttype = 'Unavailable';
+ $skipcal = 1;
}
}
+ if ($ttype eq 'Placement') {
+ $ttype = 'Placement Test';
+ }
if ($tsection) {
$twhere.=' '.&mt('Section').': '.$tsection;
}
@@ -1188,7 +1827,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;
@@ -1260,7 +1900,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('
'); }
@@ -1286,12 +1926,12 @@ sub roletable_headers {
}
sub roletypes {
- my @types = ('Domain','Construction Space','Course','Community','Unavailable','System');
+ my @types = ('Domain','Authoring Space','Course','Placement Test','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) {
@@ -1309,12 +1949,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);
}
}
}
@@ -1335,52 +1977,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;
}
@@ -1425,7 +2089,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);
@@ -1466,10 +2130,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) {
@@ -1522,7 +2189,7 @@ sub build_roletext {
$trolecode."','".$buttonname.'\');" />';
}
}
- if ($trolecode !~ m/^(dc|ca|au|aa)\./) {
+ if (($trolecode !~ m/^(dc|ca|au|aa)\./) && (!$skipcal)) {
$tremark.=&Apache::lonannounce::showday(time,1,
&Apache::lonannounce::readcalendar($tdom.'_'.$trest));
}
@@ -1530,7 +2197,7 @@ sub build_roletext {
.'