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

fix:restored removed article to available articles #6060

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

shishiro26
Copy link
Contributor

NOTE: Please review the pull request process before opening your first PR: https://github.com/WikiEducationFoundation/WikiEduDashboard/blob/master/CONTRIBUTING.md#pull-request-process

What this PR does

This PR restores both self-assigned and admin-assigned articles back to the pool of available articles.
I have written a test case for the controller to ensure that the changes work as expected.

Screenshots

After:
https://github.com/user-attachments/assets/db77ecb3-734d-4693-94d2-cfd235297c90

Open questions and concerns

With this change, when removing an article, a dialog appears with the message: "Are you sure you want to delete this program?"

  • Do we need to modify the dialog message to reflect the new functionality?

#5549

@shishiro26 shishiro26 marked this pull request as draft December 13, 2024 14:27
@shishiro26
Copy link
Contributor Author

In this PR, I have added Ruby test cases for the unclaim method in the AssignmentsController.

The scenarios covered are as follows:

  1. When the article is assigned to the user by the admin:
  2. When the article is assigned to the user by the admin:
  3. When the article is self-assigned:

@shishiro26 shishiro26 marked this pull request as ready for review December 23, 2024 15:45
@shishiro26
Copy link
Contributor Author

@ragesoss the test is passing locally in my system
image

@shishiro26
Copy link
Contributor Author

@ragesoss, I'm not entirely sure, but the multiwiki_assignment_spec.rb test seems to be failing after the latest commit merge. Additionally, the account_requests_spec.rb test is failing both on my local setup and in the master branch. However, this failure appears to be unrelated to the changes I made.

@ragesoss
Copy link
Member

@shishiro26 yes, i'm not sure why it started failing, but i'm going to look into it.

@ragesoss
Copy link
Member

Does this implementation differentiate articles that started as Available Articles versus ones that the student chose via title without starting as an Available Article? I think we need this to only apply for ones that started as Available Articles.

@shishiro26
Copy link
Contributor Author

shishiro26 commented Dec 31, 2024

I’m not sure if you’re referring to this one, sir

User:
https://github.com/user-attachments/assets/0cfa08ac-d75f-4f52-a223-a3c63a471ec9

If so, then yes, it doesn’t differentiate between the two. It removes both from the assigned ones and keeps them in the available articles, sir.

@shishiro26
Copy link
Contributor Author

Sir, I would like to know if there is any user-specific association, such as a user_id or something similar, that tracks whether a particular person created or added an article. Is there an existing reference to identify the user who created or added the article? From the logs I’ve seen, there are references to users, but they seem to be related to assignments rather than article creation. If such an association doesn’t currently exist, would it be possible for me to add a user_id field to the articles table and link it to the user who created or added the article?

@shishiro26 shishiro26 marked this pull request as draft January 2, 2025 16:59
@ragesoss
Copy link
Member

ragesoss commented Jan 2, 2025

I think you could use Assignment#flags to keep track of whether an Assignment record began as an Available Article.

@shishiro26
Copy link
Contributor Author

Sir, I believe there is no change in the flags field, as it remains NULL in both cases in the SQL database. There appears to be no update to Assignment.flags.

@ragesoss
Copy link
Member

ragesoss commented Jan 2, 2025

Right, you would need to implement that.

@shishiro26
Copy link
Contributor Author

okay, sir! 😄

@shishiro26
Copy link
Contributor Author

Could you please review this, sir? This is just a rough implementation. If this method looks fine, the unclaim method (which removes the article if it is not in the available articles pool, and if it is in the pool, the assignment is simply unclaimed and added back to the available articles), and if the assignment#flags are set correctly, I will refine the code and update the RSpec tests for the final version.

@ragesoss
Copy link
Member

ragesoss commented Jan 3, 2025

I will plan to review this next week.

@shishiro26
Copy link
Contributor Author

Okay sir

@ragesoss
Copy link
Member

ragesoss commented Jan 8, 2025

This looks like it's going in the right direction, but from my reading of the code, I think it doesn't correctly the initial setting of flags. An "Available Articles" is an Assignment record created by the instructor of a course (or an admin) that is not linked to a user. These are the ones that are available as a list for students to select as their assignment. In contrast, a newly created assignment that is linked to a user, which happens when a student enters an article title directly rather than selecting from the Available Articles list, does not start as an Available Article. Those two situations are what the flag should keep track of: whether a new Assignment started as Available Article or not.

I think feature specs should be extended to test for the new behavior. One should test for the presence of the flag when an instructor adds an Available Article, and the absence when a student adds an assigned article directly. Another should test for a student claiming and then unclaiming an assignment, verifying that the article returns to the Available list. These might be possible to test via adjusting or extending existing tests that interact with assignment features, such as my_articles_spec.rb and instructor_role_spec.rb

