'Given unparsed state, return the (grade, max_grade) we should have.'

def grade_for_state(self, state):

    parsed_state = json.loads(state)
    correct_map = parsed_state.get('correct_map')
    if (not correct_map):
        input_state = parsed_state.get('input_state')
        if (input_state is not None):
            return (0.0, float(len(input_state)))
        return (None, None)
    def item_score(item):
        'Return    score    for    an    individual    correct_map    entry.'
        partial_points = item.get('npoints')
        if (partial_points is not None):
            return partial_points
        correctness = item.get('correctness')
        if (correctness in ['correct', 'partially-correct']):
            return 1.0
        return 0.0
    grade = sum((item_score(item) for item in correct_map.values()))
    max_grade = float(len(correct_map))
    return (grade, max_grade)
