Skip to content

The purpose of this script is to generate a library with multiple containers and components linked each other to create large hierarchies.

License

Notifications You must be signed in to change notification settings

open-craft/large-library-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Large Library Sample

Generate a large library sample

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. 1 Test Organizations will be created.
  2. 1 Content Library will be created in the organization.
    • Update LIBRARY_NAME and LIBRARY_SLUG depending on your needs.
  3. 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. Use COMPONENT_TYPES to configure the types of components to be created. These types are assigned randomly.
  4. 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 is 0.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.
  5. Optional Update random.seed value to get predictable results.

Getting Started

  1. 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
  1. Set the USER_EMAIL variable in generate.py to the user the courses/units will be created under. It defaults to [email protected].
  2. 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

Notes

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

Delete library script

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

About

The purpose of this script is to generate a library with multiple containers and components linked each other to create large hierarchies.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages