ruql 0.1.3 → 0.1.4
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 +4 -4
- data/bin/ruql +26 -11
- data/lib/ruql/quiz.rb +38 -0
- data/lib/ruql/renderers/html5_renderer.rb +7 -7
- metadata +22 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c4e1dbaefe63c93236938687254c7eb6dcaf0bc3
|
4
|
+
data.tar.gz: 8dfd7eaac4c4f363ed8bf83be5f72d1c428a117e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d859ea182e95f44111181c4e61c4cdb69320cde8ae30af8bdd446bc7f3c89d797cbdcc9e36628976f2c1d8f5a8f6a6a9aea67a19db2aecc47a01896325d0ce46
|
7
|
+
data.tar.gz: 35f46ed721d7987109cc7f187b3ca531ebe953736576c6dbf9607a793ace9d72d0c8b151bed950ad960415f2fe79c12a51260d24e58c1c8eabd74ee40f348bc8
|
data/bin/ruql
CHANGED
@@ -19,14 +19,27 @@ renderer choices are:
|
|
19
19
|
Qualtrics -[partially implemented] Qualtrics survey (txt) format
|
20
20
|
|
21
21
|
Global options:
|
22
|
+
-r <file>, --report=<file>
|
23
|
+
Write to <file> a 4-line report of #points, #questions, and first and last
|
24
|
+
question#. Especially useful in conjunction with the -a/--start option.
|
25
|
+
-a <first>, --start=<first>
|
26
|
+
Sets the starting ordinal value (1=first) for question numbering. Default 1.
|
27
|
+
If a filename is given, looks for a line of the form "last NN" and
|
28
|
+
starts at the number following NN.
|
22
29
|
-l <loglevel>, --log=<loglevel>
|
23
30
|
In increasing verbosity, they are 'error' (nonfatal), 'warn', 'info',
|
24
31
|
'debug'; default is 'warn'
|
25
|
-
-p <
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
32
|
+
-p <points>, --points-threshold <points>
|
33
|
+
If a question's point value is more than <points> (default: 0), include
|
34
|
+
the string "[N points]" at the beginning of the question text. Make this a
|
35
|
+
large number to avoid any points info being printed.
|
36
|
+
-P <points-string>, --points-string <points-string>
|
37
|
+
String for formatting the points description prepended to the question text,
|
38
|
+
with %d as a placeholder for the point value and %s as a placeholder for
|
39
|
+
pluralizing the word 'points' or whatever. Default is "[%d point%s]".
|
40
|
+
-R, --no-randomize
|
41
|
+
Present the answer choices in the order they appear in the RuQL file(s),
|
42
|
+
even for questions that have :randomize => true.
|
30
43
|
|
31
44
|
The EdXML renderer supports these options:
|
32
45
|
-n <name>, --name=<name>
|
@@ -42,10 +55,8 @@ The EdXML renderer supports these options:
|
|
42
55
|
|
43
56
|
The HTML5 and HTML Forms renderers supports these options:
|
44
57
|
-o <type>, --list-type=<type>
|
45
|
-
|
46
|
-
|
47
|
-
element. Type should be one of 1,a,A,i,I. Start should always be
|
48
|
-
a number indicating the ordinal value (starting from 1) of first item.
|
58
|
+
Sets the type of HTML list to use for answer choices: 'u' for unordered
|
59
|
+
(<ul>) or 'o' for ordered (<ol>). Default is 'o'.
|
49
60
|
-j <src>, --js=<src>
|
50
61
|
embed <src> for JavaScript
|
51
62
|
-t <file.html.erb>, --template=<file.html.erb>
|
@@ -74,7 +85,7 @@ The JSON renderer currently supports no options
|
|
74
85
|
|
75
86
|
The Qualtrics renderer supports these options:
|
76
87
|
-t <file.txt.erb>, --template=<file.txt.erb>
|
77
|
-
The file should have <%= yield %> where questions should go. Since this just creates survey questions, grading information is ignored.Currently supports the same type of questions as the AutoQCM renderer.
|
88
|
+
The file should have <%= yield %> where questions should go. Since this just creates survey questions, grading information is ignored. Currently supports the same type of questions as the AutoQCM renderer.
|
78
89
|
|
79
90
|
eos
|
80
91
|
exit
|
@@ -88,13 +99,17 @@ def main
|
|
88
99
|
|
89
100
|
opts = Getopt::Long.getopts(
|
90
101
|
['-o', '--list-type', Getopt::REQUIRED],
|
91
|
-
['-
|
102
|
+
['-r', '--report', Getopt::REQUIRED],
|
103
|
+
['-a', '--start', Getopt::REQUIRED],
|
92
104
|
['-c', '--css', Getopt::REQUIRED],
|
93
105
|
['-j', '--js', Getopt::REQUIRED],
|
94
106
|
['-t', '--template', Getopt::REQUIRED],
|
95
107
|
['-s', '--solutions', Getopt::BOOLEAN],
|
96
108
|
['-n', '--name', Getopt::REQUIRED],
|
97
109
|
['-l', '--log', Getopt::REQUIRED],
|
110
|
+
['-P', '--points-string', Getopt::REQUIRED],
|
111
|
+
['-p', '--points-threshold', Getopt::REQUIRED],
|
112
|
+
['-R', '--no-randomize', Getopt::BOOLEAN],
|
98
113
|
['-y', '--yaml', Getopt::REQUIRED]
|
99
114
|
)
|
100
115
|
Quiz.instance_eval "#{IO.read(filename)}"
|
data/lib/ruql/quiz.rb
CHANGED
@@ -22,12 +22,17 @@ class Quiz
|
|
22
22
|
|
23
23
|
attr_reader :renderer
|
24
24
|
attr_reader :questions
|
25
|
+
attr_reader :first_question_number
|
25
26
|
attr_reader :options
|
26
27
|
attr_reader :output
|
28
|
+
attr_reader :suppress_random
|
27
29
|
attr_reader :seed
|
28
30
|
attr_reader :logger
|
31
|
+
attr_reader :points_threshold
|
32
|
+
attr_reader :points_string
|
29
33
|
attr_accessor :title, :quizzes
|
30
34
|
|
35
|
+
|
31
36
|
def initialize(title, options={})
|
32
37
|
@output = ''
|
33
38
|
@questions = options.delete(:questions) || []
|
@@ -42,14 +47,41 @@ class Quiz
|
|
42
47
|
end
|
43
48
|
end
|
44
49
|
|
50
|
+
def get_first_question_number(spec)
|
51
|
+
return 1 if spec.nil?
|
52
|
+
return $1.to_i if spec =~ /^(\d+)$/
|
53
|
+
# file?
|
54
|
+
begin
|
55
|
+
File.readlines(spec).each do |f|
|
56
|
+
return 1 + $1.to_i if f =~ /^last\s+(\d+)/
|
57
|
+
end
|
58
|
+
return 1
|
59
|
+
rescue StandardError => e
|
60
|
+
warn "Warning: starting question numbering at 1, cannot read #{spec}: #{e.message}"
|
61
|
+
return 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
45
65
|
def self.get_renderer(renderer)
|
46
66
|
Object.const_get(renderer.to_s + 'Renderer') rescue nil
|
47
67
|
end
|
48
68
|
|
49
69
|
def render_with(renderer,options={})
|
50
70
|
srand @seed
|
71
|
+
@first_question_number = get_first_question_number(options.delete('a'))
|
72
|
+
@points_threshold = (options.delete('p') || 0).to_i
|
73
|
+
@points_string = options.delete('P') || "[%d point%s]"
|
74
|
+
@suppress_random = !!options['R']
|
51
75
|
@renderer = Quiz.get_renderer(renderer).send(:new,self,options)
|
52
76
|
@renderer.render_quiz
|
77
|
+
if (report = options.delete('r'))
|
78
|
+
File.open(report, "w") do |f|
|
79
|
+
f.puts "questions #{num_questions}"
|
80
|
+
f.puts "first #{first_question_number}"
|
81
|
+
f.puts "last #{first_question_number + num_questions - 1}"
|
82
|
+
f.puts "points #{self.points}"
|
83
|
+
end
|
84
|
+
end
|
53
85
|
@output = @renderer.output
|
54
86
|
end
|
55
87
|
|
@@ -57,6 +89,12 @@ class Quiz
|
|
57
89
|
|
58
90
|
def num_questions ; questions.length ; end
|
59
91
|
|
92
|
+
def point_string(points)
|
93
|
+
points >= points_threshold ?
|
94
|
+
sprintf(points_string.to_s, points, (points > 1 ? 's' : '')) :
|
95
|
+
''
|
96
|
+
end
|
97
|
+
|
60
98
|
def random_seed(num)
|
61
99
|
@seed = num.to_i
|
62
100
|
end
|
@@ -10,8 +10,8 @@ class Html5Renderer
|
|
10
10
|
options.delete('template') ||
|
11
11
|
File.join(File.dirname(__FILE__), '../../../templates/html5.html.erb')
|
12
12
|
@output = ''
|
13
|
-
@list_type = options.delete('o') || options.delete('list-type') || '
|
14
|
-
@list_start =
|
13
|
+
@list_type = (options.delete('o') || options.delete('list-type') || 'o')[0] + "l"
|
14
|
+
@list_start = quiz.first_question_number
|
15
15
|
@quiz = quiz
|
16
16
|
@h = Builder::XmlMarkup.new(:target => @output, :indent => 2)
|
17
17
|
end
|
@@ -34,7 +34,7 @@ class Html5Renderer
|
|
34
34
|
|
35
35
|
def render_questions
|
36
36
|
render_random_seed
|
37
|
-
@h.ol :class => 'questions', :
|
37
|
+
@h.ol :class => 'questions', :start => @list_start do
|
38
38
|
@quiz.questions.each_with_index do |q,i|
|
39
39
|
case q
|
40
40
|
when MultipleChoice, SelectMultiple, TrueFalse then render_multiple_choice(q,i)
|
@@ -51,10 +51,10 @@ class Html5Renderer
|
|
51
51
|
render_question_text(q, index) do
|
52
52
|
answers =
|
53
53
|
if q.class == TrueFalse then q.answers.sort.reverse # True always first
|
54
|
-
elsif q.randomize then q.answers.sort_by { rand }
|
54
|
+
elsif q.randomize && !@quiz.suppress_random then q.answers.sort_by { rand }
|
55
55
|
else q.answers
|
56
56
|
end
|
57
|
-
@h.
|
57
|
+
@h.__send__(@list_type, :class => 'answers') do
|
58
58
|
answers.each do |answer|
|
59
59
|
if @show_solutions
|
60
60
|
render_answer_for_solutions(answer, q.raw?, q.class == TrueFalse)
|
@@ -123,8 +123,8 @@ class Html5Renderer
|
|
123
123
|
@h.img :src => question.question_image, :class => 'question-image'
|
124
124
|
end
|
125
125
|
@h.div :class => 'text' do
|
126
|
-
qtext =
|
127
|
-
('Select
|
126
|
+
qtext = @quiz.point_string(question.points) << ' ' <<
|
127
|
+
('Select <b>all</b> that apply: ' if question.multiple).to_s <<
|
128
128
|
if question.class == FillIn then question.question_text.gsub(/\-+/, '_____________________________')
|
129
129
|
else question.question_text
|
130
130
|
end
|
metadata
CHANGED
@@ -1,85 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.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: 2016-11-
|
11
|
+
date: 2016-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: builder
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
|
-
- -
|
17
|
+
- - ">="
|
17
18
|
- !ruby/object:Gem::Version
|
18
19
|
version: '3.0'
|
20
|
+
type: :runtime
|
19
21
|
prerelease: false
|
20
|
-
name: builder
|
21
22
|
version_requirements: !ruby/object:Gem::Requirement
|
22
23
|
requirements:
|
23
|
-
- -
|
24
|
+
- - ">="
|
24
25
|
- !ruby/object:Gem::Version
|
25
26
|
version: '3.0'
|
26
|
-
type: :runtime
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
+
name: getopt
|
28
29
|
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '1.0'
|
34
|
+
type: :runtime
|
33
35
|
prerelease: false
|
34
|
-
name: getopt
|
35
36
|
version_requirements: !ruby/object:Gem::Requirement
|
36
37
|
requirements:
|
37
|
-
- -
|
38
|
+
- - ">="
|
38
39
|
- !ruby/object:Gem::Version
|
39
40
|
version: '1.0'
|
40
|
-
type: :runtime
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
42
43
|
requirement: !ruby/object:Gem::Requirement
|
43
44
|
requirements:
|
44
|
-
- -
|
45
|
+
- - ">="
|
45
46
|
- !ruby/object:Gem::Version
|
46
47
|
version: '2.0'
|
48
|
+
type: :development
|
47
49
|
prerelease: false
|
48
|
-
name: rspec
|
49
50
|
version_requirements: !ruby/object:Gem::Requirement
|
50
51
|
requirements:
|
51
|
-
- -
|
52
|
+
- - ">="
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
version: '2.0'
|
54
|
-
type: :development
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
requirement: !ruby/object:Gem::Requirement
|
57
|
-
requirements:
|
58
|
-
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '4.0'
|
61
|
-
prerelease: false
|
62
56
|
name: activesupport
|
63
|
-
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
|
-
- - ~>
|
59
|
+
- - "~>"
|
66
60
|
- !ruby/object:Gem::Version
|
67
61
|
version: '4.0'
|
68
62
|
type: :development
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - '>='
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
75
63
|
prerelease: false
|
76
|
-
name: byebug
|
77
64
|
version_requirements: !ruby/object:Gem::Requirement
|
78
65
|
requirements:
|
79
|
-
- -
|
66
|
+
- - "~>"
|
80
67
|
- !ruby/object:Gem::Version
|
81
|
-
version: '0'
|
82
|
-
type: :development
|
68
|
+
version: '4.0'
|
83
69
|
description: Ruby-embedded DSL for creating short-answer quiz questions
|
84
70
|
email: fox@cs.berkeley.edu
|
85
71
|
executables:
|
@@ -115,7 +101,7 @@ files:
|
|
115
101
|
- templates/htmlform.html.erb
|
116
102
|
homepage: http://github.com/saasbook/ruql
|
117
103
|
licenses:
|
118
|
-
-
|
104
|
+
- MIT
|
119
105
|
metadata: {}
|
120
106
|
post_install_message:
|
121
107
|
rdoc_options: []
|
@@ -123,17 +109,17 @@ require_paths:
|
|
123
109
|
- lib
|
124
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
125
111
|
requirements:
|
126
|
-
- -
|
112
|
+
- - ">="
|
127
113
|
- !ruby/object:Gem::Version
|
128
114
|
version: '0'
|
129
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
116
|
requirements:
|
131
|
-
- -
|
117
|
+
- - ">="
|
132
118
|
- !ruby/object:Gem::Version
|
133
119
|
version: '0'
|
134
120
|
requirements: []
|
135
121
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.5.1
|
137
123
|
signing_key:
|
138
124
|
specification_version: 4
|
139
125
|
summary: Ruby question language
|