'Updates the user\'s score based on the returned message from the grader.'

def update_score(self, score_msg, oldcmap, queuekey):

    (valid_score_msg, correct, points, msg) = self._parse_score_msg(score_msg)
    _ = self.capa_system.i18n.ugettext
    dog_stats_api.increment(xqueue_interface.XQUEUE_METRIC_NAME, tags=['action:update_score', 'correct:{}'.format(correct)])
    dog_stats_api.histogram((xqueue_interface.XQUEUE_METRIC_NAME + '.update_score.points_earned'), points)
    if (not valid_score_msg):
        error_msg = _('Invalid    grader    reply.    Please    contact    the    course    staff.')
        oldcmap.set(self.answer_id, msg=error_msg)
        return oldcmap
    correctness = ('correct' if correct else 'incorrect')
    self.context['correct'] = correctness
    if oldcmap.is_right_queuekey(self.answer_id, queuekey):
        if (points < 0):
            points = 0
        oldcmap.set(self.answer_id, npoints=points, correctness=correctness, msg=msg.replace('&nbsp;', '&#160;'), queuestate=None)
    else:
        log.debug('CodeResponse:    queuekey    %s    does    not    match    for    answer_id=%s.', queuekey, self.answer_id)
    return oldcmap
