def compare_code_solutions(first_solution, second_solution):
current_code = first_solution.code.splitlines()
next_code = second_solution.code.splitlines()
diff_percentage, unified_diff = calculate_difference_percentage(current_code, next_code)
result = ""
if diff_percentage < MIN_ALLOWED_DIFFERENCE_PERCENTAGE:
result = f"""
Matching contents in solutions
{first_solution} from {first_solution.student.email} and
{second_solution} from {second_solution.student.email}
on task {first_solution.task.name}
--------------------------------------------
Differences: {diff_percentage}%\n
"""
for line in unified_diff:
result += line + '\n'
return result
评论列表
文章目录