version 1.11, 2002/08/18 21:43:59
|
version 1.12, 2002/08/31 00:43:12
|
Line 44 package Apache::loncreatecourse;
|
Line 44 package Apache::loncreatecourse;
|
use strict; |
use strict; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
use Apache::lonnet; |
use Apache::lonnet; |
|
use Apache::loncommon; |
# ===================================================== Phase one: fill-in form |
# ===================================================== Phase one: fill-in form |
|
|
sub print_course_creation_page { |
sub print_course_creation_page { |
Line 58 sub print_course_creation_page {
|
Line 58 sub print_course_creation_page {
|
} |
} |
$course_home .= "\n</select>\n"; |
$course_home .= "\n</select>\n"; |
my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain'); |
my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain'); |
|
my $bodytag=&Apache::loncommon::bodytag('Create a New Course'); |
|
|
$r->print(<<ENDDOCUMENT); |
$r->print(<<ENDDOCUMENT); |
<html> |
<html> |
<script language="JavaScript" type="text/javascript"> |
<script language="JavaScript" type="text/javascript"> |
Line 82 function openbrowser(formname,elementnam
|
Line 84 function openbrowser(formname,elementnam
|
<head> |
<head> |
<title>The LearningOnline Network with CAPA</title> |
<title>The LearningOnline Network with CAPA</title> |
</head> |
</head> |
<body bgcolor="#FFFFFF"> |
$bodytag |
<img align="right" src="/adm/lonIcons/lonlogos.gif"> |
|
<h1>Create a new Course</h1> |
|
<form action="/adm/createcourse" method="post" name="ccrs"> |
<form action="/adm/createcourse" method="post" name="ccrs"> |
<h2>Course Information</h2> |
<h2>Course Information</h2> |
<p> |
<p> |
Line 143 sub create_course {
|
Line 143 sub create_course {
|
$ccdomain=~s/\W//g; |
$ccdomain=~s/\W//g; |
my $cdescr=$ENV{'form.title'}; |
my $cdescr=$ENV{'form.title'}; |
my $curl=$ENV{'form.topmap'}; |
my $curl=$ENV{'form.topmap'}; |
|
my $bodytag=&Apache::loncommon::bodytag('Create a New Course'); |
$r->print(<<ENDENHEAD); |
$r->print(<<ENDENHEAD); |
<html> |
<html> |
<head> |
<head> |
<title>The LearningOnline Network with CAPA</title> |
<title>The LearningOnline Network with CAPA</title> |
</head> |
</head> |
<body bgcolor="#FFFFFF"> |
$bodytag |
<img align=right src=/adm/lonIcons/lonlogos.gif> |
|
<h1>Create a new Course</h1> |
|
ENDENHEAD |
ENDENHEAD |
# |
# |
# Verify data |
# Verify data |
Line 178 ENDENHEAD
|
Line 177 ENDENHEAD
|
|
|
$r->print('New LON-CAPA Course ID: '.$courseid.'<br>'); |
$r->print('New LON-CAPA Course ID: '.$courseid.'<br>'); |
# |
# |
# Set optional courseid |
# Check if created correctly |
# |
# |
my ($crsudom,$crsunum)=($courseid=~/^\/(\w+)\/(\w+)$/); |
my ($crsudom,$crsunum)=($courseid=~/^\/(\w+)\/(\w+)$/); |
my $crsuhome=&Apache::lonnet::homeserver($crsunum,$crsudom); |
my $crsuhome=&Apache::lonnet::homeserver($crsunum,$crsudom); |
$r->print('Created on: '.$crsuhome.'<br>'); |
$r->print('Created on: '.$crsuhome.'<br>'); |
|
# |
|
# Set environment |
|
# |
|
my %cenv=(); |
|
my $envflag=0; |
if ($ENV{'form.crsid'}) { |
if ($ENV{'form.crsid'}) { |
$r->print('Setting optional Course ID/Number: '. |
$envflag=1; |
&Apache::lonnet::reply('put:'.$crsudom.':'. |
$cenv{'courseid'}=$ENV{'form.crsid'}; |
$crsunum.':environment:courseid='. |
} |
&Apache::lonnet::escape($ENV{'form.crsid'}), |
if (($ccdomain) && ($ccuname)) { |
$crsuhome).'<br>'); |
if ($ENV{'form.setpolicy'}) { |
|
$envflag=1; |
|
$cenv{'policy.email'}=$ccuname.':'.$ccdomain; |
|
} |
|
if ($ENV{'form.setcontent'}) { |
|
$envflag=1; |
|
$cenv{'question.email'}=$ccuname.':'.$ccdomain; |
|
} |
} |
} |
|
if ($envflag) { |
|
$r->print('Setting environment: '. |
|
&Apache::lonnet::put('environment',\%cenv,$crsudom,$crsunum).'<br>'); |
|
} |
|
# |
|
# Open all assignments |
|
# |
|
if ($ENV{'form.openall'}) { |
|
my $storeunder=$crsudom.'_'.$crsunum.'.0.opendate'; |
|
my %storecontent = ($storeunder => time, |
|
$storeunder.'type' => 'date_start'); |
|
|
|
$r->print('Opening all assignments: '.&Apache::lonnet::cput |
|
('resourcedata',\%storecontent,$crsudom,$crsunum).'<br>'); |
|
} |
|
|
# |
# |
# Make current user course adminstrator |
# Make current user course adminstrator |
# |
# |
$r->print('Assigning role of course coordinator to self: '. |
my $end=undef; |
|
my $addition=''; |
|
if ($ENV{'form.expireown'}) { $end=time+5; $addition='expired'; } |
|
$r->print('Assigning '.$addition.' role of course coordinator to self: '. |
&Apache::lonnet::assignrole( |
&Apache::lonnet::assignrole( |
$ENV{'user.domain'},$ENV{'user.name'},$courseid,'cc').'<br>'); |
$ENV{'user.domain'},$ENV{'user.name'},$courseid,'cc',$end).'<br>'); |
# |
# |
# Make additional user course administrator |
# Make additional user course administrator |
# |
# |
|
if (($ccdomain) && ($ccuname)) { |
$r->print('Assigning role of course coordinator to '. |
$r->print('Assigning role of course coordinator to '. |
$ccuname.' at '.$ccdomain.': '. |
$ccuname.' at '.$ccdomain.': '. |
&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'<p>'); |
&Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'<p>'); |
|
} |
$r->print('Roles will be active at next login.</body></html>'); |
$r->print('Roles will be active at next login.</body></html>'); |
} |
} |
|
|