Skip to content

Conversation

@samuelallan72
Copy link
Member

@samuelallan72 samuelallan72 commented Nov 14, 2025

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
@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
Copy link
Member

@pkulkark pkulkark left a comment

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
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