ruql 0.1.3 → 1.0.3
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 +5 -5
- data/.gitignore +14 -0
- data/.travis.yml +7 -0
- data/Gemfile +6 -0
- data/LICENSE +6 -0
- data/README.md +308 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/ruql +88 -98
- data/bin/setup +8 -0
- data/examples/estilo.css +1 -0
- data/examples/example.rb +37 -0
- data/examples/file.html +94 -0
- data/examples/help.txt +55 -0
- data/examples/preguntas-TFG-20140224-0050.txt +32 -0
- data/examples/preguntas-TFG-20140224-0050.xml +168 -0
- data/examples/prueba.js +3 -0
- data/lib/ruql.rb +7 -3
- data/lib/ruql/answer.rb +2 -14
- data/lib/ruql/multiple_choice.rb +1 -1
- data/lib/ruql/open_assessment/open_assessment.rb +1 -1
- data/lib/ruql/question.rb +11 -46
- data/lib/ruql/quiz.rb +47 -36
- data/lib/ruql/renderers/edxml_renderer.rb +1 -1
- data/lib/ruql/renderers/html5_renderer.rb +58 -16
- data/lib/ruql/renderers/json_renderer.rb +35 -1
- data/lib/ruql/renderers/xml_renderer.rb +148 -0
- data/lib/ruql/select_multiple.rb +1 -0
- data/lib/ruql/stats.rb +18 -0
- data/lib/ruql/true_false.rb +1 -1
- data/lib/ruql/version.rb +3 -0
- data/ruql.gemspec +43 -0
- metadata +57 -39
- data/templates/autoqcm.tex.erb +0 -1
- data/templates/html5.html.erb +0 -42
- data/templates/htmlform.html.erb +0 -44
data/bin/setup
ADDED
data/examples/estilo.css
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.instructions { clear: both; border: 5px solid black; align: left; padding: 2ex; margin: 2ex; }
|
data/examples/example.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
quiz 'Example quiz' do
|
2
|
+
|
3
|
+
fill_in :points => 2 do
|
4
|
+
text 'The capital of California is ---'
|
5
|
+
answer 'sacramento'
|
6
|
+
end
|
7
|
+
|
8
|
+
choice_answer :randomize => true do
|
9
|
+
text "What is the largest US state?"
|
10
|
+
explanation "Not big enough." # for distractors without their own explanation
|
11
|
+
answer 'Alaska'
|
12
|
+
distractor 'Hawaii'
|
13
|
+
distractor 'Texas', :explanation => "That's pretty big, but think colder."
|
14
|
+
end
|
15
|
+
|
16
|
+
select_multiple do
|
17
|
+
text "Which are American political parties?"
|
18
|
+
answer "Democrats"
|
19
|
+
answer "Republicans"
|
20
|
+
answer "Greens", :explanation => "Yes, they're a party!"
|
21
|
+
distractor "Tories", :explanation => "They're British"
|
22
|
+
distractor "Social Democrats"
|
23
|
+
end
|
24
|
+
|
25
|
+
select_multiple do
|
26
|
+
text "Which are American political parties?"
|
27
|
+
answer "Democrats"
|
28
|
+
answer "Republicans"
|
29
|
+
answer "Greens", :explanation => "Yes, they're a party!"
|
30
|
+
distractor "Tories", :explanation => "They're British"
|
31
|
+
distractor "Social Democrats"
|
32
|
+
end
|
33
|
+
|
34
|
+
truefalse 'The week has 7 days.', true
|
35
|
+
truefalse 'The earth is flat.', false, :explanation => 'No, just looks that way'
|
36
|
+
|
37
|
+
end
|
data/examples/file.html
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Example quiz</title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
<!-- Seed: 193198071281985290800198331169288892539 -->
|
7
|
+
<form>
|
8
|
+
<ol class="questions">
|
9
|
+
<li id="question-0" class="question fillin ">
|
10
|
+
<div class="text">
|
11
|
+
<p>
|
12
|
+
[2 points] The capital of California is <input type="text" class="fillin"/>
|
13
|
+
</p>
|
14
|
+
</div>
|
15
|
+
</li>
|
16
|
+
<li id="question-1" class="question multiplechoice ">
|
17
|
+
<div class="text">
|
18
|
+
<p>
|
19
|
+
[1 point] What is the largest US state? </p>
|
20
|
+
</div>
|
21
|
+
<ol class="answers">
|
22
|
+
<input type="radio" name="a" class="select">
|
23
|
+
Alaska</br> </input>
|
24
|
+
<input type="radio" name="a" class="select">
|
25
|
+
Texas</br> </input>
|
26
|
+
<input type="radio" name="a" class="select">
|
27
|
+
Hawaii</br> </input>
|
28
|
+
</ol>
|
29
|
+
</li>
|
30
|
+
<li id="question-2" class="question selectmultiple multiple">
|
31
|
+
<div class="text">
|
32
|
+
<p>
|
33
|
+
[1 point] Select ALL that apply: Which are American political parties? </p>
|
34
|
+
</div>
|
35
|
+
<ol class="answers">
|
36
|
+
<input type="checkbox" name="b" class="check">
|
37
|
+
Democrats</br> </input>
|
38
|
+
<input type="checkbox" name="b" class="check">
|
39
|
+
Republicans</br> </input>
|
40
|
+
<input type="checkbox" name="b" class="check">
|
41
|
+
Greens</br> </input>
|
42
|
+
<input type="checkbox" name="b" class="check">
|
43
|
+
Tories</br> </input>
|
44
|
+
<input type="checkbox" name="b" class="check">
|
45
|
+
Social Democrats</br> </input>
|
46
|
+
</ol>
|
47
|
+
</li>
|
48
|
+
<li id="question-3" class="question selectmultiple multiple">
|
49
|
+
<div class="text">
|
50
|
+
<p>
|
51
|
+
[1 point] Select ALL that apply: Which are American political parties? </p>
|
52
|
+
</div>
|
53
|
+
<ol class="answers">
|
54
|
+
<input type="checkbox" name="b" class="check">
|
55
|
+
Democrats</br> </input>
|
56
|
+
<input type="checkbox" name="b" class="check">
|
57
|
+
Republicans</br> </input>
|
58
|
+
<input type="checkbox" name="b" class="check">
|
59
|
+
Greens</br> </input>
|
60
|
+
<input type="checkbox" name="b" class="check">
|
61
|
+
Tories</br> </input>
|
62
|
+
<input type="checkbox" name="b" class="check">
|
63
|
+
Social Democrats</br> </input>
|
64
|
+
</ol>
|
65
|
+
</li>
|
66
|
+
<li id="question-4" class="question truefalse ">
|
67
|
+
<div class="text">
|
68
|
+
<p>
|
69
|
+
[1 point] True or False: The week has 7 days. </p>
|
70
|
+
</div>
|
71
|
+
<ol class="answers">
|
72
|
+
<input type="radio" name="a" class="select">
|
73
|
+
True</br> </input>
|
74
|
+
<input type="radio" name="a" class="select">
|
75
|
+
False</br> </input>
|
76
|
+
</ol>
|
77
|
+
</li>
|
78
|
+
<li id="question-5" class="question truefalse ">
|
79
|
+
<div class="text">
|
80
|
+
<p>
|
81
|
+
[1 point] True or False: The earth is flat. </p>
|
82
|
+
</div>
|
83
|
+
<ol class="answers">
|
84
|
+
<input type="radio" name="a" class="select">
|
85
|
+
True</br> </input>
|
86
|
+
<input type="radio" name="a" class="select">
|
87
|
+
False</br> </input>
|
88
|
+
</ol>
|
89
|
+
</li>
|
90
|
+
</ol>
|
91
|
+
<input type="submit" value="Enviar"/>
|
92
|
+
</form>
|
93
|
+
</body>
|
94
|
+
</html>
|
data/examples/help.txt
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
Usage: #<Enumerator:0x979a960> filename.rb renderer [options]
|
2
|
+
filename.rb contains questions expressed in RuQL
|
3
|
+
|
4
|
+
renderer choices are:
|
5
|
+
Html5 - HTML 5 suitable for Web display/printing
|
6
|
+
EdXml - XML for OpenEdX platform in-course questions
|
7
|
+
AutoQCM - LaTeX for use with AutoQCM (http://home.gna.org/auto-qcm)
|
8
|
+
Coursera- [obsolete] Coursera HTML/XML format for online auto-grading
|
9
|
+
JSON - [partially implemented] JSON format
|
10
|
+
|
11
|
+
Global options:
|
12
|
+
-l <loglevel>, --log=<loglevel>
|
13
|
+
In increasing verbosity, they are 'error' (nonfatal), 'warn', 'info',
|
14
|
+
'debug'; default is 'warn'
|
15
|
+
-p <penalty>, --penalty <penalty>
|
16
|
+
The penalty for WRONG answers, as a fraction of the penalty for
|
17
|
+
RIGHT answers. For a 2-point question, penalty=0.25 means 1/2 point
|
18
|
+
(0.25 * 2) deducted for WRONG answer. Default is 0. Not all
|
19
|
+
output formats are able to do something useful with this.
|
20
|
+
|
21
|
+
The EdXML renderer supports these options:
|
22
|
+
-n <name>, --name=<name>
|
23
|
+
Only render the question(s) that have :name => 'name'.
|
24
|
+
NOTE: Some markup that is legal in RuQL questions will break the EdX parser.
|
25
|
+
Manually check your questions as you enter them into EdX. Code seems to
|
26
|
+
be particularly troublesome.
|
27
|
+
NOTE: The 'points' and 'randomize' attributes of questions are not honored by
|
28
|
+
some systems.
|
29
|
+
|
30
|
+
The HTML5 renderer supports these options:
|
31
|
+
-c <href>, --css=<href>
|
32
|
+
embed <href> for stylesheet into generated HTML5
|
33
|
+
-t <file.html.erb>, --template=<file.html.erb>
|
34
|
+
Use file.html.erb as HTML template rather than generating our own file.
|
35
|
+
file.html.erb should have <%= yield %> where questions should go.
|
36
|
+
An example is in the templates/ directory of RuQL.
|
37
|
+
The following local variables will be replaced with their values in
|
38
|
+
the template:
|
39
|
+
<%= quiz.title %> - the quiz title
|
40
|
+
<%= quiz.num_questions %> - total number of questions
|
41
|
+
<%= quiz.points %> - total number of points for whole quiz
|
42
|
+
-s, --solutions
|
43
|
+
generate solutions (showing correct answers and explanations)
|
44
|
+
NOTE: If there is more than one quiz (collection of questions) in the file,
|
45
|
+
a complete <html>...</html> block is produced in the output for EACH quiz.
|
46
|
+
|
47
|
+
The AutoQCM renderer supports these options:
|
48
|
+
-t <file.tex.erb>, --template=<file.tex.erb>
|
49
|
+
MANDATORY: Use file.tex.erb as LaTeX/AutoQCM template.
|
50
|
+
The file should have <%= yield %> where questions should go.
|
51
|
+
See the description of template under HTML5 renderer for variable
|
52
|
+
substitutions that can occur in the quiz body.
|
53
|
+
|
54
|
+
The JSON renderer currently supports no options
|
55
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
// question: 0 name: Switch category to $course$/Por defecto en Página Principal
|
2
|
+
$CATEGORY: $course$/Por defecto en Página Principal
|
3
|
+
|
4
|
+
|
5
|
+
// question: 2 name: Opción múltiple
|
6
|
+
::Opción múltiple::[html]<p>What is the largest US state?</p>{
|
7
|
+
=<p>Alaska</p>
|
8
|
+
~<p>Hawaii</p>
|
9
|
+
~<p>Texas</p>
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
// question: 3 name: Opción múltiple (Multirespuesta)
|
14
|
+
::Opción múltiple (Multirespuesta)::[html]<p>Which are American political parties?</p>{
|
15
|
+
~%33.33333%<p>Democrats</p>
|
16
|
+
~%33.33333%<p>Republicans</p>
|
17
|
+
~%33.33333%<p>Greens</p>
|
18
|
+
~<p>Tories</p>
|
19
|
+
~<p>Social Democrats</p>
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
// question: 1 name: Respuesta corta
|
24
|
+
::Respuesta corta::[html]<p>The capital of California is...</p>{
|
25
|
+
=%100%Sacramento#
|
26
|
+
}
|
27
|
+
|
28
|
+
|
29
|
+
// question: 4 name: Verdadero/Falso
|
30
|
+
::Verdadero/Falso::[html]<p>The week has 7 days.</p>{TRUE}
|
31
|
+
|
32
|
+
|
@@ -0,0 +1,168 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<quiz>
|
3
|
+
<!-- question: 0 -->
|
4
|
+
<question type="category">
|
5
|
+
<category>
|
6
|
+
<text>$course$/Por defecto en Página Principal</text>
|
7
|
+
|
8
|
+
</category>
|
9
|
+
</question>
|
10
|
+
|
11
|
+
<!-- question: 2 -->
|
12
|
+
<question type="multichoice">
|
13
|
+
<name>
|
14
|
+
<text>Opción múltiple</text>
|
15
|
+
</name>
|
16
|
+
<questiontext format="html">
|
17
|
+
<text><![CDATA[<p>What is the largest US state?</p>]]></text>
|
18
|
+
</questiontext>
|
19
|
+
<generalfeedback format="html">
|
20
|
+
<text></text>
|
21
|
+
</generalfeedback>
|
22
|
+
<defaultgrade>1.0000000</defaultgrade>
|
23
|
+
<penalty>0.3333333</penalty>
|
24
|
+
<hidden>0</hidden>
|
25
|
+
<single>true</single>
|
26
|
+
<shuffleanswers>true</shuffleanswers>
|
27
|
+
<answernumbering>abc</answernumbering>
|
28
|
+
<correctfeedback format="html">
|
29
|
+
<text><![CDATA[<p>Respuesta correcta</p>]]></text>
|
30
|
+
</correctfeedback>
|
31
|
+
<partiallycorrectfeedback format="html">
|
32
|
+
<text><![CDATA[<p>Respuesta parcialmente correcta.</p>]]></text>
|
33
|
+
</partiallycorrectfeedback>
|
34
|
+
<incorrectfeedback format="html">
|
35
|
+
<text><![CDATA[<p>Respuesta incorrecta.</p>]]></text>
|
36
|
+
</incorrectfeedback>
|
37
|
+
<shownumcorrect/>
|
38
|
+
<answer fraction="100" format="html">
|
39
|
+
<text><![CDATA[<p>Alaska</p>]]></text>
|
40
|
+
<feedback format="html">
|
41
|
+
<text></text>
|
42
|
+
</feedback>
|
43
|
+
</answer>
|
44
|
+
<answer fraction="0" format="html">
|
45
|
+
<text><![CDATA[<p>Hawaii</p>]]></text>
|
46
|
+
<feedback format="html">
|
47
|
+
<text></text>
|
48
|
+
</feedback>
|
49
|
+
</answer>
|
50
|
+
<answer fraction="0" format="html">
|
51
|
+
<text><![CDATA[<p>Texas</p>]]></text>
|
52
|
+
<feedback format="html">
|
53
|
+
<text></text>
|
54
|
+
</feedback>
|
55
|
+
</answer>
|
56
|
+
</question>
|
57
|
+
|
58
|
+
<!-- question: 3 -->
|
59
|
+
<question type="multichoice">
|
60
|
+
<name>
|
61
|
+
<text>Opción múltiple (Multirespuesta)</text>
|
62
|
+
</name>
|
63
|
+
<questiontext format="html">
|
64
|
+
<text><![CDATA[<p>Which are American political parties?</p>]]></text>
|
65
|
+
</questiontext>
|
66
|
+
<generalfeedback format="html">
|
67
|
+
<text></text>
|
68
|
+
</generalfeedback>
|
69
|
+
<defaultgrade>1.0000000</defaultgrade>
|
70
|
+
<penalty>0.3333333</penalty>
|
71
|
+
<hidden>0</hidden>
|
72
|
+
<single>false</single>
|
73
|
+
<shuffleanswers>true</shuffleanswers>
|
74
|
+
<answernumbering>abc</answernumbering>
|
75
|
+
<correctfeedback format="html">
|
76
|
+
<text><![CDATA[<p>Respuesta correcta</p>]]></text>
|
77
|
+
</correctfeedback>
|
78
|
+
<partiallycorrectfeedback format="html">
|
79
|
+
<text><![CDATA[<p>Respuesta parcialmente correcta.</p>]]></text>
|
80
|
+
</partiallycorrectfeedback>
|
81
|
+
<incorrectfeedback format="html">
|
82
|
+
<text><![CDATA[<p>Respuesta incorrecta.</p>]]></text>
|
83
|
+
</incorrectfeedback>
|
84
|
+
<shownumcorrect/>
|
85
|
+
<answer fraction="33.33333" format="html">
|
86
|
+
<text><![CDATA[<p>Democrats</p>]]></text>
|
87
|
+
<feedback format="html">
|
88
|
+
<text></text>
|
89
|
+
</feedback>
|
90
|
+
</answer>
|
91
|
+
<answer fraction="33.33333" format="html">
|
92
|
+
<text><![CDATA[<p>Republicans</p>]]></text>
|
93
|
+
<feedback format="html">
|
94
|
+
<text></text>
|
95
|
+
</feedback>
|
96
|
+
</answer>
|
97
|
+
<answer fraction="33.33333" format="html">
|
98
|
+
<text><![CDATA[<p>Greens</p>]]></text>
|
99
|
+
<feedback format="html">
|
100
|
+
<text></text>
|
101
|
+
</feedback>
|
102
|
+
</answer>
|
103
|
+
<answer fraction="0" format="html">
|
104
|
+
<text><![CDATA[<p>Tories</p>]]></text>
|
105
|
+
<feedback format="html">
|
106
|
+
<text></text>
|
107
|
+
</feedback>
|
108
|
+
</answer>
|
109
|
+
<answer fraction="0" format="html">
|
110
|
+
<text><![CDATA[<p>Social Democrats</p>]]></text>
|
111
|
+
<feedback format="html">
|
112
|
+
<text></text>
|
113
|
+
</feedback>
|
114
|
+
</answer>
|
115
|
+
</question>
|
116
|
+
|
117
|
+
<!-- question: 1 -->
|
118
|
+
<question type="shortanswer">
|
119
|
+
<name>
|
120
|
+
<text>Respuesta corta</text>
|
121
|
+
</name>
|
122
|
+
<questiontext format="html">
|
123
|
+
<text><![CDATA[<p>The capital of California is...</p>]]></text>
|
124
|
+
</questiontext>
|
125
|
+
<generalfeedback format="html">
|
126
|
+
<text></text>
|
127
|
+
</generalfeedback>
|
128
|
+
<defaultgrade>1.0000000</defaultgrade>
|
129
|
+
<penalty>0.3333333</penalty>
|
130
|
+
<hidden>0</hidden>
|
131
|
+
<usecase>0</usecase>
|
132
|
+
<answer fraction="100" format="moodle_auto_format">
|
133
|
+
<text>Sacramento</text>
|
134
|
+
<feedback format="html">
|
135
|
+
<text></text>
|
136
|
+
</feedback>
|
137
|
+
</answer>
|
138
|
+
</question>
|
139
|
+
|
140
|
+
<!-- question: 4 -->
|
141
|
+
<question type="truefalse">
|
142
|
+
<name>
|
143
|
+
<text>Verdadero/Falso</text>
|
144
|
+
</name>
|
145
|
+
<questiontext format="html">
|
146
|
+
<text><![CDATA[<p>The week has 7 days.</p>]]></text>
|
147
|
+
</questiontext>
|
148
|
+
<generalfeedback format="html">
|
149
|
+
<text></text>
|
150
|
+
</generalfeedback>
|
151
|
+
<defaultgrade>1.0000000</defaultgrade>
|
152
|
+
<penalty>1.0000000</penalty>
|
153
|
+
<hidden>0</hidden>
|
154
|
+
<answer fraction="100" format="moodle_auto_format">
|
155
|
+
<text>true</text>
|
156
|
+
<feedback format="html">
|
157
|
+
<text></text>
|
158
|
+
</feedback>
|
159
|
+
</answer>
|
160
|
+
<answer fraction="0" format="moodle_auto_format">
|
161
|
+
<text>false</text>
|
162
|
+
<feedback format="html">
|
163
|
+
<text></text>
|
164
|
+
</feedback>
|
165
|
+
</answer>
|
166
|
+
</question>
|
167
|
+
|
168
|
+
</quiz>
|
data/examples/prueba.js
ADDED
data/lib/ruql.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# basic gems/libs we rely on
|
2
|
-
require 'builder'
|
3
2
|
require 'logger'
|
4
3
|
require 'date'
|
5
4
|
|
5
|
+
require 'ruql/version'
|
6
|
+
|
6
7
|
$LOAD_PATH.unshift File.expand_path(File.join(File.dirname(__FILE__)))
|
7
8
|
|
8
|
-
|
9
|
-
|
9
|
+
module Ruql
|
10
|
+
class OptionsError < StandardError ; end
|
11
|
+
class QuizContentError < StandardError ; end
|
12
|
+
end
|
10
13
|
|
11
14
|
# question types
|
12
15
|
require 'ruql/quiz'
|
@@ -22,3 +25,4 @@ require 'ruql/open_assessment/criterion'
|
|
22
25
|
require 'ruql/open_assessment/option'
|
23
26
|
require 'ruql/open_assessment/training'
|
24
27
|
require 'ruql/open_assessment/training_criterion'
|
28
|
+
require 'ruql/stats'
|
data/lib/ruql/answer.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Answer
|
2
2
|
include Comparable
|
3
|
-
attr_accessor :answer_text, :explanation
|
3
|
+
attr_accessor :answer_text, :explanation
|
4
4
|
attr_reader :correct
|
5
5
|
attr_reader :builder
|
6
6
|
attr_reader :question
|
@@ -8,21 +8,9 @@ class Answer
|
|
8
8
|
def <=>(other) ; self.answer_text <=> other.answer_text ; end
|
9
9
|
def correct? ; !!correct ; end
|
10
10
|
def has_explanation? ; !!explanation ; end
|
11
|
-
def initialize(answer_text
|
11
|
+
def initialize(answer_text, correct, explanation=nil)
|
12
12
|
@answer_text = answer_text
|
13
13
|
@correct = !!correct # ensure boolean
|
14
14
|
@explanation = explanation
|
15
15
|
end
|
16
|
-
|
17
|
-
def to_JSON
|
18
|
-
Hash[instance_variables.collect { |var| [var.to_s.delete('@'), instance_variable_get(var)] }]
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.from_JSON(hash)
|
22
|
-
answer = Answer.new
|
23
|
-
hash.each do |key, value|
|
24
|
-
answer.send((key + '=').to_sym, value)
|
25
|
-
end
|
26
|
-
answer
|
27
|
-
end
|
28
16
|
end
|