Class: AtomicAssessmentsImport::CSV::Questions::MultipleChoice
- Inherits:
-
Question
- Object
- Question
- AtomicAssessmentsImport::CSV::Questions::MultipleChoice
show all
- Defined in:
- lib/atomic_assessments_import/csv/questions/multiple_choice.rb
Constant Summary
collapse
- QUESTION_INDEXES =
("a".."o").to_a.freeze
Instance Attribute Summary
Attributes inherited from Question
#reference
Instance Method Summary
collapse
Methods inherited from Question
#initialize, load, #points, #scoring_type, #to_learnosity
Instance Method Details
#correct_responses ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/atomic_assessments_import/csv/questions/multiple_choice.rb', line 58
def correct_responses
correct = @row["correct answer"]&.split(";")&.map(&:strip)&.map(&:downcase) || []
correct.filter_map do |value|
QUESTION_INDEXES.find_index(value).to_s
end
end
|
#distractor_rationale_response_level ⇒ Object
66
67
68
69
70
71
|
# File 'lib/atomic_assessments_import/csv/questions/multiple_choice.rb', line 66
def distractor_rationale_response_level
QUESTION_INDEXES.map do |value|
key = "option #{value} feedback"
@row[key].presence || ""
end.reverse.drop_while(&:blank?).reverse
end
|
38
39
40
41
42
43
44
|
# File 'lib/atomic_assessments_import/csv/questions/multiple_choice.rb', line 38
def metadata
super.merge(
{
distractor_rationale_response_level: distractor_rationale_response_level,
}
)
end
|
#multiple_responses ⇒ Object
73
74
75
76
77
78
79
80
81
|
# File 'lib/atomic_assessments_import/csv/questions/multiple_choice.rb', line 73
def multiple_responses
case @row["template"]&.downcase
when "multiple response", "block layout multiple response", "choice matrix",
"choice matrix inline", "choice matrix labels"
true
else
false
end
end
|
#options ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/atomic_assessments_import/csv/questions/multiple_choice.rb', line 46
def options
QUESTION_INDEXES.filter_map.with_index do |value, cnt|
key = "option #{value}"
if @row[key].present?
{
label: @row[key],
value: cnt.to_s,
}
end
end
end
|
#question_data ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/atomic_assessments_import/csv/questions/multiple_choice.rb', line 15
def question_data
raise ArgumentError, "Missing correct answer" if correct_responses.empty?
raise ArgumentError, "Missing options" if options.empty?
super.deep_merge(
{
multiple_responses: multiple_responses,
options: options,
validation: {
scoring_type: scoring_type,
valid_response: {
score: points,
value: correct_responses,
},
rounding: "none",
penalty: 1,
},
shuffle_options: Utils.parse_boolean(@row["shuffle options"], default: false),
ui_style: ui_style,
}
)
end
|
#question_type ⇒ Object
11
12
13
|
# File 'lib/atomic_assessments_import/csv/questions/multiple_choice.rb', line 11
def question_type
"mcq"
end
|
#ui_style ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/atomic_assessments_import/csv/questions/multiple_choice.rb', line 83
def ui_style
case @row["template"]&.downcase
when "multiple response"
{ type: "horizontal" }
when "block layout", "block layout multiple response"
{ choice_label: "upper-alpha", type: "block" }
when "choice matrix"
{ horizontal_lines: false, type: "table" }
when "choice matrix inline"
{ horizontal_lines: false, type: "inline" }
when "choice matrix labels"
{ stem_numeration: "upper-alpha", horizontal_lines: false, type: "table" }
when nil, "", "multiple choice", "standard"
{ type: "horizontal" }
else
raise NotImplementedError, "Unknown template"
end
end
|