-
-ENDDOCUMENT
+
+'
+ );
}
- $r->print($end_page);
+ $r->print(''.
+ $end_page);
}
# ====================================================== Phase two: make course
@@ -568,8 +596,10 @@ sub create_course {
my $r=shift;
my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
- my $crstype = 'Group';
- my ($enrollstart,$enrollend,$startaccess,$endaccess);
+ my $crstype = 'Community';
+ my ($enrollstart,$enrollend,$startaccess,$endaccess,$openallfrom);
+ my %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
if ($env{'form.phase'} eq 'coursetwo') {
$crstype='Course';
@@ -578,36 +608,10 @@ sub create_course {
}
$startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
$endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
+ $openallfrom = &Apache::lonhtmlcommon::get_date_from_form('openallfrom');
my $autharg;
my $authtype;
- my ($clonecourse,$clonedomain,$clonemsg);
-
- if (($env{'form.clonecourse'} ne '') && ($env{'form.clonedomain'} ne '')) {
- my $clonehome=&Apache::lonnet::homeserver($env{'form.clonecourse'},$env{'form.clonedomain'});
- if ($clonehome eq 'no_host') {
- $clonemsg = &mt('The new course was not cloned from an existing course because the requested course from which to create the clone does not appear to be a valid course.');
- } else {
- my %clonedesc = &Apache::lonnet::coursedescription($env{'form.clonedomain'}.'_'.$env{'form.clonecourse'},{'one_time' => 1});
- if ($env{'request.role.domain'} eq $env{'form.clonedomain'}) {
- $clonecourse = $env{'form.clonecourse'};
- $clonedomain = $env{'form.clonedomain'};
- } else {
- my %clonehash = &Apache::lonnet::get('environment',['cloners'],
- $env{'form.clonedomain'},$env{'form.clonecourse'});
- my @cloners = split(/,/,$clonehash{'cloners'});
- my %roleshash =
- &Apache::lonnet::get_my_roles($ccuname,$ccdomain,'userroles',
- ['active'],['cc'],[$env{'form.clonedomain'}]);
- if (($roleshash{$env{'form.clonecourse'}.':'.$env{'form.clonedomain'}.':cc'}) || (grep(/^\Q$ccuname\E:\Q$ccdomain\E$/,@cloners))) {
- $clonecourse = $env{'form.clonecourse'};
- $clonedomain = $env{'form.clonedomain'};
- } else {
- $clonemsg = &mt('The new course was not cloned from an existing course because the course owner ([_1]) does not have cloning rights in the existing course ([_2]).',$ccuname.':'.$ccdomain,$clonedesc{'description'});
- }
- }
- }
- }
if ($env{'form.login'} eq 'krb') {
$authtype = 'krb';
@@ -641,8 +645,10 @@ sub create_course {
nonstandard => $env{'form.nonstandard'},
crscode => $env{'form.crscode'},
crsquota => $env{'form.crsquota'},
- clonecourse => $clonecourse,
- clonedomain => $clonedomain,
+ clonecourse => $env{'form.clonecourse'},
+ clonedomain => $env{'form.clonedomain'},
+ datemode => $env{'form.datemode'},
+ dateshift => $env{'form.dateshift'},
crsid => $env{'form.crsid'},
curruser => $env{'user.name'}.':'.$env{'user.domain'},
crssections => $env{'form.crssections'},
@@ -661,128 +667,195 @@ sub create_course {
endaccess => $endaccess,
setpolicy => $env{'form.setpolicy'},
setcontent => $env{'form.setcontent'},
+ setcomment => $env{'form.setcomment'},
reshome => $env{'form.reshome'},
setkeys => $env{'form.setkeys'},
keyauth => $env{'form.keyauth'},
disresdis => $env{'form.disresdis'},
disablechat => $env{'form.disablechat'},
openall => $env{'form.openall'},
+ openallfrom => $openallfrom,
firstres => $env{'form.firstres'}
};
+ if (($crstype eq 'Course') &&
+ ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'})) {
+ $args->{'defaultcredits'} = $env{'form.defaultcredits'};
+ }
+
+ if ($env{'form.uniquecode'}) {
+ $args->{'uniquecode'} = 1;
+ }
+
#
# Verify data
#
# Check the veracity of the course coordinator
if (&Apache::lonnet::homeserver($ccuname,$ccdomain) eq 'no_host') {
$r->print(''.&Apache::loncommon::end_page());
+ $r->print('
'
+ .&mt('No such user [_1] at domain [_2].',''.$ccuname.'',''.$ccdomain.'')
+ .'
');
+ $r->print(&mt('Please click Back on your browser and select another user, or [_1]Create User[_2]'
+ , ''
+ .''
+ .''
+ .''
+ )
+ .''.&Apache::loncommon::end_page()
+ );
return;
}
# Check the proposed home server for the course
my %host_servers =
&Apache::lonnet::get_servers($env{'request.role.domain'},'library');
if (! exists($host_servers{$env{'form.course_home'}})) {
- $r->print(&mt('Invalid home server for course').': '.
- $env{'form.course_home'}.&Apache::loncommon::end_page());
+ $r->print(&mt('Invalid home server for course: [_1]'
+ ,$env{'form.course_home'}.&Apache::loncommon::end_page()));
return;
}
- if ($clonemsg ne '') {
- $r->print('
'.$clonemsg.'
');
+ my ($courseid,$crsudom,$crsunum,$code);
+ my ($success,$output) =
+ &Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
+ \$crsudom,\$crsunum,
+ $env{'user.domain'},
+ $env{'user.name'},'dc_create',undef,undef,\$code);
+ $r->print($output);
+ if ($success) {
+ #
+ # Make the requested user a course coordinator or group coordinator
+ #
+ if (($ccdomain) && ($ccuname)) {
+ my $ccrole = 'cc';
+ if ($crstype eq 'Community') {
+ $ccrole = 'co';
+ }
+ $r->print(&mt('Assigning role of '.$crstype.' Coordinator to [_1]:',
+ ,''.$ccuname.':'.$ccdomain.'')
+ .&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
+ $ccrole,'','','','','createcourse').'
'.&mt('Course identifier to share with students: [_1]',$code).'
'
+ );
+ }
+ # Flush the course logs so reverse user roles immediately updated
+ $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
+ $r->print('
'.&mt('Roles will be active at next login').'.
');
}
- my ($courseid,$crsudom,$crsunum);
- $r->print(&Apache::loncommon::construct_course($args,\$logmsg,\$courseid,\$crsudom,\$crsunum,$env{'user.domain'},$env{'user.name'}));
-
-#
-# Make the requested user a course coordinator or group coordinator
-#
- if (($ccdomain) && ($ccuname)) {
- $r->print(&mt('Assigning role of [_1] Coordinator to [_2] at [_3]:',
- $crstype,$ccuname,$ccdomain).
- &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
- 'cc').'