asker-tool 2.5.4 → 2.5.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e2f9eaec9a8bb085529b1b131f6e7184b769796f452096c7e9813da191425a70
4
- data.tar.gz: 25d938ce101b69c2171de314270207d17d1783008968fb0be7c21f228070c44f
3
+ metadata.gz: 832b26de49f5819f39da3e149c4360caa77e91b0cf1418b4225a35c81a9e197d
4
+ data.tar.gz: 8d6ba5c39fde26b38819e4c330f4ad6070811335e04839721fae4a35536c6581
5
5
  SHA512:
6
- metadata.gz: f62278acb1f78b567aae35e41256d36ff76503fd3c46939f2f0f83a414b3b817ddb515d79ee9cb557352555683cc1918af02001ada4d2f44343a0be9850cc7d6
7
- data.tar.gz: d27246c82c93285ff411ff73fd3d265e7503efce6c9037f2462147103c24e15db728553363f565043dc5443b78d3d3e73ac114f27d0ef66245ff72e333d85ee1
6
+ metadata.gz: df48a9dabc8ebb8614a67986d29c9d2110fdd8cfb6d793b7e10ab0a87120c0a78b00e44acff79a8d1b02edfa5d50823625e4e44c916e249f0c8e5f1eca42cb58
7
+ data.tar.gz: 184c5afbb7563d7cc96d9077b01339c2099b28479d616fc60c53afa29db68edde9de1c5aea6c42d2c56016e5fbd3ac95993b299d01413976abe2e9915695c858
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
+ # ASKER
2
+
1
3
  [![Gem Version](https://badge.fury.io/rb/asker-tool.svg)](https://badge.fury.io/rb/asker-tool)
2
4
  ![GitHub](https://img.shields.io/github/license/dvarrui/asker)
3
5
 
4
- # ASKER
5
-
6
6
  Generate a lot of questions from an _input_ text file with on your own _definitions_. In a way, this _input file_ is a concept map.
7
7
 
8
8
  ![logo](./docs/images/logo.png)
@@ -14,21 +14,35 @@ ASKER helps trainers to create a huge amount of questions, from a definitions (_
14
14
 
15
15
  ## Installation
16
16
 
17
- 1. Install Ruby on your system.
18
- 2. Install Asker on your system: `sudo gem install asker-tool`
17
+ First install Ruby and then:
18
+
19
+ ```
20
+ gem install asker-tool
21
+ ```
19
22
 
20
- > REMEMBER: To update Asker execute `sudo gem update asker-tool`
23
+ > REMEMBER: Update Asker with `gem update asker-tool`
21
24
 
22
25
  ## Usage
23
26
 
24
- 1. **Create input file** with your content (_conceptual map_). Examples at [Asker inputs folder](./docs/examples).
25
- 2. **Run `asker PATH/TO/INPUT`**. Example: Create questions from ACDC input example file:
26
- ```bash
27
- asker docs/examples/bands/acdc.haml
27
+ 1. **Create input file** with your contents (_conceptual map_). [Here are some examples](./docs/examples).
28
+ 2. **Run `asker PATH/TO/INPUT`**. Let's see an example creating questions from ACDC input example file:
29
+
28
30
  ```
29
- 3. Output files created into the `output` folder.
31
+ asker docs/examples/bands/acdc.haml
32
+
33
+ +--------------------+-----------+---------+---------+---+---+----+---+---+----+
34
+ | Concept | Questions | Entries | xFactor | d | b | f | i | s | t |
35
+ +--------------------+-----------+---------+---------+---+---+----+---+---+----+
36
+ | AC/DC | 45 | 18 | 2.5 | 7 | 0 | 15 | 0 | 3 | 20 |
37
+ | Excluded questions | 0 | - | - | 0 | 0 | 0 | 0 | 0 | 0 |
38
+ +--------------------+-----------+---------+---------+---+---+----+---+---+----+
39
+ | 1 concept/s | 45 | 18 | 2.5 | 7 | 0 | 15 | 0 | 3 | 20 |
40
+ +--------------------+-----------+---------+---------+---+---+----+---+---+----+
41
+ ```
42
+
43
+ 3. **Output files** are saved into the `output` folder.
30
44
 
31
- > More input examples at [dvarrui/asker-input](https://github.com/dvarrui/asker-inputs) repository.
45
+ > More input examples at [asker-input repository](https://github.com/dvarrui/asker-inputs).
32
46
 
33
47
  ## Documentation
34
48
 
@@ -5,14 +5,14 @@ require_relative 'base_code_ai'
5
5
 
6
6
  class JavascriptCodeAI < BaseCodeAI
7
7
  def initialize(code)
8
- @lang = LangFactory.instance.get('javascript')
8
+ @lang = LangFactory.instance.get("javascript")
9
9
  super code
10
10
  end
11
11
 
12
12
  def make_comment_error
13
13
  questions = []
14
- error_lines = []
15
- @lines.each_with_index do |line,index|
14
+ # error_lines = []
15
+ @lines.each_with_index do |line, index|
16
16
  if line.strip.start_with?('//')
17
17
  lines = clone_array @lines
18
18
  lines[index].sub!('//','').strip!
@@ -117,7 +117,7 @@ class JavascriptCodeAI < BaseCodeAI
117
117
 
118
118
  def make_variable_error
119
119
  questions = []
120
- error_lines = []
120
+ # error_lines = []
121
121
  @lines.each_with_index do |line, index|
122
122
  # Search Variable assignment
123
123
  m = /var\s*(\w*);\s*\w*/.match(line)
@@ -17,7 +17,7 @@ class ProblemCodeAI < BaseCodeAI
17
17
  # Make errors about comments
18
18
  def make_comment_error
19
19
  questions = []
20
- error_lines = []
20
+ # error_lines = []
21
21
  @lines.each_with_index do |line,index|
22
22
  if line.strip.start_with?('#')
23
23
  lines = clone_array @lines
@@ -129,7 +129,7 @@ class ProblemCodeAI < BaseCodeAI
129
129
  # Make questions with variable errors
130
130
  def make_variable_error
131
131
  questions = []
132
- error_lines = []
132
+ # error_lines = []
133
133
  @lines.each_with_index do |line, index|
134
134
  # Search Variable assignment
135
135
  m = /\s*(\w*)\s*\=\w*/.match(line)
@@ -11,8 +11,8 @@ class PythonCodeAI < BaseCodeAI
11
11
 
12
12
  def make_comment_error
13
13
  questions = []
14
- error_lines = []
15
- @lines.each_with_index do |line,index|
14
+ # error_lines = []
15
+ @lines.each_with_index do |line, index|
16
16
  if line.strip.start_with?('#')
17
17
  lines = clone_array @lines
18
18
  lines[index].sub!('#','').strip!
@@ -117,7 +117,7 @@ class PythonCodeAI < BaseCodeAI
117
117
 
118
118
  def make_variable_error
119
119
  questions = []
120
- error_lines = []
120
+ # error_lines = []
121
121
  @lines.each_with_index do |line, index|
122
122
  # Search Variable assignment
123
123
  m = /\s*(\w*)\s*\=\w*/.match(line)
@@ -1,15 +1,12 @@
1
+ require_relative "../../lang/lang_factory"
2
+ require_relative "../../ai/question"
3
+ require_relative "base_code_ai"
1
4
 
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
5
  class RubyCodeAI < BaseCodeAI
9
6
  def initialize(code)
10
7
  @reduce = 1
11
8
  @reduce = 4 if code.lines.size > 25
12
- @lang = LangFactory.instance.get('ruby')
9
+ @lang = LangFactory.instance.get("ruby")
13
10
  super code
14
11
  end
15
12
 
@@ -17,8 +14,8 @@ class RubyCodeAI < BaseCodeAI
17
14
  # Make errors about comments
18
15
  def make_comment_error
19
16
  questions = []
20
- error_lines = []
21
- @lines.each_with_index do |line,index|
17
+ # error_lines = []
18
+ @lines.each_with_index do |line, index|
22
19
  if line.strip.start_with?('#')
23
20
  lines = clone_array @lines
24
21
  lines[index].sub!('#','').strip!
@@ -129,7 +126,7 @@ class RubyCodeAI < BaseCodeAI
129
126
  # Make questions with variable errors
130
127
  def make_variable_error
131
128
  questions = []
132
- error_lines = []
129
+ # error_lines = []
133
130
  @lines.each_with_index do |line, index|
134
131
  # Search Variable assignment
135
132
  m = /\s*(\w*)\s*\=\w*/.match(line)
@@ -10,7 +10,6 @@ class SQLCodeAI < BaseCodeAI
10
10
  end
11
11
 
12
12
  def make_comment_error
13
- error_lines = []
14
13
  questions = []
15
14
  @lines.each_with_index do |line,index|
16
15
  if line.include?('//')
@@ -1,9 +1,7 @@
1
- # frozen_string_literal: true
2
-
3
- require 'singleton'
4
- require 'inifile'
5
- require 'rainbow'
6
- require_relative 'version'
1
+ require "singleton"
2
+ require "inifile"
3
+ require "rainbow"
4
+ require_relative "version"
7
5
 
8
6
  # Global parameters
9
7
  class Application
@@ -3,6 +3,7 @@
3
3
  require_relative '../loader/image_url_loader'
4
4
 
5
5
  class World
6
+ # TODO: change how World class works ?
6
7
  attr_reader :concepts, :filenames, :contexts, :image_urls
7
8
 
8
9
  def initialize(concepts, internet = true)
@@ -27,7 +28,6 @@ class World
27
28
 
28
29
  private
29
30
 
30
- # rubocop:disable Metrics/MethodLength
31
31
  def get_lists_from(input)
32
32
  concepts = {}
33
33
  filenames = []
@@ -43,12 +43,7 @@ class World
43
43
  contexts.uniq!
44
44
  [concepts, filenames, contexts]
45
45
  end
46
- # rubocop:enable Metrics/MethodLength
47
46
 
48
- # rubocop:disable Metrics/MethodLength
49
- # rubocop:disable Metrics/AbcSize
50
- # rubocop:disable Metrics/CyclomaticComplexity
51
- # rubocop:disable Metrics/PerceivedComplexity
52
47
  def find_url_images_from_internet(internet)
53
48
  return {} unless internet
54
49
 
@@ -61,11 +56,7 @@ class World
61
56
  searchs.each do |search|
62
57
  threads << Thread.new { urls[search] = ImageUrlLoader.load(search) }
63
58
  end
64
- threads.each(&:join) # wait for all threads to finish
59
+ threads.each(&:join)
65
60
  urls
66
61
  end
67
- # rubocop:enable Metrics/MethodLength
68
- # rubocop:enable Metrics/AbcSize
69
- # rubocop:enable Metrics/CyclomaticComplexity
70
- # rubocop:enable Metrics/PerceivedComplexity
71
62
  end
@@ -1,15 +1,10 @@
1
- # frozen_string_literal: true
1
+ require "terminal-table"
2
+ require_relative "../logger"
2
3
 
3
- require 'terminal-table'
4
- require_relative '../logger'
5
-
6
- # Export Code into Screen
7
4
  module CodeDisplayer
8
5
  ##
9
6
  # Show all "code" data on screen
10
7
  # @param codes (Array) List of "code" data
11
- # rubocop:disable Metrics/AbcSize
12
- # rubocop:disable Metrics/MethodLength
13
8
  def self.show(codes)
14
9
  return if codes.nil? || codes.size.zero?
15
10
 
@@ -47,6 +42,4 @@ module CodeDisplayer
47
42
  Logger.verboseln "\n[INFO] Showing CODE statistics"
48
43
  Logger.verboseln my_screen_table.to_s
49
44
  end
50
- # rubocop:enable Metrics/AbcSize
51
- # rubocop:enable Metrics/MethodLength
52
45
  end
@@ -74,7 +74,7 @@ class ConceptAIDisplayer
74
74
 
75
75
  # Create table TAIL
76
76
  screen_table.add_separator
77
- screen_table.add_row [Rainbow("TOTAL = #{total[:c]}").bright,
77
+ screen_table.add_row [Rainbow("#{total[:c]} concept/s").bright,
78
78
  Rainbow(total[:q].to_s).bright,
79
79
  Rainbow(total[:e].to_s).bright,
80
80
  Rainbow((total[:q].to_f / total[:e]).round(2)).bright,
@@ -1,10 +1,7 @@
1
- # frozen_string_literal: true
2
-
3
1
  require_relative '../application'
4
2
  require_relative '../formatter/concept_string_formatter'
5
- require_relative '../logger'
3
+ require_relative "../logger"
6
4
 
7
- # Show Concept Data on screen
8
5
  module ConceptDisplayer
9
6
  ##
10
7
  # Show concepts on screen
@@ -1,7 +1,5 @@
1
+ require_relative "../formatter/question_gift_formatter"
1
2
 
2
- require_relative '../formatter/question_gift_formatter'
3
-
4
- # Use to export questions from Code to gift format
5
3
  module CodeGiftExporter
6
4
  ##
7
5
  # Export an Array of codes to gift format file
@@ -14,7 +14,6 @@ module ConceptDocExporter
14
14
  file.write("Created by : #{Asker::NAME} (version #{Asker::VERSION})\n")
15
15
  file.write("File : #{project.get(:lessonname)}\n")
16
16
  file.write("Time : #{Time.new}\n")
17
- file.write("Author : David Vargas Ruiz\n")
18
17
  file.write('=' * 50 + "\n")
19
18
 
20
19
  concepts.each do |concept|
@@ -18,7 +18,6 @@ module DataGiftExporter
18
18
  file.write(" (version #{Asker::VERSION})\n")
19
19
  file.write("// File : #{project.get(:outputname)}\n")
20
20
  file.write("// Time : #{Time.new}\n")
21
- file.write("// Author : David Vargas Ruiz\n")
22
21
  file.write('// ' + ('=' * 50) + "\n\n")
23
22
  category = Application.instance.config['questions']['category']
24
23
  file.write("$CATEGORY: $course$/#{category}\n") unless category.nil?
@@ -15,7 +15,6 @@ module DataMoodleExporter
15
15
  file.write(" (version #{Asker::VERSION})\n")
16
16
  file.write(" File : #{project.get(:moodlename)}\n")
17
17
  file.write(" Time : #{Time.new}\n")
18
- file.write(" Author : David Vargas Ruiz\n")
19
18
  file.write("#{('=' * 50)}\n-->\n\n")
20
19
 
21
20
  data[:concepts_ai].each do |concept_ai|
@@ -6,13 +6,13 @@ module TextActions
6
6
  ##
7
7
  # Return text indicated by lang code...
8
8
  def text_for(option, *input)
9
- text1 = input[0]
10
- text2 = input[1]
11
- text3 = input[2]
12
- text4 = input[3]
13
- text5 = input[4]
14
- text6 = input[5]
15
- text7 = input[6]
9
+ @_text1 = input[0] # FIXME: done to avoid linter complaints.
10
+ @_text2 = input[1]
11
+ @_text3 = input[2]
12
+ @_text4 = input[3]
13
+ @_text5 = input[4]
14
+ @_text6 = input[5]
15
+ @_text7 = input[6]
16
16
 
17
17
  # Check if exists option before use it
18
18
  raise "[ERROR] Unkown template #{option}" if @templates[option].nil?
@@ -21,6 +21,34 @@ module TextActions
21
21
  renderer.result(binding)
22
22
  end
23
23
 
24
+ def text1
25
+ @_text1
26
+ end
27
+
28
+ def text2
29
+ @_text2
30
+ end
31
+
32
+ def text3
33
+ @_text3
34
+ end
35
+
36
+ def text4
37
+ @_text4
38
+ end
39
+
40
+ def text5
41
+ @_text5
42
+ end
43
+
44
+ def text6
45
+ @_text6
46
+ end
47
+
48
+ def text7
49
+ @_text7
50
+ end
51
+
24
52
  ##
25
53
  # Convert input text into output text struct
26
54
  # @param input (String) Input text
@@ -38,14 +66,14 @@ module TextActions
38
66
  # if <word> is a conector and <pFilter>==true Then Choose this <word>
39
67
  # if <word> isn't a conector and <pFilter>==true and <word>.length>1 Then Choose this <word>
40
68
  if (flag and filter) || (!flag and !filter and word.length > 1)
41
- output_words << {:word => word, :row => rowindex, :col => colindex }
42
- row << (output_words.size-1)
43
- else
44
- row << word
69
+ output_words << {:word => word, :row => rowindex, :col => colindex }
70
+ row << (output_words.size-1)
71
+ else
72
+ row << word
45
73
  end
46
- end
47
- row << '.'
48
- output_lines << row
74
+ end
75
+ row << '.'
76
+ output_lines << row
49
77
  end
50
78
 
51
79
  indexes = []
@@ -1,19 +1,17 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'haml'
4
2
 
5
- # HAML file loader
6
3
  module HamlLoader
7
4
  def self.load(filename)
8
5
  template = File.read(filename)
9
6
  begin
10
- haml_engine = Haml::Engine.new(template)
11
- return haml_engine.render
7
+ # INFO <haml 5.1> 20221223
8
+ # haml_engine = Haml::Engine.new(template)
9
+ # return haml_engine.render
10
+ return Haml::Template.new { template }.render
12
11
  rescue StandardError => e
13
12
  puts "[ERROR] HamlLoader: Can't load <#{filename}> file!"
14
13
  puts " => #{e}"
15
14
  exit 0
16
15
  end
17
16
  end
18
-
19
17
  end
data/lib/asker/logger.rb CHANGED
@@ -1,19 +1,16 @@
1
- # frozen_string_literal: true
1
+ require "singleton"
2
+ require_relative "version"
2
3
 
3
- require 'singleton'
4
- require_relative 'version'
5
-
6
- # Display and log project messages
7
4
  class Logger
8
5
  include Singleton
9
- @attr_verbose = 'yes'
6
+ @attr_verbose = "yes"
10
7
 
11
8
  def set_verbose(value)
12
9
  @attr_verbose = value
13
10
  end
14
11
 
15
12
  def self.verbose(msg)
16
- print msg if @attr_verbose == 'yes'
13
+ print msg if @attr_verbose == "yes"
17
14
  @logfile&.write(msg)
18
15
  end
19
16
 
@@ -28,16 +25,14 @@ class Logger
28
25
  def logln(msg)
29
26
  verboseln(msg)
30
27
  end
31
- ##
32
- # Create or reset logfile
33
- def self.create(logpath, logname)
28
+
29
+ def self.create(logpath)
34
30
  @logfile = File.open(logpath, 'w')
35
31
  @logfile.write('=' * 50 + "\n")
36
32
  @logfile.write("Created by : #{Asker::NAME}")
37
33
  @logfile.write(" (version #{Asker::VERSION})\n")
38
- @logfile.write("File : #{logname}\n")
34
+ @logfile.write("File : #{File.basename(logpath)}\n")
39
35
  @logfile.write("Time : #{Time.new}\n")
40
- @logfile.write("Author : David Vargas Ruiz\n")
41
36
  @logfile.write('=' * 50 + "\n\n")
42
37
  end
43
38
 
data/lib/asker/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Asker
3
- VERSION = "2.5.4"
3
+ VERSION = "2.5.5"
4
4
  NAME = "asker"
5
5
  GEM = "asker-tool"
6
6
  CONFIGFILE = "asker.ini"
data/lib/asker.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require 'rainbow'
4
2
  require 'colorize'
5
3
 
@@ -13,8 +11,8 @@ require_relative 'asker/logger'
13
11
 
14
12
  require_relative 'asker/loader/project_loader'
15
13
  require_relative 'asker/loader/input_loader'
16
- class Asker
17
14
 
15
+ class Asker
18
16
  def self.init
19
17
  Skeleton.create_configuration
20
18
  end
@@ -54,9 +52,7 @@ class Asker
54
52
  end
55
53
 
56
54
  private_class_method def self.init_logger(project_data)
57
- # Create log file where to save log messages
58
- Logger.create(project_data.get(:logpath),
59
- project_data.get(:logname))
55
+ Logger.create(project_data.get(:logpath))
60
56
  Logger.instance.set_verbose(Application.instance.config['verbose'])
61
57
  Logger.verboseln '[INFO] Project open'
62
58
  Logger.verboseln ' ├── inputdirs = ' + Rainbow(project_data.get(:inputdirs)).bright
@@ -64,38 +60,6 @@ class Asker
64
60
  end
65
61
 
66
62
  private_class_method def self.create_output(project, data)
67
- Logger.verboseln "\n[INFO] Creating output files"
68
- m = ' ├── Gift questions file => '
69
- m += if Application.instance.config['output']['gift'] == 'yes'
70
- Rainbow(project.get(:outputpath)).bright
71
- else
72
- "#{project.get(:outputpath)} (No)"
73
- end
74
- Logger.verboseln m
75
-
76
- m = ' ├── Lesson file => '
77
- m += if Application.instance.config['output']['doc'] == 'yes'
78
- Rainbow(project.get(:lessonpath)).bright
79
- else
80
- "#{project.get(:lessonpath)} (No)"
81
- end
82
- Logger.verboseln m
83
-
84
- m = ' ├── YAML questions file => '
85
- m += if Application.instance.config['output']['yaml'] == 'yes'
86
- Rainbow(project.get(:yamlpath)).bright
87
- else
88
- "#{project.get(:yamlpath)} (No)"
89
- end
90
- Logger.verboseln m
91
-
92
- m = ' └── Moodle XML file => '
93
- m += if Application.instance.config['output']['moodle'] == 'yes'
94
- Rainbow(project.get(:moodlepath)).bright
95
- else
96
- "#{project.get(:moodlepath)} (No)"
97
- end
98
- Logger.verboseln m
99
63
  OutputFileExporter.export(data, project)
100
64
  StatsDisplayer.show(data)
101
65
  Logger.close
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.5.4
4
+ version: 2.5.5
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: 2022-12-15 00:00:00.000000000 Z
11
+ date: 2022-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.1'
19
+ version: '6.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '5.1'
26
+ version: '6.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: inifile
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.8'
89
+ version: '3.0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.8'
96
+ version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: thor
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -241,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
241
241
  requirements:
242
242
  - - ">="
243
243
  - !ruby/object:Gem::Version
244
- version: 3.0.4
244
+ version: '3.0'
245
245
  required_rubygems_version: !ruby/object:Gem::Requirement
246
246
  requirements:
247
247
  - - ">="