-
Notifications
You must be signed in to change notification settings - Fork 662
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
System for discouraging assignment of specific articles #5495
System for discouraging assignment of specific articles #5495
Conversation
app/assets/javascripts/components/article_finder/article_finder_row.jsx
Outdated
Show resolved
Hide resolved
app/assets/javascripts/components/articles/add_available_articles.jsx
Outdated
Show resolved
Hide resolved
app/assets/javascripts/components/articles/available_article.jsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see nothing obviously wrong with this code, but I'm not an expert here.
okay np. |
@ragesoss, your review would be greatly appreciated whenever you have the time. |
Thanks for taking on such a big issue @Abishekcs! I think I would prefer a somewhat different approach. The first major suggestion I have is to rely on the existing I also think that the majority of the logic for this feature should be on the server. I suggest breaking it up into two parts, beginning with implementing a system that just completely prevents creating assignments that are in a certain category. This would be relatively easy to handle in terms of data flow: AssignmentManager should check against the category, raise a specific error (similar to the existing DuplicateAssignmentError), and then AssignmentsController should rescue that error and return a good error message and error status to the frontend. (The Category will need to be routinely refreshed, which can be done via a worker that gets scheduled via A follow-up could then extend it to handle articles that are discouraged but not prevented altogether. We could do this either by adding a way to acknowledge the warning and resubmit from the frontend, or by triggering an Alert when a discouraged articles is assigned and then sending an email to the user and/or the instructor with details about discouraged articles and why they should consider choosing a different article instead. Hmmm... after thinking through it, I guess the frontend approach will be better there, because one goal would be to prevent the noise of adding additional templates to the talk page of the article (even if they later get removed). |
Sure, I will make the changes you have suggested. Thank you for the review . |
app/assets/javascripts/components/common/AssignCell/AssignButton.jsx
Outdated
Show resolved
Hide resolved
app/assets/javascripts/components/articles/add_available_articles.jsx
Outdated
Show resolved
Hide resolved
@ragesoss , I have moved the logic for discouraged assignments to |
@ragesoss, I have removed the |
@Abishekcs sounds good. Give me a ping when the tests are done. I will likely have some time to review it next week if it's ready then. |
@ragesoss the test code is done for this PR. I would appreciate a review whenever you have the time. |
it's on my todo list. |
…eate_assignment Move the check against discouraged articles into the create_assignment method, parallel to the existing pattern for handling DuplicateAssignmentError. This simplifies the code structure, ensures the same clean title flow is applied, and maintains consistency in error handling.
…eManager Replace CategoryImporter with #refresh_titles, ensuring uniqueness with find_or_create_by.
Refactor and enable Wiki Education-only features for update_wiki_discouraged_article.
b9fad9c
to
4047e05
Compare
@ragesoss the test is working properly now. |
Great. That failure is unrelated to your PR, so the tests seem to be in order. I will continue trying out and reviewing it soon. Thanks! |
config/locales/en.yml
Outdated
@@ -265,6 +265,7 @@ en: | |||
article: The article %{title} is now assigned to you. | |||
article_link: Article | |||
article_link_wikidata: Item | |||
discouraged_article: The article is discouraged by Wiki Education. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't actually being used, because the message is being set already where the error is raised. I suggest using the interpolation syntax.
I suggest the key blocked_assignment
, and a message like "%{title} could not be assigned because it is on the Wikipedia community's Wiki Education assignment blocklist."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I will make the changes
lib/assignment_manager.rb
Outdated
@@ -104,6 +105,14 @@ def set_article_from_database | |||
@article = exact_title_matches.first | |||
end | |||
|
|||
def check_wiki_edu_discouraged_article | |||
category = Category.where('name = ? AND article_titles LIKE ?', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the better way to do this is to find the category first, and then check whether the title is included in the catetgory's array of titles. Using LIKE might result in mismatches, such as blocking the assignment of "Animal" when "Animal rights" is on the blocklist.
I tested this out, and it works the way I would expect. With the additional changes I requested, this will be ready to merge. |
…rror message and enhance blocklist check Refactors error messaging to use interpolation syntax and introduces 'blocked_assignment' key. Improves blocklist check by finding the category first, ensuring accurate determinations and avoiding potential mismatches.
@ragesoss , I have made the requested changes for this. |
@ragesoss any update on this PR😅 ? |
@Abishekcs yes, i'm happy with the PR and it is ready to merge, but I have not yet introduced this new feature to the Wikipedia community or finalized the category name to so, so I don't want to merge and deploy it yet. Doing that introduction is near the top of my todo list now that I am back from vacation; I hope to get it started today. |
The on-wiki discussion about this has not really come to a conclusion, in particular with regards to the category name or how the community wants to use it... but I'd like to go ahead and merge it and deploy it so that it's ready whenever we do come to consensus. So... what happens if this gets deployed but there is no |
@ragesoss by this |
Yes, that's what I mean. Is it safe to deploy it without such a value, so that it just would not do anything? If not, can it be easily adjusted to behave like that? |
@ragesoss, a) In b) The second place is in |
In WikiDiscouragedArticleManager, introduce a conditional check to verify if 'blocked_assignment_category' is present in the environment variables. When absent, log an informational message using Rails.logger.
@ragesoss i have added the if statement for |
Great, thanks! |
depth: 0 | ||
).refresh_titles | ||
blocked_assignment_category = ENV['blocked_assignment_category'] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a return unless
guard clause here, rather than the branching if
statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Looks like your new change broke the tests. The fix probably involves adding a new entry in |
It should pass now 😅 added the entry for test ENV. |
Thanks @Abishekcs! This is an exciting feature, and I'm looking forward to seeing it in action. |
Great! 👍 |
closes #5477
What this PR does
This pull request addresses the issue documented in #5477. It introduces a feature that displays a
warning message
to students and administrators when they select a discouraged article/assignment.Affected Pages:
/courses/[institution_name]/[course_name]/articles/available
/courses/[institution_name]/[course_name]/article_finder
/courses/[institution_name]/[course_name]/students/articles/[user]
/courses/[institution_name]/[course_name/home
Screenshots
Before:
For Admin :
Before.Admin.webm
For Student :
Before.Student.webm
After:
For Admin:
After.Admin.mp4
For Student:
After.Student.mp4
Note:
For testing a category from wikipedia set
blocked_assignment_category: [Category Name]
inapplication.yml
(used in assignment_manager.rb) and also rundailyupdate