src/functions/questions_verifier.rb
# Function for checking if the given question and 
Function for checking if the given question and
Function for checking if the given question and
def validate_questions(raw_question)
  data = parse_questions(raw_question)
  if not data or not data.key?("answers")
    return {score: 0, answer: nil}
  end
  question = data["answers"]
  result = 0
  answer = nil
  response = DYNAMODB.scan(table_name: TABLE_NAME).items
  if question.key?("ID") and question.key?("answer")
    response.each do |item|
      if item['ID'].to_i == question['ID'].to_i
        answer = item['answer'].strip
        if item['answer'].strip == question['answer'].strip
          result = 1
        end
        break
      end
    end
  end
  {score: result, answer: answer}
end
def validate_questions ( raw_question ) data = parse_questions ( raw_question ) if not data or not data . key? ( "answers" ) return { score : 0 , answer : nil } end question = data [ "answers" ] result = 0 answer = nil response = DYNAMODB . scan ( table_name : TABLE_NAME ) . items if question . key? ( "ID" ) and question . key? ( "answer" ) response . each do | item | if item [ 'ID' ] . to_i == question [ 'ID' ] . to_i answer = item [ 'answer' ] . strip if item [ 'answer' ] . strip == question [ 'answer' ] . strip result = 1 end break end end end { score : result , answer : answer } end
Function for checking if the given question and
Function for checking if the given question and
raw_question