');
}
$r->print(&Apache::loncommon::end_page());
return OK;
@@ -1281,7 +1197,7 @@ sub gather_roles {
my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};
if ($required ne '') {
($switchserver,$switchwarning) =
- &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
if ($switchserver || $switchwarning) {
$button = 0;
}
@@ -1304,7 +1220,7 @@ sub gather_roles {
my $required = $newhash{'internal.releaserequired'};
if ($required ne '') {
($switchserver,$switchwarning) =
- &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
if ($switchserver || $switchwarning) {
$button = 0;
}
@@ -1405,7 +1321,7 @@ sub roletable_headers {
my $doheaders;
if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) {
$r->print(' '
- .&Apache::loncommon::start_data_table('LC_textsize_mobile')
+ .&Apache::loncommon::start_data_table()
.&Apache::loncommon::start_data_table_header_row()
);
if (!$nochoose) { $r->print('
'); }
@@ -1454,15 +1370,12 @@ sub print_rolerows {
&Apache::loncommon::end_data_table_row();
}
}
- if ($sortrole->{$which} =~ m{^user\.role\.dc\./($match_domain)/}) {
+ if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) {
if (ref($dcroles) eq 'HASH') {
if ($dcroles->{$1}) {
$output .= &adhoc_roles_row($1,'');
}
}
- } elsif (($sortrole->{$which} =~ m{^user\.role\.dh\./($match_domain)/}) &&
- ($env{'environment.adhocroles.'.$1} ne '')) {
- $output .= &adhoc_customroles_row($1,'');
}
}
}
@@ -1483,7 +1396,7 @@ sub print_rolerows {
}
sub findcourse_advice {
- my ($r,$cattype) = @_;
+ my ($r) = @_;
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'})) {
@@ -1498,36 +1411,37 @@ sub findcourse_advice {
} 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.').' ');
}
- if (($cattype eq 'std') || ($cattype eq 'domonly')) {
- $r->print('
'.&mt('Self-Enrollment').'
'.
- '
'.&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,$cattype,$inrole) = @_;
+ my ($r) = @_;
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
- my (%can_request,%request_doms,$output);
+ my (%can_request,%request_doms);
&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}}));
- $output .=
+ $r->print(
'
'
.&mt('[_1]'.$typename->{$type}.'[_2] in domain: [_3]',
'',
'',
''.$domstr.'')
- .'
'.&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.',
- '','').
- '');
- }
+ }
+ $r->print('
'.&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);
}
return;
}
@@ -1719,42 +1616,29 @@ sub check_author_homeserver {
}
}
-sub check_for_adhoc {
- my ($dcroles,$dhroles,$update,$then) = @_;
+sub check_fordc {
+ my ($dcroles,$update,$then) = @_;
my $numdc = 0;
- my $numdh = 0;
- my $numadhoc = 0;
- my $num_custom_adhoc = 0;
if ($env{'user.adv'}) {
- foreach my $envkey (sort(keys(%env))) {
- if ($envkey=~/^user\.role\.(dc|dh)\.\/($match_domain)\/$/) {
- my $role = $1;
- my $roledom = $2;
- my $liverole = 1;
+ foreach my $envkey (sort keys %env) {
+ if ($envkey=~/^user\.role\.dc\.\/($match_domain)\/$/) {
+ my $dcdom = $1;
+ my $livedc = 1;
my ($tstart,$tend)=split(/\./,$env{$envkey});
my $limit = $update;
- if ((($role eq 'dc') && ($env{'request.role'} eq 'dc./'.$roledom.'/')) ||
- (($role eq 'dh') && ($env{'request.role'} eq 'dh./'.$roledom.'/'))) {
+ if ($env{'request.role'} eq 'dc./'.$dcdom.'/') {
$limit = $then;
}
- if ($tstart && $tstart>$limit) { $liverole = 0; }
- if ($tend && $tend <$limit) { $liverole = 0; }
- if ($liverole) {
- if ($role eq 'dc') {
- $dcroles->{$roledom} = $envkey;
- $numdc++;
- } else {
- $dhroles->{$roledom} = $envkey;
- if ($env{'environment.adhocroles.'.$roledom} ne '') {
- $numadhoc ++;
- }
- $numdh++;
- }
+ if ($tstart && $tstart>$limit) { $livedc = 0; }
+ if ($tend && $tend <$limit) { $livedc = 0; }
+ if ($livedc) {
+ $$dcroles{$dcdom} = $envkey;
+ $numdc++;
}
}
}
}
- return ($numdc,$numdh,$numadhoc);
+ return $numdc;
}
sub adhoc_course_role {
@@ -1845,26 +1729,76 @@ sub check_forcc {
return $is_cc;
}
+sub check_release_required {
+ my ($loncaparev,$tcourseid,$trolecode,$required) = @_;
+ my ($switchserver,$warning);
+ if ($required ne '') {
+ my ($reqdmajor,$reqdminor) = ($required =~ /^(\d+)\.(\d+)$/);
+ my ($major,$minor) = ($loncaparev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/);
+ if ($reqdmajor ne '' && $reqdminor ne '') {
+ my $otherserver;
+ if (($major eq '' && $minor eq '') ||
+ (($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) {
+ my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'});
+ my $switchlcrev =
+ &Apache::lonnet::get_server_loncaparev($env{'user.domain'},
+ $userdomserver);
+ my ($swmajor,$swminor) = ($switchlcrev =~ /^\'?(\d+)\.(\d+)\.[\w.\-]+\'?$/);
+ if (($swmajor eq '' && $swminor eq '') || ($reqdmajor > $swmajor) ||
+ (($reqdmajor == $swmajor) && ($reqdminor > $swminor))) {
+ my $cdom = $env{'course.'.$tcourseid.'.domain'};
+ if ($cdom ne $env{'user.domain'}) {
+ my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom);
+ my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname);
+ my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);
+ my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);
+ my %udomdefaults = &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ my $remoterev = &Apache::lonnet::get_server_loncaparev($serverhomedom,$coursedomserver);
+ my $canhost =
+ &Apache::lonnet::can_host_session($env{'user.domain'},
+ $coursedomserver,
+ $remoterev,
+ $udomdefaults{'remotesessions'},
+ $defdomdefaults{'hostedsessions'});
+
+ if ($canhost) {
+ $otherserver = $coursedomserver;
+ } else {
+ $warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$tcourseid.'.internal.releaserequired'}).' '. &mt("No suitable server could be found amongst servers in either your own domain or in the course's domain.");
+ }
+ } else {
+ $warning = &mt('Requires LON-CAPA version [_1].',$env{'course.'.$tcourseid.'.internal.releaserequired'}).' '.&mt("No suitable server could be found amongst servers in your own domain (which is also the course's domain).");
+ }
+ } else {
+ $otherserver = $userdomserver;
+ }
+ }
+ if ($otherserver ne '') {
+ $switchserver = 'otherserver='.$otherserver.'&role='.$trolecode;
+ }
+ }
+ }
+ return ($switchserver,$warning);
+}
+
sub courselink {
- my ($roledom,$rowtype,$role) = @_;
+ my ($dcdom,$rowtype) = @_;
my $courseform=&Apache::loncommon::selectcourse_link
- ('rolechoice','course'.$rowtype.'_'.$roledom.'_'.$role,
- 'domain'.$rowtype.'_'.$roledom.'_'.$role,
- 'coursedesc'.$rowtype.'_'.$roledom.'_'.$role,
- $roledom.':'.$role,undef,'Course/Community');
- my $hiddenitems = ''.
- ''.
- ''.
- '';
+ ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,
+ 'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.
+ $dcdom,$dcdom,undef,'Course/Community');
+ my $hiddenitems = ''.
+ ''.
+ ''.
+ '';
return $courseform.$hiddenitems;
}
sub coursepick_jscript {
- my %js_lt = &Apache::lonlocal::texthash(
+ my %lt = &Apache::lonlocal::texthash(
plsu => "Please use the 'Select Course/Community' link to open a separate pick course window where you may select the course or community you wish to enter.",
youc => 'You can only use this screen to select courses and communities in the current domain.',
);
- &js_escape(\%js_lt);
my $verify_script = <<"END";