1.1.3 • Published 6 years ago
moodlexml-to-json v1.1.3
MoodleXML to JSON
This JS library parses MoodleXML quizzes into JSON objects.
Usage
import moodleXMLtoJSON from 'moodlexml-to-json';
// ...
moodleXMLtoJSON(xmlString, (result, error) => {
if (error) {
console.error(error);
} else {
console.log(result);
}
}); Examples
On the server
import moodleXMLtoJSON from 'moodlexml-to-json';
const fs = require('fs');
const path = require('path');
const xmlString = fs.readFileSync("/path/to/your/file.xml", 'utf8');
moodleXMLtoJSON(xmlString, (result, error) => {
if (error) {
console.error(error);
} else {
console.log(result);
}
}); On a JS SPA
import moodleXMLtoJSON from 'moodlexml-to-json';
// ...
fetch("https://myweb.org/moodle.xml")
.then(res=>res.text())
.then(xmlString => {
moodleXMLtoJSON(xmlString, (result, error) => {
if (error) {
console.error(error);
} else {
console.log(result);
}
});
});Development
Commands
npm run clean- Removelib/directorynpm test- Run tests with linting and coverage results.npm test:only- Run tests without linting or coverage.npm test:watch- You can even re-run tests on file changes!npm test:prod- Run tests with minified code.npm run test:examples- Test written examples on pure JS for better understanding module usage.npm run lint- Run ESlint with airbnb-confignpm run cover- Get coverage report for your code.npm run build- Babel will transpile ES6 => ES5 and minify the code.npm run prepublish- Hook for npm. Do all the checks before publishing your module.
License
MIT © Sonsoles López Pernas
1.1.3
6 years ago
1.1.2
6 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.0.2-beta
7 years ago
1.0.1-beta
7 years ago
1.0.0-beta
7 years ago
0.0.1-beta
7 years ago