-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestcases.html
101 lines (91 loc) · 4.88 KB
/
testcases.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="mathquill.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="mathquill.php"></script>
<script src="AMtoMQlite.js?v=3"></script>
</head>
<body>
<input type="button" onclick="loadcase(0)" value="testcase 1"/>
<input type="button" onclick="loadcase(1)" value="testcase 2"/>
<input type="button" onclick="loadcase(2)" value="testcase 3"/>
<input type="button" onclick="loadcase(3)" value="testcase 4"/>
<input type="button" onclick="loadcase(4)" value="testcase 5"/>
<input type="button" onclick="loadcase(5)" value="testcase 6"/>
<input type="button" onclick="loadcase(6)" value="testcase 7"/>
<input type="button" onclick="loadcase(7)" value="testcase 8"/>
<input type="button" onclick="loadcase(8)" value="testcase 9"/>
<input type="button" onclick="loadcase(9)" value="testcase 10"/>
<br/>
<p>Test name/notes: <span id="testnotes">Default load</span></p>
Initial MathQuill: <span id="editable-math" class="mathquill-editable">e^{3x+4}-5</span><br/>
MathQuill's latex output: <textarea id="latex-source" style="width:60%;vertical-align:top"></textarea><br/>
Converted to AsciiMath: <textarea id="am-source" style="width:60%;vertical-align:top"></textarea><br/>
<span id="doesitmatch"></span><br/>
Converted back to TeX: <textarea id="amt-source" style="width:60%;vertical-align:top"></textarea><br/>
Re-rendered using MathQuill: <span id="output-math" class="mathquill-editable">4\left|x+1\right|</span>
<script type="text/javascript">
var testcases = [ //each is TeX, Asciimath
['3^{-1}+2^4+\\left(2+3\\right)^2-3^{2+3}', '3^-1+2^4+(2+3)^2-3^(2+3)', 'Forms of Exponents'], //forms of exponents
['\\sqrt{2+3}+\\nthroot{3}{5}+\\frac{3}{4}-\\frac{2}{3+4}+\\frac{-1}{-5}', 'sqrt(2+3)+root(3)(5)+3/4-(2)/(3+4)+(-1)/(-5)', 'Roots and fractions'], //roots and fractions
['4+\\left|2 + 3\\right|+1','4+abs(2+3)+1', 'Absolute values. Mathquill can\'t do nested abs'], //absolute values
['3+\\left(2+\\left(3+4\\right)\\right)+3', '3+(2+(3+4))+3', 'Nested parens'], //nested parens
['\\sin^{-1}\\left(\\theta\\right)+\\cos\\left(\\frac{\\pi}{2}x+3\\right)-\\tan^2\\left(x\\right)', 'sin^-1(theta)+cos((pi)/(2)x+3)-tan^2(x)','Trig arctrig and pi'], //pi, trig, arctrig
['\\log\\left(x+3\\right)+\\infty+\\log_2\\right(x\\right)+\\varnothing', 'log(x+3)+oo+log_2(x)+DNE', 'Logs and special chars. DNE is still ok as entry, but this allows \\varnothing as alternative'], //logs and special chars
['27\\frac{2}{3}', '27 2/3', 'Mixed number'], //mixed number
['2=4+2<9\\le10\\text{ or }3>5\\text{all real numbers}', '2=4+2<9<=10 or 3>5all real numbers', 'Equations and inequalities. '], //equations and inequalities
['\\left(2,3\\right)+\\langle{\\frac{2}{3},4}', '(2,3)+<<2/3,4>>', 'Points and vectors. To distinguish angle brackets from inequalities, I\'ll need to adjust the grader to accept <<2,3>> for vector input. MathQuill has a weird format for langle. '], //points and vectors
['\\intervalopenleft{1,2}\\cup\\intervalopenright{2,3}\\cup(3,4)\\cup[4,5]', '(1,2]U[2,3)U(3,4)U[4,5]', 'Intervals. IMathAS uses U as input for union, but that is not really AsciiMath, so this is a bit hacked up.']
];
var latexMath = $('#editable-math'), latexSource = $('#latex-source'), amSource = $('#am-source'), AMTSource = $('#amt-source'), outMath = $('#output-math');
$(function() {
latexMath.bind('keydown keypress', function() {
setTimeout(function() {
var latex = latexMath.mathquill('latex');
latexSource.val(latex);
var AMout = MQtoAM(latex);
amSource.val(AMout);
var AMTout = AMtoMQ(AMout);
AMTSource.val(AMTout);
outMath.mathquill('latex', AMTout);
});
}).keydown().focus();
});
$(function() {
amSource.bind('keydown keypress', function() {
setTimeout(function() {
var AMout = amSource.val();
var AMTout = AMtoMQ(AMout);
AMTSource.val(AMTout);
outMath.mathquill('latex', AMTout);
});
}).keydown().focus();
});
$(function() {
AMTSource.bind('keydown keypress', function() {
setTimeout(function() {
var AMTout = AMTSource.val();
outMath.mathquill('latex', AMTout);
});
}).keydown().focus();
});
function loadcase(n) {
$('#testnotes').html(testcases[n][2]);
latexMath.mathquill('latex', testcases[n][0]);
var latex = latexMath.mathquill('latex');
latexSource.val(latex);
var AMout = MQtoAM(latex);
if (AMout != testcases[n][1]) {
$("#doesitmatch").html('<span style="color:red">Does not match expected AsciiMath output. Expected'+testcases[n][1]+'</span>');
} else {
$("#doesitmatch").html('<span style="color:green">Matches expected AsciiMath output</span>');
}
amSource.val(AMout);
var AMTout = AMtoMQ(AMout);
AMTSource.val(AMTout);
outMath.mathquill('latex', AMTout);
}
</script>
</body>
</html>