Har du en postmessage API?

Ja, ihvertfald!

Postmessage API bruges til at sende ekstra informationer til den indbyggede side af vores eksamener. Den næste del er en smule teknisk, det undskylder vi. Postmessage API sender en besked, som ser sådan ud:

 

{
        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 at lette forståelsen har vi tilføjet et eksempel af JavaScript, som du kan bruge på din indbyggede side. Det bruger jQuery library, men den forudsætning kan nemt fjernes.

<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>

Hvis der opstår nogle problemer med integrationen, så ved du, hvor du kan finde vores support  support@onlinequizcreator.com.

 

 

Kom igang allerede idag!

Tilslut dig næsten 1 million bruger og prøv vores fantastiske værktøj.

Registrer gratis