Difference between revisions of "CreateDemoCourses"

From WeBWorK_wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
{{warning}} This page is not yet ready for prime time. Use with caution
 
{{warning}} This page is not yet ready for prime time. Use with caution
   
 
  +
== Creating (and refreshing) "maa101" demo courses from the command line ==
Notes on creating (and refreshing) "maa101" demo courses from the command line.
 
   
 
These command scripts allow you to restore exact clones of a model course, including the
 
These command scripts allow you to restore exact clones of a model course, including the
Line 11: Line 10:
 
The scripts are fragile -- they will need to be tweaked to conform to the directory structure
 
The scripts are fragile -- they will need to be tweaked to conform to the directory structure
 
of your WeBWorK installation and perhaps to the command line shell that you are running.
 
of your WeBWorK installation and perhaps to the command line shell that you are running.
We welcome any additions or modifications that will make these scripts more robust.
 
  +
This is particularly true of <code>dump_course_data_from_course</code> which has constants
  +
at the top which need to be initialized. We welcome any additions or modifications that will make these scripts more robust.
   
 
The procedure is essentially this:
 
The procedure is essentially this:
Line 19: Line 19:
 
*Create the courses maa101, maa102, maa103, etc. from the admin page by hand using maa99 as a model. While this could be automated I have usually found it easy enough to do this just once by hand.
 
*Create the courses maa101, maa102, maa103, etc. from the admin page by hand using maa99 as a model. While this could be automated I have usually found it easy enough to do this just once by hand.
   
* In your own directory on the command line create a subdirectory (I call mine <code>webwork_masters</code>)and in that create a subdirectory called <code>maa_data</code>. Run the <code>dump_course_data_from_course maa99</code> script attached below.
+
* In your own directory on the command line create a subdirectory (I call mine <code>webwork_masters</code>)and in that create a subdirectory called <code>maa_data</code>. Place the scripts described below in this directory.
  +
When you are done it should look something like:
  +
  +
-rwxr-xr-x 1 gage user 2558 Jan 17 15:35 dump_course_data_from_course*
  +
drwxrwxr-x 4 gage user 512 Jan 17 15:35 maa_data/
  +
-rwxrwxr-x 1 gage user 126 Jan 17 14:37 mirror_maa_courses*
  +
  +
* cd to maa_data and run the <code>dump_course_data_from_course</code> script The result should look like:
   
*Your <code>maa_data</code> directory should now look like:
 
  +
46 hosted2 ~/webwork_masters % cd maa_data
  +
130 hosted2 ~/webwork_masters/maa_data % ../dump_course_data_from_course maa99
  +
dumping data from /opt/webwork/courses/maa99
  +
it is a good idea to empty the course html/tmp directory first
  +
This script should be run in the directory receiving the data: e.g. maa_data
  +
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
   
6 hosted2 ~/webwork_masters % ls maa_data
 
  +
* Checking the maa_data directory should yield:
course.conf simple.conf database_template templates/
 
   
* The scripts <code>webwork_masters/restore_course_database</code> and <code>webwork_masters/with_this_data_update_course</code> should also have been created or updated. The script also prints out a string of "maa" courses that can be used to update many courses at once (see below)
 
  +
131 hosted2 ~/webwork_masters/maa_data % ls -l
  +
total 68
  +
-rw-r--r-- 1 gage user 3322 Jan 17 15:35 course.conf
  +
-rw-rw-r-- 1 gage user 55161 Jan 17 15:35 database_template
  +
drwxr-xr-x 3 gage user 512 Jan 28 2010 html/
  +
-rwxrwxr-x 1 gage user 117 Jan 17 15:35 restore_course_database*
  +
-rw-r--r-- 1 gage user 213 Jan 17 15:35 simple.conf
  +
drwxrwxr-x 8 gage user 512 Apr 9 2010 templates/
  +
-rwxrwxr-x 1 gage user 789 Jan 17 15:35 with_this_data_update_course*
   
  +
* As a test you can restore one course
  +
132 hosted2 ~/webwork_masters/maa_data % ./with_this_data_update_course maa107
  +
Updating /opt/webwork/courses/maa107\n
  +
Updating database for maa107\n
   
* To restore several courses at once using the tcsh shell create this script. <code>webwork_masters/mirror_maa_courses.sh</code>
 
  +
* Construct a webwork_masters/mirror_maa_courses script that looks like
   
 
#!/bin/tcsh
 
#!/bin/tcsh
foreach file (maa101 maa102 maa103 maa104 maa105 maa106 maa107 maa108 maa109 maa110 maa111 maa112 maa113 maa114 maa115 maa116)
+
foreach file (maa101 maa102 maa103 maa104 maa105 maa106 maa107)
mirror_one_maa_course $file
+
./with_this_data_update_course $file
 
end
 
end
   
and execute it from the <code>webwork_masters.maa_data</code> directory: <code> ../mirror_maa_courses.sh</code>
+
* Now execute it from the <code>webwork_masters.maa_data</code> directory:
   
  +
133 hosted2 ~/webwork_masters/maa_data % ../mirror_maa_courses
  +
Updating /opt/webwork/courses/maa101\n
  +
Updating database for maa101\n
  +
Updating /opt/webwork/courses/maa102\n
  +
Updating database for maa102\n
  +
Updating /opt/webwork/courses/maa103\n
  +
Updating database for maa103\n
  +
Updating /opt/webwork/courses/maa104\n
  +
Updating database for maa104\n
  +
Updating /opt/webwork/courses/maa105\n
  +
Updating database for maa105\n
  +
