Documentation page

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,
  • 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 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, ''
      $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, 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 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.

6 Apr 2010

Mathematical operations can be nested, and so symbols can contain expressions with symbols. Many symbols expand to match the size of their contents; note, for instance, the variable size of the square root symbol and the conjugation bar:

symbol matching

Normally we will also want our parentheses to scale depending on their contents, but this will not happen if we type them with the keyboard, since this will result in “normal” characters that do not scale, just as an “a” does not scale. If we want to use parentheses that do scale, we will have to use the , , and  icons in the General tab. By the way, this ensures that all couples of parenthesis are well closed and nested.

Let us see one example, by writing

«math xmlns=¨¨»«msup»«mfenced»«mrow»«mn»1«/mn»«mo»+«/mo»«mfrac»«mi»x«/mi»«mn»2«/mn»«/mfrac»«/mrow»«/mfenced»«mn»3«/mn»«/msup»«/math»

Write the base of the power
Select it
Click on the  icon
Select all of the parenthesis
Click on the  icon in the General tab
Click on the exponent and type 3
If instead of using the  icon we had used the ( and ) keys, the result would have been this:

If your formulae look a little bit odd, remember that, when several symbols are nested, there can be subtle differences depending on the exact order of nesting. For instance, consider «math xmlns=¨¨»«msub»«mover accent=¨true¨»«mi»x«/mi»«mo»§#8594;«/mo»«/mover»«mn»0«/mn»«/msub»«/math» and «math xmlns=¨¨»«mover accent=¨true¨»«msub»«mi»x«/mi»«mn»0«/mn»«/msub»«mo»§#8594;«/mo»«/mover»«/math»; the first is «math xmlns=¨¨»«mover accent=¨true¨»«mi»x«/mi»«mo»§#8594;«/mo»«/mover»«/math» “initialized”, while the second is «math xmlns=¨¨»«msub»«mi»x«/mi»«mn»0«/mn»«/msub»«/math» “vectorized”, so that the vector arrow extends over 0 only in the second case.