Class: Csv2qti::Outcome

Inherits:
Object
  • Object
show all
Defined in:
lib/csv2qti/outcome.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row, parent_outcome = nil) ⇒ Outcome

Returns a new instance of Outcome.



5
6
7
8
9
10
11
12
13
14
# File 'lib/csv2qti/outcome.rb', line 5

def initialize(row, parent_outcome=nil)
  @number = row[0]
  @title = row[1]
  @description = row[2]
  @guid = row[3]
  @license = row[5]
  @parent_outcome = parent_outcome
  @enabling_outcomes = []
  @questions = []
end

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description.



3
4
5
# File 'lib/csv2qti/outcome.rb', line 3

def description
  @description
end

#enabling_outcomesObject (readonly)

Returns the value of attribute enabling_outcomes.



3
4
5
# File 'lib/csv2qti/outcome.rb', line 3

def enabling_outcomes
  @enabling_outcomes
end

#guidObject (readonly)

Returns the value of attribute guid.



3
4
5
# File 'lib/csv2qti/outcome.rb', line 3

def guid
  @guid
end

#licenseObject (readonly)

Returns the value of attribute license.



3
4
5
# File 'lib/csv2qti/outcome.rb', line 3

def license
  @license
end

#numberObject (readonly)

Returns the value of attribute number.



3
4
5
# File 'lib/csv2qti/outcome.rb', line 3

def number
  @number
end

#questionsObject (readonly)

Returns the value of attribute questions.



3
4
5
# File 'lib/csv2qti/outcome.rb', line 3

def questions
  @questions
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'lib/csv2qti/outcome.rb', line 3

def title
  @title
end

Instance Method Details

#add_enabling_outcome(row) ⇒ Object



16
17
18
19
# File 'lib/csv2qti/outcome.rb', line 16

def add_enabling_outcome(row)
  @enabling_outcomes << Outcome.new(row, self)
  @enabling_outcomes.last
end

#add_question(row) ⇒ Object



21
22
23
# File 'lib/csv2qti/outcome.rb', line 21

def add_question(row)
  @questions << Question.generate(row)
end

#add_questions(group) ⇒ Object



49
50
51
52
53
# File 'lib/csv2qti/outcome.rb', line 49

def add_questions(group)
  @questions.each do |q|
    q.add_to_group(group)
  end
end

#generate_assessmentObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/csv2qti/outcome.rb', line 29

def generate_assessment
  assessment = CanvasCc::CanvasCC::Models::Assessment.new
  assessment.identifier = rand(10000).to_s
  assessment.items = []
  assessment.title = @title
  add_questions(assessment)

  @enabling_outcomes.each do |eo|
    g = CanvasCc::CanvasCC::Models::QuestionGroup.new
    g.title = eo.title
    g.identifier = rand(10000).to_s
    g.selection_number = 1
    g.points_per_item = 1
    eo.add_questions(g)
    assessment.items << g
  end

  assessment
end

#is_primary_outcome?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/csv2qti/outcome.rb', line 25

def is_primary_outcome?
  !! @parent_outcome
end

#to_sObject



55
56
57
58
59
60
61
# File 'lib/csv2qti/outcome.rb', line 55

def to_s
  if is_primary_outcome?
    "#{number}: #{title} - #{description} - #{guid} - #{license} - #{questions.count} questions"
  else
    "#{number}: #{title} - #{description} - #{guid} - #{license} - #{enabling_outcomes.count} enabling outcomes"
  end
end