def create_gradable_solution(*,
task: CompetitionTask,
participant: CompetitionParticipant,
code: str=None,
file: BinaryIO=None) -> Solution:
if code is not None and file is not None:
raise ValidationError("Provide either code or a file, not both!")
if code is None and file is None:
raise ValidationError("Provide either code or a file!")
if not CompetitionTest.objects.filter(task=task).exists():
raise ValidationError("This task does not have tests yet")
if code is not None:
new_solution = Solution.objects.create(
task=task,
participant=participant,
code=code,
status=6
)
if file is not None:
new_solution = Solution.objects.create(
task=task,
participant=participant,
file=file,
status=6
)
return new_solution
评论列表
文章目录