-
-ENDDOCUMENT
+
+'
+ );
}
- $r->print($end_page);
+ $r->print(''.
+ $end_page);
}
# ====================================================== Phase two: make course
@@ -569,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';
@@ -617,6 +626,8 @@ sub create_course {
crsquota => $env{'form.crsquota'},
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'},
@@ -644,116 +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;
}
- 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').'
'.
+ 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').'
'.
&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');
+ &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 .='