'Rules for finding a duplicate:
- Look for a record with the same complete_id and question_id'

@staticmethod
def survey_answer_duplicate(item):

    data = item.data
    qid = data.get('question_id')
    rid = data.get('complete_id')
    table = item.table
    query = ((table.question_id == qid) & (table.complete_id == rid))
    duplicate = current.db(query).select(table.id, limitby=(0, 1)).first()
    if duplicate:
        item.id = duplicate.id
        item.method = item.METHOD.UPDATE
