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 +4 -4
- data/README.md +6 -1
- data/lib/word_2_quiz/answer.rb +5 -1
- data/lib/word_2_quiz/helpers.rb +1 -3
- data/lib/word_2_quiz/question.rb +5 -3
- data/lib/word_2_quiz/quiz_solutions_parser.rb +7 -4
- data/lib/word_2_quiz/version.rb +1 -1
- data/word_2_quiz.gemspec +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9e1141b3b8549ccba5b35dce3549bc27d425194
|
|
4
|
+
data.tar.gz: e622ef3459681f3e2e3680e2ce5b1dc6474be1ba
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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/
|
|
54
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/atomicjolt/word2quiz.
|
data/lib/word_2_quiz/answer.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
|
data/lib/word_2_quiz/helpers.rb
CHANGED
|
@@ -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
|
-
|
|
70
|
-
match ? match.captures.first : nil
|
|
68
|
+
paragraphs[QUESTION_START].text[/^(\d+)\./, 1]
|
|
71
69
|
end
|
|
72
70
|
|
|
73
71
|
##
|
data/lib/word_2_quiz/question.rb
CHANGED
|
@@ -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
|
|
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 "
|
|
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
|
-
|
|
9
|
-
|
|
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)
|
data/lib/word_2_quiz/version.rb
CHANGED
data/word_2_quiz.gemspec
CHANGED
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.
|
|
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-
|
|
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:
|
|
84
|
+
name: doc_ripper
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
86
86
|
requirements:
|
|
87
87
|
- - "~>"
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version:
|
|
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:
|
|
96
|
+
version: 0.0.7.2
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
98
|
name: docx
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|