WIRISquizzes Integration Guide 1.2

Embed Size (px)

Citation preview

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    1/13

    WIRIS quizzes 2. Integration guide

    Document Release: 1.2 

    2016 may, Maths for More

    www.wiris.com 

    Contact: [email protected] 

    Summary. This guide explains a set of scenarios solved with WIRIS quizzes 2. It starts

    explaining how to call WIRIS quizzes services to evaluate a student answer and, then,

    how to integrate WIRIS editor in a quizzes system context.

    Contents

    Where can be integrated WIRIS quizzes? ........................................................................................... 2

    Comparing the equivalence of two formulas ...................................................................................... 3

    Embedding WIRIS editor ..................................................................................................................... 4

    Customizing WIRIS editor toolbar ....................................................................................................... 5

    Comparing two formulas with additional criteria ............................................................................... 6

    Step 1. Obtaining the question XML ............................................................................................... 6

    Step 2. Using the question descriptor in your program .................................................................. 8

    Validate the student answer with a custom algorithm ....................................................................... 9

    Change input symbols: working with physics units .......................................................................... 11

    Allowing physical units in WIRIS editor ......................................................................................... 12

    Integrating WIRIS quizzes studio in your own platform.................................................................... 13

    http://www.wiris.com/http://www.wiris.com/mailto:[email protected]:[email protected]:[email protected]:[email protected]://www.wiris.com/

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    2/13

    Maths for More 2016 WIRIS quizzes integration guide Page 2 of 13 

    Where can be integrated WIRIS quizzes?

    WIRIS quizzes mainly targets Web applications. There are currently five integrations that you can

    download as part of the respective “Getting started” example:

    1) 

    PHP integration

    2) 

    .NET integration

    3)  Java integration

    4)  JavaScript integration

    5)  ActionScript 3/Flash integration

    The PHP, .NET and Java integrations require that you programmatically call the WIRIS quizzes API

    in order to evaluate the answer of a student. This invocation is done from the server-side.

    For the JavaScript and ActionScript 3/Flash integrations, you also need to programmatically call

    the WIRIS quizzes API. But, instead, the invocation is done from the browser. This option is less

    secure because the correct answer is also sent to the client browser.

    It’s worth to note that the JavaScript and ActionScript 3/Flash integrations also need some server-

    side scripts used to connect your server with WIRIS quizzes server. Such scripts are part of the

    integration (Getting started examples) that we already provide for you.

    In any case, the ultimate evaluation of the student answer is performed by WIRIS quizzes using its

    Web services:

    BrowserYour server

    WIRIS quizzesWeb-servicesWIRIS quizzes

    integration

    http://www.wiris.com/quizzes/download/generichttp://www.wiris.com/quizzes/download/generichttp://www.wiris.com/quizzes/download/generic

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    3/13

    Maths for More 2016 WIRIS quizzes integration guide Page 3 of 13 

    Comparing the equivalence of two formulas

    This section explains how to compare the equivalence of two formulas given by plain text or

    MathML. We will check that x+1 is equivalent to 1+x.

    First download the getting started source code from www.wiris.com/quizzes/download/generic  

    compatible with your technology.

    Let’s note that all this examples will connect to www.wiris.net to perform the actual computations.

    The source code to compare $correctAnswer and $studentAnswer is as follows.

    This example depends on the quizzes/quizzes.php and related files that can be found in the getting

    started source code.

    Any or both $correctAnswer and $studentAnswer could contain MathML. For example,

    $correctAnswer = "x+1";

    The importance of MathML is that it can be edited with WIRIS editor, see next section of this

    documentation.

    Further discussions about the API can be found WIRIS quizzes API. 

    http://www.wiris.com/quizzes/download/generichttp://www.wiris.com/quizzes/download/generichttp://www.wiris.net/http://www.wiris.net/http://www.wiris.net/http://www.wiris.com/quizzes/demo/generic/doc/index.htmlhttp://www.wiris.com/quizzes/demo/generic/doc/index.htmlhttp://www.wiris.com/quizzes/demo/generic/doc/index.htmlhttp://www.wiris.com/quizzes/demo/generic/doc/index.htmlhttp://www.wiris.net/http://www.wiris.com/quizzes/download/generic

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    4/13

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    5/13

    Maths for More 2016 WIRIS quizzes integration guide Page 5 of 13 

    Customizing WIRIS editor toolbar

    The default WIRIS editor will be fine for many scenarios but you will, eventually, want to configure

    the toolbar icons or any other aspect. You can check the documentation in Embed WIRIS editor to

    get an idea of the available initialization parameters.

    To configure WIRIS editor, you will need to specify the initialization parameters as follows:

    ...answerField = uibuilder.newAnswerField(null, null, 0);answerField.setEditorInitialParams({'toolbar':''+

    ''+''+''+''+''+''+''+'',

    });...

    Example of customized toolbar:

    http://www.wiris.com/en/editor/docs/resources/embed-editorhttp://www.wiris.com/en/editor/docs/resources/embed-editorhttp://www.wiris.com/en/editor/docs/resources/embed-editorhttp://www.wiris.com/en/editor/docs/resources/embed-editor

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    6/13

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    7/13

    Maths for More 2016 WIRIS quizzes integration guide Page 7 of 13 

    Move to Validation tab and check is simplified.

    Move to Preview and play with possible student’s answers. You will realize that – + 1  is a valid

    response

    and 1−2 +   is wrong because it is not simplified.

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    8/13

    Maths for More 2016 WIRIS quizzes integration guide Page 8 of 13 

    Now, we will get the Question XML in order to use it in our program. Type Shift+Ctrl+Q and thefollowing dialog will appear:

    You can copy the Question XML and save it into a file named “simplified.xml”. 

    Step 2. Using the question descriptor in your program

    Create a file named example2.php with the following content

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    9/13

    Maths for More 2016 WIRIS quizzes integration guide Page 9 of 13 

    $instance->update($response);// Ask for the correctness of the 0th response.$correct = $instance->isAnswerCorrect(0);echo $correct;

    ?>

    Validate the student answer with a custom algorithm

    You can benefit from the whole power of WIRIS cas for validate answers. For example, you could

    request to the student to input a polynomial that has a given list of roots. Thus, you need a way to

    verify that a certain polynomial has the required roots.

    Visit http://www.wiris.com/quizzes/tests/generic/level3.php   and press the icon. With the

    new window press the variable tab and write the following program:

    Go back to Validation tab and set Grading function with value test.

    http://www.wiris.com/quizzes/tests/generic/level3.phphttp://www.wiris.com/quizzes/tests/generic/level3.phphttp://www.wiris.com/quizzes/tests/generic/level3.php

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    10/13

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    11/13

    Maths for More 2016 WIRIS quizzes integration guide Page 11 of 13 

    Change input symbols: working with physics units

    This section is related to physics units but is also interesting for understanding how to enable or

    disable some symbols using the following WIRIS quizzes studio sections from Validation tab

    and

    WIRIS quizzes needs to be notified when working with physics units. The underlying reason is thatit needs recognize km as kilometer instead of the multiplication of the two variables k and m.

    Open WIRIS quizzes studio as explained previously and select Quantity.

    Press Ctrl+Shift+Q and get the question XML and save it to quantity.xml

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    12/13

    Maths for More 2016 WIRIS quizzes integration guide Page 12 of 13 

    $instance = $builder->newQuestionInstance();$instance->update($response);// Ask for the correctness of the 0th response.$correct = $instance->isAnswerCorrect(0);echo $correct;

    ?>

     Allowing physical units in WIRIS editorIf you want to use WIRIS editor with physical units you will need to enable them.

    Create the file “editor2.html” and write the following 

    function displayEditor() {// Get WIRIS quizzes User Interface Builder.var builder = com.wiris.quizzes.api.QuizzesBuilder.getInstance();

    var question = builder.readQuestion(' … ');var uibuilder = builder.getQuizzesUIBuilder();// Build student's answer field.answerField = uibuilder.newAnswerField(question, null, 0);var answerContainer = document.getElementById("studentAnswer");answerContainer.replaceChild(answerField.getElement(),

    answerContainer.firstChild);}window.onload=displayEditor;


    Note that some lines, in blue, are shortened with three dots (…). The value passed to readQuestion

    is the question XML:

  • 8/15/2019 WIRISquizzes Integration Guide 1.2

    13/13

    Maths for More 2016 WIRIS quizzes integration guide Page 13 of 13 

    Now, WIRIS editor recognizes the units and displays them in blue.

    Integrating WIRIS quizzes studio in your own platform

    WIRIS quizzes studio is designed to be easily integrated in any web platform. You can follow the

    getting started demos called level 2 and level 3.

    Another benefit on a depth integration of WIRIS quizzes studio is that you have the option to

    generate random questions.