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

#bads ⇒ Object

Bads answers used by choice type question



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

def bads
  @bads
end

#comment ⇒ Object

Comments asociated



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

def comment
  @comment
end

#encode ⇒ Object

image base64 content used when export Moodle xml



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

def encode
  @encode
end

#feedback ⇒ Object

Question feedbak



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

def feedback
  @feedback
end

#good ⇒ Object

The correct answer



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

def good
  @good
end

#lang ⇒ Object

Info used when export (YAML)



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

def lang
  @lang
end

#matching ⇒ Object

Matching answers used by match type question



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

def matching
  @matching
end

#name ⇒ Object

Question name used as identification



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

def name
  @name
end

#shorts ⇒ Object

Short answers used by short type question



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

def shorts
  @shorts
end

#tags ⇒ Object

Returns the value of attribute tags.



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

def tags
  @tags
end

#text ⇒ Object

The real text of the question



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

def text
  @text
end

#type ⇒ Object (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_boolean ⇒ Object

Set boolean type



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

def set_boolean
  @type = :boolean
end

#set_choice ⇒ Object

Set choice type



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

def set_choice
  @type = :choice
end

#set_match ⇒ Object

Set match type



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

def set_match
  @type = :match
end

#set_short ⇒ Object

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_off ⇒ Object

Set shuffle off



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

def shuffle_off
  @shuffle = false
end

#shuffle_on ⇒ Object

Set shuffle on



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

def shuffle_on
  @shuffle = true
end