TriviaMD 0.1.5 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 847f2e364b5b1118c064f21dfcc93f9038a1caa8b628e3bd594059def01bb6e3
4
- data.tar.gz: 695a7af4b76beb415b9ace4c026c5390a3d157a3ae7698a5e3d7ae69dd4c132d
3
+ metadata.gz: 5462cf53b43e7aa7a44fa2b808e185ca62799e5e751e06ba05e72a960584011e
4
+ data.tar.gz: 67e4fab1f6d6ad838d45861646d6c0e1ef413dff395883254d9e8f5280edacbc
5
5
  SHA512:
6
- metadata.gz: 29dd27234614d21c20b59c6053d8f7712412326b9f92c3f4947cbd75f283b63a5ed12a0bbc3cd21292ab1e6baa8291948794f5028109c734583486644b3991aa
7
- data.tar.gz: 4fdbbe25ce3051a02f243c94d17a5956f16d06e2cd031d9c228ed2c1741f1a21015834abe991fc8f92cfe3903b13e9022267ebde3129b1e60a2e47eda812108a
6
+ metadata.gz: 98a333278afe3f7317169ea143be56215a1e5182b929fd8a5c6cd496c076699b9bc5addd95afa762f4d88e7b8b15b58d85219cdeb6be6971b147a1856077c32a
7
+ data.tar.gz: 4f57ba77589d921a59a652522838ef0e2a6fdd1b44d10ab8e71d7e67a65fd9182655bd660cc672a0f1653d1a1d945bd1b74c55c4e26b176323f0513cee860e31
data/lib/quizzes_v1.rb CHANGED
@@ -33,15 +33,12 @@ class QuizzesV1
33
33
  end
34
34
 
35
35
  def create_question(quiz_id,question)
36
- puts quiz_id
37
36
  url = quiz_base_url + "/#{quiz_id}/questions"
38
37
  body = {
39
38
  question: {
40
39
  question_text: question["question"],
41
40
  question_type: "multiple_answers_question",
42
- neutral_comments: question["reason"],
43
- correct_comments: question["reason"],
44
- incorrect_comments: question["reason"],
41
+ neutral_comments_html: question["reason"],
45
42
  points_possible: 1
46
43
  }
47
44
  }
data/lib/trivia_parser.rb CHANGED
@@ -1,20 +1,30 @@
1
1
  require 'kramdown'
2
2
 
3
3
  class TriviaParser
4
+ include Kramdown::Utils::Html
4
5
  def initialize(file, debug = false)
5
6
  @file = file
6
7
  @debug = debug
7
8
  end
8
9
 
10
+
9
11
  def get_event(c)
10
12
  return { type: :event_trivia_header } if c.type == :header && c.options[:level] == 2 && c.options[:raw_text] == "Trivia"
11
13
  return { type: :event_header } if c.type == :header
12
- return { type: :event_reason, payload: { reason: c.children.first.value } } if c.type == :p && c.children.first.type == :codespan
14
+ return { type: :event_reason, payload: { reason: parse_reason(c.children.first) } } if c.type == :p && (c.children.first.type == :codespan || c.children.first.type == :codeblock)
13
15
  return { type: :event_answers, payload: { answers: parse_answers(c) } } if c.type == :ul
14
16
  return { type: :event_question, payload: { question: c.children.first.children.first.value } } if c.type == :blockquote
15
17
  return { type: :no_event }
16
18
  end
17
19
 
20
+ def parse_reason(c)
21
+ if c.value.start_with?("html\n")
22
+ c.value.split("html\n")[1].strip
23
+ else
24
+ escape_html(c.value)
25
+ end
26
+ end
27
+
18
28
  def parse_answers(c)
19
29
  c.children.map do |li|
20
30
  head = li.children.first.children.first
@@ -41,7 +51,7 @@ class TriviaParser
41
51
 
42
52
  @doc.root.children.each do |c|
43
53
  event = get_event(c)
44
- puts [state, c.type, event] if @debug
54
+ puts [state, c.type, event] if @debug
45
55
 
46
56
  case event[:type]
47
57
  when :event_trivia_header
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: TriviaMD
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bence Pjatacsuk