Exemplo n.º 1
0
def get_essaygrade_data(slumber_data, essaygrades):
    """
    For a given essay, extract the rubric and essay grades
    slumber_data - the dict for the essay model retrieved by slumber from the api
    essaygrades - a list of all the essaygrade objects for the user
    """
    # Get the problem id from the essay
    problem_id = slumber_data['problem'].split('/')[5]
    essaygrade_data = []
    # Loop through all of the essaygrades attached to the essay
    for z in xrange(0, len(slumber_data['essaygrades'])):
        # Get the id of the essaygrade
        essaygrade_id = slumber_data['essaygrades'][z].split('/')[5]
        # Loop through the list of all the users's essaygrades to find a match
        for i in xrange(0, len(essaygrades)):
            # If there is a match, get the scored rubric data
            if int(essaygrade_id) == int(essaygrades[i]['id']):
                # Try to extract and parse the target scores
                target_scores = essaygrades[i]['target_scores']
                try:
                    target_scores = json.loads(target_scores)
                except:
                    pass
                # Retrieve the local rubric, and match with the target scores.
                rubric_data = rubric_functions.get_rubric_data(
                    problem_id, target_scores)
                # Add the rubric data to the essaygrade
                essaygrades[i]['rubric'] = rubric_data
                essaygrade_data.append(essaygrades[i])
    return essaygrade_data
Exemplo n.º 2
0
def get_essaygrade_data(slumber_data, essaygrades):
    """
    For a given essay, extract the rubric and essay grades
    slumber_data - the dict for the essay model retrieved by slumber from the api
    essaygrades - a list of all the essaygrade objects for the user
    """
    # Get the problem id from the essay
    problem_id = slumber_data['problem'].split('/')[5]
    essaygrade_data = []
    # Loop through all of the essaygrades attached to the essay
    for z in xrange(0, len(slumber_data['essaygrades'])):
        # Get the id of the essaygrade
        essaygrade_id = slumber_data['essaygrades'][z].split('/')[5]
        # Loop through the list of all the users's essaygrades to find a match
        for i in xrange(0, len(essaygrades)):
            # If there is a match, get the scored rubric data
            if int(essaygrade_id) == int(essaygrades[i]['id']):
                # Try to extract and parse the target scores
                target_scores = essaygrades[i]['target_scores']
                try:
                    target_scores = json.loads(target_scores)
                except:
                    pass
                # Retrieve the local rubric, and match with the target scores.
                rubric_data = rubric_functions.get_rubric_data(problem_id, target_scores)
                # Add the rubric data to the essaygrade
                essaygrades[i]['rubric'] = rubric_data
                essaygrade_data.append(essaygrades[i])
    return essaygrade_data
Exemplo n.º 3
0
def get_rubric_data(model, slumber_data):
    """
    Get the rubric data for a given data file and attach it.
    model - a model type, currently "problem" or "essay"
    slumber_data - a dict returned by slumber from the api
    """
    # Extract the problem id
    if model == "problem":
        problem_id = slumber_data['id']
    else:
        problem_id = slumber_data['problem'].split('/')[5]

    # Try to get the local rubric data matching the problem id
    rubric_data = []
    try:
        rubric_data = rubric_functions.get_rubric_data(problem_id)
    except:
        log.error("Could not find rubric for problem id {0}.".format(problem_id))

    return rubric_data
Exemplo n.º 4
0
def get_rubric_data(model, slumber_data):
    """
    Get the rubric data for a given data file and attach it.
    model - a model type, currently "problem" or "essay"
    slumber_data - a dict returned by slumber from the api
    """
    # Extract the problem id
    if model == "problem":
        problem_id = slumber_data['id']
    else:
        problem_id = slumber_data['problem'].split('/')[5]

    # Try to get the local rubric data matching the problem id
    rubric_data = []
    try:
        rubric_data = rubric_functions.get_rubric_data(problem_id)
    except:
        log.error(
            "Could not find rubric for problem id {0}.".format(problem_id))

    return rubric_data