Class: Question

Inherits:
Object
  • Object
show all
Defined in:
lib/asker/ai/question.rb

Overview

Define Question class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = :choice) ⇒ Question

Initialize object

Parameters:

  • type (Symbol) (defaults to: :choice)

    Question type: choice, match, boolean, short



22
23
24
# File 'lib/asker/ai/question.rb', line 22

def initialize(type = :choice)
  reset(type)
end

Instance Attribute Details

#badsObject

Bads answers used by choice type question



11
12
13
# File 'lib/asker/ai/question.rb', line 11

def bads
  @bads
end

#commentObject

Comments asociated



8
9
10
# File 'lib/asker/ai/question.rb', line 8

def comment
  @comment
end

#encodeObject

image base64 content used when export Moodle xml



18
19
20
# File 'lib/asker/ai/question.rb', line 18

def encode
  @encode
end

#feedbackObject

Question feedbak



14
15
16
# File 'lib/asker/ai/question.rb', line 14

def feedback
  @feedback
end

#goodObject

The correct answer



10
11
12
# File 'lib/asker/ai/question.rb', line 10

def good
  @good
end

#langObject

Info used when export (YAML)



17
18
19
# File 'lib/asker/ai/question.rb', line 17

def lang
  @lang
end

#matchingObject

Matching answers used by match type question



12
13
14
# File 'lib/asker/ai/question.rb', line 12

def matching
  @matching
end

#nameObject

Question name used as identification



7
8
9
# File 'lib/asker/ai/question.rb', line 7

def name
  @name
end

#shortsObject

Short answers used by short type question



13
14
15
# File 'lib/asker/ai/question.rb', line 13

def shorts
  @shorts
end

#tagsObject

Returns the value of attribute tags.



16
17
18
# File 'lib/asker/ai/question.rb', line 16

def tags
  @tags
end

#textObject

The real text of the question



9
10
11
# File 'lib/asker/ai/question.rb', line 9

def text
  @text
end

#typeObject (readonly)

Question type: :choice, :match, :boolean, :short



15
16
17
# File 'lib/asker/ai/question.rb', line 15

def type
  @type
end

Instance Method Details

#reset(type = :choice) ⇒ Object

Reset attributes rubocop:disable Metrics/MethodLength

Parameters:

  • type (Symbol) (defaults to: :choice)

    Question type: choice, match, boolean, short



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/asker/ai/question.rb', line 29

def reset(type = :choice)
  @name = ''
  @comment = ''
  @text = ''
  @type = type
  @good = ''
  @bads = []
  @matching = []
  @shorts = []
  @feedback = nil
  shuffle_on
  @tags = Set.new
  @lang = nil
  @encode = :none
end

#set_booleanObject

Set boolean type



57
58
59
# File 'lib/asker/ai/question.rb', line 57

def set_boolean
  @type = :boolean
end

#set_choiceObject

Set choice type



47
48
49
# File 'lib/asker/ai/question.rb', line 47

def set_choice
  @type = :choice
end

#set_matchObject

Set match type



52
53
54
# File 'lib/asker/ai/question.rb', line 52

def set_match
  @type = :match
end

#set_shortObject

Set short type



62
63
64
# File 'lib/asker/ai/question.rb', line 62

def set_short
  @type = :short
end

#shuffle?Boolean

Return shuffle value

Returns:

  • (Boolean)


77
78
79
# File 'lib/asker/ai/question.rb', line 77

def shuffle?
  @shuffle
end

#shuffle_offObject

Set shuffle off



67
68
69
# File 'lib/asker/ai/question.rb', line 67

def shuffle_off
  @shuffle = false
end

#shuffle_onObject

Set shuffle on



72
73
74
# File 'lib/asker/ai/question.rb', line 72

def shuffle_on
  @shuffle = true
end