Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove action scope and add action form validation. #2294

Merged
merged 12 commits into from
Feb 14, 2024

Conversation

somiaj
Copy link
Contributor

@somiaj somiaj commented Dec 31, 2023

On the UserList, ProblemSetList, and AchievementList managers, remove the scope option that helps determine which items to act on, instead users will always select which items to act on and can use filters to change the list of items to select from. This address #1991.

In addition add javascript form validation that will create a modal popup if the form is missing information, such as no items are selected, a text string is not provided, a valid file is not selected, and so on.

Last, make the import tabs not create a form if no valid files are found to import from.

@somiaj somiaj force-pushed the remove-action-scope branch from 59398cf to 9719121 Compare January 8, 2024 22:58
Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

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

Here are a few things that I noticed with an initial look at the javascript files.

There is an issue with this pull request in general though. Basically, this is a reason that issue #1991 is not entirely valid. At least for the Accounts Manager page in part. I have been meaning to add a comment to that issue about this.

If there are more than 200 users in a course, then no users are shown on that page by default. So when you select the "Edit" tab, there is initially no way to select users to edit (for example) with this pull request. You now have to go to the filter tab and get some users to be shown on the page before you can do anything. That is not ideal. Previously when none of the users were selected, you could still edit "all users".

htdocs/js/ActionTabs/actiontabs.js Outdated Show resolved Hide resolved
Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

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

This was supposed to be in the last review, but I must not have clicked the button to add it.

htdocs/js/UserList/userlist.js Outdated Show resolved Hide resolved
@drgrice1
Copy link
Member

drgrice1 commented Jan 9, 2024

Also note that using a modal dialog for form validation messages is a rather intrusive and ugly way of doing so. You should take a look at https://getbootstrap.com/docs/5.3/forms/validation/ for a better way of doing this sort of thing.

@somiaj somiaj force-pushed the remove-action-scope branch 2 times, most recently from 03799c8 to 10e9d0c Compare January 10, 2024 00:07
@somiaj
Copy link
Contributor Author

somiaj commented Jan 10, 2024

Updated the javascript and moved the validation from a modal to in-form messaging and toggling the is-invalid style.

@drgrice1 I noticed the extra step when I was testing a class with 500+ users of having to first filter before acting on all users. I wasn't sure how big of an issue it would be, with a large class is it common to act on all users or first filter? Another option could be to leave the scope menus in the few places they are beneficial, such as the example stated.

@somiaj
Copy link
Contributor Author

somiaj commented Jan 10, 2024

I also moved to disabling the import tab if no valid files are found to import from vs show a different form.

@drgrice1
Copy link
Member

Updated the javascript and moved the validation from a modal to in-form messaging and toggling the is-invalid style.

I like this better. It is less intrusive, and it is good that you clear the validation message when the tabs change. Perhaps this could be taken further though and this could be used for the other validation messages also. For example, if the "Filter" tab is used with field matching and no text is entered that message could also be shown in this hidden div (and cleared when the tabs change).

@drgrice1 I noticed the extra step when I was testing a class with 500+ users of having to first filter before acting on all users. I wasn't sure how big of an issue it would be, with a large class is it common to act on all users or first filter? Another option could be to leave the scope menus in the few places they are beneficial, such as the example stated.

You generally don't want to edit all users if the course is large enough (say 5000 or more) as the page takes to long to load, and who would seriously want to manually edit that many users at one time anyway. So filtering is almost a necessity. I think that pagination should be used for dealing with large numbers of users instead of just not showing any. With proper pagination, all users (to which the current filter applies) could be available in pages and you could select users from multiple pages.

Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

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

If you know how to do this, could you apply prettier to the javascript files that you have edited. I have started doing this when I change javascript files, and eventually I plan to add a workflow to check this (much like we use perltidy for perl files).

The contents of the .prettierrc file that I use for this (and plan to use for the workflow) are:

{
	"arrowParens": "always",
	"bracketSpacing": true,
	"printWidth": 120,
	"semi": true,
	"singleQuote": true,
	"tabWidth": 4,
	"trailingComma": "none",
	"useTabs": true
}

htdocs/js/AchievementList/achievementlist.js Outdated Show resolved Hide resolved
htdocs/js/AchievementList/achievementlist.js Outdated Show resolved Hide resolved
@somiaj somiaj force-pushed the remove-action-scope branch from a2713ff to df11e08 Compare January 10, 2024 04:51
@somiaj
Copy link
Contributor Author

somiaj commented Jan 10, 2024

I updated the javascript to remove all the error messages when switching tabs.

@somiaj somiaj force-pushed the remove-action-scope branch 2 times, most recently from bfa1769 to d0b8f3d Compare January 10, 2024 13:36
@somiaj
Copy link
Contributor Author

somiaj commented Jan 10, 2024

Last commit removes none from the list of options to filter from. Since you need some users/sets to act on, I don't think this option is useful. I can revert if others think we should keep it.

@drgrice1
Copy link
Member

