--- loncom/interface/loncreatecourse.pm 2008/06/24 15:51:25 1.108
+++ loncom/interface/loncreatecourse.pm 2016/04/04 01:09:48 1.159
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Create a course
#
-# $Id: loncreatecourse.pm,v 1.108 2008/06/24 15:51:25 bisitz Exp $
+# $Id: loncreatecourse.pm,v 1.159 2016/04/04 01:09:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -27,6 +27,50 @@
#
###
+=head1 NAME
+
+Apache::loncreatecourse.pm
+
+=head1 SYNOPSIS
+
+Allows domain coordinators to create new
+courses and assign course coordinators.
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+=head1 SUBROUTINES
+
+=over
+
+=item handler()
+
+=item print_course_creation_page()
+
+=item create_course()
+
+=item print_intro_page()
+
+=item upload_batchfile()
+
+=item process_batchfile()
+
+=item courserequestbrowser_javascript()
+
+=item print_creation_logs()
+
+=item creation_display_filter()
+
+=item context_names()
+
+=item instcode_srchstr()
+
+=item syllabuslink_javascript()
+
+=back
+
+=cut
+
package Apache::loncreatecourse;
use strict;
@@ -44,11 +88,14 @@ use LONCAPA;
sub print_course_creation_page {
my $r=shift;
- my $crstype = 'Group';
+ my $crstype = 'Community';
if ($env{'form.phase'} eq 'courseone') {
$crstype = 'Course';
+ } elsif ($env{'form.phase'} eq 'placementone') {
+ $crstype = 'Placement';
}
my $defdom=$env{'request.role.domain'};
+ my %domdefaults = &Apache::lonnet::get_domain_defaults($defdom);
my %host_servers = &Apache::lonnet::get_servers($defdom,'library');
my $course_home = '
-
-
$lt{'mssg'}
-
-
-
-
-
-$lt{'cmmn'}
-
-
-
-
-
-$lt{'acco'}
-
-
-
-
-
-$lt{'rshm'}
-
-
-
-
-
$lt{'grts'}
-$lt{'grtq'}
-Mb
-
-
-$lt{'gc'}
-
-
-
-
-
+'
+ );
+ } elsif ($crstype eq 'Community') {
+ $r->print('
-
-
-
-ENDDOCUMENT
+
+'
+ );
+ } elsif ($crstype eq 'Placement') {
+ $r->print('
+
+
+
+
+
'
+ );
}
- $r->print($end_page);
+ $r->print(''.
+ $end_page);
}
# ====================================================== Phase two: make course
@@ -578,13 +622,17 @@ 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';
$enrollstart=&Apache::lonhtmlcommon::get_date_from_form('startenroll');
$enrollend=&Apache::lonhtmlcommon::get_date_from_form('endenroll');
+ } elsif ($env{'form.phase'} eq 'placementtwo') {
+ $crstype='Placement';
}
$startaccess = &Apache::lonhtmlcommon::get_date_from_form('startaccess');
$endaccess = &Apache::lonhtmlcommon::get_date_from_form('endaccess');
@@ -655,6 +703,15 @@ 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
#
@@ -683,97 +740,151 @@ sub create_course {
,$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','','','','','createcourse').'');
+ 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').'
');
}
if ($env{'form.setkeys'}) {
$r->print(
'
'.&mt('Manage Access Keys').'
');
}
+ if ($code) {
+ $r->print(
+ ''.&mt('Course identifier to share with students: [_1]',$code).'
'
+ );
+ }
# Flush the course logs so reverse user roles immediately updated
- &Apache::lonnet::flushcourselogs();
+ $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
$r->print(''.&mt('Roles will be active at next login').'.
');
}
$r->print(''.
- &mt('Create Another [_1]',$crstype).'
'.
+ &mt("Create Another $crstype").''.
&Apache::loncommon::end_page());
}
sub print_intro_page {
- my $r = shift;
+ my ($r,$show_all_choices,$cancreate) = @_;
my $start_page =
- &Apache::loncommon::start_page('Create a New Course or Group Space');
+ &Apache::loncommon::start_page('Create a New Course, Community or Placement Test');
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 => $cancreate->{'Community'},
+ #help => '',
+ icon => 'crsnew.png',
+ linktitle => 'Create a new collaborative community by completing an online form.'
+ },
+ {
+ linktext => 'Create a single placement test',
+ url => '/adm/createcourse?phase=placementone',
+ permission => $cancreate->{'Placement'},
+ #help => '',
+ icon => 'crsnew.png',
+ linktitle => 'Create a new placement test by completing an online form.'
+ },
+ {
+ linktext => 'Create courses/communities/placement tests 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, communities or placement tests 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, community creation and placement test 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, communities and placement tests were created in this domain.'
+ },
+ ]
+ },
+ );
+
+ $r->print(
+ $start_page
+ .$crumbs
+ .&Apache::lonhtmlcommon::generate_menu(@menu)
+ .$end_page
);
- my $options;
- foreach my $choice (@choices) {
- $options .=' '.
- $choice->{'name'}.'';
- if (exists($choice->{'help'})) {
- $options .= &Apache::loncommon::help_open_topic($choice->{'help'});
- }
- $options .= "
\n".' '.(' 'x8).$choice->{'short_description'}.
- "\n";
- }
-
- $r->print(<print($start_page.$crumbs);
- $r->print(''.&mt('Upload a courses or groups attributes file').'
');
+ $r->print(''.&mt('Upload a courses, communities or placement tests attributes file').'
');
$r->print('');
+ 'value="'.&mt('Create Courses/Communities/Placement Tests').'" />');
$r->print($end_page);
return;
}
@@ -781,7 +892,7 @@ sub upload_batchfile {
sub process_batchfile {
my $r = shift;
my $start_page =
- &Apache::loncommon::start_page('Create a New Course or Group Space');
+ &Apache::loncommon::start_page('Create a New Course, Community or Placement Test');
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
my $end_page =
&Apache::loncommon::end_page();
@@ -819,6 +930,381 @@ sub process_batchfile {
}
+sub courserequestbrowser_javascript {
+ return <<"ENDREQBRW";
+
+ENDREQBRW
+}
+
+sub print_creation_logs {
+ my ($r) = @_;
+ my $formname = 'creationlog';
+ my $dom = $env{'request.role.domain'};
+ $r->print('