Skip to content

PG 2.21 Release Candidate#1393

Open
drgrice1 wants to merge 216 commits into
mainfrom
PG-2.21
Open

PG 2.21 Release Candidate#1393
drgrice1 wants to merge 216 commits into
mainfrom
PG-2.21

Conversation

@drgrice1
Copy link
Copy Markdown
Member

This is the release candidate for WeBWorK 2.21. Please re-target any pull requests that you want to get into the release for this branch.

drgrice1 and others added 30 commits July 11, 2025 06:36
`maketext` is not defined in the Translator package, and so it cannot be
called directly in the default graders defined in the translator.
Instead an eval is needed to access the `maketext` in the safe
compartment.

This fixes issue #1261.
Also fixes spelling of SYNOPSIS
…oblems.

This extends @sfiedle1's work in #1258, and implements the structural
rework that I suggested in the conversation for that pull request
(albeit slightly modified).

There are two new options for the `draggableSubsets.pl` macro.  They are
`ShowUniversalSet` and `UniversalSetLabel`.

If `ShowUniversalSet` is 1, then the set of all elements that are passed
as the first argument for the `DraggableSubsets` method will be shown as
a separate drag and drop bucket.  This bucket is always above the other
usual drag and drop buckets (both in HTML and TeX).  The elements of the
universal set can be dragged multiple times to the other buckets.
Really this is a copy of the element, so all elements always remain in
the universal set.

The `UniversalSetLabel` option is a string that will be shown as the
label of the universal set bucket.

Note that this approach doesn't require any special handling for grading
the answer regardless of if `$showPartialCorrectAnswers` is true or not,
because the universal set bucket is not part of the answer in any case.
It is not listed in any of the answer previews, and is not part of the
grading in any way. It is purely a source of elements.

I also added some validation of the answers and default subsets that are
passed to the DraggableSubsets method.  Previously invalid inputs would
have caused rather unexpected things.  Now they will be errors
(specifically `Value::Error`s).

In my original comment to #1258 I suggested a `ShowUniversalSet` option
and a related `AllowReusableElements` option.  The latter option was
dropped because I realized it doesn't really make sense in the context
of a universal set. I initially implemented it, but basically it made
the "universal set" bucket really just a regular bucket just like all of
the others, and it really wasn't a "universal set" anymore since it
didn't always have all elements. I thought of a way that it could make
sense in which it always has all elements, but only one copy was allowed
to be dragged to the other buckets.  So only one duplicate, no reuse
after that.  That would take some effort to implement (mostly in the
javascript code), but could be done. I don't know that this would really
be that useful though, so I didn't implement it for now.

A MWE for testing this is as follows:

```perl
DOCUMENT();

loadMacros(qw{PGstandard.pl PGML.pl draggableSubsets.pl PGcourse.pl});

$draggable = DraggableSubsets(
    [ 'orange', 'blue', 'apple' ],
    [ [ 0, 1 ], [ 0, 2 ] ],
    DefaultSubsets => [
        { label => 'Color', indices => [] },
        { label => 'Fruit', indices => [] },
    ],
    ShowUniversalSet  => 1,
    UniversalSetLabel =>
        'Classify each item below as a color, fruit, or both.',
    AllowNewBuckets => 0
);

BEGIN_PGML
[_]{$draggable}
END_PGML

ENDDOCUMENT();
```

To test this you should also test modifications of the above problem
with other options.  For example, change to `AllowNewBuckets => 1`, and
test addition and removal of buckets particularly removal after elements
have been added to the bucket.  Add indices to the `DefaultSubsets` so
elements are initially shown in those and behavior when elements are
dragged in an out.
`draggableSubsets.pl` macro consistent with what is documented.

Add `options.sort = false` for the universal set so that it can not be
rearranged from what it is set to.  This is for transparency since this
doesn't matter anyway.
There are some new strings that have not been added to the pot file.
66% of minimum 1% translated source file: 'pg.pot'
on 'el'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
84% of minimum 1% translated source file: 'pg.pot'
on 'he_IL'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
41% of minimum 1% translated source file: 'pg.pot'
on 'cs_CZ'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
11% of minimum 1% translated source file: 'pg.pot'
on 'es'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
14% of minimum 1% translated source file: 'pg.pot'
on 'ko'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
4% of minimum 1% translated source file: 'pg.pot'
on 'ru_RU'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
22% of minimum 1% translated source file: 'pg.pot'
on 'de'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
7% of minimum 1% translated source file: 'pg.pot'
on 'fr'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
4% of minimum 1% translated source file: 'pg.pot'
on 'zh_HK'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
9% of minimum 1% translated source file: 'pg.pot'
on 'hu'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
6% of minimum 1% translated source file: 'pg.pot'
on 'tr'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
6% of minimum 1% translated source file: 'pg.pot'
on 'zh_CN'.

