Skip to content

Commit

Permalink
Fix the exercise configure files output in container|i18n mounts
Browse files Browse the repository at this point in the history
The submit directive used to ignore the multilingual
`container|i18n` setting when it added the mount directories to
the configure files setting in the build output YAML.
  • Loading branch information
markkuriekkinen committed Jan 11, 2023
1 parent cccf56e commit 6b2de81
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
15 changes: 15 additions & 0 deletions directives/abstract_exercise.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
from typing import Any, Mapping
from urllib.parse import urlparse

from docutils.parsers.rst import Directive, directives
Expand Down Expand Up @@ -69,6 +70,20 @@ def set_assistant_permissions(self, data):
if 'allow-assistant-viewing' in self.options:
data['allow_assistant_viewing'] = str_to_bool(self.options['allow-assistant-viewing'])

def set_configure_files_from_container(
self,
configure_files: Mapping[str, str],
container: Mapping[str, Any],
) -> None:
mount: str = container.get("mount")
mounts: dict = container.get("mounts")
if mount:
configure_files[mount] = mount
if mounts:
for path_in_repo, path_in_container in mounts.items():
configure_files[path_in_repo] = path_in_repo


class ConfigurableExercise(AbstractExercise):
option_spec = {
'configure-url': directives.unchanged,
Expand Down
10 changes: 5 additions & 5 deletions directives/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ def run(self):

configure_files = {}
if "container" in data and isinstance(data["container"], dict):
if "mount" in data["container"]:
configure_files[data["container"]["mount"]] = data["container"]["mount"]
if "mounts" in data["container"]:
for path_in_repo, path_in_container in data["container"]["mounts"].items():
configure_files[path_in_repo] = path_in_repo
self.set_configure_files_from_container(configure_files, data["container"])
elif "container|i18n" in data and isinstance(data["container|i18n"], dict):
for lang, lcontainer in data["container|i18n"].items():
self.set_configure_files_from_container(configure_files, lcontainer)

if "template" in data:
configure_files[data["template"]] = data["template"]
if "feedback_template" in data:
Expand Down

0 comments on commit 6b2de81

Please sign in to comment.