diff --git a/Assets/StreamingAssets/ScrollView_Server/build/API_Parsers.js b/Assets/StreamingAssets/ScrollView_Server/build/API_Parsers.js index 2c213fd65f89c95e658228b35438f6fd68bae936..8977241f1ad8fb218ce2f7bae846ef047ed74b75 100644 --- a/Assets/StreamingAssets/ScrollView_Server/build/API_Parsers.js +++ b/Assets/StreamingAssets/ScrollView_Server/build/API_Parsers.js @@ -1,51 +1,77 @@ "use strict"; // A hack to make a list of strings on type level. // If you add another type to be parsable i.e. implement a parser for it, also add its name here -const parsable = ["string", "MathMLElement", "HTMLElement", "SVGElement"]; +const primitives = ["string", "MathMLElement", "HTMLElement", "SVGElement"]; function is_primitive(a) { return "parseAs" in a - && parsable.includes(a.parseAs) + && primitives.includes(a.parseAs) && "content" in a && typeof a.content === "string"; } +const parser = new DOMParser; +// A shorthand we will need several times +function parse(s) { + const doc = parser.parseFromString(s, "text/html"); + const errorNode = doc.querySelector("parsererror"); + if (errorNode) { + console.error(errorNode); + throw {}; + } + else { + return doc.body.firstChild; + } +} +/** + * + * @param json_object + * @returns + * @throws TypeError if {@link json_object} doesn't adhere to the JSON schema + */ function backendObject_fromJSON(json_object) { - const parser = new DOMParser; - // just a shorthand we will need several times - const parse = function (s) { - const element = parser.parseFromString(s, "text/xml").childNodes[0]; - return element; - }; // the Backend_Object to be - const bo = {}; + let bo = {}; + // If the input is sensible this works, otherwise we have to throw a TypeError anyway for (let i in json_object) { const member = json_object[i]; + //console.log(member) if (is_primitive(member)) { switch (member.parseAs) { case "string": bo[i] = member.content; break; + // all other cases are identical () case "MathMLElement": - bo[i] = parse(member.content); - break; case "HTMLElement": - bo[i] = parse(member.content); - break; case "SVGElement": + //console.log(i, parse(member.content), bo) bo[i] = parse(member.content); break; } } else { - bo[i] = backendObject_fromJSON(member); + if (Array.isArray(member)) { + bo[i] = []; + member.forEach((value, index) => { + bo[i][index] = backendObject_fromJSON(value); + }); + } + else { + bo[i] = backendObject_fromJSON(member); + } } } - if (bo.label instanceof MathMLElement - && typeof bo.uri === "string" - && typeof bo.type === "string") { - return bo; + if (!("label" in bo)) { + console.error(`Attribute 'label' is missing. Cannot finish parsing`, json_object, bo); + throw new TypeError; } - else { - console.error(`This is not a Backend_Object:`, json_object); - throw new TypeError(`This is not a Backend_Object: \n ${json_object}`); + if (!("uri" in bo && typeof bo.uri === "string")) { + console.error(`Attribute 'uri': ${bo.uri} is missing or not a string. Cannot finish parsing`, json_object, bo); + throw new TypeError; + } + if (!("type" in bo && typeof bo.type === "string")) { + console.error(`Attribute 'type': ${bo.type} is missing or not a string. Cannot finish parsing`, json_object, bo); + throw new TypeError; } + // for some reason ts does not believe the conditions above + return bo; } diff --git a/Assets/StreamingAssets/ScrollView_Server/build/SetScrollContent.js b/Assets/StreamingAssets/ScrollView_Server/build/SetScrollContent.js index a07e9945fa546ba21e5a614a7823973ef59874fe..6a9d420a9f2cbaa6f9c7c8624f63e108028c7709 100644 --- a/Assets/StreamingAssets/ScrollView_Server/build/SetScrollContent.js +++ b/Assets/StreamingAssets/ScrollView_Server/build/SetScrollContent.js @@ -9,9 +9,15 @@ function RenderScroll() { return; } const scroll_json = JSON.parse(dataSource.dataset.scrollDynamic); - const scroll = backendObject_fromJSON(scroll_json); - if (!isScroll(scroll)) { - console.error("The Scroll in the Unity-Data-Interface cannot be parsed"); + let scroll; + try { + scroll = backendObject_fromJSON(scroll_json); + if (!Scroll.isScroll(scroll)) { + throw {}; + } + } + catch (error) { + console.error(error, `Cannot parse the scroll:`, scroll_json); return; } //console.log(scroll.requiredFacts); diff --git a/Assets/StreamingAssets/ScrollView_Server/scrollView.html b/Assets/StreamingAssets/ScrollView_Server/scrollView.html index 8e6eaea48847fb2d3b0e22ad91d3ac3f72d1040e..8eec2e1e92c736717f48d44afb15758bd97af476 100644 --- a/Assets/StreamingAssets/ScrollView_Server/scrollView.html +++ b/Assets/StreamingAssets/ScrollView_Server/scrollView.html @@ -9,7 +9,7 @@ [data-allowed-types="PointFact"] * { color: #0000ff } - + [data-allowed-types="LineFact"] * { color: #008000 } @@ -86,10 +86,10 @@ <mi>tan</mi> <!--<mo>⁡</mo>--> <mo>(</mo> - <slot data-slot-id="http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB"/> + <slot data-slot-id="http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" /> <mo>)</mo> - <mo>×</mo> - <slot data-slot-id="http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC"/> + <mo>×</mo> + <slot data-slot-id="http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" /> </mrow> </math>. </div> @@ -123,19 +123,19 @@ </foreignObject> <foreignObject id='pointB' x='30' y='225' width="50" height="25"> <math xmlns="http://www.w3.org/1998/Math/MathML" - data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB' /> + data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB' /> </foreignObject> <foreignObject id='pointB' x='145' y='225' width="50" height="25"> <math xmlns="http://www.w3.org/1998/Math/MathML" - data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC' /> + data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC' /> </foreignObject> <foreignObject id='pointB' x='100' y='250' width="50" height="25"> <math xmlns="http://www.w3.org/1998/Math/MathML" - data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC' /> + data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC' /> </foreignObject> <foreignObject id='pointB' x='205' y='120' width="50" height="25"> <math xmlns="http://www.w3.org/1998/Math/MathML" style='color:#008000' - data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA' /> + data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA' /> </foreignObject> </g> </svg> @@ -161,6 +161,7 @@ } loadScript("./build/Drop_facts.js") + loadScript("./build/Types.js") loadScript("./build/API_Parsers.js") loadScript("./build/SetScrollContent.js") //loadScript("./scroll_interaction/webgl-demo.js") @@ -170,338 +171,464 @@ <data id="Unity-Data-Interface" hidden data-assignments='{"http://mathhub.info/FrameIT/frameworld?TriangleProblem?A":{"Item1":"(C)","Item2":"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact310"},"http://mathhub.info/FrameIT/frameworld?TriangleProblem?B":{"Item1":"(B)","Item2":"http://mathhub.info/FrameIT/frameworld?DefaultSituationSpace/SituationTheory1?fact309"},"http://mathhub.info/FrameIT/frameworld?TriangleProblem?C":{"Item1":"C","Item2":""},"http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC":{"Item1":"⊾C","Item2":""},"http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC":{"Item1":"BC","Item2":""},"http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB":{"Item1":"∠ABC","Item2":""},"http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA":{"Item1":"CA","Item2":""}}' data-scroll-dynamic='{ - "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen", - "label": "<mtext>OppositeLen</mtext>", + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?OppositeLen" + }, + "label": { + "parseAs": "MathMLElement", + "content": "<ms>OppositeLen</ms>" + }, + "type": { + "parseAs": "string", + "content": "Scroll" + }, "slots": [ { - "tp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?3DGeometry?point" + "label": { + "parseAs": "MathMLElement", + "content": "<mi>A</mi>" }, - "df": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" }, - "kind": "general", - "label": "A" + "type": { + "parseAs": "string", + "content": "Point_Fact" + } }, { - "tp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?3DGeometry?point" + "label": { + "parseAs": "MathMLElement", + "content": "<mi>B</mi>" }, - "df": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" }, - "kind": "general", - "label": "B" + "type": { + "parseAs": "string", + "content": "Point_Fact" + } }, { - "tp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?3DGeometry?point" + "label": { + "parseAs": "MathMLElement", + "content": "<mi>C</mi>" }, - "df": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" }, - "kind": "general", - "label": "C" + "type": { + "parseAs": "string", + "content": "Point_Fact" + } }, { - "tp": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?Logic?ded" - }, - "arguments": [ - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?Logic?eq" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" - }, - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?angle_between" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" - } - ] - }, - { - "kind": "OMLIT<Double>", - "type": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit", - "value": 90.0 - } - ] - } - ] + "label": { + "parseAs": "MathMLElement", + "content": "<mi><mrow><mo>⦝</mo><mi>C</mi></mrow></mi>" }, - "df": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC" + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC" }, - "kind": "general", - "label": "⊾C" + "type": { + "parseAs": "string", + "content": "Angle_Fact" + } }, { - "lhs": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?metric" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" - } - ] - }, - "valueTp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" + "label": { + "parseAs": "MathMLElement", + "content": "<mi><mrow><mi>B</mi><mi>C</mi></mrow></mi>" }, - "value": null, - "proof": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" }, - "kind": "veq", - "label": "BC" + "type": { + "parseAs": "string", + "content": "LineSegment_Fact" + } }, { - "lhs": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?angle_between" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" - } - ] + "label": { + "parseAs": "MathMLElement", + "content": "<mi><mrow><mo>∠</mo><mi>A</mi><mi>B</mi><mi>C</mi></mrow></mi>" }, - "valueTp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" - }, - "value": null, - "proof": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" }, - "kind": "veq", - "label": "∠ABC" + "type": { + "parseAs": "string", + "content": "Angle_Fact" + } } ], "acquiredFacts": [ { - "lhs": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?metric" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" - } - ] + "label": { + "parseAs": "MathMLElement", + "content": "<mi><mrow><mi>C</mi><mi>A</mi></mrow></mi>" }, - "valueTp": { + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA" + }, + "type": { + "parseAs": "string", + "content": "LineSegment_Fact" + } + } + ], + "description": { + "parseAs": "HTMLElement", + "content": "<scroll-description title='OppositeLenScroll' alt='Given a triangle △ABC right-angled at ⊾C, the opposite side has length CA = tan(∠ABC) ⋅ BC.'> <span>Given a triangle</span> <math> <mi>△<!-- △ --></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?A'></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?B'></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?C'></mi> </math> <span>right-angled at</span> <math> <!--<mi>⦝</mi>--><!-- ⦝ --> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC'></mi> </math>,<br /> <span>the opposite side has length</span> <math> <mi data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA'></mi> <mo>=</mo> <mrow> <mi>tan</mi> <!--<mo>⁡</mo>--> <mo>(</mo> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB'></mi> <mo>)</mo> </mrow> <mo>⁢</mo> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC'></mi> </math> <span>.</span> </scroll-description>" + }, + "depiction": { + "parseAs": "HTMLElement", + "content": "<svg width='8cm'height='8cmm'viewBox='-25-25300300'version='1.1'id='triangle'xmlns='http://www.w3.org/2000/svg'xmlns:svg='http://www.w3.org/2000/svg'><g id='shape'style='fill:none;stroke:#000000;stroke-linecap:butt;stroke-width:1;stroke-linejoin:miter;stroke-opacity:1'><path d='M0,250H200V0Z'id='triangle'/><path id='angleABC'd='M0,250l15.6,-19.5a25250019.4,19.5z'/><!--M[corner]l[25*cos()],[-25*sin()]a2525001[25-25*cos()],[25*sin()]--><g id='angleBCA'><path id='rightAngle'd='M200,250v-25a25,25000-25,25z'/><circle style='fill:#000000;fill-opacity:1;stroke:none'id='rightAngleDot'cx='190'cy='240'r='1.5'/><!--Corner-(40,40);40=15/sqrt(2)+epsilon--></g></g><g id='labels'style='line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;'><foreignObject id='pointB'x='200'y='-25'width='25'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?A'/></div></foreignObject><foreignObject id='pointB'x='-25'y='250'width='25'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?B'/></div></foreignObject><foreignObject id='pointB'x='200'y='250'width='25'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?C'/></div></foreignObject><foreignObject id='pointB'x='30'y='225'width='50'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB'/></div></foreignObject><foreignObject id='pointB'x='145'y='225'width='50'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC'/></div></foreignObject><foreignObject id='pointB'x='100'y='250'width='50'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC'/></div></foreignObject><foreignObject id='pointB'x='205'y='120'width='50'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'style='color:#008000'data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA'/></div></foreignObject></g></svg>" + } + }'> + </data> + <data id="Scroll-Dynamic-Old" hidden data-scroll-dynamic='{ + "ref": "http://mathhub.info/FrameIT/frameworld?OppositeLen", + "label": "OppositeLen", + "description": "<scroll-description title='OppositeLenScroll' alt='Given a triangle △ABC right-angled at ⊾C, the opposite side has length CA = tan(∠ABC) ⋅ BC.'> <span>Given a triangle</span> <math> <mi>△<!-- △ --></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?A'></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?B'></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?C'></mi> </math> <span>right-angled at</span> <math> <!--<mi>⦝</mi>--><!-- ⦝ --> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC'></mi> </math>,<br /> <span>the opposite side has length</span> <math> <mi data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA'></mi> <mo>=</mo> <mrow> <mi>tan</mi> <!--<mo>⁡</mo>--> <mo>(</mo> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB'></mi> <mo>)</mo> </mrow> <mo>⁢</mo> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC'></mi> </math> <span>.</span> <div> <svg width='50mm' height='45mm' viewBox='35 0 90 70' version='1.1' id='triangle' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'> <g id='shape'> <path style='fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' d='M 42.871972,64.67128 H 84.290656 V 7.6297578 Z' id='triangle' /> <path id='angleABC' style='fill:none;stroke:#000000;stroke-width:0.265;stroke-dasharray:none;stroke-opacity:1' d='m 46.024276,60.304806 a 5.3589964,5.3589964 0 0 1 2.252109,4.366474 h -5.358996 z' /> <g id='angleBCA'> <path style='fill:none;stroke:#000000;stroke-width:0.264999;stroke-dasharray:none;stroke-opacity:1' id='rightAngle' d='m 78.972396,64.665062 a 5.3308268,5.3308268 0 0 1 5.330827,-5.330827 v 5.330827 z' /> <circle style='fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264999;stroke-dasharray:none;stroke-opacity:1' id='rightAngleDot' cx='82.081886' cy='62.813831' r='0.32113415' /> </g> </g> <g id='labels' style='font-size:4.23333px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;stroke-width:0.264583' > <text xml:space='preserve' x='39.242592' y='67.117035' id='pointB' style='fill:#0000ff' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?B'>B</text> <text xml:space='preserve' x='85.100548' y='68.080437' id='pointC' style='fill:#0000ff' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?C'>C</text> <text xml:space='preserve' x='84.650963' y='6.551136' id='pointA' style='fill:#0000ff' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?A'>A</text> <text xml:space='preserve' x='48.234348' y='62.492699' id='angleAtB' style='fill:#ffcc00' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB'>∠ABC</text> <text xml:space='preserve' x='71.548683' y='60.951256' id='rightAngleAtC' style='fill:#ffcc00' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC'>⊾C</text> <text xml:space='preserve' x='59.409813' y='68.273117' id='distanceBC' style='fill:#008000' data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC'>BC</text> <text xml:space='preserve' x='84.972092' y='35.260529' id='solutionCA' style='fill:#008000' data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA'>CA</text> </g> </svg> </div> </scroll-description>", + "requiredFacts": [ + { + "tp": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/core/geometry?3DGeometry?point" + }, + "df": null, + "ref": { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" + }, + "kind": "general", + "label": "A" + }, + { + "tp": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/core/geometry?3DGeometry?point" + }, + "df": null, + "ref": { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" + }, + "kind": "general", + "label": "B" + }, + { + "tp": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/core/geometry?3DGeometry?point" + }, + "df": null, + "ref": { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" + }, + "kind": "general", + "label": "C" + }, + { + "tp": { + "kind": "OMA", + "applicant": { "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" + "uri": "http://mathhub.info/MitM/Foundation?Logic?ded" }, - "value": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/arithmetics?RealArithmetics?multiplication" - }, - "arguments": [ - { - "kind": "OMA", - "applicant": { + "arguments": [ + { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/Foundation?Logic?eq" + }, + "arguments": [ + { "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?Trigonometry?tan" + "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" }, - "arguments": [ - { - "kind": "OMA", - "applicant": { + { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?angle_between" + }, + "arguments": [ + { "kind": "OMS", - "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" - } - ] - } - ] - }, - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" + }, + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" + } + ] }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" - } - ] - } - ] + { + "kind": "OMLIT<Double>", + "type": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit", + "value": 90.0 + } + ] + } + ] + }, + "df": null, + "ref": { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC" + }, + "kind": "general", + "label": "⊾C" + }, + { + "lhs": { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?metric" + }, + "arguments": [ + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" + }, + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" + } + ] + }, + "valueTp": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" + }, + "value": null, + "proof": null, + "ref": { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" + }, + "kind": "veq", + "label": "BC" + }, + { + "lhs": { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?angle_between" + }, + "arguments": [ + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" + }, + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" + }, + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" + } + ] + }, + "valueTp": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" + }, + "value": null, + "proof": null, + "ref": { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" + }, + "kind": "veq", + "label": "∠ABC" + } + ], + "acquiredFacts": [ + { + "lhs": { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?metric" }, - "proof": { - "kind": "OMA", - "applicant": { + "arguments": [ + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" + }, + { "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?InformalProofs?proofsketch" + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" + } + ] + }, + "valueTp": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" + }, + "value": { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/core/arithmetics?RealArithmetics?multiplication" + }, + "arguments": [ + { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/Foundation?Trigonometry?tan" + }, + "arguments": [ + { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" + }, + "arguments": [ + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" + } + ] + } + ] }, - "arguments": [ - { - "kind": "OMA", - "applicant": { + { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" + }, + "arguments": [ + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" + } + ] + } + ] + }, + "proof": { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/Foundation?InformalProofs?proofsketch" + }, + "arguments": [ + { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/Foundation?Logic?eq" + }, + "arguments": [ + { "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?Logic?eq" + "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" }, - "arguments": [ - { + { + "kind": "OMA", + "applicant": { "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" + "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?metric" }, - { - "kind": "OMA", - "applicant": { + "arguments": [ + { "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?metric" + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" }, - "arguments": [ - { + { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" + } + ] + }, + { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://mathhub.info/MitM/core/arithmetics?RealArithmetics?multiplication" + }, + "arguments": [ + { + "kind": "OMA", + "applicant": { "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" + "uri": "http://mathhub.info/MitM/Foundation?Trigonometry?tan" }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" - } - ] - }, - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/arithmetics?RealArithmetics?multiplication" - }, - "arguments": [ - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?Trigonometry?tan" - }, - "arguments": [ - { - "kind": "OMA", - "applicant": { + "arguments": [ + { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" + }, + "arguments": [ + { "kind": "OMS", - "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" - } - ] - } - ] + "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" + } + ] + } + ] + }, + { + "kind": "OMA", + "applicant": { + "kind": "OMS", + "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" }, - { - "kind": "OMA", - "applicant": { + "arguments": [ + { "kind": "OMS", - "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" - } - ] - } - ] - } - ] - }, - { - "kind": "OMLIT<String>", - "type": "http://cds.omdoc.org/urtheories?Strings?string", - "value": "OppositeLen Scroll" - } - ] - }, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA" - }, - "kind": "veq", - "label": "CA" - } - ], - "description": "<scroll-description title='OppositeLenScroll' alt='Given a triangle △ABC right-angled at ⊾C, the opposite side has length CA = tan(∠ABC) ⋅ BC.'> <span>Given a triangle</span> <math> <mi>△<!-- △ --></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?A'></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?B'></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?C'></mi> </math> <span>right-angled at</span> <math> <!--<mi>⦝</mi>--><!-- ⦝ --> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC'></mi> </math>,<br /> <span>the opposite side has length</span> <math> <mi data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA'></mi> <mo>=</mo> <mrow> <mi>tan</mi> <!--<mo>⁡</mo>--> <mo>(</mo> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB'></mi> <mo>)</mo> </mrow> <mo>⁢</mo> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC'></mi> </math> <span>.</span> </scroll-description>", - "depiction": "<div> <svg width='50mm' height='45mm' viewBox='35 0 90 70' version='1.1' id='triangle' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'> <g id='shape'> <path style='fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' d='M 42.871972,64.67128 H 84.290656 V 7.6297578 Z' id='triangle' /> <path id='angleABC' style='fill:none;stroke:#000000;stroke-width:0.265;stroke-dasharray:none;stroke-opacity:1' d='m 46.024276,60.304806 a 5.3589964,5.3589964 0 0 1 2.252109,4.366474 h -5.358996 z' /> <g id='angleBCA'> <path style='fill:none;stroke:#000000;stroke-width:0.264999;stroke-dasharray:none;stroke-opacity:1' id='rightAngle' d='m 78.972396,64.665062 a 5.3308268,5.3308268 0 0 1 5.330827,-5.330827 v 5.330827 z' /> <circle style='fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264999;stroke-dasharray:none;stroke-opacity:1' id='rightAngleDot' cx='82.081886' cy='62.813831' r='0.32113415' /> </g> </g> <g id='labels' style='font-size:4.23333px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;stroke-width:0.264583' > <text xml:space='preserve' x='39.242592' y='67.117035' id='pointB' style='fill:#0000ff' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?B'>B</text> <text xml:space='preserve' x='85.100548' y='68.080437' id='pointC' style='fill:#0000ff' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?C'>C</text> <text xml:space='preserve' x='84.650963' y='6.551136' id='pointA' style='fill:#0000ff' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?A'>A</text> <text xml:space='preserve' x='48.234348' y='62.492699' id='angleAtB' style='fill:#ffcc00' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB'>∠ABC</text> <text xml:space='preserve' x='71.548683' y='60.951256' id='rightAngleAtC' style='fill:#ffcc00' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC'>⊾C</text> <text xml:space='preserve' x='59.409813' y='68.273117' id='distanceBC' style='fill:#008000' data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC'>BC</text> <text xml:space='preserve' x='84.972092' y='35.260529' id='solutionCA' style='fill:#008000' data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA'>CA</text> </g> </svg> </div>" - }'>hi</data> + "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" + } + ] + } + ] + } + ] + }, + { + "kind": "OMLIT<String>", + "type": "http://cds.omdoc.org/urtheories?Strings?string", + "value": "OppositeLen Scroll" + } + ] + }, + "ref": { + "kind": "OMS", + "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA" + }, + "kind": "veq", + "label": "CA" + } + ], + "name": "http://mathhub.info/FrameIT/frameworld?OppositeLen", + "path": null + }'> </data> <!--<script src="visualiseCursor.mjs" defer type="module"></script>--> <!--<script> diff --git a/Assets/StreamingAssets/ScrollView_Server/src/API_Parsers.ts b/Assets/StreamingAssets/ScrollView_Server/src/API_Parsers.ts index 5d7f39fa9c3beb9e176bd7e0bb6bbfc053a42e6e..b5f3230b5c3ac8153bacbc36d62995d984ce48bd 100644 --- a/Assets/StreamingAssets/ScrollView_Server/src/API_Parsers.ts +++ b/Assets/StreamingAssets/ScrollView_Server/src/API_Parsers.ts @@ -1,58 +1,93 @@ // A hack to make a list of strings on type level. // If you add another type to be parsable i.e. implement a parser for it, also add its name here -const parsable = ["string", "MathMLElement", "HTMLElement", "SVGElement"] as const +const primitives = ["string", "MathMLElement", "HTMLElement", "SVGElement"] as const type Primitive = string | MathMLElement | HTMLElement | SVGElement -type Parsable_Primitive = { parseAs: typeof parsable[number], content: string }; +type Parsable_Primitive = { parseAs: typeof primitives[number], content: string }; function is_primitive(a: any): a is Parsable_Primitive { - return "parseAs" in a - && parsable.includes(a.parseAs) + return "parseAs" in a + && primitives.includes(a.parseAs) && "content" in a && typeof a.content === "string" } -type Parsable_BO = {[key: string]: Parsable_Primitive | Parsable_BO}; +// type Typed_JSONObject = { [data: string]: Primitive | Backend_Object } -function backendObject_fromJSON(json_object: Parsable_BO): Backend_Object { - const parser = new DOMParser; - // just a shorthand we will need several times - const parse = function <E extends Element>(s: string): E { - const element = parser.parseFromString(s, "text/xml").childNodes[0] - return element as E + +// declare var Generic_BackendObject: { +// label: MathMLElement +// uri: string +// type: string +// [data: string]: any +// prototype: Backend_Object; +// }; + + +type Parsable_BO = { [key: string]: Parsable_Primitive | Parsable_BO | [Parsable_BO] }; + +const parser = new DOMParser; +// A shorthand we will need several times +function parse (s: string): Primitive { + const doc = parser.parseFromString(s, "text/html") + const errorNode = doc.querySelector("parsererror"); + if (errorNode) { + console.error(errorNode) + throw{} + } else { + return doc.body.firstChild as Primitive } +} +/** + * + * @param json_object + * @returns + * @throws TypeError if {@link json_object} doesn't adhere to the JSON schema + */ +function backendObject_fromJSON(json_object: Parsable_BO): Backend_Object { // the Backend_Object to be - const bo: { - [key: keyof typeof json_object]: Primitive | Backend_Object - } = { } + let bo: {[data:string]: any} = {} + + // If the input is sensible this works, otherwise we have to throw a TypeError anyway for (let i in json_object) { const member = json_object[i] + //console.log(member) if (is_primitive(member)) { switch (member.parseAs) { case "string": bo[i] = member.content break; + // all other cases are identical () case "MathMLElement": - bo[i] = parse<MathMLElement>(member.content) - break; case "HTMLElement": - bo[i] = parse<HTMLElement>(member.content) - break; case "SVGElement": - bo[i] = parse<SVGElement>(member.content) + //console.log(i, parse(member.content), bo) + bo[i] = parse(member.content) break; } } else { - bo[i] = backendObject_fromJSON(member) + if (Array.isArray(member)) { + bo[i] = [] + member.forEach((value, index) => { + bo[i][index] = backendObject_fromJSON(value) + }) + } + else { bo[i] = backendObject_fromJSON(member) } } } - if (bo.label instanceof MathMLElement - && typeof bo.uri === "string" - && typeof bo.type === "string") { - return bo as unknown as Backend_Object + if (!("label" in bo)) { + console.error(`Attribute 'label' is missing. Cannot finish parsing`, json_object, bo) + throw new TypeError + } + if (!("uri" in bo && typeof bo.uri === "string")) { + console.error(`Attribute 'uri': ${bo.uri} is missing or not a string. Cannot finish parsing`, json_object, bo) + throw new TypeError } - else { - console.error(`This is not a Backend_Object:`, json_object) - throw new TypeError(`This is not a Backend_Object: \n ${json_object}`) + if (!("type" in bo && typeof bo.type === "string")) { + console.error(`Attribute 'type': ${bo.type} is missing or not a string. Cannot finish parsing`, json_object, bo) + throw new TypeError } + // for some reason ts does not believe the conditions above + return bo as unknown as Backend_Object + } \ No newline at end of file diff --git a/Assets/StreamingAssets/ScrollView_Server/src/SetScrollContent.ts b/Assets/StreamingAssets/ScrollView_Server/src/SetScrollContent.ts index cd913a59b4fbb0a6bda8d8b08baa99b14b8774a3..99cb43a155107f04dbf058ff450a60ee5e11822d 100644 --- a/Assets/StreamingAssets/ScrollView_Server/src/SetScrollContent.ts +++ b/Assets/StreamingAssets/ScrollView_Server/src/SetScrollContent.ts @@ -10,9 +10,12 @@ function RenderScroll() { return } const scroll_json = JSON.parse(dataSource.dataset.scrollDynamic); - const scroll = backendObject_fromJSON(scroll_json) - if (!isScroll(scroll)) { - console.error("The Scroll in the Unity-Data-Interface cannot be parsed") + let scroll: Backend_Object + try { + scroll = backendObject_fromJSON(scroll_json) + if (!Scroll.isScroll(scroll)) {throw {} } + } catch (error) { + console.error(error, `Cannot parse the scroll:`, scroll_json) return } //console.log(scroll.requiredFacts); diff --git a/Assets/StreamingAssets/ScrollView_Server/tmp.json b/Assets/StreamingAssets/ScrollView_Server/tmp.json index da1a3d86f2b3d26f27091af559533fbc310e095f..99456cb471f06808826c59fcf84fd6ebf2916a2b 100644 --- a/Assets/StreamingAssets/ScrollView_Server/tmp.json +++ b/Assets/StreamingAssets/ScrollView_Server/tmp.json @@ -1,334 +1,124 @@ { - "ref": "http://mathhub.info/FrameIT/frameworld?OppositeLen", - "label": "OppositeLen", - "description": "<scroll-description title='OppositeLenScroll' alt='Given a triangle △ABC right-angled at ⊾C, the opposite side has length CA = tan(∠ABC) ⋅ BC.'> <span>Given a triangle</span> <math> <mi>△<!-- △ --></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?A'></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?B'></mi> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?C'></mi> </math> <span>right-angled at</span> <math> <!--<mi>⦝</mi>--><!-- ⦝ --> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC'></mi> </math>,<br /> <span>the opposite side has length</span> <math> <mi data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA'></mi> <mo>=</mo> <mrow> <mi>tan</mi> <!--<mo>⁡</mo>--> <mo>(</mo> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB'></mi> <mo>)</mo> </mrow> <mo>⁢</mo> <mi data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC'></mi> </math> <span>.</span> <div> <svg width='50mm' height='45mm' viewBox='35 0 90 70' version='1.1' id='triangle' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'> <g id='shape'> <path style='fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1' d='M 42.871972,64.67128 H 84.290656 V 7.6297578 Z' id='triangle' /> <path id='angleABC' style='fill:none;stroke:#000000;stroke-width:0.265;stroke-dasharray:none;stroke-opacity:1' d='m 46.024276,60.304806 a 5.3589964,5.3589964 0 0 1 2.252109,4.366474 h -5.358996 z' /> <g id='angleBCA'> <path style='fill:none;stroke:#000000;stroke-width:0.264999;stroke-dasharray:none;stroke-opacity:1' id='rightAngle' d='m 78.972396,64.665062 a 5.3308268,5.3308268 0 0 1 5.330827,-5.330827 v 5.330827 z' /> <circle style='fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264999;stroke-dasharray:none;stroke-opacity:1' id='rightAngleDot' cx='82.081886' cy='62.813831' r='0.32113415' /> </g> </g> <g id='labels' style='font-size:4.23333px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;stroke-width:0.264583' > <text xml:space='preserve' x='39.242592' y='67.117035' id='pointB' style='fill:#0000ff' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?B'>B</text> <text xml:space='preserve' x='85.100548' y='68.080437' id='pointC' style='fill:#0000ff' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?C'>C</text> <text xml:space='preserve' x='84.650963' y='6.551136' id='pointA' style='fill:#0000ff' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?A'>A</text> <text xml:space='preserve' x='48.234348' y='62.492699' id='angleAtB' style='fill:#ffcc00' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB'>∠ABC</text> <text xml:space='preserve' x='71.548683' y='60.951256' id='rightAngleAtC' style='fill:#ffcc00' data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC'>⊾C</text> <text xml:space='preserve' x='59.409813' y='68.273117' id='distanceBC' style='fill:#008000' data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC'>BC</text> <text xml:space='preserve' x='84.972092' y='35.260529' id='solutionCA' style='fill:#008000' data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA'>CA</text> </g> </svg> </div> </scroll-description>", - "requiredFacts": [ + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?OppositeLen" + }, + "label": { + "parseAs": "MathMLElement", + "content": "<mtext>OppositeLen</mtext>" + }, + "type": { + "parseAs": "string", + "content": "Scroll" + }, + "slots": [ { - "tp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?3DGeometry?point" - }, - "df": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" - }, - "kind": "general", - "label": "A" + "label": { + "parseAs": "MathMLElement", + "content": "<mi>A</mi>" + }, + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" + }, + "type": { + "parseAs": "string", + "content": "Point_Fact" + } }, { - "tp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?3DGeometry?point" - }, - "df": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" - }, - "kind": "general", - "label": "B" + "label": { + "parseAs": "MathMLElement", + "content": "<mi>B</mi>" + }, + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" + }, + "type": { + "parseAs": "string", + "content": "Point_Fact" + } }, { - "tp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?3DGeometry?point" - }, - "df": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" - }, - "kind": "general", - "label": "C" + "label": { + "parseAs": "MathMLElement", + "content": "<mi>C</mi>" + }, + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" + }, + "type": { + "parseAs": "string", + "content": "Point_Fact" + } }, { - "tp": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?Logic?ded" - }, - "arguments": [ - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?Logic?eq" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" - }, - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?angle_between" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" - } - ] - }, - { - "kind": "OMLIT<Double>", - "type": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit", - "value": 90.0 - } - ] - } - ] - }, - "df": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC" - }, - "kind": "general", - "label": "⊾C" + "label": { + "parseAs": "MathMLElement", + "content": "<mi><mrow><mo>⦝</mo><mi>C</mi></mrow></mi>" + }, + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC" + }, + "type": { + "parseAs": "string", + "content": "Angle_Fact" + } }, { - "lhs": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?metric" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" - } - ] - }, - "valueTp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" - }, - "value": null, - "proof": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" - }, - "kind": "veq", - "label": "BC" + "label": { + "parseAs": "MathMLElement", + "content": "<mi><mrow><mi>B</mi><mi>C</mi></mrow></mi>" + }, + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" + }, + "type": { + "parseAs": "string", + "content": "LineSegment_Fact" + } }, { - "lhs": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?angle_between" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?B" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" - } - ] - }, - "valueTp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" - }, - "value": null, - "proof": null, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" - }, - "kind": "veq", - "label": "∠ABC" + "label": { + "parseAs": "MathMLElement", + "content": "<mi><mrow><mo>∠</mo><mi>A</mi><mi>B</mi><mi>C</mi></mrow></mi>" + }, + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" + }, + "type": { + "parseAs": "string", + "content": "Angle_Fact" + } } ], "acquiredFacts": [ { - "lhs": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?metric" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" - } - ] - }, - "valueTp": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" - }, - "value": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/arithmetics?RealArithmetics?multiplication" - }, - "arguments": [ - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?Trigonometry?tan" - }, - "arguments": [ - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" - } - ] - } - ] - }, - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" - } - ] - } - ] - }, - "proof": { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?InformalProofs?proofsketch" - }, - "arguments": [ - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?Logic?eq" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?RealLiterals?real_lit" - }, - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/geometry?Geometry/Common?metric" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?C" - }, - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem?A" - } - ] - }, - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/core/arithmetics?RealArithmetics?multiplication" - }, - "arguments": [ - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://mathhub.info/MitM/Foundation?Trigonometry?tan" - }, - "arguments": [ - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB" - } - ] - } - ] - }, - { - "kind": "OMA", - "applicant": { - "kind": "OMS", - "uri": "http://gl.mathhub.info/MMT/LFX/Sigma?Symbols?Projl" - }, - "arguments": [ - { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC" - } - ] - } - ] - } - ] - }, - { - "kind": "OMLIT<String>", - "type": "http://cds.omdoc.org/urtheories?Strings?string", - "value": "OppositeLen Scroll" - } - ] - }, - "ref": { - "kind": "OMS", - "uri": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA" - }, - "kind": "veq", - "label": "CA" + "label": { + "parseAs": "MathMLElement", + "content": "<mi><mrow><mi>C</mi><mi>A</mi></mrow></mi>" + }, + "uri": { + "parseAs": "string", + "content": "http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA" + }, + "type": { + "parseAs": "string", + "content": "LineSegment_Fact" + } } ], - "name": "http://mathhub.info/FrameIT/frameworld?OppositeLen", - "path": null + "description": { + "parseAs": "HTMLElement", + "content": "<scroll-descriptiontitle='OppositeLenScroll'alt='Givenatriangle△ABCright-angledat⊾C,theoppositesidehaslengthCA=tan(∠ABC)⋅BC.'><span>Givenatriangle</span><math><mi>△<!--△--></mi><midata-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?A'></mi><midata-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?B'></mi><midata-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?C'></mi></math><span>right-angledat</span><math><!--<mi>⦝</mi>--><!--⦝--><midata-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC'></mi></math>,<br/><span>theoppositesidehaslength</span><math><midata-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA'></mi><mo>=</mo><mrow><mi>tan</mi><!--<mo>⁡</mo>--><mo>(</mo><midata-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB'></mi><mo>)</mo></mrow><mo>⁢</mo><midata-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC'></mi></math><span>.</span></scroll-description" + }, + "depiction": { + "parseAs": "HTMLElement", + "content": "<svg width='8cm'height='8cmm'viewBox='-25-25300300'version='1.1'id='triangle'xmlns='http://www.w3.org/2000/svg'xmlns:svg='http://www.w3.org/2000/svg'><g id='shape'style='fill:none;stroke:#000000;stroke-linecap:butt;stroke-width:1;stroke-linejoin:miter;stroke-opacity:1'><path d='M0,250H200V0Z'id='triangle'/><path id='angleABC'd='M0,250l15.6,-19.5a25250019.4,19.5z'/><!--M[corner]l[25*cos()],[-25*sin()]a2525001[25-25*cos()],[25*sin()]--><g id='angleBCA'><path id='rightAngle'd='M200,250v-25a25,25000-25,25z'/><circle style='fill:#000000;fill-opacity:1;stroke:none'id='rightAngleDot'cx='190'cy='240'r='1.5'/><!--Corner-(40,40);40=15/sqrt(2)+epsilon--></g></g><g id='labels'style='line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;'><foreignObject id='pointB'x='200'y='-25'width='25'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?A'/></div></foreignObject><foreignObject id='pointB'x='-25'y='250'width='25'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?B'/></div></foreignObject><foreignObject id='pointB'x='200'y='250'width='25'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem?C'/></div></foreignObject><foreignObject id='pointB'x='30'y='225'width='50'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_AngleAtB?angleB'/></div></foreignObject><foreignObject id='pointB'x='145'y='225'width='50'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?TriangleProblem_RightAngleAtC?rightAngleC'/></div></foreignObject><foreignObject id='pointB'x='100'y='250'width='50'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'data-slot-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Problem?distanceBC'/></div></foreignObject><foreignObject id='pointB'x='205'y='120'width='50'height='25'><div><math xmlns='http://www.w3.org/1998/Math/MathML'style='color:#008000'data-solution-id='http://mathhub.info/FrameIT/frameworld?OppositeLen/Solution?deducedLineCA'/></div></foreignObject></g></svg>" + } } \ No newline at end of file