CreateDemoCourses

From WeBWorK_wiki
Revision as of 12:07, 17 January 2011 by Gage (talk | contribs) (Created page with '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 templat…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 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. 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. Copy

the templates directory and the course.conffrom the maa99 course to maa_data. In the maa_data directory run the script dump_course_database maa99 > database_template(shown below). Your maa_data directory should now look like:

6 hosted2 ~/webwork_masters % ls maa_data
course.conf             database_template       templates/ 
  • dump_course_database script
#! /bin/sh
sudo -H mysqldump webwork $1_key $1_password $1_permission $1_problem $1_problem_user $1_set $1_set_user $1_user 


  • Now comes the automated part. To initialize or restore a single maa course to its original state run sudo -H . mirror_one_maa_course maa101. The sudo -H command gives sufficient privileges to access the mysql database as root and to write into the courses

directory. mirror_one_maa_course

#!/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
  • The restore_course_database script
#!/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


  • To restore several courses at once using the tcsh shell use this script. mirror_maa_courses
#!/bin/tcsh
foreach file (maa101 maa102 maa103 maa104 maa105 maa106 maa107 maa108 maa109 maa110 maa111 maa112 maa113 maa114 maa115   maa116)
mirror_one_maa_course $file
end