There is another case on the UserList page (the accounts manager) that the removal of the scope selector is particularly bad with for large courses. That is the "Export" tab. Now if you have a large class and you want to export all users, the only way to do this is to first show all users and then select them all. For really large classes that can take a really long time for the browser to load all of that. Previously you could just choose the export "all users" option.

I think in general removing these scope selectors for the accounts manager is not a good idea, and will need to be added back. For the sets manager and the achievements manager it is fine, since those lists are usually not that large.

@somiaj
Copy link
Contributor Author

somiaj commented Jan 10, 2024

I added the action scope back to the Edit, Password, and Export actions on the UserList. In this case it only has two options, either all or selected, since there is a select all checkbox for visible users. Though in practice it will probably only be the export option this is most likely used, since manually editing or changing the password of all users in a class of >200 isn't something that is probably done that often.

Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

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

I think this is okay now. I agree that the "scope" selector is most important for the export form of the user list page. Although I think it should be there for the edit and password forms as well due to the fact that there is the case where all users are hidden by default for large courses.

@somiaj
Copy link
Contributor Author

somiaj commented Jan 10, 2024

I did consider only showing the scope drop downs to Edit, Password, and Export users when less than the full list of students is shown, though unsure if that is useful.

@drgrice1
Copy link
Member

At least for the export page I think that the option to select all users for export via the dropdown should always be there. Even if the class is not large. this makes sense as it allows not needing to deal with the checkboxes at all.

@drgrice1
Copy link
Member

To be frank, I think that should be added back for the set manager export form as well. In fact, that is how I have always done it. It is just clear and concise, and really is better than needing to select all users. It should be there for the export form for achievements also.

@somiaj
Copy link
Contributor Author

somiaj commented Jan 10, 2024

That logic could be extended to any place that scope use to be used, though export is the place it is most likely used.

As an alternative to removing scope completely, would be just reduce it to all and selected. Having none there isn't useful, and the checkboxes take care of the visible option. This would also be useful if you have done a filter, but want to quickly act on the full class without having to reset the filter. I will work on adding back this limited scope approach.

@dlglin do you have any input from your intent behind #1991?

Copy link
Member

@pstaabp pstaabp left a comment

Choose a reason for hiding this comment

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

I'm good with this. @drgrice1 I know you approved, but okay with merging now or any other changes?

@drgrice1
Copy link
Member

drgrice1 commented Feb 7, 2024

Lets wait a bit on this. There are still open questions.

@somiaj somiaj force-pushed the remove-action-scope branch from 42b5a9d to 38d16c4 Compare February 8, 2024 17:32
@somiaj
Copy link
Contributor Author

somiaj commented Feb 8, 2024

I have updated this so that both the Accounts and Sets manager still have action scope, but it is limited to two options, either 'all' or 'selected' and 'selected' is always default. In essence only 'visible' and 'none' was removed (since this can be done via the checkboxes). My thoughts here are that on the Accounts and Sets manager can filter the options, so it could be useful to have a quick way to act on all users without having to update the filter (along with large classes not showing any users without filtering).

I have a patch to also add this back to the achievements manager too, but didn't add it here. Logic being there is no filter on the achievements page, so the checkboxes can be used to act on all achievements at any time. If others prefer to have the scope added back here too, let me know and I'll add that patch.

It would be nice if @dlglin weighs in on the original intent behind #1991

Copy link
Member

@drgrice1 drgrice1 left a comment

Choose a reason for hiding this comment

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

I think that this is better now. Allowing acting on all sets or users regardless of selection for the accounts and sets manager pages is good.

There is one detail that needs attention, and then this can be merged.

lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList.pm Outdated Show resolved Hide resolved
  On the UserList, ProblemSetList, and AchievementList managers,
  remove the scope option that helps determine which items to
  act on, instead users will always select which items to act on
  and can use filters to change the list of items to select from.
  This address openwebwork#1991.

  In addition add javascript form validation that will inform the user
  if the form is missing information, such as no items are selected,
  a text string is not provided, a valid file is not selected, and so on.

  Last, disable the import tab if no valid files are found to import from.
@somiaj somiaj force-pushed the remove-action-scope branch from 38d16c4 to b6f4fd8 Compare February 13, 2024 17:58
@dlglin
Copy link
Member

dlglin commented Feb 13, 2024

When I posted #1991 I wasn't thinking about large classes where all students are not automatically displayed, so I see @drgrice1's point on it being extra work to have to show the whole list before exporting. My thought was to simplify the interface, since right now the user has to mess with two things: the dropdown and the checkboxes to get the subset of students/sets that they want.

There is one thing that I find counterintuitive with this setup: if you filter the list and then perform an action (e.g. export), you are given the option of "all users", which leads to exporting users that are not currently being shown.

I'm not sure if the following suggestion is too complicated, but would it make sense to have the options be "all" and "selected" when no filter is applied, but replace "all" with "displayed" if the list is filtered (with appropriate logic to only apply the action to the shown items)? Maybe that's beyond the scope of this PR.

@drgrice1
Copy link
Member

I personally find that counterintuitive. To me it seems clear that "all" users means all users from the course, and not all visible users. Furthermore, I think the "all" option should always be there. If you do as you suggest, and make that switch to "displayed" when a filter is applied, then you are back to the how this initially was and you add steps needed to export all users again if you have previously applied a filter. That also seems counter to your initial issue that led to this pull request. What you can do with the "displayed" option can always be done with the check boxes.

