def survey_answer_list_represent(value):
 db = current.db
 qtable = current.s3db.survey_question
 answer_text = value
 answer_list = answer_text.splitlines()
 result = TABLE()
 questions = {}
 xml_decode = S3Codec.xml_decode
 for line in answer_list:
  line = xml_decode(line)
  (question, answer) = line.split(',', 1)
  question = question.strip('" ')
  if (question in questions):
   question = questions[question]
  else:
   query = (qtable.code == question)
   qstn = db(query).select(qtable.name, limitby=(0, 1)).first()
   if (not qstn):
    continue
   questions[question] = qstn.name
   question = qstn.name
  answer = answer.strip('" ')
  result.append(TR(TD(B(question)), TD(answer)))
 return result

def survey_answer_list_represent ( value ) : db = current . db qtable = current . s3db . survey_question answer_text = value answer_list = answer_text . splitlines ( ) result = TABLE ( ) questions = { } xml_decode = S3Codec . xml_decode for line in answer_list : line = xml_decode ( line ) ( question , answer ) = line . split ( ',' , 1 ) question = question . strip ( '" ' ) if ( question in questions ) : question = questions [ question ] else : query = ( qtable . code == question ) qstn = db ( query ) . select ( qtable . name , limitby = ( 0 , 1 ) ) . first ( ) if ( not qstn ) : continue questions [ question ] = qstn . name question = qstn . name answer = answer . strip ( '" ' ) result . append ( TR ( TD ( B ( question ) ) , TD ( answer ) ) ) return result
display the answer list in a formatted table .