erik-multiple-select 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/erik-multiple-select.rb +71 -0
- metadata +58 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dfd4e2cc231965819766108cae521d70899a0ece
|
4
|
+
data.tar.gz: 1c426d056bcbe1ff4ee4de03a18687f4c4c94337
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 273988d5f2353ac71378ae037444755eacfc7b9f51725c2a45fa93f418c04140e4f2e7d55867522744a20dff17f80c7e84a1b1a85ccb0bfa28d20d9e65f6349a
|
7
|
+
data.tar.gz: fd8562575513f130d9e6744358a4306aec12a5c0df830bd0dfce56cc5ba00ec8f279e54c2eafcc18e46d177f49b97de785128053738b6feb0d3aabb0a5d56804
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'erik-question-feedback'
|
2
|
+
|
3
|
+
module Questions
|
4
|
+
class MultipleSelect
|
5
|
+
def initialize(index, question_json)
|
6
|
+
@index = index
|
7
|
+
@text = question_json['question']
|
8
|
+
@options = question_json['options']
|
9
|
+
@answer = question_json['answer']
|
10
|
+
end
|
11
|
+
|
12
|
+
def name
|
13
|
+
@text
|
14
|
+
end
|
15
|
+
|
16
|
+
def mark(answer)
|
17
|
+
correct = answer == @answer.collect { |a| a.to_s }
|
18
|
+
QuestionFeedback.new(correct, correct ? nil : feedback_string)
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_html
|
22
|
+
@options.collect.with_index do |option, index|
|
23
|
+
id = "q-#{@index}-#{index}"
|
24
|
+
%(<div>
|
25
|
+
<input id="#{id}" type="checkbox" name="q-#{@index}[]" value="#{index}" />
|
26
|
+
<label for="#{id}">#{option}</label>
|
27
|
+
</div>)
|
28
|
+
end.join("\n")
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.schema
|
32
|
+
{
|
33
|
+
"properties": {
|
34
|
+
"question": {
|
35
|
+
"type": "string"
|
36
|
+
},
|
37
|
+
"type": {
|
38
|
+
"type": "string",
|
39
|
+
"pattern": "^multiple-select$"
|
40
|
+
},
|
41
|
+
"options": {
|
42
|
+
"type": "array",
|
43
|
+
"items": {
|
44
|
+
"type": "string"
|
45
|
+
}
|
46
|
+
},
|
47
|
+
"answer": {
|
48
|
+
"type": "array",
|
49
|
+
"items": {
|
50
|
+
"type": "integer"
|
51
|
+
}
|
52
|
+
}
|
53
|
+
},
|
54
|
+
"required": [
|
55
|
+
"question",
|
56
|
+
"type",
|
57
|
+
"options",
|
58
|
+
"answer"
|
59
|
+
],
|
60
|
+
"additionalProperties": false
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def feedback_string
|
67
|
+
answers = @answer.collect{ |a| %("#{@options[a]}") }.join(' and ')
|
68
|
+
"The correct answers were #{answers}."
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: erik-multiple-select
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Team Eriksen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: erik-question-feedback
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
27
|
+
description: A multiple selection question type.
|
28
|
+
email: eriksen@example.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/erik-multiple-select.rb
|
34
|
+
homepage: http://dams.flippd.it/
|
35
|
+
licenses:
|
36
|
+
- BSD
|
37
|
+
metadata: {}
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 2.2.5
|
55
|
+
signing_key:
|
56
|
+
specification_version: 4
|
57
|
+
summary: A multiple selection question type.
|
58
|
+
test_files: []
|