@shishiro26
Copy link
Contributor Author

Thank you for the clarification. I realized I had overlooked this situation earlier. When adding assignments, I mistakenly assumed they were directly linked to articles rather than being part of the assignments workflow. Upon reviewing, I noticed that when adding an available_article, the user_id is set to nil and it gets added to the assignments. I’ll address this issue and ensure the flags are set correctly to distinguish between "Available Articles" and directly assigned articles.

Additionally, I’ll review and update the tests to align with the expected behavior. I now have a clearer understanding of the logic, but I’ll double-check the code and adjust or extend the relevant tests before committing the changes.

@shishiro26 shishiro26 marked this pull request as ready for review January 9, 2025 19:34
@shishiro26
Copy link
Contributor Author

I've also updated the test cases to reflect these scenarios. However, I am unsure if I should update the flags in the create_assignment within the assignment_controller_spec.rb. Could you clarify this?

@ragesoss
Copy link
Member

ragesoss commented Jan 9, 2025

I am unsure if I should update the flags in the create_assignment within the assignment_controller_spec.rb. Could you clarify this?

I'm not sure what you're referring to here; I don't see create_assignment in that spec. However, it would make sense to ensure that spec tests the creation of assignment both with and without a user, and verify the flag is present as expected in the case of creating an assignment without a user. I think that both adding Available Articles and adding user-assigned Assignments both go through the #create method of that controller.

@shishiro26
Copy link
Contributor Author

shishiro26 commented Jan 10, 2025

I've only added the test for available articles, while the tests for user-assigned assignments are already present and not covered in this test, sir. Also, the assigned_articles_spec.rb was running successfully on my local machine, sir.

@shishiro26
Copy link
Contributor Author

Could you please take a look at this, @ragesoss?

@ragesoss
Copy link
Member

@shishiro26 it's on my todo list, but I likely won't be able to review it until next week. @Abishekcs: if you're interested in having a look, I think your feedback would be helpful in the meantime.

@Abishekcs
Copy link
Contributor

@shishiro26 it's on my todo list, but I likely won't be able to review it until next week. @Abishekcs: if you're interested in having a look, I think your feedback would be helpful in the meantime.

Sure, I will look into it.😄

@Abishekcs
Copy link
Contributor

Open questions and concerns

With this change, when removing an article, a dialog appears with the message: "Are you sure you want to delete this program?"

  • Do we need to modify the dialog message to reflect the new functionality?

How about adding a "notification message" after successfully unclaiming an assignment that belonged to available articles?

By dispatching an ADD_NOTIFICATION action in the unclaimAssignment thunk. This way, the one who removes the article will be clearly notified if an article has been returned to the available pool and don't always have to check the if the article was successfully added back to the available articles.

@shishiro26
Copy link
Contributor Author

I believe this new implementation works well. When an assignment is unclaimed, it won't display any dialog box or confirmation message. Instead, it will directly unclaim the assignment and show a notification.
image

@Abishekcs
Copy link
Contributor

Abishekcs commented Jan 16, 2025

I believe this new implementation works well. When an assignment is unclaimed, it won't display any dialog box or confirmation message. Instead, it will directly unclaim the assignment and show a notification.
image

Probably should keep the existing dialog box and confirmation message. Just add the Notification(that is for the article that is removed and belongs to available article section) after the user has confirmed his choice.

@@ -33,8 +33,15 @@ const isClassroomProgram = course => (course.type === 'ClassroomProgramCourse');
const unassign = ({ assignment, course, dispatch }) => {
const body = { course_slug: course.slug, ...assignment };
const confirmMessage = I18n.t('assignments.confirm_deletion');
const successNotification = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Moving the successNotification definition inside the unclaimAssignment function would be better. Since this notification is specifically tied to the success state of unclaiming an article, it makes more sense to define it within the function itself rather than passing it as a parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but I noticed that in other parts of the code, the notification is also being sent as a parameter. So, I kept it that way and did not change it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but I noticed that in other parts of the code, the notification is also being sent as a parameter. So, I kept it that way and did not change it.

ohh but still it would be nice to move as much as logic to redux the less parameter to pass better.

export const unclaimAssignment = (assignment, successNotification) => (dispatch) => {
return API.unclaimAssignment(assignment)
.then((resp) => {
if (resp.assignment) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally, I am not sure but using assignment to check for successful unclaim may not be the most reliable indicator. Instead, consider using flags or checking if user_id is null/undefined, as these would more explicitly confirm that the article was successfully unclaimed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yuppp

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.

3 participants