--- loncom/interface/loncreatecourse.pm 2014/01/30 19:00:09 1.156
+++ loncom/interface/loncreatecourse.pm 2017/11/17 01:02:28 1.158.2.3.2.2
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Create a course
#
-# $Id: loncreatecourse.pm,v 1.156 2014/01/30 19:00:09 bisitz Exp $
+# $Id: loncreatecourse.pm,v 1.158.2.3.2.2 2017/11/17 01:02:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -82,7 +82,7 @@ use Apache::lonlocal;
use Apache::lonuserutils;
use Apache::lonclonecourse;
use LONCAPA::batchcreatecourse;
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
# ===================================================== Phase one: fill-in form
@@ -133,6 +133,8 @@ sub print_course_creation_page {
} else {
my $title_alert = &mt('A Community title is required');
my $coord_alert = &mt('The username of the Coordinator is required');
+ &js_escape(\$title_alert);
+ &js_escape(\$coord_alert);
$javascript_validations = qq|
function validate(formname) {
if (formname.title == '') {
@@ -158,7 +160,7 @@ function validate(formname) {
'snid' => "Section Numbers and corresponding LON-CAPA section IDs",
'csli' => "a comma separated list of institutional section numbers, each separated by a colon from the (optional) corresponding section ID to be used in LON-CAPA e.g., 001:1,002:2",
'crcs' => "Crosslisted courses",
- 'cscs' => "a comma separated list of course sections crosslisted with the current course, with each entry including the institutional course section name followed by a colon and then the (optional) sectionID to be used in LON-CAPA, e.g., fs03ent231001:ent1,fs03bot231001:bot1,fs03zol231002:zol2",
+ 'cscs' => "a comma separated list of course sections crosslisted with the current course, with each entry including the institutional course section name followed by a colon and then the (optional) section ID to be used in LON-CAPA, e.g., fs03ent231001:ent1,fs03bot231001:bot1,fs03zol231002:zol2",
'ccre' => "Course credits",
'crcd' => "Create six character course identifier to share with students",
'cred' => "the number of institutional credits students will earn by completing this course",
@@ -185,7 +187,8 @@ function validate(formname) {
'oaas' => "Open all assessments",
'mssg' => "Messaging",
'scpf' => "Set course policy feedback to Course Coordinator",
- 'scfc' => "Set content feedback to Course Coordinator",
+ 'scfc' => "Set resource content feedback to Course Coordinator",
+ 'scof' => "Set course content feedback to Course Coordinator",
'cmmn' => "Communication",
'dsrd' => "Disable student resource discussion",
'dsuc' => "Disable student use of chat rooms",
@@ -231,7 +234,8 @@ function validate(formname) {
$lt{'navi'} = &mt('Community Contents');
$lt{'cid'} = &mt('Community ID');
$lt{'scpf'} = &mt('Set community policy feedback to Coordinator');
- $lt{'scfc'} = &mt('Set content feedback to Coordinator');
+ $lt{'scfc'} = &mt('Set resource content feedback to Coordinator');
+ $lt{'scof'} = &mt('Set community content feedback to Coordinator');
$lt{'dsrd'} = &mt('Disable member resource discussion');
$lt{'dsuc'} = &mt('Disable member use of chat rooms');
$lt{'dads'} = &mt('Default Access Dates for Members');
@@ -460,6 +464,10 @@ END
.''
.&Apache::lonhtmlcommon::row_closure()
+ .&Apache::lonhtmlcommon::row_title($lt{'scof'})
+ .''
+ .&Apache::lonhtmlcommon::row_closure()
+
.&Apache::lonhtmlcommon::row_headline()
.'
'.$lt{'cmmn'}.'
'
.&Apache::lonhtmlcommon::row_closure()
@@ -646,6 +654,7 @@ 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'},
@@ -732,7 +741,7 @@ sub create_course {
}
sub print_intro_page {
- my ($r,$show_all_choices) = @_;
+ my ($r,$show_all_choices,$cancreate,$permission) = @_;
my $start_page =
&Apache::loncommon::start_page('Create a New Course or Community');
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Options','Create_Course',undef,'Create_Courses');
@@ -741,6 +750,10 @@ sub print_intro_page {
my $helplink=&Apache::loncommon::help_open_topic('Create_Course_Community',&mt('Help on Creating Courses and Communities'));
# Create menu
+ my $approve = 'Display requests awaiting approval';
+ if ($permission->{'create'}) {
+ $approve = 'Approve or reject requests';
+ }
my @menu;
@menu =
({ categorytitle => 'Course/Community Creation',
@@ -748,7 +761,7 @@ sub print_intro_page {
{
linktext => 'Create a single course',
url => '/adm/createcourse?phase=courseone',
- permission => 1,
+ permission => $permission->{'create'},
#help => '',
icon => 'crsnew.png',
linktitle => 'Create a new course by completing an online form.'
@@ -756,7 +769,7 @@ sub print_intro_page {
{
linktext => 'Create a single community',
url => '/adm/createcourse?phase=groupone',
- permission => $show_all_choices,
+ permission => $permission->{'create'} && $cancreate->{'Community'},
#help => '',
icon => 'crsnew.png',
linktitle => 'Create a new collaborative community by completing an online form.'
@@ -764,7 +777,7 @@ sub print_intro_page {
{
linktext => 'Create courses/communities by uploading an attributes file',
url => '/adm/createcourse?phase=batchone',
- permission => 1,
+ 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.'
@@ -774,7 +787,7 @@ sub print_intro_page {
{ categorytitle => 'Course/Community Requests',
items => [
{
- linktext => 'Approve or reject requests',
+ linktext => $approve,
url => '/adm/createcourse?phase=requestdisplay',
permission => $show_all_choices,
#help => '',
@@ -835,43 +848,60 @@ sub upload_batchfile {
sub process_batchfile {
my $r = shift;
- my $start_page =
- &Apache::loncommon::start_page('Create a New Course or Community');
- my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('Creation Outcome','Create_Course',undef,'Create_Courses');
- my $end_page =
- &Apache::loncommon::end_page();
my $defdom=$env{'request.role.domain'};
- my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
- 'batchupload',undef,undef,
- undef,undef,$defdom);
- my ($batchdir,$filename) = ($batchfilepath =~ m-^(.+)/pending/([^/]+)$-);
+ my $uname = $env{'user.name'};
+ my $udom = $env{'user.domain'};
+ my $dir = &LONCAPA::tempdir().'addcourse';
my ($result,$logmsg);
- if (-e "$batchfilepath") {
- open(FILE,"<$batchfilepath");
- my @buffer = ;
- close(FILE);
- if ((defined($filename)) && (defined($batchdir))) {
- my @requests = ($filename);
- my %courseids = ();
- ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(
- \@requests,\%courseids,'web',$defdom,
- $env{'user.name'},$env{'user.domain'});
- if ($result) {
- if (!-e "$batchdir/processed") {
- mkdir("$batchdir/processed", 0755);
- open(FILE,">$batchdir/processed/$filename");
- print FILE @buffer;
+ if (($defdom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/) && ($udom =~/^$match_domain$/)) {
+ my $batchfilepath=&Apache::lonnet::userfileupload('coursecreatorxml',undef,
+ 'batchupload',undef,undef,
+ undef,undef,$defdom);
+ if ($batchfilepath =~ m{^(\Q$dir/$defdom/web/$uname\_$udom\E)/pending/([^/]+)$}) {
+ my ($batchdir,$filename) = ($1,$2);
+ if (-e "$batchfilepath") {
+ if (open(FILE,"<",$batchfilepath)) {
+ my @buffer = ;
close(FILE);
- if (-e "$batchdir/processed/$filename") {
- unlink("$batchdir/pending/$filename");
+ if ((defined($filename)) && (defined($batchdir))) {
+ my @requests = ($filename);
+ my %courseids = ();
+ ($result,$logmsg) = &LONCAPA::batchcreatecourse::create_courses(
+ \@requests,\%courseids,'web',$defdom,
+ $uname,$udom);
+ if (keys(%courseids) > 0) {
+ if (!-e "$batchdir/processed") {
+ mkdir("$batchdir/processed", 0755);
+ }
+ if (-d "$batchdir/processed") {
+ if (open(FILE,">","$batchdir/processed/$filename")) {
+ print FILE @buffer;
+ close(FILE);
+ }
+ }
+ if (-e "$batchdir/processed/$filename") {
+ unlink("$batchdir/pending/$filename");
+ }
+ }
}
+ } else {
+ $result = '
'.&mt('Could not open attributes file.').' '.&mt('No courses created.').'