Skip to content

Move the WeBWorK::PG module to PG.#1792

Merged
pstaabp merged 4 commits intoopenwebwork:developfrom
drgrice1:pg-envir-work
Oct 12, 2022
Merged

Move the WeBWorK::PG module to PG.#1792
pstaabp merged 4 commits intoopenwebwork:developfrom
drgrice1:pg-envir-work

Conversation

@drgrice1
Copy link
Member

Note that the WeBWorK::PG::Local and WeBWorK::PG::Remote modules have been removed. The Local variant is integrated directly into WeBWorK::PG, and the Remote variant was not working and is in disrepair.

Remove the pg special environment variables ALWAYS_SHOW_HINT_PERMISSION_LEVEL and ALWAYS_SHOW_SOLUTION_PERMISSION_LEVEL. Use the always_show_hint and always_show_solution permissions directly. Whether solutions and hints are shown is now controlled by webwork2 and not by pg.

The pg variable/flag $showHint is removed. When and if hints are shown is now controlled by the instructor with a combination of options at the course, set, and problem level.

Note that hints were not implemented in gateway quizzes and still aren't.

Also the options to use knowls for solutions and hints have been removed. Always use knowls for solutions and hints.

Showing the various pieces of debugging information for a problem is now controlled with translation options. Webwork permissions are converted into these debugging options. The VIEW_PROBLEM_DEBUGGING_INFO special pg environment variable was removed and is one of these debugging options.

Although the permissionLevel and effectivePermissionLevel are still passed in, they are no longer used by anything in PG. A translator option named isInstructor is passed into the environment that can be set to get instructor things to happen. Another special translator option for scaffolds named forceScaffoldsOpen can be passed to force all scaffolds to be open. This is set in the library browser and in gateway quizzes.

Reduced scoring is implemented on the webwork2 side. PG no longer does that. It is implemented with the old method where the reduced score is saved in the problem status and the score before the reduced scoring period begins is saved in the sub_status. This can be changed later to fix some of the other issues with reduced scoring.

Several other environment variables that are clearly not needed have also been removed including the appletPath and session key.

Note that PGalias no longer uses the course name, user login, set number, and problem number for generating resource UUID's. It now only uses the problem seed, psvn, and problemUUID. So webwork2 constructs a problemUUID that guarantees the necessary uniqueness.

This depends on openwebwork/pg#709.

Copy link
Member

