Fixing any_unfulfilled_milestones in mobile course_enrollments API - #280
Conversation
509b9e5 to
b37e736
Compare
Salomari1987
left a comment
There was a problem hiding this comment.
I think this calls for an OSPR, please contribute it to edX and cherry pick
|
|
||
| from milestones import api as milestones_api | ||
| fulfillment_paths = milestones_api.get_course_milestones_fulfillment_paths(course_id, {'id': user_id}) | ||
|
|
There was a problem hiding this comment.
Just one comment, why not use the function in this file: get_course_milestones_fulfillment_paths ?
I see in some functions the milestones_api.get_course_..... is being used, and only in one function the get_course_milestones_fulfillment_paths in the file is being used. I do not see the difference in the result on one hand, and I do not see why from milestones import api as milestones_api has to be used many times?
There was a problem hiding this comment.
The other methods are using the API gateway, so I prefer keeping it like this. In the same hand, the get_course_milestones_fulfillment_paths function is rechecking the feature flag again, a reason that tells not call it.
Let's wait for edX's review and see. But we still need to know the status of the changes if we need had to merge this before edX do.
|
@AhmedAljazzar ping |
|
@Salomari1987 pong. |
|
@AhmedAljazzar this works fine as expected, however when tried for course prerequisites, the has_access field will become false for the nonsuperuser. Please fix it also for course prerequisites. |
|
and rebase |
b37e736 to
7b668bf
Compare
|
@Salomari1987 Done :) |
0641d0e to
b84b304
Compare
b84b304 to
f67df39
Compare
857ceca to
f67df39
Compare
|
@Salomari1987, @halawa : This needs approval if you have time. |
|
I'll take it! |
|
Great! |
OmarIthawi
left a comment
There was a problem hiding this comment.
Smoke tested it and it works. The code looks fine although I haven't tested it rigorously.
Description
In User Course Enrollments List, if we enabled Entrance Exam from Schedule & Details section and then re-desabling it, the
courseware_accessfield in the API will keep preventing the student from showing the course on the mobile apps.This problem is happening because the
get_course_milestones_fulfillment_pathsmethod in the milestones API is returning an empty dictionary{}if the course doesn't have any milestones, after enabling Entrance Exam it returns a complex dict-of-dicts like this:{ "course-v1:org+course+run.entrance_exams.Completed Course Entrance Exam": { "content": [ "block-v1:org+course+run+type@chapter+block@cd5f1b8bef874bcdad80b2857f5aeffd" ] } }While redoubling the entrance exam causes the method to return the previously-enabled prerequisites with an empty dictionary like this:
{"course-v1:org+course+run.entrance_exams.Completed Course Entrance Exam": {}}The method
any_unfulfilled_milestonesis not addressing this scenario, so what I did is checking that every value in the dict returned fromget_course_milestones_fulfillment_paths, if any value has a non-empty dictionary then the student is still having unfulfilled milestones and we are returningTrue, if the dictionary is empty or the student have fulfilled the milestones then we are returningFalse.Notes
get_course_milestones_fulfillment_pathswill return an empty dictionary if the Entrance Exam fulfilled.Update
Another issue arised as if the instructor enabled and disabled the Prerequisite Course in Studio's Requirements section, the course became inaccessible for learner in the dashboard and the API views.
This happens because selecting None from the dropdown list in Studio has no functionality in the code.