Problem Statement
At present when a resource is bundled to an Ecml content it bundles all katex library dependencies like css,js,fonts etc.But we need katex library only when a math text or formulas are presented on the question.
So if formulas are not present katex library dependencies should be removed from the question plugins.
Proposed Solution
This solution involves following steps:
1. When saving the question data if an equation/formula is added to the question ,add a param 'isFormulaAdded' with value true to the create assessment request body as given in below example:
{"request":{"assessment_item":{"objectType":"AssessmentItem","metadata":{"code":"NA","isShuffleOption":false,"body":"{\"data\":{\"plugin\":{\"id\":\"org.ekstep.questionunit.mtf\",\"version\":\"1.1\",\"templateId\":\"horizontalMTF\"},\"data\":{\"question\":{\"text\":\"<p>gfggf <span advance=\\\"false\\\" class=\\\"math-text\\\" data-math=\\\"A=\\\\pi r^2A=\\\\pi r^2\\\" style=\\\"display: inline-block;\\\">A=\\\\\\\\pi r^2A=\\\\\\\\pi r^2</span></p>\\n\",\"image\":\"\",\"audio\":\"\",\"audioName\":\"\",\"hint\":\"\"},\"option\":{\"optionsLHS\":[{\"text\":\"<p>a</p>\\n\",\"image\":\"\",\"audio\":\"\",\"audioName\":\"\",\"hint\":\"\",\"index\":1,\"$$hashKey\":\"object:1459\"},{\"text\":\"<p>b</p>\\n\",\"image\":\"\",\"audio\":\"\",\"audioName\":\"\",\"hint\":\"\",\"index\":2,\"$$hashKey\":\"object:1460\"},{\"text\":\"<p>c</p>\\n\",\"image\":\"\",\"audio\":\"\",\"audioName\":\"\",\"hint\":\"\",\"index\":3,\"$$hashKey\":\"object:1461\"}],\"optionsRHS\":[{\"text\":\"<p>A</p>\\n\",\"image\":\"\",\"audio\":\"\",\"audioName\":\"\",\"hint\":\"\",\"mapIndex\":1},{\"text\":\"<p>B</p>\\n\",\"image\":\"\",\"audio\":\"\",\"audioName\":\"\",\"hint\":\"\",\"mapIndex\":2},{\"text\":\"<p>C</p>\\n\",\"image\":\"\",\"audio\":\"\",\"audioName\":\"\",\"hint\":\"\",\"mapIndex\":3}],\"questionCount\":0},\"media\":[]},\"config\":{\"metadata\":{\"max_score\":1,\"isShuffleOption\":false,\"isPartialScore\":true,\"evalUnordered\":false,\"templateType\":\"Horizontal\",\"name\":\"gfggf A=\\\\\\\\pi r^2A=\\\\\\\\pi r^2\\n\",\"title\":\"gfggf A=\\\\\\\\pi r^2A=\\\\\\\\pi r^2\\n\",\"board\":\"ICSE\",\"medium\":\"English\",\"subject\":\"English\",\"qlevel\":\"MEDIUM\",\"gradeLevel\":[\"Class 1\"],\"category\":\"MTF\"},\"max_time\":0,\"max_score\":1,\"partial_scoring\":true,\"layout\":\"Horizontal\",\"isShuffleOption\":false,\"questionCount\":1,\"evalUnordered\":false},\"media\":[]}}","itemType":"UNIT","version":2,"category":"MTF","createdBy":"fd7ef85c-df8f-4504-b502-47d001085e91","channel":"01231711180382208027","type":"mtf","template":"NA","template_id":"NA","framework":"NCF","max_score":1,"isPartialScore":true,"evalUnordered":false,"templateType":"Horizontal","name":"gfggf A=\\\\pi r^2A=\\\\pi r^2\n","title":"gfggf A=\\\\pi r^2A=\\\\pi r^2\n","board":"ICSE","medium":"English","subject":"English","qlevel":"MEDIUM","gradeLevel":["Class 1"],"lhs_options":[{"value":{"type":"mixed","text":"इक","image":"","count":"","audio":"","resvalue":"इक","resindex":0},"index":0}],"rhs_options":[{"value":{"type":"mixed","text":"इक","image":"","count":"","audio":"","resvalue":"इक","resindex":0},"index":0}]},"outRelations":[],"isFormulaAdded":true}}}
2. Now once question is saved ,on the renderer side while generating ECML we should check whether any of the question in the added question sets containing the flag 'isFormulaAdded' and if it is false then all the katex library dependencies should be removed from the 'questionset' plugin manifest dependencies.Hence all the katex library assets will not get bundled to the content.
3. For older questions either we should republish them or this feature will not work.
Questions/Challenges:
- To set the flag 'isFormulaAdded' to true while saving question (if formula presents) what kind of logics to be used?
- Inorder to remove katex dependencies incase of no formula how do system knows a particular dependency in a manifest is katex one?
Conclusion:
This feature will reduce the size of generated ECML content considerably for the included questions that don't have formulae in it.