version 1.11, 2002/08/18 21:43:59
|
version 1.13, 2002/09/05 19:37:00
|
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; |
|
use Apache::lonratedt; |
|
use Apache::londocs; |
|
|
# ===================================================== Phase one: fill-in form |
# ===================================================== Phase one: fill-in form |
|
|
Line 58 sub print_course_creation_page {
|
Line 61 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 87 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> |
<b>Course Title:</b> |
<b>Course Title:</b> |
<input type="text" size="50" name="title"> |
<input type="text" size="50" name="title"> |
</p><p> |
</p><p> |
|
<b>Course Home Server:</b>$course_home |
|
</p><p> |
|
<b>Course ID/Number (optional)</b> |
|
<input type="text" size="30" name="crsid"> |
|
</p> |
|
<h2>Course Content</h2> |
|
<p> |
<b>Map:</b> |
<b>Map:</b> |
<input type="text" size="50" name="topmap"> |
<input type="text" size="50" name="topmap"> |
<a href="javascript:openbrowser('ccrs','topmap')">Browse</a> |
<a href="javascript:openbrowser('ccrs','topmap')">Browse</a> |
Line 98 function openbrowser(formname,elementnam
|
Line 108 function openbrowser(formname,elementnam
|
<b>Do NOT generate as standard course</b> |
<b>Do NOT generate as standard course</b> |
(only check if you know what you are doing): |
(only check if you know what you are doing): |
<input type="checkbox" name="nonstandard"> |
<input type="checkbox" name="nonstandard"> |
</p><p> |
</p> |
<b>Course Home Server:</b>$course_home |
<p> |
</p><p> |
<b>First Resource</b> (standard courses only): |
<b>Course ID/Number (optional)</b> |
<input type="radio" name="firstres" value="blank" checked>Blank |
<input type="text" size="30" name="crsid"> |
|
</p><p> |
<input type="radio" name="firstres" value="syl">Syllabus |
|
|
|
<input type="radio" name="firstres" value="nav">Navigate |
|
</p> |
|
|
|
<h2>Assessment Parameters</h2> |
|
<p> |
<b>Open all assessments: </b> |
<b>Open all assessments: </b> |
<input type="checkbox" name="openall" checked> |
<input type="checkbox" name="openall" checked> |
</p><p> |
</p> |
|
<h2>Messaging</h2> |
|
<p> |
<b>Set course policy feedback to Course Coordinator: </b> |
<b>Set course policy feedback to Course Coordinator: </b> |
<input type="checkbox" name="setpolicy" checked> |
<input type="checkbox" name="setpolicy" checked> |
</p><p> |
</p><p> |
Line 143 sub create_course {
|
Line 161 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 195 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>'); |
|
} |
|
# |
|
# Set first page |
|
# |
|
unless (($ENV{'form.nonstandard'}) || ($ENV{'form.firstres'} eq 'blank')) { |
|
$r->print('Setting first resource: '); |
|
my ($errtext,$fatal)= |
|
&Apache::londocs::mapread($crsunum,$crsudom,'default.sequence'); |
|
$r->print(($fatal?$errtext:'read ok').' - '); |
|
my $title; my $url; |
|
if ($ENV{'form.firstres'} eq 'syl') { |
|
$title='Syllabus'; |
|
$url='/public/'.$crsudom.'/'.$crsunum.'/syllabus'; |
|
} else { |
|
$title='Navigate Contents'; |
|
$url='/adm/navmaps'; |
|
} |
|
$Apache::lonratedt::resources[1]=$title.':'.$url.':false:start:res'; |
|
my ($errtext,$fatal)= |
|
&Apache::londocs::storemap($crsunum,$crsudom,'default.sequence'); |
|
$r->print(($fatal?$errtext:'write ok').'<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>'); |
} |
} |
|
|