TriviaMD 0.1.6 → 0.1.8

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: 7c3b042230b7218be57af4349eb5f5c733eca5fa2e43011e5ab02ead83147d6b
4
- data.tar.gz: '028e3233cbbcd451fed7c4fa42ff045d73aa95490bfdb169e25b8822ca5d5e78'
3
+ metadata.gz: 11a573c7c5f9f468ec7b5516223b03c82e969a8422a1e05618955e27c2362cc1
4
+ data.tar.gz: 23bf44e763e2d73d21a88027a2f6e5453d0bcc5a9077d1fdf8f8549dd28e1a67
5
5
  SHA512:
6
- metadata.gz: 8b72e80621bc7826f53b59d354ac09e5c66859c4f82db4295691955f5f80115c2694ba9e553c64fdbe6f68123c2dafc508b44f5e2a732ac69b637c2e21339724
7
- data.tar.gz: 22de231eea88b58636967ed3e40fa51c8ceb0c851faf67f6671d44b8a66da07279586641f21e958826cf8ba7657de21f981c85ecf18f2ab2faf282bacabf824d
6
+ metadata.gz: 231c1b0a2cdbae0012d3634f429c1e2c273666d092483ad701808d9ab092eb6ea5a6eb621cefde207282b7129cdad53b5ae03603992022352934c0f955c16d91
7
+ data.tar.gz: 5082698b8f7d736fecd6402b17768587d0e15e53a891b5fbf90f6285b4eac732bf1bb11f5683938c00b792cb21a66d3ae0a8d17869b09d88aa45e1b88e618437
data/lib/quizzes_v1.rb CHANGED
@@ -33,14 +33,13 @@ 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
41
  neutral_comments_html: question["reason"],
42
+ neutral_comments: question["reason"],
44
43
  points_possible: 1
45
44
  }
46
45
  }
data/lib/trivia_parser.rb CHANGED
@@ -7,15 +7,24 @@ class TriviaParser
7
7
  @debug = debug
8
8
  end
9
9
 
10
+
10
11
  def get_event(c)
11
12
  return { type: :event_trivia_header } if c.type == :header && c.options[:level] == 2 && c.options[:raw_text] == "Trivia"
12
13
  return { type: :event_header } if c.type == :header
13
- return { type: :event_reason, payload: { reason: escape_html(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)
14
15
  return { type: :event_answers, payload: { answers: parse_answers(c) } } if c.type == :ul
15
16
  return { type: :event_question, payload: { question: c.children.first.children.first.value } } if c.type == :blockquote
16
17
  return { type: :no_event }
17
18
  end
18
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
+
19
28
  def parse_answers(c)
20
29
  c.children.map do |li|
21
30
  head = li.children.first.children.first
@@ -42,7 +51,7 @@ class TriviaParser
42
51
 
43
52
  @doc.root.children.each do |c|
44
53
  event = get_event(c)
45
- puts [state, c.type, event] if @debug
54
+ puts [state, c.type, event] if @debug
46
55
 
47
56
  case event[:type]
48
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.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bence Pjatacsuk