asker-tool 2.4.5 → 2.5.0

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: c936c3b95ba797cf9a1fd0652fa9b5d3154c11ebf1d1b62e3febf3a194581374
4
- data.tar.gz: 5e642c8e1ce5e0f700190c9b9caca1bdb13952a44cfe1d02837cb50cae3a8c5e
3
+ metadata.gz: c80632141abb14dfce16fd8c30023f56a807d20ad4c93fb664d89409e7f7261c
4
+ data.tar.gz: 7c478c4175f7cf7d689dc08c35443eafd55066ea8e173ce0ad0c1e675d178941
5
5
  SHA512:
6
- metadata.gz: b3433f6b80c5e89417580637175c9e11de2cfae9960b52d347deb39881e52dac34df53a53225cfc4f9766bc2b24a2717927e5ec139e0811557db1126062f96e3
7
- data.tar.gz: 97ebd51f2c232487dd51b39bb9083d23d9dba25e1c29da54c3817d4d7d04a15e2c4b99bd6ac03e1423945595f3b448b7603a9cbeef505e8f7b1c6e02e03b31ed
6
+ metadata.gz: 339b987ca596d8f40ac9767214311e7c90cc23e1a32bce078f656a8984bb4a8afed9fce6e7af526a42989c82901af66eb81c8eb9789f7d4069a2493f262c1564
7
+ data.tar.gz: 9b7387a951854aec90e288128af94cd3adaf06b8acc133a42e972a42d534c7f3093aa09e0c13f4e65eba1a9dff3cba4c848d16ed7071140882c765fc537d5528
@@ -3,11 +3,9 @@ require_relative 'concept_doc_exporter'
3
3
  require_relative 'data_gift_exporter'
4
4
  require_relative 'data_moodle_exporter'
5
5
 
6
- # Export Output data:
7
- # * Gift (ConceptAI, Code)
8
- # * YAML
9
- # * Doc (txt)
10
- # * Moodle XML (ConceptAI, Code)
6
+ ##
7
+ # Export Output data files
8
+ # * YAML, Doc (txt), Gift (ConceptAI, Code) and Moodle XML (ConceptAI, Code)
11
9
  module OutputFileExporter
12
10
  def self.export(data, project)
13
11
  config = Application.instance.config
@@ -12,9 +12,9 @@
12
12
  :f1: 'Els seguents elements son "<%=text2%>" del concepte <b><%=text1%></b>:<ul><li><%=text3%></li></ul>'
13
13
  :f2: "Els seguents elements son \"<%=text2%>\".<br/>Selecciona l'opció que no pertanyi al concepte <b><%=text1%></b>."
14
14
  :f3: 'Els seguents elements son "<%=text2%>" del concepte <b><%=text1%></b>:<br><p><%=text3%></p>(Coloca cada paraula a la seva posició correcta dins el text)'
15
- :i1: "<%=text1%><br/>Escull l'opció que millor es correspongui amb la imatge anterior.<br/>"
16
- :i2: '<%=text1%><br/>La imatge/text anterior correspo a <b><%=text2%></b>.'
17
- :i3: "<%=text1%><br/>Escriu l'opció <%=text2%>, que millor correspongui amb la imatge anterior.<br/>"
15
+ :i1: "<%=text1%><br/>Escull l'opció que millor es correspongui amb el fitxer anterior.<br/>"
16
+ :i2: '<%=text1%><br/>El fitxer anterior correspo a <b><%=text2%></b>.'
17
+ :i3: "<%=text1%><br/>Escriu l'opció <%=text2%>, que millor correspongui amb el fitxer imatge anterior.<br/>"
18
18
  :i4: '<%=text1%><br/>Definició: <i><%=text2%></i><br/><br/>(Coloca cada palabra en su posición correcta dentro del texto)'
19
19
  :s1: 'En relació al concepte <b><%=text1%></b>, ordena cada/les/els "<%=text2%>" per tal que es compleixi el criteri "<%=text3%>".<br/>'
