Skip to content

Commit

Permalink
[common/tasks_problems] Fixing empty input leading to code block star…
Browse files Browse the repository at this point in the history
…ting at 0
  • Loading branch information
AlexandreDoneux committed Dec 8, 2023
1 parent 8ed921d commit b35cb77
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion inginious/common/tasks_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,17 @@ def input_is_consistent(self, task_input, default_allowed_extension, default_max
@classmethod
def parse_problem(self, problem_content):
# Checking problem edit inputs
if len(problem_content["offset"]) != 0:
if len(problem_content["offset"]) == 0:
problem_content["offset"] = 1
else:
try:
offset = int(problem_content["offset"])
if offset < 1:
raise Exception("Line offset must be positive!")
problem_content["offset"] = offset
except ValueError:
raise Exception("Line offset must be an integer!")

return Problem.parse_problem(problem_content)

@classmethod
Expand Down

0 comments on commit b35cb77

Please sign in to comment.