+//
-\n");
+ $r->rflush();
+ $r->print('');
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
+ }
+ if ($needs_switchserver) {
+ $r->print("".&mt('Server Switch Required')." \n".
+ &mt('Construction Space access is only available from '.
+ 'the home server of the corresponding Author.').' '.
+ &mt("Click the 'Switch Server' link to go there.").' ');
+ }
}
# ----------------------------------------------------------------------- Table
- unless ((!&Apache::lonmenu::show_course()) || ($nochoose) || ($countactive==1)) {
+ unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {
$r->print("".&mt('Select a Course to Enter')." \n");
}
+ if ($env{'form.destinationurl'}) {
+ $r->print(' ');
+ if ($env{'form.destsymb'} ne '') {
+ $r->print(' ');
+ }
+ }
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose);
if ($env{'environment.recentroles'}) {
my %recent_roles =
@@ -904,7 +876,7 @@ ENDHEADER
if ($output) {
$r->print(&Apache::loncommon::start_data_table_empty_row()
.''
- .&mt('Recent Roles')
+ .$recent
.' '
.&Apache::loncommon::end_data_table_empty_row()
);
@@ -956,18 +928,194 @@ ENDHEADER
$r->print(&Apache::lonnet::getannounce());
if ($advanced) {
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
- $r->print(''
- .&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion'))
- .' '
- .''.&mt('Logout').' '
+ $r->print('
'
+ .&mt('This LON-CAPA server is version [_1]',$r->dir_config('lonVersion'))
+ .' '
+ .''.&mt('Logout').' '
.''
- .&mt('Course Catalog')
- .'
');
+ .&mt('Course/Community Catalog')
+ .'');
}
$r->print(&Apache::loncommon::end_page());
return OK;
}
+sub gci_info_page {
+ return <<"END";
+Welcome to the Geoscience Concept Inventory WebCenter
+
+Use the tabs to navigate the WebCenter and...
+
+Review and comment on existing GCI questions
+Submit a GCI question of your own
+Create an online test for your students
+
+
+For more information about writing and reviewing Concept Inventory questions
+please refer to the GCI Workbook .
+
+END
+}
+
+sub gather_roles {
+ my ($then,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones) = @_;
+ my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,'');
+ my $advanced = $env{'user.adv'};
+ my $tryagain = $env{'form.tryagain'};
+ foreach my $envkey (sort(keys(%env))) {
+ my $button = 1;
+ my $switchserver='';
+ 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,
+ \$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';
+ }
+ my $tbg;
+ if (($tstatus eq 'is')
+ || ($tstatus eq 'selected')
+ || ($tstatus eq 'future')
+ || ($env{'form.showall'})) {
+ if ($tstatus eq 'is') {
+ $tbg='LC_roles_is';
+ $possiblerole=$trolecode;
+ $countactive++;
+ } elsif ($tstatus eq 'future') {
+ $tbg='LC_roles_future';
+ $button=0;
+ $futureroles->{$trolecode} = $tstart.':'.$tend;
+ $countfuture ++;
+ } elsif ($tstatus eq 'expired') {
+ $tbg='LC_roles_expired';
+ $button=0;
+ } elsif ($tstatus eq 'will_not') {
+ $tbg='LC_roles_will_not';
+ $tremark.=&mt('Expired after logout.').' ';
+ } elsif ($tstatus eq 'selected') {
+ $tbg='LC_roles_selected';
+ $inrole=1;
+ $countactive++;
+ $tremark.=&mt('Currently selected.').' ';
+ }
+ my $trole;
+ if ($role =~ /^cr\//) {
+ my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
+ if ($tremark) { $tremark.=' '; }
+ $tremark.=&mt('Defined by [_1] at [_2].',$rauthor,$rdomain);
+ }
+ $trole=Apache::lonnet::plaintext($role);
+ my $ttype;
+ my $twhere;
+ 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 @ids=&Apache::lonnet::current_machine_ids();
+ foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+ if (!$allowed) {
+ $button=0;
+ $switchserver='otherserver='.$home.'&role='.$trolecode;
+ }
+ #next if ($home eq 'no_host');
+ $home = &Apache::lonnet::hostname($home);
+ $ttype='Construction Space';
+ $twhere=&mt('User').': '.$trest.' '.&mt('Domain').
+ ': '.$tdom.' '.
+ ' '.&mt('Server').': '.$home;
+ $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
+ $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
+ $sortkey=$role."$trest:$tdom";
+ } elsif ($role eq 'au') {
+ # Authors
+ my $home = &Apache::lonnet::homeserver
+ ($env{'user.name'},$env{'user.domain'});
+ my $allowed=0;
+ my @ids=&Apache::lonnet::current_machine_ids();
+ foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
+ if (!$allowed) {
+ $button=0;
+ $switchserver='otherserver='.$home.'&role='.$trolecode;
+ }
+ #next if ($home eq 'no_host');
+ $home = &Apache::lonnet::hostname($home);
+ $ttype='Construction Space';
+ $twhere=&mt('Domain').': '.$tdom.' '.&mt('Server').
+ ': '.$home;
+ $env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
+ $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$env{'user.name'}.'/');
+ $sortkey=$role;
+ } elsif ($trest) {
+ my $tcourseid=$tdom.'_'.$trest;
+ $ttype = &Apache::loncommon::course_type($tcourseid);
+ $trole = &Apache::lonnet::plaintext($role,$ttype);
+ if ($env{'course.'.$tcourseid.'.description'}) {
+ $twhere=$env{'course.'.$tcourseid.'.description'};
+ $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
+ unless ($twhere eq &mt('Currently not available')) {
+ $twhere.=' '.
+ &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
+ ' ';
+ }
+ } else {
+ my %newhash=&Apache::lonnet::coursedescription($tcourseid);
+ if (%newhash) {
+ $sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
+ "\0".$envkey;
+ $twhere=$newhash{'description'}.
+ ' '.
+ &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
+ ' ';
+ $ttype = $newhash{'type'};
+ $trole = &Apache::lonnet::plaintext($role,$ttype);
+ } else {
+ $twhere=&mt('Currently not available');
+ $env{'course.'.$tcourseid.'.description'}=$twhere;
+ $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
+ $ttype = 'Unavailable';
+ }
+ }
+ if ($tsection) {
+ $twhere.=' '.&mt('Section').': '.$tsection;
+ }
+ if ($role ne 'st') { $twhere.=" ".&mt('Domain').":".$tdom; }
+ } elsif ($tdom) {
+ $ttype='Domain';
+ $twhere=$tdom;
+ $sortkey=$role.$twhere;
+ } else {
+ $ttype='System';
+ $twhere=&mt('system wide');
+ $sortkey=$role.$twhere;
+ }
+ ($role_text,$role_text_end) =
+ &build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,
+ $advanced,$tremark,$tbg,$trole,$twhere,$tpstart,
+ $tpend,$nochoose,$button,$switchserver,$reinit);
+ $roletext->{$envkey}=[$role_text,$role_text_end];
+ if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
+ $sortrole->{$sortkey}=$envkey;
+ $roleclass->{$envkey}=$ttype;
+ }
+ }
+ }
+ return ($countactive,$countfuture,$inrole,$possiblerole);
+}
+
sub role_timezone {
my ($where,$timezones) = @_;
my $timezone;
@@ -1049,7 +1197,7 @@ sub roletable_headers {
}
sub roletypes {
- my @types = ('Domain','Construction Space','Course','Unavailable','System');
+ my @types = ('Domain','Construction Space','Course','Community','Unavailable','System');
return @types;
}
@@ -1111,12 +1259,66 @@ 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.').' ');
}
- $r->print('
'.&mt('The [_1]Course Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created.','',' ',$domdesc).' ');
- $r->print(&mt('You can search the course catalog for courses which permit self-enrollment, if you would like to enroll in a course.').'
');
+ $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.').'
');
&queued_selfenrollment($r);
return;
}
+sub requestcourse_advice {
+ 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);
+ &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(
+ ''
+ .&mt('[_1]'.$typename->{$type}.'[_2] in domain: [_3]',
+ '',
+ ' ',
+ ''.$domstr.' ')
+ .' '
+ );
+ foreach my $dom (@{$request_doms{$type}}) {
+ unless (grep(/^\Q$dom\E/,@reqdoms)) {
+ push(@reqdoms,$dom);
+ }
+ }
+ }
+ }
+ my @showtypes;
+ foreach my $type (@{$types}) {
+ if (grep(/^\Q$type\E$/,@reqtypes)) {
+ push(@showtypes,$type);
+ }
+ }
+ my $requrl = '/adm/requestcourse';
+ if (@reqdoms == 1) {
+ $requrl .= '?showdom='.$reqdoms[0];
+ }
+ if (@showtypes > 0) {
+ $requrl.=(($requrl=~/\?/)?'&':'?').'crstype='.$showtypes[0];
+ }
+ if (@reqdoms == 1 || @showtypes > 0) {
+ $requrl .= '&state=crstype&action=new';
+ }
+ $r->print(' '.&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.','',' ').'');
+ }
+ }
+ return;
+}
+
sub queued_selfenrollment {
my ($r) = @_;
my %selfenrollrequests = &Apache::lonnet::dump('selfenrollrequests');
@@ -1237,31 +1439,31 @@ sub build_roletext {
} elsif ($tstatus eq 'is') {
$roletext.=''.
' ';
} elsif ($tryagain) {
$roletext.=
''.
' ';
} elsif ($advanced) {
$roletext.=
''.
' ';
} elsif ($reinit) {
$roletext.=
''.
' ';
} else {
$roletext.=
''.
' ';
}
}
@@ -1338,21 +1540,22 @@ sub check_fordc {
}
sub adhoc_course_role {
- my ($then) = @_;
- my ($cdom,$cnum);
+ my ($refresh,$then) = @_;
+ my ($cdom,$cnum,$crstype);
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- if (&check_forcc($cdom,$cnum,$then)) {
+ $crstype = &Apache::loncommon::course_type();
+ if (&check_forcc($cdom,$cnum,$refresh,$then,$crstype)) {
my $setprivs;
if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
$setprivs = 1;
} else {
my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}});
- if (($start && ($start>$then || $start == -1)) ||
+ if (($start && ($start>$refresh || $start == -1)) ||
($end && $end<$then)) {
$setprivs = 1;
}
- }
+ }
if ($setprivs) {
if ($env{'form.switchrole'} =~ m-^(in|ta|ep|ad|st|cr)([\w/]*)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) {
my $role = $1;
@@ -1382,7 +1585,7 @@ sub adhoc_course_role {
}
&Apache::lonnet::standard_roleprivs(\%newrole,$role,$cdom,$spec,$cnum,$area);
&Apache::lonnet::set_userprivs(\%userroles,\%newrole,\%newgroups);
- my $adhocstart = $then-1;
+ my $adhocstart = $refresh-1;
$userroles{'user.role.'.$spec} = $adhocstart.'.';
&Apache::lonnet::appenv(\%userroles,[$role,'cm']);
}
@@ -1392,15 +1595,20 @@ sub adhoc_course_role {
}
sub check_forcc {
- my ($cdom,$cnum,$then) = @_;
- my $is_cc;
+ my ($cdom,$cnum,$refresh,$then,$crstype) = @_;
+ my ($is_cc,$ccrole);
+ if ($crstype eq 'Community') {
+ $ccrole = 'co';
+ } else {
+ $ccrole = 'cc';
+ }
if ($cdom ne '' && $cnum ne '') {
if (&Apache::lonnet::is_course($cdom,$cnum)) {
- my $envkey = 'user.role.cc./'.$cdom.'/'.$cnum;
+ my $envkey = 'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum;
if (defined($env{$envkey})) {
$is_cc = 1;
my ($tstart,$tend)=split(/\./,$env{$envkey});
- if ($tstart && $tstart>$then) { $is_cc = 0; }
+ if ($tstart && $tstart>$refresh) { $is_cc = 0; }
if ($tend && $tend <$then) { $is_cc = 0; }
}
}
@@ -1413,7 +1621,7 @@ sub courselink {
my $courseform=&Apache::loncommon::selectcourse_link
('rolechoice','dccourse'.$rowtype.'_'.$dcdom,
'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.
- $dcdom,$dcdom,undef);
+ $dcdom,$dcdom,undef,'Course/Community');
my $hiddenitems = ' '.
' '.
' '.
@@ -1423,11 +1631,12 @@ sub courselink {
sub coursepick_jscript {
my %lt = &Apache::lonlocal::texthash(
- plsu => "Please use the 'Select Course' link to open a separate pick course window where you may select the course you wish to enter.",
- youc => 'You can only use this screen to select courses in the current domain.',
+ 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.',
);
my $verify_script = <<"END";
END
return $verify_script;
@@ -1474,9 +1684,10 @@ sub display_cc_role {
my $advanced = $env{'user.adv'};
my $tryagain = $env{'form.tryagain'};
unless ($rolekey =~/^error\:/) {
- if ($rolekey =~ m-^user\.role.cc\./($match_domain)/($match_courseid)$-) {
- my $tcourseid = $1.'_'.$2;
- my $trolecode = 'cc./'.$1.'/'.$2;
+ if ($rolekey =~ m{^user\.role\.(cc|co)\./($match_domain)/($match_courseid)$}) {
+ my $ccrole = $1;
+ my $tcourseid = $2.'_'.$3;
+ my $trolecode = $1.'./'.$2.'/'.$3;
my $twhere;
my $ttype;
my $tbg='LC_roles_is';
@@ -1491,7 +1702,7 @@ sub display_cc_role {
$twhere=&mt('Currently not available');
$env{'course.'.$tcourseid.'.description'}=$twhere;
}
- my $trole = &Apache::lonnet::plaintext('cc',$ttype);
+ my $trole = &Apache::lonnet::plaintext($ccrole,$ttype);
$twhere.=" ".&mt('Domain').":".$1;
($roletext,$roletext_end) = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,'');
}
@@ -1503,21 +1714,15 @@ sub adhoc_roles_row {
my ($dcdom,$rowtype) = @_;
my $output = &Apache::loncommon::continue_data_table_row()
.' '
- .''
.&mt('[_1]Ad hoc[_2] roles in domain [_3] --'
,'',' ',$dcdom)
- .' '
- .'';
+ .' ';
my $selectcclink = &courselink($dcdom,$rowtype);
- my $ccrole = &Apache::lonnet::plaintext('cc');
+ my $ccrole = &Apache::lonnet::plaintext('co',undef,undef,1);
my $carole = &Apache::lonnet::plaintext('ca');
my $selectcalink = &coauthorlink($dcdom,$rowtype);
- $output.=&mt('[_1]: [_2]',$ccrole,$selectcclink)
- .' '
- .' '
- .''.&mt('[_1]: [_2]',$carole,$selectcalink).' '
- .'
'
- .' '
+ $output.=$ccrole.': '.$selectcclink
+ .' | '.$carole.': '.$selectcalink
.&Apache::loncommon::end_data_table_row();
return $output;
}