[LON-CAPA-cvs] cvs: loncom /interface loncreatecourse.pm
www
lon-capa-cvs@mail.lon-capa.org
Tue, 02 Sep 2003 19:47:47 -0000
www Tue Sep 2 15:47:47 2003 EDT
Modified files:
/loncom/interface loncreatecourse.pm
Log:
Bug #1144: can now clone a course
Index: loncom/interface/loncreatecourse.pm
diff -u loncom/interface/loncreatecourse.pm:1.31 loncom/interface/loncreatecourse.pm:1.32
--- loncom/interface/loncreatecourse.pm:1.31 Tue Sep 2 14:00:14 2003
+++ loncom/interface/loncreatecourse.pm Tue Sep 2 15:47:47 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Create a course
#
-# $Id: loncreatecourse.pm,v 1.31 2003/09/02 18:00:14 www Exp $
+# $Id: loncreatecourse.pm,v 1.32 2003/09/02 19:47:47 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -166,6 +166,11 @@
my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
my $bodytag=&Apache::loncommon::bodytag('Create a New Course');
my $helplink=&Apache::loncommon::help_open_topic('Create_Course','Help on Creating Courses');
+ my $cloneform=&Apache::loncommon::select_dom_form
+ ($ENV{'request.role.domain'},'clonedomain').
+ &Apache::loncommon::selectcourse_link
+ ('ccrs','clonecourse','clonedomain');
+ my $coursebrowserjs=&Apache::loncommon::coursebrowser_javascript();
$r->print(<<ENDDOCUMENT);
<html>
<script language="JavaScript" type="text/javascript">
@@ -187,6 +192,7 @@
editbrowser.focus();
}
</script>
+$coursebrowserjs
<head>
<title>The LearningOnline Network with CAPA</title>
</head>
@@ -204,24 +210,34 @@
<input type="text" size="30" name="crsid">
</p>
<h2>Course Content</h2>
+<table border="2">
+<tr><th>Completely new course</th><th>Clone an existing course</th></tr>
+<tr><td>
<p>
<b>Map:</b>
<input type="text" size="50" name="topmap">
<a href="javascript:openbrowser('ccrs','topmap')">Select Map</a>
</p><p>
-<b>Do NOT generate as standard course</b>
+<b>Do NOT generate as standard course</b><br />
(only check if you know what you are doing):
<input type="checkbox" name="nonstandard">
</p>
<p>
-<b>First Resource</b> (standard courses only):
+<b>First Resource</b><br />(standard courses only):
<input type="radio" name="firstres" value="blank">Blank
<input type="radio" name="firstres" value="syl" checked>Syllabus
<input type="radio" name="firstres" value="nav">Navigate
</p>
-
+</td><td>
+Course ID: <input input type="text" size="25" name="clonecourse" value="" />
+<br />
+Domain:
+$cloneform<br /> <br />
+Additional settings, if specified below, will override cloned settings.
+</td></tr>
+</table>
<h2>Assessment Parameters</h2>
<p>
<b>Open all assessments: </b>
@@ -303,6 +319,7 @@
#
# Open course
#
+ my %cenv=();
my $courseid=&Apache::lonnet::createcourse($ENV{'request.role.domain'},
$cdescr,$curl,
$ENV{'form.course_home'},
@@ -320,52 +337,62 @@
my $crsuhome=&Apache::lonnet::homeserver($crsunum,$crsudom);
$r->print('Created on: '.$crsuhome.'<br>');
#
-# Set environment
+# Are we cloning?
+#
+ my $cloneid='';
+ if (($ENV{'form.clonecourse'}) && ($ENV{'form.clonedomain'})) {
+ $cloneid='/'.$ENV{'form.clonedomain'}.'/'.$ENV{'form.clonecourse'};
+ my ($clonecrsudom,$clonecrsunum)=($cloneid=~/^\/(\w+)\/(\w+)$/);
+ my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom);
+ if ($clonehome eq 'no_host') {
+ $r->print(
+ '<br /><font color="red">Attempting to clone non-existing course '.$cloneid.'</font>');
+ } else {
+ $r->print(
+ '<br /><font color="green">Cloning course from '.$clonehome.'</font>');
+# Copy all files
+ ©coursefiles($cloneid,$courseid);
+# Restore title
+ $cenv{'description'}=$cdescr;
+ }
+ }
+#
+# Set environment (will override cloned, if existing)
#
- my %cenv=();
- my $envflag=0;
if ($ENV{'form.crsid'}) {
- $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 ($ENV{'form.setkeys'}) {
- $envflag=1;
$cenv{'keyaccess'}='yes';
}
if ($ENV{'form.disresdis'}) {
- $envflag=1;
$cenv{'pch.roles.denied'}='st';
}
if ($ENV{'form.disablechat'}) {
- $envflag=1;
$cenv{'plc.roles.denied'}='st';
}
- # Record we've not yet viewed the Course Initialization Helper for this course
+ # Record we've not yet viewed the Course Initialization Helper for this
+ # course
$cenv{'course.helper.not.run'} = 1;
#
# Use new Randomseed
#
- $envflag=1;
$cenv{'rndseed'}=&Apache::lonnet::latest_rnd_algorithm_id();;
#
# By default, use standard grading
$cenv{'grading'} = 'standard';
- if ($envflag) {
- $r->print('Setting environment: '.
+ $r->print('<br />Setting environment: '.
&Apache::lonnet::put('environment',\%cenv,$crsudom,$crsunum).'<br>');
- }
#
# Open all assignments
#