Skip to content

Commit

Permalink
Send course personalized exercises dir to grader
Browse files Browse the repository at this point in the history
If the personalized exercise instances are generated
to the course Git repository by course staff, send the
personalized_exercises directory to MOOC-Grader when
configuring the grader.
  • Loading branch information
ihalaij1 committed Jan 19, 2024
1 parent ced2c56 commit a3443f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion builder/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
import json
from json.decoder import JSONDecodeError
import logging
import os
from pathlib import Path
from tempfile import TemporaryFile
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
from tarfile import PAX_FORMAT, TarFile

from aplus_auth.payload import Permission, Permissions
from aplus_auth.requests import RemoteTokenError, Session
from django.conf import settings
from requests.models import Response
from requests.packages.urllib3.util.retry import Retry
from requests.sessions import HTTPAdapter
Expand Down Expand Up @@ -148,12 +150,20 @@ def configure_graders(config: CourseConfig) -> Tuple[Dict[str, Any], List[Union[
"files": list(exercise.configure.files.keys()),
})

personalized_exercises_path = os.path.join(config.dir, settings.PERSONALIZED_CONTENT_DIR)
personalized_exercises_path_exists = os.path.isdir(personalized_exercises_path)
files = chain.from_iterable((
course_files.items(),
*(
exercise.configure.files.items()
for exercise in exercises
)
),
[
(
settings.PERSONALIZED_CONTENT_DIR,
settings.PERSONALIZED_CONTENT_DIR
)
] if personalized_exercises_path_exists else [],
))

response, error = configure_url(url, course_id, course_key, config.dir, files, course_spec=course_spec, exercises=exercise_data, version_id=config.version_id)
Expand Down
4 changes: 4 additions & 0 deletions gitmanager/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@
# Extra options applied to all git commands
GIT_OPTIONS = []

# Personalized exercises are kept in this directory (relative to the course git repository root).
# This value should be identical to the value of settings.PERSONALIZED_CONTENT_DIR in MOOC-Grader.
PERSONALIZED_CONTENT_DIR = 'personalized_exercises'

# Location of test files
TESTDATADIR = "test_data"

Expand Down

0 comments on commit a3443f6

Please sign in to comment.