Difference between revisions of "CreateDemoCourses"
Line 11: | Line 11: | ||
This is particularly true of <code>dump_course_data_from_course</code> which has constants |
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. |
at the top which need to be initialized. We welcome any additions or modifications that will make these scripts more robust. |
||
+ | |||
+ | -- Mike Gage |
||
The procedure is essentially this: |
The procedure is essentially this: |
Latest revision as of 18:12, 7 March 2015
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.
-- Mike Gage
The procedure is essentially this:
- Set up an initial demonstration course (call it say maa99) with the appropriate users, (instructors and students ) and the desired homework assignments present. For example I create instructors
profa
, andprofb
, import the usual collection of practice users using thedemoCourse.lst
file. I import theOrientation
homework set and I have available thesetDemo.def
andsetMAAtutorial.def
files so that instructors can practice importing sets. These files are part of the standard "modelCourse" often used to create a new course. I add other set definition files depending on the audience.
- In your own directory on the command line create a subdirectory (I call mine
webwork_masters
)and in that create a subdirectory calledmaa_data
. Place thedump_course_data_from_course
script described below in this directory. Be careful not to wrap lines while creating the file. Change permissions to 755. When you are donewebwork_masters
should look something like:
127 hosted2 ~/webwork_masters % chmod 755 dump_course_data_from_course 128 hosted2 ~/webwork_masters % ls -l -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/
- cd to maa_data and run the
dump_course_data_from_course
script The result should look like:
129 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
- You can use the last line of the output from
dump_course_data_from_course
to construct awebwork_masters/mirror_maa_courses
script that looks like
#!/bin/tcsh foreach file (101 102 103 104 105 106 107) ./with_this_data_update_course maa$file end
- Give the file executable permissions and 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
- Alternatively you can type in the contents of the
mirror_maa_courses
directly on the command line
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 cat ./database_template | sed s/maa99/$1/ >>tmp sudo -H mysql <tmp rm tmp
Contents of dump_course_data_from_course
Warning : | The first three lines of this script MUST be edited for local use |
139 hosted2 ~/webwork_masters % cat dump_course_data_from_course #!/bin/tcsh # run this script in a directory such as maa_data to collect data for restoring a webwork set # setenv COURSESDIRECTORY /opt/webwork/courses setenv MYSQLDUMP /usr/local/mysql/bin/mysqldump setenv WEBWORKDAEMON wwhttpd # "user name" for the webwork server echo "dumping data from $COURSESDIRECTORY/$1" echo "it is a good idea to empty the course html/tmp directory first" echo "This script should be run in the directory receiving the data: e.g. maa_data" if (! -e $COURSESDIRECTORY/$1) then echo "Can't find course directory at |$COURSESDIRECTORY/$1|" exit endif sudo -H mysqldump webwork $1_key $1_password $1_permission $1_problem \ $1_problem_user $1_set $1_set_locations $1_set_locations_user $1_set_user \ $1_setting $1_user >database_template #FIXME get this to dump all tables using * somehow #create script "with_this_data_update_course" to update one course # this script should be stored in the same directory as maa_data cat <<END_FILE >./with_this_data_update_course #!/bin/tcsh setenv COURSESDIRECTORY $COURSESDIRECTORY setenv WEBWORKDAEMON $WEBWORKDAEMON if (! -e \$COURSESDIRECTORY/\$1) then addcourse \$1 --db-layout=sql_single --users=../adminClasslist.lst --professors=admin echo "Created course directory at \$COURSESDIRECTORY/\$1" endif echo "Updating \$COURSESDIRECTORY/\$1\n" sudo cp course.conf \$COURSESDIRECTORY/\$1/course.conf sudo cp simple.conf \$COURSESDIRECTORY/\$1/simple.conf #cp hide_directory \$COURSESDIRECTORY/\$1/hide_directory sudo rm -rf \$COURSESDIRECTORY/\$1/templates sudo rm -rf \$COURSESDIRECTORY/\$1/html sudo cp -RPpi -f templates \$COURSESDIRECTORY/\$1/templates sudo cp -RPpi -f html \$COURSESDIRECTORY/\$1/html sudo chown -R \$WEBWORKDAEMON \$COURSESDIRECTORY/\$1 echo "Updating database for \$1\n" ./restore_course_database \$1 END_FILE # get data from the model course directory rm -rf html rm -rf templates cp -RPpi $COURSESDIRECTORY/$1/templates . cp -RPpi $COURSESDIRECTORY/$1/html . cp $COURSESDIRECTORY/$1/course.conf . cp $COURSESDIRECTORY/$1/simple.conf . #create restore_course_database script cat <<END_FILE >./restore_course_database #\!/bin/sh echo "use webwork;" >tmp cat ./database_template | sed s/$1/\$1/ >>tmp sudo -H mysql <tmp rm tmp END_FILE chmod +x with_this_data_update_course restore_course_database # this snippet will print a bunch of course numbers perl -e 'foreach $i (101..120){print $i;print " ";} print "\n"' ##you can insert it into a file webwork_masters/mirror_maa_courses # #!/usr/bin/tcsh # foreach file (101 102 ) # sudo -H .with_this_data_update_course $file # end ## and run it from within the data directory (e.g. maa_data)