reactjs - How to capture the xAPI events in a LMS? - Stack Overflow

I am building a react based LMS, I have been stuck on a issue where I have a xAPI conformant course con

I am building a react based LMS, I have been stuck on a issue where I have a xAPI conformant course constructed using articulate 360. I hosted the course on localhost 8000 and using it in iframe to import inside my LMS. i have setup event listeners on window to capture the events happening inside iframe. Now whenever I perform any action on the course I don't get any data related to course.

                         <iframe
                ref={iframeRef}
                id='parent-frame'
                width={600}
                height={600}
                src='http://localhost:8000/index.html'
                onLoad={handleIframeLoaded}
                ></iframe>

This is iframe code where I am loading the course.

useEffect(() => {
        const listeners = (event: MessageEvent) => {
            console.log('message from Iframe:', event);
            if (iframeRef.current && event.source === iframeRef.current.contentWindow) {
                try {
                    const messageData = JSON.parse(event.data);
                    if (messageData.statement) {
                        console.log('xAPI Statement:', messageData.statement);
                    } else {
                        console.log('message from Iframe:', messageData);
                    }
                } catch (error) {
                    console.error('Error processing message:', error);
                }
            }
        };

        window.addEventListener('message', listeners);

        return () => {
            window.removeEventListener('message', listeners);
        };
    }, []);

this is the event listener I have applied where I am expecting to capture the xAPI events but all I get is coursePreviewClicked on console logging the event data.

I am building a react based LMS, I have been stuck on a issue where I have a xAPI conformant course constructed using articulate 360. I hosted the course on localhost 8000 and using it in iframe to import inside my LMS. i have setup event listeners on window to capture the events happening inside iframe. Now whenever I perform any action on the course I don't get any data related to course.

                         <iframe
                ref={iframeRef}
                id='parent-frame'
                width={600}
                height={600}
                src='http://localhost:8000/index.html'
                onLoad={handleIframeLoaded}
                ></iframe>

This is iframe code where I am loading the course.

useEffect(() => {
        const listeners = (event: MessageEvent) => {
            console.log('message from Iframe:', event);
            if (iframeRef.current && event.source === iframeRef.current.contentWindow) {
                try {
                    const messageData = JSON.parse(event.data);
                    if (messageData.statement) {
                        console.log('xAPI Statement:', messageData.statement);
                    } else {
                        console.log('message from Iframe:', messageData);
                    }
                } catch (error) {
                    console.error('Error processing message:', error);
                }
            }
        };

        window.addEventListener('message', listeners);

        return () => {
            window.removeEventListener('message', listeners);
        };
    }, []);

this is the event listener I have applied where I am expecting to capture the xAPI events but all I get is coursePreviewClicked on console logging the event data.

Share asked Mar 4 at 8:03 Vivek SherkhaneVivek Sherkhane 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

This code is trying to leverage browser based postMessage events (see https://developer.mozilla./en-US/docs/Web/API/Window/postMessage) but that is not how xAPI is implemented. xAPI itself defines the interface to a system called an LRS. The LRS implements a RESTful web service API that the content will communicate directly with. In the case of Articulate 360 it is implemented as a package with a tincan.xml file which follows a set of [deprecated] guidelines released with a pre-1.x version of xAPI that can be found here: https://github/RusticiSoftware/launch/blob/master/lms_lrs.md

To implement an LMS to support this type of content you will need access to an LRS and to implement the launch guidelines such that certain pieces of information are provided to the content's "launch" page. It will then communicate with the LRS directly. For more about launch you may want to visit this page/site: https://xapi/launch/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745056374a4608693.html

相关推荐

  • reactjs - How to capture the xAPI events in a LMS? - Stack Overflow

    I am building a react based LMS, I have been stuck on a issue where I have a xAPI conformant course con

    7小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信