@drdrew42 drdrew42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly inconsequential feedback from initial code review. Testing forthcoming.

} elsif ( $item eq 'showMeAnother' ) {
$showMeAnother = ( $value ) ? $value : 0;
} elsif ( $item eq 'showHintsAfter' ) {
$showHintsAfter = ( $value ) ? $value : 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$showHintsAfter = ( $value ) ? $value : 0;
$showHintsAfter = ( $value ) ? $value : -2;

or, more ideally, pull the server default value?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I see, there's a check later that would override with the default value -- but in order for that to occur, the alternate value here must fail the regex /-?\d+/... so empty string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the logic does seem messed up here. All of the settings here should use the defaults already it seems.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact the later "problem value clean up" won't even occur if these do happen. This is all in a big if .. elsif ... elsif statement.

$showMeAnother =~ s/[^-?\d-]*//g;

unless ($showHintsAfter =~ /-?\d+/) {$showHintsAfter = $showMeAnother_default;}
$showHintsAfter =~ s/[^-?\d-]*//g;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$showHintsAfter =~ s/[^-?\d-]*//g;
$showHintsAfter =~ s/[^-\d]*//g;

don't allow ? and remove duplicate - (this should happen in all these regex expressions...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there is another issue on line 2182, it should be falling back to $showMeAnother_default and not to $showMeAnother_default.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You caught me on a cut and paste without real thought on this one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I am not sure what was intended with the regular expressions including the question mark there. Did some errant values have question marks at some point? It is also debatable if these substitutions are really at all effective in any case. If there is a value that the substitutions actually do something for, that means the administrator has the defaults set to something invalid. In addition this won't fix all bad values. One thing the substitutions wouldn't fix is a value like '5-3'.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed -- it looks like someone threw [] around the earlier regex... dunno why the - ended up in there a second time. I'd lean towards removing all of these secondary regexes.

Comment on lines 48 to 50
# WARNING: The usage of $self throughout this file is incorrect and quite misleading. In all cases $self needs to at
# least be a WeBWorK::ContentGenerator object even. In addition it must be ensured that the $self object has the
# correct hash values to work with the method.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# WARNING: The usage of $self throughout this file is incorrect and quite misleading. In all cases $self needs to at
# least be a WeBWorK::ContentGenerator object even. In addition it must be ensured that the $self object has the
# correct hash values to work with the method.
# WARNING: The usage of $self throughout this file is incorrect and quite misleading. In all cases $self needs to at
# least be a WeBWorK::ContentGenerator object. In addition it must be ensured that the $self object has the
# correct hash values to work with the method.

Is it worth performing ref($self) =~ /WeBWorK::ContentGenerator/ check in these subroutines? I realize that's not entirely enough... necessary, but not sufficient.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps. The old code had comments about what the ref should be, but no actual check. I will leave this for future thought and work. The design of the old ProblemUtil/ProblemUtil.pm module was rather flawed, and this improves things a little, but more needs to be done.

@drgrice1 drgrice1 force-pushed the pg-envir-work branch 2 times, most recently from 6083f3f to acf5fdc Compare September 1, 2022 11:47
@drgrice1
Copy link
Member Author

drgrice1 commented Sep 1, 2022

I tested reduced scoring with gateway quizzes, and things are working correctly with that.

I also added a check to ensure that the recorded score is never lowered by webwork regardless of what comes back from PG.

@drgrice1 drgrice1 force-pushed the pg-envir-work branch 3 times, most recently from 64ee2a0 to d9ce8ab Compare September 9, 2022 17:53
@drgrice1 drgrice1 force-pushed the pg-envir-work branch 2 times, most recently from f132368 to 22d0d48 Compare September 14, 2022 10:53
Note that the WeBWorK::PG::Local and WeBWorK::PG::Remote modules have
been removed.  The Local variant is integrated directly into
WeBWorK::PG, and the Remote variant was not working and is in disrepair.

Remove the pg special environment variables
ALWAYS_SHOW_HINT_PERMISSION_LEVEL and
ALWAYS_SHOW_SOLUTION_PERMISSION_LEVEL.  Use the always_show_hint and
always_show_solution permissions directly.  Whether solutions and hints
are shown is now controlled by webwork2 and not by pg.

The pg variable/flag $showHint is removed.  When and if hints are shown
is now controlled by the instructor with a combination of options at the
course, set, and problem level.

Note that hints were not implemented in gateway quizzes and still
aren't.

Also the options to use knowls for solutions and hints have been
removed.  Always use knowls for solutions and hints.

Showing the various pieces of debugging information for a problem is now
controlled with translation options.  Webwork permissions are converted
into these debugging options.  The VIEW_PROBLEM_DEBUGGING_INFO special
pg environment variable was removed and is one of these debugging
options.

Although the permissionLevel and effectivePermissionLevel are still
passed in, they are no longer used by anything in PG.  A translator
option named isInstructor is passed into the environment that can be set
to get instructor things to happen.  Another special translator option
for scaffolds named forceScaffoldsOpen can be passed to force all
scaffolds to be open.  This is set in the library browser and in gateway
quizzes.

Reduced scoring is implemented on the webwork2 side.  PG no longer does
that.  It is implemented with the old method where the reduced score is
saved in the problem status and the score before the reduced scoring
period begins is saved in the sub_status.  This can be changed later to
fix some of the other issues with reduced scoring.

Several other environment variables that are clearly not needed have
also been removed including the appletPath and session key.

Note that PGalias no longer uses the course name, user login, set
number, and problem number for generating resource UUID's.  It now only
uses the problem seed, psvn, and problemUUID.  So webwork2 constructs a
problemUUID that guarantees the necessary uniqueness.
unreduced score in to PG for the recorded score.  Otherwise the recorded
score can be updated incorrectly.  This is determined simply by checking
if the sub_status is less that the status in the case that reduced
scoring is enabled for the set.

Also, a check is added that the score returned by PG (and reduced if
reduced scoring is in effect) is less than the currently saved score.
If that is the case, the the score in the database is not changed.
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.

4 participants