Created
March 1, 2019 04:50
-
-
Save extsalt/56e13005bb652426fe3d1dcdd6ca7dd8 to your computer and use it in GitHub Desktop.
mathjax
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
<html> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/latest.js?config=AM_CHTML"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> | |
</head> | |
<body> | |
<div id="app"> | |
<div v-for="(q, i) in questions" :key="i"> | |
<p>#{{q.id}}. {{q.title}}</p> | |
<ul> | |
<li v-for="(o, j) in q.options" :key="j"> | |
<input type="radio" @change="checkAnswer(i,j)" name="option"> {{o.option}}</input> | |
</li> | |
</ul> | |
</div> | |
</div> | |
<script> | |
new Vue({ | |
el: '#app', | |
data: { | |
questions: [ | |
{ | |
id: 1, | |
title: 'What are the roots of this equation `x^2+3sqrtx-1`', | |
options: [ | |
{ | |
'option': '1,2' | |
}, | |
{ | |
'option': '0,0' | |
}, | |
{ | |
'option': '3,4' | |
}, | |
], | |
correct: 1 | |
}, | |
{ | |
id: 2, | |
title: 'solve for x: `dy/dx (x^2)`', | |
options: [ | |
{ | |
'option': '2x' | |
}, | |
{ | |
'option': '2' | |
}, | |
{ | |
'option': '3' | |
}, | |
], | |
correct: 0 | |
}, | |
{ | |
id: 3, | |
title: 'solve for x: `lim_(N->oo) sum_(i=0)^N i^(-2)`', | |
options: [ | |
{ | |
'option': '2x' | |
}, | |
{ | |
'option': '2' | |
}, | |
{ | |
'option': '3' | |
}, | |
], | |
correct: 0 | |
}, | |
{ | |
id: 3, | |
title: 'Value of this determinant: `[[1,2],[3,4]]`', | |
options: [ | |
{ | |
'option': '-2' | |
}, | |
{ | |
'option': '2' | |
}, | |
{ | |
'option': '3' | |
}, | |
], | |
correct: 0 | |
} | |
] | |
}, | |
methods: { | |
checkAnswer(i, j) { | |
var q = this.questions[i]; | |
if (q.correct === j) { | |
alert('Rigth answers'); | |
} else { | |
alert('Wrong answer'); | |
} | |
} | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment