Skip to main content
maximilianf46353140
Known Participant
November 3, 2017
Question

logging duration with xAPI

  • November 3, 2017
  • 1 reply
  • 427 views

Hi everyone, 


I'm trying to log duration with xAPI and encounter some problems.

The first problem is already solved - I had to find out how to get and store the elapsed time on a slide. 

This article was great help: http://iconlogic.blogs.com/weblog/2014/12/adobe-captivate-system-time-variables.html

 

My problem is now that I don't manage to send the ISO-converted time to xAPI and to retain it in my data,

which I'm downloading from scorm cloud via a get request with postman.


Here's my code, Im basically trying to get the elapsed time - which I calculated before using the proposed method from the iconlogic blog -

and to convert it to an iso string and to assign it to the result duration variable:

 

var tincan = new TinCan ({url: window.location.href});

 

var duration_conv = window.cpAPIInterface.getVariableValue("elapsed_time_slide1");

 

 

tincan.sendStatement(

{

    "verb": {

        "id": "http://adlnet.gov/expapi/verbs/completed",

        "display": {

            "en-US": "completed"

        }

    },

"object": {

        "id": "http://COSIMA_TP4_SIM_AINMUELLER/main_question_menu",

        "definition": {

            "name": {

                "en-US": "main_question_menu"

            },

         "description": {

                "en-US": "Menu for main questions"

            }

        },

        "objectType": "Activity"

    },

 

"result": {

    "duration": new Date(duration_conv).toISOString()

  }

}

 

);

This topic has been closed for replies.

1 reply

maximilianf46353140
Known Participant
November 3, 2017

I forgot to mention. I followed the advice to convert the time from Milliseconds to ISO format as proposed here (https://www.w3schools.com/jsref/jsref_toisostring.asp) with the following line of code: 

new Date(duration_conv).toISOString()


PPS: I've also asked this question on stackoverflow as it requires xAPI and Captivate and Javascript knowledge:
https://stackoverflow.com/questions/47098887/log-duration-with-xapi-in-captivate