Har du Postmessage API?

Naturligtvis!

Postmessage API används för att skicka extra information till provsidornas inbäddningssidor. Nästa bit är lite teknisk, försök att stå ut med oss. PostMessage API kommer att pusha ett meddelande som ser ut ungefär såhär:


{
        status: 'ranking',
        ranking: {
               score: 50,           // Number, the mark for the exam. 100 means 100% correct, 0 means 0% correct correct
               answered: 2,         // Number, The amount of answered questions for this session
               correct: 1,          // Number, the amount of questions that were answered (partially) correct
               incorrect: 1,        // Number, the amount of questions that were answered wrong
               points: 2,           // Number, The amount of points scored for this session
               maximum: 4,          // Number, the maximum amount of possible points for this session
               category: {
                       title: 'Failed'  // String,
               }
        }
}

For your ease below I've added a sample JavaScript that you can use on your embedding page. It makes use of the jQuery library, but that requirement can be quite easily removed if necessary.

<script type="text/javascript>
// Sample implementation of events. Using jQuery v1.7 or higher
// Should work on following browsers: http://caniuse.com/#feat=x-doc-messaging
jQuery(window).on("message onmessage", function(event) {
        var     origin = event.originalEvent.origin;
        var     allowedDomains = [
               'https://www.onlinequizcreator.com',
               'https://www.onlineassessmenttool.com',
               'https://www.onlineexambuilder.com',
               'https://www.easy-lms.com'
        ];
        try {
               var     data = (typeof event.originalEvent.data === "string") ? JSON.parse(event.originalEvent.data) || event.originalEvent.data;
        }
        catch (e) {
               return;
        }
       
        if (allowedDomains.indexOf(origin) !== -1 && data.status && data.ranking) {
               // Your custom script....
               // The following variables are available
               data.ranking.score;           // The mark in (%) for this exam. eg. 100 for everything correct and 0 when every answer was wrong
               data.ranking.answered;        // The total amount of answered questions
               data.ranking.correct;         // Amount of correctly answered questions
               data.ranking.incorrect;       // Amount of wrong answered questions
               data.ranking.points;          // The amount of points that the particpant got for this session
               data.ranking.maximum;         // The maximum possible points for this exam
               data.ranking.category.title;  // The name of the category the particpant falls in. Likely to be 'Passed' or 'Failed'
        }
});
</script>
 
Om du fastnar i processen av implementering så hittar du vår support här: support@onlinequizcreator.com

Kom igång idag!

Häng med nästan 1 miljon användare och prova på vårt fantastiska verktyg.

Registrera dig kostnadsfritt