--- loncom/interface/loncreatecourse.pm	2002/08/18 21:43:59	1.11
+++ loncom/interface/loncreatecourse.pm	2002/08/31 00:43:12	1.12
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Create a course
 #
-# $Id: loncreatecourse.pm,v 1.11 2002/08/18 21:43:59 www Exp $
+# $Id: loncreatecourse.pm,v 1.12 2002/08/31 00:43:12 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -44,7 +44,7 @@ package Apache::loncreatecourse;
 use strict;
 use Apache::Constants qw(:common :http);
 use Apache::lonnet;
-
+use Apache::loncommon;
 # ===================================================== Phase one: fill-in form
 
 sub print_course_creation_page {
@@ -58,6 +58,8 @@ sub print_course_creation_page {
     }
     $course_home .= "\n</select>\n";
     my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
+    my $bodytag=&Apache::loncommon::bodytag('Create a New Course');
+
     $r->print(<<ENDDOCUMENT);
 <html>
 <script language="JavaScript" type="text/javascript">
@@ -82,9 +84,7 @@ function openbrowser(formname,elementnam
 <head>
 <title>The LearningOnline Network with CAPA</title>
 </head>
-<body bgcolor="#FFFFFF">
-<img align="right" src="/adm/lonIcons/lonlogos.gif">
-<h1>Create a new Course</h1>
+$bodytag
 <form action="/adm/createcourse" method="post" name="ccrs">
 <h2>Course Information</h2>
 <p>
@@ -143,14 +143,13 @@ sub create_course {
     $ccdomain=~s/\W//g;
     my $cdescr=$ENV{'form.title'};
     my $curl=$ENV{'form.topmap'};
+    my $bodytag=&Apache::loncommon::bodytag('Create a New Course');
     $r->print(<<ENDENHEAD);
 <html>
 <head>
 <title>The LearningOnline Network with CAPA</title>
 </head>
-<body bgcolor="#FFFFFF">
-<img align=right src=/adm/lonIcons/lonlogos.gif>
-<h1>Create a new Course</h1>
+$bodytag
 ENDENHEAD
     #
     # Verify data
@@ -178,30 +177,63 @@ ENDENHEAD
 
     $r->print('New LON-CAPA Course ID: '.$courseid.'<br>');
 #
-# Set optional courseid
+# Check if created correctly
 #
     my ($crsudom,$crsunum)=($courseid=~/^\/(\w+)\/(\w+)$/);
     my $crsuhome=&Apache::lonnet::homeserver($crsunum,$crsudom);
     $r->print('Created on: '.$crsuhome.'<br>');
+#
+# Set environment
+#
+    my %cenv=();
+    my $envflag=0;
     if ($ENV{'form.crsid'}) {
-       $r->print('Setting optional Course ID/Number: '.                 
-           &Apache::lonnet::reply('put:'.$crsudom.':'.
-                                  $crsunum.':environment:courseid='.
-                                  &Apache::lonnet::escape($ENV{'form.crsid'}),
-                                  $crsuhome).'<br>');
+	$envflag=1;
+        $cenv{'courseid'}=$ENV{'form.crsid'};
+    }
+    if (($ccdomain) && ($ccuname)) {
+       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
 #
-    $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(
-     $ENV{'user.domain'},$ENV{'user.name'},$courseid,'cc').'<br>');
+     $ENV{'user.domain'},$ENV{'user.name'},$courseid,'cc',$end).'<br>');
 #
 # Make additional user course administrator
 #
+   if (($ccdomain) && ($ccuname)) {
     $r->print('Assigning role of course coordinator to '.
                $ccuname.' at '.$ccdomain.': '.
     &Apache::lonnet::assignrole($ccdomain,$ccuname,$courseid,'cc').'<p>');
+   }
     $r->print('Roles will be active at next login.</body></html>');
 }