Class: Question

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

Constant Summary collapse

TYPES =
%i[boolean choice ddmatch match ordering short]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type = :choice) ⇒ Question

Returns a new instance of Question.



24
25
26
# File 'lib/asker/ai/question.rb', line 24

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

Instance Attribute Details

#badsObject

Bads answers (type: choice)



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

def bads
  @bads
end

#commentObject

Comments asociated



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

def comment
  @comment
end

#encodeObject

image base64 content used when export Moodle xml



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

def encode
  @encode
end

#feedbackObject

Question feedbak



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

def feedback
  @feedback
end

#goodObject

The correct answer (types: boolean, choice)



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

def good
  @good
end

#langObject

Info used when export (YAML)



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

def lang
  @lang
end

#matchingObject

Matching answers (type: match)



20
21
22
# File 'lib/asker/ai/question.rb', line 20

def matching
  @matching
end

#nameObject

Question name used as identification



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

def name
  @name
end

#orderingObject

Steps answer (type: ordering)



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

def ordering
  @ordering
end

#shortsObject

Short answers (type: short)



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

def shorts
  @shorts
end

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
end

#textObject

The real text of the question



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

def text
  @text
end

#typeObject (readonly)

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



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

def type
  @type
end

Instance Method Details

#reset(type = :choice) ⇒ Object

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
44
45
46
47
# File 'lib/asker/ai/question.rb', line 29

def reset(type = :choice)
  validate type
  @type = type

  @name = ""
  @comment = ""
  @tags = Set.new
  @lang = nil
  @encode = :none

  @text = ""
  @feedback = nil
  @good = ""
  @bads = []
  @matching = []
  @ordering = []
  @shorts = []
  shuffle_on
end

#shuffle?Boolean

Returns:

  • (Boolean)


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

def shuffle?
  @shuffle
end

#shuffle_offObject



49
50
51
# File 'lib/asker/ai/question.rb', line 49

def shuffle_off
  @shuffle = false
end

#shuffle_onObject



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

def shuffle_on
  @shuffle = true
end