Sync of partially translated files: 
untranslated content is included with an empty translation 
or source language content depending on file format
don't let a negative score be reported
Rewrite the PG uniq function to return the array in a consistent order
This fixes two issues with a check in BeginList; first, it accessed a parameter without checking it if existed first, resulting in undefined value warnings; and second it tested the validity of the uppercase version of the parameter but then used the literal parameter in the assignment.
drgrice1 and others added 30 commits May 17, 2026 05:54
Don't use student_formula to collect matrix array and update typeMatch methods.
This fixes issue #1349 and is the result of the discussion in that
issue.  See the issue for details and example problems.
This color has a contrast ratio of 6.68 against the white background.
The red color has a contrast ration of 4.00 which is not sufficient for
accessibility purposes.
The method returns an array containing references to arrays that form a
partition the vertex indices into the connected components of the graph.
For example, for the graph with vertices E, F, G, H, I, J, K, and L, and
edge set {{{E, L}, {F, G}, {F, L}, {G, J}, {H, I}, {J, K}, {J, L}}}, the
method will return ([E, F, G, J, K, L], [H, I]).
Instead of trying to place the labels using the coordinates, use the
`anchor` and padding options to get better positioning.  The primary
advantage is now the labels don't float away when the image is enlarged.
This was not done originally because at the time this macro was
implemented the `anchor` and `padding` options didn't exist.

The weights for the default layout and the wheel layout are still
positioned along the perpendicular vector for now.  The problem is that
those labels are rotated, and that does not work well with the anchor.
This is a TikZ issue (I implemented the anchor for JSXGraph to work the
same as the TikZ anchor option).  The problem is that the rotation is
around the position of the anchor, and not around the center of the
text. The usual solution for this in TikZ is to use a `\rotatebox` on
the node contents. Perhaps another rotation option could be addded to
the plots macro that would rotate the text instead of rotating around
the anchor position.
an invalid edge set for a graph with a single edge.
First, the method is now quite a bit more efficient.  Rather than
finding and sorting only the weights of the edges in the graph, and then
searching through the graph to find those edges at each step in the
algorithm, the edges with the weights are all listed and sorted by
weight (more like the actual sorted edges algorithm works).  So there is
no need to find the edge later, you just follow the algorithm and
process the edges in order.

Second, the return value of the method is reordered and more data
returned.  See the updated POD for good documentation on what is
returned.

This makes the method return a lot more useful information that can be
used for constructing a solution to problems using the sorted edges
algorithm.
First, the method is now quite a bit more efficient.  Rather than
finding and sorting only the weights of the edges in the graph, and then
searching through the graph to find those edges at each step in the
algorithm, the edges with the weights are all listed and sorted by
weight (more like the actual sorted edges algorithm works).  So there is
no need to find the edge later, you just follow the algorithm and
process the edges in order.

Also make the algorithm terminate once the minimal spanning tree is
complete as it should.

Second, the return value of the method returns more data. See the
updated POD for good documentation on what is returned.

This makes the method return more useful information that can be used
for constructing a solution to problems using the sorted edges
algorithm.

These is the basically the same changes that were made for the
`sortedEdgesPath` method.
This returns a translated string description of the graph.  The string
that is returned is suitable for use as the "alt" text for the image
returned by one of the image methods.
This is giving warnings when the unit tests are run.
Make list answers work in MultiAnswer and RadioMultiAnswer part answers.
Fix a typo in the `ProhibitBeginproblem.pm` PG critic policy.
Fix an ambibous `abs` call in `AnswerChecker.pm`.
Using `//=` in signatures is a feature that is not available until
version 5.28 of perl.

I am not entirely certain of why the added `to_string` is needed or why
it works with newer versions of perl, but it causes an issue with older
perl versions as well.

