Documentation page

22 Jul 2010


This installation should used by advanced users or if the automatic installation doesn’t work.

1 Requirements

  • Moodle 1.6 or higher installed.
  • A valid license to install the plugin in a production environment; otherwise, you can use the downloaded file just for demo purposes.

2 Plugin version

This instructions are to be used when installing manually the WIRIS plugin for Moodle up to version 2.2 of the plugin included. For later versions of this plugin, please check these instructions.

3 Uncompressing the package

Unzip WIRIS Plugin package it on your moodle’s root directory.

4 Copy files

Copy wiris directory from pluginwiris/install/filter/ to filter/.

5 Edit files

Copy lib/weblib.php file to lib/weblib.php.old, open lib/weblib.php and search this string:

echo print_editor_config($editorhidebuttons);


Then, add after this line the next code:

/**** begin WIRIS Plugin ****/
echo "\nWiris.register(config);\n";
/**** end WIRIS Plugin ****/




echo print_editor_config($editorhidebuttons);

if (empty($name)) {


echo print_editor_config($editorhidebuttons);

/**** begin WIRIS Plugin ****/
echo "\nWiris.register(config);\n";
/**** end WIRIS Plugin ****/

if (empty($name)) {

5.1 On moodle 1.6 and 1.7

Now search this string:


Then, add before this line the next code:

/**** start WIRIS plugin ****/
$str .= ($scriptcount < 1) ? '<script type="text/javascript" src="' . $CFG->wwwroot . '/pluginwiris/editor/wrs_plugin.js.php"></script>' . "\n" : '';
/**** end WIRIS Plugin ****/



$str .= ($scriptcount < 1) ? '<script type="text/javascript src="' . $CFG->wwwroot . '/lib/editor/htmlarea/lang/en.php"></script>' . "\n" : '';


$str .= ($scriptcount < 1) ? '<script type="text/javascript src="' . $CFG->wwwroot . '/lib/editor/htmlarea/lang/en.php"></script>' . "\n" : '';

/**** start WIRIS plugin ****/
$str .= ($scriptcount < 1) ? '<script type="text/javascript" src="' . $CFG->wwwroot . '/pluginwiris/editor/wrs_plugin.js.php"></script>' . "\n" : '';
/**** end WIRIS Plugin ****/


5.2 On moodle 1.8 or higher

Now search this string:


Then, add before this line the next code:

/**** start WIRIS plugin ****/
$str .= ($scriptcount < 1) ? '<script type="text/javascript" src="' . $CFG->httpswwwroot . '/pluginwiris/editor/wrs_plugin.js.php"></script>' . "\n" : '';
/**** end WIRIS Plugin ****/



$str .= ($scriptcount < 1) ? '<script type=”text/javascript src="' . $CFG->httpswwwroot. '/lib/editor/htmlarea/lang/en.php"></script>' . "\n" : '';


$str .= ($scriptcount < 1) ? '<script type=”text/javascript src="' . $CFG->httpswwwroot. '/lib/editor/htmlarea/lang/en.php"></script>' . "\n" : '';

/**** start WIRIS plugin ****/
$str .= ($scriptcount < 1) ? '<script type="text/javascript" src="' . $CFG->httpswwwroot. '/pluginwiris/editor/wrs_plugin.js.php"></script>' . "\n" : '';
/**** end WIRIS Plugin ****/


6 Activate the filter

6.1 On moodle 1.6

On moodle administration block, click on “Configuration”. Then, click on “Filters”. Finally, activate “Wiris” filter as this image:

6.2 On moodle 1.7 or higher

On moodle administration block, click on “Modules” >> “Filters”. Then, activate “Wiris” filter as this image:

Configure WIRIS Plugin

Now you can set WIRIS Plugin configuration editing pluginwiris/wrs_config.php file. This table specifies each parameter:

 Key  Description  Default value  Possible values 
$CFG->wirisservicehost(1)Host of the application server.'services.wiris.com' 
$CFG->wirisserviceportPort of the application server.80 
$CFG->wirisservicepathContext root of the application server.'/demo/formula' 
$CFG->wirisserviceversionVersion of the application server.'2.0''1.0', '2.0'
$CFG->wirisimagebgcolorBackground formula color.'#fafafa' 
$CFG->wiristransparencySets transparent background for the formulas (avaible for Mozilla / IE 7 or higher).'true''true', 'false'
$CFG->wirisimagefontsizeFormulas font size.'16' 
$CFG->wirisformulaeditorenabledEnable the insertion of formulas using WIRIS Formula Editor.truetrue, false
$CFG->wiriseditorarchiveSpecifies the WIRIS Formula Editor jar file.'wiriseditor.jar' 
$CFG->wiriseditorclassSpecifies the WIRIS Formula Editor main class.'WirisFormulaEditor' 
$CFG->wiriscasenabledEnable the insertion of WIRIS CAS applet in the HTML editor.truetrue, false
$CFG->wiriscascodebase(1)WIRIS CAS codebase.'http://www.wiris.net/demo/wiris/wiris-codebase/' 
$CFG->wiriscasarchive(1)WIRIS CAS jar file.'wrs_XX_en.jar' 
$CFG->wiriscasclass(1)WIRIS CAS main class.'WirisApplet_XX_en' 

Available languages (depending on your WIRIS CAS installation).

'en,es,fr,it,nl,et,ca,eu,pt,de'Any subset of the default value.
$CFG->wirisfilterdirSpecifies where is the WIRIS Plugin filter directory.'filter/wiris' 
$CFG->wirisimagedirSpecifies where the formulas will be created.'filter/wiris' 
$CFG->wirisformulaimageclassSpecifies the class attribute for image formulas.'Wirisformula' 
$CFG->wiriscasimageclassSpecifies the class attribute for CAS objects.'Wiriscas' 
$CFG->wirisproxySpecifies if the server should use a proxy connection.falsetrue, false
$CFG->wirisproxy_hostSpecifies the proxy host.  
$CFG->wirisproxy_portSpecifies the proxy port.  
$CFG->wirisPHP4compatibilitySet it “true” if you are using PHP 4. This attribute disables proxy connections. If you want to use a proxy connection, use PHP 5.truetrue, false

(1)The WIRIS plugin needs to access an external server to get additional resources (formula editor applet, image service and WIRIS CAS). See architecture for more information. The default configuration connects to de demonstration services at www.wiris.net/demo/ . It is possible to install all necessary services in the customer server (not only the plugin).

8 Clean data

If you want to free your disk space, you can empty the cache directory (remember: don’t delete the directory, only remove its contents). The path to that directory is %moodledata%/filter/wiris

This directory will be repopulated when users view the formulas.

19 Jul 2010

Which permissions does the installer need?

The WIRIS Quizzes automatic installer (as well as the uninstaller) is a script that gets executed by the web server. Hence, it will be able to do only what the web server is allowed to do. As a safety measure, it is customary to restrict as much as possible access to the web server files. In order for the installer to work properly, make sure the web server that reading and writing permission in the following paths (from the root directory of Moodle):

  • wiris-quizzes/*
  • question/type
  • lib
  • lib/questionlib.php
  • question
  • question/question.php
  • lang/help

Note that the installer needs permission to read and write both in the wiris-quizzes folder and in all the files it contains. In the other cases, permissions are needed only for the one file or folder indicated.

Once permissions have been granted in those locations, launch the installer. Once installation is complete, restore the initial settings to those files and also to the new WIRIS Quizzes files, which are:

  • wiris-quizzes
  • lib/questionlib.php.old
  • question/question.php.old
  • question/type/matchwiris
  • question/type/multichoicewiris
  • question/type/essaywiris
  • question/type/shortanwerwiris
  • question/type/truefalsewiris
  • question/type/multianswerwiris
  • lang/help/wiris-quizzes


Which WIRIS Quizzes service server must be selected?

An important part of Quizzes is provided by an external server, which is in charge of running the WIRIS CAS programs, evaluating variables and student answers, and other tasks. The WIRIS Quizzes service server is not usually in the same computer where Moodle and Quizzes are installed.

If you are installing this software in a test or a demo environment, quite probably you will find more convenient to use the demo server provided by WIRIS. Select the option “WIRIS demo".

If you want to specify manually a server, select the last option, “Use your own server”, and fill in the three fields that determine the service:

  • WIRIS Quizzes server host: the address of the server where the WIRIS Quizzes service is installed. For instance, services.wiris.com.
  • WIRIS Quizzes server port: the port in which the WIRIS Quizzes service can be found. For instance, 80.
  • WIRIS Quizzes server path: the service path, relative to the server address. For instance, /quizzes/qwirisservlet.


Which tables does WIRIS Quizzes create in Moodle’s database?

Quizzes needs a set of additional tables in Moodle’s database, where information is stored about the questions that use Quizzes’s functionalities. Note that questions which do not use Quizzes’s functionalities will use only the usual tables of Moodle.

Concretely, Quizzes uses two tables for each question it can handle. One table is use to store the options of each question, and the other stores data need by the WIRIS CAS program. The names of these tables are the following (remember to add the prefix of the tables in your database, usually  'mdl_'):

Type of questionOptions tableWIRIS CAS table
Short answerquestion_shortanswerwirisquestion_wshanprom
True falsequestion_truefalsewirisquestion_wtrflsprom
Multianswer (Cloze)question_multianswerwirisquestion_wmansprom

A definition of these tables in Moodle XMLDB format can be found in the file wiris-quizzes/install/db/install.xml.

How to create by hand the tables WIRIS Quizzes needs?

If the automatic installation of the database has failed, you can manually execute the SQL commands needed to create the tables. In order to get these commands, you can use a Moodle tool: the XMLDB editor. Hence, from an XML file that specifies the tables, you can obtain the SQL code to create them in any database supported by Moodle.

  1. Find the file wiris-quizzes/install/db/install.xml. It contains the complete specification in XMLDB format of the tables needed by WIRIS Quizzes.
  2. Open this file with the Moodle XMLDB editor, that can be found within the Moodle Administration menu, in the Miscelanea section. It is possible that, in order to open the file, you may have to make a copy of it into one of the directories that Moodle reads. For instance, you could copy wiris-quizzes/install/db/install.xml to question/type/shortanwerwiris/db/install.xml.
  3. From the XMLDB editor, load the file and click on “Edit".
  4. Click on “See SQL code” and select your type of database.
  5. You will be shown the SQL code required to create the tables.
  6. Copy and paste it into the SQL client of your database.
  7. Remove the file question/type/shortanwerwiris/db/install.xml if you had to create it.

How to update WIRIS Quizzes to the latest version?

Quizzes does not have an automatic update mechanism. The neatest way to update is uninstalling it and then installing the latest version:

Go to http://<your_moodle>/wiris-quizzes/uninstall.php and go until the third screen, where you are asked which actions must perform the uninstaller. Select only the first two actions; that is, “Uninstall WIRIS Quizzes” and “Delete WIRIS Quizzes files”. It is extremely important NOT to choose the third option, because you would erase all Quizzes data and all questions that use Quizzes.

After uninstallation is complete, install the latest version by following the installation instructions.

19 Jul 2010

Remember that this installation procedure is only intended for system administrators with particular needs, or in case the automatic installation has failed.

Follow these instructions:

  1. Unzip wiris-quizzes-x.x.x.xx.zip in the root directory of Moodle. The folder wiris-quizzes will be created.
  2. Copy the following folders:
    • From wiris-quizzes/questiontypes to question/type. There are 6 folders which contain the new question types used by WIRIS Quizzes, which will be added to Moodle’s question types.
  3. Edit the following Moodle files:
    1. lib/questionlib.php
      1. Make a copy of this file; copy lib/questionlib.php to lib/questionlib.php.old . The name of the backup file is important because it could be used in case of update or uninstallation.
      2. Open lib/questionlib.php with a plain text editor.
      3. Search for the following string in the text:
        						if ($menuname) {
      4. Add, immediately after this line, the following three lines:

        						/**** start WIRIS plugin ****/
        if (array_key_exists($name . "wiris", $QTYPES)) continue;
        /**** end WIRIS Plugin ****/
      5. Hence, this fragment of file will look like this:

        						foreach ($QTYPES as $name => $qtype) {
            $menuname = $qtype->menu_name();
            if ($menuname) {
                /**** start WIRIS plugin ****/
                if (array_key_exists($name . 'wiris', $QTYPES)) continue;
                /**** end WIRIS Plugin ****/
                $menu_options[$name] = $menuname;
    2. question/question.php
      1. Just as before, make a copy of this file and call it question/question.php.old .
      2. Open question/question.php with a plain text editor.
      3. Search for the following line in the text:
        						// Validate the question category.
      4. Add, immediately before this line, the following four lines:
        						/**** begin WIRIS Plugin ****/
        if (array_key_exists($question->qtype . 'wiris', $QTYPES))
        $question->qtype = $question->qtype . 'wiris';
        /**** end WIRIS Plugin ****/
      5. Hence, this fragment of file will look like this:
        						print_error('notenoughdatatoeditaquestion', 'question', $returnurl);
        /**** begin WIRIS Plugin ****/
        if (array_key_exists($question->qtype . 'wiris', $QTYPES))
        $question->qtype = $question->qtype . 'wiris';
        /**** end WIRIS Plugin ****/
        // Validate the question category.
        if (!$category = get_record('question_categories', 'id', $question->category)) {
  4. Configure Quizzes by editing its configuration file:
    1. Find the configuration file of Quizzes: wiris-quizzes/wrsqz_config.php .
    2. Make a copy of this file, and call it wiris-quizzes/wrsqz_config.php.old .
    3. Open wiris-quizzes/wrsqz_config.php with a plain text editor. It will have the following content:
      global $CFG;
      $CFG->wirisquizzes_imagedir = 'wiris-quizzes/imagecache';
      //Plot images style options.
      $CFG->wirisquizzes_plotborderstyle = 'solid';
      $CFG->wirisquizzes_plotborderwidth = '1px';
      $CFG->wirisquizzes_plotbordercolor = '#8888ff';
      $CFG->wirisquizzes_plotmargin = '5px';
    4. Each line with the form:
      				$CFG->wirisquizzes_xxx = yyy;

      is the definition of a configuration parameter of Quizzes. In most cases, and especially in test or demo installations, you will not have to change any of these parameters. In a production environment, however, it is very likely that you will have to modify the first three parameters, related to the WIRIS Quizzes remote server (see Which WIRIS Quizzes service server must be selected?). Next we explain the meaning of each parameter.

      Parameter Description
      $CFG->wirisquizzes_serverhost The address of the remote web server where it has been installed the WIRIS Quizzes service. By default, 'services.wiris.com'
      $CFG->wirisquizzes_serverport The port where the WIRIS Quizzes is found in the above server. By default, '80'.
      $CFG->wirisquizzes_serverpath The route, relative to the server address, in which the WIRIS Quizes server can be found. For instance, if the service is at http://services.wiris.com/quizzes/qwirisservlet, this property should be '/quizzes/qwirisservlet'. Usually this parameter will not have to modified.
      $CFG->wirisquizzes_imagedir The folder, relative to the Moodle data folder (usually moodledata), where images generated by Quizzes are stored. Don’t get this mixed with the folder where the WIRIS Plugin stores formulae images, although they can be the same. By default, 'wiris-quizzes/imagecache'.
      $CFG->wirisquizzes_plotborderstyle The style of the border used for the images of graphics generated by Quizzes. The syntax is that of CSS stylesheets. By default, 'solid'.
      $CFG->wirisquizzes_plotborderwidth The width of the border used for the images of graphics generated by Quizzes. The syntax is that of CSS stylesheets. By default, '1px'.
      $CFG->wirisquizzes_plotbordercolor The color of the border used for the images of graphics generated by Quizzes. The syntax is that of CSS stylesheets. By default, '#8888ff'.
      $CFG->wirisquizzes_plotmargin The margin used for the images of graphics generated by Quizzes. The syntax is that of CSS stylesheets. For example, '5px'.
      $CFG->wirisquizzes_maxconnections Number of maximum simultaneous connections to WIRIS quizzes services.

  5. Create the tables needed for Quizzes in Moodle’s database. Except in very unusual cases, this process can be done automatically. Just open your browser and write this address in the navigation bar: http://<your_moodle>/wiris-quizzes/installdb.php . In case an error happens, you can find the database specification in Moodle XMLDB format at wiris-quizzes/install/db/install.xml. Vea Which tables does WIRIS Quizzes create in Moodle’s database? y How to create manually the tables WIRIS Quizzes needs? in case you need it.
15 Jul 2010

Moodle Quiz Module allows you to define questionnaire-like activities in a course. A questionnaire consists of a set of questions, probably of different types. Read the information on moodle.org about this module if you are not familiar with it. From now on, Moodle basic terminology on questionnaires will be adopted.

WIRIS QUIZZES improves the types of questions in Moodle in order to add additional options aimed at posing strong maths questions. These options are displayed by clicking Show Advanced.

This manual offers a gradual and detailed view of WIRIS QUIZZES. It can be read linearly, or individual articles can be checked through the menu or through the following list:

9 Apr 2010

WIRIS Editor works with MathML but under some circumstances it modifies slightly the XML encoding.

This is done when the application that uses WIRIS editor does not allow inserting XML. For example, Moodle filters some HTML tags (APPLET, OBJECT, EMBED, etc.) and all unrecognized XML tags, and so it removes any MathML formula. This also occurs when the MathML appears inside an HTML attribute (for example, the SRC attribute of an IMG tag) and the browser, wrongly, tries to parse it.

In these situations, the 5 reserved characters of XML are replaced by other characters as shown in the following table:

Original XML characterReplacing character
< (#3C)« (#AB)
> (#3E)» (#BB)
& (#26)§ (#A7)
" (#22)¨ (#A8)
' (#27)´ (#B4)

For example,

Original XML fragmentReplaced XML fragment
<math xmlns="…">
«math xmlns=¨…¨»
    «mn»§pi; «/mn»

Then, recovering the MathML from the modified version is as simple as undoing the replacement. We provide as attached file an XSLT that does this replacement.