Class: CanvasQtiToLearnosityConverter::CalculatedQuestion
Instance Method Summary
collapse
#extract_template, #get_template
#convert, #extract_feedback, #extract_mattext, #extract_points_possible, for, #initialize, #make_identifier, #process_assets!
Instance Method Details
#add_learnosity_assets(assets, path, learnosity) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 51
def add_learnosity_assets(assets, path, learnosity)
process_assets!(
assets,
path,
learnosity[:stimulus]
)
learnosity
end
|
#dynamic_content_data ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 60
def dynamic_content_data()
values = ()
columns = (0...(values.first.count - 1)).map{ |x| "val#{x}" }
columns.push("answer")
rows = Hash[values.map.with_index do |row, index|
[make_identifier(), { values: row, index: index }]
end]
{ cols: columns, rows: rows }
end
|
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 73
def ()
template = get_template()
vars = (template).map do |var_name|
@xml.css(%{item > itemproc_extension > calculated > var_sets >
var_set > var[name="#{var_name}"]}).map { |node| node.text }
end
answers = @xml.css("item > itemproc_extension var_sets answer").map do |node|
node.text
end
vars.push(answers).transpose
end
|
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 15
def ()
template = get_template()
uses_backtick = template.match?(/`[^`]+`/)
(template).each.with_index do |var_name, index|
pattern = uses_backtick ? "`#{var_name}`" : "[#{var_name}]"
template.sub!(pattern, "{{var:val#{index}}}")
end
template
end
|
New Quizzes exports variables with backtick notation (e.g. ‘w`), while Classic Quizzes uses square bracket notation (e.g. [w]). Detect which format is in use and return plain variable names either way.
30
31
32
33
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 30
def (template)
backtick_vars = template.scan(/`([^`]+)`/).map(&:first)
backtick_vars.any? ? backtick_vars : super
end
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 35
def ()
pm = @xml.css("item > itemproc_extension > calculated > answer_tolerance")
.first.text
{
"scoring_type" => "exactMatch",
"valid_response" => {
"score" => ,
"value" => [[{
"method" => "equivValue",
"value" => "{{var:answer}}\\pm#{pm}"
}]]
}
}
end
|
#to_learnosity ⇒ Object
5
6
7
8
9
10
11
12
13
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 5
def to_learnosity
{
type: "clozeformula",
is_math: true,
stimulus: (),
template: "{{response}}",
validation: (),
}
end
|