ruql-olx 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ruql/olx/olx.rb +19 -2
- data/lib/ruql/olx/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58a477614eb1b0baea402a669b3ae78984bad1f5956f41feb236831e185f91e9
|
4
|
+
data.tar.gz: 5c3d28aac985353cf40ff49361c9c773074c3acb0be03915677997895c69d43b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7320c20e7f0de379dcf0e1173b67dbb280dcea2e67c1dad747c196cb79b7387f030b59ab80a24e0494f86ce27e86316dddb77238a7fcb900ad478cf0abea8bf
|
7
|
+
data.tar.gz: e5fa89ae5ed156ae184292fc0eea9d806d6a924161d21ee0d5d9d2dfacf4b44a0357bd1efbcf5654a44f088a9703be0b3666999a3c0b7f6e93b7bc83f5fdc26b
|
data/Gemfile.lock
CHANGED
data/lib/ruql/olx/olx.rb
CHANGED
@@ -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
|
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>
|
data/lib/ruql/olx/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruql
|