-
-ENDDOCUMENT
+
+'
+ );
}
- $r->print($end_page);
+ $r->print(''.
+ $end_page);
}
# ====================================================== Phase two: make course
@@ -568,8 +576,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 $crstype = 'Community';
my ($enrollstart,$enrollend,$startaccess,$endaccess);
+ my %domdefaults =
+ &Apache::lonnet::get_domain_defaults($env{'request.role.domain'});
if ($env{'form.phase'} eq 'coursetwo') {
$crstype='Course';
@@ -581,33 +591,6 @@ sub create_course {
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 +624,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'},
@@ -670,119 +655,180 @@ sub create_course {
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').'
'.
&Apache::loncommon::end_page());
}
sub print_intro_page {
- my $r = shift;
+ my ($r,$show_all_choices) = @_;
my $start_page =
- &Apache::loncommon::start_page('Create a New Course or Group Space');
+ &Apache::loncommon::start_page('Create a New Course or Community');
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
my $end_page =
&Apache::loncommon::end_page();
- my $helplink=&Apache::loncommon::help_open_topic('Create_Course_GroupSpace',&mt('Help on Creating Courses and Groups'));
+ my $helplink=&Apache::loncommon::help_open_topic('Create_Course_Community',&mt('Help on Creating Courses and Communities'));
- my @choices = ({ internal_name => 'courseone',
- name => &mt('Create a single course'),
- short_description =>
- &mt('Create a new course by completing an online form.'),
- },
- { internal_name => 'groupone',
- name => &mt('Create a single collaborative group space '),
- short_description =>
- &mt('Create a new group space for non-course use by completing an online form .'),
- },
- { internal_name => 'batchone',
- name => &mt('Create courses/groups by uploading an attributes file'),
- short_description =>
- &mt('Upload an attributes file containing specifications for one or more courses or groups in XML format'),
- help => 'Batch_Creation',
- },
+ # Create menu
+ my @menu;
+ @menu =
+ ({ categorytitle => 'Course/Community Creation',
+ items => [
+ {
+ linktext => 'Create a single course',
+ url => '/adm/createcourse?phase=courseone',
+ permission => 1,
+ #help => '',
+ icon => 'crsnew.png',
+ linktitle => 'Create a new course by completing an online form.'
+ },
+ {
+ linktext => 'Create a single community',
+ url => '/adm/createcourse?phase=groupone',
+ permission => $show_all_choices,
+ #help => '',
+ icon => 'crsnew.png',
+ linktitle => 'Create a new collaborative community by completing an online form.'
+ },
+ {
+ linktext => 'Create courses/communities by uploading an attributes file',
+ url => '/adm/createcourse?phase=batchone',
+ permission => 1,
+ help => 'Batch_Creation',
+ icon => 'uplcrs.png',
+ linktitle => 'Upload an attributes file containing specifications for one or more courses or communities in XML format.'
+ },
+ ]
+ },
+ { categorytitle => 'Course/Community Requests',
+ items => [
+ {
+ linktext => 'Approve or reject requests',
+ url => '/adm/createcourse?phase=requestdisplay',
+ permission => $show_all_choices,
+ #help => '',
+ icon => 'rcrs.png',
+ linktitle => 'Display course and community creation requests submitted by authorized users, held pending approval by a Domain Coordinator.'
+ },
+ {
+ linktext => 'View pending official course requests',
+ url => '/adm/createcourse?phase=pendingdisplay',
+ permission => $show_all_choices,
+ #help => '',
+ icon => 'edit-find.png',
+ alttext => '',
+ linktitle => 'Display official course requests submitted by authorized users, held pending validation of instructor status.'
+ },
+ ]
+ },
+ { categorytitle => 'Administration',
+ items => [
+ {
+ linktext => 'View creation log',
+ url => '/adm/createcourse?phase=creationlog',
+ permission => $show_all_choices,
+ #help => '',
+ icon => 'document-properties.png',
+ linktitle => 'Display information about when, how and by whom courses and communities were created in this domain.'
+ },
+ ]
+ },
+ );
+
+ $r->print(
+ $start_page
+ .$crumbs
+ .&Apache::lonhtmlcommon::generate_menu(@menu)
+ .$end_page
);
- my $options;
- foreach my $choice (@choices) {
- $options .='