Master Prompt Interactive HTML5 Simulation Design for SLS HTML5
Overview
I want to create an interactive HTML5 simulation called [Insert Title], which models [Describe the simulation, e.g., magnetic field lines around a current-carrying wire]. The simulation should include the following features:
1. Interactivity & User Controls
A slider allowing the user to adjust [Variable, e.g., current from -5 to 5].
Real-time updates where [Describe dynamic elements, e.g., circular magnetic field lines that expand/shrink based on current].
Directional arrows on field lines following [Scientific principle, e.g., the Right-Hand Grip Rule].
Buttons for Play/Pause and Reset to control the simulation.
A score or progress tracker that updates dynamically based on user interaction.
2. xAPI Integration (Learning Management System - SLS)
Include xAPI tracking to record user interactions and send scores to the LMS.
Use xAPIWrapper.js to extract LMS parameters and send statements when a user completes an interaction.
Automatically fetch xAPI parameters when the page loads.
Call
sendScore(score)at appropriate interaction points (e.g., when a user successfully adjusts the field strength or completes a challenge).The xAPI integration should:
Extract
endpoint,auth,agent,stateId, andactivityIdfrom the LMS.Use
ADL.XAPIWrapper.sendState()to send the score.Include the following code:
<script src="xapiwrapper.min.js"></script>
<script>
// Using a namespace to prevent global variable clashes
const XAPIUtils = {
parameters: null, // Parameters store
getParameters: function () {
if (!this.parameters) { // Ensure fetch once
var urlParams = new URLSearchParams(window.location.search);
var endpoint = urlParams.get('endpoint');
var auth = urlParams.get('auth');
var agent = JSON.parse(urlParams.get('agent'));
var stateId = urlParams.get('stateId');
var activityId = urlParams.get('activityId');
ADL.XAPIWrapper.changeConfig({"endpoint": endpoint + "/", "auth": `Basic ${auth}`});
this.parameters = { agent, stateId, activityId };
}
return this.parameters;
}
};
// Immediately invoke getParameters on page load
document.addEventListener("DOMContentLoaded", function() { XAPIUtils.getParameters(); });
</script>
<script>
function sendScore(score) {
try {
const parameters = XAPIUtils.getParameters(); // Retrieve parameters from store
const activityid = parameters.activityId;
const stateId = parameters.stateId;
const agent = parameters.agent;
const registration = null;
const stateValue = { score: score };
ADL.XAPIWrapper.sendState(activityid, agent, stateId, registration, stateValue);
} catch (err) { console.error("An error has occurred!", err); }
}
</script>3. User Experience & Interface
The UI should be responsive, visually appealing, and structured using CSS Flexbox/Grid.
Mobile-friendly design, ensuring usability across screen sizes. The width and height should automatically adjust to fit the SLS iframe without requiring scrolling.
Provide clear visual feedback (e.g., field line changes, arrows updating dynamically).
An explanation section below the simulation describing [Concept, e.g., the Right-Hand Grip Rule] in simple terms.
4. Code Structure & Best Practices
Write clean, modular JavaScript with well-documented comments.
Use event listeners and DOM manipulation to update the UI dynamically.
Optimize performance using requestAnimationFrame for smooth animations.
Ensure accessibility with keyboard navigation, color contrast, and ARIA attributes.
5. Additional Enhancements
If applicable, store user preferences using LocalStorage.
Suggest additional interactive elements, such as zooming, different field densities, or color coding.
Follow best practices for modern web development.
6. Output Requirements
Generate the full HTML, CSS, and JavaScript code in a single file.
The file structure of the generated zip file should be:
index.htmlxapiwrapper.min.js
Include the xAPI integration script (
xapiwrapper.min.js).Ensure the file is lightweight, efficient, and properly structured.
Embed
sendScore(score)at the correct position (e.g., when a user successfully completes an interaction or task).Provide clear comments to guide beginners through the implementation process.
G3 Science Example 1: fail in one try. GPTo3 high, Grok3, deepseek.
G1 Science Example 2: Works on first try, suitable for SLS HTML5 generator
plantwithdrawing.html.zip to upload to SLS |
2. xAPI Integration (Learning Management System - SLS)
Include xAPI tracking to record user interactions and send scores to the LMS.
Use xAPIWrapper.js to extract LMS parameters and send statements when a user completes an interaction.
Automatically fetch xAPI parameters when the page loads.
Call
sendScore(score)at appropriate interaction points (e.g., when a user successfully adjusts the field strength or completes a challenge).The xAPI integration should:
Extract
endpoint,auth,agent,stateId, andactivityIdfrom the LMS.Use
ADL.XAPIWrapper.sendState()to send the score.Include the following code:
<script src="xapiwrapper.min.js"></script>
<script>
// Using a namespace to prevent global variable clashes
const XAPIUtils = {
parameters: null, // Parameters store
getParameters: function () {
if (!this.parameters) { // Ensure fetch once
var urlParams = new URLSearchParams(window.location.search);
var endpoint = urlParams.get('endpoint');
var auth = urlParams.get('auth');
var agent = JSON.parse(urlParams.get('agent'));
var stateId = urlParams.get('stateId');
var activityId = urlParams.get('activityId');
ADL.XAPIWrapper.changeConfig({"endpoint": endpoint + "/", "auth": `Basic ${auth}`});
this.parameters = { agent, stateId, activityId };
}
return this.parameters;
}
};
// Immediately invoke getParameters on page load
document.addEventListener("DOMContentLoaded", function() { XAPIUtils.getParameters(); });
</script>
<script>
function sendScore(score) {
try {
const parameters = XAPIUtils.getParameters(); // Retrieve parameters from store
const activityid = parameters.activityId;
const stateId = parameters.stateId;
const agent = parameters.agent;
const registration = null;
const stateValue = { score: score };
ADL.XAPIWrapper.sendState(activityid, agent, stateId, registration, stateValue);
} catch (err) { console.error("An error has occurred!", err); }
}
</script>3. User Experience & Interface
The UI should be responsive, visually appealing, and structured using CSS Flexbox/Grid.
Mobile-friendly design, ensuring usability across screen sizes. The width and height should automatically adjust to fit the SLS iframe without requiring scrolling.
Provide clear visual feedback (e.g., field line changes, arrows updating dynamically).
An explanation section below the simulation describing [Concept, e.g., the Right-Hand Grip Rule] in simple terms.
4. Code Structure & Best Practices
Write clean, modular JavaScript with well-documented comments.
Use event listeners and DOM manipulation to update the UI dynamically.
Optimize performance using requestAnimationFrame for smooth animations.
Ensure accessibility with keyboard navigation, color contrast, and ARIA attributes.
5. Additional Enhancements
If applicable, store user preferences using LocalStorage.
Suggest additional interactive elements, such as zooming, different field densities, or color coding.
Follow best practices for modern web development.
6. Output Requirements
Generate the full HTML, CSS, and JavaScript code in a single file.
The file structure of the generated zip file should be:
index.htmlxapiwrapper.min.js
Include the xAPI integration script (
xapiwrapper.min.js).Ensure the file is lightweight, efficient, and properly structured.
Embed
sendScore(score)at the correct position (e.g., when a user successfully completes an interaction or task).Provide clear comments to guide beginners through the implementation process.

No comments:
Post a Comment