126
p41
© Half-Baked Software, Inc., 1998-2004
Editing th
e
s
our
ce
fil
es
One of the most powerful features in Hot Potato
es
is the ability to directly edit the source files (or
templates) that the program uses to generate Web pages (usually kept in the
s
our
ce
subfolder of the main
Hot Potato
es
folder). These files are text files, and if you are familiar with HTML and JavaScript, you'll see
familiar code if you open them in a text editor. See How the programs use source files for more details on
how the source files work. There is also a tutorial on this topic on the Hot Potatoes Website. Backups of
the original source files are kept in the
\
s
r
c
ba
c
kup\
folder, so you can easily restore a file if you edit it and
are unhappy with the results.
-o-
How th
e
program
s
u
se
s
our
ce
fil
es
If you are familiar with HTML and JavaScript, you may want to make your own changes to the templates
used to create the Web pages. At the simplest level, you might want to change text sizes and colours by
replacing the HTML font codes; however, you may also wish to change the way the score is calculated, or
remove scoring completely from the exercise. Whatever you wish to do, it will help to have some idea of
how the source files are used when the exercises are compiled. This page will give you a basic
introduction; there is a more detailed tutorial on this topic on the Hot Potatoes Website.
Each source file contains all the code necessary for creating a page. All the elements in the page which are
entered from the data (questions, answers etc.) are placed into the page at compile time. The source files
contain placeholders for these elements, surrounded by square brackets. For example, you may see the
placeholder
[
s
trEx
e
r
c
i
se
Titl
e
]
in the source file. This will be replaced at compile time by the title of the
particular exercise you are making.
Making changes to the source files is a risky and unpredictable business unless you know what you are
doing. In particular, you may cause problems if you eliminate any of the placeholders. However, as long as
you make changes to copies of the files (see below), and leave the originals alone, you have nothing to
lose!
Source files are stored in the
\
s
our
ce
\
folder, inside the Hot Potatoes program folder. They are named
according to their application and function -- for example:
jmat
c
h6.ht_ = standard output
djmat
c
h6.ht_ = JMatch drag/drop output
hotpot6r.ht_
= source file for reading texts in all applications
hp6utiliti
es
.j
s
_ = JavaScript utility functions used in all the output pages
hp6.
cs
_
= Cascading Stylesheet code used in all the output pages
Each program looks for source files in a folder you specify; the default is the \
s
our
ce
\ folder inside the Hot
Potatoes program folder. Here's an example of how you might edit a source file:
You decide to change the appearance of the pages, so you're going to edit hp6.
cs
_. First, you copy this file
to a new location. You open the copy in your text editor, and make the changes to the code. Then you start
a Potato (say
JQuiz
). Now you need to tell the program where to find the new source file. You choose "Set
Source File location" from the Options menu (or press Control + Alt + Shift + S), and you see a dialog box
asking you for the location of the source folder. You specify the location of your changed file. (You'll see the
path to the folder appear in the status bar at the bottom of the main screen.) Then you create the exercise,
and export. The program looks for all its source files in the folder you specified. In most cases, it doesn't
find the file (because there's only one file there), but when it comes to look for
hp6.
cs
_
, it finds your
changed version and uses it. In the case of the other files, it simply defaults to the normal source folder
location. Your exercise should be exported using your customized hp6.
cs
_ file.
Supposing you want to go back to using the normal source folder in JQuiz? Simply choose "Reset Default
Source Folder" on the Options menu, or press Control + Alt + Shift + T to reset the program to the default
source folder. When you do this, the path to the custom folder will disappear from the status bar at the
bottom left of the screen.