问题
I am trying to create a moodle-STACK question with an interactive element via jsxgraph
.
Within the [[jsxgraph]]
... [[/jsxgraph]]
tags, I am plotting a curve with two databases, each with 6 elements.
Since I would like students to add error bars for both scales, I added a loop within the jsxgraph-element
:
var plot = function() {
var j, xr0, yr0, xr1, yr1, xr2, yr2, err1, err2;
board.suspendUpdate();
for (j=0; j<6;j++) {
const v1 = Number(input1.Value());
const v2 = Number(input2.Value());
xr1 = dataX[j]-v1;
yr1 = dataY[j]+v2;
xr2 = dataX[j]+v1;
yr2 = dataY[j]-v2;
xr0 = dataX[j];
yr0 = dataY[j];
err1 = board.create('line',[[xr1,yr0],[xr2,yr0]],{straightFirst:false,straightLast:false, fixed:true});
err2 = board.create('line', [[xr0,yr1],[xr0,yr2]],{straightFirst:false,straightLast:false, fixed:true});
}
};
Since the jsxgraph
code is within the HTML-text field of the STACK-question in moodle, the <
sign is converted to <
and now the loop cant be executed.
Is there a way to use a <
sign within the HTML-field of moodle? If not, how can I get past this problem?
I already wrote a running Javascript-Code that shows what I want to create within moodle:
- https://jsfiddle.net/Furfinator/3q8yk7hp/15/
来源:https://stackoverflow.com/questions/63670241/loop-within-stack-question-in-moodle-using-jsxgraph