ruql-olx 0.0.1

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: b338552de6eca7a95e525b113b681a31bda209ea1e2f728056361b1110cbc89d
4
+ data.tar.gz: 458284a76b3f4b2df93ca269b7ca8fa28b2b66687334b2928e6e7f82c72c8879
5
+ SHA512:
6
+ metadata.gz: 1f69c1e66ee0d7df6df0519dad6c5724992a2143a72dacca0c5533de619d2967d8a653c65622d42ae8f4494eade64a682b67b6c9ba51927b7369066197d1dcd3
7
+ data.tar.gz: a37db5380cdf926e2846ce20ce0283029d6fedc0859479cd3a287687eddc9cd5b569c6c2d183499a45ac2b45bb40ba921e6ae1d8d08169bd7d73a0b1e0c27385
@@ -0,0 +1,2 @@
1
+ TAGS
2
+ pkg
@@ -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-olx.gemspec
6
+ gemspec
@@ -0,0 +1,39 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruql-olx (0.0.1)
5
+ builder (~> 3.0)
6
+ ruql (~> 1.0, >= 1.0.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ builder (3.2.4)
12
+ diff-lcs (1.4.4)
13
+ rake (10.5.0)
14
+ rspec (3.9.0)
15
+ rspec-core (~> 3.9.0)
16
+ rspec-expectations (~> 3.9.0)
17
+ rspec-mocks (~> 3.9.0)
18
+ rspec-core (3.9.2)
19
+ rspec-support (~> 3.9.3)
20
+ rspec-expectations (3.9.2)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.9.0)
23
+ rspec-mocks (3.9.1)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.9.0)
26
+ rspec-support (3.9.3)
27
+ ruql (1.0.4)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.17)
34
+ rake (~> 10.0)
35
+ rspec (~> 3.0)
36
+ ruql-olx!
37
+
38
+ BUNDLED WITH
39
+ 1.17.3
@@ -0,0 +1,61 @@
1
+ # Ruql::Olx
2
+
3
+ This formatter requires [ruql](https://github.com/saasbook/ruql) and
4
+ allows formatting RuQL quizzes as OLX or Open Learning XML, a format
5
+ developed and used by [edX](https://edx.org) for rendering course assets.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ruql-olx'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ruql-olx
22
+
23
+ ## Usage
24
+
25
+ The simplest usage is `ruql olx --sequential seq.xml quizfile.rb > output.olx`.
26
+
27
+ The OLX representation of all the questions in `quizfile.rb` will be
28
+ left in the file `output.olx`.
29
+
30
+ The file `seq.xml` will contain the necessary XML markup for the quiz
31
+ metadata itself, such as time limit, the fact that it's graded, etc.
32
+ This XML snippet needs to be copied into the correct file in the
33
+ appropriate `sequentials` subdirectory of an edX course export.
34
+ If the `--sequential` option is omitted, no such file is created.
35
+
36
+ ## Limitations of current version
37
+
38
+ The time limit is computed as 1 point per minute plus 5
39
+ minutes of slop, rounded up to the nearest 5 minutes.
40
+
41
+ The other metadata items (graded or not, etc.) cannot be customized
42
+ except by manually editing the `seq.xml` file.
43
+
44
+ Normally, RuQL questions that have the same `group` attribute value
45
+ are considered a "pool" of questions from which a particular subset
46
+ are randomly used each time a quiz is generated. The current version
47
+ of the gem ignores this field and simply outputs *all* questions in
48
+ the `quizfile.rb`.
49
+
50
+
51
+ ## Development/Contributing
52
+
53
+ 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.
54
+
55
+ 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).
56
+
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/saasbook/ruql-olx. 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.
58
+
59
+ ## Code of Conduct
60
+
61
+ Everyone interacting in the Ruql::Olx project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/saasbook/ruql-olx/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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ruql/olx"
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/olx/version"
2
+ require "ruql/olx/olx"
3
+
@@ -0,0 +1,120 @@
1
+ module Ruql
2
+ class Olx
3
+ require 'builder'
4
+ require 'erb'
5
+
6
+ attr_reader :output
7
+
8
+ def initialize(quiz,options={})
9
+ @sequential = options.delete('--sequential')
10
+ @output = ''
11
+ @quiz = quiz
12
+ @h = Builder::XmlMarkup.new(:target => @output, :indent => 2)
13
+ end
14
+
15
+ def self.allowed_options
16
+ opts = [
17
+ ['--sequential', GetoptLong::REQUIRED_ARGUMENT]
18
+ ]
19
+ help = <<eos
20
+ The OLX renderer supports these options:
21
+ --sequential <filename>.xml
22
+ Write the OLX quiz header (includes quiz name, time limit, etc to <filename>.xml.
23
+ This information can be copy-pasted into the appropriate <sequential> OLX element
24
+ in a course export. If omitted, no quiz header .xml file is created.
25
+ eos
26
+ return [help, opts]
27
+ end
28
+
29
+ def render_quiz
30
+ render_questions
31
+ write_quiz_header if @sequential
32
+ @output
33
+ end
34
+
35
+ # write the quiz header
36
+ def write_quiz_header
37
+ fh = File.open(@sequential, 'w')
38
+ @quiz_header = Builder::XmlMarkup.new(:target => fh, :indent => 2)
39
+ @quiz_header.sequential(
40
+ is_time_limited: "true",
41
+ default_time_limit_minutes: self.time_limit,
42
+ display_name: @quiz.title,
43
+ exam_review_rules: "",
44
+ is_onboarding_exam: "false",
45
+ is_practice_exam: "false",
46
+ is_proctored_enabled: "false")
47
+ fh.close
48
+ end
49
+
50
+ def time_limit
51
+ minutes_per_point = 1
52
+ slop = 5 # extra time for setup, etc
53
+ limit = @quiz.points.to_i * minutes_per_point + slop
54
+ # round up to next 5 minutes
55
+ limit += 5 - (limit % 5)
56
+ limit
57
+ end
58
+
59
+ # this is what's called when the OLX template yields:
60
+ def render_questions
61
+ @quiz.questions.each do |q|
62
+ case q
63
+ when MultipleChoice then render_multiple_choice(q)
64
+ when SelectMultiple then render_select_multiple(q)
65
+ else
66
+ raise Ruql::QuizContentError.new "Unknown question type: #{q}"
67
+ end
68
+ end
69
+ end
70
+
71
+ # //This Question has Html formatting in the answer
72
+ # <problem display_name="Multiple Choice" markdown="null">
73
+ # <multiplechoiceresponse>
74
+ # <label>Which condition is necessary when using Ruby's collection methods such as map and reject?</label>
75
+ # <description> </description>
76
+ # <choicegroup type="MultipleChoice">
77
+ # <choice correct="false">The collection on which they operate must consist of objects of the same type.</choice>
78
+ # <choice correct="true">The collection must respond to <pre> &lt;tt&gt;each&lt;/tt&gt; </pre></choice>
79
+ # <choice correct="false">Every element of the collection must respond to <pre> &lt;tt&gt;each&lt;/tt&gt; </pre></choice>
80
+ # <choice correct="false">The collection itself must be one of Ruby's built-in collection types, such as <pre> &lt;tt&gt;Array&lt;/tt&gt; or &lt;tt&gt;Set&lt;/tt&gt; </pre></choice>
81
+ # </choicegroup>
82
+ # </multiplechoiceresponse>
83
+ # </problem>
84
+ def render_multiple_choice(q)
85
+ @h.problem(display_name: 'MultipleChoice', markdown: 'null') do
86
+ @h.multiplechoiceresponse do
87
+ render_question_text(q)
88
+ @h.choicegroup(type: 'MultipleChoice') do
89
+ render_answers(q)
90
+ end
91
+ end
92
+ end
93
+ @output << "\n\n"
94
+ end
95
+
96
+ def render_select_multiple(q)
97
+ @h.problem(display_name: 'Checkboxes', markdown: 'null') do
98
+ @h.choiceresponse do
99
+ render_question_text(q)
100
+ @h.checkboxgroup do
101
+ render_answers(q)
102
+ end
103
+ end
104
+ end
105
+ end
106
+
107
+ def render_answers(q)
108
+ q.answers.each do |answer|
109
+ @h.choice(correct: answer.correct?) { |l| l << answer.answer_text }
110
+ end
111
+ end
112
+
113
+ def render_question_text(q)
114
+ qtext = q.question_text
115
+ qtext << " Select ALL that apply." if q.multiple
116
+ @h.label { |l| l << qtext }
117
+ end
118
+
119
+ end
120
+ end
@@ -0,0 +1,5 @@
1
+ module Ruql
2
+ class Olx
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,43 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "ruql/olx/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ruql-olx"
8
+ spec.version = Ruql::Olx::VERSION
9
+ spec.summary = "OLX 5 renderer for RuQL"
10
+ spec.description = "OLX 5 renderer for RuQL"
11
+ spec.authors = ["Armando Fox"]
12
+ spec.email = 'fox@berkeley.edu'
13
+ spec.homepage = 'https://github.com/saasbook/ruql-olx'
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.2'
28
+ spec.add_runtime_dependency 'builder', '~> 3.0'
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_development_dependency "bundler", "~> 1.17"
40
+ spec.add_development_dependency "rake", "~> 10.0"
41
+ spec.add_development_dependency "rspec", "~> 3.0"
42
+ end
43
+
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruql-olx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Armando Fox
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-07-29 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.2
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.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: builder
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '3.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.17'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.17'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '10.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '10.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ description: OLX 5 renderer for RuQL
90
+ email: fox@berkeley.edu
91
+ executables: []
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - ".gitignore"
96
+ - CODE_OF_CONDUCT.md
97
+ - Gemfile
98
+ - Gemfile.lock
99
+ - README.md
100
+ - Rakefile
101
+ - bin/console
102
+ - bin/setup
103
+ - lib/ruql/olx.rb
104
+ - lib/ruql/olx/olx.rb
105
+ - lib/ruql/olx/version.rb
106
+ - ruql-olx.gemspec
107
+ homepage: https://github.com/saasbook/ruql-olx
108
+ licenses: []
109
+ metadata:
110
+ allowed_push_host: https://rubygems.org
111
+ homepage_uri: https://github.com/saasbook/ruql-olx
112
+ source_code_uri: https://github.com/saasbook/ruql-olx
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubygems_version: 3.0.8
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: OLX 5 renderer for RuQL
132
+ test_files: []