forked from mgavaudan/DBC-voter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv_dbc.rb
71 lines (54 loc) · 1.55 KB
/
v_dbc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
require_relative "view.rb"
require_relative "models.rb"
class Controller
def initialize
@username = ''
@model = Model.new
end
def program_loop
#system('clear')
@username = @model.login(View.welcome)
loop do
puts "Welcome #{@username}"
subject_choice = subjects_module
break if subject_choice == 'quit'
#system('clear')
answers_module(subject_choice)
#system('clear')
end
end
def subjects_module
subjects = @model.load_subjects
View.subjects_menu(subjects)
subject_choice = View.subjects_menu_options
if subject_choice == "add"
subject_string = View.new_subject
new_subject_id = @model.add_subject(subject_string)
return new_subject_id
end
subject_choice
end
def answers_module(subject_choice)
answers = @model.load_answers(subject_choice.to_i)
View.view_answers(answers)
answer_choice = View.answers_menu_options
if answer_choice == 'add'
answer_string = View.new_answer
@model.add_answer(answer_string, subject_choice.to_i)
View.view_answers(answers)
end
end
#display welcome view
#receive the username from welcome view
#pass the username to login model
#receive authentication from login model either way
#display subjects_menu view
#receive option variable from subjects view and pass through to view answers or create subject
# option 1 - view answers
# option 2 - create subjects - takes input from user, creates subject in db
# takes you to view answers for just created subject
#controller sends answers from db view answers
end
vdbc = Controller.new
vdbc.program_loop
#MODEL - DB ACCESS