Module: Csv2qti
- Defined in:
- lib/csv2qti.rb,
lib/csv2qti/course.rb,
lib/csv2qti/outcome.rb,
lib/csv2qti/version.rb,
lib/csv2qti/question.rb,
lib/csv2qti/question_types/matching.rb,
lib/csv2qti/question_types/multiple_choice.rb,
lib/csv2qti/question_types/multiple_select.rb
Defined Under Namespace
Classes: Course, Csv2qtiError, Matching, MultipleChoice, MultipleSelect, Outcome, Question, QuestionParseError
Constant Summary
collapse
- VERSION =
"0.0.1"
Class Method Summary
collapse
Class Method Details
.process_dir(path = '.') ⇒ Object
15
16
17
|
# File 'lib/csv2qti.rb', line 15
def self.process_dir(path='.')
end
|
.process_file(path) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/csv2qti.rb', line 19
def self.process_file(path)
course = nil
current_primary = nil
current_enabling = nil
CSV.foreach(path, skip_blanks: true) do |row|
begin
if $INPUT_LINE_NUMBER == 1
raise Csv2qtiError, "Course title not in first cell" unless row[0]
course = Course.new(row[0], path)
next
end
if row[1] == 'Title'
current_primary = nil
current_enabling = nil
elsif row[0]
current_enabling = nil
if current_primary
current_enabling = current_primary.add_enabling_outcome(row)
current_enabling.add_question(row)
else
current_primary = course.add_primary_outcome(row)
end
elsif current_enabling
current_enabling.add_question(row)
elsif row[2] == "Enabling Learning Outcome"
else
puts "what is row #{$INPUT_LINE_NUMBER}?"
puts row
end
rescue QuestionParseError => e
puts "line #{$INPUT_LINE_NUMBER + 1}: Problem parsing question: #{$!.message} (just Skipping)"
rescue Csv2qtiError => e
puts "line #{$INPUT_LINE_NUMBER + 1}: Error: #{$!.message}"
raise e
rescue
puts "line #{$INPUT_LINE_NUMBER + 1}: Unknown Error for this data:"
puts row
raise $!
end
end
course
end
|