WeBWorK Main Forum

insert missing macro (draggableSubsets.pl)

insert missing macro (draggableSubsets.pl)

by Vivien Altwasser -
Number of replies: 3

Hello everyone,

I am (still) running webwork 2.16. One of my problem authors wanted to use draggableSubsets.pl to have a list sorted in two buckets in an arbitrary order. This unveiled the fact that the macro was missing in /opt/webwork/pg/macros. I found the file on github, inserted it in the macros folder and reloaded apache. I did a first try with the POD example:

DOCUMENT();
loadMacros(
    'PGstandard.pl',
    'PGML.pl',
    'MathObjects.pl',
    'draggableSubsets.pl'
);

$draggable = DraggableSubsets(
    # Full set.  Make sure to use "\(...\)" for math and not "`...`" for correct display.
    [
        "\(e\)",    # index 0
        "\(r\)",    # index 1
        "\(r^2\)",  # index 2
        "\(s\)",    # index 3
        "\(sr\)",   # index 4
        "\(sr^2\)", # index 5
    ],

    # Reference to array of arrays of indices, corresponding to
    # the correct set of subsets.
    [ [0, 3], [1, 4], [2, 5] ],

    # Default instructor-provided subsets.
    # The default value if not given is [] which is interpreted to mean that
    # the full set will be the only subset initially shown.
    DefaultSubsets => [
        {
            # Label of the bucket.
            label     => 'coset 1',
            # Specifies pre-included elements in the bucket via their indices.
            indices   => [ 1, 3, 4, 5 ],
            # Specifies whether student may remove bucket.
            removable => 0
        },
        {
            label     => 'coset 2',
            indices   => [ 0 ],
            removable => 1
        },
        {
            label     => 'coset 3',
            indices   => [ 2 ],
            removable => 1
        }
    ],

    # 0 means order of subsets does not matter. 1 means otherwise.
    # (The order of elements within each subset never matters.)
    # The default value if not given is 0.
    OrderedSubsets => 0,

    # 0 means no new buckets may be added by student. 1 means otherwise.
    # The default value if not given is 1.
    AllowNewBuckets => 1,

    # If this option is defined then labels for buckets for which a specific
    # label is not provided will be created by replacing %s with the bucket
    # number to this prefix.  These labels will also be used for buckets
    # added by the user if AllowNewBuckets is 1.  This string should contain
    # exactly one instance of %s.  The default value if not given is
    # undefined.
    BucketLabelFormat => 'Subset %s'

    # This is the text label for the button shown that resets the drag and
    # drop element to its default state.  The default value if not given is
    # "Reset".
    ResetButtonText => 'zurücksetzen'

    # This is the text label for the button shown that adds new buckets.
    # The button is only shown if AllowNewBuckets is 1.
    # The default value if not given is "Add Bucket".
    AddButtonText => 'Add Subset'

    # This is the text label for the remove button that is added to any
    # removable buckets.  The default value if not given is "Remove".
    RemoveButtonText => 'Delete'

    # These are options that will be passed to the $draggable->cmp method.
    cmpOptions => { checker => sub { ... } }
);

BEGIN_PGML
Let [``G = D_3 = \{ e, r, r^2, s, sr, sr^2 \}``] be the Dihedral group of
order [`6`], where [`r`] is counter-clockwise rotation by [`2\pi/3`], and
[`s`] is the reflection across the [`x`]-axis.

Partition [`G = D_3`] into *right* cosets of the subgroup
[`H = \{ e, s \}`].

Give your result by dragging the following elements into separate buckets,
each corresponding to a coset.

[_]{$draggable}
END_PGML

ENDDOCUMENT();
...which gave error:

ERRORS from evaluating PG file: 

 syntax error at (eval 2503) line 68, near "'Subset %s'

    # This is the text label for the button shown that resets the drag and
    # drop element to its default state.  The default value if not given is
    # "Reset".
    ResetButtonText"
Is there something I missed in the process of inserting the macro or is the issue known with a workaround? First thing my author tried was using draggableProof.pl, but there was no chance to have the lists arbitrary. I would also go with another macro if available.
In reply to Vivien Altwasser

Re: insert missing macro (draggableSubsets.pl)

by Glenn Rice -

The draggableSubset.pl macro was added for webwork 2.17, and since then has undergone more changes.  Regardless of which version you get, you will also need the lib/DragNDrop.pm module.  In addition, you need the dragndrop.js and dragndrop.scss files.  Unfortunately, It is unlikely that you are really going to get this all to work with webwork 2.16.  There have been a lot of changes to webwork and PG that are not entirely compatible with webwork 2.16, and this macro depends on several of those things.

In reply to Glenn Rice

Re: insert missing macro (draggableSubsets.pl)

by Vivien Altwasser -

Thank you for your quick answer. It seems my only option would be to update to 2.18 or make a crude list with blanks to be filled. Nevertheless, many thanks.

In reply to Vivien Altwasser

Re: insert missing macro (draggableSubsets.pl)

by Glenn Rice -

Unfortunately, those do seem to be your options without a lot of effort of recreating the macro in such a way that it is compatible with webwork 2.16.

If you are upgrading, I recommend upgrading to 2.19 instead of 2.18.