20
20
  :t1table: "Concepte <b><%=text1%></b><br/><%=text2%>: [*]<br/><%=text3%>: \"<%=text4%>\"<br/>Escull l'opció correcta.<br/>"
@@ -12,9 +12,9 @@
12
12
  :f1: 'Die folgenden Elemente sind "<%=text2%>" des Begriffs <b><%=text1%></b>:<ul><li><%=text3%></li></ul>'
13
13
  :f2: 'Die folgenden Elemente sind "<%=text2%>".<br/>Wählen Sie die Antwortmöglichkeit aus, die nicht zum Begriff <b><%=text1%></b> passt.'
14
14
  :f3: 'Die folgenden Elemente sind "<%=text2%>" des Begriffs <b><%=text1%></b>:<br><p><%=text3%></p>(Setzen Sie die Wörter in die Lücken ein)'
15
- :i1: '<%=text1%><br/>EWählen Sie die Antwortmöglichkeit, die am besten zu dem gezeigten Bild passt.<br/>'
16
- :i2: '<%=text1%><br/>Das gezeigte Bild gehört zu <b><%=text2%></b>.'
17
- :i3: '<%=text1%><br/>Setzen Sie die Antwort ein <%=text2%>, qdie am besten zu dem gezeigten Bild passt.<br/>'
15
+ :i1: '<%=text1%><br/>EWählen Sie die Antwortmöglichkeit, die am besten zu dem gezeigten Datei passt.<br/>'
16
+ :i2: '<%=text1%><br/>Das gezeigte Datei gehört zu <b><%=text2%></b>.'
17
+ :i3: '<%=text1%><br/>Setzen Sie die Antwort ein <%=text2%>, qdie am besten zu dem gezeigten Datei passt.<br/>'
18
18
  :i4: '<%=text1%><br/>Bedeutung: <i><%=text2%></i><br/><br/>(Setzen Sie die Wörter in die Lücken ein)'
19
19
  :s1: 'Beziehen Sie sich auf den Begriff <b><%=text1%></b>, und ordnen Sie die "<%=text2%>" richtigen Lösungen zu "<%=text3%>".<br/>'
20
20
  :t1table: 'Begriff <b><%=text1%></b><br/><%=text2%>: [*]<br/><%=text3%>: "<%=text4%>"<br/>Wählen Sie die richtige Lösung aus.<br/>'
@@ -12,9 +12,9 @@
12
12
  :f1: 'The next items are "<%=text2%>" from <b><%=text1%></b> concept:<br/><ul><li><%=text3%></li></ul>'
13
13
  :f2: 'The next items are "<%=text2%>".<br/>Choose the option that not belongs concept <b><%=text1%></b>.'
14
14
  :f3: 'The next items are "<%=text2%>" from <b><%=text1%></b> concept:<br><p><%=text3%></p>(Put every word into the right position)'
15
- :i1: '<%=text1%><br/>Choose the best association for the previous image.<br/>'
16
- :i2: '<%=text1%><br/>The previous image/text corresponds to <b><%=text2%></b>.'
17
- :i3: '<%=text1%><br/>Write the best answer <%=text2%>, for the previous image.<br/>'
15
+ :i1: '<%=text1%><br/>Choose the best association for the previous file.<br/>'
16
+ :i2: '<%=text1%><br/>The previous file corresponds to <b><%=text2%></b>.'
17
+ :i3: '<%=text1%><br/>Write the best answer <%=text2%>, for the previous file.<br/>'
18
18
  :i4: '<%=text1%><br/>Definition:<br/> <i><%=text2%></i><br/><br/>(Put every word in the right text position)'
19
19
  :s1: "About <b><%=text1%></b> concept, sort every \"<%=text2%>\", so It is true that \"<%=text3%>\".<br/>"
20
20
  :t1table: '<b>Concept <%=text1%></b><br/><%=text2%>: [*]<br/><%=text3%>: "<%=text4%>"<br/>Choose the right answer.<br/>'
@@ -12,9 +12,9 @@
12
12
  :f1: 'Los siguientes elementos son "<%=text2%>" del concepto <b><%=text1%></b>:<ul><li><%=text3%></li></ul>'
