def survey_updateMetaData(record, qtype, metadata):

    metatable = current.s3db.survey_question_metadata
    question_id = record.id
    # the metadata can either be passed in as a JSON string
    # or as a parsed map. If it is a string load the map.
    if isinstance(metadata, str):
        metadata_list = json2py(metadata)
    else:
        metadata_list = metadata
    for (desc, value) in metadata_list.items():
        desc = desc.strip()
        if not isinstance(value, str):
            # web2py stomps all over a list so convert back to a string
            # before inserting it on the database
            value = json.dumps(value)
        value = value.strip()
        metatable.insert(question_id = question_id,
                         descriptor = desc,
                         value = value,
                         )
    if qtype == "Grid":
        widget_obj = survey_question_type["Grid"]()
        widget_obj.insertChildren(record, metadata_list)

# =============================================================================
Function to update the metadata of a question
dataset/ETHPy150Open sahana/eden/modules/s3db/survey.py/survey_updateMetaData