Skip to content

Tangy form event#16

Open
faridy-mahvish wants to merge 7 commits into
RESPECTify-mainfrom
tangy-form-event
Open

Tangy form event#16
faridy-mahvish wants to merge 7 commits into
RESPECTify-mainfrom
tangy-form-event

Conversation

@faridy-mahvish

@faridy-mahvish faridy-mahvish commented Oct 8, 2025

Copy link
Copy Markdown

Description


This pull request adds support for the launcher xAPI parameter. The client now reads the xapiStatement provided in the Tangy form input and sends it to the LRS endpoint specified via the xapi parameter.

This enables proper xAPI tracking for form launches and allows learning activity data to be recorded in the configured LRS.

Files Change and Includes


  • xapi-actor-base.mode.ts
  • xapi.service.ts
  • tangy-from-player-component.ts

@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @faridy-mahvish, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates xAPI (Experience API) functionality into the Tangy Forms player. It enables the collection and submission of xAPI statements based on user interactions within a form. Key changes include a new service for sending xAPI data, modifications to the form player component to capture and dispatch these statements, and new TypeScript interfaces to define the structure of xAPI statements and form responses.

Highlights

  • xAPI Integration: This PR introduces comprehensive xAPI integration into the Tangy Forms player, allowing form interactions to be captured as xAPI statements and sent to a Learning Record Store (LRS).
  • New xAPI Service: A new XapiService is added to handle the sending of xAPI statements, including basic authentication and error handling for network issues.
  • Dynamic Statement Collection: The Tangy Forms player now dynamically collects xAPI statements from form inputs during updates and sends them upon form submission, incorporating actor information from query parameters.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Thank you for your contribution. I've reviewed the changes and have some suggestions to improve correctness, maintainability, and adherence to best practices. My main points are around handling circular dependencies, improving robustness in data parsing, modernizing asynchronous code, and ensuring type safety. Please see my detailed comments below.

Comment thread online-survey-app/src/app/model/xapi-actor-base.model.ts
Comment thread online-survey-app/src/app/model/xapi-actor-base.model.ts
Comment thread online-survey-app/src/app/shared/_services/xapi.service.ts
Comment thread online-survey-app/src/app/shared/_services/xapi.service.ts
Comment thread online-survey-app/src/app/shared/_services/xapi.service.ts Outdated
Comment thread online-survey-app/src/app/shared/_services/xapi.service.ts
tangyForm.addEventListener('TANGY_FORM_UPDATE', async (event) => {
let response = event.target.store.getState()
let response = event.target.store.getState();
this.xapiResponse = [];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xapiResponse is a misleading variable name: this would imply it is the response for sending a statement: it isn't. You are taking in the statements (without actor), and putting the actor into the statement. Could be more accurately called complete statements or statementsWithActor

@@ -0,0 +1,132 @@
export interface TangyFormResponse {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TangyFormResponse, Form, TangyFormItem, and TangyInput interfaces are not related to xAPI, they are not used by xAPI related code, they must be removed and should not be part of this pull request.

export interface XapiChoice {
id: string;
description: {
"en-US": string;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Xapi interfaces also need to be removed: these are not compliant with the xAPI spec (e.g. statements can be of four different types, the result is optional, there are extensions, etc. This could get in the way of a valid statement.

This code is not responsible to validate a statement created by a form component.

xapiEndpoint?: string;
xapiAuth?: string;
xapiRegistration?: string;
xapiStatementWithActor: any[] = [];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be plural: xapiStatementsWithActor

tangyForm.addEventListener('TANGY_FORM_UPDATE', async (event) => {
let response = event.target.store.getState()
let response = event.target.store.getState();
this.xapiStatementWithActor = [];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is flawed: the TANGY_FORM_UPDATE event will happen every time the user clicks next. Hence there will be multiple statements for a single question for a single submission which is not desired.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic needs to move to the after-submit event to avoid the problem as above.

if(this.xapiStatementWithActor && this.xapiStatementWithActor.length > 0 && this.xapiEndpoint && this.xapiAuth) {
for (let statement of this.xapiStatementWithActor) {
try {
await this.xapiService.sendStatement(statement, this.xapiEndpoint, this.xapiAuth);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should make one request to submit statements together (e.g. 1 http request instead of n requests where n is the number of questions).

This is possible as per the xAPI spec

@mikedawson mikedawson left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per comments on lines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants