ruql-olx 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b338552de6eca7a95e525b113b681a31bda209ea1e2f728056361b1110cbc89d
4
- data.tar.gz: 458284a76b3f4b2df93ca269b7ca8fa28b2b66687334b2928e6e7f82c72c8879
3
+ metadata.gz: 58a477614eb1b0baea402a669b3ae78984bad1f5956f41feb236831e185f91e9
4
+ data.tar.gz: 5c3d28aac985353cf40ff49361c9c773074c3acb0be03915677997895c69d43b
5
5
  SHA512:
6
- metadata.gz: 1f69c1e66ee0d7df6df0519dad6c5724992a2143a72dacca0c5533de619d2967d8a653c65622d42ae8f4494eade64a682b67b6c9ba51927b7369066197d1dcd3
7
- data.tar.gz: a37db5380cdf926e2846ce20ce0283029d6fedc0859479cd3a287687eddc9cd5b569c6c2d183499a45ac2b45bb40ba921e6ae1d8d08169bd7d73a0b1e0c27385
6
+ metadata.gz: c7320c20e7f0de379dcf0e1173b67dbb280dcea2e67c1dad747c196cb79b7387f030b59ab80a24e0494f86ce27e86316dddb77238a7fcb900ad478cf0abea8bf
7
+ data.tar.gz: e5fa89ae5ed156ae184292fc0eea9d806d6a924161d21ee0d5d9d2dfacf4b44a0357bd1efbcf5654a44f088a9703be0b3666999a3c0b7f6e93b7bc83f5fdc26b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruql-olx (0.0.1)
4
+ ruql-olx (0.0.2)
5
5
  builder (~> 3.0)
6
6
  ruql (~> 1.0, >= 1.0.2)
7
7
 
@@ -7,6 +7,7 @@ module Ruql
7
7
 
8
8
  def initialize(quiz,options={})
9
9
  @sequential = options.delete('--sequential')
10
+ @groupselect = (options.delete('--group-select') || 1_000_000).to_i
10
11
  @output = ''
11
12
  @quiz = quiz
12
13
  @h = Builder::XmlMarkup.new(:target => @output, :indent => 2)
@@ -14,19 +15,25 @@ module Ruql
14
15
 
15
16
  def self.allowed_options
16
17
  opts = [
17
- ['--sequential', GetoptLong::REQUIRED_ARGUMENT]
18
+ ['--sequential', GetoptLong::REQUIRED_ARGUMENT],
19
+ ['--group-select', GetoptLong::REQUIRED_ARGUMENT]
18
20
  ]
19
21
  help = <<eos
20
22
  The OLX renderer supports these options:
21
- --sequential <filename>.xml
23
+ --sequential=<filename>.xml
22
24
  Write the OLX quiz header (includes quiz name, time limit, etc to <filename>.xml.
23
25
  This information can be copy-pasted into the appropriate <sequential> OLX element
24
26
  in a course export. If omitted, no quiz header .xml file is created.
27
+ --group-select=<n>
28
+ If multiple RuQL questions share the same 'group' attribute, include at most n of them
29
+ in the output. If omitted, defaults to "all questions in group".
25
30
  eos
26
31
  return [help, opts]
27
32
  end
28
33
 
29
34
  def render_quiz
35
+ @groups_seen = Hash.new { 0 }
36
+ @group_count = 0
30
37
  render_questions
31
38
  write_quiz_header if @sequential
32
39
  @output
@@ -59,6 +66,8 @@ eos
59
66
  # this is what's called when the OLX template yields:
60
67
  def render_questions
61
68
  @quiz.questions.each do |q|
69
+ # have we maxed out the number of questions per group for this group?
70
+ next unless more_in_group?(q)
62
71
  case q
63
72
  when MultipleChoice then render_multiple_choice(q)
64
73
  when SelectMultiple then render_select_multiple(q)
@@ -68,6 +77,14 @@ eos
68
77
  end
69
78
  end
70
79
 
80
+ def more_in_group?(q)
81
+ group = q.question_group
82
+ # OK to proceed if q. has no group, OR if we haven't used @groupselect questions in group
83
+ return true if group.to_s == ''
84
+ @groups_seen[group] += 1
85
+ return (@groups_seen[group] <= @groupselect)
86
+ end
87
+
71
88
  # //This Question has Html formatting in the answer
72
89
  # <problem display_name="Multiple Choice" markdown="null">
73
90
  # <multiplechoiceresponse>
@@ -1,5 +1,5 @@
1
1
  module Ruql
2
2
  class Olx
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruql-olx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Armando Fox
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-29 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruql