asker-tool 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/asker/ai/ai.rb +6 -6
- data/lib/asker/ai/ai_calculate.rb +3 -3
- data/lib/asker/ai/code/base_code_ai.rb +5 -30
- data/lib/asker/ai/code/code_ai_factory.rb +6 -12
- data/lib/asker/ai/code/javascript_code_ai.rb +33 -34
- data/lib/asker/ai/code/python_code_ai.rb +35 -36
- data/lib/asker/ai/code/ruby_code_ai.rb +33 -33
- data/lib/asker/ai/code/sql_code_ai.rb +20 -21
- data/lib/asker/ai/concept_ai.rb +12 -22
- data/lib/asker/ai/problem/problem_ai.rb +226 -0
- data/lib/asker/ai/question.rb +34 -45
- data/lib/asker/ai/stages/base_stage.rb +7 -7
- data/lib/asker/ai/stages/stage_b.rb +62 -28
- data/lib/asker/ai/stages/stage_d.rb +10 -10
- data/lib/asker/ai/stages/stage_f.rb +17 -17
- data/lib/asker/ai/stages/stage_i.rb +8 -18
- data/lib/asker/ai/stages/stage_s.rb +28 -26
- data/lib/asker/ai/stages/stage_t.rb +40 -51
- data/lib/asker/application.rb +15 -14
- data/lib/asker/check_input/check_haml_data.rb +52 -51
- data/lib/asker/check_input/check_table.rb +17 -20
- data/lib/asker/check_input.rb +10 -23
- data/lib/asker/cli.rb +43 -24
- data/lib/asker/data/code.rb +10 -9
- data/lib/asker/data/column.rb +21 -17
- data/lib/asker/data/concept.rb +24 -37
- data/lib/asker/data/data_field.rb +2 -2
- data/lib/asker/data/problem.rb +112 -0
- data/lib/asker/data/project_data.rb +11 -15
- data/lib/asker/data/row.rb +25 -23
- data/lib/asker/data/table.rb +25 -46
- data/lib/asker/data/template.rb +7 -7
- data/lib/asker/data/world.rb +3 -3
- data/lib/asker/{formatter → deprecated}/question_moodlexml_formatter.rb +19 -21
- data/lib/asker/displayer/code_displayer.rb +10 -10
- data/lib/asker/displayer/concept_ai_displayer.erb +1 -1
- data/lib/asker/displayer/concept_ai_displayer.rb +16 -16
- data/lib/asker/displayer/concept_displayer.rb +4 -2
- data/lib/asker/displayer/problem_displayer.rb +45 -0
- data/lib/asker/displayer/stats_displayer.rb +7 -12
- data/lib/asker/exporter/code_gift_exporter.rb +2 -2
- data/lib/asker/exporter/concept_ai_gift_exporter.rb +4 -4
- data/lib/asker/exporter/concept_ai_yaml_exporter.rb +7 -7
- data/lib/asker/exporter/concept_doc_exporter.rb +5 -5
- data/lib/asker/exporter/data_gift_exporter.rb +14 -15
- data/lib/asker/exporter/data_moodle_exporter.rb +51 -20
- data/lib/asker/exporter/output_file_exporter.rb +9 -8
- data/lib/asker/exporter/problem_gift_exporter.rb +30 -0
- data/lib/asker/files/language/ca/templates.yaml +6 -0
- data/lib/asker/files/language/du/templates.yaml +6 -0
- data/lib/asker/files/language/en/templates.yaml +7 -1
- data/lib/asker/files/language/es/templates.yaml +6 -0
- data/lib/asker/files/language/fr/templates.yaml +6 -0
- data/lib/asker/formatter/code_string_formatter.rb +5 -5
- data/lib/asker/formatter/concept_doc_formatter.rb +3 -3
- data/lib/asker/formatter/concept_string_formatter.rb +6 -6
- data/lib/asker/formatter/moodle/ddmatch.erb +40 -0
- data/lib/asker/formatter/moodle/gapfill.erb +57 -0
- data/lib/asker/formatter/moodle/ordering.erb +41 -0
- data/lib/asker/formatter/question_gift_formatter.rb +41 -14
- data/lib/asker/formatter/question_hash_formatter.rb +5 -6
- data/lib/asker/formatter/question_moodle_formatter.rb +14 -7
- data/lib/asker/formatter/rb2haml_formatter.rb +8 -7
- data/lib/asker/lang/lang.rb +16 -16
- data/lib/asker/lang/lang_factory.rb +13 -16
- data/lib/asker/lang/text_actions.rb +20 -18
- data/lib/asker/loader/code_loader.rb +10 -22
- data/lib/asker/loader/content_loader.rb +42 -49
- data/lib/asker/loader/directory_loader.rb +13 -16
- data/lib/asker/loader/embedded_file.rb +14 -14
- data/lib/asker/loader/file_loader.rb +5 -4
- data/lib/asker/loader/haml_loader.rb +4 -3
- data/lib/asker/loader/image_url_loader.rb +6 -5
- data/lib/asker/loader/input_loader.rb +24 -10
- data/lib/asker/loader/problem_loader.rb +88 -0
- data/lib/asker/loader/project_loader.rb +5 -12
- data/lib/asker/logger.rb +19 -10
- data/lib/asker/skeleton.rb +19 -35
- data/lib/asker/start.rb +44 -0
- data/lib/asker/version.rb +1 -1
- data/lib/asker.rb +7 -52
- metadata +12 -6
- data/lib/asker/ai/code/problem_code_ai.rb +0 -176
- data/lib/asker/exporter/code_moodle_exporter.rb +0 -15
- data/lib/asker/exporter/concept_ai_moodle_exporter.rb +0 -15
@@ -1,176 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../../lang/lang_factory'
|
3
|
-
require_relative '../../ai/question'
|
4
|
-
require_relative 'base_code_ai'
|
5
|
-
|
6
|
-
##
|
7
|
-
# Class for RubyCodeAI objects
|
8
|
-
class ProblemCodeAI < BaseCodeAI
|
9
|
-
def initialize(code)
|
10
|
-
@reduce = 1
|
11
|
-
@reduce = 4 if code.lines.size > 25
|
12
|
-
@lang = LangFactory.instance.get('es')
|
13
|
-
super code
|
14
|
-
end
|
15
|
-
|
16
|
-
##
|
17
|
-
# Make errors about comments
|
18
|
-
def make_comment_error
|
19
|
-
questions = []
|
20
|
-
# error_lines = []
|
21
|
-
@lines.each_with_index do |line,index|
|
22
|
-
if line.strip.start_with?('#')
|
23
|
-
lines = clone_array @lines
|
24
|
-
lines[index].sub!('#','').strip!
|
25
|
-
|
26
|
-
q = Question.new(:short)
|
27
|
-
q.name = "#{name}-#{num}-uncomment"
|
28
|
-
q.text = @lang.text_for(:code1,lines_to_html(lines))
|
29
|
-
q.shorts << (index+1)
|
30
|
-
q.feedback = 'Comment symbol removed'
|
31
|
-
questions << q
|
32
|
-
elsif line.strip.size>0
|
33
|
-
lines = clone_array @lines
|
34
|
-
lines[index]='# ' + lines[index]
|
35
|
-
|
36
|
-
q = Question.new(:short)
|
37
|
-
q.name = "#{name}-#{num}-comment"
|
38
|
-
q.text = @lang.text_for(:code1,lines_to_html(lines))
|
39
|
-
q.shorts << (index+1)
|
40
|
-
q.feedback = 'Comment symbol added'
|
41
|
-
questions << q
|
42
|
-
end
|
43
|
-
end
|
44
|
-
questions.shuffle[0,@lines.size/@reduce]
|
45
|
-
end
|
46
|
-
|
47
|
-
##
|
48
|
-
# Make questions without errors
|
49
|
-
def make_no_error_changes
|
50
|
-
questions = []
|
51
|
-
empty_lines = []
|
52
|
-
used_lines = []
|
53
|
-
@lines.each_with_index do |line,index|
|
54
|
-
if line.strip.size.zero?
|
55
|
-
empty_lines << index
|
56
|
-
else
|
57
|
-
used_lines << index
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
used_lines.each do |index|
|
62
|
-
lines = clone_array(@lines)
|
63
|
-
lines.insert(index, ' ' * (rand(4).to_i + 1))
|
64
|
-
if @lines.size < 4 || rand(2) == 0
|
65
|
-
q = Question.new(:short)
|
66
|
-
q.name = "#{name}-#{num}-codeok"
|
67
|
-
q.text = @lang.text_for(:code1,lines_to_html(lines))
|
68
|
-
q.shorts << '0'
|
69
|
-
q.feedback = 'Code is OK'
|
70
|
-
questions << q
|
71
|
-
else
|
72
|
-
q = Question.new(:choice)
|
73
|
-
q.name = "#{name}-#{num}-codeok"
|
74
|
-
q.text = @lang.text_for(:code2,lines_to_html(lines))
|
75
|
-
others = (1..@lines.size).to_a.shuffle!
|
76
|
-
q.good = '0'
|
77
|
-
q.bads << others[0].to_s
|
78
|
-
q.bads << others[1].to_s
|
79
|
-
q.bads << others[2].to_s
|
80
|
-
q.feedback = 'Code is OK'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
questions.shuffle[0,@lines.size/@reduce]
|
85
|
-
end
|
86
|
-
|
87
|
-
##
|
88
|
-
# Make questions with syntax errors
|
89
|
-
def make_syntax_error
|
90
|
-
questions = []
|
91
|
-
|
92
|
-
@lang.mistakes.each_pair do |key,values|
|
93
|
-
error_lines = []
|
94
|
-
@lines.each_with_index do |line,index|
|
95
|
-
error_lines << index if line.include?(key.to_s)
|
96
|
-
end
|
97
|
-
|
98
|
-
v = values.split(',')
|
99
|
-
v.each do |value|
|
100
|
-
error_lines.each do |index|
|
101
|
-
lines = clone_array(@lines)
|
102
|
-
lines[index].sub!(key.to_s, value)
|
103
|
-
if @lines.size < 4 || rand(2) == 0
|
104
|
-
q = Question.new(:short)
|
105
|
-
q.name = "#{name}-#{num}-syntaxerror"
|
106
|
-
q.text = @lang.text_for(:code1,lines_to_html(lines))
|
107
|
-
q.shorts << (index+1)
|
108
|
-
q.feedback = "Syntax error: '#{value}' must be '#{key}'"
|
109
|
-
else
|
110
|
-
q = Question.new(:choice)
|
111
|
-
q.name = "#{name}-#{num}-syntaxerror"
|
112
|
-
q.text = @lang.text_for(:code2,lines_to_html(lines))
|
113
|
-
others = (1..@lines.size).to_a.shuffle!
|
114
|
-
others.delete(index+1)
|
115
|
-
q.good = (index + 1).to_s
|
116
|
-
q.bads << others[0].to_s
|
117
|
-
q.bads << others[1].to_s
|
118
|
-
q.bads << others[2].to_s
|
119
|
-
q.feedback = "Syntax error: '#{value}' must be '#{key}'"
|
120
|
-
end
|
121
|
-
questions << q
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
questions.shuffle[0,@lines.size/@reduce]
|
126
|
-
end
|
127
|
-
|
128
|
-
##
|
129
|
-
# Make questions with variable errors
|
130
|
-
def make_variable_error
|
131
|
-
questions = []
|
132
|
-
# error_lines = []
|
133
|
-
@lines.each_with_index do |line, index|
|
134
|
-
# Search Variable assignment
|
135
|
-
m = /\s*(\w*)\s*\=\w*/.match(line)
|
136
|
-
i = []
|
137
|
-
unless m.nil?
|
138
|
-
varname = (m.values_at 1)[0]
|
139
|
-
# Search used Variable
|
140
|
-
@lines.each_with_index do |line2, index2|
|
141
|
-
next if index >= index2
|
142
|
-
i << index2 if line2.include?(varname)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
next if i.size == 0
|
146
|
-
i.shuffle!
|
147
|
-
i.each do |k|
|
148
|
-
lines = clone_array @lines
|
149
|
-
temp = lines[index]
|
150
|
-
lines[index] = lines[k]
|
151
|
-
lines[k] = temp
|
152
|
-
|
153
|
-
if rand(2) == 0
|
154
|
-
q = Question.new(:short)
|
155
|
-
q.name = "#{name}-#{num}-variable"
|
156
|
-
q.text = @lang.text_for(:code1, lines_to_html(lines))
|
157
|
-
q.shorts << (index + 1)
|
158
|
-
q.feedback = "Variable error! Swapped lines #{(index+1)} with #{(k+1)}"
|
159
|
-
else
|
160
|
-
q = Question.new(:choice)
|
161
|
-
q.name = "#{name}-#{num}-variable"
|
162
|
-
q.text = @lang.text_for(:code2, lines_to_html(lines))
|
163
|
-
others = (1..@lines.size).to_a.shuffle!
|
164
|
-
others.delete(index+1)
|
165
|
-
q.good = (index + 1).to_s
|
166
|
-
q.bads << others[0].to_s
|
167
|
-
q.bads << others[1].to_s
|
168
|
-
q.bads << others[2].to_s
|
169
|
-
q.feedback = "Variable error! Swapped lines #{(index+1)} with #{(k+1)}"
|
170
|
-
end
|
171
|
-
questions << q
|
172
|
-
end
|
173
|
-
end
|
174
|
-
questions.shuffle[0,@lines.size/@reduce]
|
175
|
-
end
|
176
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../formatter/question_moodle_formatter'
|
3
|
-
|
4
|
-
module CodeMoodleExporter
|
5
|
-
|
6
|
-
def self.run(code, file)
|
7
|
-
return false unless code.process?
|
8
|
-
|
9
|
-
code.questions.each do |question|
|
10
|
-
file.write QuestionMoodleFormatter.to_s(question)
|
11
|
-
end
|
12
|
-
true
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
|
2
|
-
require_relative '../formatter/question_moodle_formatter'
|
3
|
-
|
4
|
-
module ConceptAIMoodleExporter
|
5
|
-
|
6
|
-
def self.run(concept_ai, file)
|
7
|
-
return unless concept_ai.concept.process?
|
8
|
-
|
9
|
-
Application.instance.config['questions']['stages'].each do |stage|
|
10
|
-
concept_ai.questions[stage].each do |question|
|
11
|
-
file.write(QuestionMoodleFormatter.to_s(question))
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|