STACK Dokumentaatio

Dokumentaation juuri | Kategoriahakemisto | Sivukartta | English site map

Dynamic blocks

Dynamic blocks deal with dynamic content such as Javascript and JSXGraph

Reveal block

This block allows sections of text to be shown or hidden based on the value of an input.

[[reveal input="ans1" value="true"]]
Text shown when the value of input `ans1` is `true`.
[[/reveal]]

The block will only do singular direct string match, and so use of this block is most likely to be useful when combined with true/false or other multiple choice input types. An example question using this feature is provided in the sample questions.

There is currently no "else" clause available with this block.

JSXGraph block

STACK supports inclusion of dynamic graphs using JSXGraph: http://jsxgraph.uni-bayreuth.de/wiki/. The key feature of this block is the ability to bind elements of the graph to inputs of the question. See the specific documentation on including JSXGraph elements.

[[jsxgraph]]
  // boundingbox:[left, top, right, bottom]
  var board = JXG.JSXGraph.initBoard(divid, {boundingbox: [-3, 2, 3, -2], axis: true, showCopyright: false});
  var f = board.jc.snippet('sin(1/x)', true, 'x', true);
  board.create('functiongraph', [f,-3,3]);
[[/jsxgraph]]

JSString block

A new feature in 4.4 is the [[jsstring]] which makes it simpler to produce JavaScript string values out of CASText content. This may be useful for example when generating labels in JSXGraph. The block takes its content and evaluates it as normal CASText and then excapes it as JavaScript string literal.

var label = [[jsstring]]{@f(x)=sqrt(x)@}[[/jsstring]];
/* Would generate, without the need to manually escape things. */
var label = "\\({f\\left(x\\right)=\\sqrt{x}}\\)";

Note, this block is not designed to output Maxima expressins in JS format. For example, this block will not convert x^2 into x**2.


Dokumentaation juuri | Kategoriahakemisto | Sivukartta | English site map

Creative Commons LicenseThe STACK documentation is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.