from books.models import Module
from users.models import User


def are_solutions_enabled_for(user: User, module: Module):
    school_class = user.selected_class
    return module.solutions_enabled_for.filter(pk=school_class.pk).exists()


def get_type_and_value(data):
    if isinstance(data, tuple):
        return data[0], data[1]
    else:
        return data['type'], data['value']
