Skip to content

feat: Add a csv report of xblocks used in courses (redwood) - #794

Merged
samuelallan72 merged 1 commit into
opencraft-release/redwood.1from
samuel/xblock-list-csv-redwood
Dec 3, 2025
Merged

feat: Add a csv report of xblocks used in courses (redwood)#794
samuelallan72 merged 1 commit into
opencraft-release/redwood.1from
samuel/xblock-list-csv-redwood

Conversation

@samuelallan72

@samuelallan72 samuelallan72 commented Nov 14, 2025

Copy link
Copy Markdown
Member

Description

Add a management command for generating a csv report of xblocks used in courses.

Usage (with common management command help removed for clarity):

$ python manage.py lms xblock_list_csv --help
...
usage: manage.py xblock_list_csv [-h] [--exclude-core-xblocks] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color]
                                 [--force-color] [--skip-checks]
                                 filename

Generate a CSV file with all published components used in courses with their xblock type.

positional arguments:
  filename              Path to the CSV output file. Use '-' to print to stdout.

options:
  -h, --help            show this help message and exit
  --exclude-core-xblocks
                        Exclude components using core XBlocks: (html, problem, video). Default: false
...

Examples:

Print complete csv to stdout:

python manage.py lms xblock_list_csv - 

Save complete csv to components.csv:

python manage.py lms xblock_list_csv components.csv

Save csv excluding components using core xblocks to components.csv:

python manage.py lms xblock_list_csv --exclude-core-xblocks components.csv

Example csv output files:

components-excluded.csv
components.csv
components-stdout.csv

Supporting information

Private-ref: https://tasks.opencraft.com/browse/BB-10225

Testing instructions

  • deploy this branch to a redwood devstack
  • ensure there is a range of published course content across at least two courses on the devstack
  • start an lms shell: tutor dev exec lms -- bash
  • run python manage.py lms xblock_list_csv -
  • verify the csv data is printed to the console
  • run python manage.py lms xblock_list_csv components.csv
  • verify the csv data is saved to components.csv
  • run python manage.py lms xblock_list_csv - > components-stdout.csv
  • run diff components.csv components-stdout.csv and verify the diff is empty (to verify printing to stdout has the same report as writing to file)
  • verify components.csv contains rows as expected - check that all courses are included and the data makes sense
  • run python manage.py lms xblock_list_csv --exclude-core-xblocks components-excluded.csv
  • in components-excluded.csv, verify there are no rows for the core xblocks (html, problem, video)

@samuelallan72 samuelallan72 self-assigned this Nov 14, 2025
@samuelallan72 samuelallan72 changed the title feat: Add a csv report of xblocks used in courses feat: Add a csv report of xblocks used in courses (redwood port) Nov 14, 2025
Comment thread lms/djangoapps/instructor/views/api.py Outdated
Comment thread lms/djangoapps/instructor/views/api.py Outdated
Comment thread lms/djangoapps/instructor_task/tasks_helper/components.py Outdated
Comment thread lms/djangoapps/instructor_task/tasks_helper/components.py Outdated
@samuelallan72 samuelallan72 changed the title feat: Add a csv report of xblocks used in courses (redwood port) feat: Add a csv report of xblocks used in courses (redwood) Dec 2, 2025
This is added via an lms management command:

```
$ python manage.py lms xblock_list_csv --help
...
usage: manage.py xblock_list_csv [-h] [--exclude-core-xblocks] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color]
                                 [--force-color] [--skip-checks]
                                 filename

Generate a CSV file with all published components used in courses with their xblock type.

positional arguments:
  filename              Path to the CSV output file. Use '-' to print to stdout.

options:
  -h, --help            show this help message and exit
  --exclude-core-xblocks
                        Exclude components using core XBlocks: (html, problem, video). Default: false
...
```

Example usage:

```
python manage.py lms xblock_list_csv --exclude-core-xblocks components.csv
```

Private-ref: https://tasks.opencraft.com/browse/BB-10225
@samuelallan72
samuelallan72 force-pushed the samuel/xblock-list-csv-redwood branch from 4a9da3f to 70cc7ed Compare December 2, 2025 06:07
@samuelallan72
samuelallan72 marked this pull request as ready for review December 2, 2025 06:08

@pkulkark pkulkark 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.

LGTM 👍

  • I tested this: I couldn't get my devstack running but verified the generated reports are as expected.
  • I read through the code

@samuelallan72
samuelallan72 merged commit 0d4e82e into opencraft-release/redwood.1 Dec 3, 2025
16 of 75 checks passed
@samuelallan72
samuelallan72 deleted the samuel/xblock-list-csv-redwood branch December 3, 2025 00:11
samuelallan72 added a commit that referenced this pull request Jan 23, 2026
Also add docstring to keep pylint happy and add some type hints.

Relates to #794
samuelallan72 added a commit that referenced this pull request Jan 23, 2026
Also add docstring to keep pylint happy and add some type hints.

Relates to #794
samuelallan72 added a commit that referenced this pull request Jan 27, 2026
Also add docstring to keep pylint happy and add some type hints.

Relates to #794
Agrendalath pushed a commit that referenced this pull request Jan 27, 2026
Also add docstring to keep pylint happy and add some type hints.

Relates to #794
@samuelallan72

Copy link
Copy Markdown
Member Author

@pkulkark do we want this cherry picked to our shared ulmo or verawood release branch?

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