gipper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/PostInstall.txt +5 -0
- data/README.rdoc +49 -0
- data/Rakefile +69 -0
- data/VERSION.yml +4 -0
- data/docs/gift_reference.pdf +0 -0
- data/features/fixtures/matching.gift +9 -0
- data/features/fixtures/missing_word.gift +8 -0
- data/features/fixtures/multiple_choice.gift +41 -0
- data/features/fixtures/numerical.gift +10 -0
- data/features/fixtures/short_answer.gift +10 -0
- data/features/fixtures/super_gift.txt +169 -0
- data/features/fixtures/true_or_false.gift +19 -0
- data/features/gift_parsing.feature +10 -0
- data/features/parse_matching_questions.feature +10 -0
- data/features/parse_missing_word.feature +10 -0
- data/features/parse_multiple_choice_questions.feature +10 -0
- data/features/parse_numerical_questions.feature +10 -0
- data/features/parse_short_answer_questions.feature +10 -0
- data/features/parse_true_or_false_questions.feature +10 -0
- data/features/steps/gift_parsing_steps.rb +546 -0
- data/features/steps/parse_matching_steps.rb +30 -0
- data/features/steps/parse_missing_word_steps.rb +58 -0
- data/features/steps/parse_multiple_choice_steps.rb +107 -0
- data/features/steps/parse_numerical_steps.rb +35 -0
- data/features/steps/parse_short_answer_steps.rb +42 -0
- data/features/steps/parse_steps.rb +7 -0
- data/features/steps/parse_true_or_false_steps.rb +61 -0
- data/features/support/env.rb +10 -0
- data/lib/answer.rb +165 -0
- data/lib/answers.rb +99 -0
- data/lib/gipper.rb +15 -0
- data/lib/question.rb +53 -0
- data/lib/quiz.rb +31 -0
- data/lib/special_charater_handler.rb +8 -0
- data/script/txt2html +71 -0
- data/script/txt2html.cmd +1 -0
- data/tasks/rspec.rake +21 -0
- data/test/answer_test.rb +152 -0
- data/test/answers_test.rb +126 -0
- data/test/custom_assertions.rb +68 -0
- data/test/fixtures/begins_with_comment.txt +6 -0
- data/test/question_test.rb +86 -0
- data/test/quiz_test.rb +65 -0
- data/test/special_character_handler_test.rb +43 -0
- data/test/test_helper.rb +19 -0
- metadata +125 -0
data/.gitignore
ADDED
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
= gipper
|
2
|
+
|
3
|
+
* http://gipper.rubyforge.org
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
A ruby parser for the GIFT quiz file format
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* Parses GIFT files into a usable format.
|
12
|
+
* Missing features - Categories, Description type questions, setting case sensitivity on short answer questions.
|
13
|
+
|
14
|
+
== SYNOPSIS:
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
== REQUIREMENTS:
|
19
|
+
|
20
|
+
* Oniguruma
|
21
|
+
|
22
|
+
== INSTALL:
|
23
|
+
|
24
|
+
* sudo gem install gipper
|
25
|
+
|
26
|
+
== LICENSE:
|
27
|
+
|
28
|
+
(The MIT License)
|
29
|
+
|
30
|
+
Copyright (c) 2008 Jamal Hansen
|
31
|
+
|
32
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
33
|
+
a copy of this software and associated documentation files (the
|
34
|
+
'Software'), to deal in the Software without restriction, including
|
35
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
36
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
37
|
+
permit persons to whom the Software is furnished to do so, subject to
|
38
|
+
the following conditions:
|
39
|
+
|
40
|
+
The above copyright notice and this permission notice shall be
|
41
|
+
included in all copies or substantial portions of the Software.
|
42
|
+
|
43
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
44
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
45
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
46
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
47
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
48
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
49
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'jeweler'
|
7
|
+
Jeweler::Tasks.new do |gem|
|
8
|
+
gem.name = "gipper"
|
9
|
+
gem.summary = %Q{A gem for parsing the GIFT quiz file format}
|
10
|
+
gem.email = "jamal.hansen@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/rubyyot/gipper"
|
12
|
+
gem.authors = ["Jamal Hansen"]
|
13
|
+
gem.rubyforge_project = "gipper"
|
14
|
+
gem.add_dependency 'oniguruma'
|
15
|
+
gem.add_development_dependency 'technicalpickles-shoulda'
|
16
|
+
|
17
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
18
|
+
end
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new(:test) do |test|
|
25
|
+
test.libs << 'lib' << 'test'
|
26
|
+
test.pattern = 'test/**/*_test.rb'
|
27
|
+
test.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
require 'rcov/rcovtask'
|
32
|
+
Rcov::RcovTask.new do |test|
|
33
|
+
test.libs << 'test'
|
34
|
+
test.pattern = 'test/**/*_test.rb'
|
35
|
+
test.verbose = true
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
task :rcov do
|
39
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
begin
|
44
|
+
require 'cucumber/rake/task'
|
45
|
+
Cucumber::Rake::Task.new(:features)
|
46
|
+
rescue LoadError
|
47
|
+
task :features do
|
48
|
+
abort "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
task :default => :test
|
53
|
+
|
54
|
+
require 'rake/rdoctask'
|
55
|
+
Rake::RDocTask.new do |rdoc|
|
56
|
+
if File.exist?('VERSION.yml')
|
57
|
+
config = YAML.load(File.read('VERSION.yml'))
|
58
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
59
|
+
else
|
60
|
+
version = ""
|
61
|
+
end
|
62
|
+
|
63
|
+
rdoc.rdoc_dir = 'rdoc'
|
64
|
+
rdoc.title = "gipper #{version}"
|
65
|
+
rdoc.rdoc_files.include('README*')
|
66
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
67
|
+
end
|
68
|
+
|
69
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
data/VERSION.yml
ADDED
Binary file
|
@@ -0,0 +1,8 @@
|
|
1
|
+
Sally sells { =seashells ~snails} by the seashore.
|
2
|
+
|
3
|
+
::Hamster Tree::
|
4
|
+
Oh woe is me, {~oh =doh!} woe is me!
|
5
|
+
|
6
|
+
You say that, "money is the root of all evil", I ask you "what is the root of all {~honey ~bunnies =money}?"
|
7
|
+
|
8
|
+
Ooh Eee \{Uh\} Ooh Ah Ah {=Ting Tang ~Tung Ting ~Wing Wang} Walla Walla Bing Bang!
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
::Ninjas and the future::In the future, ninjas will be able to{= Travel to the moon ~play tennis ~eat apples ~play fable 2 ~code in Assembly }
|
4
|
+
|
5
|
+
|
6
|
+
// question: 2 name: Ninjas and you
|
7
|
+
::Ninjas and you::
|
8
|
+
If you see a ninja you should: {~offer them a crunchy frog =run ~attack them}
|
9
|
+
|
10
|
+
Ninjas will only attack when {~provoked ~ upset ~off duty =none of the above}
|
11
|
+
|
12
|
+
One way ninjas are like a snake is: {~Ninjas have scales ~Ninjas eat rodents =Ninjas can spit venom}
|
13
|
+
|
14
|
+
::Supercomputing Ninjas
|
15
|
+
::Ninjas can recite the value of pi to how many digits?{
|
16
|
+
~10
|
17
|
+
# do you even know what a ninja is?
|
18
|
+
~100
|
19
|
+
# are you crazy?
|
20
|
+
~100,000
|
21
|
+
# that is pitiful
|
22
|
+
=twice the US national debt
|
23
|
+
# if not more!
|
24
|
+
}
|
25
|
+
|
26
|
+
// Ninjas can be commented on
|
27
|
+
::Are you a Ninja?::
|
28
|
+
When confronted by a zombie army of terracotta kung-fu masters, you would: {
|
29
|
+
~ cry
|
30
|
+
# not even baby ninjas would do that
|
31
|
+
~ try to fight
|
32
|
+
# fight or fight not, there is no try.
|
33
|
+
= slay them all with a single strike before they even saw you.
|
34
|
+
# You are Ninja!
|
35
|
+
~ run away
|
36
|
+
# You would make a poor ninja.
|
37
|
+
}
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
When was Harvey D. Smith born?{#1945:5}
|
2
|
+
|
3
|
+
//this comment will be ignored in the import process
|
4
|
+
::Numerical example::
|
5
|
+
When was Elizabeth M. Danson born? {#
|
6
|
+
=1993:0 #Correct! you will get full credit for this answer
|
7
|
+
=%50%1993:2 #She was born in 1993.
|
8
|
+
You get 50% credit for being close.
|
9
|
+
}
|
10
|
+
|
@@ -0,0 +1,169 @@
|
|
1
|
+
// Basic GIFT questions
|
2
|
+
// GIFT filter and documentation by Paul Tsuchido Shew http://ac.shew.jp.
|
3
|
+
//---------------------------
|
4
|
+
|
5
|
+
Who's buried in Grant's tomb?{~Grant ~Jefferson =no one}
|
6
|
+
|
7
|
+
Grant is {~buried =entombed ~living} in Grant's tomb.
|
8
|
+
|
9
|
+
//----------------------------------
|
10
|
+
// Formatting
|
11
|
+
//----------------------------------
|
12
|
+
The American holiday of Thanksgiving is celebrated on the {
|
13
|
+
~second
|
14
|
+
~third
|
15
|
+
=fourth
|
16
|
+
} Thursday of November.
|
17
|
+
|
18
|
+
Japanese characters originally came from what country? {
|
19
|
+
~India
|
20
|
+
=China
|
21
|
+
~Korea
|
22
|
+
~Egypt}
|
23
|
+
|
24
|
+
|
25
|
+
Who's buried in Grant's tomb?{=no one =nobody}
|
26
|
+
|
27
|
+
Two plus two equals {=four =4}
|
28
|
+
|
29
|
+
Four plus one equals {5}
|
30
|
+
|
31
|
+
Three plus {2} equals five.
|
32
|
+
|
33
|
+
Grant is buried in Grant's tomb.{F}
|
34
|
+
|
35
|
+
The sun rises in the east.{T}
|
36
|
+
|
37
|
+
// ------------------------------------------
|
38
|
+
// Matching
|
39
|
+
// There must be at least three matching pairs.
|
40
|
+
// Matching questions do not support feedback or percentage answer weights.
|
41
|
+
// ------------------------------------------
|
42
|
+
|
43
|
+
Matching Question. {
|
44
|
+
=subquestion1 -> subanswer1
|
45
|
+
=subquestion2 -> subanswer2
|
46
|
+
=subquestion3 -> subanswer3
|
47
|
+
}
|
48
|
+
|
49
|
+
Match the following countries with their corresponding capitals. {
|
50
|
+
=Canada -> Ottawa
|
51
|
+
=Italy -> Rome
|
52
|
+
=Japan -> Tokyo
|
53
|
+
=India -> New Delhi
|
54
|
+
}
|
55
|
+
|
56
|
+
// ------------------------------------------
|
57
|
+
// Numerical
|
58
|
+
// ------------------------------------------
|
59
|
+
|
60
|
+
When was Ulysses S. Grant born? {#1822}
|
61
|
+
|
62
|
+
What is the value of pi (to 3 decimal places)? {#3.1415:0.0005}
|
63
|
+
|
64
|
+
What is the value of pi (to 3 decimal places)? {#3.141..3.142}
|
65
|
+
|
66
|
+
When was Ulysses S. Grant born? {#
|
67
|
+
=1822:0
|
68
|
+
=%50%1822:2}
|
69
|
+
|
70
|
+
|
71
|
+
//Line Comments:
|
72
|
+
|
73
|
+
// Subheading: Numerical questions below
|
74
|
+
What's 2 plus 2? {#4}
|
75
|
+
|
76
|
+
//Question Name:
|
77
|
+
::Kanji Origins::Japanese characters originally
|
78
|
+
came from what country? {=China}
|
79
|
+
|
80
|
+
::Thanksgiving Date::The American holiday of Thanksgiving is
|
81
|
+
celebrated on the {~second ~third =fourth} Thursday of November.
|
82
|
+
|
83
|
+
//Feedback:
|
84
|
+
|
85
|
+
What's the answer to this multiple-choice question?{
|
86
|
+
~wrong answer#feedback comment on the wrong answer
|
87
|
+
~another wrong answer#feedback comment on this wrong answer
|
88
|
+
=right answer#Very good!}
|
89
|
+
|
90
|
+
Who's buried in Grant's tomb?{
|
91
|
+
=no one#excellent answer!
|
92
|
+
=nobody#excellent answer!}
|
93
|
+
|
94
|
+
Grant is buried in Grant's tomb.{FALSE#No one is buried in Grant's tomb.}
|
95
|
+
|
96
|
+
//Percentage Answer Weights:
|
97
|
+
//Percentage answer weights are available for both Multiple Choice and Short Answer questions. Percentage answer weights can be included by following the tilde (for Multiple Choice) or equal sign (for Short Answer) with the desired percent enclosed within percent signs (e.g., %50%).
|
98
|
+
//This option can be combined with feedback comments.
|
99
|
+
|
100
|
+
Difficult question.{~wrong answer ~%50%half credit answer =full credit answer}
|
101
|
+
|
102
|
+
::Jesus' hometown::Jesus Christ was from {
|
103
|
+
~Jerusalem#This was an important city, but the wrong answer.
|
104
|
+
~%25%Bethlehem#He was born here, but not raised here.
|
105
|
+
~%50%Galilee#You need to be more specific.
|
106
|
+
=Nazareth#Yes! That's right!}.
|
107
|
+
|
108
|
+
::Jesus' hometown:: Jesus Christ was from {
|
109
|
+
=Nazareth#Yes! That's right!
|
110
|
+
=%75%Nazereth#Right, but misspelled.
|
111
|
+
=%25%Bethlehem#He was born here, but not raised here.}
|
112
|
+
|
113
|
+
//Specify text-formatting for the question
|
114
|
+
//The question text (only) may have an optional text format specified.
|
115
|
+
//Currently the available formats are moodle (Moodle Auto-Format), html (HTML format), plain (Plain text format) and markdown (Markdown format).
|
116
|
+
//The format is specified in square brackets immediately before the question text. More information on text formats in Moodle.
|
117
|
+
|
118
|
+
[markdown]The *American holiday of Thanksgiving* is celebrated on the {
|
119
|
+
~second
|
120
|
+
~third
|
121
|
+
=fourth
|
122
|
+
} Thursday of November.
|
123
|
+
|
124
|
+
//Multiple Answers:
|
125
|
+
//The Multiple Answers option is used for multiple choice questions when
|
126
|
+
//two or more answers must be selected in order to obtain full credit.
|
127
|
+
//The multiple answers option is enabled by assigning partial answer weight to
|
128
|
+
//multiple answers, while allowing no single answer to receive full credit.
|
129
|
+
|
130
|
+
What two people are entombed in Grant's tomb? {
|
131
|
+
~No one
|
132
|
+
~%50%Grant
|
133
|
+
~%50%Grant's wife
|
134
|
+
~Grant's father }
|
135
|
+
//Note that there is no equal sign (=) in any answer and the answers should total no more than 100%, otherwise Moodle will return an error. To avoid the problem of students automatically getting 100% by simply checking all of the answers, it is best to include negative answer weights for wrong answers.
|
136
|
+
|
137
|
+
What two people are entombed in Grant's tomb? {
|
138
|
+
~%-50%No one
|
139
|
+
~%50%Grant
|
140
|
+
~%50%Grant's wife
|
141
|
+
~%-50%Grant's father }
|
142
|
+
|
143
|
+
//Special Characters ~ = # { } :
|
144
|
+
//These symbols ~ = # { } control the operation of this filter
|
145
|
+
//and cannot be used as normal text within questions.
|
146
|
+
//Since these symbols have a special role in determining the
|
147
|
+
//operation of this filter, they are called "control characters."
|
148
|
+
//But sometimes you may want to use one of these characters,
|
149
|
+
//for example to show a mathematical formula in a question.
|
150
|
+
//The way to get around this problem is "escaping" the control characters.
|
151
|
+
//This means simply putting a backslash (\) before a control character
|
152
|
+
//so the filter will know that you want to use it as a literal character
|
153
|
+
//instead of as a control character. For example:
|
154
|
+
|
155
|
+
Which answer equals 5? {
|
156
|
+
~ \= 2 + 2
|
157
|
+
= \= 2 + 3
|
158
|
+
~ \= 2 + 4 }
|
159
|
+
|
160
|
+
::GIFT Control Characters::
|
161
|
+
Which of the following is NOT a control character for the GIFT import format? {
|
162
|
+
~ \~ # \~ is a control character.
|
163
|
+
~ \= # \= is a control character.
|
164
|
+
~ \# # \# is a control character.
|
165
|
+
~ \{ # \{ is a control character.
|
166
|
+
~ \} # \} is a control character.
|
167
|
+
= \ # Correct! \ (backslash) is not a control character. BUT,
|
168
|
+
it is used to escape the control characters.
|
169
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
::TrueStatement about monkeys::Monkeys like to fly like ninjas.{T}
|
2
|
+
|
3
|
+
// question: 0 name: TrueStatement
|
4
|
+
::A Second TrueStatement about monkeys::
|
5
|
+
Monkeys roam in packs with swords.{True}
|
6
|
+
|
7
|
+
Monkeys will jump from buildings without fear. {T}
|
8
|
+
|
9
|
+
Monkeys have a formal system of government{False}
|
10
|
+
|
11
|
+
::A Second FalseStatement about monkeys
|
12
|
+
::Monkeys wear suits and sit around in corporate offices.{False}
|
13
|
+
|
14
|
+
// question: 6 name: FalseStatement
|
15
|
+
::A Third FalseStatement about monkeys:: Monkeys can operate heavy machinery.{F}
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Story: Parsing a GIFT File with multiple formats
|
2
|
+
As a developer
|
3
|
+
I want to parse a GIFT file
|
4
|
+
So that I can use the data in my application
|
5
|
+
|
6
|
+
Scenario: read a file and return an array of questions and answers
|
7
|
+
Given a GIFT file
|
8
|
+
When I tell gipper to parse the file
|
9
|
+
Then I will get an array of questions and answers
|
10
|
+
And contains the correct questions
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Story: Parsing matching questions
|
2
|
+
As a developer
|
3
|
+
I want to parse a GIFT file containing matching questions
|
4
|
+
So that I can use the data in my application
|
5
|
+
|
6
|
+
Scenario: read a file and return an array of questions and answers
|
7
|
+
Given a GIFT file of matching questions
|
8
|
+
When I tell gipper to parse the file
|
9
|
+
Then I will get an array of questions and answers
|
10
|
+
And contains the correct matching questions
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Story: Parsing missing word questions
|
2
|
+
As a developer
|
3
|
+
I want to parse a GIFT file containing missing word questions
|
4
|
+
So that I can use the data in my application
|
5
|
+
|
6
|
+
Scenario: read a file and return an array of questions and answers
|
7
|
+
Given a GIFT file of missing word questions
|
8
|
+
When I tell gipper to parse the file
|
9
|
+
Then I will get an array of questions and answers
|
10
|
+
And contains the correct missing word questions
|