Updating /opt/webwork/courses/maa106\n
  +
Updating database for maa106\n
  +
Updating /opt/webwork/courses/maa107\n
  +
Updating database for maa107\n
   
 
=== Additional information ===
 
=== Additional information ===

Revision as of 17:59, 17 January 2011

Warning : This page is not yet ready for prime time. Use with caution

Creating (and refreshing) "maa101" demo courses from the command line

These command scripts allow you to restore exact clones of a model course, including the templates directory and the original database. I use these to restore maa101 demo courses to their original state after they have been experimented with by instructors learning the capabilities of WeBWorK

The scripts are fragile -- they will need to be tweaked to conform to the directory structure of your WeBWorK installation and perhaps to the command line shell that you are running. This is particularly true of dump_course_data_from_course which has constants at the top which need to be initialized. We welcome any additions or modifications that will make these scripts more robust.

The procedure is essentially this:

  • Set up an initial demonstration course (call it maa99) with the appropriate users, (instructors and students ) and the desired homework assignments present. For example I create instructors profa, and profb, import the usual collection of practice users using the demoCourse.lst file. I import the "Orientation" homework set and I have available the setDemo.def and setMAAtutorial.def files so that instructors can practice importing sets. These sets are in the standard "modelCourse" often used to create a new course. I add other set definition files depending on the audience.
  • Create the courses maa101, maa102, maa103, etc. from the admin page by hand using maa99 as a model. While this could be automated I have usually found it easy enough to do this just once by hand.
  • In your own directory on the command line create a subdirectory (I call mine webwork_masters)and in that create a subdirectory called maa_data. Place the scripts described below in this directory.

When you are done it should look something like:

-rwxr-xr-x  1 gage  user   2558 Jan 17 15:35 dump_course_data_from_course*
drwxrwxr-x  4 gage  user    512 Jan 17 15:35 maa_data/
-rwxrwxr-x  1 gage  user    126 Jan 17 14:37 mirror_maa_courses*
  • cd to maa_data and run the dump_course_data_from_course script The result should look like:
46 hosted2 ~/webwork_masters % cd maa_data
130 hosted2 ~/webwork_masters/maa_data % ../dump_course_data_from_course maa99
dumping data from /opt/webwork/courses/maa99
it is a good idea to empty the course html/tmp directory first
This script should be run in the directory receiving the data: e.g. maa_data
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 
  • Checking the maa_data directory should yield:
131 hosted2 ~/webwork_masters/maa_data % ls -l
total 68
-rw-r--r--  1 gage  user   3322 Jan 17 15:35 course.conf
-rw-rw-r--  1 gage  user  55161 Jan 17 15:35 database_template
drwxr-xr-x  3 gage  user    512 Jan 28  2010 html/
-rwxrwxr-x  1 gage  user    117 Jan 17 15:35 restore_course_database*
-rw-r--r--  1 gage  user    213 Jan 17 15:35 simple.conf
drwxrwxr-x  8 gage  user    512 Apr  9  2010 templates/
-rwxrwxr-x  1 gage  user    789 Jan 17 15:35 with_this_data_update_course*
  • As a test you can restore one course
132 hosted2 ~/webwork_masters/maa_data % ./with_this_data_update_course maa107
Updating /opt/webwork/courses/maa107\n
Updating database for maa107\n
  • Construct a webwork_masters/mirror_maa_courses script that looks like
#!/bin/tcsh
foreach file (maa101 maa102 maa103 maa104 maa105 maa106 maa107)
./with_this_data_update_course $file
end
  • Now execute it from the webwork_masters.maa_data directory:
133 hosted2 ~/webwork_masters/maa_data % ../mirror_maa_courses 
Updating /opt/webwork/courses/maa101\n
Updating database for maa101\n
Updating /opt/webwork/courses/maa102\n
Updating database for maa102\n
Updating /opt/webwork/courses/maa103\n
Updating database for maa103\n
Updating /opt/webwork/courses/maa104\n
Updating database for maa104\n
Updating /opt/webwork/courses/maa105\n
Updating database for maa105\n
Updating /opt/webwork/courses/maa106\n
Updating database for maa106\n
Updating /opt/webwork/courses/maa107\n
Updating database for maa107\n

Additional information

The contents of webwork_masters/with_this_data_update_course is approximately:

#!/bin/tcsh
echo "Updating /opt/webwork/courses/$1\n"
cp maa_data/course.conf /opt/webwork/courses/$1/course.conf
rm -rf /opt/webwork/courses/$1/templates
cp -RPpi -f maa_data/templates /opt/webwork/courses/$1/templates
echo "Updating database for $1\n"
echo "You need to use sudo -H ./mirror_one_maa_course to run load the data"
./restore_course_database $1


Warning : The tables dumped, dropped and restored need to be updated in these scripts as more features and tables are added to the webwork database.
  • The contents of webwork_masters/restore_course_database is approximately
#!/bin/sh
echo "use webwork;" >tmp
echo "drop table \`$1_key\`;" >>tmp
echo "drop table \`$1_password\`;" >>tmp  
echo "drop table \`$1_permission\`;" >>tmp  
echo "drop table \`$1_problem\`;" >>tmp  
echo "drop table \`$1_problem_user\`;" >>tmp  
echo "drop table \`$1_set\`;" >>tmp
echo "drop table \`$1_set_user\`;" >>tmp
echo "drop table \`$1_user\`;" >>tmp   
cat maa_data/database_template | sed s/maa99/$1/ >>tmp   
mysql    <tmp
rm tmp