Difference between revisions of "Customizing WeBWorK"
Line 21: | Line 21: | ||
== Creating and installing your own theme == |
== Creating and installing your own theme == |
||
− | Currently, to define a new theme in WeBWorK you must create three files which define that theme and put those files in the proper locations in the <tt>webwork2</tt> directory hierarchy. |
+ | Currently, to define a new theme in WeBWorK you must create three files which define that theme and put those files in the proper locations in the <tt>webwork2</tt> directory hierarchy. A new theme called <tt>my_theme</tt>, requires that there exist: |
− | * |
+ | * a new directory <tt>webwork2/conf/templates/my_theme</tt> |
− | * in that directory, |
+ | * in that directory, the files <tt>system.template</tt> and <tt>gateway.template</tt>. |
− | * |
+ | * and a file <tt>my_theme.css</tt> in the <tt>webwork2/htdocs/css</tt> directory |
− | To get started, it is probably best to simply copy the <tt>math</tt> theme under the new name and change it incrementally. To do so, change directories to <tt>/webwork2/conf/templates</tt> and do |
+ | To get started with creating a new theme, it is probably best to simply copy the <tt>math</tt> theme under the new name and change it incrementally. To do so, change directories to <tt>/webwork2/conf/templates</tt> and do |
cp -r math my_theme |
cp -r math my_theme |
||
Insde the <tt>my_theme</tt> directory are the files <tt>system.template</tt> and <tt>gateway.template</tt>. Edit '''both''' of those files to change the line |
Insde the <tt>my_theme</tt> directory are the files <tt>system.template</tt> and <tt>gateway.template</tt>. Edit '''both''' of those files to change the line |
Revision as of 15:27, 1 July 2010
Contents
Introduction
The basic look and feel of the WeBWorK user interface is highly customizable, and can be easily changed by users. Currently, WeBWorK ships with four themes (or skins) to choose from: ur, math, math2 and moodle; however, users with with knowledge of CSS and basic HTML may define their own themes for use in their courses.
Changing to a different provided theme
To change to one of the provided themes, log into a WeBWorK course as a professor and navigate to the "Course Configuration" page under "Instructor Tools." On that page you will be able to select one of the four installed themes: math, math2, ur, moodle, and union.
The math, math2, and moodle themes all look fairly similar. The ur and union themes are different from those and from each other.
After you select a new theme, you must click "Save Changes" for the change to be applied, and then refresh your browser to see the result.
Changing the theme in this manner only changes the theme for the course you are logged into. If you would like to set a new default theme for all courses created on your WeBWorK server, then change the value of the $defaultTheme
variable in global.conf. In new installations of WeBWorK, that variable is set as
$defaultTheme = "math";
And changing it to "math2", "ur", "moodle" or "union" would apply the corresponding theme to every current course on your server and to all courses created in the future. Of course, even if the $defaultTheme
is changed in global.conf, individual instructors can still override that setting as described above.
Creating and installing your own theme
Currently, to define a new theme in WeBWorK you must create three files which define that theme and put those files in the proper locations in the webwork2 directory hierarchy. A new theme called my_theme, requires that there exist:
- a new directory webwork2/conf/templates/my_theme
- in that directory, the files system.template and gateway.template.
- and a file my_theme.css in the webwork2/htdocs/css directory
To get started with creating a new theme, it is probably best to simply copy the math theme under the new name and change it incrementally. To do so, change directories to /webwork2/conf/templates and do
cp -r math my_theme
Insde the my_theme directory are the files system.template and gateway.template. Edit both of those files to change the line
<link rel="stylesheet" type="text/css" href="<!--#url type="webwork" name="htdocs"-->/css/math.css"/>
so that the href attribute reads
href="<!--#url type="webwork" name="htdocs"-->/css/my_theme.css"
Note the portion of those lines which says <!--#url type="webwork" name="htdocs"-->. This special comment style is used by WeBWorK's template system to provide dynamic content. Be sure not to alter that portion of the href attribute's value.
Now change directories to /webwork2/htdocs/css and do
cp math.css my_theme.css
At this point, you will have installed a new theme called my_theme into WeBWorK. To apply it to a single course, it can be selected and applied from the "Course Configuration" page along with the four provided themes. To apply it to every course on the server, simply set
$defaultTheme = "my_theme"
in global.conf. Now you can go about changing the look and feel of your WeBWorK courses by appropriately modifying the my_theme.css stylesheet and the templates under the /webwork2/conf/templates/my_template directory.