JSXGraph:带有Moodle的多个板和堆栈

发布于 2025-02-07 07:52:11 字数 633 浏览 3 评论 0原文

有时能够控制html页面上多个jsxgraph板的放置很方便,例如 https://jsxgraph.org/wiki/index.php?title=sine

我知道,如下所述,有可能在Moodle中包含多个板子的问题: https://github.com/jsxgraph/moodleforpaph/moodleformulas_jsxgraph/blob/blob/master/master/readmaster/readmec.md#insert-more-more-than-than-one-one-board -Into-a-question

我的问题是:是否有可能在公式问题中控制董事会的位置?和/或在堆栈问题中可以吗? - 谢谢!

Sometimes it is handy to be able to control the placement of multiple JSXGraph boards on the html page, like on https://jsxgraph.org/wiki/index.php?title=Sine.

I know that it is possible to include more than one board in a Formulas question in Moodle, as described here: https://github.com/jsxgraph/moodleformulas_jsxgraph/blob/master/README.md#insert-more-than-one-board-into-a-question

My question is: Is it possible to gain control over the placement of boards in a Formulas question? And/or is that possible in a STACK question? – Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

豆芽 2025-02-14 07:52:11

使用Stack,可以将多个板包含在一个问题中。对于每个JSXGraph块,Stack生成一个DIV,该DIV带有Divid变量中的ID。然后,董事会的DIVS替换问题文本中的JSXGraph块。

董事会交互

如果您希望板相互交互,则需要在单个JSXGRAPH块中编写板的JavaScript代码(封装了一个块中的JavaScript代码)。为此,您应该首先在问题文本中放置一个空的JSXGraph块,该块将生成第一个Div,该DIV具有“ stack-jsxgraph-1”的ID。然后,您添加了第二个块,其中将两个板的代码放入其中。由于基本上只是计数一个数字,因此您可以在JavaScript中使用正则表达式访问第一个板的Divid。

为了控制放置位置,您可以使用一些CSS和HTML 例如,您可以将两个JSXGraph块包裹在DIV中,并使此Div用显示:Flex。然后,两个板将水平对齐。您也可以使用网格布局。

示例代码

问题文本的代码可能看起来像:

<!-- Wrapper div flexbox -->
<div style="display: flex;">
<!-- Empty JSXGraph block for the first board-->
[[ jsxgraph width="200px" height="200px"]] [[/ jsxgraph ]]

<!-- JSXGraph block for the second board-->
[[ jsxgraph width="200px" height="200px"]]
/* divid variables */
const divid1 = divid.replace(/[0-9]+/g,divid.match(/[0-9]+/g)-1)
const divid2 = divid;
console.log(divid1, divid2);
/* init boards */
const board1 = JXG.JSXGraph.initBoard(divid1,{ boundingbox: [-5, 5, 5, -5], axis: true });
const board2 = JXG.JSXGraph.initBoard(divid2,{ boundingbox: [-5, 5, 5, -5], axis: true });
[[/ jsxgraph ]]
</div>

堆栈问题然后显示两个董事会:
带有两个jsxgraph板的堆栈问题

此代码在第二个JSXgraph块中创建两个JSXGRAPH板,可以交互,可以交互,彼此。使用Flexbox包装器div完成了位置。我认为这也适用于公式。希望这回答您的问题。

With STACK, it is possible to include more than one board into a question. For each JSXGraph block, STACK generates a div with an id stored in the divid variable. The divs for the boards then replace the JSXGraph blocks in the question text.

Board interaction

If you want the boards to interact with each other, you need to write the JavaScript code for the boards in a single JSXGraph block (the JavaScript code in a block is encapsulated). To do so, you should first place an empty JSXGraph block in the question text which will generate the first div with an id of the pattern "stack-jsxgraph-1". Then, you add a second block where you put in the code for the two boards. Since the naming for the divids is basically just counting up a number, you can access the divid for the first board with regular expressions in JavaScript.

Board placement

In order to control the placement, you can use some CSS and HTML. For example you can wrap two JSXGraph blocks in a div and make this div a flexbox with display: flex. The two boards will then align horizontally. You can also use a grid layout.

Example Code

The code for the question text could look like this:

<!-- Wrapper div flexbox -->
<div style="display: flex;">
<!-- Empty JSXGraph block for the first board-->
[[ jsxgraph width="200px" height="200px"]] [[/ jsxgraph ]]

<!-- JSXGraph block for the second board-->
[[ jsxgraph width="200px" height="200px"]]
/* divid variables */
const divid1 = divid.replace(/[0-9]+/g,divid.match(/[0-9]+/g)-1)
const divid2 = divid;
console.log(divid1, divid2);
/* init boards */
const board1 = JXG.JSXGraph.initBoard(divid1,{ boundingbox: [-5, 5, 5, -5], axis: true });
const board2 = JXG.JSXGraph.initBoard(divid2,{ boundingbox: [-5, 5, 5, -5], axis: true });
[[/ jsxgraph ]]
</div>

The STACK question then shows two boards:
stack question with two jsxgraph boards

This code creates two JSXGraph boards inside the second JSXGraph block that can interact with each other. The placement is done with a flexbox wrapper-div. I think this should also work for Formulas similarly. I hope this answers your question.

月寒剑心 2025-02-14 07:52:11

遵循 @bernhard759的提示使用CSS来指导该图的位置。以下CSS代码会产生我喜欢的结果:

.jsxgraph-boards {
    align-items: start;
    justify-content: start;
    margin: 0 0 1rem 0;
}

.jxgbox {
    margin: 1rem 0 0 1rem;
}

Following @bernhard759's hint to use CSS to steer the diagram's placement. The following CSS code produces a result that I like:

.jsxgraph-boards {
    align-items: start;
    justify-content: start;
    margin: 0 0 1rem 0;
}

.jxgbox {
    margin: 1rem 0 0 1rem;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文