@dlglin
Copy link
Member

dlglin commented Feb 13, 2024

I'm having trouble envisioning a scenario where you would apply a filter, and then subsequently perform an action on all users. My intuition is that once I've filtered I'm only working on that subset. If I want to do something to all users I would expect that I would remove the filter.

@drgrice1
Copy link
Member

I can. You might want to edit some users and so apply a filter to find those users in your large class. After doing so you might want to export all users.

There is also the issue that there really isn't a way to remove a filter other than to start from scratch by reloading the page.

@Alex-Jordan
Copy link
Contributor

Can we do this with more clear labeling? Instead of "all" or "all users", something like "all course users" would (to me) clearly imply everyone, not just all the ones being displayed.

@drgrice1
Copy link
Member

I am fine with that.

Copy link
Contributor

@Alex-Jordan Alex-Jordan left a comment

Choose a reason for hiding this comment

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

I just tried this and it looks good. I suggest changing "all users" to "all course users" as mentioned in the thread, but mark for approval either way.

@somiaj
Copy link
Contributor Author

somiaj commented Feb 13, 2024

@Alex-Jordan Should All sets be kept as is, or do you suggest updating that as well?

@somiaj
Copy link
Contributor Author

somiaj commented Feb 13, 2024

I just noticed an issue with the validation javascript. It requires a user to be selected even when 'all course users' is selected. Fixing that now, so don't merge.

@Alex-Jordan
Copy link
Contributor

@Alex-Jordan Should All sets be kept as is, or do you suggest updating that as well?

Oh, I realize now I was only looking in the Accounts Manager, not several other places this impacts. But sure, "all course sets" seems fine. Just looking for clarity between literally all of them versus all that are presently displayed.

Does "all course achievements" come up too?

@somiaj
Copy link
Contributor Author

somiaj commented Feb 13, 2024

Because achievements don't have a filter action, there is no option to select between all course achievements and selected achievements, since the checkboxes already deal with this case. I have a patch to add that option to the achievements page if desired for consistency, but currently is not there.

@Alex-Jordan
Copy link
Contributor

Because achievements don't have a filter action, there is no option to select between all course achievements and selected achievements, since the checkboxes already deal with this case. I have a patch to add that option to the achievements page if desired for consistency, but currently is not there.

I'd like to have that. Of course, it can be separate from this PR. The reason I'd like it is that I often load the default collection of achievements, but then go and delete the Challenge achievements, plus a few more. Filtering would just make that a little more smooth. (I should just export the sets that I actually use into an achievement collection file, but then I still have colleagues to mentor, etc.)

@drgrice1
Copy link
Member

Since a filter on the achievements list page is new, that is something that I think should be in a separate pull request.

@somiaj
Copy link
Contributor Author

somiaj commented Feb 13, 2024

I can not remove the action scope from achievements here in anticipation of such a change, but agree it should be in a different PR.

  First fix a but where the javascript required a set to be selected
  when acting on 'all course sets'.

  Second make it so the all/selected select gets flagged as is-invalid
  when failing to select any item, since one way to select an item
  is to toggle this to all. Also remove the is-invalid class when
  an item is selected.
@somiaj somiaj force-pushed the remove-action-scope branch from c4a4208 to 14d1db9 Compare February 13, 2024 21:22
@somiaj somiaj force-pushed the remove-action-scope branch from 286bf45 to fda7619 Compare February 13, 2024 21:48
@somiaj
Copy link
Contributor Author

somiaj commented Feb 13, 2024

Might be worth looking over one last time. I noticed I overlooked the javascript interacting with the all/selected toggle, so I improved that. I also added the all/selected scope back to the achievements page for consistency and if a filter ever does get added in a future PR.

@dlglin
Copy link
Member

dlglin commented Feb 13, 2024

Another observation: when I first looked at this I was confused as to why the Import tab was greyed out. Is there a good way to let the user know that in order to import Sets/Users that they need to first upload a file via the file manager?

It would be nice if the instructor could upload a .def/.lst file here directly, but that's beyond the scope of this PR, so it's captured in #2325.

@drgrice1
Copy link
Member

I looked this over another time to be sure, but I think this pull request is ready.

As to @dlglin's comment about the import tab being grayed out, perhaps a comment could be added to the help file about that. I don't think that is a particularly serious issue though, as the typical course will have .def files in the templates directory, since some are copied from the model course in the default course creation process.

I personally think that import/export should ONLY be done the way that @dlglin suggested. Files are imported from a local client side file, and files are exported for download. There is no need for the clutter in the courses templates directory of set definition and classlist files (or even achievement .axp files). For exporting multiple set definition files, a zip file could be offered.

@pstaabp pstaabp merged commit 4a78f81 into openwebwork:develop Feb 14, 2024
1 check passed
@drgrice1
Copy link
Member

We are going to merge this. If someone wants to add a comment in the help regarding the grayed out import tabs, that might be nice.

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.

5 participants