Loop within STACK question in moodle using jsxgraph

旧巷老猫 提交于 2021-02-11 12:36:28

问题


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 &lt; 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!