asker-tool 2.7.1 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/asker/ai/problem/problem_ai.rb +37 -11
- data/lib/asker/check_input/check_haml_data.rb +136 -0
- data/lib/asker/check_input.rb +15 -10
- data/lib/asker/files/language/ca/templates.yaml +1 -0
- data/lib/asker/files/language/du/templates.yaml +1 -0
- data/lib/asker/files/language/en/templates.yaml +1 -0
- data/lib/asker/files/language/es/templates.yaml +1 -0
- data/lib/asker/files/language/fr/templates.yaml +1 -0
- data/lib/asker/loader/content_loader.rb +10 -8
- data/lib/asker/loader/file_loader.rb +2 -1
- data/lib/asker/logger.rb +7 -3
- data/lib/asker/start.rb +1 -1
- data/lib/asker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04fea4738c097db67a060121841ec075ce611ceceec3c31fb49819cd03924db0
|
4
|
+
data.tar.gz: 89e0185e69dac3e5f66dec08331de9c64dfe49801a33cf587293d93f03163263
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13c0dbaceeb204e6b8263f15ba5ccd240a8c3ec7909575a6ace921d8bf8f74554c673d350bf02dc14aca22edd935d5e1f820d74714fddaaf4a33fce93c38a26a
|
7
|
+
data.tar.gz: 9698ad8f849a346b0e9abb86a6be4e64c17922c0e22a35daa423dda2c2b08d679c6ae5d8edc2d3edbb7f64c26026c2f7dd1d66e0538187244d0e2f8d66f8fdee
|
@@ -65,7 +65,7 @@ class ProblemAI
|
|
65
65
|
|
66
66
|
# Question boolean => true
|
67
67
|
q = Question.new(:boolean)
|
68
|
-
q.name = "#{name}-#{counter}-
|
68
|
+
q.name = "#{name}-#{counter}-01pa1true"
|
69
69
|
q.text = lang.text_for(:pa1, desc, asktext, correct_answer)
|
70
70
|
q.good = "TRUE"
|
71
71
|
@questions << q
|
@@ -81,7 +81,7 @@ class ProblemAI
|
|
81
81
|
# Question boolean => true
|
82
82
|
if incorrect_answers.size > 0
|
83
83
|
q = Question.new(:boolean)
|
84
|
-
q.name = "#{name}-#{counter}-
|
84
|
+
q.name = "#{name}-#{counter}-02pa1false"
|
85
85
|
q.text = lang.text_for(:pa1, desc, asktext, incorrect_answers.first)
|
86
86
|
q.good = "FALSE"
|
87
87
|
@questions << q
|
@@ -90,7 +90,7 @@ class ProblemAI
|
|
90
90
|
# Question choice NONE
|
91
91
|
if incorrect_answers.size > 2
|
92
92
|
q = Question.new(:choice)
|
93
|
-
q.name = "#{name}-#{counter}-
|
93
|
+
q.name = "#{name}-#{counter}-03pa2-choice-none"
|
94
94
|
q.text = lang.text_for(:pa2, desc, asktext)
|
95
95
|
q.good = lang.text_for(:none)
|
96
96
|
incorrect_answers.shuffle!
|
@@ -104,7 +104,7 @@ class ProblemAI
|
|
104
104
|
# Question choice OK
|
105
105
|
if incorrect_answers.size > 2
|
106
106
|
q = Question.new(:choice)
|
107
|
-
q.name = "#{name}-#{counter}-
|
107
|
+
q.name = "#{name}-#{counter}-04pa2choice"
|
108
108
|
q.text = lang.text_for(:pa2, desc, asktext)
|
109
109
|
q.good = correct_answer
|
110
110
|
incorrect_answers.shuffle!
|
@@ -117,7 +117,7 @@ class ProblemAI
|
|
117
117
|
|
118
118
|
if incorrect_answers.size > 1
|
119
119
|
q = Question.new(:choice)
|
120
|
-
q.name = "#{name}-#{counter}-
|
120
|
+
q.name = "#{name}-#{counter}-05pa2choice"
|
121
121
|
q.text = lang.text_for(:pa2, desc, asktext)
|
122
122
|
q.good = correct_answer
|
123
123
|
incorrect_answers.shuffle!
|
@@ -130,7 +130,7 @@ class ProblemAI
|
|
130
130
|
|
131
131
|
# Question short
|
132
132
|
q = Question.new(:short)
|
133
|
-
q.name = "#{name}-#{counter}-
|
133
|
+
q.name = "#{name}-#{counter}-06pa2short"
|
134
134
|
q.text = lang.text_for(:pa2, desc, asktext)
|
135
135
|
q.shorts << correct_answer
|
136
136
|
q.feedback = "Correct answer is #{correct_answer}."
|
@@ -153,19 +153,33 @@ class ProblemAI
|
|
153
153
|
|
154
154
|
# Question steps ok
|
155
155
|
q = Question.new(:short)
|
156
|
-
q.name = "#{name}-#{counter}-
|
156
|
+
q.name = "#{name}-#{counter}-07ps3short-ok"
|
157
157
|
q.text = lang.text_for(:ps3, desc, asktext, lines_to_s(steps))
|
158
158
|
q.shorts << 0
|
159
159
|
@questions << q
|
160
160
|
|
161
|
+
# Question steps ordering
|
161
162
|
if steps.size > 3
|
162
163
|
q = Question.new(:ordering)
|
163
|
-
q.name = "#{name}-#{counter}-
|
164
|
+
q.name = "#{name}-#{counter}-08ps6ordering"
|
164
165
|
q.text = lang.text_for(:ps6, desc, asktext, lines_to_s(steps))
|
165
166
|
steps.each { |step| q.ordering << step }
|
166
167
|
@questions << q
|
167
168
|
end
|
168
169
|
|
170
|
+
# Question steps hide
|
171
|
+
if steps.size > 3
|
172
|
+
(0...(steps.size)).each do |index|
|
173
|
+
q = Question.new(:short)
|
174
|
+
q.name = "#{name}-#{counter}-09ps7short-hide"
|
175
|
+
hide_steps = steps.clone
|
176
|
+
hide_steps[index] = hide(steps[index])
|
177
|
+
q.text = lang.text_for(:ps7, desc, asktext, lines_to_s(hide_steps))
|
178
|
+
q.shorts << steps[index]
|
179
|
+
@questions << q
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
169
183
|
# Using diferents wrong steps sequences
|
170
184
|
max = steps.size - 1
|
171
185
|
(0..max).each do |index|
|
@@ -183,7 +197,7 @@ class ProblemAI
|
|
183
197
|
|
184
198
|
# Question steps error
|
185
199
|
q = Question.new(:short)
|
186
|
-
q.name = "#{name}-#{counter}-
|
200
|
+
q.name = "#{name}-#{counter}-10ps3short-error"
|
187
201
|
q.text = lang.text_for(:ps3, desc, asktext, lines_to_s(bads))
|
188
202
|
q.shorts << minor + 1
|
189
203
|
q.feedback = lang.text_for(:ps4, minor + 1, major + 1)
|
@@ -200,7 +214,7 @@ class ProblemAI
|
|
200
214
|
incomplete_steps[indexes[first + 3]] = "?"
|
201
215
|
|
202
216
|
q = Question.new(:match)
|
203
|
-
q.name = "#{name}-#{counter}-
|
217
|
+
q.name = "#{name}-#{counter}-11ps5match"
|
204
218
|
q.text = lang.text_for(:ps5, desc, asktext, lines_to_s(incomplete_steps))
|
205
219
|
q.matching << [steps[indexes[first]], (indexes[first] + 1).to_s]
|
206
220
|
q.matching << [steps[indexes[first + 1]], (indexes[first + 1] + 1).to_s]
|
@@ -210,7 +224,7 @@ class ProblemAI
|
|
210
224
|
@questions << q
|
211
225
|
|
212
226
|
q = Question.new(:ddmatch)
|
213
|
-
q.name = "#{name}-#{counter}-
|
227
|
+
q.name = "#{name}-#{counter}-12ps5ddmatch"
|
214
228
|
q.text = lang.text_for(:ps5, desc, asktext, lines_to_s(incomplete_steps))
|
215
229
|
q.matching << [(indexes[first] + 1).to_s, steps[indexes[first]]]
|
216
230
|
q.matching << [(indexes[first + 1] + 1).to_s, steps[indexes[first + 1]]]
|
@@ -222,5 +236,17 @@ class ProblemAI
|
|
222
236
|
end
|
223
237
|
end
|
224
238
|
end
|
239
|
+
|
240
|
+
def hide(text)
|
241
|
+
output = []
|
242
|
+
text.chars do |c|
|
243
|
+
output << if c == " "
|
244
|
+
c
|
245
|
+
else
|
246
|
+
"?"
|
247
|
+
end
|
248
|
+
end
|
249
|
+
output.join
|
250
|
+
end
|
225
251
|
end
|
226
252
|
end
|
@@ -73,6 +73,14 @@ class CheckHamlData
|
|
73
73
|
check_type(line, index)
|
74
74
|
check_path(line, index)
|
75
75
|
check_features(line, index)
|
76
|
+
check_problem(line, index)
|
77
|
+
check_cases(line, index)
|
78
|
+
check_case(line, index)
|
79
|
+
check_desc(line, index)
|
80
|
+
check_ask(line, index)
|
81
|
+
check_text(line, index)
|
82
|
+
check_answer(line, index)
|
83
|
+
check_step(line, index)
|
76
84
|
check_unknown(line, index)
|
77
85
|
@ok = false unless @outputs[index][:state] == :ok
|
78
86
|
@ok = false if @outputs[index][:type] == :unkown
|
@@ -245,6 +253,134 @@ class CheckHamlData
|
|
245
253
|
end
|
246
254
|
end
|
247
255
|
|
256
|
+
def check_problem(line, index)
|
257
|
+
return unless @outputs[index][:state] == :none
|
258
|
+
return unless line.include? "%problem"
|
259
|
+
|
260
|
+
@outputs[index][:type] = :problem
|
261
|
+
@outputs[index][:level] = 1
|
262
|
+
@outputs[index][:state] = :ok
|
263
|
+
if find_parent(index) != :map
|
264
|
+
@outputs[index][:state] = :err
|
265
|
+
@outputs[index][:msg] = "Parent(map) not found!"
|
266
|
+
elsif !line.match(/^\s\s%problem\s*$/)
|
267
|
+
@outputs[index][:state] = :err
|
268
|
+
@outputs[index][:msg] = "Write 2 spaces before %problem, and no text after"
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
def check_cases(line, index)
|
273
|
+
return unless @outputs[index][:state] == :none
|
274
|
+
return unless line.include? "%cases"
|
275
|
+
|
276
|
+
@outputs[index][:type] = :cases
|
277
|
+
@outputs[index][:level] = 2
|
278
|
+
@outputs[index][:state] = :ok
|
279
|
+
if find_parent(index) != :problem
|
280
|
+
@outputs[index][:state] = :err
|
281
|
+
@outputs[index][:msg] = "Parent(problem) not found!"
|
282
|
+
elsif !line.match(/^\s\s\s\s%cases{\s/)
|
283
|
+
@outputs[index][:state] = :err
|
284
|
+
@outputs[index][:msg] = "Write 4 spaces before %cases"
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def check_case(line, index)
|
289
|
+
return unless @outputs[index][:state] == :none
|
290
|
+
return unless line.include? "%case "
|
291
|
+
|
292
|
+
@outputs[index][:type] = :case
|
293
|
+
@outputs[index][:level] = 3
|
294
|
+
@outputs[index][:state] = :ok
|
295
|
+
if find_parent(index) != :cases
|
296
|
+
@outputs[index][:state] = :err
|
297
|
+
@outputs[index][:msg] = "Parent(cases) not found!"
|
298
|
+
elsif !line.match(/^\s\s\s\s\s\s%case\s/)
|
299
|
+
@outputs[index][:state] = :err
|
300
|
+
@outputs[index][:msg] = "Write 6 spaces before %case"
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
def check_desc(line, index)
|
305
|
+
return unless @outputs[index][:state] == :none
|
306
|
+
return unless line.include? "%desc"
|
307
|
+
|
308
|
+
@outputs[index][:type] = :desc
|
309
|
+
@outputs[index][:level] = 2
|
310
|
+
@outputs[index][:state] = :ok
|
311
|
+
if find_parent(index) != :problem
|
312
|
+
@outputs[index][:state] = :err
|
313
|
+
@outputs[index][:msg] = "Parent(problem) not found!"
|
314
|
+
elsif !line.match(/^\s\s\s\s%desc\s/)
|
315
|
+
@outputs[index][:state] = :err
|
316
|
+
@outputs[index][:msg] = "Write 4 spaces before %desc"
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
def check_ask(line, index)
|
321
|
+
return unless @outputs[index][:state] == :none
|
322
|
+
return unless line.include? "%ask"
|
323
|
+
|
324
|
+
@outputs[index][:type] = :ask
|
325
|
+
@outputs[index][:level] = 2
|
326
|
+
@outputs[index][:state] = :ok
|
327
|
+
if find_parent(index) != :problem
|
328
|
+
@outputs[index][:state] = :err
|
329
|
+
@outputs[index][:msg] = "Parent(problem) not found!"
|
330
|
+
elsif !line.match(/^\s\s\s\s%ask/)
|
331
|
+
@outputs[index][:state] = :err
|
332
|
+
@outputs[index][:msg] = "Write 4 spaces before %ask"
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
def check_text(line, index)
|
337
|
+
return unless @outputs[index][:state] == :none
|
338
|
+
return unless line.include? "%text"
|
339
|
+
|
340
|
+
@outputs[index][:type] = :text
|
341
|
+
@outputs[index][:level] = 3
|
342
|
+
@outputs[index][:state] = :ok
|
343
|
+
if find_parent(index) != :ask
|
344
|
+
@outputs[index][:state] = :err
|
345
|
+
@outputs[index][:msg] = "Parent(ask) not found!"
|
346
|
+
elsif !line.match(/^\s\s\s\s\s\s%text\s/)
|
347
|
+
@outputs[index][:state] = :err
|
348
|
+
@outputs[index][:msg] = "Write 6 spaces before %text"
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
def check_answer(line, index)
|
353
|
+
return unless @outputs[index][:state] == :none
|
354
|
+
return unless line.include? "%answer"
|
355
|
+
|
356
|
+
@outputs[index][:type] = :answer
|
357
|
+
@outputs[index][:level] = 3
|
358
|
+
@outputs[index][:state] = :ok
|
359
|
+
if find_parent(index) != :ask
|
360
|
+
@outputs[index][:state] = :err
|
361
|
+
@outputs[index][:msg] = "Parent(ask) not found!"
|
362
|
+
elsif !line.match(/^\s\s\s\s\s\s%answer\s/)
|
363
|
+
@outputs[index][:state] = :err
|
364
|
+
@outputs[index][:msg] = "Write 6 spaces before %answer"
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
def check_step(line, index)
|
369
|
+
return unless @outputs[index][:state] == :none
|
370
|
+
return unless line.include? "%step"
|
371
|
+
|
372
|
+
@outputs[index][:type] = :step
|
373
|
+
@outputs[index][:level] = 3
|
374
|
+
@outputs[index][:state] = :ok
|
375
|
+
if find_parent(index) != :ask
|
376
|
+
@outputs[index][:state] = :err
|
377
|
+
@outputs[index][:msg] = "Parent(ask) not found!"
|
378
|
+
elsif !line.match(/^\s\s\s\s\s\s%step\s/)
|
379
|
+
@outputs[index][:state] = :err
|
380
|
+
@outputs[index][:msg] = "Write 6 spaces before %step"
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
248
384
|
def check_unknown(line, index)
|
249
385
|
return unless @outputs[index][:state] == :none
|
250
386
|
|
data/lib/asker/check_input.rb
CHANGED
@@ -2,34 +2,39 @@ require_relative "check_input/check_haml_data"
|
|
2
2
|
require_relative "logger"
|
3
3
|
|
4
4
|
class CheckInput
|
5
|
+
attr_accessor :verbose
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@verbose = true
|
9
|
+
end
|
10
|
+
|
5
11
|
def check(filepath)
|
6
|
-
@filepath = filepath
|
7
12
|
# Check HAML file syntax
|
8
|
-
exist = check_file_exist
|
13
|
+
exist = check_file_exist(filepath)
|
9
14
|
return false unless exist
|
10
|
-
check_file_content
|
15
|
+
check_file_content(filepath)
|
11
16
|
end
|
12
17
|
|
13
18
|
private
|
14
19
|
|
15
|
-
def check_file_exist
|
16
|
-
if
|
20
|
+
def check_file_exist(filepath)
|
21
|
+
if filepath.nil?
|
17
22
|
Logger.error "CheckInput: Unknown filename"
|
18
23
|
exit 1
|
19
24
|
end
|
20
|
-
unless File.exist?
|
21
|
-
Logger.error "CheckInput: File not found! (#{
|
25
|
+
unless File.exist? filepath
|
26
|
+
Logger.error "CheckInput: File not found! (#{filepath})"
|
22
27
|
exit 1
|
23
28
|
end
|
24
|
-
unless File.extname(
|
29
|
+
unless File.extname(filepath) == ".haml"
|
25
30
|
Logger.error "CheckInput: Check works with HAML files!"
|
26
31
|
exit 1
|
27
32
|
end
|
28
33
|
true
|
29
34
|
end
|
30
35
|
|
31
|
-
def check_file_content
|
32
|
-
data = CheckHamlData.new(
|
36
|
+
def check_file_content(filepath)
|
37
|
+
data = CheckHamlData.new(filepath)
|
33
38
|
data.check
|
34
39
|
data.show_errors if @verbose
|
35
40
|
data.ok?
|
@@ -33,3 +33,4 @@
|
|
33
33
|
:ps4: 'Canvia el pas <%=text1%> pel pas <%=text2%>'
|
34
34
|
:ps5: '<p><%=text1%></p><p><b>Pregunta:</b> <%=text2%></p><p><b>Resposta:</b ></p><pre><%=text3%></pre><br/><i>(Col·loca cada pas en la seva posició correcta dins de la seqüència)</i>'
|
35
35
|
:ps6: '<p><%=text1%></p><p><b>Pregunta:</b> <%=text2%></p><br/><i>(Posa cada pas en la posició correcta dins de la seqüència)</i>'
|
36
|
+
:ps7: '<p><%=text1%></p><p><b>Pregunta:</b> <%=text2%></p><p><b>Resposta:</b ></p><pre><%=text3%></pre><br/><i>(Nota: Cada símbol ? representa una lletra/símbol, i cada * represent una o diverses paraules.)</i >'
|
@@ -33,3 +33,4 @@
|
|
33
33
|
:ps4: 'Ändere Schritt <%=text1%> in Schritt <%=text2%>'
|
34
34
|
:ps5: '<p><%=text1%></p><p><b>Frage:</b> <%=text2%></p><p><b>Antwort:</b ></p><pre><%=text3%></pre><br/><i>(Platzieren Sie jeden Schritt an der richtigen Position innerhalb der Sequenz)</i>'
|
35
35
|
:ps6: '<p><%=text1%></p><p><b>Frage:</b> <%=text2%></p><br/><i>(Platzieren Sie jeden Schritt an der richtigen Position innerhalb der Sequenz)</i>'
|
36
|
+
:ps7: '<p><%=text1%></p><p><b>Frage:</b> <%=text2%></p><p><b>Antwort:</b ></p><pre><%=text3%></pre><br/><i>(Hinweis: Jedes ? steht für einen Buchstaben/ein Symbol und jedes * steht für ein oder mehrere Wörter.)</i > '
|
@@ -33,3 +33,4 @@
|
|
33
33
|
:ps4: 'Change step <%=text1%> by step <%=text2%>'
|
34
34
|
:ps5: '<p><%=text1%></p><p><b>Question:</b> <%=text2%></p><p><b>Answer:</b></p><pre><%=text3%></pre><br/><i>(Place each step in its correct position within the sequence)</i>'
|
35
35
|
:ps6: '<p><%=text1%></p><p><b>Question:</b> <%=text2%></p><br/><i>(Place each step in its correct position within the sequence)</i>'
|
36
|
+
:ps7: '<p><%=text1%></p><p><b>Question:</b> <%=text2%></p><p><b>Answer:</b ></p><pre><%=text3%></pre><br/><i>(Note: Each ? represents a letter/symbol, and each * represents one or more words.)</i>'
|
@@ -33,3 +33,4 @@
|
|
33
33
|
:ps4: 'Cambia el paso <%=text1%> por el paso <%=text2%>'
|
34
34
|
:ps5: '<p><%=text1%></p><p><b>Pregunta:</b> <%=text2%></p><p><b>Respuesta:</b></p><pre><%=text3%></pre><br/><i>(Coloca cada paso en su posición correcta dentro de la secuencia)</i>'
|
35
35
|
:ps6: '<p><%=text1%></p><p><b>Pregunta:</b> <%=text2%></p><br/><i>(Coloca cada paso en su posición correcta dentro de la secuencia)</i>'
|
36
|
+
:ps7: '<p><%=text1%></p><p><b>Pregunta:</b> <%=text2%></p><p><b>Respuesta:</b></p><pre><%=text3%></pre><br/><i>(Nota: Cada símbolo ? representa una letra/símbolo, y cada * represent una o varias palabras.)</i>'
|
@@ -33,3 +33,4 @@
|
|
33
33
|
:ps4: "Changer l'étape <%=text1%> en étape <%=text2%>"
|
34
34
|
:ps5 : "<p><%=text1%></p><p><b>Question :</b> <%=text2%></p><p><b>Réponse :</b ></p><pre><%=text3%></pre><br/><i>(Placez chaque étape dans sa position correcte dans la séquence)</i>"
|
35
35
|
:ps6 : "<p><%=text1%></p><p><b>Question :</b> <%=text2%></p><br/><i>(Placez chaque étape dans sa position correcte dans la séquence)</i>"
|
36
|
+
:ps7 : '<p><%=text1%></p><p><b>Question :</b> <%=text2%></p><p><b>Réponse :</b ></p><pre><%=text3%></pre><br/><i>(Remarque : chaque ? représente une lettre/un symbole, et chaque * représente un ou plusieurs mots.)</i > '
|
@@ -6,12 +6,12 @@ require_relative "../data/project_data"
|
|
6
6
|
require_relative "../lang/lang_factory"
|
7
7
|
require_relative "../logger"
|
8
8
|
|
9
|
-
|
9
|
+
class ContentLoader
|
10
10
|
##
|
11
11
|
# Load XML content into Asker data objects
|
12
12
|
# @param filepath (String) File path
|
13
13
|
# @param content (String) XML plane text content
|
14
|
-
def
|
14
|
+
def call(filepath, content)
|
15
15
|
begin
|
16
16
|
xmlcontent = REXML::Document.new(content)
|
17
17
|
rescue REXML::ParseException
|
@@ -39,7 +39,9 @@ module ContentLoader
|
|
39
39
|
{concepts: concepts, codes: codes, problems: problems}
|
40
40
|
end
|
41
41
|
|
42
|
-
|
42
|
+
private
|
43
|
+
|
44
|
+
def read_lang_attribute(xmldata)
|
43
45
|
begin
|
44
46
|
lang_code = xmldata.root.attributes["lang"]
|
45
47
|
rescue itself
|
@@ -49,7 +51,7 @@ module ContentLoader
|
|
49
51
|
LangFactory.instance.get(lang_code)
|
50
52
|
end
|
51
53
|
|
52
|
-
|
54
|
+
def read_context_attribute(xmldata)
|
53
55
|
begin
|
54
56
|
context = xmldata.root.attributes["context"].split(",")
|
55
57
|
context.collect!(&:strip)
|
@@ -60,7 +62,7 @@ module ContentLoader
|
|
60
62
|
context
|
61
63
|
end
|
62
64
|
|
63
|
-
|
65
|
+
def read_concept(xmldata, filepath, lang, context)
|
64
66
|
project = ProjectData.instance
|
65
67
|
concept = Concept.new(xmldata, filepath, lang, context)
|
66
68
|
cond = [File.basename(filepath), :default].include? project.get(:process_file)
|
@@ -68,7 +70,7 @@ module ContentLoader
|
|
68
70
|
concept
|
69
71
|
end
|
70
72
|
|
71
|
-
|
73
|
+
def read_code(xmldata, filepath)
|
72
74
|
project = ProjectData.instance
|
73
75
|
code = CodeLoader.call(xmldata, filepath)
|
74
76
|
cond = [File.basename(filepath), :default].include? project.get(:process_file)
|
@@ -76,7 +78,7 @@ module ContentLoader
|
|
76
78
|
code
|
77
79
|
end
|
78
80
|
|
79
|
-
|
81
|
+
def read_problem(xmldata, filepath, lang, context)
|
80
82
|
project = ProjectData.instance
|
81
83
|
problem = ProblemLoader.new(lang, context).call(xmldata, filepath)
|
82
84
|
cond = [File.basename(filepath), :default].include? project.get(:process_file)
|
@@ -84,7 +86,7 @@ module ContentLoader
|
|
84
86
|
problem
|
85
87
|
end
|
86
88
|
|
87
|
-
|
89
|
+
def raise_error_with(filepath, content)
|
88
90
|
Logger.error "ContentLoader: Format error (#{filepath})"
|
89
91
|
Logger.error " : Revise output file (ouput/error.xml)"
|
90
92
|
f = File.open("output/error.xml", "w")
|
@@ -7,6 +7,7 @@ require_relative "../logger"
|
|
7
7
|
# return { concepts: [], codes: [] }
|
8
8
|
module FileLoader
|
9
9
|
def self.call(filename)
|
10
|
+
Logger.debug "==> Loading #{filename}"
|
10
11
|
if File.extname(filename).casecmp(".haml").zero?
|
11
12
|
file_content = HamlLoader.load filename
|
12
13
|
elsif File.extname(filename).casecmp(".xml").zero?
|
@@ -15,6 +16,6 @@ module FileLoader
|
|
15
16
|
Logger.error "FileLoader: HAML or XML required (#{filename})"
|
16
17
|
exit 1
|
17
18
|
end
|
18
|
-
ContentLoader.call(filename, file_content)
|
19
|
+
ContentLoader.new.call(filename, file_content)
|
19
20
|
end
|
20
21
|
end
|
data/lib/asker/logger.rb
CHANGED
@@ -1,14 +1,18 @@
|
|
1
|
-
require "singleton"
|
2
1
|
require_relative "version"
|
3
2
|
|
4
3
|
class Logger
|
5
|
-
include Singleton
|
6
4
|
@verbose = true
|
7
5
|
|
8
|
-
def set_verbose(value)
|
6
|
+
def self.set_verbose(value)
|
9
7
|
@verbose = (value == "yes")
|
10
8
|
end
|
11
9
|
|
10
|
+
def self.debug(msg)
|
11
|
+
msg = Rainbow("#{msg}").white
|
12
|
+
puts msg if @verbose
|
13
|
+
@logfile&.write(msg)
|
14
|
+
end
|
15
|
+
|
12
16
|
def self.info(msg)
|
13
17
|
puts msg if @verbose
|
14
18
|
@logfile&.write(msg)
|
data/lib/asker/start.rb
CHANGED
@@ -19,7 +19,7 @@ class Start
|
|
19
19
|
init_project_data
|
20
20
|
project_data = ProjectLoader.load(args)
|
21
21
|
Logger.create(project_data.get(:logpath))
|
22
|
-
Logger.
|
22
|
+
Logger.set_verbose(Application.instance.config["global"]["verbose"])
|
23
23
|
|
24
24
|
inputdirs = project_data.get(:inputdirs).split(",")
|
25
25
|
internet = Application.instance.config["global"]["internet"] == "yes"
|
data/lib/asker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asker-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Vargas Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|