Skip to content

PG 2.21 Release Candidate#1393

Open
drgrice1 wants to merge 170 commits intomainfrom
PG-2.21
Open

PG 2.21 Release Candidate#1393
drgrice1 wants to merge 170 commits intomainfrom
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.
somiaj and others added 30 commits January 31, 2026 20:36
…ion-workflow

Add a workflow to generate and publish PG POD and sample problem documentation.
Implement several options for the GraphTool in hardcopy that should have been implemented before.
Upgrade JSXGraph to the latest version and fix the graphtool for that.
Fix the enter key behavior for MathQuill inputs.
The image view and knowl dialogs need to be forced into light mode.
These dialogs are injected outside of the problem content div in
webwork2, and so by default will display in the mode of the page. So the
data-bs-theme attribute needs to be set to "light" to prevent that.

Many PG images have transparent backgrounds and so will not work with a
dark background.  Furthermore, the image view and knowl dialog styles
themself are not set up to honor dark mode.

Note that there is another modal dialog for the `quickMatrixEntry.pl`
macro (in the `htdocs/js/QuickMatrixEntry/quickMatrixEntry.js` file),
but for now I have left that and allowed it to go into dark mode.  That
dialog works fine with dark mode already.  It could be forced to light
mode for consistency though.  Although, does anyone actually use this?

Also ensure that the accordion buttons for scaffolds are dark so that
they have sufficient contrast against the blue or green accordion header
background color.  Bootstrap wants to use the page text color for this,
and if the primary color is light (for instance with the math4-yellow
theme), that does not work.
The CAPA problems have now been removed from the Contrib section of the
OPL (see openwebwork/webwork-open-problem-library#1277).
So this is not needed anymore.

Note that the files in the `macros/capa` directory were not used anyway.
The webwork2 `specialPGEnvironmentVars` settings related to CAPA
problems control where these files are used from, and those still were
using the `Contrib/CAPA/macros` directories. We could update those, but
there were files there that were not copied (they were .pg files that
were actually macros and it was probably believed that they were problem
files).

So in short CAPA problems just will not work anymore even without this
pull request.
Force some things to be displayed in the light color scheme.
This note isn't that useful and can be misleading as it only is
about number of answer blanks.
…e `PERSISTENCE_HASH`.

The applet state is not a "kept extra answer" which is what the
`RECORD_FORM_LABEL` approach is for.  The applet state isn't an answer
at all.  It is just extra problem data that needs to persist.  So
exactly what the `PERSISTENCE_HASH` is for.  In addition, webwork2
stores the kept extra answers in the `last_answer` column which is type
`TEXT` and thus limited to 64KB.  The data in the `PERSISTENCE_HASH` is
stored in the `problem_data` column which is of type `MEDIUMTEXT` and so
can hold up to 16MB of data.  The applet state can become larger than
64KB as is evidenced by the issue posted in the forums at
https://forums.openwebwork.org/mod/forum/discuss.php?d=8785.

There is also a litle clean up of the `insertAll` method of the
`AppletObjects.pl` macro.  It can take advantage of the `tag` method.
…lers on the submit buttons.

This makes applet problems work in the PG problem editor of webwork2.
The PG problem editor uses click handlers on the submit buttons as well,
but calls `preventDefault` on the event, and prevents the form
submission from occuring.  That prevents the current submit handler set
in the ww_applet_support.js code from happening.  Thus the answers for
applets do not get submitted.  By using the click handlers this gets in
at the same point that the PG problem editor handlers are, and they
still occur.  All click handlers are executed even if one of them
prevents default behavior.
Switch applets from storing state via `RECORD_FORM_LABEL` to using the `PERSISTENCE_HASH`.
Remove partial credit note in avg_problem_grader.
When a MathView element is initialized the `mvInitialized` data
attribute is set on the element, and if that attribute is found for the
element in the mutation observer code, then the it does not try to
reinitialize MathView for the element.  However, the code only checks
the primary node in the mutations list, and does not also check for this
data attribute on any element contained therein.  As a result, those
elements can be initialized more than once.

Now that the problem grader for webwork2 is in a collapse, the element
for instructor comments is not initialy visible in the page and is
revealed later by the problem grader javascript.  This causes the
MathView initializer to trigger repeatedly and crashes the page.

To test this set the "Assist with student entry process" to "MathView"
for a course.  Then open a problem when acting as a student.  Make sure
that a student has answered so that the comment box is available. With
the develop branches for both webwork2 and pg, that will crash the page.
With the develop branch of webwork2 and this pull request to pg that
won't happen.
Fix a possible infinite loop in the MathView initializion code.
PG::Critic add policy for weightedGrader.pl functions.
This is the result of running `npm audit fix`.
Update the license to match what is in the webwork2 repo.
This includes clarifying we use artistic license 1.0,
remove the fsf physical address and provide links to both
the artistic license 1.0 and gpl 2.0.

The old license and new license mention copies of the license
should be provided in the "package", but they were not in the pg
repo. This adds them to the doc directory to match what is done
in webwork2.

Remove the old README which was just a copyright statement.
This is the result of executing the `bin/update-localization-files`
script.
Currently if the y axis location is 'center', 'left' (or 'box'), or
'right', then the determination that zero is drawn is made by checking
that the y axis min or max value.  That is incorrect.  It should be
checking the x axis min or max value.  The point is that if the y axis
is passing through x = 0, then zero should not be drawn, and otherwise
it should be.

Similarly, the y axis `drawZero` determination is fixed.

You can test this with the following problem code:

```
DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'plots.pl', 'PGcourse.pl');

$graph = Plot(
    xmin           => -2,
    xmax           => 10,
    xtick_distance => 1,
    xminor         => 0,
    xlocation      => 'bottom',
    ymin           => 0,
    ymax           => 10,
    ytick_distance => 1,
    yminor         => 0,
    ylocation      => 'left'
);

BEGIN_PGML
[!graph!]{$graph}{500}
END_PGML

ENDDOCUMENT();
```

With that example and the develop branch the zero on the x-axis is
incorrectly not drawn in JSXGraph output.  With this branch it is drawn
as it should be. Note that in TikZ output the zero is drawn with this
example. So this makes the two output formats consistent.
The only place this is used is for error messages in
`lib/PGresponsegroup.pm`. That is now reworked to use the
`PGcore::warning_message` method instead. The `internal_debug_messages`
is just not needed anymore in addition to the `warning_message` and
`debug_message` methods. Furthermore, it is inappropriately named. It
has "debug" in the name, but is used for error messages, not debugging
messages.
Yes, this is the same one the dependabot pointed out for the main
branch.
Fix an npm dependency security vulnerability.
Remove the internal debug messages.
Fix `drawZero` for JSXGraph output of the plots macro.
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.

9 participants