work on multiplication begins

This commit is contained in:
Martin Putzlocher 2025-01-16 01:23:58 +01:00
parent 1fb7dd0c3d
commit ccfa2dc8ce
2 changed files with 16 additions and 6 deletions

View File

@ -17,7 +17,8 @@ ops = {
# Anzahl der zu generierenden Fragen.
NUM_QUESTIONS = 5
# Algebraische Struktur der Aufgaben
STRUCTURE = "(+)-((+)-(+))"
#STRUCTURE = "(+)-((+)-(+))"
STRUCTURE = "*"
# Gleiche Nenner erlauben
SAME_ALLOWED = True
# Größter Zähler
@ -286,6 +287,15 @@ def create_formula_question(ex_number: int):
elif has_minus:
expression_type = "Subtraktion" + f" ({STRUCTURE})"
exercise_text = "Subtrahiere die Brüche"
elif has_mult and has_div:
expression_type = "Punktrechnung" + f" ({STRUCTURE})"
exercise_text = "Berechne den Term"
elif has_mult:
expression_type = "Multiplikation" + f" ({STRUCTURE})"
exercise_text = "Multipliziere die Brüche"
elif has_div:
expression_type = "Division" + f" ({STRUCTURE})"
exercise_text = "Dividiere die Brüche"
else:
expression_type = "Rechnung" + f" ({STRUCTURE})"
exercise_text = "Berechne den Term"
@ -456,7 +466,7 @@ def create_formula_question(ex_number: int):
latex_calculation = gen_latex_calculate_string(STRUCTURE_PH, fractions_latex_strings)
sub_q_t_begin = "<![CDATA[ <p>Berechne:</p>"
sub_q_t_math = "<p>\$\\Large \\displaystyle " + f"{latex_calculation}" + "=\$</p>"
sub_q_t_math = "<p>\(\\Large \\displaystyle " + f"{latex_calculation}" + "=\)</p>"
rows_list = [
["Zähler:", "{_0}"],
["Nenner:", "{_1}"]
@ -490,11 +500,11 @@ def create_formula_question(ex_number: int):
if shortable:
feedback_text = '''<![CDATA[ <h4>Lösungshinweis</h4>
<p>Die korrekte Lösung ist:</p>
<p>\$\\displaystyle''' + f"{latex_calculation}" +" = " + f"{expanded_latex_calculation}" + ''' = \\frac{{resnum}}{{cd}} = \\frac{{sresnum}}{{sresden}} \$ </p> ]]>'''
<p>\(\\displaystyle''' + f"{latex_calculation}" +" = " + f"{expanded_latex_calculation}" + ''' = \\frac{{resnum}}{{cd}} = \\frac{{sresnum}}{{sresden}} \) </p> ]]>'''
else:
feedback_text = '''<![CDATA[ <h4>Lösungshinweis</h4>
<p>Die korrekte Lösung ist:</p>
<p>\$ \\displaystyle ''' + f"{latex_calculation}" +" = " + f"{expanded_latex_calculation}" + ''' = \\frac{{resnum}}{{cd}} \$ </p> ]]>'''
<p>\( \\displaystyle ''' + f"{latex_calculation}" +" = " + f"{expanded_latex_calculation}" + ''' = \\frac{{resnum}}{{cd}} \) </p> ]]>'''
ET.SubElement(feedback_elem, 'text').text = feedback_text
# correctfeedback

View File

@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<quiz><question type="formulas"><name><text>Addition von 2 ungleichnamigen Brüchen 0</text></name><questiontext format="html"><text>&lt;![CDATA[ &lt;p&gt;Addiere die Brüche und kürze das Ergebnis so weit wie möglich.&lt;/p&gt;
&lt;p&gt;{#A} &lt;/p&gt; ]]&gt; </text></questiontext><generalfeedback format="html"><text> </text></generalfeedback><defaultgrade>1.0000000</defaultgrade><penalty>0.3333333</penalty><hidden>0</hidden><idnumber> </idnumber><correctfeedback format="html"><text>&lt;![CDATA[ &lt;p&gt;Die Antwort ist richtig.&lt;/p&gt; ]]&gt; </text></correctfeedback><partiallycorrectfeedback format="html"><text>&lt;![CDATA[ &lt;p&gt;Die Antwort ist teilweise richtig.&lt;/p&gt; ]]&gt; </text></partiallycorrectfeedback><incorrectfeedback format="html"><text>&lt;![CDATA[ &lt;p&gt;Die Antwort ist falsch.&lt;/p&gt; ]]&gt;</text></incorrectfeedback><shownumcorrect /><varsrandom><text> </text></varsrandom><varsglobal><text>n = [5, 3];
d = [9, 6];</text></varsglobal><answernumbering><text>ABCD</text></answernumbering><answers><partindex><text>0</text></partindex><placeholder><text>#A</text></placeholder><answermark><text>1</text></answermark><answertype><text>0</text></answertype><numbox><text>2</text></numbox><vars1><text>g = gcd(d[0],d[1]);
&lt;p&gt;{#A} &lt;/p&gt; ]]&gt; </text></questiontext><generalfeedback format="html"><text> </text></generalfeedback><defaultgrade>1.0000000</defaultgrade><penalty>0.3333333</penalty><hidden>0</hidden><idnumber> </idnumber><correctfeedback format="html"><text>&lt;![CDATA[ &lt;p&gt;Die Antwort ist richtig.&lt;/p&gt; ]]&gt; </text></correctfeedback><partiallycorrectfeedback format="html"><text>&lt;![CDATA[ &lt;p&gt;Die Antwort ist teilweise richtig.&lt;/p&gt; ]]&gt; </text></partiallycorrectfeedback><incorrectfeedback format="html"><text>&lt;![CDATA[ &lt;p&gt;Die Antwort ist falsch.&lt;/p&gt; ]]&gt;</text></incorrectfeedback><shownumcorrect /><varsrandom><text> </text></varsrandom><varsglobal><text>n = [8, 8];
d = [4, 10];</text></varsglobal><answernumbering><text>ABCD</text></answernumbering><answers><partindex><text>0</text></partindex><placeholder><text>#A</text></placeholder><answermark><text>1</text></answermark><answertype><text>0</text></answertype><numbox><text>2</text></numbox><vars1><text>g = gcd(d[0],d[1]);
cd = d[0]*d[1]/pow(g,2);
e = [cd / d[0], cd / d[1]];
nums = [n[0]*e[0], n[1]*e[1]];