word_2_quiz 1.1.2 → 1.1.3

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
  SHA1:
3
- metadata.gz: 68bde196ceb87f284ba78a9514305e32f50dc0a0
4
- data.tar.gz: 31fdd60fbfa915228c260ebab76a50a96bd6927f
3
+ metadata.gz: a9e1141b3b8549ccba5b35dce3549bc27d425194
4
+ data.tar.gz: e622ef3459681f3e2e3680e2ce5b1dc6474be1ba
5
5
  SHA512:
6
- metadata.gz: a5269a9726d3fca559a599a767da34efdb5ea9a710901c3ee4d233f267c6dc0f7d50feaf4927d2718894246f60e8aded9f1a0fafc7c3379ded748b847216c753
7
- data.tar.gz: 55d3cbde2a5eb03fb194ca86b6191a073b990cdb6ed29a1220f51d1c652be453e7873be99d7fd06e48d7c5ffb3a307bbae2bfcd92d15875fc14f07ff075dde8a
6
+ metadata.gz: 2ec3daaa83f46619ec87bc975675d63ddcce3f1eabb750dfd085233478115debbec86871320c04e04d603961216c2d3b8d86a09a80d11cde38e0211cc3db979c
7
+ data.tar.gz: 5178b97579997c48cfa926d8cd38783917d3b36031d55cfbe3d4317198f6dd30607e79761d673c8484b560ffd42d5566e2b013ded6c06b1e69176cdf4b68e245
data/README.md CHANGED
@@ -3,6 +3,11 @@
3
3
  Converts word document quizzes to a Word2Quiz::Quiz, which can be converted to a hash or to an Instructure canvas hash format.
4
4
 
5
5
  ## Installation
6
+ This gem uses antiword to parse doc files. On a mac:
7
+ `brew install antiword`
8
+
9
+ On ubuntu:
10
+ `sudo apt-get install antiword`
6
11
 
7
12
  Add this line to your application's Gemfile:
8
13
 
@@ -46,4 +51,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
46
51
 
47
52
  ## Contributing
48
53
 
49
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/word_2_quiz.
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/atomicjolt/word2quiz.
@@ -26,7 +26,11 @@ module Word2Quiz
26
26
  ##
27
27
  def self.from_paragraphs(paragraphs, solution)
28
28
  non_empty_paragraphs = Helpers.strip_blanks(paragraphs)
29
- text = non_empty_paragraphs.map(&:to_html).join("\n")
29
+
30
+ text = non_empty_paragraphs.map do |paragraph|
31
+ paragraph.to_html.sub(/(>)[a-z]\.\s?/i, '\1') # Remove answer letter.
32
+ end.join("\n")
33
+
30
34
  start_paragraph = non_empty_paragraphs[ANSWER_START]
31
35
  is_correct = start_paragraph.text.downcase.start_with?(solution.downcase)
32
36
 
@@ -63,11 +63,9 @@ module Word2Quiz
63
63
 
64
64
  ##
65
65
  # Returns the question number
66
- #
67
66
  ##
68
67
  def self.get_question_number(paragraphs)
69
- match = paragraphs[QUESTION_START].text.match(/^(\d+)\./)
70
- match ? match.captures.first : nil
68
+ paragraphs[QUESTION_START].text[/^(\d+)\./, 1]
71
69
  end
72
70
 
73
71
  ##
@@ -30,8 +30,6 @@ module Word2Quiz
30
30
  )
31
31
  end
32
32
 
33
- answers = []
34
-
35
33
  answer_start_indexes = paragraphs.each_index.select do |i|
36
34
  # an answer starts with a letter then a dot
37
35
  paragraphs[i].text.match(/^[a-z]\./)
@@ -44,7 +42,11 @@ module Word2Quiz
44
42
 
45
43
  question_paragraphs = paragraphs.take(answer_start_indexes.first)
46
44
  question_paragraphs = Helpers.strip_blanks(question_paragraphs)
47
- question_text = question_paragraphs.map(&:to_html).join("\n")
45
+ question_text = question_paragraphs.map do |paragraph|
46
+ paragraph.to_html.sub(/(>)\d+\.\s?/, '\1') # Remove question number.
47
+ end.join("\n")
48
+
49
+ answers = []
48
50
 
49
51
  all_answer_paragraphs.each do |answer_paragraphs|
50
52
  answer = Answer.from_paragraphs(answer_paragraphs, solution)
@@ -1,12 +1,15 @@
1
- require "yomu"
2
- require "docx"
1
+ require "doc_ripper"
3
2
  require "strscan"
4
3
  require "word_2_quiz/errors"
5
4
 
6
5
  module Word2Quiz
7
6
  def self.parse_answers(file_path)
8
- yomu = Yomu.new file_path
9
- text = yomu.text
7
+ text = DocRipper::rip(file_path)
8
+
9
+ if text.nil?
10
+ raise InvalidAnswerKey.new "The uploaded answer key could not be parsed."
11
+ end
12
+
10
13
  answers = {}
11
14
 
12
15
  scanner = StringScanner.new(text)
@@ -1,3 +1,3 @@
1
1
  module Word2Quiz
2
- VERSION = "1.1.2".freeze
2
+ VERSION = "1.1.3".freeze
3
3
  end
data/word_2_quiz.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
  ].each { |d| spec.add_development_dependency(*d) }
29
29
 
30
30
  [
31
- ["yomu", "~> 0.2"],
31
+ ["doc_ripper", "~> 0.0.7.2"],
32
32
  ["docx", "~> 0.2"],
33
33
  ["numbers_in_words", "~> 0.4"],
34
34
  ["activesupport", "~> 4.2"],
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: word_2_quiz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Atomic Jolt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-25 00:00:00.000000000 Z
11
+ date: 2017-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,19 +81,19 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '4.8'
83
83
  - !ruby/object:Gem::Dependency
84
- name: yomu
84
+ name: doc_ripper
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.2'
89
+ version: 0.0.7.2
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: '0.2'
96
+ version: 0.0.7.2
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: docx
99
99
  requirement: !ruby/object:Gem::Requirement