The purpose of this script is to generate a library with multiple containers and components linked each other to create large hierarchies.
Running this script will do the following:
- 1 Test Organizations will be created.
- 1 Content Library will be created in the organization.
- Update
LIBRARY_NAME
andLIBRARY_SLUG
depending on your needs.
- Update
- Container and components will be created depending on the configuration:
SECTION_COUNT
: Number of sections to be created.SUBSECTION_COUNT
: Number of subsections to be created.UNIT_COUNT
: Number of units to be created.COMPONENT_COUNT
: Number of components to be created. UseCOMPONENT_TYPES
to configure the types of components to be created. These types are assigned randomly.
- Adds subsections in sections, units in subsections and components in units, depending on the configuration:
- The link rate represents how many containers the object will be linked to, for example, if the link rate is
1
for subsections, then all the subsections will be linked to all the sections. If the link rate is0.5
, then each subsection will be linked to the half of the sections selected randomly. SUBSECTION_LINK_RATE
: Link rate for link subsections to sections.UNIT_LINK_RATE
: Link rate for link units to subsections.COMPONENT_LINK_RATE
: Link rate for link components to units.
- The link rate represents how many containers the object will be linked to, for example, if the link rate is
- Optional Update random.seed value to get predictable results.
- To begin, clone this repo to your host computer and mount it in Tutor using this command.
tutor mounts add cms:/host/path/to/large-library-sample:/openedx/large-library-sample
- Set the
USER_EMAIL
variable ingenerate.py
to the user the courses/units will be created under. It defaults to[email protected]
. - To run the script, enter the CMS shell (
tutor dev run cms bash
) and run the following command:python manage.py cms shell < /openedx/large-library-sample/generate.py
- The resulting library may be completely different from another generated by the same script and the same configuration.
- With current settings the script may take ~15min to run. This is because in update_container_children, the part where events are sent takes too long to execute. The function isn't implemented to update a large number of children. I decided to leave it like this because the only use case for multiple children is this script, and this script is only intended to run when needed in test environments.
A helper script to delete any v2 library. Update library_key
value to the library key that you want to be deleted.
To run the script, enter the CMS shell (tutor dev run cms bash
) and run the following command:
python manage.py cms shell < /openedx/large-library-sample/delete_library_v2.py