ruql 1.0.3 → 1.0.4

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: 9fccf871f5ff726c5efff5cbc3871792bcdc6b9610296285a962018e906e9cc7
4
- data.tar.gz: e8f08ac21c0e465767decc50022c69c7e4d770e631ba9a0df01b8fb058bfcb3e
3
+ metadata.gz: ac017e4ff423a6512c6fb5ce4c96ddeb444e27d4eddc33f629889a4bec3b4ff2
4
+ data.tar.gz: 29479e8ed8d5fa71d54b6ab0ca8ac264cc81532ffc3af273a71caa3a606fb773
5
5
  SHA512:
6
- metadata.gz: 14f33e1817d330f2fee438529a1a4ef86cf7f90a68156381c73f9a99db6b1b48da7706cad0847919102c648b1d1b4371ac6a88e869eaf8efacccc9c227ee54ec
7
- data.tar.gz: 611b7d96d5597b9bd14f995c9aece5b8c46695b472470a9b7edf8a3322a8067e8bfa36ba470c032314c7c4cdb6c85f001e4ac16733fee73df85b79d37ab56106
6
+ metadata.gz: 581422b4e8c0d094d6f3c9e2f4eab77d2f29fd8a8f039a2b865fd19dd0f24247bf0e08a0227216baec18475d4c8d8d787e95cd1f987e4ff2ce83e7c042447347
7
+ data.tar.gz: 39438734c62ea04ebda86a95b1f834f9eba553530d4a4e8c8d7ac7a11bf77b456245dae069e27d32e1307652c39ae3471342406222330ebb9c2d3413d7b369a8
data/bin/ruql CHANGED
@@ -24,10 +24,12 @@ module Ruql
24
24
 
25
25
  def load_renderer
26
26
  renderer = ARGV.shift
27
+ @help = ''
28
+ @additional_options = []
27
29
  if renderer == 'stats'
28
30
  @renderer = Ruql::Stats
29
- @help = ''
30
- @additional_options = []
31
+ elsif renderer == 'json'
32
+ @renderer = Ruql::Json
31
33
  else
32
34
  begin
33
35
  require "ruql/#{renderer}"
@@ -11,6 +11,7 @@ module Ruql
11
11
  class QuizContentError < StandardError ; end
12
12
  end
13
13
 
14
+ require 'json'
14
15
  # question types
15
16
  require 'ruql/quiz'
16
17
  require 'ruql/question'
@@ -25,4 +26,6 @@ require 'ruql/open_assessment/criterion'
25
26
  require 'ruql/open_assessment/option'
26
27
  require 'ruql/open_assessment/training'
27
28
  require 'ruql/open_assessment/training_criterion'
29
+ # 2 built in "renderers"
28
30
  require 'ruql/stats'
31
+ require 'ruql/json'
@@ -13,4 +13,9 @@ class Answer
13
13
  @correct = !!correct # ensure boolean
14
14
  @explanation = explanation
15
15
  end
16
+
17
+ def as_json
18
+ Hash(:text => @answer_text, :correct => @correct,:explanation => @explanation).compact
19
+ end
20
+
16
21
  end
@@ -0,0 +1,12 @@
1
+ module Ruql
2
+ class Json
3
+ attr_reader :output
4
+ def initialize(quiz, options={})
5
+ @quiz = quiz
6
+ @output = ''
7
+ end
8
+ def render_quiz
9
+ @output = JSON.pretty_generate(@quiz.as_json)
10
+ end
11
+ end
12
+ end
@@ -12,6 +12,19 @@ class Question
12
12
  @question_comment = ''
13
13
  end
14
14
 
15
+ def as_json
16
+ Hash(
17
+ :question_text => @question_text,
18
+ :question_tags => @question_tags.compact,
19
+ :question_group => @question_group,
20
+ :answers => @answers.map(&:as_json),
21
+ :question_type => self.class.to_s,
22
+ :raw => !!@raw,
23
+ :name => @name,
24
+ :points => @points
25
+ ).compact
26
+ end
27
+
15
28
  def uid(str); @uid = str; end
16
29
 
17
30
  def raw? ; !!@raw ; end
@@ -28,6 +28,13 @@ class Quiz
28
28
  #@quiz_yaml = yaml
29
29
  end
30
30
 
31
+ def as_json
32
+ Hash(:title => @title,
33
+ :questions => @questions.map(&:as_json),
34
+ :seed => @seed
35
+ )
36
+ end
37
+
31
38
  def render_with(renderer,options={})
32
39
  srand @seed
33
40
  @renderer = renderer.send(:new,self,options)
@@ -142,4 +149,5 @@ class Quiz
142
149
  quiz.instance_eval(&block)
143
150
  @@quizzes << quiz
144
151
  end
152
+
145
153
  end
@@ -1,3 +1,3 @@
1
1
  module Ruql
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Armando Fox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-12 00:00:00.000000000 Z
11
+ date: 2020-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -107,6 +107,7 @@ files:
107
107
  - lib/ruql/answer.rb
108
108
  - lib/ruql/dropdown.rb
109
109
  - lib/ruql/fill_in.rb
110
+ - lib/ruql/json.rb
110
111
  - lib/ruql/multiple_choice.rb
111
112
  - lib/ruql/open_assessment/criterion.rb
112
113
  - lib/ruql/open_assessment/open_assessment.rb