engine/process.py
def answer_insert(self, message, ans_num=''):
        """Control the message length. Call the get_q_count method, get the number of
           questions. Get questions for the survey from the questions table.
           Insert the foreign keys (feature id; question id, derived
           from the number of questions) and the answer for a message/call sender
           into the answers table. If the number of questions > 1, decrease it by 1
           in the features table. Return the proper answer"""
        if len(message.text) > 255:
            return answers['LONG']
        else:
            q_count = self.get_q_count(message)
            cursor.execute(f"select id, question from {self.db}questions where survey = '{self.get_survey(message)}' "
                           f"order by id")
            result = cursor.fetchall()
            cursor.execute(f"insert into {self.db}answers (id, f_id, q_id, answer) values (default, "
                           f"(select max(id) from {self.db}features where user_id = {message.from_user.id}),"
                           f"{result[q_count * (- 1)][0]}, '{self.sub(message.text)}{ans_num}')")
            connection.commit()
            if q_count > 1:
                cursor.execute(
                    f"update {self.db}features set q_count = {q_count - 1} where id = (select max(id) from "
                    f"{self.db}features where user_id = {message.from_user.id})")
                connection.commit()
                return answers['ANS_NEXT_Q'] % result[(q_count - 1) * (-1)][1]
            else:
                return answers['ALL_ANSWERED']
Control the message length. Call the get_q_count method, get the number of
           questions. Get questions for the survey from the questions table.
           Insert the foreign keys (feature id; question id, derived
           from the number of questions) and the answer for a message/call sender
           into the answers table. If the number of questions > 1, decrease it by 1
           in the features table. Return the proper answer
Control the message length. Call the get_q_count method, get the number of
questions. Get questions for the survey from the questions table.
Insert the foreign keys (feature id; question id, derived
from the number of questions) and the answer for a message/call sender
into the answers table. If the number of questions > 1, decrease it by 1
in the features table. Return the proper answer
Control the message length . Call the get_q_count method get the number of questions . Get questions for the survey from the questions table . Insert the foreign keys ( feature id ; question id derived from the number of questions ) and the answer for a message / call sender into the answers table . If the number of questions > 1 decrease it by 1 in the features table . Return the proper answer
def answer_insert(self, message, ans_num=''):
        if len(message.text) > 255:
            return answers['LONG']
        else:
            q_count = self.get_q_count(message)
            cursor.execute(f"select id, question from {self.db}questions where survey = '{self.get_survey(message)}' "
                           f"order by id")
            result = cursor.fetchall()
            cursor.execute(f"insert into {self.db}answers (id, f_id, q_id, answer) values (default, "
                           f"(select max(id) from {self.db}features where user_id = {message.from_user.id}),"
                           f"{result[q_count * (- 1)][0]}, '{self.sub(message.text)}{ans_num}')")
            connection.commit()
            if q_count > 1:
                cursor.execute(
                    f"update {self.db}features set q_count = {q_count - 1} where id = (select max(id) from "
                    f"{self.db}features where user_id = {message.from_user.id})")
                connection.commit()
                return answers['ANS_NEXT_Q'] % result[(q_count - 1) * (-1)][1]
            else:
                return answers['ALL_ANSWERED']
def answer_insert ( self , message , ans_num = '' ) : if len ( message . text ) > 255 : return answers [ 'LONG' ] else : q_count = self . get_q_count ( message ) cursor . execute ( f"select id, question from {self.db}questions where survey = '{self.get_survey(message)}' " f"order by id" ) result = cursor . fetchall ( ) cursor . execute ( f"insert into {self.db}answers (id, f_id, q_id, answer) values (default, " f"(select max(id) from {self.db}features where user_id = {message.from_user.id})," f"{result[q_count * (- 1)][0]}, '{self.sub(message.text)}{ans_num}')" ) connection . commit ( ) if q_count > 1 : cursor . execute ( f"update {self.db}features set q_count = {q_count - 1} where id = (select max(id) from " f"{self.db}features where user_id = {message.from_user.id})" ) connection . commit ( ) return answers [ 'ANS_NEXT_Q' ] % result [ ( q_count - 1 ) * ( - 1 ) ] [ 1 ] else : return answers [ 'ALL_ANSWERED' ]
Control the message length.
Control the message length .
"""Control the message length. Call the get_q_count method, get the number of
           questions. Get questions for the survey from the questions table.
           Insert the foreign keys (feature id; question id, derived
           from the number of questions) and the answer for a message/call sender
           into the answers table. If the number of questions > 1, decrease it by 1
           in the features table. Return the proper answer"""
self
message
ans_num