bugfix remove course pre requisite only if is not entrance exam - #22529
Conversation
|
Thanks for the pull request, @melvinsoft! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
|
jenkins run all |
|
@melvinsoft Thank you for your contribution, please let me know once all tests are green. |
OmarIthawi
left a comment
There was a problem hiding this comment.
Thanks Maxi! I've added some minor changes. Please let me know whenever this is ready for review again.
| course_milestones = milestones_api.get_course_milestones(course_key=course_key, relationship="requires") | ||
| for milestone in course_milestones: | ||
| remove_prerequisite_course(course_key, milestone) | ||
| ee_milestone_namespace = generate_milestone_namespace( |
There was a problem hiding this comment.
ee is not immediately clear. Please refactor as suggested below 👇
|
jenkins run all |
3 similar comments
|
jenkins run all |
|
jenkins run all |
|
jenkins run all |
529907a to
01fa77f
Compare
|
jenkins run all |
1 similar comment
|
jenkins run all |
|
@melvinsoft Can you please check the failing tests? |
01fa77f to
fcffb2e
Compare
|
Thanks Natalia for the ping. @melvinsoft I've rebased the branch meanwhile hoping the Jenkins tests will be a bit better, |
|
@natabene Thanks for reaching out, and thanks @OmarIthawi I hope test are better now after the rebase, if not we'll take care of the errors. |
|
jenkins run all |
|
@melvinsoft I've fixed all of the quality checks that I can fix, please check the second commit to see what I have done. There's only one that I couldn't fix quickly, which is @natabene We could use the reviewer advice on how to refactor the code to avoid nested |
|
@OmarIthawi Sure, I will line this up. |
|
@OmarIthawi Thank you for the changes, and thanks for helping moving this PR along. |
|
jenkins run all |
|
@natabene Looks like all checks have passed now! @OmarIthawi Thanks for pylint fixes! |
|
@melvinsoft Sorry for delay, this is good to go now from CLA perspective. The check is green. |
|
Who can take it over the finish line and merge (once ready)? |
|
I can review @natabene |
|
Thanks @mariajgrimaldi and @natabene. The PR should be ready for review and merge. @shadinaif would you mind confirm that? |
|
Let me know! @shadinaif @OmarIthawi |
There was a problem hiding this comment.
Agreed. It'd more clear if you use entrance_exam_namespace or something similar. Also, can you add a substantial comment explaining why you're adding this change? In case there's a similar issue in the future
There was a problem hiding this comment.
And that makes me wonder, do you think there are other milestones that this piece of code could remove? or just entrance exam?
There was a problem hiding this comment.
| if not milestone["namespace"] == ee_milestone_namespace: | |
| if milestone["namespace"] != ee_milestone_namespace: |
|
Hello! Any updates here? |
6193915 to
4ce975c
Compare
|
Thanks @mariajgrimaldi for the reminder |
4ce975c to
76e724c
Compare
| assert milestones_helpers.any_unfulfilled_milestones(self.course.id, self.user.id), \ | ||
| 'The entrance exam should be required.' | ||
|
|
||
| data_date = { | ||
| 'entrance_exam_enabled': 'true', | ||
| 'entrance_exam_minimum_score_pct': '60', | ||
| 'syllabus': 'none', | ||
| 'short_description': 'empty', | ||
| 'overview': '', | ||
| 'effort': '', | ||
| 'intro_video': '', | ||
| 'start_date': '2018-01-01', | ||
| 'end_date': '{year}-12-31'.format(year=datetime.datetime.now().year + 4), | ||
| } | ||
| response = self.client.post( | ||
| settings_details_url, | ||
| data=json.dumps(data_date), | ||
| content_type='application/json', | ||
| HTTP_ACCEPT='application/json' | ||
| ) | ||
| assert response.status_code == 200 | ||
| assert milestones_helpers.any_unfulfilled_milestones(self.course.id, self.user.id), \ | ||
| 'The entrance exam should be required.' | ||
|
|
There was a problem hiding this comment.
Is this test duplicated? What changes from the 1st post call to the 2nd one? If it's just the date:
so we don't have to duplicate this, we could use the ddt library, something like this:
@ddt.data(
first_dict,
second_dict
)
def test_entrance_after_changing_other_setting(self, edit_course_data):
There was a problem hiding this comment.
Thank you for the review! it's not duplicated, we need to verify that saving new settings will not delete the entrance exam we set before. I've adjusted the code to show that
There was a problem hiding this comment.
Hello! I tested a before & after (attached here), and this is working as you described. Thank you so much. I'm happy with this but consider making the tests shorter as I mentioned in the comment (if this makes sense to you folks).
After creating a course, enabling the entrance exam and then updating the date in the course:

After doing the same but with the fix:

I have a question: How can people fix this without creating a new course? For me, it worked to turn off and on again the entrance exam.
|
@shadinaif: hello! Do these recommendations make sense to you? If not, please leave a comment explaining and I'll merge it since the implementation looks good to me. |
|
@shadinaif hello again! Please, refer to my previous comment so we can merge :) |
76e724c to
ef93b2e
Compare
See details in the related PR Update cms/djangoapps/contentstore/tests/test_course_settings.py Co-Authored-By: Omar Al-Ithawi <i@omardo.com> Update cms/djangoapps/contentstore/tests/test_course_settings.py Co-Authored-By: Omar Al-Ithawi <i@omardo.com>
Reformatting for an old code, no harm done
We've made a change in an old code. Pylint is not happy about that old code we don't need to refactor it now, lets just disable the error message for it
ef93b2e to
e68af88
Compare
|
@melvinsoft 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
|
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
|
EdX Release Notice: This PR has been deployed to the production environment. |
|
@mariajgrimaldi @natabene @shadinaif and @melvinsoft. Thank you so much for closing this bug fix! It's been a while since this was opened. Thanks for making it to the end 🎉 🎉 🎉 |
This is a bug fix for Entrance Exams management in Schedule & Details page.
The error is easy to reproduce:
You need to make sure that the following
FEATURESflags are enabled:When you go back to the LMS, you will find out that the entrance exam is disabled now, and you can see all the course content, but in the "Schedule and Details" is still active.
What happens in the background, is that there is a bug in the settings handlers that is there is any pre requisite course set, iterates over all pre requisites and deletes them, but the problem is Entrance Exams are a type of pre requisite since they belong to the milestones app, and is getting deleted too.
The fix check the milestone namespace, and if it's an Entrance Exam skips it.
Co-Authored-By: Omar Al-Ithawi i@omardo.com