WIMS (Www
Interactive
Multipurpose
Server)
is an internet server system designed for mathematical and other educational purposes.
The WIMS server is composed of a kernel program which is a cgi program
(wims.cgi), plus various activity units called ``modules''.
The client browser accesses the server via a http request to wims.cgi, with
parameters specifying the name of the module to request, the type of the
request, and possibly parameters for the module ; wims.cgi
processes the requested module, passing the user parameters to it, and sends
the result returned by the module back to the client.
A module may consist of a number of script files grouped in one directory.
These scripts are written in a special scripting language: the WIMS language.
The WIMS language contains commands which allow it to call external
programs (especially various mathematical softwares) to make sophisticated
computations. Such commands are processed by wims.cgi and sent through
interface programs which filter the request, check for security breaches,
and send back a filtered output.
The current version 4.27a of wims has several applications which
demonstrates (non-exhaustively) what one can do with a wims system.
Take a look at the
animated plotter: it allows you to plot curves and surfaces with zooming, deforming and rotating
effects, more easily as you may possibly imagine.
The game
Q-Puzzle gives a very good idea of how wims can provide a convenient way to combine
multimedia means and abstract mathematical notions.
The game-exercise
Coincidence-freehand shows the possibility to create interactive graphic exercises of a new
style.
The exercise
Correspondance gives an idea of the possibility of embedding javascript interactivity
into a wims application.
The exercise
Accordance shows the possibility of linking different wims applications:
except for the easiest level,
such an exercise is practical only if the user can use computer to
solve a linear system. Now such a solver (another wims application)
is available directly in the
exercise page, via a hypertext link. In order to teach the student to
choose the appropriate tool, some irrelevant links are also added.
Please notice that the lack of direct data communication between the two
modules is only a choice of the design of the module, in order to make
the student type the matrices.
The tool
Function illustrates the possibility to create pages which are at the same time
powerful and easy to use. By linking a plotter (gnuplot), a symbolic
calculator (Maxima) and a numerical calculator
(pari) at backend level, it allows the user to click on a root (or a
local extremum) he sees on the curve, and get the value of the root (or
local extremum) at arbitrary precision.
To achieve this, softwares are dynamically called at backend. First,
gnuplot is used to draw the curve in the given interval. When the user
clicks on a point, gp is called to try to find a root in the neighborhood
of the point. If it fails, Maxima is called to compute the formal
derivative of the function, and gp is called again to find a root of the
derivative in the neighborhood (which will be the local extremum).
This document itself is an illustration to the fact that wims can
provide an easy way to dynamically reorganise contents of a document. By
changing a parameter, contents of the document can be grouped, split, or
chosen, in various ways. (Remark that this document is itself a wims module.)
Advantage of WIMS versus locally installed softwares
No need of software installation and/or update by users.
All installation and/or update of background software is done on the
server side, which can be anywhere on the internet. On the client
machine, only a common web browser is required (which needs not to be
very up to date).
No need to learn the usage and the syntax of a particular software package.
As WIMS uses the html standard for user interface, a user, in particular
a student, has only to use his usual knowledge of html browsing (which
is now a common knowledge), in order to work on WIMS applications.
This is not the case for any of current mathematics softwares; all of
them require a training period before the user can work on it. This
training period may be more or less lengthy, but we remark that the
knowledge of using a particular software is not a universal knowledge,
and such a knowledge usually has a short lifespan.
Moreover, teaching knowledge about a commercial software contradicts
with the principle of commercial neutrality of a public education
institution.
It provides a means to collect the knowledge and experience
of the whole educational community.
WIMS is a modular system, where each application is a separated module
whose links with other modules are done in the usual html way.
This allows modules
to be developped independently and remotely. It is our hope that as many
educators as possible will add their knowledge and experience to the
system by contributions in the form of new modules or improvements of
existing ones.
It allows student - teacher interactions in several ways.
Organized under the structure of
classes,
a WIMS system allows teacher
to assign works for his students, and get reliable informations about
the progress (and/or difficulty) of the student in real time. This may
allow the teacher to give more personalised guide to the student.
The big advantage of such a system based on internet is that there is
no site restriction: any work done from any site (local or remote) is
valid, and is taken into account.
It provides a dynamic interaction between different components, e.g.
between exercises and computing tools.
For example, practically no software dedicated to exercises can
interface a computational tool as easily as WIMS does.
It can be more powerful than any given software for certain works.
Because WIMS can use different (dedicated) software as backend engine,
even several softwares for one application or one request.
Disadvantage of WIMS versus locally installed softwares
Low speed of reaction.
Because usually every WIMS response has to travel through internet.
This will improve when internet speed improves.
Limited computational power and programming capability.
If a user has a heavy computational job and/or has to design a complicated
script to get his job done, he should work directly on the appropriate
software. It is not at all the intention of WIMS to interface such
activities.
Limited capability of the graphical interface.
The html graphical user interface is not very suited for interactive
works.
Advantage of WIMS versus hand calculators
Easier to use.
A html page used by WIMS for user interface is much more comprehensible
than any hand calculator.
(Much) more powerful.
Disadvantage of WIMS versus hand calculators
Non-portability.
WIMS is accessible only to computers connected to internet.
Advantage of WIMS versus interactive web applications based
only on java or javascript
More powerful and more versatile.
As WIMS can embed java or javascript programs in its applications, a
wisely designed WIMS application just extends the capability of java or
javascript.
And WIMS can really do more:
even if it is theoretically possible to develop java applications which
has the same power as a software used as a backend engine for WIMS, it
would take too much effort to develop (is it reasonable to re-write TeX
in java?), and would be so big that it would take forever for an http
query to load.
Easier to develop.
Because WIMS language is first based on html (easy to learn), with an
extension specifically designed for this purpose.
Allows student-supervisor interaction.
The design of server-based interactivity for users allows the back-end
communication with supervisors, and much more (performance analysis,
automatic intervention from supervisors, etc).
Disadvantage of WIMS versus interactive web applications based
on java or javascript
Lower speed of reaction.
Because usually every WIMS response has to travel through internet.
This will improve when internet speed improves. One can also use
embedded javascript or java in a WIMS application, in places where
response speed is important.
Write html pages with a programmability extension: substitution of
variables, conditional branching, etc.
This wims programmability extension to html does not require any
addon or plugin at the browser side, as all the wims commands are treated
by the wims server before sending the result to the browser, which will
be a standard html page.
For example, this allows you to define style macros which can be
dynamically changed.
And this extension can cohabit with all the current (and hopefully
future) html standards, including java applets, javascripts, embedded
objects,
dhtml... This is because the wims extension follows a strict line
discipline (i.e. a wims command must start at the first word of a line),
while html standard is not line-oriented.
This means that you can even embed wims extensions into javascripts,
applets, dhtml...
Dynamic insertions of paints, plots and TeX formatted mathematical
formulas into html pages.
For example, you may insert the following line into your wims-extended html
page. At the browser side, the visitor will see a TeX formatted matrix
whose content varies with the value of the variable $matrix:
!instex $$ \left( $matrix \right) $$
Moreover, this implementation of dynamic insertions makes future updates
possible without modification at module's level. (For example when a
better way to render mathematical formula is available, a simple
modification at server's level will immediately let all !instex
lines take benefit of the new standard.)
Insplot is now animated!
Exemple: the tool
Tracés Animés .
Direct interfaces to powerful external software packages.
For example, you may define a variable `factor' by the following line:
factor=!exec pari print(factor($number))
Upon execution of this line, the variable will be replaced by
its current value, then the software package `PARI' will be called
with the string `print(factor(<value of $number>))' as command to
execute. The output of the program, with the overheads stripped, will
be placed as the value of the variable `factor'.
Interfaces provided in version 4.27a of wims: PARI, Maxima, MuPAD,
Coq, Povray, gnuplot, PostgreSQL, Fly (gif drawing), CALC (by Keith Matthew).
Simple and versatile language.
The language used for wims modules is an extension of the existing and
popular html language. This extension is designed to be simple,
easy to use and close to natural language. Synonymes are accepted
whenever necessary. For example, to include the content of another
file, you don't have to remember whether the command is
include as in C, or input as in TeX,
because both are valid.
Convenient directives for string manipulations:
replace with regular
expression capability, extraction of a subset from a list of items,
shuffle, evaluation of mathematical expressions, etc.
Easy inline mathematical symbols:
simply type $m_pi for , $m_RR for
, $m_le for
, $m_Rightarrow for , etc.
Intelligent treatment of mathematical expressions:
built-in translation routines to allow error-tolerant expressions
like 2y (instead of 2*y) or (x+1)(x-1)
(instead of (x+1)*(x-1)), and translations of raw mathematical
expressions into beautified html sources (x^3-3*x^2+1*x-5
will become x3-3x2+x-5 ,
etc.), or TeX sources, etc.
Powerful random capabilities:
random permutation (shuffle), random
record from a datafile, random filename, etc.
The system includes several facilities allowing you to create and develop
WIMS activities directly online. To do so, you have only to click on the
respective links from the home page of the server.
The easiest is the creation of simple interactive exercises
which does not really require the knowledge about a computer language, but
exercises that can be written in this way have limited power and versatility.
On the other hand, you can also develop full-power WIMS modules
by working entirely on line. For obvious security reasons, you will need a
login/password pair which you must ask the site manager to attribute to you.
Once logged in, you can create and modify as many modules as you like, in a
special development zone. When you have finished the development of a
module, you can ask the site manager to move it to a public place.
The central piece of a WIMS server is a cgi program, usually in the name of
wims.cgi. It takes all the http calls to the server, then does the following
work:
Call the module asked by the user, and process parameters and variables
according to what is defined in the module.
Session management.
Send the result of the process to the user.
Write to different log files.
Modules of WIMS
A WIMS server is a modular system, with different applications as modules.
At each new call to WIMS, the user has to specify which module he wants to
access.
A WIMS module may be an interactive course or interactive exercise (of any
level), a computational tool, a dictionary, a mathematical game, a database,
or a mixture of the above.
WIMS modules are independent from each other. Each module has its own
directory, which serves as its address, and contains all the files of this
module. Different modules have different authors and different maintainers,
and may follow different copyright policies.
There is no relation between modules in a same WIMS site, except hypertext
links which allows one module to access another in various ways.
How to access a WIMS server
WIMS is accessed by a request to the main cgi program, for example
https://wims.univ-cotedazur.fr/wims/wims.cgi
which usually should be followed by parameters. A call to the main wims.cgi
program without parameter will bring up the WIMS homepage of the site.
Parameters of wims.cgi is a usual http name=value pair, where the
name field may be one of the following:
cmd: the value is the command of the call.
Valid commands:
Parameter string
Meaning
cmd=intro
get introduction page of the module
cmd=new
open new working session
cmd=renew
restart working session
cmd=reply
send reply to the module
cmd=next
get next exercise (in a working session)
cmd=config
set preferences
cmd=help
get contextual help
cmd=hint
get contextual hint
cmd=resume
resume work (e.g. after help)
cmd=getins
get dynamic insertions: internal use
by the server. Not to be used by modules.
module. the value is the name of the module
which the user wants to access.
session: the value is the number of the current
session of the user.
The session number is automatically generated by wims.cgi, and is usually
automatically contained in the pages sent by the server. Tampering with this
parameter by the user (e.g. in order to spy into others' work) is not
allowed and has practically no chance to get through.
lang: the value defines the prefered language
of the user.
user: the value is the user name (for
registered users; reserved for internal use).
useropts: the value contains user options for the
server. The format is coded and may vary from version to version.
worksheet: reserved for internal use, for
determining user works assigned by worksheets.
special_parm: this parameter is reserved for
special requests (help, etc).
Any variables accepted by the module the user is working on (or
wants to work on).
calls the WIMS server at wims.univ-cotedazur.fr, with `new' as the value of `cmd',
`tool/algebra/factor.en' as the module name.
How to use the supervisor-side interface
Supervisors of registered classes can maintain their classes and consult
results of students via the same web address (the main cgi program), just
by logging in as supervisor. All the options are then available via html
links and buttons.
Each WIMS module has a private home directory in which go all the files
of this module.
A module must have at least the following files:
A variable definition file var.def.
This file defines external variables of the module. A parameter given by the
user must have a name declared in this file, except parameter names reserved by
WIMS (cmd, session, module, ...). And exactly variables declared in this
file will be saved in the session directory (to be recalled at the next
request from the same session).
A variable processing file var.proc.
This file is processed at EACH request of the module (except special
requests: when cmd=intro or getins).
A main phtml file main.phtml.
This file will be processed at avery request to the module, except under
special commands (when cmd=intro or getins).
An indexing file INDEX, which defines the application's nature.
This file will be used by WIMS database for searching available modules.
And it may often contain the following (optional) files too:
A variable initialisation file var.init.
This file has the same syntax as the file var.proc, and is processed
exactly at requests with cmd=new or cmd=renew.
A introductory page intro.phtml.
This is a phtml file, which is processed when the module is
accessed with cmd=intro. It is usually used to introduce the content of the
module, and to let the user choose starting options.
There may be any number of other files, like a README.md file, one or more
help pages, an about page, one or more graphics files, files called by one
of the above mandatory or optional files, etc.
Variable processing files
The files var.init and var.proc,
as well as any files called by these two
files, are variable processing files.
A variable processing file is divided into lines, separated by
non-escaped new-line characters. A new-line character can be escaped by the
character \, in which case it does not separate the two lines
before and after it.
Every line of a variable processing file must be one of the following:
A comment line, whose first non-space character is either the character
#, or ! followed by another !.
A variable definition line, in the form of
name=value. The content of
value may be a string (if this string contains a new-line
character, it must be escaped by the character \), or a WIMS
variable command (which must then start with the character !).
A command line, whose first non-space character is the character
!, followed by the command name and optional parameters.
If the command produces an output string, this output will be ignored.
A label line, whose first non-space character is the character
:, followed by the name of the label. Anything following the
label name will be considered as comment and ignored by the interpreter.
Label is used in conjunction with the jumping command
!goto.
A label starting with the character '*' is catch-all, matching any
!goto label.
Any line not fitting into one of the above 4 will generate a WIMS error
message.
Phtml files
The files main.phtml and intro.phtml, as well as any files called by these
two files, are phtml files (programmable html).
A phtml file is an ordinary html file, except for lines whose
first non-space character is a ! or a :.
Lines can be escaped by \, just as in the case of a variable
processing file.
A line starting with : is a label line, as in the case of a
variable processing file.
A line starting with ! is a command line, as in the case of a
variable processing file. To the difference that if the command produces an
output string, this output will be inserted into the html page, at the place
of the line.
Lines not of the above two types will be sent to the http client, after
substitution of variables.
WIMS variables have only one type: they are all string variables. Numerical
evaluation can be done on variables via the variable command
!eval.
A variable may be defined or modified in a variable processing file, or by
the commands
!let and
!default.
Variable names can contain any alphanumeric character, as well as the
underscore character _. There is a limit to the length of
variable names, and a limit to the length of values. (Limits depending on
server configuration.)
Variable substitution can be done anywhere in a variable processing file or
a phtml file (even in the name field of a variable definition
line). A word preceeded by the character $
is considered to be a variable name, and will be replaced by its value when
the line containing it is processed.
Special rules of variable substitution:
If the character $ is followed by a space, it will be
discarded.
The string $$ is replaced by a single $.
If the character $ is followed by the left parenthesis
(, the matching ) will be located, the content
of the pair of parentheses substituted. The result of the substitution
will then be used as the name of variable, and finally the whole thing
will be replaced by the value of the last variable. This allows nested
substitutions, as well as substitution of a variable which is followed
by an alphanumeric character.
Example: if the variable i has value 3
and the variable alpha3beta has value pi,
the string
3*$(alpha$(i)beta)*x
will become
3*pi*x
after substitution.
Array addressing: if the variable i contains a
comma-separated list a,b,c,d,e, then the string
$(i[3]) gives c after substitution, and
$(i[2 to 4]) gives b,c,d, etc.
Two-dimensional array addressing is also available: if
$M=x,y,z;a,b,c
(a 2x3 matrix), then
$(M[1;3,2])=z,y
If the character $ is followed by the left bracket
[, the matching ] will be located, the content
of the pair of brackets substituted then evaluated to a real number value whose
precision depends on the value of print_precision.
This value will replace the whole thing
together with the leading $.
It can be used for array subscripts.
Example: if the variable i has value 3
and the variables a1 has value 3 and a2 has value pi,
then the string
$(a$[$i-1])*x+$(a$[$i-2])
will become
pi*x+3
after substitution.
If the value of a variable being substituted contains the character
$, this value will again be substituted, until no more
substitution is needed. The server has a built-in limit of nested
substitutions; infinite nested substitions will violate this limit and
generate an error message.
Reserved variable names
The following names are reserved for their special meanings. They should not be
used for internal needs of any module.
Do not use variables with names consisting only of numbers. They are
reserved for future enhancements of the language.
Variables named
cmd,
module,
session,
lang,
special_parm,
user,
useropts,
worksheet,
are reserved for special parameter passed by the user. A module's variable
processing file or phtml file can read but cannot set them.
Refer to the section Basic structure of WIMS for the meaning of
these variables.
The variable no_name has a special use:
Parameters in the user query string with no name (for example when the
coordinate of a mappable image is passed this way to the http server) will
be registered under this variable. For this reason, it should not be used
for other purposes.
All variable names starting with wims_ will have special
meanings for WIMS server. A module should read or write them only for the
special meanings they are designed for.
Variable names starting with m_ are reserved for inline
mathematical fonts. The module programmer may redefine them, but then their
original meaning will be lost.
The variable module_dir has a value preset to the directory
of the current module (with respect to the public home directory of the
server). This value is usually $module_dir=module/$module
(but may vary with the config of the installation).
Variable names starting with module_ will have special
meanings: they are used to hold variables defined in the module's INDEX
file. Currently implemented variables:
Variables
Meaning
module_title
title of the module
module_description
short description of the module
module_author
name(s) of author(s) of the module
module_address
e-mail address of the (principal) author
module_maintainer
name of the current maintainer
module_maintainer_address
e-mail address of the maintainer
module_copyright
copyright notice of the module
module_version
current version of the module
module_wims_version
minimal WIMS version required
to run this module
module_dir
address of the module to use inside the module for example
to insert an image loaded in a subdirectory of the module
module_language
language of the module (en, fr, de, or ...)
module_category
category of the module
(exercise, tool, course, pedia, recreation, adm, other)
module_level
level of the module
module_domain
algebra, analysis, geometry, ...
module_keywords
keywords, to be placed in the html header
module_scoring
= yes if the module gives scores according to WIMS standard
module_data
address of datamodule
Also, variables module_has_intro,
module_has_help and
module_has_about
have value "yes" if the module's directory contains the respective
.phtml file. These variables are used in the command !homeref.
Some environment variables setup by httpd are readable by WIMS
modules under names starting with httpd_. For example, the
environment variable REMOTE_HOST becomes
httpd_REMOTE_HOST under WIMS.
Please refer to httpd protocol specifications for details of such variables.
All variable names starting with ins_,
insplot_, instex_ will have special meanings for the
corresponding dynamic insertion engines. A module should read or write them
only for the special meanings they are designed for.
If your module uses an external package (e.g. pari),
variable names starting with the name of the interface to that external
package followed by _ will have special meanings for that
interface, and should be reserved for that purpose.
is used to store error messages of the external program called by
!exec.
For this reason, this variable will be overwritten each time a !exec command is executed.
wims_module_log
is used for individual module's log files: if this variable is non-empty, wims.cgi will put its
content into the module's log file, at the end of the process of the user request.
wims_version
has a value preset to the current version of the wims server.
wims_version_date
has a value preset to the last compile date of the server program.
wims_site_manager
contains the electronic address of the site manager, as defined in the configuration file
wims.conf of the site. Modules should not modify this
variable.
wims_print_precision
defines the printing precision when a result of evaluation (via !eval or NaN) is converted to
a character string. Default value: 8 (may be modified in wims.conf).
wims_warn_
... is ...
wims_compare_precision
is used to define error tolerance when wims compares two numerical values.
Formula: !ifval a=b will
return TRUE if
abs(a-b)*10000<abs(a+b)+1/10000.
Default value: 10000 (may be modified in wims.conf).
wims_texsize
can be used to modify TeX sizes for the module. Default value is 0 (no change). Maybe 1,2,... (increase TeX size) or
-1,-2... (decrease TeX size).
wims_homeref_parm
is reserved for future use in the command !homeref.
wims_homeref_bgcolor
is...
wims_rawmath_functions
is used to tell rawmath routine that the words contained in the variable value should be
treated as function names.
These words can be separated either by white space or by comma.
wims_rawmath_variables
is used to tell rawmath routine that
the words contained in the variable value should be treated as math variable
names. These words can be separated either by white space or by comma.
wims_ref_name
gives the addess of the wims serveur (for this server, https://wims.univ-cotedazur.fr/~wims/wims.cgi)
httpd_HTTP_HOST
gives the name of the wims serveur (for this server, wims.univ-cotedazur.fr)
wims_protocol
gives protocol used (http, https. for this connexion )
wims_ref_target
defines the target of the command
!href, !homeref, !form. Its value is not automatically
reset to empty after the commands. (Defaults to empty string, meaning that
the target is the current document.)
wims_ref_id
defines the id in the command
!href (<a ... id=" ">) and
in the commands !formradio, !formcheckbox and !getfile.
Its value is automatically
reset to empty after the commands. (Defaults to empty string)
wims_ref_class
defines the css class in the command
!href (<a ... class=" ">) and
in the commands !formradio, !formcheckbox and !getfile.
Its value is automatically
reset to empty after the command. (Defaults to empty string)
wims_ref_title
defines the title in the commands
!href and !getfile (<a ... title=" ">).
Its value is automatically
reset to empty after the command. (Defaults to empty string)
wims_html_mode
can be used before a command
as !formradio, !formcheckbox. It forces
the results of the formradio to be inside the html mode.
The value must be span, li,
div.
It could be td.
wims_getfile_fname
can be used before the command !getfile to specify the value
for the download attribute, which will be the new filename of the downloaded file.
wims_html_header
is the standardised html header for all
its modules' html outputs. Its value is defined in the file
html/header.phtml. It is highly recommended that modules use this variable
to define their html headers.
wims_expire
is used to define expiration dates of the pages sent to clients.
Don't touch it if you don't know what this means.
module_init_parm
is...
wims_ins_alt
if the value is the word empty, no automatic alt is inserted
(should be put in ins_attr for example);
if the value is the word none, some alt is inserted (generated by WIMS).
jquery_defined
if the value is the word yes, one can use jquery script (some themes do not use it,
so another solution must be found even if there is less functionnality
as dragdrop).
freepar_
If a variable begins by this prefix, no check on parenthesis is done.
wims_writable
wims_prefix
Variables reserved for dynamic insertions
ins_align
defines the manner in which the inline picture
is aligned with respect to the line. Possible values: bottom, middle or top.
Default is empty (which means bottom).
ins_attr
is used to define miscallaneous attributes of a
dynamic insertion. Examples:
ins_attr = alt="meaning"
or
ins_attr = align=middle
(aligns the middle of the image with the baseline for the current
textline), or
ins_attr = ismap
(coordinates of the click will be passed back to the server; if the link
of the element is the wims server, the coordinates will be registered
under the variable no_name.)
This variable is reset to empty after a dynamic insertion.
ins_border
is used to define border width of the html
element IMG resulted from the dynamic insertion. Its value should be a positive
number.
This variable is reset to empty after a dynamic insertion.
ins_density
is used to define the density of the dynamic
insertions. Default value: 100x100 .
Avoid using this variable! We are planning to
suppress it. Will be replaced by a server-managed variable.
ins_format
can be used to determine the format of the
graphics file of the dynamic insertion: its value should be either
gif or jpg. The default value of this variable is
gif (which can be changed by modifying the file
wims.conf; but such change is not recommended).
Some types of dynamic insertions may not be affected by this variable.
ins_quality
is used to define quality of the graphics
convertion used in dynamic insertions. Its value should be between 0 and
100. Affects only dynamic insertions whose graphics format is jpg.
ins_tag
is used for dynamic insertions within a form.
In this case define ins_tag=form name
where name is the name of the html element IMG
within the form (optional).
This variable is reset to empty after a dynamic insertion.
insdraw_size
is the size in pixels for the dynamic insertion.
ins_filename
is the name of the graphics file of the dynamic insertion
(generated by wims). It must be taken just after the command !insdraw
ins_url
is the url of the graphics file of the dynamic insertion.
It must be taken just after the command !insdraw
insplot_data
is ...
insplot_font
is ...
insplot_set
is ...
insplot_split
is ...
insplot_transparent
is used to define transparent color for insertions. Default is empty (no transparency).
Usual value: 255,255,255(white is transparent).
Variables reserved for software
wims_backslash_insmath
if the value is yes, it is possible to use the notation \( \) to insert mathematical expressions.
force_mathml
if the value is yes, force mathml output of tex formulas.
disable_mathml
If the value is 1, disable mathml output of tex formulas.
The variable disable_mathml has priority on force_mathml.
pari_precision
give the pari precision of the computation with Pari/GP
print_precision
give the precision of the computed number at the end of the computation.
maxima_precision
give the maxima precision of the computation with Maxima.
wims_multiexec
If the value is yes, allow the multiexecution of the mathematical software
use_comma
If value is 1 moneyprint will use a decimal comma. Any other value or no value will use the decimal point notation.
Only to be used for presentation purposes.
There is no special syntax in wims language for arrays. However, it is
possible to design array-like variable structures, with integer or even
string subscripts. This can be done using nested variable substitutions. For
example, ...
Fields in a string
WIMS variables are all string variables. There are three different ways to
split a string into fields:
As a list of words, separated by white-space characters. Consecutive
white-spaces are considered as one field separator.
As a list of lines, separated by new-line characters. Consecutive
new-lines are considered as separating empty lines.
As a list of items, separated by commas ( , ). Consecutive
commas are considered as separating empty items.
WIMS commands can be used in variable processing files and phtml files.
A command is a word preceeded by the character !.
Commands has two types:
Execution commands, which are placed as the first word of a line.
Variable commands, which are placed at the beginning of a definition of
a variable.
Some commands can be used both as execution command and as variable command.
Commands may accept parameters which are words following it. Parameter
fields are separated by white spaces or special words (depending on the command).
Here is the list of all commands.
append
Type:
both execution and variable command
Syntax:
!append object s1 to str
Meaning:
String manipulation: append object s1 to the string str; object may be item, word,
line, colon or semicolon. The object s1 should not be empty before evaluation.
bound
Type:
execution command
Syntax:
!bound vname between [integer] v1 and v2 [default defaultvalue] !bound vname within list [default defaultvalue]
Meaning:
bound the range of the variable vname. Usually this is used on user-submitted variables.
The first syntax is usually for numerical variables (integer or real,
defaults to real). In this case v1 and v2 supplies the lower and
upper bounds for the value of vname.
In the second syntax, the value of vname is compared with
each item of list. If no occurrence is found, the value of
vname is replaced either by defaultvalue or the first item of list,
according to whether defaultvalue is defined.
In any case, defaultvalue is optional.
nocache
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!nocache
changeto
Type:
execution command
Syntax:
!changeto file [parm]
Meaning:
Abandon the current file, changing processing to file. file is as in read.
The parameter parm can be accessed from within
the new file under the variable name wims_read_parm.
char
Type:
both execution and variable command
Syntax:
!char numlist of string
Aliases:
chars
Meaning:
Outputs selected characters of string, according to numlist.
numlist can be a single integer, a comma-separated list of
integers, or a range of integers.
A positive integer denotes the number of character in string
counted from the beginning,
with 1 corresponding to the first
character. A negative integer denotes the number of character from
the end of string: -1
means the last character, -2 means
the next-to-last character, etc.
The syntax for a range of integers is
n1 to n2.
For example, 2 to -2
means the whole string except the first
and the last characters.
charcnt
Type:
variable command
Syntax:
!charcnt string
Aliases:
charcount, charno, charnum, lengthof
Meaning:
Returns the number of characters in string.
checkallpar
Type:
only for trusted modules (in particular administrative modules).
Syntax:
!checkallpar string
Meaning:
check if parentheses (all types) are balanced in string and return yes
if it is the case and no if not.
checkdata
Type:
variable command
Syntax:
!checkdata
Aliases:
checkdatamodule
Meaning:
This command is used to check whether datamodules required by
the present module are installed on the server. It returns "yes" if every
required datamodule is installed or if no datamodule is required. Otherwise
it returns the address of the first missing datamodule.
If your module depends on datamodules to run, declare them in the INDEX
file, then use this command to check the presence of the datamodules. If
the answer is "no", you can take actions to lock further access to your
module and/or show error messages.
checkhost
Type:
both execution and variable command; only for trusted modules (in particular administrative modules).
Syntax:
!checkhost
column
Type:
both execution and variable command
Syntax:
!column numlist of string
Aliases:
columns
Meaning:
Outputs selected (comma-separated) columns of a matrix string,
according to numlist. Rows of the matrix can be separated either
by new lines or by semi-colon ;.
numlist can be a single integer, a comma-separated list of
integers, or a range of integers.
A positive integer denotes the number of column in string
counted from the beginning,
with 1 corresponding to the first
column. A negative integer denotes the number of column from
the end of string: -1
means the last column, -2 means
the next-to-last column, etc.
The syntax for a range of integers is
n1 to n2.
For example, 2 to -2
means the whole string except the first
and the last columns.
The output is separated by commas if only one column is selected, or
separated in the same way as the matrix string otherwise.
comment
Type:
only for trusted modules (in particular administrative modules).
Syntax:
!comment
Aliases:
rem remark
date
Type:
both execution and variable command
Syntax:
!date parm
Meaning:
This is simply an interface to the Linux date utility. parm is the parameter
string to the Linux command date, please refer to the man page of date for its syntax.
The command returns the output of the date utility.
deaccent
Type:
both execution and variable command
Syntax:
!deaccent string
Meaning:
Returns string with all accented letters (such as é, à, ï) folded to
their unaccented counterparts.
debug
Type:
both execution and variable command
Syntax:
!debug parms
Meaning:
This command is for debugging purposes: it substitutes the parameter parms,
and stops the execution with a module error sent to the user. The content of the
error message contains the result of the substitution.
declosing
Type:
both execution and variable command
Syntax:
!declosing string
Meaning:
Strips off enclosing pair of parentheses ((),[],{}) in string.
Useful for treatment of user-input vectors or sets,
where some users use enclosing parentheses and other do not.
default
Type:
execution command
Syntax:
!default name=value
Meaning:
put value into the variable name, if name is not already defined.
value may be a variable command (together with optional parameters).
defof
Type:
both execution and variable command
Syntax:
!defof vname in fname
Aliases:
definitionof, getdef
Meaning:
Returns the definition of variables vname in the file fname.
When vname contains several names, the values of each will
be returned with the same separators as for the names.
detag
Type:
both execution and variable command
Syntax:
!detag string
Meaning:
Removes html tags in string. It is very rudimentary and should be used with care.
Very useful for security enhancement in some occasions (apply to user-supplied strings).
detrust
Type:
only for trusted modules (in particular administrative modules).
Syntax:
!detrust
Aliases:
distrust
distribute
Type:
execution command
Syntax:
!distribute type string into namelist
Meaning:
Distribute the content of string into variables namelist. The distribution
can be done word by word, item by item, character by character or line by line,
according to the word type where type can be one of the following: words, items,
lines, chars.
For example, if type is words,
then the first (resp. second, etc.) variable in namelist will be set
to the first (resp. second, etc.) word of string.
embraced
Type:
both execution and variable command
Syntax:
!embraced opword string
Meaning:
executes an operation opword in each substring of string enclosed in a pair
of curly braces.
The curly braces in string can be nested, but the execution runs from outmost pair
to innermost pair.
Available opword:
randitem. Random item in every embraced text.
randrow. Random row in every embraced text.
linkedranditem. Random item in every embraced text such that
for each level of curly braces, the position of the choosen item is the same.
extract. Extracts the first (outmost) embraced text.
delete. Deletes all embraced contents (encluding the curly braces).
eval
Type:
variable command
Syntax:
!eval expr
Aliases:
evalue
Meaning:
Returns the numerical value of the expression expr. expr must evaluate to
a real number (under the current version of wims). The evaluation is internally done in double
precision, but the print precision can be changed by setting the variable
wims_print_precision (whose default value is 8).
If an error is found in the expression expr, 0 is returned.
(I know that this is very bad; I just have no time to make everything right.)
Meaning:
Manipulation of mathematical expressions: substitute variable name by val in expr,
then evaluate the expression to a real number. No regular expression is allowed in name.
See also the commands
!mathsubst,
!replace.
examscore
Type:
both execution and variable command
Syntax:
!examscore
exchange
Type:
execution command
Syntax:
!exchange var1 and var2 !exchange var1, var2
Meaning:
Exchanges the values of the variables var1 and var2.
exec
Type:
both execution and variable command
Syntax:
!exec command parms
Aliases:
execute, run, call
Meaning:
execute external command command with optional parameters parms.
command must be a valid program name in the wims-public directory bin.
When used as variable command, returns the output of the called program.
exit
Type:
execution command
Syntax:
!exit
Aliases:
return
Meaning:
Abandon the current file. If current file is called by another file, return to the latter.
fileappend
Type:
execution command
Syntax:
!fileappend fname content
Aliases:
appendfile
Meaning:
Append content to file fname. fname is a file residing in directory of the module,
under the subdirectory writable. A new line will be added at the end of the content.
Special case: if the file name starts with getfile/, the file is written to the getfile
subdirectory of the session. This file is then accessible via the command
Meaning:
return yes if file is a file in the base directory public_html
in the case of a non trusted module.
If the command is executed from a trusted module, file
may be of the form wimshome/address. For example,
!fileexists themes/standard/_procs/tt.phtml
or for a trusted module,
!fileexists wimshome/log/classes/2001/Exindex
filewrite
Type:
execution command
Syntax:
!filewrite fname content
Aliases:
writefile
Meaning:
Write content to file fname. fname is a file residing in the module's directory,
under the subdirectory writable.
A new-line character will be added at the end of the content.
Special case: if the file name starts with getfile, the file is written to the getfile
subdirectory of the session. This file is then accessible via the command
Syntax:
!for var = start to end [step st ] !for var from start to end [step st ] !for var in list
... (multi-line content)
!next
Meaning:
For loop. In the first two forms, var goes from start to end, with optional step st.
In the last form, var takes successively items in the list
list. list is a list of items separated by commas.
The command
!break
within the for loop breaks it. continue is not yet implemented in this version.
It is recommended that the variable name var be added to the
!next line. This has no effect for the time being, but may be
used in future versions of wims.
form
Type:
execution command
Syntax:
!form cmdvar
Meaning:
Creates a html form pointing to the wims server.
Whenever possible, this command should be used instead of a direct use of
html tag <form>.
This command will create a <form> tag pointing to the wims server, adding
<input> fields to pass session number (and other reserved things in the
future). In lines which follow, other input (or select) fields may be
added to the form. A final !formend must also be added by the
programmer. cmdvar is an optional parameter. Its value should be a valid
value for the variable cmd. In this case the value cmdvar will
be automatically submitted to the variable cmd. If this parameter is missing
or is invalid, then the programmer should add a
<input type="hidden" name="cmd" value="..." /> tag before the
final </form>.
The target of the form can be controlled by the variable wims_ref_target.
It can also be defined via an optional word target=.... Note that in this case
the target must start with wims_.
The variable wims_form_method which must be either get or post controls the method
of the form. This method defaults to post for tool modules, and to get for all
other modules.
formbar
Type:
execution command
Syntax:
!formbar name from n1 to n2 !formbar name list selectlist
Aliases:
formradiobar, htmlbar, htmlradiobar
Meaning:
Creates a bar of radio buttons under a previously defined html form.
This bar should be arranged to represent values from small to big. No prompt is given
to the user, except the indication that left is smaller. In the parameters, name defines the
name field of the menu, and the values of the menu are either integers going from n1 to n2
(in the first syntax), or items in the list selectlist.
The default of the menu will be the current value of the variable $name.
formcheckbox
Type:
execution command
Syntax:
!formcheckbox name from n1 to n2 prompt promptlist !formcheckbox name list selectlist prompt promptlist
Aliases:
htmlcheckbox
Meaning:
Creates a checkbox list menu under a previously defined html form.
This command speeds up the creation of checkboxed menus, as well as simplifies
the source files. In the parameters, name defines the name field of the menu,
and the values of the menu are either integers going from n1 to n2 (in the first syntax),
or items in the list selectlist.
The optional parameter promptlist can be used to generate user prompts for each items in the list.
If promptlist is empty or is shorter than selectlist, the undefined prompts
will be replaced by the value. If it is longer, the rest will be ignored.
An id is created automatically, except if the variable
wims_ref_id is specified just before. If the variable
wims_html_mode has a value as div, li, td, the different items of
the html form will be in the corresponding html environmment. If the
variable wims_ref_class is non empty, the class of this html environment is the value
of this variable. The default of the menu will be the current value of the variable
$name.
The variables wims_ref_id and wims_html_mode are reinitialized after the html form.
Sample(s):
Command
Result
!formcheckbox varCHK1 from 1 to 3 prompt txt1,txt2,txt3
,
,
!formcheckbox varCHK2 list a,b,c prompt txtA,txtB,txtC
,
,
<ol> !set wims_html_mode=li
!formcheckbox varCHK3 list apple,pear prompt 🍎,🍐
</ol>
<ul> !set wims_html_mode=li
!formcheckbox varCHK4 list apple,pear prompt 🍎,🍐
</ul>
formend
Type:
execution command
Syntax:
!formend
Meaning:
Creates the balise which closes the form created by !form
formradio
Type:
execution command
Syntax:
!formradio name from n1 to n2 prompt promptlist !formradio name list selectlist prompt promptlist
Aliases:
htmlradio
Meaning:
Creates a radio button list menu under a previously defined html form.
This command speeds up the creation of radio buttoned menus, as well as simplifies
the source files. In the parameters, name defines the name field of the menu,
and the values of the menu are either integers going from n1 to n2 (in the first syntax),
or items in the list selectlist.
The optional parameter promptlist can be used to generate user prompts for each items in the list.
If promptlist is empty or is shorter than selectlist, the undefined prompts
will be replaced by the value. If it is longer, the rest will be ignored.
The default of the menu will be the current value of the variable $name.
An id is created automatically, except if the variable
wims_ref_id is specified just before. If the variable
wims_html_mode has a value as div, li, td, the different items of
the html form will be in the corresponding html environmment. If the
variable wims_ref_class is non empty, the class of this html environment is the value
of this variable. The default of the menu will be the current value of the variable
$name.
The variables wims_ref_id and wims_html_mode are reinitialized after the html form.
Sample(s):
Command
Result
!formradio quest1 list 0,1,2 prompt zero,one,two
,
,
!formradio quest2 from 0 to 2 prompt A,B,C
,
,
!set wims_ref_id=quest3_0 !formradio quest3 list 0 prompt one choice
Syntax:
!formselect name from n1 to n2 prompt promptlist !formselect name list selectlist prompt promptlist
Aliases:
htmlselect
Meaning:
Creates a select menu under a previously defined html form.
This command speeds up the creation of select menus, as well as simplifies
the source files. In the parameters, name defines the name field of the menu,
and the values of the menu are either integers going from n1 to n2 (in the first syntax),
or items in the list selectlist.
The optional parameter promptlist can be used to generate user prompts for each items
in the list. If promptlist is empty or is shorter than selectlist, the undefined prompts
will be replaced by the value. If it is longer, the rest will be ignored.
The default of the menu will be the current value of the variable $name.
The variable $wims_formselect_switch may be used to set switches (for example by letting
wims_formselect_switch=multiple, the selection will be multiple.
getscoreremain
Type:
both execution and variable command; only for trusted modules (in particular administrative modules).
Syntax:
!getscoreremain
getfile
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!getfile filename [prompt]
Aliases:
outfile, fileout
Meaning:
Creates a hypertext reference pointing to a specified file on the current wims session.
Whenever possible, this command should be used instead of a direct use of
html tag <a href="...">. filename is the file name to find in the /getfile directory of current session,
which should not contain white spaces.
prompt is an optional text on which the hypertext link sits. It can be
any text or a <img...> tag, but dynamic insertions are not accepted yet.
There is no need to add the end tag </a>.
The CSS class (class='...') of the link can be controlled via the variable
wims_ref_class.
The title (title='...') of the link can be controlled via the variable
wims_ref_title.
The HTML ID (id='...') of the link can be controlled via the variable
wims_ref_id.
getopt
Type:
both execution and variable command
Syntax:
!getopt name in string
Meaning:
This command allows to extract the definition of a word in string under the form name=value.
It returns the defined value in the string, or the name itself if it appears in string
but if there is no = sign following it, or an empty string if name does not appear
in string as a word.
value can be a multi-word string, if it is enclosed by a pair of parentheses, brackets,
curly braces or double quotes. The enclosing parentheses etc. will be removed from the output.
Spaces are allowed before and/or after the = sign.
getscore
Type:
both execution and variable command, only for trusted modules (in particular administrative modules).
Meaning:
summary for work done for each exercise of a sheet. The output is four
word score mean best level:
score : sum of cumulative_points of each exercises of the sheet (limited by required points of each) divided
by sum of required_points of all exercises of the sheet (integer between 0 and 100)
mean : average of score for all score (between 0 and 10);
best : average of best score for each exercices of the sheet (integer between 0 and 100).
see command getscorebest for meaning of best score of an exercise;
level : average of minimum score for each exercice of the sheet
(integer between 0 and 100).
See command getscorelevel for meaning of minimum score of an exercise.
Default value for class is wims_class.
Default value for user is wims_user.
If no sheet id is specified, each line represents a sheet.
getscorequality
Type:
both execution and variable command; only for trusted modules (in particular administrative modules).
Meaning:
return yes if score registering for the current sheet is open and no if not.
The restrictions done in the .security of the class are taken in account.
The same is true for the technical variables attached to quser in qclass.
Default value for class is wims_class.
Default value for user is wims_user.
The command can be used in non administrative module if no user and no class is specified.
So it applies to the current wims_user and wims_class.
getscoretry
Type:
both execution and variable command; only for trusted modules (in particular administrative modules).
If no sheet id is specified, each line represent a sheet.
If no work id is specified, each word (of each line) represents an exercise.
The command can be used in non administrative module if no user and no class is specified.
goto
Type:
execution command
Syntax:
!goto label
Meaning:
Unconditionally jump to label. label must be a valid label in the current file.
header
Type:
execution command
Syntax:
!header parm
Aliases:
htmlheader, wimsheader
Meaning:
Standardized header for html page outputs. Includes the variable wims_html_header
and the commands !headmenu and !title.
parm is reserved for future implementation.
header1
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!header1
headmenu
Type:
execution command
Syntax:
!headmenu
Meaning:
Creates a standardised menu bar, usually to be included on the top of the page.
hex
Type:
both execution and variable command
Syntax:
!hex string
Aliases:
tohex
Meaning:
Returns a new string replacing every character in string by its hexadecimal code.
In particular, the result can be used as part of a variable
name whatever the content of string is (as long as it is not too long).
homeref
Type:
execution command
Syntax:
!homeref parm
Aliases:
wimsref
Meaning:
Creates a standardised table of links to wims homepage (and eventually other things).
parm is reserved for future implementation.
href
Type:
execution command
Syntax:
!href parms text
Meaning:
Creates a hypertext reference pointing to the wims server.
Whenever possible, this command should be used instead of a direct use of
html tag <a href="...">. parms is the string of parameters to the call to wims server,
which should not contain white spaces. Usually a cmd=... pair should be at least present;
on the other hand, the session number and prefered language will be directly added by the server.
text is the text on which the hypertext link sits. It can be
any text or a <img...> tag, but dynamic insertions are not accepted yet.
There is no need to add the end tag </a>.
The target of the reference can be controlled via the variable
wims_ref_target. It can also be defined via an optional word
target=.... Note that in this case the target must start with wims_.
The CSS class (class='...') of the link can be controlled via the variable
wims_ref_class.
The title (title='...') of the link can be controlled via the variable
wims_ref_title.
The HTML ID (id='...') of the link can be controlled via the variable
wims_ref_id.
html2iso
Type:
both execution and variable command
Syntax:
!html2iso string
Meaning:
Translate some html entities in isolatin in string. The list of translated entities
htmlmath
Type:
both execution and variable command
Syntax:
!htmlmath expr
Aliases:
math2html
Meaning:
Translate the raw mathematical expression expr, into a form which can be
best possibly rendered via html tags. If the expression is not a "machine-understandable
mathematical expression", there is no garanty on the result (at the moment and in the future !).
All digits or + or - following a ^ or _ are considered as in exponent/subscript;
expression with ( ) following a ^ or _ are considered as in exponent/subscript
parenthesis are remove (if no sign before) except in case of exponent and only digits.
Get rid of 1*.. ..*1. example: in 1 * x, x/1, the 1 is removed.
Replace scientific notation 35E-05 by 10 power and add multiplication sign. Remove the + or 0 useless.
Replace some names as greek letters by their equivalents.
Remove * or replace by multiplication sign.
Replace <=, >=, ->, =>, <=> by their html equivalents if possible.
if
Type:
execution command
Syntax:
!if string1 relation string2
... (multi-line content)
[!else]
... (multi-line content)
!endif
Meaning:
Conditional branching: execute the multi-line content between !if line and !endif line
(or between !if line and !else line if !else is present)
if relation is verified, and the potential lines between !else line and !endif line
if relation is not verified.
The leading and trailing spaces of string1 and string2
will be stripped before making comparisons.
All comparisons are made on strings: string1 rel string2.
Comparisons can be joined using and and
or. Parentheses may
be used to build complex comparison logics.
Valid relations
Relation
Condition
==
string1 == string2 string1 == string2
with if: true if string1 and string2 are identical. with ifval: true if the numerical evaluations of string1 and of string2 are equal.
!=
string1 != string2 string1 <> string2
with if: true if string1 and string2 are NOT identical. with ifval: true if the numerical evaluations of string1 and of string2 are not equal.
!=
<
string1 < string2
true if (the numerical evaluation of) string1 is < string2.
<=
string1 <= string2
true if (the numerical evaluation of) string1 is string2.
>
string1 > string2
true if (the numerical evaluation of) string1 is > string2.
>=
string1 >= string2
true if (the numerical evaluation of) string1 is string2.
isin
string1 isin string2
true if string1 is a substring of string2.
notin
string1 notin string2
true if string1 is NOT a substring of string2.
iswordof
string1 iswordof string2
true if string1 is a word of string2.
notwordof
string1 notwordof string2
true if string1 is NOT a word of string2.
isvarof
string1 isvarof string2
true if string1 is a (mathematical) variable of the expression string2.
notvarof
string1 notvarof string2
true if string1 is NOT a (mathematical) variable of the expression string2.
isvariableof
string1 isvariableof string2
true if string1 is a (mathematical) variable of the expression string2.
notvariableof
string1 notvariableof string2
true if string1 is NOT a (mathematical) variable of the expression string2.
isitemof
string1 isitemof string2
true if string1 is an item of the list string2.
notitemof
string1 notitemof string2
true if string1 is NOT an item of the list string2.
islineof
string1 islineof string2
true if string1 is a line of the list string2.
notlineof
string1 notlineof string2
true if string1 is NOT a line of the list string2.
issamecase
string1 issamecase string2
true if string1 and string2 are the same text by a comparison insensitive to multiple spaces but case-sensitive.
notsamecase
string1 notsamecase string2
true if string1 and string2 are NOT the same text by a comparison nsensitive to multiple spaces but case-sensitive.
issametext
string1 issametext string2
true if string1 and string2 are the same text by a comparison insensitive to cases, multiple spaces and accented letters.
notsametext
string1 notsametext string2
true if string1 and string2 are NOT the same text by a comparison insensitive to cases, multiple spaces and accented letters.
ifval
Type:
execution command
Syntax:
!ifval string1 relation string2
... (multi-line content)
!endif
Meaning:
Same as if, but = (==), != compares the
numerical values of string1 and string2 rather than the strings themselves.
imgrename
Type:
both execution and variable command; only for trusted modules (in particular administrative modules).
Syntax:
!imgrename
increase
Type:
execution command
Syntax:
!increase var
Aliases:
advance
Meaning:
Increase the value of var by one. The value of var is first rounded to an integer.
insdraw
Type:
execution command (only valid for phtml files)
Syntax:
!insdraw drawsource
Aliases:
inspaint
Meaning:
The server will call a paint program (flydraw), submit drawsource
as its command (with variables substituted), and insert the result into the page.
insmath
Type:
execution command (only valid for phtml files)
Syntax:
!insmath formula
Meaning:
According to the complicatedness of formula, the server will either render it
as beautifully as possible using html tags, or translate formula into TeX source then
call TeX to compile and finally transform the TeX result into a picture. The latter
is inserted into the page (at the place of the command).
If the user browser knows mathml, then the formula is simply translated into mathml
and sent to the browser. What is done is the following:
replace .. by ,
If there is no \ or { , apply rawmath if it is asked;
If there is no \ or { , apply texmath if there is some computer matrix [1,2;4,5] or if
there is a word as "sqrt int integrate sum prod product Int Sum Prod conj abs"
or if there is some / in the formula.
send it to instex (gifs) or to mathml or do nothing more according to ...
insplot
Type:
execution command (only valid for phtml files)
Syntax:
!insplot plotsource
Meaning:
The server program will call an external plotting program (gnuplot for the current version),
submit plotsource as the 2D plot command (with variables substituted),
and insert the result into the page.
The syntax of plotsource is that of the plot command of gnuplot.
insplot3d
Type:
execution command (only valid for phtml files)
Syntax:
!insplot3d plotsource
Meaning:
As for insplot,
but plotsource is in the syntax of the splot command of gnuplot, and a 3D
surface will be plotted.
instex
Type:
execution command (only valid for phtml files)
Syntax:
!instex texsource
Meaning:
The server program will call TeX to process the (plain) TeX source texsource
(after variable substitution), translate the result into a picture, and
insert it into the page (at the place of the command).
A tip: avoid using substituted variables in texsource
whenever possible. In this case WIMS will use static instex, improving
performance dramatically over dynamic instex.
The font color of the inserted text can be controled either by the variable
instex_color, or by a \special{color=...} string
in the texsource.
instexstatic
Type:
execution command (only valid for phtml files)
Syntax:
!instexstatic gifname texsource
Aliases:
instexst, staticinstex, stinstex
Meaning:
This command is obsolete, and will be dropped in future versions.
Use !instex instead.
item
Type:
both execution and variable command
Syntax:
!item numlist of string
Aliases:
items
Meaning:
Outputs selected (comma-separated) items of string, according to numlist.
numlist can be a single integer, a comma-separated list of
integers, or a range of integers.
A positive integer denotes the number of item in string
counted from the beginning,
with 1 corresponding to the first
item. A negative integer denotes the number of item from
the end of string: -1
means the last item, -2 means
the next-to-last item, etc.
The syntax for a range of integers is
n1 to n2.
For example, 2 to -2
means the whole string except the first
and the last items.
itemcnt
Type:
variable command
Syntax:
!itemcnt list
Aliases:
itemcount, itemno, itemnum
Meaning:
Returns the number of items in list.
items2lines
Type:
both execution and variable command
Syntax:
!items2lines string
Aliases:
itemstolines, list2lines, listtolines
Meaning:
This command changes multiple items in string into multiple lines.
items2words
Type:
both execution and variable command
Syntax:
!items2words string
Aliases:
itemstowords, list2words, listtowords
Meaning:
This command changes multiple items in string into multiple words.
let
Type:
execution command
Syntax:
!let name=value
Aliases:
def, define, set
Meaning:
put value into the variable name. value may be a variable command
(together with optional parameters).
leveldata
Type:
both execution and variable command
Syntax:
!leveldata size xsize,ysize ranges x1,x2,y1,y2 function f(x,y) [levels l1,l2,...]
Aliases:
levelpoints
Meaning:
Computes coordinates of points on the level curve of f(x,y), at levels l1,l2,...
(defaults to one level 0).
The computation is made from (x1,y1) to (x2,y2), and points are computed as integer
positions in a picture with size xsize,ysize.
Order of the fields is not important. All the fields except levels are mandatory.
line
Type:
both execution and variable command
Syntax:
!line numlist of string
Aliases:
lines
Meaning:
Outputs selected lines of string, according to numlist.
numlist can be a single integer, a comma-separated list of
integers, or a range of integers.
A positive integer denotes the number of line in string
counted from the beginning,
with 1 corresponding to the first
line. A negative integer denotes the number of line from
the end of string: -1
means the last line, -2 means
the next-to-last line, etc.
The syntax for a range of integers is
n1 to n2.
For example, 2 to -2
means the whole string except the first
and the last lines.
linecnt
Type:
variable command
Syntax:
!linecnt string
Aliases:
linecount, lineno, linenum
Meaning:
Returns the number of lines in string.
lines2items
Type:
both execution and variable command
Syntax:
!lines2items string
Aliases:
linestoitems, lines2list, linestolist
Meaning:
This command changes multiple lines in string into multiple items.
lines2rows
Type:
both execution and variable command
Syntax:
!lines2rows string
Meaning:
This command changes multiple lines in string into rows (the separator is
the semicolon).
lines2words
Type:
both execution and variable command
Syntax:
!lines2words string
Aliases:
linestowords
Meaning:
This command changes multiple lines in string into multiple words.
listcomplement
Type:
both execution and variable command
Syntax:
!listcomplement list1 in list2
Meaning:
Returns items appearing in list2 but not in list1. Repetitive occurrences are eliminated.
listfile
Type:
both execution and variable command; only for trusted modules (in particular administrative modules).
Syntax:
!listfile filespec
Aliases:
listfiles, filelist, ls, dir
Meaning:
list files specified in filespec. Options to Linux command ls are accepted.
The base directory is the base of the wims server. So if you want to list files
in the current module, type
!listfile $module_dir
listintersect
Type:
both execution and variable command
Syntax:
!listintersect list1 and list2
Aliases:
listintersection
Meaning:
Returns items appearing in both list1 and list2. Repetitive occurrences are eliminated.
listunion
Type:
both execution and variable command
Syntax:
!listunion list1 and list2
Meaning:
Returns items appearing in either list1 or list2. Repetitive occurrences are eliminated.
listuniq
Type:
both execution and variable command
Syntax:
!listuniq list
Aliases:
listunique
Meaning:
Returns items in list, with repetitive occurrences eliminated.
lookup
Type:
both execution and variable command
Syntax:
!lookup defname in fname
Meaning:
Returns the definition of word defname in the file fname which must be
a dictionary file in the same syntax as for the program translator
(not necessarily sorted).
fname may be either in the module directory (in this case the
module directory need not be specified), or in the directory bases.
lower
Type:
both execution and variable command
Syntax:
!lower string
Aliases:
lowercase, tolower
Meaning:
Returns string with all upper case letters replaced by their lowercase counterparts.
mailto
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!mailto ...
Meaning:
sends an email to a person whose address is the first line of the parameter.
The second line (optional) is the sender
The third line is the subject of the message.
And the remaining lines constitute the body of the message.
mailurl
Type:
both execution and variable command
Syntax:
!mailurl address name ...
Meaning:
Creates a javascript-crypted email interface that is difficult
for spammer-robot to decrypt.
The first word of the first line in the parameter should be the email address.
The rest of the first line is the recepient name (default to email address).
The second line and up is the mail subject.
This command calls, in the order of priority, one of the following files:
"mailurl.proc" in the module directory.
"mailurl.proc" in the current theme.
"scripts/mailurl.proc".
This allows site managers and authors to define different address encryption methods.
Mail addresses are not encrypted when the user is within a virtual class.
This command collapses some variables beginning with "mailurl_".
makelist
Type:
both execution and variable command
Syntax:
!makelist templ for v=v1 to v2 [step st], or !makelist templ for v in v1,v2,v3,...
Meaning:
Outputs a list consisting of templ with variable v successively substituted
by values v1, ..., v2.
In the second syntax, the substitutions are done with respect to each item in
the list v1,v2,....
The variable v should appear in templ as a math variable
(that is, with no preceeding character).
Sample(s):
Command
Result
!makelist [x;x+1;xx] for x in a,x and y,1,(2,3)
[a;a+1;xx],[x and y;x and y+1;xx],[1;1+1;xx],[(2,3);(2,3)+1;xx]
mathmlmath
Type:
both execution and variable command
Syntax:
!mathmlmath expr
Aliases:
math2mathml
Meaning:
Translate the raw mathematical expression expr, into a form which can be best
possibly rendered via mathml tags. The transformations
are the same as in htmlmath command and the result is in html if mathml is not available.
If the expression is not a "machine-understandable mathematical expression",
there is no garanty on the result (today and in the future !).
All digits or + or - following a ^ or _ are considered as in exponent/subscript;
expression with ( ) following a ^ or _ are considered as in exponent/subscript;
parentheseses are removed (if no sign before) except in case of exponent and only digits.
Get rid of 1*.. ..*1. example: in 1 * x, x/1, the 1 is removed.
Replace scientific notation (for example) 35E-05 by 10 power and add multiplication sign. Remove the + or 0 useless.
Replace some names as greek letters by their equivalents.
Remove * or replace by multiplication sign.
Replace <=, >=, ->, =>, <=> by their html/mathml equivalents if possible.
Sample(s):
Command
Result
!mathmlmath 1*x+3*y = 35E-05
!mathmlmath 2x, 2*x
!mathmlmath x2, x_2, x^2
mathsubst
Type:
both execution and variable command
Syntax:
!mathsubst name=val in expr
Aliases:
mathsubstit, mathsubstitute
Meaning:
Manipulation of mathematical expressions: substitute variable name by val in expr.
No regular expression is allowed in name.
See also the commands
!evalsubst,
!replace.
mexec
Type:
both execution and variable command; only for trusted modules (in particular administrative modules).
Syntax:
!mexec command parms
Meaning:
execute a module-private external command command with optional parameters parms.
command must be a valid program name in the module's home directory. But the command is
executed from the base directory of the server.
When used as variable command, returns the output of the called program.
module
Type:
both execution and variable command
Syntax:
!module defnamemodname
Meaning:
Returns the definition for defname of the module modname.
The most common use of this command is to get the title of a module
(defname is then title).
The INDEX file of the module modname will be parsed to look
for the definition of defname.
msg
Type:
execution command
Syntax:
!msg error [parm]
Meaning:
Put an error message of type error, with eventual parm depending on error.
nocache
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!nocache
nonempty
Type:
both execution and variable command
Syntax:
!nonempty objcontent
Aliases:
non_empty
Meaning:
obj can be item or line. The non-empty items or lines in content will be extracted.
nospace
Type:
both execution and variable command
Syntax:
!nospace string
Meaning:
Collapses all space characters (' ', tab, newline) in string.
nosubst
Type:
variable command
Syntax:
!nosubst string
Meaning:
Returns string as-is, without variable substitution.
passcheck
Type:
only for trusted modules (in particular administrative modules).
Syntax:
!passcheck word and list2
Meaning:
compare the (non crypted) word to the list of crypted words list2
(crypted words begin by *) and return yes if its crypted version is equal
to one of them
passcrypt
Type:
only for trusted modules (in particular administrative modules).
Syntax:
!passcrypt word
Meaning:
return word crypted (an * is added at the beginning of the
crypted result); word must contain only alphanumeric characters.
pedia
Type:
both execution and variable command
Syntax:
!pedia keyword, name
Aliases:
encyclopedia, encyclo
Meaning:
Creates a hypertext link pointing to an online encyclopedia.
keyword will be the name under which the reference is looked for,
and should be a phrase with one or several words separated by space.
Examples: finite field or linear transformation.
name is the name of the link (i.e. what people see in their page, and can click on).
Actually wims use
Wikipedia
as the standard reference encyclopedia.
perl
Type:
both execution and variable command; only for trusted modules (in particular administrative modules).
Syntax:
!perl
positionof
Type:
both execution and variable command
Syntax:
!positionof [type] s in string
Aliases:
position, positions
Meaning:
Reports the positions of the object s in string.
The word type can be char, word,
item, line or row.
If it is specified, then the comparison only takes place for
corresponding objects of string which are identical to s.
The output of the command is a list of positions (char, word, item,
line or row, according to the value of type) where s is found in string.
Here, rows are separated by semi-colon ; and lines by new lines.
If type is missing, then s is searched in string as a substring,
and the positions reported are character positions (more precisely,
the positions of the previous character of s in string).
product
Type:
both execution and variable command
Syntax:
!product fn for v=v1 to v2 [step st] !product fn for v in v1,v2,v3,...
Aliases:
prod, multiply
Meaning:
Computes the product of a function fn(v) with variable v replaced
successively by values v1, ..., v2.
In the second syntax, the values are given with respect to each item in the list v1,v2,....
randchar
Type:
variable command
Syntax:
!randchar str
Meaning:
Returns a random character in str.
randfile
Type:
variable command
Syntax:
!randfile fname
Aliases:
randrecord
Meaning:
Returns a random record in the datafile fname.
randint
Type:
variable command
Syntax:
!randint n1, n2 !randint n1, n2 repeat i
Meaning:
Returns a random integer between n1 and n2 (inclusive).
Substitution and evaluation are done on n1 and n2 before applying random.
If n2 is missing, returns random integer between 1 and n1 (inclusive).
If both n1 and n2 are missing, returns 0.
You can also type !randint n1, n2 repeat i to repeatedly generate
i random integers.
randitem
Type:
variable command
Syntax:
!randitem list
Meaning:
Returns a random item in list. Items are separated by commas.
randline
Type:
variable command
Syntax:
!randline str
Meaning:
Returns a random line in str.
random
Type:
variable command
Syntax:
!random n1, n2
Aliases:
randdouble, randfloat
Meaning:
Returns a random real number between n1 and n2.
Substitution and evaluation are done on n1 and n2 before applying random.
If n2 is missing, returns random number between 0 and n1.
If both n1 and n2 are missing, returns 0.
You can also type !random n1,n2 repeat i to repeatedly generate
i random numbers.
randword
Type:
variable command
Syntax:
!randword str
Meaning:
Returns a random word in str.
rawmath
Type:
both execution and variable command
Syntax:
!rawmath expr
Meaning:
Translate the mathematical expression expr, possibly with common user errors,
into a machine-understandable mathematical expression.
It will replace (x+1)(x-1) into (x+1)*(x-1), 5x^3 into 5*x^3, etc.
More precisely,
Replace some badcharacters as **, ², ³.
translate ++, +-, -+, ... into one sign
translate | | in abs
replace new lines or tabs by spaces
add zero in case of decimal digits if necessary: for example, replace 4. by 4.0 and .5 -> 0.5
replace justapositions by multiplications if rawmatheasy=yes
rawmatrix
Type:
both execution and variable command
Syntax:
!rawmatrix expr
Meaning:
Translate the matrix expr, possibly with common user errors,
into a machine-understandable matrix expression.
reaccent
Type:
both execution and variable command
Syntax:
!reaccent string
Meaning:
Replace accented letter compositions in string by accented letters
(replacing e' by é, a` by à,
i" by ï, o^ by ô, etc.)
The only exception is that ç and Ç are composed from c~
and C~ respectivement.
read
Type:
execution command
Syntax:
!read file [parm]
Aliases:
include, input
Meaning:
Insert the content of file, and process it. file must be a valid file name with
the module's home directory as base directory. (directory structure may be specified in file,
but backtracing to parent directories is prohibited.)
And the parameter parm can be accessed from within
the called file under the variable name wims_read_parm.
WIMS will try to cache the file for repeated use, unless the filename is preceded by "./".
readdef
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!readdef
readproc
Type:
execution command
Syntax:
!readproc file [parm]
Meaning:
Include a variable processing file file. file must be a valid file name
with the module's home directory as base directory. (directory structure may be specified
in file, but backtracing to parent directories is prohibited.)
And the parameter parm can be accessed from within
the called file under the variable name wims_read_parm.
record
Type:
both execution and variable command
Syntax:
!record numlist of fname
Aliases:
records
Meaning:
Outputs selected records of the datafile fname, according to numlist.
numlist can be a single integer, a comma-separated list of
integers, or a range of integers.
A positive integer denotes the number of record in fname
counted from the beginning,
with 1 corresponding to the first
record. A negative integer denotes the number of record from
the end of fname: -1
means the last record, -2 means
the next-to-last record, etc.
The syntax for a range of integers is
n1 to n2.
For example, 2 to -2
means the whole fname except the first
and the last records.
recordcnt
Type:
variable command
Syntax:
!recordcnt fname
Aliases:
recordcount, recordno, recordnum
Meaning:
Returns the number of records in the datafile fname.
recursion
Type:
both execution and variable command
Syntax:
!recursion fn for v=v1 to v2 [step st] !recursion fn for v in v1,v2,v3,...
Meaning:
Computes the outcome of a recursion using the function fn in which the
variable v is replaced successively by values v1, ..., v2.
In the second syntax, the values are given with respect to each item in
the list v1,v2,....
The function fn should use the variable last to indicate the value of the previous
recursion step. And the starting value can be put into the WIMS variable
$recursion_start.
reinput
Type:
both execution and variable command
Syntax:
!reinput string
Meaning:
Prepares string to be inserted into a form input or textarea.
Browsers translate & primitives into corresponding (special) characters
even when these primitives occur in input or textarea fields. Also, if
string contains html tags, they may confuse browsers. You can
use this command on the string (usually derived from an earlier user input)
before inserting them back into a input or textarea, to avoid the above problems.
rename
Type:
both execution and variable command
Syntax:
!rename f
Meaning:
Changes the reference to a file f, such as a graphics file reachable by direct http,
into one with a different name using the method !getfile.
This command is useful with exercises where important information is carried
by multimedia files (pictures, audios, movies). It can be used to hide the
name of the multimedia file that otherwise would give clues to the solution
of the problem.
The renamed file must be located within the module, and the filename f should start
with $module_dir.
The command returns a string which is the new URL. The file is not
effectively copied or renamed on the server.
replace
Type:
both execution and variable command
Syntax:
!replace [internal] s1 by s2 in string !replace objident by s in string
Meaning:
String manipulation.
Under the first syntax, variable substitution is first done on string.
Then all occurences of substring s1 are replaced by s2.
When the keyword internal is absent, the Linux utility sed is called to make the replacements,
therefore regular expressions are accepted in s1 and s2.
Please refer to the man page of sed for details.
Under the second syntax, obj can be char, word, item or line.
Then the word, item or line identified by ident in string is replaced
by s, after variable substitutions. ident can be a string, in this case all objects (words, items or lines) matching ident
will be replaced. It can also be a number (positive or negative integer n), preceded
by the word number. In this case the object number n will be replaced.
(In the case where n<0, it is the last -n th object which is replaced.)
reset
Type:
execution command
Syntax:
!reset name1 [ ,name2,...] names[1O]
Meaning:
erase the content of the variable(s) name1, name2,
..., names1, names2,..., names10
restart
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!restart parm
Meaning:
Restart from a new request with parameters parm, usually for jumping to another module.
This command can be only used before output starts. Repeated restart is disabled,
to avoid infinite loops.
robotrap
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!robotrap
Aliases:
robottrap
lines2rows
Type:
both execution and variable command
Syntax:
!rows2lines string
Meaning:
This command changes multiple rows in string into lines (the separator is
the line break).
select
Type:
both execution and variable command
Syntax:
!select data where condition
Meaning:
Outputs rows of a matrix data, according to condition.
Rows of the matrix can be separated either by new lines or by semi-colon ;.
The condition can use words column 1, column 2, etc. to
designate comma-separated columns in each row.
setdef
Type:
execution command
Syntax:
!setdef defstr in fname
Meaning:
Set definitions defstr in the file fname.
setseed
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!setseed
sh
Type:
both execution and variable command; only for trusted modules (in particular administrative modules).
Syntax:
!sh
shortout
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!shortout
shuffle
Type:
variable command
Syntax:
!shuffle [even|odd] n !shuffle [even|odd] list
Aliases:
randperm, randpermute
Meaning:
Randomly permutes a set of n elements. n must be a positive integer
not greater than 1024 in the first usage, or is the number of items in list in the second
usage.
For the first usage, the command returns a comma-separated list i1, i2, ...,
in, where the items ik are
randomly ordered elements of the set {1,2,...,n}.
This command can be used in conjunction with commands
!item,
!line,
!word,
!char,
to randomly permute items, lines, words, or characters in a string.
For the second usage, a new list with randomly permuted items in list is returned.
In any case, the variable wims_shuffle_order is set to be
the list i1, i2, ..., in.
When the optional word even or odd is present, only even/odd permutations are produced.
singlespace
Type:
both execution and variable command
Syntax:
!singlespace string
Meaning:
Returns string with all space characters (space, tab, newline) replaced by ,
and multiple occurrences of space characters collapsed into single one.
Leading and ending spaces are not removed. You can use this command in conjunction with
trim if you want also to
remove leading and ending spaces.
This command is especially useful for comparisons between multi-word strings.
solve
Type:
both execution and variable command
Syntax:
!solve fn for v=v1 to v2
Aliases:
rootof
Meaning:
Find out (real simple) roots of the function/equation fn
for the variable v between v1 andv2.
fn may have several roots in the interval [v1,v2], but
roots too close to each other may be overlooked.
sort
Type:
both execution and variable command
Syntax:
!sort [nocase] [reverse] [numeric] type [of] string
Meaning:
Sort string. The type of the sort may be char, word, list
(equivalently item) or line.
After this command is executed, the sort order is stored in the variable
wims_sort_order (as a list). This can therefore be used
for relational sorting, in conjunction with commands
!item,
!line,
!word or
!char.
Sample(s):
Command
Result
!sort list 0,4,2
0,2,4
!sort reverse list 0,4,2
4,2,0
!sort list 10,4,2
10,2,4
!sort numeric list 10,4,2
2,4,10
sum
Type:
both execution and variable command
Syntax:
!sum fn for v=v1 to v2 [step st] !sum fn for v in v1,v2,v3,...
Aliases:
add
Meaning:
Computes the sum of a function fn(v) with variable v replaced successively
by values v1, ..., v2.
In the second syntax, the values are given with respect to each item in the list v1,v2,....
tail
Type:
execution command
Syntax:
!tail parm
Meaning:
Standardized ending for html page outputs. Includes the command !homeref.
parm is reserved for future implementation.
texmath
Type:
both execution and variable command
Syntax:
!texmath expr
Aliases:
TeXmath, math2tex
Meaning:
Translate the mathematical expression expr into a TeX source. If the expression
is not a "machine-understandable mathematical expression", like products without *,
there is no garanty on the result
(at the moment and in the future !). See examples below.
Il might be useful to use !rawmath before applying !texmath.
The following transformations are performed:
Transform computer matrix as [ 4,5;6,7] in latex matrix.
Transform A/B in {1 over B} A or { A over B} according to the priority of
the presume type of A and B (integer, numeric, variable, poly, transcend).
transforms <=, <=> =>, -> in tex/latex codes.
Transform a relation without a second member by adding 1.
Replace scientific notation 35E-05 by 10 power and add multiplication sign. Remove the + or 0 useless.
Remove the stars *.
Replace some names as greek letters by their equivalents.
interpret sum(), integrate, prod () (coming from maxima ) in tex/latex codes.
Sample(s):
Command
Result
!texmath 1*x+3*y = 35E-05
x +3 y=35 \times 10^{-5}
!texmath 2x, 2*x
2,2 x
!texmath x2, x_2, x^2
x _2 ,x_{2},x^2
text
Type:
both execution and variable command
Syntax:
!text operationparameter
Meaning:
This is intended to be a very powerful text manipulation tool,
allowing very sophisticated processing of long text strings with high speed.
Many of the operations accept masks. A mask is a string composed of 0s and 1s.
For operations which accept a mask, only characters at positions whose corresponding
character in the mask is not a 0 are processed. (In this sense positions
corresponding to 0s are masked.) Empty mask is considered
as of being entirely composed of 1s.
A mask which is too short repeats itself, unless it terminates with a +,
in which case it fills the rest with 1s, or with a -, in which case
it fills the rest with 0s.
For the time being, implemented operations are as follows.
!text common text1 and text2 [mask maskstring]
Extracts characters in text1 one by one, for those identical
to the corresponding characters in text2 and whose
positions are not masked by maskstring.
!text compare text1 and text2
Compares the strings text1 and text2 character by character,
and returns a mask string with 0s on positions where the corresponding characters in text1
and text2 are equal, and 1s otherwise.
!text copy text [mask maskstring]
Returns non-masked characters in text.
!text count charlist in text [mask maskstring]
Returns the number of characters in text whose positions
are not masked by maskstring, and who appear in charlist.
!text diff text1 from text2 [mask maskstring]
Extracts characters in text1 one by one, for those different to the corresponding
characters in text2 and whose positions are not masked by maskstring.
(Synonyme of diff: differ).
!text expand text using maskstring
Produces a string, where positions corresponding to 0s in
maskstring are filled by (the space character),
and where positions corresponding to 1s in maskstring are filled by characters of
text. The characters in text are used one by one, and the
resulting string stops when all the characters in text are exhausted
(or when the string reaches the length limit).
!text insert text1 into text2 [mask maskstring]
Returns text2 with non-masked characters replaced by characters text1.
Characters in text1 are used one by one (without taking into account the masking), and
the replacement stops when there is no character left in text1.
!text interact text1 and text2 table itab [mask maskstring]
Returns a new text which is result of interactions of characters
in corresponding positions in text1 and text2. The rule of the interaction is defined in
itab. itab contains n+1 lines, each of n characters.
The first line defines the characters corresponding to each position
in the following n lines which defines the multiplication table.
The multiplication table needs not to be symmetric. In this case, the rows correspond
to characters in text1, and the columns correspond to characters in text2.
If text1 or text2 contains a character not in the first line of itab,
the interaction at the corresponding position is considered as empty. Also, masked
positions are ignored.
If text1 and text2 have different lengths, the longer is cut to fit the shorter.
!text mark charlist in text
Returns a mask string with 1s on positions where the corresponding character in text
appears in charlist, and with 0s on other positions.
!text max text1 and text2 [mask maskstring]
Returns a string which at each position is the character with highest
ASCII code between corresponding characters in text1 and text2.
The length of the result is that of the longest of the two. Masked positions are skipped.
!text min text1 and text2 [mask maskstring]
Returns a string which at each position is the character with lowest
ASCII code between corresponding characters in text1 and text2.
The length of the result is that of the
shortest of the two. Masked positions are skipped.
!text occur charlist in text [mask maskstring]
Returns characters in charlist which occur in unmasked positions in text.
(Synonymes of occur: appear, occurrence).
!text remove charlist in text [mask maskstring]
Returns text in which masked characters and characters
appearing in charlist are removed. (Synonymes of remove: drop, delete).
!text reorder text by orderlist
Returns a reordered text using the order list orderlist. Reordering is cyclic
if orderlist is shorter than text. orderlist must be a list of n positive integers, which
is a permutation of the set {1,...,n}. If orderlist contains
items other than integers within the bound, empty string is returned.
However, unicity check is not performed on items of orderlist.
!text repeat text to len
Repeat the string text cyclicly, up to length len.
!text reverse text
Reverse the order of text, with the last character coming first, etc.
!text select charlist in text [mask maskstring]
Returns text in which masked characters and characters not appearing in
charlist are removed. (Synonymes of select: pick, pickup).
title
Type:
execution command
Syntax:
!title parm
Aliases:
htmltitle, wimstitle
Meaning:
Puts page's title in a standardized format. parm is reserved for future implementation.
translate
Type:
both execution and variable command
Syntax:
!translate [internal] s1 to s2 in string !translate [internal] s1 in string to s2
Meaning:
String manipulation: variable substitution is first done on string.
Then all occurences of the first (resp. second, ...)
character of s1 is replaced by the first (resp. second, ...)
character of s2.
When the keyword internal is absent, the Linux utility tr is called to make the translations,
therefore regular expressions are accepted in s1 and s2.
Please refer to the man page of tr for details.
trim
Type:
variable command
Syntax:
!trim string
Meaning:
Returns string with leading and trailing spaces stripped off.
upper
Type:
both execution and variable command
Syntax:
!upper string
Aliases:
uppercase, toupper
Meaning:
Returns string with all lower case letters replaced by their uppercase counterparts.
usererror
Type:
execution command; only for trusted modules (in particular administrative modules).
Syntax:
!test
values
Type:
both execution and variable command
Syntax:
!values fns for v=v1 to v2 [step st] !values fns for v in v1,v2,v3,...
Meaning:
Outputs a list of values of fns with variable v replaced successively by values
v1, ..., v2.
In the second syntax, the values are given with respect
to each item in the list v1,v2,....
fns may be a comma-separated list of functions.
This command can also be used to make recursions. If the functions
fns contain a variable named last, this variable
will take the value of the last step each time. And the starting value
can be put into the WIMS variable $recursion_start.
varlist
Type:
both execution and variable command
Syntax:
!varlist [nofn] formula
Aliases:
listvar
Meaning:
Manipulation of mathematical expressions: returns list of variable
names (and function names) appearing in the formula.
If the switch nofn is present, function names will not be listed.
warn
Type:
execution command
Syntax:
!warn subject
Aliases:
warning
Meaning:
Outputs a warning message related to subject. Does nothing if no warning
message about subject is present.
while
Type:
execution command
Syntax:
!while string1 relation string2
Meaning:
Conditional branching: execute the multi-line content between
!while line and !endwhile line, until relation is no longer verified.
The leading and trailing spaces of string1 and string2 will be stripped
before making comparisons.
Syntax:
Same as the command while, but = (==), != compares the numerical values of string1 and string2 rather than the strings themselves.
word
Type:
both execution and variable command
Syntax:
!word numlist of string
Aliases:
words
Meaning:
Outputs selected words of string, according to numlist.
numlist can be a single integer, a comma-separated list of
integers, or a range of integers.
A positive integer denotes the number of word in string
counted from the beginning,
with 1 corresponding to the first
word. A negative integer denotes the number of word from
the end of string: -1
means the last word, -2 means
the next-to-last word, etc.
The syntax for a range of integers is
n1 to n2.
For example, 2 to -2
means the whole string except the first
and the last words.
wordcnt
Type:
variable command
Syntax:
!wordcnt string
Aliases:
wordcount, wordno, wordnum
Meaning:
Returns the number of words in string.
words2items
Type:
both execution and variable command
Syntax:
!words2items string
Aliases:
wordstoitems, words2list, wordstolist
Meaning:
This command changes multiple words in string into multiple items.
words2lines
Type:
both execution and variable command
Syntax:
!words2lines string
Aliases:
wordstolines
Meaning:
This command changes multiple words in string into multiple lines.
Besides, large parentheses are available under the name of
$m_leftpar2, $m_leftpar3,..., $m_leftpar10 and
$m_rightpar2, $m_rightpar3,..., $m_rightpar10. They can be used
to inclose matrices of 2,3,...,10 rows. Ditto for leftbrace
and rightbrace.
Scripts in this library can be called from modules using the command
!read (or !readproc from within a phtml file).
For example, the line
!read slib/matrix/random 3, 5, 10
generates a 3×5 matrix with random integer coefficients in [-10, 10].
The result is placed in the variable
slib_out.
To call an slib script from OEF exercises, documents or forum
messages, use the function
slib().
Only variables prefixed by
slib_
are modified by these scripts.
In the following table, [color]
may be either a color name, or 3 integers between 0 and 255, separated by commas,
for the values of red,green,blue.
Drawing commands
-
Synonymes
affine a,b,c,d,tx,ty
Make an affine transformation for the subsequent objects: (x;y) -> [a,b;c,d](x;y)+(tx;ty).
alt texte
This command is only available for WIMS OEF and doc and MUST appear on the first line. It gives the attribut alt="text" to the image.
animate fra,del,rep
This command is only available for WIMS OEF and doc, and MUST appear on the first line or after the command alt. Set up animation for fra frames, with del seconds between frames, and rep repetitions (rep=0 means infinite repetition). Frame control is done via two variables: animstep (integer) going from 1 to frame count, and s going from 0 to 1.
animstep n
Set up an integer which can be called in any evaluation. Used for animation. Direct use of this command must be avoided under WIMS.
arc x,y,w,h,a1,a2,[color]
Arc segment of an ellipse of width w and hight h centered at (x,y), from angle a1 to angle a2 (in degrees).
arrow x1,y1,x2,y2,l,[color]
Arrow (x1,y1)--->(x2,y2), where l is the length (in pixels) of arrowhead.
arrow2 x1,y1,x2,y2,l,[color]
Two sided arrow (x1,y1)<--->(x2,y2), where l is the length (in pixels) of arrowhead.
circle x,y,d,[color]
Circle of center (x,y) and diameter d (in pixels).
circles [color],x1,y1,d1,x2,y2,d2 ...
Circles of center (x1;y1) and diameter d1 (according to xrange) ...
comment
Does nothing.
copy x,y,x1,y1,x2,y2,[filename]
insert
Insert the region from (x1,y1) to (x2,y2) (in pixels) of [filename] to (x,y). If x1=y1=x2=y2=-1, the whole [filename] is copied. [filename] is the address of the file from the directory wims/public_html/gifs or from the directory common_images for OEF modules.
Insert the region from (x1,y1) to (x2,y2) (in pixels) of [filename], possibly resized, to the region of (dx1,dy1) to (dx2,dy2). If x1=y1=x2=y2=-1, the whole [filename] is copied and resized.
crosshair x1,y1,[color]
draw a crosshair point at (x1,y1)
crosshairs [color], x1,y1,x2,y2,...
draw multiple crosshair points at given coordinates (x1,y1), (x2,y2), ...
crosshairsize w
Set crosshair size to w (in pixels).
darrow x1,y1,x2,y2,l,[color]
dasharrow dashedarrow
Dashed arrow (x1,y1)- - ->(x2,y2), where l is the length (in pixels) of arrowhead.
darrow2 x1,y1,x2,y2,l,[color]
dasharrow2 dashedarrow2
Two sided dashed arrow (x1,y1)<- - ->(x2,y2), where l is the length (in pixels) of arrowhead.
Flood fill the region containing (x,y) with the same original color by double hatching (parallel lines), (nx,ny) being the horizontal and vertical distance between adjacent lines (in pixels).
dline x1,y1,x2,y2,[color]
dashedline dashline
Segment en pointillés entre les points de coordonnées (x1; y1) et (x2; y2).
dlines [color],x1,y1,x2,y2,x3,y3...
dashedlines dashlines
n dashed line segments (x1,y1)---(x2,y2)---(x3,y3)...
dotfill x,y,nx,ny,[color]
pointfill diskfill
Flood fill the region containing (x,y) with the same original color by (fat) dots at each (nx,ny) pixels.
Ellipse with center (x1,y1), width w1 and height h1 etc.
fcircle x,y,d,[color]
ball disk filledcircle
Filled circle of center (x,y) and diameter d (in pixels).
fellipse x,y,w,h,[color]
filledellipse
Filled ellipse with center (x,y), width w and height h.
fill x,y,[color]
flood floodfill
Flood fill the region containing (x,y) with the same original color, by color.
filltoborder x,y,[color1],[color2]
Flood fill by color2 the region containing (x,y) and bounded by color1.
fpoly [color],x1,y1,x2,y2,x3,y3...
filledpoly filledpolygon fpolygon
Filled polygon (x1,y1)-(x2,y2)-(x3,y3)...
frect x1,y1,x2,y2,[color]
filledrect fillecrectangle frectangle
Filled rectangle with corners (x1,y1) and (x2,y2).
fsquare x,y,s,[color]
filledsquare
Filled square with sides s (in pixels) and first corner at (x,y).
ftriangle x1,y1,x2,y2,x3,y3,[color]
filledtriangle
Filled triangle with vertices (x1,y1),(x2,y2),(x3,y3).
gridfill x,y,nx,ny,[color]
Flood fill the region containing (x,y) with the same original color by a grid of horizontal and vertical lines with distance (nx,ny) (in pixels).
hatchfill x,y,nx,ny,[color]
Flood fill the region containing (x,y) with the same original color by hatching (parallel lines), (nx,ny) being the horizontal and vertical displacement of adjacent lines (in pixels).
hline x,y,[color]
horizontalline
Horizontal line through (x,y).
interlace
Set interlaced image
killaffine
Reset affine transformation to identity.
killbrush
Turns off brush selection for line drawing.
killlinear
killrotation killrotate
Reset linear transformation to identity.
killtile
Turns off tile selection for filling.
killtranslation
killtranslate
Reset translation to identity.
lattice x0,y0,x1,y1,x2,y2,n1,n2,[color]
A lattice of n1xn2 points starting with (x0,y0), with n1 rows in direction of (x1,y1) and n2 rows in direction of (x2,y2).
levelcurve [color],expression,l1,l2,...
Draws level curves for expression, with levels l1, l2,...
levelstep n
Set the number of pixel steps in levelcurve plotting. Between 1 and 16, defaults to 4.
linear a,b,c,d
Make a linear transformation for the subsequent objects: (x;y) -> [a,b;c,d](x;y).
linewidth w
Set line width to w (in pixels) for line drawing.
multicopy n1,n2,...,nk, [filename]
Copy the image [filename] in the parallelogram given by parallelogram command (with deformation) and apply to it the transformations n_1, ..., n_k (up to 19). If no n1 ... are given, all the transformations are applied. So setparallelogram and some setvector or setmatrix or settransform must be previously defined.
new x,y
Set a new image of size x,y.
output [filename]
Output the current image to [filename].
parallel x1,y1,x2,y2,xv,yv,n,[color]
n parallel lines starting from (x1,y1)---(x2,y2), with displacement (xv,yv).
pixels [color],x1,y1,x2,y2,...
Points (all of diameter 1) at (x1,y1), (x2,y2), ...
plot [color],[formula]
curve
Plot a curve according to [formula] which can be either an explicit function of x, or a pair of parametric functions in t.
plotjump j
Plotted curve will jump if two consecutive points have distance more than j pixels. Useful to avoid plotting discontinuous functions as continuous. Default value: 200.
plotstep n
plotsteps tstep tsteps
Set the number of point computations in curve plot. Defaults to 100.
point x,y,[color]
A (fat) point at (x,y), whose diameter is equal to linewidth.
points [color],x1,y1,x2,y2,...
(Fat) points at (x1,y1), (x2,y2), ..., whose diameters are equal to linewidth.
polygon [color],x1,y1,x2,y2,x3,y3...
poly
Polygon (x1,y1)-(x2,y2)-(x3,y3)...
polyline [color],x1,y1,x2,y2,x3,y3...
brokenline lines:deprecated
n line segments (x1,y1)---(x2,y2)---(x3,y3)...
range x1,x2,y1,y2
Set the drawing range to [x1,x2] horizontally and [y1,y2] vertically. Note that by default, horizontal range is [0,xsize-1] and vertical range is [ysize-1,0].
rays [color],x0,y0,x1,y1,x2,y2...
Line segments (x0,y0)---(x1,y1), (x0,y0)---(x2,y2), ...
rect x1,y1,x2,y2,[color]
rectangle
Rectangle with corners (x1,y1) and (x2,y2).
resetmatrix n
Reset n-th linear or affine transformation to identity.
resetparallelogram
kill setparallelogram
resetvector n
Reset n-th translation to identity.
resettransform n
Reset n-th linear, affine transformation and n-th translation to initial values (identity or null vector).
rotation d
rotate
Make a rotation of degree d counter-clockwise (centered at (0,0)), for the subsequent objects.
segment x1,y1,x2,y2,[color]
seg line:deprecated
Line segment (x1,y1)---(x2,y2).
segments [color],x1,y1,x2,y2,x3,y3,x4,y4, ...
Line segments (x1; y1)---(x2; y2), (x3; y3)---(x4; y4), ...
setbrush [filename]
Use the image [filename] as a brush for all line draws.
setmatrix n,a,b,c,d
Make the n-th linear transformation for multicopy objects: (x;y) -> [a,b;c,d](x;y).
setparallelogram xs,ys,xu,yu,xv,yv
Prepare the place where the image will be copied by multicopy (mathematical coordinates) : xs,ys mathematical coordinates of the origin point, xu,yu mathematical coordinates of the "horizontal line of the image" to copy, xv,yv mathematical coordinates of the "verticale line of the image" to copy.
setpixel x,y,[color]
A point (of diameter 1 pixel) at (x,y).
setstyle [color1],[color2],...
Set the line style to color1,color2,...
settile [filename]
Use the image [filename] as a tile for all filling commands.
settransform n,a,b,c,d,tx,ty
Make the n-th linear transformation for multicopy objects: (x;y) -> [a,b;c,d](x;y) + (tx;ty). (settransform n,a,b,c,d,tx,ty is equivalent to setmatrix n,a,b,c,d and setvector n,tx,ty, so it kills a previous definition setmatrix n,a,b,c,d with the same number n).
setvector n,tx,ty
Make the n-th translation for multicopy objects: (x;y) -> (tx,ty).
size x,y
Set the image size to x pixels horizontally and y pixels vertically.
square x,y,s,[color]
Square with sides s (in pixels) and first corner at (x,y).
text [color],x,y,[font],[string]
print string write
Write the string at (x,y), with font=small,medium,large or giant.
textup [color],x,y,[font],[string]
stringup writeup
Write upwards the string at (x,y), with font=small,medium,large or giant.
trange t1,t2
ranget
Set the t range to [t1,t2] for parametric curve plotting. Defaults to [0,1].
translation tx,ty
translate
Make a translation for the subsequent objects: (x;y) -> (x;y)+(tx;ty).
transparent [color]
Makes [color] a transparent color.
triangle x1,y1,x2,y2,x3,y3,[color]
Triangle with vertices (x1,y1),(x2,y2),(x3,y3).
vimg n
Enable (1) or disable (0) vector graphics output.
vimgfile [filename]
Direct vector graphics output (currently DXF only) to [filename].
vline x,y,[color]
verticalline
Vertical line through (x,y).
xrange x1,x2
rangex
Set the horizontal drawing range to [x1,x2]. Defaults to [0,xsize-1].
yrange y1,y2
rangey
Set the horizontal drawing range to [y1,y2]. Defaults to [ysize-1,0].
line width of any object can be controlled by command linewidth int
any may be dashed by using keyword dashed before the object command. the dashing type can be controled by command dashtype int,intplease note: dashing may have different spacing depending on the angle of the line see https://wimsedu.info/?topic=dashed-arrows-not-dashed-in-canvasdraw
a fillable object can be set fillable by starting the object command with an f (like frect,fcircle,ftriangle ...) or by using the keyword filled before the object command. The fill colour of non_userdraw objects will be the stroke colour...(flydraw harmonization 19/10/2013) non-solid filling (grid,hatch,diamond,dot,text) is provided using command fillpattern a_pattern note: do not use a f with this non-solid pattern filling ! for filltoborder x0,y0,color or fill x0,y0,color type filling (eg fill a region around x0,y0 with color until a border is encountered), there are non-solid pattern fill analogues:
all draggable objects may have a slider for translation / rotation; several objects may be translated / rotated by a single slider
a draggable object can be set draggable by a preceding command drag x/y/xy The translation can be read by javascript:read_dragdrop();The replyformat is: object_number : x-orig : y-orig : x-drag : y-drag The x-orig/y-orig will be returned in maximum precision (javascript float)... the x-drag/y-drag will be returned in defined precision number of decimals Multiple objects may be set draggable / clickable (no limit) not all flydraw objects may be dragged / clicked Only draggable / clickable objects will be scaled on zoom and will be translated in case of panning.
a onclick object can be set clickable by the preceding keyword onclick not all flydraw objects can be set clickable
remarks using a ; as command separator. Commands with only numeric or colour arguments may be using a ; as command separator (instead of a new line). Commands with a string argument may not use a ; as command separator ! these exceptions are not really straight forward... so keep this in mind.
almost every command for a single object has a multiple objects counterpart:
general syntax rule:
object x1,y1,...,color
objects color,x1,y1,...
All inputfields or textareas generated, can be styled individually using command css some_css the fontsize used for labeling these elements can be controlled by command fontsize int command fontfamily is not active for these elements
If needed multiple interactive scripts (*) may be used in a single webpage. A function read_canvas() and / or read_dragdrop() can read all interactive userdata from these images. The global array canvas_scriptswill contain all unique random "canvas_root_id" of the included scripts. The included local javascript "read" functions read_canvas%d() and read_dragdrop%d() will have this %d = canvas_root_id e.g. canvas_scripts[0] will be the random id of the first script in the page and will thus provide a function fun = eval("read_canvas"+canvas_scripts[0]) to read user based drawings / inputfield in this first image. The read_dragdrop is analogue. If the default reply formatting is not suitable, use command replyformat to format the replies for an individual canvas script, To read all user interactions from all included canvas scripts, use something like: function read_all_canvas_images(){ var script_len = canvas_scripts.length; var draw_reply = ""; var found_result = false; for(var p = 0 ; p < script_len ; p++){ var fun = eval("read_canvas"+canvas_scripts[p]); if( typeof fun === 'function'){ var result = fun(); if( result && result.length != 0){ if(script_len == 1 ){.return result;}; found_result = true; draw_reply = draw_reply + result + "newline"; }; }; }; if( found_result ){return draw_reply;}else{return null;}; }; (*) Note: the speed advantage over canvas-do-it-all libraries is reduced to zero, when multiple canvasdraw scripts are present in a single page... For example a typical canvasdraw script is between 5 and 40 kB...a large library like JSXgraph is approx 600 kB In these cases it would be much faster to load a static general HTML5 canvas javascript draw library and parse it multiple raw fly instructions !
Canvasdraw can be used to paint a html5 bitmap image by generating a tailor-made javascript include file: providing only the js-functionality needed to perform the job. thus ensuring a minimal strain on the client browser (unlike some popular canvas-do-it-all libraries, who have proven to be not suitable for low-end computers found in schools...)
You can check the javascript reply format in the wims tool direct exec
For usage within OEF (without anstype draw), something like this (a popup function plotter) will work: ext{popup_grapher=wims(exec canvasdraw popup size 400,400 xrange -10,10 yrange -10,10 axis axisnumbering opacity 100,100 grid 2,2,grey,2,2,6,black snaptogrid linewidth 2 jsplot red,5*sin(1/x) strokecolor green functionlabel f(x)= userinput function mouse blue,22 ) } \statement{ \popup_grapher }.
Be aware that older browsers will probably not work correctly no effort has been undertaken to add glue code for older browsers !! in any case it is not wise to use older browsers...not just for canvasdraw.
Be aware that combining several different objects and interactivity may lead to problems.
If you find flaws, errors or other incompatibilities -not those mentioned in this document- send me an email with screenshots and the generated javascript include file.
There is limited support for touch devices: touchstart, touchmove and touchend in commands userdraw primitives , multidraw primitives , protractor, ruler and probably a few others... Only single finger gestures are supported (for now). The use of a special pen is advised for interactive drawing on touch devices. For more accurate user-interaction (numeric, eg keyboard driven drawings) with canvasdraw on touch devices: use the command family userinput.
all other canvas object or group of objects (like lines,circles,rects,points...images,svg,latex,mathml etc) may be animated using command slider with keyword 'anim'
the animated point is a filled rectangle ; adjust colour with command fillcolor colorname/hexnumber
use linewidth to adjust size of the points
will animate a point on -only- the next jsplot/jscurve command. Only a single call to animate is allowed...in case of multiple animate keywords, only the last one is valid
only usable in combination with command jsplot (normal functions or parametric)
for arrow hat: type = 1 : right type = 2 : left type = 3 : left&right
if the default arrow hat/head is not satisfactory , the size of the arrow may be set with command arrowhead
no other arrow types are implemented...yet
may be set draggable or onclick
attention: when width ad height are very different, the arrow hat is not drawn correctly. This is a flaw and not a feature...(for now: too much calculations to correct)
example: xrange 0,300 yrange 0,10 boxplot x,4,8,120,160,170,220,245 meaning: create a boxplot in x-direction, with height 4 (in yrange) and centered around line y=8
example: xrange 0,10 yrange 0,300 boxplot y,4,8,120,160,170,220,245 meaning: create a boxplot in y-direction, with width 4 (in xrange) and centered around line x=8
use command filled to fill the box note: the strokecolor is used for filling Q1, the fillcolor is used for filling Q3
adds a button to clear the userdraw canvas with text value
attention command clearbutton is incompatible with multidraw based drawings (in multidraw there is always a remove_object_button for every draw primitive)
normally userdraw primitives have the option to use middle/right mouse button on a point of the object to remove this specific object...this clear button will remove all drawings
uses the tooltip placeholder div element: may not be used with command intooltip
the clearbutton will have id="canvas_scripts[%d]" ; starting with %d=0 for the first script to change the style of all clearbutton of all included canvasdraw scripts, use something like if(document.getElementById("clearbutton"+canvas_scripts[0])){ var p = 0; while(document.getElementById("clearbutton"+canvas_scripts[p])){ document.getElementById("clearbutton"+canvas_scripts[p]).className="some_class_name"; <!−− or document.getElementById("clearbutton"+canvas_scripts[p]).setAttribute("style","some_style"); −−> p++; }; };
use command opacity stroke-opacity,fill-opacity to adjust foreground (stroke) and background (fill) transparency
type hourglass: type = 0: only segments type = 1: only numbers type = 2: numbers and segments
colors are optional: if not defined, default values will be used default colours: clock 0,0,60,4,35,45,1,2 custom colours: clock 0,0,60,4,35,45,1,2,,,,yellow,red custom colours: clock 0,0,60,4,35,45,1,2,white,green,blue,black,yellow
if you don't want a seconds hand (or minutes...), just make it invisible by using the background color of the hourglass...
interactive
0: not interactive, just clock(s)
1: function read_canvas() will read all active clocks in H:M:S format The active clock(s) can be adjusted by pupils
2: function read_canvas() will return the clicked clock (like multiplechoice; first clock in script in nr. 0 )
3: no prefab buttons...create your own buttons (or other means) to make the clock(s) adjustable by javascript function set_clock(num,type,diff) wherein: num = clock id (starts with 0) ; type = 1 (hours) ; type = 2 (minutes) ; type = 3 (seconds) and diff = the increment of 'type' (positive or negative)
canvasdraw will not check validity of colornames...the javascript console is your best friend
no combinations with other reply_types allowed, for now
if interactive is set to 1, 6 buttons per clock will be displayed for adjusting a clock (H+ M+ S+ H- M- S-) set_clock(clock_id,type,incr) first clock has clock_id=0 ; type: H=1,M=2,S=3 ; incr: increment integer
note: if you need multiple -interactive- clocks on a webpage, use multiple clock commands in a single script ! and not multiple canvas scripts in a single page
note: clocks will not zoom or pan, when using command zoom
can be used with command userdraw clickfill,color when more than one fillcolor is wanted. in that case use for example replyformat 10 ... reply=x1:y1:color1,x2:y2:color2... the pupil can choose from the given colors by clicking small coloured buttons. the click coordinates and corresponding fillcolor will be stored in read_canvas()...when using the appropriate replyformat. the first color of the palette is color=0
Insert the region from (x1,y1) to (x2,y2) (in pixels) of [filename] to (x,y) in x/y-range
If x1=y1=x2=y2=-1, the whole [filename URL] is copied.
[filename] is the URL of the image
TODO:move special image functions to generic 'dragstuff' library
URL is normal URL of network reachable image file location
if command drag x/y/xy is set before command copy, the images will be draggable javascript function read_canvas(); will return the x/y coordinate data in xrange/yrange of all -including non draggable- images the command drag is only valid for the next image draggable / non-draggable images may be mixed may be used together with preceding keywords snaptogrid, xsnaptogrid, ysnaptogrid or snaptopoints x1,y1,x2,y2....
if keyword onclick is set before command copy the image(s) is clickable (marked with a green rectangle around the image) use 'read_dragdrop' to get the number of the clicked image(s) use command 'clearbutton some_text' to reset the reply/click array. example: 4 images; student clicked on image 2 and 3: reply = 0,1,1,0 after clicking the clear button: reply = 0,0,0,0 May be mixed with commands drag x|y|xy (use javascript read_canvas to get the new coordinates
onclick for external images may be mixed with canvas generated stuff (like lines,curves, embeded XML etc)
you may draw / userdraw / drag other stuff on top of an "imported" image
Insert the region from (x1,y1) to (x2,y2) (in pixels) of [ filename], possibly resized, to the region of (dx1,dy1) to (dx2,dy2) in x/y-range
(dx1:dy1) must be left top corner; (dx2:dy2) must be right bottom corner of inserted image
If x1=y1=x2=y2=-1, the whole [filename / URL ] is copied and resized.
URL is normal URL of network reachable image file location (as seen from public_html-root or network reachable 'http://some_server/my_images/test.gif' (eg no special wims paths are searched !!)
if command drag x/y/xy is set before command copy, the images will be draggable javascript function read_canvas(); will return the x/y coordinate data in xrange/yrange of all -including non draggable- images the command drag is only valid for the next image draggable / non-draggable images may be mixed may be used together with preceding keywords snaptogrid,xsnaptogrid,ysnaptogrid or snaptopoints x1,y1,x2,y2...
if keyword onclick is set before command copy the image(s) is clickable (marked with a green rectangle around the image) use read_dragdrop to get the number of the clicked image(s) use command 'clearbutton some_text' to reset the reply/click array. example: 4 images; student clicked on image 2 and 3: reply = 0,1,1,0 after clicking the clear button: reply = 0,0,0,0 May be mixed with commands drag x|y|xy (use javascript read_canvas to get the new coordinates
onclick for external images may be mixed with canvas generated stuff (like lines,curves etc)
you may draw / userdraw / drag stuff on top of an "imported" image
when set draggable, there will be special function 'read_canvas_images()' now dragging external images may be combined with 'read_canvas()' from userdraw or multidraw set command precision before command copy
use keyword centered before command 'copyresized' to place image center at given coordinates.
TODO:move special image functions to generic 'dragstuff' library
choose from these types: alias,all-scroll,auto,cell,context-menu,col-resize,copy,crosshair,default,e-resize, ew-resize,grab,grabbing,help,move,n-resize,ne-resize,nesw-resize,ns-resize,nw-resize, nwse-resize,no-drop,none,not-allowed,pointer,progress,row-resize,s-resize,se-resize, sw-resize,text,url(myBall.cur),auto,vertical-text,w-resize,wait,zoom-in,zoom-out,initial
note: wims will not check the validity of your cursor declaration
use command trange in parametric functions before every command curve / plot trange -pi,pi curve color,formula1(t),formula2(t) A next parametric curve will only be correctly plot when trange is set again ! this is a design flaw and not a feature...
use command precision to increase the number of digits of the plotted points
use command plotsteps to increase / decrease the amount of plotted points (default 150)
the next object will be draggable in x / y / xy direction
the displacement can be read by javascript:read_dragdrop();
the precision (default 2 decimals) in the student reply may be set with command precision. Use this 'precision' command before this command 'drag x|y|xy' !
onclick and drag x|y|xy may be combined (for different objects: a single object can either be onclick or drag, not both )
multi_objects will be numbered in the given x/y-sequence (example: points red,0,0,1,1,2,2,3,3: point (0:0) is object_number 1)
attention: static objects and onclick/drag objects of the same type (like point,circle,etc) with the same coordinates (e.g. objects that overlap) will give problems in the recognition algorithm) in this example linewidth 4 point 0,0,red drag xy point 0,0,blue the red point will not be recognised as draggable ! in the example linewidth 4 drag xy point 0,0,red drag xy point 0,0,blue both points will be recognised
the answer is: drag_or_onclick_object_number : Xorg : Yorg : Xnew : Ynew wherein object_number is the sequence number of the draggable & onclick objects in your script. Only draggable & onclick objects will have an object_number (e.g things like point,crosshair,line,segment,circle,rect,triangle...etc)
in case of external images (commands copy / copyresized) the external image can be set draggable ; always xy. The function javascript;read_canvas() will return the xy-coordinates of all images.
fill all region containing points (x1:y1),(x2:y2)...(x_n:y_n) with color 'color'
any other colors (objects) in the canvastype will act as border to the bucket fill
use this command after all boundary objects are declared.
Use command 'userdraw clickfill,color' for user click driven flood fill.
use command canvastype to fill another canvas (default should be fine: DRAG_CANVAS = 5)
note: the fill-family of commands are very (client) cpu intensive operations! filling is done pixel by pixel e.g. image size of 400x400 uses 160000 pixels: each pixel contains 4 data (R,G,B,Opacity) = 640000 data. on every data a few operations / comparisons are done... So have pity on your students CPU..
when using an image-url, make sure it contains an / in the filename...fillpattern $module_dir/gifs/test.jpg will fill the next fillable object with this image.| the argument to html5 canvas routine 'createPattern(img,argument)' is set to repeat e.g. if the image is smaller then the canvas, multiple copies will be used to fill the area ( e.g. ctx.fillStyle() = pattern) for example: size 150,150 xrange -5,5 yrange -5,5 drag xy fillpattern gifs/en.gif fcircle 0,0,100,red fillpattern gifs/nl.gif drag xy fcircle -3,2,100,green fillpattern gifs/cn.gif drag xy fcircle 3,2,100,green
fillpattern is also active for userdraw object,color... the userdraw family a has also clickfill type (e.g. an object gets filled between boundaries, when clicked) commands like: 'userdraw dotfill,color' 'userdraw hatchfill,color' etc
any other color will not act as border to the bucket fill
use this command after all boundary objects are declared.
use command canvastype to fill another canvas (default should be fine: DRAG_CANVAS = 5)
note: filltoborder is a very (client) cpu intensive operation! filling is done pixel by pixel e.g. image size of 400x400 uses 160000 pixels: each pixel contains 4 data (R,G,B,Opacity) = 640000 data. on every data a few operations / comparisons are done... So have pity on your students CPU..
any other color or size of picture (borders of picture) will act as border to the bucket fill
use this command after all boundary objects are declared.
Use command userdraw clickfill,color for user click driven flood fill.
use command canvastype to fill another canvas (default should be fine: DRAG_CANVAS = 5)
note: floodfill is a very (client) cpu intensive operation! filling is done pixel by pixel e.g. image size of 400x400 uses 160000 pixels: each pixel contains 4 data (R,G,B,Opacity) = 640000 data. on every data a few operations / comparisons are done... So have pity on your students CPU..
in case commands string color,x,y,the string, stringup color,x,y,rotation,the string, fontfamily can be something like:fontfamily italic 34pt Arial. Use correct syntax: font style, font size pt, fontfamily
note: for some macros (like grid | legend | xaxistext | xlabel etc) sometimes command fontfamily can be used for some specific font-setting this is however not always very straight forward... so just try and see what happens
if keywords axis or axisnumbering are set, use: grid step_x,step_y,major_color,minor_x,minor_y,tics height in px,axis_color minor x step = step_x / minor_x
if xmin > 0 and/or ymin > 0 and zooming / panning is not active: be aware that the x/y-axis numbering and x/y major/minor tic marks will not be visual as they are placed under the x-axis and left to the y-axis (in Quadrant II and IV)
use commands xlabel some_string and/or ylabel some_string to label axis; use command fontsize to adjust size: the font family is non-configurable 'italic your_fontsize px Arial' !
see command legend to set a legend for the graph; use command fontsize to adjust size (the font family is non-configurable 'bold your_fontsize px Arial')
all objects(*) after the command and until kill group or killslider may be moved together with mouse moverments (*) for now all real canvas objects and latex / xml ; but no images (work in progress)
may be combined with slider driven movements or drag & drop
link_text may also be an image URL http://some_server/images/my_image.png or $module_dir/gifs/my_image.jpg
link_text may contain HTML markup
the canvas will be displayed in a tooltip on link_text
the canvas is default transparent: use command bgcolor color to adjust background-color, the link text will also be shown with this 'bgcolor'.
many userinput stuff will use the tooltip_placeholder_div element...only one is defined in the wims-page and are therefore these commands are mutually exclusive. keep this in mind...
your function will be plotted by the javascript engine of the client browser
if trange is defined, the two functions will be plotted parametric note: use x as variable...and not t. Use keyword animate to animate a point on the curve
use only basic math in your curve: sqrt,^,asin,acos,atan,log,pi,abs,sin,cos,tan,e
use parenthesis and rawmath: use 2*x instead of 2x ; use 2^(sin(x))...etc etc (use error console to debug any errors...)
attention: last precision command in the canvasdraw script determines the calculation precision of the javascript curve plot !
no validity check is done by wims.
zooming & panning are implemented: use command zoom color for mouse driven zooming or use keyword 'setlimits' for inputfields setting xmin/xmax, ymin/ymax
zooming & panning is better than for curves produced by command curve color,formula because for avery change in x/y-range the curve is recalculated in javascript
zooming & panning in case of userbased functionplot: reclick the OK button to re-plot curve onto the resized grid
use keyword animate for animating a point on the curve
use command trace_jscurve formula(x) for tracing
use command jsmath formula(x) for calculating and displaying indiviual points on the curve
commands plotjump / plotstep are not active for jscurve
every command jscurve will produce a new canvas (canvastype 111,112,113...) for this one curve.
plotting multiple js-curves on the same canvas (for example if you want to use 'userdraw clickfill,color' on canvastype number 111, use: jscurve red,fun1(x),fun2(x)...fun_n(x), you must specify individual multistrokecolors & multistrokeopacity & multilinewidth for these multiple js-curves to use different colors. Otherwise all curves will be the same color... Use commands like: multistrokecolors, multilinewidth, multidash, multistroke, color given for the command jscurve color,formulas(x) will not be used in that case... but the color argument must still be given in any case (otherwise syntax error...)
will calculate an y-value from a userinput x-value and draws a crosshair on these coordinates.
default labels x and y; the commands xlabel some_x_axis_name and ylabel some_y_axis_name will set the label for the input fields
use command 'css some_css' for styling the display fields. Use command 'fontsize int' to size the labels x and y
the client browser will convert your math function to javascript math. use parenthesis and rawmath: use 2*x instead of 2x etc etc no check is done on the validity of your function and/or syntax use error console to debug any errors...
be aware that the formula's of the plotted function(s) can be found in the page javascript source
will also reset the command rotationcenter to the first (x;y) of the next rotatable/slidable object(s) eg a following rotate command will have the first object point as rotation center
if not set, the rotation center will remain unchanged
note:any active transformation or linear will not be killed (e.g an active transformation matrix remains active)
you may also use command mathml for xml strings generated with wims commmand mathmlmath (will not work on KaTeX enabled WIMS)
transformation commands affine, translation and rotate are supported.(onclick and drag will work)
can be set onclick: javascript:read_dragdrop(); will return click numbers of mathml-objects if 4 clickable object are drawn, the reply could be 1,0,1,0 ... meaning clicked on the first and third object
can be set draggable:javascript:read_dragdrop(); will return all coordinates in the same order as the canvas script: unmoved object will have their original coordinates...
when clicked, the colour of the 'div background' of the 'mathobject' will be determined by the fillcolor and opacity settings
userdraw may be combined with 'latex' ; the js-function 'read_canvas()' will contain the coordinates of the drawing.
userdraw may be combined; the read_canvas() will contain the drawing.
draggable or onclick 'external images' from command copy or copyresized and all objects from commands html or obabel can be combined with drag and/or onclick mathml
other drag objects (circles/rects etc) are supported, but read_dragdrop() will probably be difficult to interpret...
if inputfields are incorporated in mathml (with id's: id='mathml0',id='mathml1',...id='mathml_n') the user_input values will be read by javascript:read_mathml();. attention: if after this mathml-input object other user-interactions are included, these will read mathml too using "read_canvas();"
If other inputfields (command input / command textarea) or userdraw are performed, the function read_canvas() will not read mathml. Use some generic function to read it....
use keyword centered to center the katex div object on (x1:y1) this may not work as expected for MathJaX [TO BE TESTED]
note: if you want to include external TeX via drag&drop onto a canvasdraw element, use \mmlid{integer} in the tex-command:!insmath \mmlid{1}rac{1}{pi} (if your wims_mathml does not support it...use this version...)
note: the same is true for all external P,SPAN,DIV,IMG,SVG-images via drag&drop onto a canvasdraw element, use onclick=javascript:place_image_on_canvas(this.id)
draw multiple lines through points (x1:y1)--(x2:y2) ...(x_n-1:y_n-1)--(x_n:y_n) in color 'color'
or use multiple commands curve color,formula or jscurve color,formule to draw the line (uses more points to draw the line; is however better draggable)
the mathml_string can be produced using WIMS commands like texmath followed by mathmlmath... or write correct TeX and use only mathmlmath
mathml will be displayed in a rectangle left top (x1:y1)
can be set onclick javascript:read_dragdrop(); will return click numbers of mathml-objects; if 4 clickable object are drawn, the reply could be 1,0,1,0 ... meaning clicked on the first and third object
can be set draggable: javascript:read_dragdrop() will return all coordinates in same order as the canvas script: unmoved objects will have their original coordinates...
snaptogrid is supported...snaptopoints will work, but use with care... due to the primitive dragging. Technically: the dragstuff library is not used... the mathml is embedded in a new div element and not in the html5-canvas.
when clicked, the mathml object will be drawn in red color; the div background color will be determined by the fillcolor and opacity settings.
userdraw may be combined with 'mathml' ; the read_canvas() will contain the drawing.
draggable or onclick 'external images' from command copy or copyresized can be combined with drag and/or onclick mathml
other drag objects (circles/rects etc) are supported, but read_dragdrop() will probably be difficult to interpret...
if inputfields are incorporated in mathml (with id's: id='mathml0',id='mathml1',...id='mathml_n') the user_input values will be read by javascript:read_mathml(); attention: if after this mathml-input object other user-interactions are included, these will read mathml too using "read_canvas();"
If other inputfields (command input / command textarea) or userdraw is performed, the function read_canvas() will not read mathml. Use some generic function to read it....
use keyword centered to center the mathml/xml object on (x1:y1)
will display the mouse cursor coordinates as x-only,y-only,(x:y), the radius of a circle (this only in case 'userdraw circle(s),color') or the angle in degrees or radians for commands userdraw arc,color or protractor, ruler (if set dynamic).
use commands xunit and / or yunit to add the units to the mouse values. The degree | radian will always have the appropriate symbol).
just like commands mouse, mousex, mousey, mouse_degree... only other name
for simple single object user drawings you could also use command userdraw
implemented obj_types:
point | points
circle | circles
line | lines
segment | segments
arrow | arrows (use command 'arrowhead int' for size (default value 8 pixels))
curvedarrow | curvedarrows
rect | rects
closedpoly only one closedpolygon may be drawn.The number of corner points is not preset (e.g. not limited, freestyle), the polygon is closed when clicking on the first point again..(+/- 10px)
triangle | triangles
parallelogram | parallelograms
poly[3-9] | polys[3-9] draw 3...9 point polygone(s): polys3 is of course triangles
images
crosshair | crosshairs
function for more function user input fields, use it multiple times for 4 inputfields use : multidraw function,function,function,function
additionally objects may be user labelled, using obj_type text... in this case allways a text input field and if multiuserinput=1 also (x:y) inputfields will be added to the page. use commands fontfamily and fontcolor to adjust (command multistrokeopacity may be set to adjust text opacity) note: text is always centered on the mouse-click or user-input coordinates ! note: no keyboard listeners are used
it makes no sense using something like multidraw point,points ... something like "multidraw polys4,polys7" will only result in drawing a 4 point polygone and not a 7 point polygone: this is a design flaw and not a feature...
note: mouselisteners are only active if "$status != done " (eg only drawing in an active/non-finished exercise) to overrule use command/keyword "status" (no arguments required)
buttons for changing the obj_type (and in case of multiuserinput, some inputfields and buttons) will be present in the reserved div tooltip_div and can be styled using command 'css some_css'
the button label will be default the object primitive name (like point, circles). If you want a different label (e.g. an other language), use command multilabel for example in dutch: multilabel cirkel,lijnstuk,punten,STOP multidraw circle,segment,points (see command multilabel for more details)
a right mouse button click will remove the last drawn object of the selected drawing type. All other type of objects are not removed
multidraw is incompatible with command tooltip (the reserved div_area is used for the multidraw control buttons)
all multidraw drawings will scale on zooming. this in contrast to the command userdraw.
wims will not check the amount or validity of your command arguments ! ( use javascript console to debug any typo's )
a local function read_canvas%d will read all userbased drawings. The output is always a 16 lines string with fixed sequence. line 1 = points_x+";"+points_y+"
" line 2 = circles_x+";"+circles_y+";"+multi_radius+"
" line 3 = segments_x+";"+segments_y+"
" line 4 = arrows_x+";"+arrows_y+"
" line 5 = lines_x+";"+lines_y+"
" line 6 = triangles_x+";"+triangles_y+"
" line 7 = polys[3-9]_x+";"+polys[3-9]_y+"
" line 8 = rects_x +";"+rects_y+"
" line 9 = closedpoly_x+";"+closedpoly_y+"
" line 10 = parallelogram_x+";"+parallelogram_y"
" line 11 = text_x+";"+text_y+";"+text"
" line 12 = image_x+";"+image_y+";"+image_id line 13 = curvedarrows_x +";"+ curvedarrows_y +"
" line 14 = curvedarrows2_x +";"+ curvedarrows2_y +"
" line 15 = crosshairs_x +";"+ crosshairs_y +"
" line 16 = userdraw_x +";"+userdraw_y + "
" note: this is for single userdraw object,color and replyformat 29 line 17 = userdraw_x +";"+userdraw_y +";"+userdraw_radius + "
" note: this is for single userdraw object,color and replyformat 29 The x/y-data are in x/y-coordinate system and display precision may be set by a previous command precision 0 | 10 | 100 | 1000... In case of circles the radius is -for the time being- rounded to pixels use the wims "direct exec" tool to see the format of the reply
It is best to prepare / format the student reply in clientside javascript. However in wims language you could use something like this for example you are interested in the polys5 drawings of a pupil (the pupil may draw multiple poly5 objects...) note: the reply for 2 poly5's is: x11,x12,x13,x14,x15,x21,x22,x23,x24,x25 ; y11,y12,y13,y14,y15,y21,y22,y23,y24,y25 rep = !line 7 of reply rep = !translate ';' to '
' in $rep pts = 5 # 5 points for polygon x_rep = !line 1 of $rep y_rep = !line 2 of $rep tot = !itemcnt $x_rep num_poly = $[$tot/$pts] idx = 0 !for p=1 to $num_poly !for s=1 to $pts !increase idx X = !item $idx of $x_rep Y = !item $idx of $y_rep # do some checking !next s !next p
attention: for command argument closedpoly, only one polygone can be drawn. The last point (e.g. the point clicked near the first point) of the array is removed.
technical: all 10 draw primitives + text will have their own -transparent- PNG bitmap canvas. So for example there can be a points_canvas entirely separated from a line_canvas. This to avoid the need for a complete redraw when something is drawn to the canvas...(eg only the object_type_canvas is redrawn), this in contrast too many very slow do-it-all HTML5 canvas javascript libraries. The mouselisteners are attached to the canvas-div element.
a special object type is images. if used together with imagepalette a image table will be integrated in the 'control section' of multidraw (set multiuserinput 1 for images) if not used with imagepalette, provide the images or div's (<img> tag with bitmap or SVG or anything in a div element) somewhere on the html exercise page, with an onclick handler like: <img src='gifs/images/dog.svg' onclick='javascript:place_image_on_canvas(this.id);' id="ext_image_1" /> <img src='gifs/fish.png' onclick='javascript:place_image_on_canvas(this.id);' id="another" /> etc ... when activating the multidraw image button, the images can be selected (left mouse button/onclick) and placed on the canvas...left mouse click. using div's will enable you -amongst other content- to add math typesetting from the exercise page onto the canvas.
When you are not content with the default multidraw control panel, you can create your own interface, using a few javascript functions to call the drawprimitives, delete things and stop drawing in case you also want to drag&drop stuff...To activate this feature, use multilabel NOCONTROLS The object types are internally represented by the following numbers (making typos will render your exercise null and void) point = 0 points =1 circle = 2 circles = 3 line = 4 lines = 5 segment = 6 segments = 7 arrow = 8 arrows = 9 triangle = 10 triangles = 11 closedspoly = 12 text = 13 rect = 14 rects = 15 poly[3-9] = 16 polys[3-9] = 17 parallelogram = 18 parallelograms = 19 images = 20 curvedarrow = 21 curvedarrows = 22 curvedarrow2 = 23 curvedarrows2 = 24 crosshair = 25 crosshairs = 26 controls for example: <input type='button' onclick='javascript:userdraw_primitive=null' value='STOP DRAWING' /> <input type='button' onclick='javascript:userdraw_primitive=24;multidraw_object_cnt = 0;' value='start drawing curvedarrows2' /> <input type='button' onclick='javascript:var fun=eval("clear_draw_area"+canvas_scripts[0]);fun(24,0);' value='REMOVE LAST CURVEDARROW ' /> If using multiple canvas scripts in a single page, loop through the canvas_scripts[n] note: if using NOCONTROLS and just a single draw primitive (for example, just: 'multidraw circles'), the object may be drawn directly. (analogue to 'userdraw circles,color') And since a right mouse button click will always remove the last drawn object of the current object type, there is no need for a special "remove button"
if not set all labels (e.g. the value of input type 'button') will be set by the english names for the draw_primitives (like 'point','circle'...)
the stop drawing button text must be the last item on the multilabel -list for example: multilabel punten,lijnen,Stop met Tekenen multidraw points,lines
all buttons can be styled by using command css note:If you want to add some CSS style to the buttons... the id's of the draw buttons are their english command argument (e.g. id="canvasdraw_points" for the draw points button). the id of the stop drawing button is "canvasdraw_stop_drawing". the id of the "OK" button is canvasdraw_ok_button
wims will not check the amount or validity of your input
always use the same sequence as is used for multidraw
if you don't want the controls, and want to write your own interface, set multilabel NOCONTROLS
meaning draw objects no. 3 and 5, in the list of command multifill, are filled (if the object is fillable...and not a line,segment,arrow or point...)
using a fillpattern: multifill 0,1,2,5,3,4 meaning: first object is not filled...second object is solid color filled...2=grid | 3=hatch | 4=diamond | 5=dot
if not set all fillcolors (for circle | triangle | poly[3-9] | closedpoly ) will be stroke_color, fill_opacity
use these up to 6 colors for the draw primitives used by command multidraw obj_type_1,obj_type_2...obj_type_n
wims will not check if the number of colours matches the amount of draw primitives...
always use the same sequence as is used for multidraw
can also be used with command userdraw clickfill,color when more than one fillcolor is wanted. in that case use for example replyformat 10 ... reply=x1:y1:color1,x2:y2:color2... the colors will restart at the first color, when there are more fill-clicks than multi-fill-colors if more control over the used colours is wanted, see command colorpalette color1,color2...
meaning draw objects no. 2 (circle) and 3 (segments), in the list of command like multifill points,circle,segments, will snap to the xy-grid (default 1 in x/y-coordinate system: see command snaptogrid)
freehand drawing...specify precision for reply: all objects snap to grid multisnaptogrid 1,1,1,...
only the xy-values snap_to_grid: all objects snap to grid multisnaptogrid 1,1,1,...
only the x-values snap_to_grid: all objects snap to x-grid multisnaptogrid 2,2,2,...
only the y-values snap_to_grid: all objects snap to y-grid multisnaptogrid 3,3,3,...
if snaptopoints is defined: all objects snap to points multisnaptogrid 4,4,4,... make sure to define the points to snap on... use command snaptopoints
multisnaptogrid 0,1,2,3,4 multidraw text,arrow,line,circle,image text is free hand, arrow is snap to grid, line is snap to x-grid, circle is snap to y-grid, image is snap to points defined by command snaptopoints
meaning, when the command multidraw is used multidraw circles,points,lines,triangles objects points and lines may additionally be drawn by direct input (inputfields) all other objects must be drawn with a mouse
in case of circle | circles a third inputfield for Radius (R) is added. The radius must be in the x/y coordinate system (x-range) and not in pixels...students don't think in pixels. note: R-values will not snap-to-grid
in case of line(s) | segment(s) | arrow(s) the user should write x1:y1 in the first inputfield and x2:y2 in the second. These hints are pre-filled into the input field. Other coordinate delimiters are ; and , e.g. x1;y1 or x1,y1. An error message (alert box) will popup when things are not correctly...
in case of a triangle | poly3, three inputfields are provided.
in case of text and multiuserinput=1, 3 inputfields will be shown: x,y,text
in case of text and multiuserinput=0, 1 inputfield will be shown: text ... a mouse click will place the text on the canvas.
may come in handy if canvas script code is generated using loops
if used the following properties will remain to be valid
filled
dash settings
onclick or drag settings
centering or offset
if used again, these properies will be reset to the default values and normal behaviour is continued (e.g. the above properties will be reset after 'use' on a canvas object)
can be set onclick: javascript:read_dragdrop(); will return click numbers of mathml-objects if 4 clickable object are drawn, the reply could be 1,0,1,0 ... meaning clicked on the first and third object
can be set draggable: javascript:read_dragdrop(); will return all coordinates in the same order as the canvas script: unmoved object will have their original coordinates...
snaptogrid is supported...snaptopoints will work, but use with care...due to the primitive dragging technically: the dragstuff library is not used...the mathml is embedded in a new div element and not in the html5-canvas
external files may be loaded if they are present on the server or in the modules for example: obabel 0,0,mol,$module_dir/caffeine.mol,-P100,-xb none
parallel x1,y1,x2,y2,dx,dy,n,[colorname or #hexcolor]
affine transformations should be identical to flydraw
in case of rotation or affine transformation , command parallel will produce n individual segments, and these may be set onclick or drag xy individually.
in case of no rotation or transformations the lines can not be set onclick or drag xy.
note: a large number of parallel lines (large n) may result in a canvasdraw error (...simplify your script...it produces too many lines...)
remark: there is no command polylines | brokenlines | paths ... just use multiple commands polyline, x1,y1,x2,y2...x_n,y_n
remark: there are commands userdraw path(s),color and userdraw polyline,color... these are two entirely different things ! the path(s) userdraw commands may be used for freehand drawing(s) the polyline userdraw command is analogue to this polyline|brokenline command
the command interconnects the points in the given order with a line (canvasdraw will not close the drawing: use command polygon for this)
use command segments for a series of segments. These may be clicked/dragged individually
if fly-script starts with keyword popup, the canvas image will be exclusively in a popup window (xsize px × ysize px)
if keyword popup is used after command size xsize,ysize the canvas will also be displayed in a popup window with size xsize × ysize
the popup window will be embedded into the page as a normal image, when status=done; override with keyword nostatus
to access the read_canvas and read_dragdrop functions in a popup window, use: function read_all(){ if( typeof popup !== 'undefined' ){ var fun1 = popup['read_dragdrop'+canvas_scripts[0]]; var fun2 = popup['read_canvas'+canvas_scripts[0]]; popup.close(); return "dragdrop="+fun1()+"
canvas="+fun2(); };
to set a canvasdraw produced clock or multiple clocks...use something like: popup.set_clock(clock_id,type,diff); as js-function for a button (or something else) in your document page. where in clock_id starts with 0 for the first clock type is 1 for Hours,2 for Minutes and 3 for Seconds diff is the increment (positive or negative) per click
x_width: give the width in x-coordinate system (e.g. not in pixels !)
type = 1: a triangle range 0 - 180 type = 2: a circle shape 0 - 360
mode: use -1 to set the protractor interactive (mouse movement of protractor) use mode = '0° - 360°' to set the protractor with a static angle of some value
use_scale = 1: the protractor will have some scale values printed; use_scale=0 to disable
the rotating direction of the mouse around the protractor determines the clockwise/ counter clockwise rotation of the protractor...
commands stroke_color | fill_color | linewidth | opacity | font_family will determine the looks of the protractor.
default replyformat: reply[0] = x;reply[1] = y;reply[2] = angle_in_radians use command precision to set the reply precision.
if combined with a ruler, use replyformat = 32
command snap_to_grid may be used to assist the pupil at placing the protractor
when using command zoom, pay attention to the size and symmetry of your canvas ...to avoid a partial image, locate the start position near the center of the visual canvas technical: the actual protractor is just a static generated image in a new canvas-memory This image is only generated once, and a copy of its bitmap is translated & rotated onto the visible canvas. That is the reason for the high-speed dragging and rotating. I've limited its size to xsize × ysize e.g. the same size as the visual canvas...
only one protractor allowed (for the time being)
usage: first left click on the protractor will activate dragging; a second left click will activate rotating (just move mouse around) a third click will freeze this position and the x/y-coordinate and angle in radians will be stored in reply(3) a next click will restart this sequence...
(xc: yc) center of circle diagram in xrange/yrange
radius in pixels
data+color list: a colon separated list of raw data and corresponding colours canvasdraw will not check validity of colornames... in case of trouble look into javascript debugging of your browser
example data+colorlist: 32:red:65:green:23:black:43:orange:43:yellow:14:white
the number of colors must match the number of data.
if defined fillpattern some_pattern then the pie pieces will be filled with the respective color and a fill pattern... the pattern is cycled from the 4 pattern primitives: grid,hatch,diamond,dot,grid,hatch,diamond,dot,...
use command opacity to adjust fill_opacity of colours
use command legend to automatically create a legend using the same colours as pie segments; unicode allowed in legend; expect javascript trouble if the amount of pie-slices, pie-colors, pie-legend-titles do not match, a javascript console is your best friend... use command fontfamily to set the font of the legend.
use command centered to place legend text inside the piechart. The text is using the same color as the pie segment: use (fill) opacity to enhance visibility.
note: internally a rect is defined with 4 points. So when performing some affine transformation, other than translation, it will result in some morphing of the rectangle ! this is a deviation of flydraw's rect&affine
replyformat 13: Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2,Cx1:Cy1:Cx2:Cy2,Dx1:Dy1:Dx2:Dy2, ... ,Zx1:Zy1:Zx2:Zy2 x/y in xrange / yrange coordinate system
replyformat 14: Ax1:Ay1:Ax2:Ay2,Bx1:By1:Bx2:By2....Zx1:Zy1:Zx2:Zy2 x/y in pixels
replyformat 15: reply from inputfields,textareas reply1,reply2,reply3,...,reply_n
replyformat 16: mathml input fields
replyformat 17: read userdraw text,color only x1,y1,text1
x2,y2,text2...
...x_n,y_n,text_n x/y-values are in xrange/yrange
replyformat 18: read_canvas() will read all interactive clocks in H1:M1:S1,H2:M2:S2...Hn:Mn:Sn
replyformat 19: read_canvas() will return the object number of marked / clicked object (clock), analogue to (shape library) onclick command
replyformat 20: read_canvas() will reply "object_number:x:y" of external images: object_number of the first draggable external image in the fly-script starts with 0, e.g. expect something like 0:-5:4,1:6:2,2:-2:-5, the first image position is (-5:4), the second image position is (6:2) and the third image position is (-2:-5)
replyformat 22: returns an array .... reply[0]=x1 reply[1]=y1 reply[2]=x2 reply[3]=y2 ... reply[n-1]=x_n reply[n]=y_n x/y in xrange / yrange coordinate system
replyformat 23: can only be used for drawtype polyline. A typical click sequence in drawtype polyline is x1,y1,x2,y2,x2,y2,x3,y3,x3,y3.....,x(n-1),y(n-1),x(n-1),y(n-1),xn,yn --replyformat 23 gives x1,y1,x2,y2,x3,y3,.....x(n-1),y(n-1),xn,yn; multiple occurences will be filtered out. The reply will be in x-y-range (xreply
yreply)
replyformat 24: read all inputfield values: even those set readonly
replyformat 25: angle1,angle2;...;angle_n will return the radius (one or many) of the user drawn circle segment in degrees
replyformat 26: rad1,rad2,...rad_n will return the radius (one or many) of the user drawn circle segment in radians
replyformat 28: x1,y1,r1,x2,y2,r2...x_n,y_n,r_n x / y / r in xrange / yrange coordinate system: may be used to reinput into command circles color,x1,y1,r1,x2,y2,r2...x_n,y_n,r_n will not return anything else (e.g. no inputfields, text etc)
replyformat 34: a special for OEF and dragging external images -included via commands copy or copyresized there will be an extra function read_canvas_images() for reading the coordinates of the images. for now this is a unique function, e.g. there is no canvas id linked to it. (TO DO !!! 18/5/2019)
special replyformat = 100 ; will access to the raw javascript object data...use: read_dragdrop([property,property,...]) for example properies like 'clicked','text', 'angle' , 'x'
x-width, y-height are the ruler dimensions width & height in xy-coordinate system
the ruler scale is by definition the x-scale, set by command xrange. For example: a ruler x-width of 6 will have a scale ranging from 0 to 6
mode: use -1 to set the ruler interactive (eg mouse movement of ruler; drag & rotate) use mode = '0° - 360°' to set the ruler with a static angle of some value
if combined with a protractor, use replyformat = 32
only one ruler allowed (for the time being)
when using command zoom, pay attention to the size and symmetry of your canvas to avoid a partial image, locate the start position near the center of the visual canvas; technical: the actual ruler is just a static generated image in a new canvas-memory. This image is only generated once, and a copy of its bitmap is translated & rotated onto the visible canvas. That is the reason for the high-speed dragging and rotating. I have limited its size to xsize × ysize e.g. the same size as the visual canvas...
usage: first left click on the ruler will activate dragging; a second left click will activate rotating (just move mouse around), a third click will freeze this position and the x/y-coordinate and angle in radians will be stored in reply(3), a next click will restart this sequence...
(only) the next object will be rotated is given angle
positive values rotate counter clockwise
attention: all objects will be rotated around their first point... rotate 45 triangle 1,1,5,1,3,4,red will rotate 45 degrees around point (1:1)
if another rotation center is needed, use command rotationcenter xc,yc. to reset this rotationcenter, use keyword killrotate
attention: rotate will mess up the interactivity of the rotated object e.g. if combined with command drag xy or keyword onclick: the mouse recognises the original -unrotated- coordinates of the object
mandatory first command (can only be preceded by keyword popup)
if xrange and/or yrange is not given the range will be set to pixels: xrange 0,xsize yrange 0,ysize note: lower left corner is origin (0:0) !!! this in contrast to flydraw
if a slider value display is desired, use for argument type: x display, y display, angle radian, angle degree
is the slider is used for animation, add keyword anim or animate to type; for now only one animated slider may be used...
default behaviour is: click on an object to use its slider(s) to use sliders without clicking on an object, use for type keyword active eg: slider -2*pi,2*pi,300,30,angle degree active,Rotate
if a unit (or something like that...) for x/y-value display is needed, use commands xunit and / or yunit
if the translation should be performed using a function, use for type: x function, y function use commands sliderfunction_x and/or sliderfunction_y before the slider command to define the functions. Example:sliderfunction_x x^2 sliderfunction_y y^2 slider -5,5,100,100,xy function,Some_Text ...some stuff to slide killslider sliderfunction_x x^2-2 slider -15,15,100,10,x function,Some_Other_Text ...more stuff to slide killslider... etc
use command slider before draggable/clickable objects.
drag and drop may be combined with rotation slider for example an arrow rotated by a slider may be placed anywhere (drag&drop) size 300,300 xrange -5,5 yrange -5,5 grid 1,1,grey linewidth 3 drag xy fillcolor orange strokecolor blue slider 0,2*pi,250,30,angle degrees,Rotate arrow arrow 2,2,5,5,8,red note: except a combination 'drag' and 'slider' for command 'latex, katex, mathml, html, obabel'
no slider for a math function, these can be traced using command trace_jscurve some_function_in_x
a slider will affect all draggable objects after the slider command... and can be used to group translate / rotate several objects... until a next slider or keyword killslider
amount of sliders is not limited.
a slider can not be set snaptogrid or other snapto* : you may always use 'drag xy' in combination with the slider objects
javascript:read_dragdrop(); will return an array with object_number:slider_value
every draggable object may have its own slider (no limit in amount of sliders)
label: some slider text. Note: on KaTeX enabled wims, TeX produced by wims command mathmlmath, is allowed.
use fillcolor for slider controlkey
use strokecolor for slider bar
use fontfamily / fontcolor to set used fonts
use opacity (only fill opacity will be used) to set transparency
the slider canvas will be added to the tooltip div: so incompatible with command tooltip ; setlimits etc
primitive implementation of a broken scale graph...
not very versatile: only usable in combination with userdraw eg no other objects will obey this "coordinate system" if you want to place an object into this coordinate system, be aware that 10% or 20% of xsize and/or ysize is lost. Use these "formulas" to recalculate the virtual coordinates: factor=0.8 in case xstart != xmin (or ystart != ymin) factor=0.9 in case xstart = xmin (or ystart = ymin) px_x_point = ((factor*xsize)/(xmax - xstart))*(x_point - xmax)+xsize x_recalculated = px*(xmax - xmin)/xsize + px_y_point = -1*factor*y_point*ysize/(ymax - ystart) + ymax*factor*ysize/(ymax - ystart) y_recalculated = ymax - py*(ymax - ymin)/ysize
the array size (e.g. the number of points) of command snaptopoints is limited by constant MAX_INT (canvasdraw.h) this command may be repeated multiple times (no limit) to add points
a draggable object (use command drag x|y|xy) will snap to the closed of these points when dragged (mouseup)
other options: use keyword snaptogrid, xsnaptogrid or ysnaptogrid
a draggable object (use command drag x|y|xy) will snap to the given grid when dragged (mouseup)
in case of userdraw the drawn points will snap to xmajor / ymajor grid
if no grid is defined, points will snap to every integer xrange/yrange value. (eg snap_x=1,snap_y=1)
if you do not want a visible grid, but you only want a snaptogrid with some value...define this grid with opacity 0.
if xminor / yminor is defined,(use keyword axis to activate the minor steps) the drawing will snap to xminor and yminor use only even dividers in x/y-minor...for example snaptogrid axis grid 2,1,grey,4,4,7,red will snap on x=0, x=0.5, x=1, x=1.5 .... will snap on y=0, y=0.25 y=0.5 y=0.75 ...
note: when set onclick, use an extra command fontsize (default: fontsize=12) to adjust the size of the clicked text-string note: a clicked text string will be hardcoded : fontsize+10 in the font family courier
use a command like fontfamily italic 24px Arial to set fonts on browser that support font change
super / sub script is supported, using '_' and '^' The font family for the sub/sup string will be Helvetica e.g. your font family settings will be ignored to force end the subscript/supscript, use an extra space...see example:
stringup color,x,y,rotation_degrees,the text string
may be set onclick or drag xy
note: when set onclick, use an extra command fontsize (default: fontsize=12) to adjust the size of the clicked text-string note: a clicked text string will be hardcoded : fontsize+10 in the font family courier
unicode supported: stringup red,0,0,45,\u2232
use a command like fontfamily bold 34px Courier to set fonts on browser that support font change
you could use keyword yoffset to -sometimes- do a small correction of text placement under/above a point (e.g. text & point have thesame coordinates)
note: no need to killrotate after stringup onclick rotate 45 string red,0,0,AAAAAA killrotate string red,4,4,BBBBBB is identical with: onclick stringup red,0,0,45,AAAAAA string red,4,4,BBBBBB
super / sub script is supported, using '_' and '^' to end the subscript/supscript, use an extra space...see example:
font may be described by keywords: giant,huge,normal,small,tiny
use command fontsize to increase base fontsize for these keywords
may be set onclick or drag xy
backwards compatible with flydraw
unicode supported: text red,0,0,huge,\u2232
special: use '_' and '^' to imitate html sup/sub, like H_3O^+ + OH^\u22i2 \u2192 2H_2 O
much better to use command string combined with fontfamily for a more fine grained control over html5 canvas text element
super / sub script is supported, using '_' and '^' to end the subscript/supscript, use an extra space...see string command
Avoid mixing old flydraw commands text, textup with new canvasdraw commands string, stringup. If the fontfamily was set completely like fontfamily italic 24px Arial. In that case reset fontfamily to something lke fontfamily Arial before the old flydraw commands.
can not be set onclick or drag xy (because of translaton matrix...mouse incompatible)
font may be described by keywords: giant,huge,normal,small,tiny
use command fontsize to increase base fontsize for the keywords
backwards compatible with flydraw
unicode supported: textup red,0,0,huge,\u2232
use command stringup and fontfamily for a more fine grained control over html5 canvas text element
Avoid mixing old flydraw commands text, textup with new canvasdraw commands string; stringup. If the fontfamily was set completely like fontfamily italic 24px Arial. In that case reset fontfamily to something like fontfamily Arial before the old flydraw commands.
two inputfields will display the current x/y-values (numerical evaluation by javascript)
default labels x and y; use commands xlabel some_x_axis_name and ylabel some_y_axis_name to customize the labels for the input fields
use commands fontsize and css to format the fonts for labels and inputfields.
use commands linewidth, strokecolor, crosshairsize to adjust the corsshair.
the client browser will convert your math function to javascript math. use parenthesis and rawmath: use 2*x instead of 2x etc etc no check is done on the validity of your function and/or syntax (use error console to debug any errors...)
be aware that the formulas of the plotted function(s) can be found in the page javascript source
if set, the student will have to calculate "min,Q1,median,Q3,max" and feed these data into the draw_boxplot function
for example: put the canvas-script into a html element with id='boxplot' and set style='display:none' define a variable called student_boxplot and fill it with the 5 student-data (from inputfields or something) var student_boxplot = new Array(5) function show_boxplot(){ student_boxplot[0] = min; student_boxplot[1] = Q1; student_boxplot[2] = median; student_boxplot[3] = Q3; student_boxplot[4] = max; document.getElementById('boxplot').style.display = "block"; draw_boxplot(12345,1,2.00,5.00,[0,0,0,0,0],4,"0,0,255",0.78,"255,165,0",0.60,1,0,1,1); }; In the canvas-script the function draw_boxplot has the following arguments: draw_boxplot=function(canvas_type,xy,hw,cxy,data,line_width,stroke_color,stroke_opacity,fill_color,fill_opacity,use_filled,use_dashed,dashtype0,dashtype1)
for multiple different 'userdraw' objects in an exercise, use command multidraw
implemented object_type:
point
points
crosshair
crosshairs
line
lines
vline
vlines
hline
hlines
demiline
demilines
segment
segments
polyline | brokenline
circle
circles
arrow
arrow2 (double arrow)
arrows
arrows2 (double arrows)
curvedarrow
curvedarrows
curvedarrow2
curvedarrows2
triangle
polygon
poly[3-9] (e.g poly3 ... poly7...poly9
rect
roundrect
rects
roundrects
freehandline | path
freehandlines | paths
clickfill: fill the clicked area with color multiple areas may be selected multiple colors may be provided using commands colorpalette color1,color2,color3,... use replyformat 10 for checking the user click color ... reply=x1:y1:color1,x2:y2:color2... attention: this will not work for pattern filling, because the pattern image is only generated once and after creation can not be changed ! the opacity of this image on a separate canvas is set to 0.01 and not 0 (!!)...in the fill algorithm the opacity of the matching pixels is set to 1
dotfill: fill the clicked area with a dot pattern; use command linewidth to change dot size
diamondfill: fill the clicked area with a diamond pattern
hatchfill: fill the clicked area with a hatch pattern
gridfill: fill the clicked area with a grid pattern
textfill: fill the clicked area with a repeating string userdraw textfill,blue,some_text use command fontfamily to adjust text style and size
clickfill | pattern filling in general: the clicks may be set snaptogrid can be used together with command floodfill or fill always use together with command clearbutton some_text for removal of all click_colored areas the function read_canvas() will return the click coordinates in the sequence of the user clicks use command canvastype to fill another canvas (default should be fine: DRAG_CANVAS = 5)
text an inputfield is provided, unicode allowed. The text is drawn a the mouse click, or if used with command userinput inputfield also at the given x/y-coordonates
arc
arcs
image only a single "image" of every supported type(*) may be added to canvas window from the surrounding html page. the image should have an 'id' and an onclick handler. (*) supported types are svg,bitmap,p-element,div-element and mathml/tex-code with \mmlid{int}.
images
input place a single inputfield on canvas use commands 'css' for css styling: use command linewidth for adjusting the input field size (default 1)
inputs place multiple inputfield: placing inputfields on top of each other is not possible
note: mouselisteners are only active if $status != done (eg only drawing in an active/non-finished exercise) to overrule use command/keyword status (no arguments required)
note: object_type text: Any string or multiple strings may be placed anywhere on the canvas. Use command fontfamily to set font
note: object_type polygone: Will be finished (the object is closed) when clicked on the first point of the polygone again.
note: all objects will be removed -after a javascript confirm box- when clicked on an object point with middle or right mouse button (e.g. event.button != 1: all buttons but left)
use a prefix filled or f to set fillable objects filled. (fcircles,filledcircles etc) in case of fillpattern do not use the f prefix !
may be combined width the snaptogrid snaptopoints etc, to simplify the checking of the student reply
the cursor may be appropriately styled using command cursor
note: when zooming / panning after a drawing, the drawing will NOT be zoomed / panned...this is a "design" flaw and not a feature To avoid trouble do not use zooming / panning together width userdraw.! use command multidraw is this is a problem for you...
note: the default replyformat for userdraw input(s),color used format x1;y1;text1 n x2;y2;test2 n x_n;y_n;text_n (e.g. it is not a comma separated array...use direct exec to test)
note: a special case is userdraw image,boguscolor. Images (bitmap or svg or div) present in the exercise page and the img/svg/div-tag with an unique 'id' and onclick='javascript:place_image_on_canvas(this.id)' can be placed onto the canvas. The id and (x;y) coordinates will be returned using read_canvas(); native MathML, MathJax or KaTeX typesetting may be included in div's.(experiments; wims_modules svn version only!)
note: command userdraw function,color is identical to acombination of strokecolor color and userinput function
note: commands : multicolors red,green,blue multilabel f(x)=:g(x)=:h(x)= userdraw functions3,color is identical to commands : functionlabel f(x)=:p(x)=:w(x)= strokecolor red userinput function strokecolor green userinput function strokecolor blue userinput function
inputfield is only usable in combination with some userdraw draw_type
note: the input fields are not cleared after the object is drawn...be aware of multiple idential drawings (many clicks on the ok button)
userinput function may be used any time (e.g. without userdraw)
multiple userinput function commands may be used.
use command functionlabel some_string to define the inputfield text: default value "f(x)="
use command strokecolor some_color to adjust the plot / functionlabel color
use command css some_css to adjust the inputfields
use command fontsize int to adjust the label fonts. (default 12px)
the user input for the function will be corrected by a simple rawmath implementation... an error message will be shown if javascript can not interpret the user input
this value may be read with read_canvas(). for do it yourself js-scripters: If this is the first inputfield in the script, its id is canvas_input0
use before this command userinput_function, commands like css some_css, xlabel some_description, opacity int,int, linewidth int, dashed and dashtype int,int to modify
fontsize can be set using command fontsize int
incompatible with command intooltip link_text_or_image: it uses the tooltip div for adding the inputfield
usable for commands numberline and grid or combinations thereof
use these x-axis num1...num_n values instead of default xmin...xmax
in case of command grid. there is no need to use keyword axisnumbering
use command axis to have visual x/y-axis lines (see command grid
use command fontcolor, fontfamily to adjust font defaults: black,12,Arial note: command fontsize is not active for this command.(fontsize can be used for the legend in a grid)
a javascript error message will flag non-matching value:name pairs
if the x-axis words are too big and will overlap, a simple alternating offset will be applied
use command axis to have visual x/y-axis lines (see command grid
use these x-axis num1...num_n values instead of default xmin...xmax
use command fontcolor, fontfamily to adjust font defaults: black,12,Arial note: command fontsize is not active for this command.(fontsize can be used for the legend in a grid)
a javascript error message will flag non-matching value:name pairs
if the x-axis words are too big, they will overlap the graph (in this case the text will start from ysize upwards)
a draggable object (use command drag x|y|xy) will snap to the given x-grid values when dragged (mouseup)
in case of userdraw the drawn points will snap to xmajor grid
if no grid is defined, points will snap to every integer xrange value. (eg snap_x=1)
if you do not want a visible grid, but you only want a snaptogrid with some value...define this grid with opacity 0.
if xminor is defined (use keyword axis to activate xminor), the drawing will snap to xminor use only even dividers in x-minor...for example xsnaptogrid axis grid 2,1,grey,4,4,7,red will snap on x=0, x=0.5, x=1, x=1.5 .... will snap on y=0, y=0.25 y=0.5 y=0.75 ...
only active for commands text and string (e.g. objects in the drag/drop/onclick-librariy
in case of inputfields the inputfield will be centered x and y on its coordinates. for example: inputs 1,1,10,? point 1,1,red the point will be completely invisible note: keyword xyoffset will also provide centering if used with input(s),color
will be used to create a label for the x-axis (label is in quadrant I)
can only be used together with command grid not depending on keywords axis and axisnumbering
font setting: italic Courier, fontsize will be slightly larger (fontsize + 4) use command fontsize to adjust. (command fontfamily is not active for this command)
the x/y-range are set using commands xrange xmin,xmax and yrange ymin,ymax
the linewidth is set using command linewidth int
the opacity of major / minor grid lines is set by command opacity [0-255],[0-255]
default logbase number = 10 ... when needed, set the logbase number with command xlogbase number and/or ylogbase number
the x/y- axis numbering is triggered by keyword axisnumbering
use commands xlabel some_text and/or ylabel some_text for text on axis: use command fontsize int to set the fontsize (default 12px)
use command fontfamily fnt_family_string to set the fonts for axis-numbering
use command fontcolor to set the colour
note: the complete canvas will be used for the log paper
note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
note: command mouse color,fontsize will show the real values in the logpaper.
note: when using something like yrange 0.0001,0.01...combined with commands mouse color,fontsize and/or userdraw type,color... make sure the precision is set accordingly (eg command precision 10000)
note: in case of userdraw, the use of keyword userinput_xy may be handy !
attention: keyword snaptogrid may not lead to the desired result...
use command fontcolor, fontfamily to adjust font defaults: black,12,Arial note: command fontsize is not active for this command.(fontsize can be used for the legend in a grid)
a draggable object (use command drag x|y|xy) will snap to the given y-grid values when dragged (mouseup)
in case of userdraw the drawn points will snap to ymajor grid
if no grid is defined, points will snap to every integer yrange value. (eg snap_y=1)
if you do not want a visible grid, but you only want a snaptogrid with some value...define this grid with opacity 0.
if yminor is defined (use keyword axis to activate yminor), the drawing will snap to yminor use only even dividers in y-minor...for example ysnaptogrid axis grid 2,1,grey,4,4,7,red will snap on x=0, x=0.5, x=1, x=1.5 .... will snap on y=0, y=0.25 y=0.5 y=0.75 ...
will be used to create a (vertical) label for the y-axis (label is in quadrant I)
can only be used together with command grid not depending on keywords axis and axisnumbering
font setting: italic Courier, fontsize will be slightly larger (fontsize + 4) use command fontsize to adjust (command fontsize is not active for this command)
the x/y-range are set using commands xrange xmin,xmax and yrange ymin,ymax
xmajor is the major step on the x-axis; xminor is the divisor for the x-step
the linewidth is set using command linewidth int
the opacity of major / minor grid lines is set by command opacity [0-255],[0-255]
default logbase number = 10 ... when needed, set the logbase number with command ylogbase number
the x/y- axis numbering is triggered by keyword axisnumbering
use command precision before ylogscale command to set the precision (decimals) of the axis numbering
use commands xlabel some_text and/or ylabel some_text for text on axis: use command fontsize int to set the fontsize (default 12px)
use command fontfamily fnt_family_string to set the fonts for axis-numbering
use command fontcolor to set the color
note: the complete canvas will be used for the log paper
note: userdrawings are done in the log paper, e.g. javascript:read_canvas() will return the real values
note: command mouse color,fontsize will show the real values in the logpaper.
note: when using something like yrange 0.0001,0.01...combined with commands mouse color,fontsize and/or userdraw type,color... make sure the precision is set accordingly (eg command precision 10000)
note: in case of userdraw, the use of keyword userinput_xy may be handy !
attention: do not use command zoom
attention: keyword snaptogrid may not lead to the desired result...
PARI/GP est un système de calcul formel très répandu, conçu pour des calculs rapides en arithmétique (factorisations, théorie algébrique des nombres, courbes elliptiques...) mais contient aussi un grand nombre de fonctions pour le calcul matriciel, sur les développements limités, les nombres algébriques, etc. ainsi que de nombreuses fonctions transcendantes.
maxima
http://maxima.sourceforge.net/
Use
Maxima is a system for the manipulation of symbolic and numerical expressions, including differentiation, integration, Taylor series, Laplace transforms, ordinary differential equations, systems of linear equations, polynomials, and sets, lists, vectors, matrices, and tensors. Maxima yields high precision numeric results by using exact fractions, arbitrary precision integers, and variable precision floating point numbers.
Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. Automatic graph drawing has many important applications in software engineering, database and web design, networking, and in visual interfaces for many other domains.
GAP is a system for computational discrete algebra, with particular emphasis on Computational Group Theory. GAP provides a programming language, a library of thousands of functions implementing algebraic algorithms written in the GAP language as well as large data libraries of algebraic objects. See also the overview and the description of the mathematical capabilities. GAP is used in research and teaching for studying groups and their representations, rings, vector spaces, algebras, combinatorial structures, and more.
YACAS is an easy to use, general purpose Computer Algebra System, a program for symbolic manipulation of mathematical expressions. It uses its own programming language designed for symbolic as well as arbitrary-precision numerical computations. The system has a library of scripts that implement many of the symbolic algebra operations; new algorithms can be easily added to the library. YACAS comes with extensive documentation (hundreds of pages) covering the scripting language, the functionality that is already implemented in the system, and the algorithms we used.
jmol
Use
geogebra
Use
Logiciels internes à WIMS
checkmol
Norbert Haider, norbert.haider@univie.ac.at, modified by Ernst-Georg Schmid
Use
Input data
Output data
Example
curvecomp
Xiao Gang
Use
Compare two curves
Input data
Input parameters: environment. w_curvecomp_1 and w_curvecomp_2: curves to compare, as lists of points. w_curvecomp_xrange and w_curvecomp_yrange: list of 2 integers each. w_curvecomp_tolerance: Maximal tolerance of distances.
Output data
Output: 10 double numbers separated by white spaces. - Average distance of curve 1 with respect to curve 2. - Average distance of curve 2 with respect to curve 1. - Maximal distance of curve 1 with respect to curve 2. - Maximal distance of curve 2 with respect to curve 1. - Proportion of curve 1 close to curve 2. - Proportion of curve 2 close to curve 1. - Maximal jump of curve 1. - Maximal jump of curve 2. - Ratio of repetitions found in curve 1. Number 10: Ratio of repetitions found in curve 2. Furthermore, words "fnofx" and/or "fnofy" will appear if curve 2 represents the graph of a function of x (and/or y). Returns empty if one of the curves is degenerated.
This program generates cyclic code from a polynomial defined over a prime field. It does not check whether the polynomial is primitive or irreducible.
Input data
Accepted parameter: 3 words Word 1: field characteristics, limited to 2,3,5,7 Word 2: The polynomial coefficients (except the leading one, from lower degree to higher). Word 3: The starting status (starting from the first bit).
Output data
Example
cyclicode 3 22 10
dicfind
Xiao Gang
Use
for adm modules
Input data
Output data
Example
dicsort
Xiao Gang
Use
Sort dictionary
Input data
for adm modules
Output data
Example
huffman
Xiao Gang
Use
This program computes an optimal coding of variable lengths on a given distribution of probabilities, using Huffman algorithm.
Input data
Two environment variables wims_exec_parm is a comma-separated list of probability distributions Limited to MAX_ITEMS The input data will be scaled to unit sum w_huffman_radix is the encoding radix, between 2 and MAX_RADIX.
Output data
two lines Line 1: Entropy and Average code length, comma-separated Line 2: comma-separated list of codes.
Example
huffman_radix=4
huffman 0.16, 0.39, 0.55
lceb
Lucas Nussbaum, lucas@lucas-nussbaum.net
Use
jeu "le compte est bon"
Input data
7 integers
Output data
How to obtain the first number from the six other ones by addition, multiplication, division, substraction
Example
lceb 598 6 8 2 5 10 12
matchmol
Norbert Haider, norbert.haider@univie.ac.at, modified by Ernst-Georg Schmid
Use
Input data
Output data
Example
mathexp
Xiao Gang
Use
Mathematical expression manipulations for WIMS
Input data
For the moment, use only in deductio
Output data
Example
moneyprint
J.M. Evers
Use
prints a number with fixed amount of decimal places
Input data
Usage:!exec moneyprint number1,number2,number3,....number_n decimal_places or !exec moneyprint number1,number2,number3;....number_n decimal_places \text{A=wims(exec moneyprint number1,number2,number3....number_n decimal_places)} default value "decimal_places = 2" A=!exec moneyprint 123,43.5,23.45665 A=123.00,43.50,23.47 A=!exec moneyprint 1.000,6.234;8.4567 A=1.00,6.23;8.46 or specified a last "word" A=!exec moneyprint 123,43.5,23.45665 3 A=123.000,43.500,23.457
Output data
Example
msg2wims
Xiao Gang
Use
transforms a text in a file and save it in another file (administrative module). Transforms some commands of the form \ in wims equivalence. By default, the commands are \(\) (replace by !insmath) and translation in html of $, !, (to complete). More commands can be translated by the configuration of the variable msg2wims_primitives. Usage:!sh cd $wims_home; bin/msg2wims file_in > file_out
Input data
name of a file
Output data
modified text of the input file
Example
oncechar
Xiao Gang
Use
This special program selects words composed by selected characters, each selected character being used at most once in the word. Used in the shell script public_html/bin/dicfind
Input data
Selected characters are entered by the env var 'oncechar'. Words entered by stdin. Output to stdout.
Output data
Example
scienceprint
J.M. Evers
Use
Prints a number in scientific notation.
Input data
Usage: !exec scienceprint number,significant_digits,output_type \text{A=wims(exec scienceprint number,significant_digits,output_type )} output_type can be
0 : calculating format : 1.234*10^-4
1 : html format :1.234×10-4
2 : latex format : 1.234\times10^{-4}
3 : prefix format : 1.234×10-1 m
4 : mathml format :
5 : long prefix format : 1.234×10-1 milli
Output data
Example
shortpath
Xiao Gang
Use
Finds the shortest paths linking given points
Input data
wims_exec_parm is ... . w_shortpath_style : 0: loop to the start 1: arbitrary open path 2: open path with fixed start 3: open path with fixed end 4: open path with fixed start and end
compute Voronoi diagram or Delaunay triangulation. Voronoi reads the standard input for a set of points in the plane and writes either the Voronoi diagram or the Delaunay triangulation to the standard output.
Input data
Each input line should consist of two real numbers, separated by white space.
Output data
If option -t is present, the Delaunay triangulation is produced. Each output line is a triple i j k which are the indices of the three points in a Delaunay triangle. Points are numbered starting at 0. If this option is not present, the Voronoi diagram is produced. There are four output record types. s a b indicates that an input point at coordinates l a b c indicates a line with equation ax + by = c. v a b indicates a vertex at a b. e l v1 v2 indicates a Voronoi segment which is a subsegment of line number l; with endpoints numbered v1 and v2. If v1 or v2 is -1, the line extends to infinity.
Some files in the distribution are template. They can be changed and used
for global configuration. They are local so will not be erased by WIMS update.
Preliminary version
log/front.phtml.template
replace template by the symbol of a language xx
read this page instead of
public_html/modules/home/front.phtml.xx
so it changes the home page of WIMS for lang=xx
log/motd.phtml.template
replace template by the symbol of a language
xx
General message in the front page of WIMS for
lang=xx
log/manager_msg.phtml.template
replace template by the symbol of a language for
xx
message in all classes seen only by class supervisors for
lang=xx
log/wims.conf.access.template
delete .template
limits the access to some ressources for the whole site
see public_html/scripts/help/xx/accessconf.phtml
for example
# How to add a new anstype (called here `_name`)
Each anstype contains two files, `_name.input` is the input form element, and
`_name` is the answer processing file.
Specific anstypes need not be put into this directory.
One can create a subdirectory "anstype" in the module, then put the files there.
Any name will do, but we recommend that module-specific anstypes use a specific
prefix for its names, like "mynumeric", "myfunction", ..., in order to avoid
possible confusions.
In an oef exercise, the anstype is called by the line
`\answer{xxx}{yyy}{type=_name}{option=zzz}`
see later for the intern variables corresponding to the values.
The input file should contain the following two definitions:
1. define `anstype=yes`. Otherwise the OEF manager will not recognize the
existence of the anstype.
2. define the form style using the variable `anstyle`. Here are the possible
words to declare in this variable:
* `mc`: multiple choice style.
* `symtext`: allows symtext processing.
* `numeric`: the data is numeric or with an input field
* `dprompt`: correct answer prompt given under double-underlined variable (internal `reply__$i`);
in this mode, the correct answer is not present by default.
* `nogood`: never present correct answer (because there cannot be).
* `noanswer`: never present the answer analysis (because there is no correct or wrong answer)
These scripts accept the following input variables:
* `i`: The number of the reply field.
* `replyname$i`: The prompt of the form element.
* `reply$i`: The answer given by the student.
* `replygood$i`: The correct answer given by the author.
so the value of the second field of `\answer{}{}`.
* `replyoption$i`: Option words. Anstypes are more or less free to
define their own recognized option words.
In oef exercises, it correspond to the value `zzz` in `{option=zzz}`
* `inputsize`: the second item of the field \embed{} (the first one is
* `r$i` ou `reply$i`). In general, it contains the size of the form element.
Moreover, if no comparison is wanted, the answer processing file can have a
calling parameter "nocompare" (not useful in oef exercices).
Output variables of the answer processing file:
* `Test`: Put `bad $i` if the correct answer given by the author
is not understandable.
* `test`: Put `NaN` followed possibly by an error indicator,
if the answer given by the student is not understandable.
some available error indicators:
* `badsize` (following by a number)
* `badform`
* `badform noreduced`
* `nocompute`
* `nocomputecomplex`
* `notunit`
* `bad_variable`
* `unknownword` followed by some words
* `chemdraw_empty_data`
* `chemclick_empty_data`
* `diareply$i`: Diagnostics result. Possible values: `good`, `bad`.
* `precreply$i`: If the answer misses the correct result just by a
problem of precision, put `yes` to this variable and put
`bad` to `diareply$i`. In the computation of the score, a coefficient
depending on the level is introduced. In thise case, one must
not advance `freegot` at all.
* `partialgood$i`: If the answer should be considered as partially correct,
put `yes` to this variable and put `good` to `diareply$i`.
It has no consequence on the calculation of the real score (use `freegot` for that).
* `freegot`: This is a numerical variable. Its content is incremented
by 1 if the answer is 100% OK, none if it is false,
or anything between 0 and 1 for partially correct answer.
It is not recommended to decrement this value, nor to
increment it more than 1. The real score is computed using it.
So,
`partialgood$i=yes + diareply$i=good + freegot` advances of a number strictly between 0 and 1
or
`!advance precgood + diareply$i=bad + fregot=0 + precreply$i=yes`
There are also some optional output variables (they can be left empty).
* `replyGood$i`: This variable can be defined for the correct answer
shown to the students after replying to the exercise,
It should be different than the real `replygood$i`.
It is not shown in the analysis of the answer for false student
answer if dprompt is declared in anstyle.
* `m_reply$i`: This variable can be defined for the answer shown back
in the oef variable `reply$i`, if it should be different than the
real answer typed in.
* `reply_$i`: The answer of the student shown in the html page in place
of `\embed{}` or in the analysis zone (for oef exercises).
* `reply__$i`: A special prompt in the analysis of the answer
to show when `dprompt` is declared in anstyle. If it is empty, its
value is the value of `reply_$i`. If the variable `noshow$i` is yes,
the student reply is not shown in the answer analysis.
* `m_sc_reply$i`: by default 0, 0.5 or 1 according to `diareply$i`, `partialgood$i` and
`freegot`. Can be set to special values. Give the possibility
to the developer of exercises to give feedbacks without testing again.
There are also some variables which can be used (new/2009)
* `oef_formnosubmit`: if `yes`, no "Send answer" button appear.
* `oef_js_submit`: can be used to put javascript in the answer button,
the line `onclick="javascript:$oef_js_submit;"` will be present
in this button (in test).
* `oef_anstype_css`: style css (what is inside ``)
will be include at the end of the web page.
If the following variables are defined in the file `_name.input`, they can be reused
in the file `_name`:
`oef_applet_option`,`oef_applet_command`,`oef_fill_option`,`oef_answer_option1`...,
(for reuse applet options or embed options for example, if one wants to use the anstype several
times in the same html page, it is recommanded to use `oef_answer_option$i` indexed by the
answer's number).
If you use an external software, use the variable `ans_require` (best if there is a version number).
Add the help in `scripts/help/anstype` and `scripts/help/anstype.$lang` and in the list
`help/$lang/reply.phtml`.
See the lists of the anstype in the OEF documentation even if they can be used
in any pedagogical modules (with adaptation of the syntax).
# To add a theme:
1. Decide on the name of the theme. If the theme is not intended for
publication, please put it under the subdirectory "local":
`local/1`, `local/YourName`, etc.
Say the name is `local/1`.
2. Copy the content of `public_html/themes/standard` to
`public_html/themes/local/1`, and modify.
- un fichier css global est créé par le script mkcss.pl dans themes.
Ce script concatene et minimise les fichiers css dont la liste est dans le fichier `css.css.template` (respecter la syntaxe ...).
Vous pouvez ainsi utiliser des fichiers css communs dans `themes/_css` des fichiers d'autres thèmes (à manier avec précaution) ou dans le répertoire `local/1/_css` de votre thème.
- Si vous désirez garder certains fichiers sans changement,
il est conseillé de faire plutôt un changement de fichiers.
Par exemple, si vous désirez conserver sans modification le fichier supervisor.phtml
créez-le en écrivant simplement par exemple
`!changeto themes/standard/supervisor.phtml`
- Le fichier `local.phtml.template` une fois changé en `local_phtml.fr`
permet d'inclure des modules administratifs locaux dans les menus
- vous pouvez changer le "vocabulaire" dans la version de langue xx
(par exemple xx=fr) de la manière suivante :
créez un répertoire lang.
Si vous désirez changer la définition des noms
définis dans html, faites-le dans un fichier
`lang/home_names.xx`.
Si les définitions sont faites dans un module administratif,
par exemple dans `modules/adm/class/exam/lang/names.phtml.xx`, faites-le dans un fichier de nom
`adm_class_exam_lang_names.phtml.xx`
- il est possible d'utiliser les "widgets" du répertoire `themes/_widgets`
widget front.phtml:
`!read themes/_widgets/frontmsg.phtml local/data/news.fr blocnews blocexamples`
argument: `nom_du_module` `nom_du_bloc_news` `nom_du_bloc_exemple`
(le module doit être dans `local/data`)
css nécessaires (à rajouter dans `css.css.template`)
`_css/news.css _css/foundation_button.css _css/foundation_animation.css`
À faire :
- nettoyer un peu plus les fichiers pour n'avoir qu'une succession
de widgets.
- bientôt un appel du type
`!read themes/_widgets/visitormenubox.phtml`
lira s'il existe `themes/local/1/_widgets/visitormenubox.phtml` dans `themes/local/1/_widgets` et sinon dans `themes/_widgets`.
* wims_homeref_n0 = renouveler, aide, wims_menu_items (liens venant des modules)
* wims_homeref_n1 : lien sur feuille, séquence, aide, about, resume, divers ! print
* wims_homeref_n2 :
* wims_homeref_n3 : était prévu pour des tabs, ne contient rien à supprimer
* wims_homeref_n4 : contrôle des scores par l'élève
* wims_homeref_n5 contient pour l'instant uniquement l'aide feedback des exos
* wims_hm : lien du menu supérieur (headmenu)
# Model for an slib
The first part (before :proc) is for the documentation.
You can also put the documentation part (everything except slib_author)
in multiple files, one per lang in scripts/help/lang/slib/...
if you want it to be translated.
##############
!if $wims_read_parm!=slib_header
!goto proc
!endif
slib_author=Firstname, Lastname
slib_parms=3\
default, explanation\
default, explanation\
default, explanation
slib_example=example1\
example2
slib_require=
slib_out= result of the slib
slib_comment= more explanation
!exit
:proc
proc
!distribute items $wims_read_parm into slib_xx, slib_yy, slib_zz, and so on
...
calculation
slib_out=
##############
The result must be in the variable slib_out.
Please prefix all the variables names by slib_.
We list here some debugging methods of an administrative module.
You can add anywhere in a module file writen in wims language
(this excludes for instance shell files) a line starting with the
command !debug , followed by a string that may contain
variable names (preceeded by a $ sign) to get their values. For
instance : !debug The score of $user is $score If the program execution tries to execute such a line, it will
stop there, displaying an error message containing your string with
the variable names replaced by their values. In the above example, the
program displays for instance a debugging message containing The score of Ted Watson is 7
All files and line numbers processed when we issue a wims command
can be stored for debugging purposes in a special file named trace.txt
in the tmp/sessions/XXXX directory where XXXX is the session
number. This debugging trace is in action each time the wims command
is executed from a server administrator IP and the debug mode is
enabled (it is then written tmp_debug=yes in log/wims.conf).
You can add a tmp_debug_var variable to the log/wims.conf file
and assign to it the list of variable names whose evolution you want
to know when running the program. You can also add a tmp_debug_use_var
variable to the log/wims.conf file and assign to it a list of variable names:
each time one of these variables is used, its value is put in the debugging trace.
When the server is configured to be in debug mode, peripheral
software error messages are displayed at the bottom of the html page.
This page is not in its usual appearance because WIMS is unable to recognize your
web browser.
Please take note that WIMS pages are interactively generated; they are not ordinary
HTML files. They must be used interactively ONLINE. It is useless
for you to gather them through a robot program.
Description: documentation of WWW Interactive Multipurpose Server This is the main site of WIMS (WWW Interactive Multipurpose Server): interactive exercises, online calculators and plotters, mathematical recreation and games