示例#1
0
def user_import_from_dict(cls, data, tasks_by_name):
    """Build the object using data from a dictionary.

    """
    data['messages'] = [
        Message.import_from_dict(message_data)
        for message_data in data['messages']
    ]
    data['questions'] = [
        Question.import_from_dict(question_data)
        for question_data in data['questions']
    ]
    data['submissions'] = [
        Submission.import_from_dict(submission_data,
                                    tasks_by_name=tasks_by_name)
        for submission_data in data['submissions']
    ]
    data['user_tests'] = [
        UserTest.import_from_dict(user_test_data, tasks_by_name=tasks_by_name)
        for user_test_data in data['user_tests']
    ]
    if 'starting_time' in data and data['starting_time'] is not None:
        data['starting_time'] = make_datetime(data['starting_time'])
    if 'extra_time' in data:
        data['extra_time'] = timedelta(seconds=data['extra_time'])
    obj = cls(**data)
    for submission in obj.submissions:
        submission.user = obj
    return obj
示例#2
0
def user_import_from_dict(cls, data, tasks_by_name):
    """Build the object using data from a dictionary.

    """
    data['messages'] = [Message.import_from_dict(message_data)
                        for message_data in data['messages']]
    data['questions'] = [Question.import_from_dict(question_data)
                         for question_data in data['questions']]
    data['submissions'] = [Submission.import_from_dict(
        submission_data, tasks_by_name=tasks_by_name)
                           for submission_data in data['submissions']]
    obj = cls(**data)
    for submission in obj.submissions:
        submission.user = obj
    return obj
示例#3
0
def user_import_from_dict(cls, data, tasks_by_name):
    """Build the object using data from a dictionary.

    """
    data['messages'] = [Message.import_from_dict(message_data)
                        for message_data in data['messages']]
    data['questions'] = [Question.import_from_dict(question_data)
                         for question_data in data['questions']]
    data['submissions'] = [Submission.import_from_dict(
        submission_data, tasks_by_name=tasks_by_name)
                           for submission_data in data['submissions']]
    if 'starting_time' in data and data['starting_time'] is not None:
        data['starting_time'] = make_datetime(data['starting_time'])
    if 'extra_time' in data:
        data['extra_time'] = timedelta(seconds=data['extra_time'])
    obj = cls(**data)
    for submission in obj.submissions:
        submission.user = obj
    return obj