def subtotal(cols, trigger='mark', key='total'):
    """Work out a total for answers formatted as: question => (trigger => score)"""
    total = 0
    for question, val in cols.items():
        if not isinstance(val, dict):
            continue
        if trigger in val:
            total += int(val[trigger])
    if key and key not in cols:
        cols[key] = total
    return total
