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

Adding course topics #2210

Merged
merged 13 commits into from
May 28, 2024
Merged

Adding course topics #2210

merged 13 commits into from
May 28, 2024

Conversation

annagav
Copy link
Contributor

@annagav annagav commented May 15, 2024

What are the relevant tickets?

Fix https://github.com/mitodl/hq/issues/4110

Description (What does it do?)

Adding topics in MITx Online.
The ability to create delete topics through the cms, and add them to courses.

Populates topics with existing department names. I don't think it is necessary, but this is how it was done in mitxpro. And I think it is nice to have some topics to begin with.

Screenshots (if appropriate):

Screenshot 2024-05-16 at 8 53 26 AM

How can this be tested?

Run migrations
Run the app, go to the cms and make sure you can see Course Topics.
Click on it and try to add or delete a course topic.

Go to Course page add topic to a course page.

Also view http://mitxonline.odl.local:8013/api/v2/parent_course_topics/

@annagav annagav force-pushed the ag/add_topics branch 2 times, most recently from 67bc5aa to 7720306 Compare May 16, 2024 12:52
@annagav annagav marked this pull request as ready for review May 16, 2024 12:53
@collinpreston collinpreston self-assigned this May 20, 2024
@collinpreston
Copy link
Contributor

@annagav hey, my fault, but I think you will need to update this branch from main in order for the application to properly load. Related to: #2213

@annagav annagav force-pushed the ag/add_topics branch 2 times, most recently from f4aa3e8 to a2b0ea8 Compare May 21, 2024 14:58

def parent_topics_with_annotated_course_counts(self):
"""
Returns parent course topics with annotated course counts including the child topic course counts as well.
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to specify that the course counts are based on filtering defined in get_catalog_course_filter.

courses/utils.py Outdated
@@ -166,3 +166,27 @@ def get_unenrollable_courses(queryset):
.filter(courseruns__id__in=courseruns_qs.values_list("id", flat=True))
.distinct()
)


def get_catalog_course_filter(relative_filter=""):
Copy link
Contributor

@collinpreston collinpreston May 21, 2024

Choose a reason for hiding this comment

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

Do the filters in this method align with the filters on our catalog page?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure. Maybe the start date is irrelevant, since we show archived courses. What do you think?

Copy link
Contributor Author

@annagav annagav May 21, 2024

Choose a reason for hiding this comment

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

So it looks like this is the place where courses get filtered for the catalog class CourseFilterSet.
The main criteria is_live and is_enrollable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know what defines "is_enrollable" in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to try and reuse whatever filtering already exists. It's not realistic to assume that a developer will update this method when updating the filtering logic within CourseFilterSet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I looked into a bit, and In order to reuse the the existing filtering I would need to refactor a bunch of existing code, and might introduce a bug. I think it would be better to do that refactor in a separate PR, and test it thoroughly.

@pdpinch
Copy link
Member

pdpinch commented May 21, 2024

Can we pre-populate the topics with the ones from this spreadsheet: https://docs.google.com/spreadsheets/d/1Euu4ezPKeYkiTThvmxB5vFONFNG4fOULNW42F6qLuFI/edit?pli=1#gid=431773359

@annagav
Copy link
Contributor Author

annagav commented May 21, 2024

Can we pre-populate the topics with the ones from this spreadsheet: https://docs.google.com/spreadsheets/d/1Euu4ezPKeYkiTThvmxB5vFONFNG4fOULNW42F6qLuFI/edit?pli=1#gid=431773359

Should the first row be included?

@pdpinch
Copy link
Member

pdpinch commented May 21, 2024

Yeah, it's a hierarchy. The first row are the top-level topics. The other ones are children.

@annagav annagav force-pushed the ag/add_topics branch 2 times, most recently from 9432946 to f502aa8 Compare May 22, 2024 13:37
@annagav
Copy link
Contributor Author

annagav commented May 22, 2024

@collinpreston make sure reverse all three migrations before checking out the changes:
./manage.py migrate cms 0035
./manage.py migrate courses 0050

Copy link
Contributor

@collinpreston collinpreston left a comment

Choose a reason for hiding this comment

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

Looks good. I would just check whether Programs should also have Topics.

@annagav
Copy link
Contributor Author

annagav commented May 23, 2024

Looks good. I would just check whether Programs should also have Topics.

Following the example in xpro, no programs don't have topics.

@annagav annagav merged commit 0f7d16b into main May 28, 2024
7 checks passed
@annagav annagav deleted the ag/add_topics branch May 28, 2024 15:36
@odlbot odlbot mentioned this pull request May 28, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants