Skip to content

Commit a3443f6

Browse files
committed
Send course personalized exercises dir to grader
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.
1 parent ced2c56 commit a3443f6

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

builder/configure.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
import json
33
from json.decoder import JSONDecodeError
44
import logging
5+
import os
56
from pathlib import Path
67
from tempfile import TemporaryFile
78
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
89
from tarfile import PAX_FORMAT, TarFile
910

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

153+
personalized_exercises_path = os.path.join(config.dir, settings.PERSONALIZED_CONTENT_DIR)
154+
personalized_exercises_path_exists = os.path.isdir(personalized_exercises_path)
151155
files = chain.from_iterable((
152156
course_files.items(),
153157
*(
154158
exercise.configure.files.items()
155159
for exercise in exercises
156-
)
160+
),
161+
[
162+
(
163+
settings.PERSONALIZED_CONTENT_DIR,
164+
settings.PERSONALIZED_CONTENT_DIR
165+
)
166+
] if personalized_exercises_path_exists else [],
157167
))
158168

159169
response, error = configure_url(url, course_id, course_key, config.dir, files, course_spec=course_spec, exercises=exercise_data, version_id=config.version_id)

gitmanager/settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@
206206
# Extra options applied to all git commands
207207
GIT_OPTIONS = []
208208

209+
# Personalized exercises are kept in this directory (relative to the course git repository root).
210+
# This value should be identical to the value of settings.PERSONALIZED_CONTENT_DIR in MOOC-Grader.
211+
PERSONALIZED_CONTENT_DIR = 'personalized_exercises'
212+
209213
# Location of test files
210214
TESTDATADIR = "test_data"
211215

0 commit comments

Comments
 (0)