13
13
  :f2: 'Los siguientes elementos son "<%=text2%>".<br/>Selecciona la opción que no pertenezca al concepto <b><%=text1%></b>.'
14
14
  :f3: 'Los siguientes elementos son "<%=text2%>" del concepto <b><%=text1%></b>:<br><p><%=text3%></p>(Coloca cada palabra en su posición correcta dentro del texto)'
15
- :i1: '<%=text1%><br/>Elige la opción que mejor se corresponda con la imagen anterior.<br/>'
16
- :i2: '<%=text1%><br/>La imagen/texto anterior corresponde a <b><%=text2%></b>.'
17
- :i3: '<%=text1%><br/>Escribe la opción <%=text2%>, que mejor corresponda con la imagen anterior.<br/>'
15
+ :i1: '<%=text1%><br/>Elige la opción que mejor se corresponda con el fichero anterior.<br/>'
16
+ :i2: '<%=text1%><br/>El fichero anterior corresponde a <b><%=text2%></b>.'
17
+ :i3: '<%=text1%><br/>Escribe la opción <%=text2%>, que mejor corresponda con el fichero anterior.<br/>'
18
18
  :i4: '<%=text1%><br/>Definición: <i><%=text2%></i><br/><br/>(Coloca cada palabra en su posición correcta dentro del texto)'
19
19
  :s1: 'En relación al concepto <b><%=text1%></b>, ordena cada/las/los "<%=text2%>" de modo que se cumpla el criterio "<%=text3%>".<br/>'
20
20
  :t1table: 'Concepto <b><%=text1%></b><br/><%=text2%>: [*]<br/><%=text3%>: "<%=text4%>"<br/>Elige la opción correcta.<br/>'
@@ -12,9 +12,9 @@
12
12
  :f1: 'Les éléments suivants sont "<%=text2%>" du concept <b><%=text1%></b>:<ul><li><%=text3%></li></ul>'
13
13
  :f2: "Les éléments suivants sont \"<%=text2%>\".<br/>Sélectionnez l'option qui n'appartient pas au concept <b><%=text1%></b>."
14
14
  :f3: 'Les éléments suivants sont "<%=text2%>" du concept <b><%=text1%></b>:<br><p><%=text3%></p>(Mettez chaque mot à la bonne position dans le texte)'
15
- :i1: "<%=text1%><br/>Choisissez l'option qui correspond le mieux à l'image précédente.<br/>"
16
- :i2: "<%=text1%><br/>L'image précédente correspond à <b><%=text2%></b>."
17
- :i3: "<%=text1%><br/>Écrivez l'option <%=text2%>, qui correspond le mieux à l'image précédente.<br/>"
15
+ :i1: "<%=text1%><br/>Choisissez l'option qui correspond le mieux à le fichier précédente.<br/>"
16
+ :i2: "<%=text1%><br/>Le fichier précédente correspond à <b><%=text2%></b>."
17
+ :i3: "<%=text1%><br/>Écrivez l'option <%=text2%>, qui correspond le mieux à le fichier précédente.<br/>"
18
18
  :i4: '<%=text1%><br/>Définition: <i><%=text2%></i><br/><br/>(Mettez chaque mot à la bonne position dans le texte)'
19
19
  :s1: "Par rapport au concept <b><%=text1%></b>, mettez dans l'ordre chaque \"<%=text2%>\" afin que le critère soit rempli \"<%=text3%>\".<br/>"
20
20
  :t1table: "Concept <b><%=text1%></b><br/><%=text2%>: [*]<br/><%=text3%>: \"<%=text4%>\"<br/>Choisissez l'option correcte.<br/>"
@@ -1,4 +1,3 @@
1
- # frozen_string_literal: true
2
1
 
3
2
  require 'base64'
4
3
 
@@ -11,12 +10,17 @@ module EmbeddedFile
11
10
  # @param value (String)
12
11
  # @param localdir (String) Input file base folder
13
12
  # @return Hash
