-
-ENDDOCUMENT
+
+'
+ );
}
- $r->print($end_page);
+ $r->print(''.
+ $end_page);
}
# ====================================================== Phase two: make course
@@ -578,8 +600,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';
@@ -588,6 +612,7 @@ 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;
@@ -646,174 +671,688 @@ 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;
}
- my ($courseid,$crsudom,$crsunum);
+ my ($courseid,$crsudom,$crsunum,$code);
my ($success,$output) =
&Apache::loncommon::construct_course($args,\$logmsg,\$courseid,
\$crsudom,\$crsunum,
$env{'user.domain'},
- $env{'user.name'});
+ $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)) {
- $r->print(&mt('Assigning role of [_1] Coordinator to [_2] at [_3]: ',
- $crstype,$ccuname,$ccdomain).
- &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,
- 'cc').'
');
+ 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("Create Another $crstype").''.
&Apache::loncommon::end_page());
}
sub print_intro_page {
- my $r = shift;
+ my ($r,$show_all_choices,$cancreate,$permission) = @_;
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 $approve = 'Display requests awaiting approval';
+ if ($permission->{'create'}) {
+ $approve = 'Approve or reject requests';
+ }
+ my @menu;
+ @menu =
+ ({ categorytitle => 'Course/Community Creation',
+ items => [
+ {
+ linktext => 'Create a single course',
+ url => '/adm/createcourse?phase=courseone',
+ permission => $permission->{'create'},
+ #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 => $permission->{'create'} && $cancreate->{'Community'},
+ #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 => $permission->{'create'},
+ 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,
+ 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 .='