MecLib Question Setup - mkraska/meclib GitHub Wiki

MecLib is all about using STACK questions in Moodle for engineering mechanics.

A STACK question consists of the following sections:

  • Question variables (Maxima code)
  • Question text (CAS text, i.e. text with embedded injections of Maxima values)
  • Input (definition of input fields)
  • PRT (potential response tree, where the feedback is computed)
  • optional: General feedback (CAS text, usually a worked solution)

Question variables

Template for Meclib objects. See Test Examples and the individual object pages for examples.

initdata: [
  [ "grid", "x","y", -5,5,-4,5, 50 ],
   ...
];
init: stackjson_stringify(initdata);

You also can provide a similar structure as model answer:

tansdata: [
  [ "grid", "x","y", -5,5,-4,5, 50 ],
   ...
];
tans: stackjson_stringify(initdata);

Feedback on symbolic and numeric values with and without units

German version:

stack_include("https://raw.githubusercontent.com/mkraska/meclib/main/Maxima/fb_value.mac");

English version:

stack_include("https://raw.githubusercontent.com/mkraska/meclib/main/Maxima/fb_value_EN.mac");

Feedback on interactive free body diagrams

stack_include("https://raw.githubusercontent.com/mkraska/meclib/main/Maxima/fb_fbd.mac");

Question text (interactive mode)

There are two hidden input fields.

  • objects stores the full state of the graphics widget.
  • names contains special information for feedback functions.

Copy this text to the question variables (remove the div if you don't want a float right image):

<p hidden>[[input:objects]] [[validation:objects]]</p>
<p hidden>[[input:names]] [[validation:names]] </p>
<div style="float:right">
[[jsxgraph width='500px' height='400px' input-ref-objects="stateRef" input-ref-names="fbd_names" ]]
var mode  = "STACK";
const initstring = {#init#};
const centeredLabelStyle = {size:0, showInfobox:false, label:{offset:[-6,0], 
  anchorX:'left', anchorY:'middle'}};
// End of STACK header
[[include src="https://raw.githubusercontent.com/mkraska/meclib/main/imeclib.js" /]]
[[/jsxgraph]]</div>

Question text, Non-interactive mode

Modifications, if possible, aren't stored.

Add the following lines to the question text:

<div style="float:right">
[[jsxgraph width='250px' height='250px' ]] 
var mode  = "STACK";
var stateRef;
const initstring = {#init#};
const centeredLabelStyle = {size:0, showInfobox:false, label:{offset:[-6,0], 
  anchorX:'left', anchorY:'middle'}};
// End of STACK header
[[include src="https://raw.githubusercontent.com/mkraska/meclib/main/imeclib.js" /]]
[[/jsxgraph]]</div>

Input fields (for interactive mode)

Specify properties of the input fields:

  • objects

    • Input type: String (Zeichenkette),
    • Model answer: tans
    • Students must verify: no
    • Show validation: no
  • names

    • Input type: algebraic,
    • Model answer: []
    • Forbid float: no
    • Students must verify: no
    • Show validation: no

Potential Feedback Trees

{@fb_vars(sans, tans, vars, label)@}
{@fb_unit(S_, , 0.005)@}
{@fb_number(S_, , 0.005)@}

see Feedback Overview

Multiple Images

A question can have more than one Meclib image. Currently, inclusion of meclib is required in each individual [[jsxgraph]] region.

You have to define individual variables for the contents, similar to init in the question variables or in the feedback variables.

Example: FBD 01 (general feedback with separate image) in the Demo Moodle Course

⚠️ **GitHub.com Fallback** ⚠️