-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
38c9bc2
commit 961ed2d
Showing
10 changed files
with
11,015 additions
and
2,745 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["@babel/preset-env"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"target": "es6", | ||
"checkJs": true | ||
}, | ||
"include": ["src/**/*"], | ||
"exclude": ["node_modules"] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { LT } from './src/assessment/core.js'; | ||
|
||
window.launch = function (app) { | ||
LT.init(app); | ||
window.LT = LT; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const express = require('express'); | ||
const net = require('net'); | ||
const path = require('path'); | ||
const signature = require('./signature'); | ||
|
||
const app = express(); | ||
const PORT = process.env.PORT || 5150; | ||
let server; | ||
|
||
app.set('view engine', 'ejs'); | ||
app.set('views', './tests/api-server/src/views'); | ||
app.use(express.static('./tests/api-server/public')); | ||
app.use('/src', express.static(path.join(__dirname, '../../../src'))); | ||
app.use('/dist', express.static(path.join(__dirname, '../../../dist'))); | ||
app.use('/src', (req, res, next) => { | ||
if (req.path.indexOf('.js', req.path.length - 3) === -1) { | ||
// If the request does not end in '.js', append '.js' and try to resolve the file | ||
const jsPath = path.join(__dirname, '../../../src', `${req.path}.js`); | ||
res.sendFile(jsPath); | ||
} else { | ||
next(); | ||
} | ||
}); | ||
|
||
// Route for testing LT modules (initalises Items API) | ||
app.get('/itemsapi', (req, res) => { | ||
const signatureData = signature.itemsApi(); | ||
res.render('itemsapi', { signature: JSON.stringify(signatureData) }); | ||
}); | ||
|
||
function startServer() { | ||
checkServer(PORT, isRunning => { | ||
if (!isRunning) { | ||
console.log('Starting the server...'); | ||
server = app.listen(PORT); | ||
} | ||
}); | ||
} | ||
|
||
function checkServer(port, callback) { | ||
const server = net.createServer(); | ||
server.once('error', function (err) { | ||
if (err.code === 'EADDRINUSE') { | ||
callback(true); | ||
} | ||
}); | ||
|
||
server.once('listening', function () { | ||
server.close(); | ||
callback(false); | ||
}); | ||
|
||
server.listen(port); | ||
} | ||
|
||
function stopServer() { | ||
server.close(); | ||
} | ||
|
||
module.exports = { startServer, stopServer }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const LearnositySDK = require('learnosity-sdk-nodejs/index'); | ||
|
||
function itemsApi() { | ||
const signature = new LearnositySDK().init( | ||
'items', | ||
{ | ||
consumer_key: 'yis0TYCu7U9V4o7M', | ||
domain: 'localhost', | ||
}, | ||
'74c5fd430cf1242a527f6223aebd42d30464be22', | ||
{ | ||
user_id: 'lt-user', | ||
session_id: '4ca30e35-d73a-4135-af33-f9cad7d01652', | ||
activity_id: 'lt_integration_testing', | ||
rendering_type: 'assess', | ||
type: 'local_practice', | ||
name: 'LT integration testing', | ||
items: ['itembranching-demo-open1', 'itembranching-demo-open2', 'itembranching-demo-open3'], | ||
config: { | ||
regions: 'main', | ||
navigation: { | ||
show_intro: false, | ||
}, | ||
}, | ||
} | ||
); | ||
|
||
return signature; | ||
} | ||
|
||
module.exports = { itemsApi }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<body> | ||
<div id="flag"></div> | ||
<div id="learnosity_assess"></div> | ||
<script src="https://items.learnosity.com?developer"></script> | ||
<script src="./index.mjs" type="module"></script> | ||
<script> | ||
const signature = <%- locals.signature || {} %>; | ||
const itemsApp = LearnosityItems.init(signature, { | ||
readyListener: init, | ||
errorListener: error | ||
}); | ||
function init() { | ||
// A DOM element that we can set so the test script knows the API has rendered | ||
document.getElementById('flag').classList.add('has-loaded'); | ||
console.log('Items API ready!'); | ||
window.launch(itemsApp); | ||
} | ||
function error(e) { | ||
console.log('Items API error', e); | ||
} | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.