|
4 | 4 | from ..evaluation import evaluation_function
|
5 | 5 | from ..preview import preview_function
|
6 | 6 |
|
| 7 | +def create_diagram_for_documentation(filename, result): |
| 8 | + for (index, graph) in enumerate(result["criteria_graphs_vis"].values()): |
| 9 | + with open(filename+"_"+str(index)+".md", "w") as f: |
| 10 | + #f.write(r'<!DOCTYPE html><html lang="en"><body><style>.mermaid {display: inline-flex;}</style>'+'\n') |
| 11 | + f.write("```mermaid\n") |
| 12 | + for g in result["criteria_graphs_vis"].values(): |
| 13 | + print(g) |
| 14 | + #f.write('<pre class="mermaid">\n'+g+'\n</pre>\n') |
| 15 | + f.write(g+"\n") |
| 16 | + #f.write('<script type="module"> import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";</script></body></html>') |
| 17 | + f.write("```\n") |
7 | 18 |
|
8 | 19 | class TestEvaluationFunction():
|
9 | 20 | """
|
@@ -143,6 +154,18 @@ def test_checking_the_value_of_a_physical_quantity(self, response, answer, respo
|
143 | 154 | assert tags == set(result["tags"])
|
144 | 155 | assert result["is_correct"] == value
|
145 | 156 |
|
| 157 | + def test_checking_the_value_of_a_physical_quantity_and_create_diagram_for_docs(self): |
| 158 | + params = { |
| 159 | + "strict_syntax": False, |
| 160 | + "elementary_functions": True, |
| 161 | + "physical_quantity": True, |
| 162 | + } |
| 163 | + response = "2.00 kilometre/hour" |
| 164 | + answer = "2.00 km/h" |
| 165 | + result = evaluation_function(response, answer, params, include_test_data=True) |
| 166 | + create_diagram_for_documentation("physical_quantity", result) |
| 167 | + assert result["is_correct"] == True |
| 168 | + |
146 | 169 | @pytest.mark.parametrize(
|
147 | 170 | "res,ans,convention,value",
|
148 | 171 | [
|
@@ -573,6 +596,13 @@ def test_custom_comparison_with_criteria_order(self, response, value, tags):
|
573 | 596 | }
|
574 | 597 | answer = "2*x^2"
|
575 | 598 | result = evaluation_function(response, answer, params, include_test_data=True)
|
| 599 | + create_diagram_for_documentation("custom_comparison_with_criteria_order", result) |
| 600 | +# with open("diagrams.html", "w") as f: |
| 601 | +# f.write(r'<!DOCTYPE html><html lang="en"><body><style>.mermaid {display: inline-flex;}</style>'+'\n') |
| 602 | +# for g in result["criteria_graphs_vis"].values(): |
| 603 | +# print(g) |
| 604 | +# f.write('<pre class="mermaid">\n'+g+'\n</pre>\n') |
| 605 | +# f.write('<script type="module"> import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs";</script></body></html>') |
576 | 606 | assert result["is_correct"] is value
|
577 | 607 | assert set(tags) == set(result["tags"])
|
578 | 608 |
|
|
0 commit comments