CreateDemoCourses

From WeBWorK_wiki
Jump to navigation Jump to search

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


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. Run the dump_course_data_from_course maa99 script attached below.
  • Your maa_data directory should now look like:
6 hosted2 ~/webwork_masters % ls maa_data
course.conf            simple.conf  database_template       templates/ 
  • The scripts webwork_masters/restore_course_database and webwork_masters/with_this_data_update_course 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)


  • To restore several courses at once using the tcsh shell create this script. webwork_masters/mirror_maa_courses.sh
#!/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

and execute it from the webwork_masters.maa_data directory: ../mirror_maa_courses.sh


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