Class: CanvasQtiToLearnosityConverter::CalculatedQuestion
Instance Method Summary
collapse
#extract_template, #extract_template_values, #get_template
#convert, #extract_mattext, #extract_points_possible, #initialize, #make_identifier, #process_assets!
Instance Method Details
#add_learnosity_assets(assets, path, learnosity) ⇒ Object
40
41
42
43
44
45
46
47
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 40
def add_learnosity_assets(assets, path, learnosity)
process_assets!(
assets,
path,
learnosity[:stimulus]
)
learnosity
end
|
#dynamic_content_data ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 49
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
|
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 62
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
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 15
def ()
template = get_template()
(template).each.with_index do |var_name, index|
template.sub!("[#{var_name}]", "{{var:val#{index}}}")
end
template
end
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/canvas_qti_to_learnosity_converter/questions/calculated.rb', line 24
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
|