forked from sd17spring/InteractiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion.py
More file actions
57 lines (46 loc) · 1.58 KB
/
question.py
File metadata and controls
57 lines (46 loc) · 1.58 KB
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
"""
Authors: Emily Lepert and Vicky McDermott
"""
from interpret import Interpret
from data import Data
from bokeh.io import output_file, show, vform
from bokeh.layouts import widgetbox
from bokeh.models.widgets import RadioGroup, Div, Button
class Question():
# placeholder radiogroup variable so it can be modified later
answer = RadioGroup(labels=['dfd', 'dfd'])
def __init__(self,index, interpret, data_type, data):
'''
Determines layout of the question child
Attributes: data_type, interpret, index, qa, question_typed_out, question
'''
#differentiates between earthquake and comma
self.data_type = data_type
#Interpret class reference
self.interpret = interpret
#question number in either earthquake or comma
self.index = index
#dictionary of questions and answers from the Interpret class
self.qa = self.interpret.dictionary_of_qa()
# Written out question
self.question_typed_out = data.get_question(self.index)
# Question text div
self.question = Div(text=self.question_typed_out)
def get_fig(self):
'''
Creates the question and answer widget
'''
#creates a radio group with the appropriate answer options
length = len(self.qa[self.index])
Question.answer = RadioGroup(labels=self.get_list_answers(length))
choices = widgetbox(self.question, Question.answer)
items = length
return([choices, items])
def get_list_answers(self, items):
'''
Outputs the list of answers for the question
'''
list_answers = []
for i in range(items):
list_answers.append(self.interpret.key_formatting(self.qa[self.index][i]))
return(list_answers)