Skip to content

Achievement unassign JavaScript confirmation - #3286

Open
somiaj wants to merge 1 commit into
openwebwork:developfrom
somiaj:achieve-unassign-js-confirmation
Open

somiaj wants to merge 1 commit into
openwebwork:developfrom
somiaj:achieve-unassign-js-confirmation

Conversation

@somiaj

@somiaj somiaj commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Use JavaScript conformation when unassigning achievements instead of the old radio button option. Also use JavaScript to confirm when deleting an achievement evaluator override. This makes the assign achievement to users page act similar to the users assigned to sets page.

This is built on top of #3215, so I will keep this a draft request until that one finally gets merged. One could test both PRs using this branch though.

Claude did spot one possible issue with the 'allow_unassign' approach here and on the users assigned to sets page. If a page goes stale (a user gets assigned to a set by another instructor/tab/etc), and the form is submitted, the users would then be unassigned without any confirmation (it won't be listed on the confirmation here because this page didn't know the user was assigned, but would still be unassigned because the checkbox was not selected). I have left this alone for now, as it isn't new behavior, but it is something to consider looking into in the future.

@somiaj somiaj changed the title Achieve unassign js confirmation Achievement unassign JavaScript confirmation Nov 14, 2026
@somiaj
somiaj force-pushed the achieve-unassign-js-confirmation branch 3 times, most recently from 16efec9 to e752e76 Compare November 17, 2026 22:27
@somiaj
somiaj marked this pull request as ready for review November 17, 2026 22:28
@somiaj
somiaj force-pushed the achieve-unassign-js-confirmation branch from e752e76 to aa7023d Compare November 20, 2026 02:57

@drgrice1 drgrice1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally this looks good. However, there are some things I see in the code that I don't like, and one notable behavioral change to consider.

@drgrice1

Copy link
Copy Markdown
Member

What needs to be done to fix the allow_unassign issue is what is done on the user detail page for test versions. The same thing could happen there. If the instructor loads the set detail page for a user, and then while the instructor is on that page, that user starts a new test version, then the test version is not represented on the page. So if any test version not listed on the page were simply deleted by the code, that newly started test version would be unintentionally deleted. So, basically, a hidden input is added to the page for the test versions that exist at the time that the user detail page is loaded. So all test versions that existed at the time the page loaded are represented in the form submission later possibly by a checked checkbox that means leave assigned and always by the hidden input which means delete if the checked checkbox is not present, and all test versions that did not exist when the page loaded are completely skipped by the deletion code.

@drgrice1

Copy link
Copy Markdown
Member

By the way see line 50 of templates/ContentGenerator/Instructor/UserDetail/set_row.html.ep and lines 120-123 of lib/WeBWorK/ContentGenerator/Instructor/UserDetail.pm to see the code that implements what I was talking about in my last comment.

@somiaj
somiaj force-pushed the achieve-unassign-js-confirmation branch from aa7023d to 4515271 Compare November 20, 2026 18:28
@somiaj

somiaj commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

@drgrice1 I applied your suggested fix for the issue of something changing in the background, and Claude pointed out that it is fragile because it relies on the order of the inputs and what parameter returned first. In addition mentioned the FIXME in Controler.pm about no longer overriding the param method could cause the order to reverse breaking this because that forces the first value to return. Claude's suggestion, which I used was to avoid order altogether and get all values:

my %actions = $c->param("$userID.achievemenets");
if ($actions{assigned}) { ... }
elsif ($actions{delete}) { ... }

Mentioning this in case you want to update the other locations this is done.

@somiaj

somiaj commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

Code suggestions updated. There is a bigger change, I now have checks to ensure that any changes in the background don't get silently overwritten. This is done for the unassigned achievements, changing the earned status or the counter to make sure if a student earns or updates a counter in the background it isn't reverted.

@somiaj
somiaj force-pushed the achieve-unassign-js-confirmation branch from 4515271 to 6af2acb Compare November 20, 2026 18:38
@somiaj

somiaj commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

I updated the "Assign" tab to also allow assigning to current users. I am still unsure on what is best here. I could have read the intent wrong, I was going off the button was "Assign to All Current Users", which could have been a copy/paste that was never fixed. The code was clear that it was always "All" users.

@Alex-Jordan as someone who I think uses achievements, do you have an opinion on if the idea of assigning to only current users is useful here, or just remove the complication and always assign to all users?

After looking thinks over a bit more, I'm now leaning on the side that "current" doesn't really mean anything here and is extra complication.

@drgrice1

Copy link
Copy Markdown
Member

@drgrice1 I applied your suggested fix for the issue of something changing in the background, and Claude pointed out that it is fragile because it relies on the order of the inputs and what parameter returned first. In addition mentioned the FIXME in Controler.pm about no longer overriding the param method could cause the order to reverse breaking this because that forces the first value to return. Claude's suggestion, which I used was to avoid order altogether and get all values:

Claude said that because, as I always say, Claude is an idiot. There is nothing fragile about the approach and using is is standard procedure for checkbox fallback. If the FIXME is dealt with, then the order would need to be fixed, but that is expected, and not hard to do. It is simply a matter of changing the order of inputs in the DOM since our param override returns the first value and the Mojolicious one returns the last.

In any case, you added the "All Users" versus "Current Users" option when assigning achievements from the "Achievements Manager" page, and you mention that in the help. However, that is not good enough. You need to explain what "all" versus "current" means. I noted this before, but that is entirely unclear and confusing. In fact, I would rather not see that option added, because I don't think it even makes sense to have this distinction of terms that is so utterly unclear and meaningless. I don't even know what it means or where you came up with that distinction really.

@drgrice1

Copy link
Copy Markdown
Member

Just to clarify what I meant by there is nothing fragile about the approach further, anytime you are working according to the design of the system, it cannot be called "fragile", and that is what the approach of calling param and expecting the first input value is doing. Yes, when the system is redesigned, then changes might need to be made. Duh. That is how it always works when you do a redesign. But working outside of the design in an attempt to guess about future redesigns and then calling it "fragile" is not well conceived.

@drgrice1

Copy link
Copy Markdown
Member

Sorry to rant about this, but the "Claude says this is fragile" comment just pissed me off. The fact is that Claude is fragile.

It is further worth noting that if that FIXME in the code regarding the param method is dealt with, then the code you used (suggested by Claude) would still need to be changed as it would not work with the default Mojolicious param method.

@somiaj

somiaj commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

I didn't realize Mojolicious param method didn't return an array in an array context, and it appears one needs to use a different method for this. I mostly went with Claude's suggestion in the hope that when you do address that FIXME (which you mentioned rectally) the code wouldn't need updated, but appears that is not the case.

@somiaj
somiaj force-pushed the achieve-unassign-js-confirmation branch from f9f5c16 to 380e46a Compare November 22, 2026 18:39
@somiaj

somiaj commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

I removed the idea of 'Current Users' on this page, and it is now just assign or unassign from all users.

I did notice one open question (not new with this PR). If a user edits the earned status or counter of some achievements, then clicks the assign to all button, any edits will also be saved. Should this be done? Or when assign to all is clicked, should I reset the earned/counter fields and only preform the assign?

Use JavaScript conformation when unassigning achievements instead of
the old radio button option. Also use JavaScript to confirm when
deleting an achievement evaluator override. This makes the assign
achievement to users page act similar to the users assigned to
sets page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@somiaj
somiaj force-pushed the achieve-unassign-js-confirmation branch from 380e46a to a576e59 Compare November 22, 2026 18:59
@somiaj

somiaj commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

I also reverted Claude's suggestion on the action change it thought was fragile.

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.

2 participants