Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
sonsoleslp committed May 25, 2020
1 parent 822e3e8 commit 84dc0a2
Show file tree
Hide file tree
Showing 5 changed files with 292 additions and 275 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "quiz-converter",
"version": "0.1.0",
"dependencies": {
"aiken-to-moodlexml": "^1.2.1",
"moodlexml-to-json": "^1.1.0",
"aiken-to-moodlexml": "^1.3.4",
"moodlexml-to-json": "^1.1.1",
"react": "^16.6.3",
"react-dom": "^16.6.3",
"react-scripts": "2.1.1"
Expand Down
5 changes: 5 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ textarea {

}

.lc {
padding-left: 10px;
font-size: 11px;
}

@media (max-width: 700px) {
.content {
flex-direction: column;
Expand Down
28 changes: 19 additions & 9 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@ import './App.css';
import moodleXMLtoJson from 'moodlexml-to-json';
import aikenToMoodleXML from 'aiken-to-moodlexml';
import sampleAiken from './sampleAiken';
// import * as Moodle from './moodle';

class App extends Component {
constructor(props) {
super(props);
this.state = {
left: sampleAiken,
right :"",
from: 'txt',
to: 'xml'
to: 'xml',
es: false,
nsnc: false,
penalty: false,
shuffle: false
}
}
render() {
return (
<div className="App">
<header>
<h1> <i className="material-icons">school</i> QUIZ converter</h1>
<div class="links">
<div className="links">
<a target="_blank" rel="noreferrer noopener" href="https://docs.moodle.org/38/en/Moodle_XML_format">MoodleXML</a>
<a target="_blank" rel="noreferrer noopener" href="https://docs.moodle.org/38/en/Aiken_format">Aiken</a>
</div>
Expand All @@ -31,6 +37,10 @@ class App extends Component {
<option value="txt" >Aiken</option>
{/* <option disabled value="json" >JSON</option> */}
</select>
{this.state.from === "txt"? <label className="lc"><input type="checkbox" checked={this.state.es} onChange={()=>this.setState({es: !this.state.es})}/>Spanish</label>: null}
{this.state.from === "txt"? <label className="lc"><input type="checkbox" checked={this.state.nsnc} onChange={()=>this.setState({nsnc: !this.state.nsnc})}/>Empty option</label>: null}
{this.state.from === "txt"? <label className="lc"><input type="checkbox" checked={this.state.penalty} onChange={()=>this.setState({penalty: !this.state.penalty})}/>Proportional penalty</label>: null}
{this.state.from === "txt"? <label className="lc"><input type="checkbox" checked={this.state.shuffle} onChange={()=>this.setState({shuffle: !this.state.shuffle})}/>Shuffle</label>: null}

</div>
<textarea onChange={(e)=>{this.onWrite(e,'left')}} value={this.state.left}></textarea>
Expand Down Expand Up @@ -96,7 +106,7 @@ class App extends Component {

this.setState({right});
})
})
}, {lang: this.state.es ? "es": "en", penalty: this.state.penalty, nsnc: this.state.nsnc, shuffle: this.state.shuffle});
} else if (from === "txt" && to === "xml") {
aikenToMoodleXML(left, (res, err) => {
if (err) {
Expand All @@ -109,7 +119,7 @@ class App extends Component {
.replace(/\t/g, " ");

this.setState({right});
})
}, {lang: this.state.es ? "es": "en", penalty: this.state.penalty, nsnc: this.state.nsnc, shuffle: this.state.shuffle});
} else if (from === "xml" && to === "xml") {
this.setState({right: left});
}
Expand Down Expand Up @@ -138,18 +148,18 @@ class App extends Component {

componentDidMount(){
window.onbeforeunload = (e) => {
let {left, right, from, to} = this.state;
let {left, right, from, to, es, penalty, nsnc, shuffle} = this.state;
if (left === "") {
localStorage.removeItem("moodleXMLtoJson");
} else {
localStorage.moodleXMLtoJson = JSON.stringify({left, right, from, to});
localStorage.moodleXMLtoJson = JSON.stringify({left, right, from, to, es, penalty, nsnc, shuffle});
}
};
if (localStorage.moodleXMLtoJson) {
const {left, from, to} = JSON.parse(localStorage.moodleXMLtoJson);
console.log(left, from, to)
this.setState({left, from, to});
const {left, from, to, es, penalty, nsnc, shuffle} = JSON.parse(localStorage.moodleXMLtoJson);
this.setState({left, from, to, es, penalty, nsnc, shuffle});
}
// window.Moodle = Moodle;
}


Expand Down
Empty file added src/moodle.js
Empty file.
Loading

0 comments on commit 84dc0a2

Please sign in to comment.