Skip to content

Commit

Permalink
feat!: default importdemocourse to the new course & lib
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Jan 10, 2024
1 parent 8cab65d commit 0733b74
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.d/20240110_101228_kyle_importnewdemocourse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- 💥 [Feature] `tutor local do importdemocourse` will now import the new [Open edX Demo Course](https://github.com/openedx/openedx-demo-course), which has been rebuilt from scratch, as well as its new accompanying Demo Content Library. If you wish to import the old demo course instead (which no longer receives updates), you can run: `tutor local do importdemocourse -d . -v open-release/palm.4`.
49 changes: 38 additions & 11 deletions tutor/commands/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,37 +120,64 @@ def create_user_template(
"""


@click.command(help="Import the demo course")
@click.command(help="Import the demo course and content library")
@click.option(
"-r",
"--repo",
default="https://github.com/openedx/edx-demo-course",
default="https://github.com/openedx/openedx-demo-course",
show_default=True,
help="Git repository that contains the course to be imported",
)
@click.option(
"-d",
"--repo-dir",
default="",
default="demo-course/course",
show_default=True,
help="Git relative subdirectory to import data from",
help="Git relative subdirectory to import course data from",
)
@click.option(
"-l",
"--library-tar",
default="dist/demo-content-library.tar.gz",
show_default=True,
help="Git relative .tar.gz path to import content library from"
)
@click.option(
"-L",
"--library-owner",
show_default=True,
help="Name of Open edX user who will own the library. If omitted, library import will be skipped."
)
@click.option(
"-v",
"--version",
help="Git branch, tag or sha1 identifier. If unspecified, will default to the value of the OPENEDX_COMMON_VERSION setting.",
)
def importdemocourse(
repo: str, repo_dir: str, version: t.Optional[str]
repo: str, repo_dir: str, library_tar: str, library_owner: t.Optional[str], version: t.Optional[str]
) -> t.Iterable[tuple[str, str]]:
version = version or "{{ OPENEDX_COMMON_VERSION }}"
template = f"""
# Import demo course
git clone {repo} --branch {version} --depth 1 /tmp/course
python ./manage.py cms import ../data /tmp/course/{repo_dir}
template = f"git clone {repo} --branch {version} --depth 1 /tmp/course"
if library_owner:
template += f"\n./manage.py cms import_content_library ../data/{library_tar} /temp/course/{library_tar}"
else:
template += "\necho 'WARNING: Skipped demo library import because --library-owner was not provided.'"
template += f"\npython ./manage.py cms import ../data /tmp/course/{repo_dir}"
template += f"\n./manage.py cms reindex_course --all --setup"
yield ("cms", template)

# Re-index courses
./manage.py cms reindex_course --all --setup"""

def importnewdemocourse(
repo: str, repo_dir: str, library_tar: str, library_owner: t.Optional[str], version: t.Optional[str]
) -> t.Iterable[tuple[str, str]]:
version = version or "main" # In Redwood, this should become {{ OPENEDX_COMMON_VERSION }}
template = f"git clone {repo} --branch {version} --depth 1 /tmp/course"
if library_owner:
template += f"\n./manage.py cms import_content_library ../data/{library_tar} /temp/course/{library_tar}"
else:
template += "\necho 'WARNING: Skipped demo library import because --library-owner was not provided.'"
template += f"\npython ./manage.py cms import ../data /tmp/course/{repo_dir}"
template += f"\n./manage.py cms reindex_course --all --setup"
yield ("cms", template)


Expand Down

0 comments on commit 0733b74

Please sign in to comment.