13,689 new quiz questions in 160 practice islands (grades 3-12), Question.figure, replay rotates the quiz, LaTeX removed from lesson/question text
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
52
content/tests_plain_math.py
Normal file
52
content/tests_plain_math.py
Normal file
@@ -0,0 +1,52 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
from content.plain_math import convert, convert_figures, leftover
|
||||
|
||||
SEED = Path(__file__).parent / 'seed' / 'curriculum.json'
|
||||
|
||||
|
||||
class ConvertTests(SimpleTestCase):
|
||||
def test_vector_and_sets(self):
|
||||
self.assertEqual(convert(r'بردار \( \vec{a} \) و \( \vec{AB} \)'), 'بردار a و AB')
|
||||
self.assertEqual(convert(r'از \( \mathbb{Q} \) و \( \mathbb{R} \)'), 'از ℚ و ℝ')
|
||||
|
||||
def test_norm_sqrt_powers(self):
|
||||
self.assertEqual(convert(r'\( \|\vec{a}\| = \sqrt{x^2 + y^2} \)'), '|a| = √(x² + y²)')
|
||||
self.assertEqual(convert('(−۱)^{۲+۲}'), '(−۱)²⁺²')
|
||||
|
||||
def test_unmappable_script_is_kept_readable_not_dropped(self):
|
||||
self.assertEqual(convert('D_{g}'), 'D_(g)')
|
||||
self.assertEqual(convert('a^b'), 'a^b')
|
||||
|
||||
def test_blank_placeholder_untouched(self):
|
||||
self.assertEqual(convert('3، 6، ___، 12'), '3، 6، ___، 12')
|
||||
|
||||
def test_idempotent(self):
|
||||
s = r'\( \frac{1}{2} \vec{a}^{n} \)'
|
||||
self.assertEqual(convert(convert(s)), convert(s))
|
||||
|
||||
def test_figure_expr_is_never_rewritten(self):
|
||||
fig = [{'diagram': {'items': [{'type': 'function', 'expr': 'x^2', 'label': 'f(x)=x^2'}]}}]
|
||||
out = convert_figures(fig)[0]['diagram']['items'][0]
|
||||
self.assertEqual(out['expr'], 'x^2')
|
||||
self.assertEqual(out['label'], 'f(x)=x²')
|
||||
|
||||
|
||||
class SeedHasNoLatexTests(SimpleTestCase):
|
||||
"""گزارشِ مالک ۲۰۲۶-۱۰-۱۲: LaTeX خام در درسهای بردار. فرانت LaTeX رندر نمیکند."""
|
||||
|
||||
def test_no_latex_in_lesson_text(self):
|
||||
data = json.loads(SEED.read_text(encoding='utf-8'))
|
||||
bad = []
|
||||
for g in data['grades']:
|
||||
for u in g['units']:
|
||||
for n in u['nodes']:
|
||||
for l in n['lessons']:
|
||||
texts = [l.get('introText'), l.get('example'), *(l.get('steps') or [])]
|
||||
for t in texts:
|
||||
if leftover(t):
|
||||
bad.append((l['title'], leftover(t)))
|
||||
self.assertEqual(bad, [])
|
||||
Reference in New Issue
Block a user