'Grader reply is a JSON-dump of the following dict
{ \'correct\': True/False,
\'score\': Numeric value (floating point is okay) to assign to answer
\'msg\': grader_msg }
Returns (valid_score_msg, correct, score, msg):
valid_score_msg: Flag indicating valid score_msg format (Boolean)
correct:         Correctness of submission (Boolean)
score:           Points to be assigned (numeric, can be float)
msg:             Message from grader to display to student (string)'

def _parse_score_msg(self, score_msg):

    fail = (False, False, 0, '')
    try:
        score_result = json.loads(score_msg)
    except (TypeError, ValueError):
        log.error('External    grader    message    should    be    a    JSON-serialized    dict.    Received    score_msg    =    %s', score_msg)
        return fail
    if (not isinstance(score_result, dict)):
        log.error('External    grader    message    should    be    a    JSON-serialized    dict.    Received    score_result    =    %s', score_result)
        return fail
    for tag in ['correct', 'score', 'msg']:
        if (tag not in score_result):
            log.error("External    grader    message    is    missing    one    or    more    required    tags:    'correct',    'score',    'msg'")
            return fail
    msg = score_result['msg']
    try:
        etree.fromstring(msg)
    except etree.XMLSyntaxError as _err:
        try:
            parsed = html5lib.parseFragment(msg, treebuilder='lxml', namespaceHTMLElements=False)
        except ValueError:
            parsed = False
        if (not parsed):
            log.error("Unable    to    parse    external    grader    message    as    valid    XML:    score_msg['msg']=%s", msg)
            return fail
    return (True, score_result['correct'], score_result['score'], msg)
