Skip to content

Commit

Permalink
Add has_submittable_files to the exercises API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jaakkonakaza authored and ihalaij1 committed May 7, 2024
1 parent ce46d6f commit 8ffafea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions course/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def __recurse_exercises(
'max_submissions': child.max_submissions,
'hierarchical_name': child.hierarchical_name,
'difficulty': child.difficulty,
'has_submittable_files': child.has_submittable_files,
}
exercises.append(exercise_dictionary)

Expand Down
10 changes: 10 additions & 0 deletions exercise/cache/basetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class LearningObjectEntryBase(LearningObjectProto, CacheBase, EqById, Generic[Mo
submittable: bool
grading_mode: Optional[int]
model_answer_modules: List[ModuleEntry]
has_submittable_files: bool

@property
def course_module(self):
Expand Down Expand Up @@ -269,11 +270,20 @@ def _generate_data(

category = lobj.category

exercise_info = lobj.exercise_info
has_submittable_files = (
exercise_info
and exercise_info['form_spec']
and isinstance(exercise_info['form_spec'], list)
and any(map(lambda item: item.get('type') == 'file', exercise_info['form_spec']))
)

self.module = precreated.get_or_create_proxy(ModuleEntryBase, module.id)
if lobj.parent_id is None:
self.parent = None
else:
self.parent = precreated.get_or_create_proxy(LearningObjectEntryBase, lobj.parent_id)
self.has_submittable_files = has_submittable_files
self.category = str(category)
self.category_id = category.id
self.category_status = category.status
Expand Down

0 comments on commit 8ffafea

Please sign in to comment.