ruql-json 1.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9f89517af580a8ef90b3703594891a491f4d6f147eacee85985989581f1f9589
4
+ data.tar.gz: 220da3f3fd936611de1065a9ee597a0a8ee5463d14032977a8ee30d527cf9220
5
+ SHA512:
6
+ metadata.gz: 8d3976f99f1e4249aa1de80efb84da74d4e4014697b3e86a6ed77f781e6079b4174b46f955845d2f4453e4c0a258dc120e53ada272630fbbde57583f618dee4f
7
+ data.tar.gz: 69a9f35d0e11ed2a20f0a9b4648bdf6b4b99a7d6ffbcb68a66209169579ac45d7110d21cdd745ef8ac3eb3093154747098e1c0afa991f0fb65b8b912522323c5
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 1.17.3
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at fox@cs.berkeley.edu. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in ruql-json.gemspec
6
+ gemspec
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruql-json (1.0.0)
5
+ ruql (~> 1.0, >= 1.0.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.3)
11
+ rake (10.5.0)
12
+ rspec (3.9.0)
13
+ rspec-core (~> 3.9.0)
14
+ rspec-expectations (~> 3.9.0)
15
+ rspec-mocks (~> 3.9.0)
16
+ rspec-core (3.9.2)
17
+ rspec-support (~> 3.9.3)
18
+ rspec-expectations (3.9.2)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.9.0)
21
+ rspec-mocks (3.9.1)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.9.0)
24
+ rspec-support (3.9.3)
25
+ ruql (1.0.3)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ bundler (~> 1.17)
32
+ rake (~> 10.0)
33
+ rspec (~> 3.0)
34
+ ruql-json!
35
+
36
+ BUNDLED WITH
37
+ 1.17.3
@@ -0,0 +1,35 @@
1
+ # Ruql::Json
2
+
3
+ This formatter requires [ruql](https://github.com/saasbook/ruql) and
4
+ allows formatting RuQL quizzes as simple JSON objects. This
5
+ capability is mostly used by Course Question Bank.
6
+
7
+ ## Installation
8
+
9
+ Add to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ruql-json'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ruql-jsona
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/saasbook/ruql-json. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
32
+
33
+ ## Code of Conduct
34
+
35
+ Everyone interacting in the Ruql::Json project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ruql-json/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/TAGS ADDED
@@ -0,0 +1,103 @@
1
+
2
+ CODE_OF_CONDUCT.md,69
3
+ In the interest of fostering an open and welcoming environment,5,55
4
+
5
+ bin/setup,10
6
+ IFS=3,38
7
+
8
+ ruql-json.gemspec,83
9
+ lib 2,1
10
+ spec.bindir bindir34,1413
11
+ spec.require_paths require_paths36,1517
12
+
13
+ lib/ruql/json/json.rb,283
14
+ module Ruql1,0
15
+ class Json2,12
16
+ attr_reader :outputoutput5,49
17
+ def initialize(7,74
18
+ def self.allowed_optionsallowed_options15,254
19
+ def render_quiz19,313
20
+ def render_multiple_choice(31,712
21
+ def answers_to_json_array(39,935
22
+ def render_fill_in(52,1268
23
+
24
+ lib/ruql/json/version.rb,52
25
+ module Ruql1,0
26
+ class JSON2,12
27
+ VERSION 3,25
28
+
29
+ Gemfile,17
30
+ git_source(3,31
31
+
32
+ Gemfile.lock,20
33
+ builder 5,48
34
+
35
+ .git/config,30
36
+ repositoryformatversion 2,7
37
+
38
+ .git/description,24
39
+ Unnamed repository;1,0
40
+
41
+ .git/hooks/pre-rebase.sample,16
42
+ publish=18,587
43
+
44
+ .git/hooks/applypatch-msg.sample,18
45
+ commitmsg=13,367
46
+
47
+ .git/hooks/fsmonitor-watchman.sample,288
48
+ my ($version, $time)($version, $time19,598
49
+ my $git_work_tree;git_work_tree31,867
50
+ my $retry retry40,1047
51
+ sub launch_watchman 44,1083
52
+ my $pid pid46,1106
53
+ my $query query63,1824
54
+ my $response response73,2054
55
+ my $json_pkg;json_pkg80,2333
56
+ my $o o90,2469
57
+ local $,112,3284
58
+
59
+ .git/hooks/pre-receive.sample,12
60
+ i=22,520
61
+
62
+ .git/hooks/prepare-commit-msg.sample,24
63
+ COMMIT_MSG_FILE=23,857
64
+
65
+ .git/hooks/pre-applypatch.sample,18
66
+ precommit=12,313
67
+
68
+ .git/hooks/pre-push.sample,15
69
+ remote=22,770
70
+
71
+ .git/hooks/update.sample,78
72
+ refname=28,929
73
+ allowunannotated=46,1315
74
+ zero=63,1896
75
+ newrev_type=65,1977
76
+
77
+ .travis.yml,0
78
+
79
+ .git/hooks/post-update.sample,0
80
+
81
+ .git/hooks/pre-commit.sample,0
82
+
83
+ .git/hooks/commit-msg.sample,0
84
+
85
+ .git/info/exclude,0
86
+
87
+ .git/HEAD,0
88
+
89
+ lib/ruql/json.rb,0
90
+
91
+ .gitignore,0
92
+
93
+ Rakefile,0
94
+
95
+ README.md,0
96
+
97
+ spec/ruql/json_spec.rb,0
98
+
99
+ spec/spec_helper.rb,0
100
+
101
+ bin/console,0
102
+
103
+ .rspec,0
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ruql/json"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ require "ruql/json/version"
2
+ require "ruql/json/json"
3
+
@@ -0,0 +1,54 @@
1
+ module Ruql
2
+ class Json
3
+ require 'json'
4
+
5
+ attr_reader :output
6
+
7
+ def initialize(quiz,options={})
8
+ @output = ''
9
+ @json_array = []
10
+ @quiz = quiz
11
+ end
12
+
13
+ def self.allowed_options
14
+ return ['',[]]
15
+ end
16
+
17
+ def render_quiz
18
+ @quiz.questions.each do |question|
19
+ case question
20
+ when MultipleChoice, SelectMultiple, TrueFalse then render_multiple_choice(question)
21
+ when FillIn then render_fill_in(question) # not currently supported
22
+ else
23
+ raise "Unknown question type: #{question}"
24
+ end
25
+ end
26
+ @output = ::JSON.pretty_generate(@json_array)
27
+ end
28
+
29
+ def render_multiple_choice(question)
30
+ question_hash = {
31
+ "text" => question.question_text,
32
+ "answers" => answers_to_json_array(question.answers)
33
+ }
34
+ @json_array.push(question_hash)
35
+ end
36
+
37
+ def answers_to_json_array(answers)
38
+ answers_array = []
39
+ answers.each do |answer|
40
+ answer_json = {
41
+ "text" => answer.answer_text,
42
+ "explanation" => answer.explanation,
43
+ "correct" => answer.correct
44
+ }
45
+ answers_array.push(answer_json)
46
+ end
47
+ answers_array
48
+ end
49
+
50
+ def render_fill_in(q)
51
+ # fill-in-the-blank questions not currently supported
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,5 @@
1
+ module Ruql
2
+ class Json
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,42 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ruql/json/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruql-json"
8
+ spec.version = Ruql::Json::VERSION
9
+ spec.authors = ["Armando Fox"]
10
+ spec.email = ["fox@berkeley.edu"]
11
+ spec.summary = "Simple JSON renderer for RuQL"
12
+ spec.description = "Simple JSON renderer for RuQL"
13
+ spec.homepage = 'https://github.com/saasbook/ruql-json'
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = spec.homepage
22
+ #spec.metadata["changelog_uri"] = ''
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+ spec.add_runtime_dependency 'ruql', '~> 1.0', '>= 1.0.3'
28
+
29
+ # Specify which files should be added to the gem when it is released.
30
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
31
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
32
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
33
+ end
34
+ spec.bindir = "exe"
35
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
+ spec.require_paths = ["lib"]
37
+
38
+ spec.add_development_dependency "bundler", "~> 1.17"
39
+ spec.add_development_dependency "rake", "~> 10.0"
40
+ spec.add_development_dependency "rspec", "~> 3.0"
41
+ end
42
+
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruql-json
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Armando Fox
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruql
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.17'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.17'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ description: Simple JSON renderer for RuQL
76
+ email:
77
+ - fox@berkeley.edu
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - ".gitignore"
83
+ - ".rspec"
84
+ - ".travis.yml"
85
+ - CODE_OF_CONDUCT.md
86
+ - Gemfile
87
+ - Gemfile.lock
88
+ - README.md
89
+ - Rakefile
90
+ - TAGS
91
+ - bin/console
92
+ - bin/setup
93
+ - lib/ruql/json.rb
94
+ - lib/ruql/json/json.rb
95
+ - lib/ruql/json/version.rb
96
+ - ruql-json.gemspec
97
+ homepage: https://github.com/saasbook/ruql-json
98
+ licenses: []
99
+ metadata:
100
+ allowed_push_host: https://rubygems.org
101
+ homepage_uri: https://github.com/saasbook/ruql-json
102
+ source_code_uri: https://github.com/saasbook/ruql-json
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubygems_version: 3.0.8
119
+ signing_key:
120
+ specification_version: 4
121
+ summary: Simple JSON renderer for RuQL
122
+ test_files: []