Skip to content

show textbooks - #3618

Merged
abeglova merged 1 commit into
mainfrom
ab/show-textbooks
Jul 17, 2026
Merged

show textbooks#3618
abeglova merged 1 commit into
mainfrom
ab/show-textbooks

Conversation

@abeglova

@abeglova abeglova commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

closes https://github.com/mitodl/hq/issues/12337

Description (What does it do?)

OCW textbooks are ready to be made visible to all users in production. We want to create them regardless of CREATE_OCW_LEARNING_MATERIALS and show them in the main search without requiring show_ocw_files=true.

How can this be tested?

Set CREATE_HIDDEN_OCW_LEARNING_MATERIALS=True

Run
docker-compose run web ./manage.py backpopulate_ocw_data --course-name 6-011-introduction-to-communication-control-and-signal-processing-spring-2010

go to http://open.odl.local:8062/search?resource_type_group=learning_material. You should see "Open Textbook" as an option

go to http://open.odl.local:8062/search?resource_type_group=learning_material&show_ocw_files=true You should also see "Practice and Assignment"

Set CREATE_HIDDEN_OCW_LEARNING_MATERIALS=False

Run
docker-compose run web ./manage.py update_ocw_learning_material_resources

go to http://open.odl.local:8062/search?resource_type_group=learning_material. You should still see "Open Textbook" as an option

go to http://open.odl.local:8062/search?resource_type_group=learning_material&show_ocw_files=true You should no longer see "Practice and Assignment"

run
docker-compose run web ./manage.py backpopulate_ocw_data --course-name 6-011-introduction-to-communication-control-and-signal-processing-spring-2010

search should not change

Set CREATE_HIDDEN_OCW_LEARNING_MATERIALS=True again

Run
docker-compose run web ./manage.py update_ocw_learning_material_resources

Go to
go to http://open.odl.local:8062/search?resource_type_group=learning_material&show_ocw_files=true You should see "Practice and Assignment" again

@github-actions

github-actions Bot commented Jul 15, 2026

Copy link
Copy Markdown

OpenAPI Changes

No changes detected

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@abeglova
abeglova marked this pull request as ready for review July 15, 2026 14:46
Copilot AI review requested due to automatic review settings July 15, 2026 14:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the OCW “learning materials” ingestion and search behavior so that OCW Open Textbooks are created and surfaced by default, while other OCW learning-material file types remain gated behind a new “hidden materials” feature flag.

Changes:

  • Always run OCW learning-material promotion, but only promote Open Textbooks by default; promote additional OCW categories only when CREATE_HIDDEN_OCW_LEARNING_MATERIALS=True.
  • Update OCW ETL fixtures/tests to include a textbook content file and validate the resulting learning-material resources.
  • Adjust search filtering so that OCW Open Textbooks are included even when show_ocw_files is false.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test_json/courses/16-01-unified-engineering-i-ii-iii-iv-fall-2005-spring-2006/resources/textbook/data.json Adds OCW fixture data for a textbook resource.
main/settings.py Replaces prior flag with CREATE_HIDDEN_OCW_LEARNING_MATERIALS for hidden OCW learning materials.
learning_resources/tasks.py Removes the “flag disabled” runtime guard so the task can run unconditionally.
learning_resources/tasks_test.py Updates task test to match unconditionally-running behavior.
learning_resources/etl/pipelines.py Always calls load_learning_materials during OCW ETL.
learning_resources/etl/pipelines_test.py Updates ETL expectations for new textbook file and hidden-material flag behavior.
learning_resources/etl/ocw_test.py Updates OCW content-file transform expectations to include textbook fixture.
learning_resources/etl/loaders.py Changes learning-material promotion logic to allow textbooks by default and gate additional categories behind the new flag.
learning_resources/etl/loaders_test.py Updates promotion tests for new flag/behavior.
learning_resources/constants.py Introduces the “visible” OCW categories list used when hidden materials are disabled.
learning_resources_search/api.py Includes Open Textbooks in results when show_ocw_files is false.
learning_resources_search/api_test.py Updates search filter-clause test expectations accordingly.

Comment thread learning_resources/etl/ocw_test.py Outdated
Comment thread main/settings.py
Comment on lines +1081 to 1085
if settings.CREATE_HIDDEN_OCW_LEARNING_MATERIALS:
promoted_ocw_file_types = set(OCW_COURSE_CONTENT_CATEGORY_MAPPING.keys())
else:
promoted_ocw_file_types = set(OCW_VISIBLE_CATEGORIES)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment thread learning_resources/constants.py Outdated
Comment thread learning_resources/etl/loaders_test.py
@mbertrand mbertrand self-assigned this Jul 16, 2026
Comment on lines 389 to 391
for course in LearningResource.objects.filter(
published=True, etl_source=ETLSource.ocw.name, resource_type="course"
):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this task is now the mechanism for rolling hidden materials out (and back) in production, it could use a guard for a published course that has no published run — in that case course_run ends up as None and the error on the next line stops the loop for all remaining courses (it happens before the try/except). Something like if not course_run: continue, or moving these lines inside the try, would keep one bad course from halting the whole run.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread learning_resources/etl/pipelines.py Outdated

if settings.CREATE_OCW_LEARNING_MATERIALS:
loaders.load_learning_materials(course_run, content_file_ids)
loaders.load_learning_materials(course_run, content_file_ids)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now that this runs unconditionally, there's a case that used to be gated off: when load_content_files takes its "preserving existing content files" path and returns an empty list, this call will still run and clear all of the course's learning-material relationships at the end (resources.set([])), even though the promoted resources stay published. Wrapping this in if content_file_ids: would keep the preserve behavior intact.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@mbertrand mbertrand left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@abeglova
abeglova force-pushed the ab/show-textbooks branch from 1860694 to af4a492 Compare July 17, 2026 14:13
@abeglova abeglova changed the title Ab/show textbooks show textbooks Jul 17, 2026
@abeglova
abeglova merged commit 0dc6670 into main Jul 17, 2026
13 checks passed
@abeglova
abeglova deleted the ab/show-textbooks branch July 17, 2026 15:28
@odlbot odlbot mentioned this pull request Jul 20, 2026
12 tasks
mbertrand pushed a commit that referenced this pull request Jul 22, 2026
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