Jump to: Site Navigation

draggableSubsets.pl

This macro helps the instructor create a drag-and-drop environment in which a pre-specified set of elements may be dragged to different "buckets", effectively partitioning the original set into subsets.

An HTML element into or out of which other elements may be dragged will be called a "bucket". An HTML element which houses a collection of buckets will be called a "bucket pool".

To initialize a DraggableSubset bucket pool in a .pg problem, insert the line:

$draggable = DraggableSubsets($full_set, $ans, Options1 => ..., Options2 => ...);

before BEGIN_TEXT (or BEGIN_PGML).

Then, call:

$draggable->Print (or [@ $draggable->Print @]* )

within the BEGIN_TEXT / END_TEXT (or BEGIN_PGML / END_PGML ) environment.

$full_set, e.g. ["statement1", "statement2", ...], is an array reference to the list of elements, given as strings, in the original full set.

$ans, e.g. [[1, 2, 3], [4, 5], ...], is an array reference to the list of array references corresponding to the correct answer which is a set of subsets. Each subset is specified via the indices of the elements according to their positions in $full_set, with the first element having index 0.

Available Options:

```
DefaultSubsets => <array reference>
OrderedSubsets => 0 or 1
AllowNewBuckets => 0 or 1
```

Their usage is explained in the example below.

```
DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGML.pl",
"MathObjects.pl",
"draggableSubsets.pl",
);
TEXT(beginproblem());
$D3 = [
"`e`", #0
"`r`", #1
"`r^2`", #2
"`s`", #3
"`sr`", #4
"`sr^2`", #5
];
$subgroup = "e, s";
$subsets = [ [0, 3], [1, 4], [2, 5] ];
$draggable = DraggableSubsets(
$D3, # full set. Square brackets must be used.
#
$subsets, # reference to array of arrays of indices, corresponding to correct set of subsets.
# Square brackets must be used.
#
DefaultSubsets => [ # default instructor-provided subsets. Default value = [].
{
label => 'coset 1', # label of the bucket.
indices => [ 1, 3, 4, 5 ], # specifies pre-included elements in the bucket via their indices.
removable => 0 # specifies whether student may remove bucket.
},
{
label => 'coset 2',
indices => [ 0 ],
removable => 1
},
{
label => 'coset 3',
indices => [ 2 ],
removable => 1
}
],
# OrderedSubsets => 0, # means order of subsets does not matter. 1 means otherwise.
# (The order of elements within each subset never matters.) Default value = 0.
#
# AllowNewBuckets => 0, # means no new buckets may be added by student. 1 means otherwise. Default value = 1.
);
```

BEGIN_PGML

Let [``G=D_3=\lbrace e,r,r^2, s,sr,sr^2 \rbrace``] 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=\lbrace [$subgroup] \rbrace`]. Give your result by dragging the following elements into separate buckets, each corresponding to a coset.

[@ $draggable->Print @]*

END_PGML

# Answer Evaluation

ANS($draggable->cmp);

ENDDOCUMENT();