canvas_cc 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/canvas_cc/canvas_cc/file_upload_question_writer.rb +19 -0
- data/lib/canvas_cc/canvas_cc/models/question.rb +2 -1
- data/lib/canvas_cc/canvas_cc/multiple_blanks_question_writer.rb +2 -5
- data/lib/canvas_cc/canvas_cc/question_writer.rb +1 -0
- data/lib/canvas_cc/version.rb +1 -1
- data/lib/canvas_cc.rb +1 -0
- data/spec/moodle2cc/canvas_cc/file_upload_question_writer_spec.rb +23 -0
- data/spec/moodle2cc/canvas_cc/multiple_answers_question_writer_spec.rb +2 -2
- data/spec/moodle2cc/canvas_cc/multiple_blanks_question_writer_spec.rb +1 -17
- data/spec/moodle2cc/canvas_cc/multiple_choice_question_writer_spec.rb +3 -3
- data/spec/moodle2cc/canvas_cc/question_writer_spec.rb +3 -3
- data/spec/moodle2cc/canvas_cc/short_answer_question_writer_spec.rb +2 -2
- data/spec/moodle2cc/canvas_cc/true_false_question_writer_spec.rb +3 -3
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1353f996dbae51f90ef66a15ea6710bb7fd26243
|
4
|
+
data.tar.gz: cfacb8d84b95dcd767c7bcba8a6e3a75c5d1d5b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7c5d8081b0e86c1d9cc6217b955af3f72b766f9cb5bdcb9d6a566f2e46d9df29d49b560d7fa0b4d59b3eadf6276da5b430f0900b55423f5a05025a52b6c8603
|
7
|
+
data.tar.gz: da0c4c112c27771d15d961b4ccdfae4715f160bf07ca372f5103ef2cac74e1018fc4785e391924fa89118f98bf15f154df81b5a1761eff5278ba6d13f3e6b3b2
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
module CanvasCc::CanvasCC
|
2
|
+
class FileUploadQuestionWriter < QuestionWriter
|
3
|
+
|
4
|
+
register_writer_type 'file_upload_question'
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def self.write_question_item_xml(node, question)
|
9
|
+
node.item(:title => question.title, :ident => question.identifier) do |item_node|
|
10
|
+
write_qti_metadata(item_node, question)
|
11
|
+
item_node.presentation do |presentation_node|
|
12
|
+
presentation_node.material do |material_node|
|
13
|
+
material_node.mattext(question.material, :texttype => 'text/html')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,7 +3,8 @@ module CanvasCc::CanvasCC::Models
|
|
3
3
|
QTI_META_ATTRIBUTES = [:question_type, :points_possible, :assessment_question_identifierref]
|
4
4
|
STANDARD_QUESTION_TYPES = ['essay_question', 'fill_in_multiple_blanks_question',
|
5
5
|
'multiple_choice_question', 'multiple_answers_question',
|
6
|
-
'short_answer_question', 'text_only_question', 'true_false_question'
|
6
|
+
'short_answer_question', 'text_only_question', 'true_false_question',
|
7
|
+
'file_upload_question']
|
7
8
|
|
8
9
|
attr_accessor :identifier, :original_identifier, :title, :material, :answers, :general_feedback,
|
9
10
|
:general_incorrect_feedback, :general_correct_feedback, *QTI_META_ATTRIBUTES
|
@@ -7,7 +7,7 @@ module CanvasCc::CanvasCC
|
|
7
7
|
def self.write_responses(presentation_node, question)
|
8
8
|
resp_idents = question.answers.map{|a| a.resp_ident}.uniq
|
9
9
|
resp_idents.each do |resp_ident|
|
10
|
-
presentation_node.response_lid(:ident => resp_ident) do |response_node|
|
10
|
+
presentation_node.response_lid(:ident => resp_ident, :rcardinality => 'Single') do |response_node|
|
11
11
|
response_node.render_choice do |choice_node|
|
12
12
|
question.answers.select{|a| a.resp_ident == resp_ident}.each do |answer|
|
13
13
|
choice_node.response_label(:ident => answer.id) do |label_node|
|
@@ -35,7 +35,7 @@ module CanvasCc::CanvasCC
|
|
35
35
|
|
36
36
|
# Scores
|
37
37
|
question.answers.each do |answer|
|
38
|
-
processing_node.respcondition() do |condition_node|
|
38
|
+
processing_node.respcondition(:continue => 'No') do |condition_node|
|
39
39
|
condition_node.conditionvar do |var_node|
|
40
40
|
var_node.varequal answer.id, :respident => answer.resp_ident
|
41
41
|
end
|
@@ -44,8 +44,5 @@ module CanvasCc::CanvasCC
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
# def self.write_additional_nodes(item_node, question)
|
48
|
-
# write_standard_answer_feedbacks(item_node, question)
|
49
|
-
# end
|
50
47
|
end
|
51
48
|
end
|
data/lib/canvas_cc/version.rb
CHANGED
data/lib/canvas_cc.rb
CHANGED
@@ -66,6 +66,7 @@ module CanvasCc
|
|
66
66
|
autoload :ShortAnswerQuestionWriter, 'canvas_cc/canvas_cc/short_answer_question_writer'
|
67
67
|
autoload :TextOnlyQuestionWriter, 'canvas_cc/canvas_cc/text_only_question_writer'
|
68
68
|
autoload :TrueFalseQuestionWriter, 'canvas_cc/canvas_cc/true_false_question_writer'
|
69
|
+
autoload :FileUploadQuestionWriter, 'canvas_cc/canvas_cc/file_upload_question_writer'
|
69
70
|
|
70
71
|
autoload :QuestionBankWriter, 'canvas_cc/canvas_cc/question_bank_writer'
|
71
72
|
autoload :QuestionGroupWriter, 'canvas_cc/canvas_cc/question_group_writer'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module CanvasCc::CanvasCC
|
4
|
+
describe FileUploadQuestionWriter do
|
5
|
+
|
6
|
+
let(:question) { CanvasCc::CanvasCC::Models::Question.create('file_upload_question')}
|
7
|
+
|
8
|
+
it 'creates the question item xml for a file upload question' do
|
9
|
+
question.identifier = 4200
|
10
|
+
question.title = 'hello title'
|
11
|
+
question.general_feedback = 'feedbacks'
|
12
|
+
question.material = 'this is the material'
|
13
|
+
|
14
|
+
xml = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |node|
|
15
|
+
QuestionWriter.write_question(node, question)
|
16
|
+
end.doc
|
17
|
+
|
18
|
+
expect(xml.at_xpath('item/@ident').value).to eq question.identifier.to_s
|
19
|
+
expect(xml.at_xpath('item/@title').value).to eq question.title
|
20
|
+
expect(xml.at_xpath("item/itemmetadata/qtimetadata/qtimetadatafield[fieldlabel=\"question_type\" and fieldentry=\"#{question.question_type}\"]")).to_not be_nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -29,7 +29,7 @@ module CanvasCc::CanvasCC
|
|
29
29
|
xml = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |node|
|
30
30
|
QuestionWriter.write_question(node, question)
|
31
31
|
end.doc
|
32
|
-
|
32
|
+
|
33
33
|
expect(xml.at_xpath('item/@ident').value).to eq question.identifier.to_s
|
34
34
|
expect(xml.at_xpath('item/@title').value).to eq question.title
|
35
35
|
expect(xml.at_xpath("item/itemmetadata/qtimetadata/qtimetadatafield[fieldlabel=\"question_type\" and fieldentry=\"#{question.question_type}\"]")).to_not be_nil
|
@@ -47,7 +47,7 @@ module CanvasCc::CanvasCC
|
|
47
47
|
expect(condition.at_xpath("conditionvar/and/not/varequal[@respident=\"response1\" and text()=\"#{answer2.id}\"]")).not_to be_nil
|
48
48
|
expect(condition.at_xpath("conditionvar/and/varequal[@respident=\"response1\" and text()=\"#{answer3.id}\"]")).not_to be_nil
|
49
49
|
|
50
|
-
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer1.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/
|
50
|
+
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer1.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/plain\"]")
|
51
51
|
expect(feedback.text).to eq answer1.feedback
|
52
52
|
end
|
53
53
|
end
|
@@ -46,22 +46,6 @@ module CanvasCc::CanvasCC
|
|
46
46
|
expect(response.attributes['ident'].value).to eq 'response2'
|
47
47
|
expect(response.at_xpath("render_choice/response_label[@ident=\"#{answer2.id}\"]/material/mattext[@texttype=\"text/html\" and text()=\"#{answer2.answer_text}\"]")).not_to be_nil
|
48
48
|
|
49
|
-
# Feedback
|
50
|
-
condition = xml.at_xpath("item/resprocessing/respcondition[@continue=\"Yes\"]/conditionvar/varequal[@respident=\"response1\" and text()=\"#{answer1.id}\"]/../..")
|
51
|
-
expect(condition).not_to be_nil
|
52
|
-
feedback = condition.at_xpath("displayfeedback[@feedbacktype=\"Response\" and @linkrefid=\"#{answer1.id}_fb\"]")
|
53
|
-
expect(feedback).not_to be_nil
|
54
|
-
|
55
|
-
condition = xml.at_xpath("item/resprocessing/respcondition[@continue=\"Yes\"]/conditionvar/varequal[@respident=\"response2\" and text()=\"#{answer2.id}\"]/../..")
|
56
|
-
expect(condition).not_to be_nil
|
57
|
-
feedback = condition.at_xpath("displayfeedback[@feedbacktype=\"Response\" and @linkrefid=\"#{answer2.id}_fb\"]")
|
58
|
-
expect(feedback).not_to be_nil
|
59
|
-
|
60
|
-
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer1.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/html\"]")
|
61
|
-
expect(feedback.text).to eq answer1.feedback
|
62
|
-
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer2.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/html\"]")
|
63
|
-
expect(feedback.text).to eq answer2.feedback
|
64
|
-
|
65
49
|
# Conditions
|
66
50
|
condition = xml.at_xpath("item/resprocessing/respcondition[@continue=\"No\"]/conditionvar/varequal[@respident=\"response1\" and text()=\"#{answer1.id}\"]/../..")
|
67
51
|
expect(condition).not_to be_nil
|
@@ -74,4 +58,4 @@ module CanvasCc::CanvasCC
|
|
74
58
|
expect(setvar).not_to be_nil
|
75
59
|
end
|
76
60
|
end
|
77
|
-
end
|
61
|
+
end
|
@@ -49,9 +49,9 @@ module CanvasCc::CanvasCC
|
|
49
49
|
feedback = condition.at_xpath("displayfeedback[@feedbacktype=\"Response\" and @linkrefid=\"#{answer2.id}_fb\"]")
|
50
50
|
expect(feedback).not_to be_nil
|
51
51
|
|
52
|
-
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer1.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/
|
52
|
+
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer1.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/plain\"]")
|
53
53
|
expect(feedback.text).to eq answer1.feedback
|
54
|
-
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer2.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/
|
54
|
+
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer2.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/plain\"]")
|
55
55
|
expect(feedback.text).to eq answer2.feedback
|
56
56
|
|
57
57
|
# Conditions
|
@@ -66,4 +66,4 @@ module CanvasCc::CanvasCC
|
|
66
66
|
expect(setvar).not_to be_nil
|
67
67
|
end
|
68
68
|
end
|
69
|
-
end
|
69
|
+
end
|
@@ -100,7 +100,7 @@ module CanvasCc::CanvasCC
|
|
100
100
|
|
101
101
|
general_feedback = xml.at_xpath('item/itemfeedback[@ident="general_fb"]')
|
102
102
|
expect(general_feedback).to_not be_nil
|
103
|
-
expect(general_feedback.at_xpath('flow_mat/material/mattext[@texttype="text/
|
103
|
+
expect(general_feedback.at_xpath('flow_mat/material/mattext[@texttype="text/plain"]').text).to eq question.general_feedback
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'writes standard answer feedback if called' do
|
@@ -113,7 +113,7 @@ module CanvasCc::CanvasCC
|
|
113
113
|
QuestionWriter.write_question(node, question)
|
114
114
|
end.doc
|
115
115
|
|
116
|
-
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/
|
116
|
+
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/plain\"]")
|
117
117
|
expect(feedback.text).to eq answer.feedback
|
118
118
|
end
|
119
119
|
|
@@ -126,4 +126,4 @@ module CanvasCc::CanvasCC
|
|
126
126
|
end
|
127
127
|
|
128
128
|
end
|
129
|
-
end
|
129
|
+
end
|
@@ -43,8 +43,8 @@ module CanvasCc::CanvasCC
|
|
43
43
|
feedback = condition.at_xpath("displayfeedback[@feedbacktype=\"Response\" and @linkrefid=\"#{answer.id}_fb\"]")
|
44
44
|
expect(feedback).to_not be_nil
|
45
45
|
|
46
|
-
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/
|
46
|
+
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{answer.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/plain\"]")
|
47
47
|
expect(feedback.text).to eq answer.feedback
|
48
48
|
end
|
49
49
|
end
|
50
|
-
end
|
50
|
+
end
|
@@ -52,11 +52,11 @@ module CanvasCc::CanvasCC
|
|
52
52
|
setvar = condition.at_xpath('setvar[@varname="SCORE" and @action="Set" and text()="0"]')
|
53
53
|
expect(setvar).not_to be_nil
|
54
54
|
|
55
|
-
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{true_answer.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/
|
55
|
+
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{true_answer.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/plain\"]")
|
56
56
|
expect(feedback.text).to eq true_answer.feedback
|
57
57
|
|
58
|
-
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{false_answer.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/
|
58
|
+
feedback = xml.at_xpath("item/itemfeedback[@ident=\"#{false_answer.id}_fb\"]/flow_mat/material/mattext[@texttype=\"text/plain\"]")
|
59
59
|
expect(feedback.text).to eq false_answer.feedback
|
60
60
|
end
|
61
61
|
end
|
62
|
-
end
|
62
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas_cc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -261,6 +261,7 @@ files:
|
|
261
261
|
- lib/canvas_cc/canvas_cc/discussion_writer.rb
|
262
262
|
- lib/canvas_cc/canvas_cc/essay_question_writer.rb
|
263
263
|
- lib/canvas_cc/canvas_cc/file_meta_writer.rb
|
264
|
+
- lib/canvas_cc/canvas_cc/file_upload_question_writer.rb
|
264
265
|
- lib/canvas_cc/canvas_cc/ims_manifest_generator.rb
|
265
266
|
- lib/canvas_cc/canvas_cc/matching_question_writer.rb
|
266
267
|
- lib/canvas_cc/canvas_cc/models/answer.rb
|
@@ -325,6 +326,7 @@ files:
|
|
325
326
|
- spec/moodle2cc/canvas_cc/discussion_writer_spec.rb
|
326
327
|
- spec/moodle2cc/canvas_cc/essay_question_writer_spec.rb
|
327
328
|
- spec/moodle2cc/canvas_cc/file_meta_writer_spec.rb
|
329
|
+
- spec/moodle2cc/canvas_cc/file_upload_question_writer_spec.rb
|
328
330
|
- spec/moodle2cc/canvas_cc/ims_manifest_generator_spec.rb
|
329
331
|
- spec/moodle2cc/canvas_cc/matching_question_writer_spec.rb
|
330
332
|
- spec/moodle2cc/canvas_cc/models/assessment_spec.rb
|
@@ -430,6 +432,7 @@ test_files:
|
|
430
432
|
- spec/moodle2cc/canvas_cc/discussion_writer_spec.rb
|
431
433
|
- spec/moodle2cc/canvas_cc/essay_question_writer_spec.rb
|
432
434
|
- spec/moodle2cc/canvas_cc/file_meta_writer_spec.rb
|
435
|
+
- spec/moodle2cc/canvas_cc/file_upload_question_writer_spec.rb
|
433
436
|
- spec/moodle2cc/canvas_cc/ims_manifest_generator_spec.rb
|
434
437
|
- spec/moodle2cc/canvas_cc/matching_question_writer_spec.rb
|
435
438
|
- spec/moodle2cc/canvas_cc/models/assessment_spec.rb
|