Skip to content
jotux edited this page Mar 1, 2013 · 9 revisions

Variable

Spec

[[variable_name=initial_value]]

Example

Var is [[v=1]].

Htm

Var is <span data-var="v"></span>.

Js

{
    initialize:
        function ()
        {
            this.v = 1;
        },
    update:
        function ()
        {
        }
}

Number Box

Spec

[[variable_name=initial_value,_]]

Example

Box value is [[b=2,_]]. Box value plus one is [[bp=b+1]].

Htm

Box value is <span data-var="b" class="TKNumberField"></span>. Box value plus one is <span data-var="bp"></span>.

Js

{
    initialize:
        function ()
        {
            this.b = 2;
        },
    update:
        function ()
        {
            this.bp = this.b + 1;
        }
}

Adjustable Number

Spec

[[variable_name=initial_value,(range_min..range_max,step),text]]

Example

There are [[a=10,(10..30,1), items]]. If each item costs $5 the total cost would be $[[ac=a*5]].

Htm

Thre are <span data-var="a" class="TKAdjustableNumber" data-min="10" data-max="30" data-step="1">items</span>. If each item costs $5 the total cost would be $<span data-var="ac"></span>.

Js

{
    initialize:
        function ()
        {
            this.a = 10;
        },
    update:
        function ()
        {
            this.ac = this.a * 5;
        }
}

Toggle

Spec

[[variabe_name=initial_value,text_0,text_1]]

Example

The value is [[t=0,reasonable,unreasonable]].

Htm

The value is <span data-var="t" class="TKToggle TKSwitch"><span>reasonable</span><span>unreasonable</span></span>.

Js

{
    initialize:
        function ()
        {
            this.t = 0;
        },
    update:
        function ()
        {
        }
}

Resultant

Spec

[[variable_name,expression,format_specifier]]

Example

If you get [[rs=75,(0..100,1),%]] on the test your final grade will be [[r,52 + rs/3,%0.0]]%.

Htm

If you get <span data-var="rs" class="TKAdjustableNumber" data-min="0" data-max="100" data-step="1">%</span> on the test your final grade will be <span data-var="r" data-format="%0.0f"></span>%.

Js

{
    initialize:
        function ()
        {
            this.rs = 75;
        },
    update:
        function ()
        {
            this.r = 52 + rs / 3;
        }
}

If/Switch

Spec

[[variabe_name,(condition_1,condition_2,...),(text_1,text_2,...)]]

Example

With a score of [[sc=75,(0..100,1),%]] you will [[sf,(sc <= 60,sc > 60),(fail,pass)]].

Htm

With a score of <span data-var="sc" class="TKAdjustableNumber" data-min="0" data-max="100" data-step="1"></span> you will <span data-var="sf" class="TKSwitch"><span>fail</span><span>pass</span></span>

Js

{
    initialize:
        function ()
        {
            this.sc=75;
        },
    update:
        function ()
        {
            if (this.sc <= 60)
            {
                this.sf = 0;
            }
            else if (this.sc > 60)
            {
                this.sf = 1;
            }
        }
}

Clone this wiki locally