This fixes issue openwebwork/webwork2#2978.
This addes a comment to the POD about the `scores` array that is set
internally, and that can be used in a custom checker.
Add a note in the `parserMultiAnswer.pl` macro about the `scores` array.
Some improvements and additions to the `SimpleGraph.pl` macro.
This adds two options to plots, `texPackages` and `tikzLibraries`
to Plots, that can be used to add additional packages and libraries
fro generating TikZ output. This also adds "amsmath" in the list
of default packages that are loaded.
This is for problmes that use the `dragndrop.js` JavaScript and the
`DragNDrop.pm` module via the `draggableProof.pl` and
`draggableSubsets.pl` macros.

The elements in a drag and drop list can now be focused using tab and
shift-tab.  Once focused the arrow keys move the elements around.  If an
element is moved with the keyboard controls the changes are announced in
a visually hidden span.  Note that drag and drop actions via the mouse
cursor are not aria announced for now.  I am assuming that a screen
reader user would not be using the mouse for drag and drop.

There is now also a "Drag and Drop Help" button that is shown below the
drag and drop lists.  If pressed, help is shown describing the keyboard
controls.  This help can be customized by the problem.

There are new options for the macros that allow for customizing the help
and associated texts.  See the updated POD in the module and macros for
details.  Also, I don't like that there are some options that are for
the `DragNDrop.pm` package that are passed in from the macros, but are
different in the macros than in the module.  Basically the first letter
is upper case in the macros, but lower case in the module.  So the upper
case first letter variants is deprecated (but will still work with a
compatibility layer).  I don't like that the macros use Pascal case to
begin with for options.  Options should be camel case.

Note that I also made all of the texts for the drag and drop object
translatable via `maketext`.  The texts can be customized per problem as
mentioned above, but if only a translation is needed there is no need
for such customization.
This sets the `aria` option from the JSXGraph library for all graphed
objects. Thus objects are described as they are graphed.

I am sure this will still need some work, but this makes the graphtool
at least basically accessible.

There is also a need to specifically set the tabindex for objects
(usually to the empty string which is the closest thing to unsetting it
that the JSXGraph library allows).  Otherwise JSXGraph now sets that to
-1 for everything and tries to focus those things with javascript and
that is interfering with the graphtools own focus behavior. This is more
of what was done in #1357.

Note that the aria labels are not translated.  Although nothing for the
graphtool is.  The usual data attribute approach really would be a mess
for this.  There are a lot of strings.  Translating the graphtool would
take a lot of effort with the current methods for javascript
translation.
Also, using `Ctrl-Backspace` will clear the graph.

This is not documented or in the help, but I susped that some keyboards
label what is really the Backspace key as Delete.  So this will make
those work.
…ots.pl` macro.

To set custom tick positions use the `tick_positions` axis option.  Set
that to a reference to an array containing the positions on the axis
that ticks are desired.  For example, `tick_positions => [ 2, 5, 9 ]`
will place ticks at positions 2, 5, and 9 on the axis.  Note that when
this option is used the `tick_delta`, `tick_scale`, and `tick_distance`
options are not used. So only the given tick positions will appear in
the graph.

To set custom tick labels use the `tick_labels` option.  Note that this
is not a new option, but now it accepts a new type of value.  Previously
this was purely boolean (0 or 1), and it only determined if tick labels
would be shown or not.  Now it can take a value that is a reference to a
hash.  The keys of the hash are tick positions, and the values are the
labels to be placed at those positons. Note that formatting of the label
must be done by the auther, and the `tick_label_format` option is
ignored for any label provided in this hash. If a major tick is not
listed in the hash, then the position will be used for the label and it
will be formatted according to the `tick_label_format` option.

This is intended to replace what is done in #1374 and is a more flexible
approach than what is done there.  In that pull request the capability
for custom tick labels only is added, and it is extremely restrictive in
what it can do.  Only positive tick labels can be customized, and it
requires that the problem author label all major ticks (there is no
fallback and a tick is labeled "undefined" if one is missing).
…the y-axis.

The coordinate for the y-axis is different than for the x-axis.
Make the graphtool screen reader friendly.
Make it possible to set custom tick positions and labels with the `plots.pl` macro.
Add keyboard controls for drag and drop problems.
Add method to load texPackages and tikzLibraries to Plots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants