class SQLCodeAI
Public Class Methods
new(code)
click to toggle source
Calls superclass method
BaseCodeAI::new
# File lib/asker/ai/code/sql_code_ai.rb, line 7 def initialize(code) @lang = LangFactory.instance.get('sql') super code end
Public Instance Methods
make_comment_error()
click to toggle source
# File lib/asker/ai/code/sql_code_ai.rb, line 12 def make_comment_error error_lines = [] questions = [] @lines.each_with_index do |line,index| if line.include?('//') lines = clone_array @lines lines[index].sub!('//','').strip! q = Question.new(:short) q.name = "#{name}-#{num}-code1uncomment" q.text = @lang.text_for(:code1,lines_to_html(lines)) q.shorts << (index+1) q.feedback = 'Comment symbol removed' questions << q elsif line.strip.size>0 lines = clone_array @lines lines[index]='// ' + lines[index] q = Question.new(:short) q.name = "#{name}-#{num}-code1comment" q.text = @lang.text_for(:code1,lines_to_html(lines)) q.shorts << (index+1) q.feedback = 'Comment symbol added' questions << q end end questions end
make_keyword_error()
click to toggle source
# File lib/asker/ai/code/sql_code_ai.rb, line 41 def make_keyword_error error_lines = [] questions = [] @lang.mistakes.each_pair do |key,values| v = values.split(',') v.each do |value| @lines.each_with_index do |line,index| error_lines << index if line.include?(key.to_s) end error_lines.each do |index| lines = clone_array @lines lines[index].sub!(key.to_s, value) q = Question.new(:short) q.name = "#{name}-#{num}-code1keyword" q.text = @lang.text_for(:code1,lines_to_html(lines)) q.shorts << (index+1) q.feedback = "Keyword error: '#{value}' must be '#{key}'" questions << q end end end questions end