14
- # rubocop:disable Metrics/MethodLength
15
- # rubocop:disable Metrics/AbcSize
16
13
  def self.load(value, localdir)
17
14
  # When filename is an URL
18
15
  if value.start_with?('https://') || value.start_with?('http://')
19
- return { text: "<img src=\"#{value}\" alt=\"image\" width=\"400\" height=\"300\">", file: :none }
16
+ if is_image? value
17
+ html_text = "<img src=\"#{value}\" alt=\"image\" width=\"400\" height=\"300\">"
18
+ elsif is_audio? value
19
+ html_text = "<audio src=\"#{value}\" controls></audio>"
20
+ else
21
+ html_text = "<b> #{value}: Unkown file type!</b>"
22
+ end
23
+ return { text: html_text, file: :none }
20
24
  end
21
25
 
22
26
  filepath = File.join(localdir, value)
@@ -25,18 +29,48 @@ module EmbeddedFile
25
29
  Logger.verbose Rainbow("[ERROR] Unknown file! #{filepath}").red.bright
26
30
  exit 1
27
31
  end
28
- # When filename is PNG, JPG o JPEG
29
- if ['.png', '.jpg', '.jpeg'].include? File.extname(filepath)
30
- # converts image into base64 strings
32
+ if is_image? filepath
31
33
  text = '<img src="@@PLUGINFILE@@/' + File.basename(filepath) \
32
34
  + '" alt="imagen" class="img-responsive atto_image_button_text-bottom">'
33
35
  data = '<file name="' + File.basename(filepath) + '" path="/" encoding="base64">' \
34
36
  + Base64.strict_encode64(File.open(filepath, 'rb').read) + '</file>'
35
37
  return { text: text, file: data }
38
+ elsif is_audio? filepath
39
+ text = '<audio controls><source src="@@PLUGINFILE@@/' + File.basename(filepath) \
40
+ + '">Your browser does not support the audio tag.</audio>'
41
+ data = '<file name="' + File.basename(filepath) + '" path="/" encoding="base64">' \
42
+ + Base64.strict_encode64(File.open(filepath, 'rb').read) + '</file>'
43
+ return { text: text, file: data }
44
+ elsif is_video? filepath
45
+ text = '<video controls><source src="@@PLUGINFILE@@/' + File.basename(filepath) \
46
+ + '">Your browser does not support the video tag.</video>'
47
+ data = '<file name="' + File.basename(filepath) + '" path="/" encoding="base64">' \
48
+ + Base64.strict_encode64(File.open(filepath, 'rb').read) + '</file>'
49
+ return { text: text, file: data }
36
50
  end
37
51
  # Suposse that filename is TXT file
38
52
  return { text: "<pre>#{File.read(filepath)}</pre>", file: :none } if File.exist?(filepath)
53
+
54
+ { text: :error, file: :none}
39
55
  end
40
- # rubocop:enable Metrics/MethodLength
41
- # rubocop:enable Metrics/AbcSize
56
+
57
+ def self.is_audio?(filename)
58
+ extens = ['.mp3', '.ogg', '.wav']
59
+ extens.each {|ext| return true if filename.downcase.end_with?(ext) }
60
+ false
61
+ end
62
+
63
+ def self.is_image?(filename)
64
+ extens = ['.jpg', '.jpeg', '.png']
65
+ extens.each {|ext| return true if filename.downcase.end_with?(ext) }
66
+ false
67
+ end
68
+
69
+ def self.is_video?(filename)
70
+ extens = ['.mp4', '.ogv']
71
+ extens.each {|ext| return true if filename.downcase.end_with?(ext) }
72
+ false
73
+ end
74
+
75
+
42
76
  end
data/lib/asker/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Asker
3
- VERSION = '2.4.5'
3
+ VERSION = '2.5.0'
4
4
  NAME = 'asker'
5
5
  GEM = 'asker-tool'
6
6
  CONFIGFILE = 'asker.ini'
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.4.5
4
+ version: 2.5.0
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-07-16 00:00:00.000000000 Z
11
+ date: 2022-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml