Beispiel #1
0
class ThatsMyBrand(qtw.QWidget):
    def __init__(self, brand, subprompt, warm, friendly, rest_header, rest_qs):
        super().__init__()
        self.warm_q = SingleQuestion(*warm)
        self.friendly_q = SingleQuestion(*friendly)
        # One MultiQuestion (same header)
        self.multi_q = MultiQuestion(rest_header, rest_qs)

        txt = JustText(subprompt % brand)  # Please answer the following...
        lt = qtw.QVBoxLayout()
        lt.addWidget(txt)
        lt.addWidget(self.warm_q)
        lt.addWidget(self.friendly_q)
        lt.addWidget(self.multi_q)
        self.setLayout(lt)

    def get_responses(self):
        return [
            self.warm_q.get_responses(),
            self.friendly_q.get_responses(),
            self.multi_q.get_responses()
        ]

    def all_ans(self):
        resps = self.get_responses()
        return all([x >= 1 for sublist in resps for x in sublist])
Beispiel #2
0
class MovieQuestion(qtw.QWidget):
    def __init__(self, headers, questions, q3_ans, movie_info):
        super().__init__()
        self.question1 = SingleQuestion(headers[0], questions[0])
        self.question2 = SingleQuestion(headers[1], questions[1])
        self.question3 = DropDownQuestion(questions[2], q3_ans)
        layout = qtw.QVBoxLayout()
        layout.addWidget(JustText(movie_info))
        layout.addWidget(self.question1)
        layout.addWidget(self.question2)
        layout.addWidget(self.question3)
        self.setLayout(layout)

    def get_responses(self):
        return [
            self.question1.get_responses(),
            self.question2.get_responses(),
            self.question3.get_responses()
        ]

    def all_ans(self):
        if (all(x >= 1 for x in self.question1.get_responses())
                and all(x >= 1 for x in self.question2.get_responses()) and
                self.question3.get_responses() != self.question3._default_ans):
            return True
        return False
Beispiel #3
0
 def __init__(self, prompt, header, question):
     super().__init__()
     txt = JustText(prompt)
     self.question = SingleQuestion(header, question)
     layout = qtw.QVBoxLayout()
     layout.addWidget(txt)
     layout.addWidget(self.question)
     self.setLayout(layout)
 def __init__(self, header1, question1, header2, question2):
     super().__init__()
     self.q1 = SingleQuestion(header1, question1)
     self.q2 = SingleQuestion(header2, question2)
     layout = qtw.QVBoxLayout()
     layout.addWidget(self.q1)
     layout.addWidget(self.q2)
     self.setLayout(layout)
Beispiel #5
0
class DV10WillingnessToForgive(BaseDV):
    name = 'dv10'
    long_name = 'dv10_willingnesstoforgive'

    def __init__(self, block_num, device, temperature, settings):
        super().__init__(block_num, device, temperature, settings)
        lang = settings['language']

        translation_path = os.path.join(settings['translation_dir'],
                                        '%s.toml' % self.name)
        with open(translation_path, 'r', encoding='utf8') as f:
            translation = toml.load(f)

        prompt = translation['prompt'][lang]
        self.question = translation['question'][lang]
        header = translation['header'][lang]

        layout = qtw.QVBoxLayout()
        layout.addWidget(JustText(prompt))

        self.qs = SingleQuestion(header, self.question)
        layout.addWidget(self.qs)

        self.setLayout(layout)

    def save_data(self):
        current_answers = self.qs.get_responses()
        current_answers = [ca if ca >= 1 else None for ca in current_answers]
        settings = self.settings
        now = self._start_time.strftime('%y%m%d_%H%M%S')
        csv_name = os.path.join(settings['data_dir'],
                                '%s_%s.csv' % (self.name, now))
        data = {
            'participant_id': [settings['id']],
            'datetime_start_exp': [settings['datetime_start']],
            'datetime_start_block': [now],
            'datetime_end_block': [self._end_time.strftime('%y%m%d_%H%M%S')],
            'language': [settings['language']],
            'locale': [settings['locale']],
            'questions': [self.question],
            'question_original_order': ['q0'],
            'responses': current_answers,
            'dv': [self.long_name],
            'block_number': [self.block_num],
            'embr_temperature': [self.temperature]
        }
        keys = sorted(data.keys())
        with open(csv_name, 'w', newline='\n', encoding='utf-8') as f:
            writer = csv.writer(f, delimiter=",")
            writer.writerow(keys)
            writer.writerows(zip(*[data[key] for key in keys]))

    def all_ans(self):
        ff = [x >= 1 for x in self.qs.get_responses()]
        return all(ff)
Beispiel #6
0
 def __init__(self, headers, questions, q3_ans, movie_info):
     super().__init__()
     self.question1 = SingleQuestion(headers[0], questions[0])
     self.question2 = SingleQuestion(headers[1], questions[1])
     self.question3 = DropDownQuestion(questions[2], q3_ans)
     layout = qtw.QVBoxLayout()
     layout.addWidget(JustText(movie_info))
     layout.addWidget(self.question1)
     layout.addWidget(self.question2)
     layout.addWidget(self.question3)
     self.setLayout(layout)
Beispiel #7
0
 def __init__(self, img_name, header, question):
     super().__init__()
     img = QPixmap(img_name)
     img_holder = qtw.QLabel()
     img_holder.setPixmap(img.scaled(1000, 500, Qt.KeepAspectRatio, Qt.SmoothTransformation))
     img_holder.setAlignment(Qt.AlignCenter)
     self.question = SingleQuestion(header, question)
     layout = qtw.QVBoxLayout()
     layout.addWidget(img_holder)
     layout.addWidget(self.question)
     self.setLayout(layout)
Beispiel #8
0
    def __init__(self, brand, subprompt, warm, friendly, rest_header, rest_qs):
        super().__init__()
        self.warm_q = SingleQuestion(*warm)
        self.friendly_q = SingleQuestion(*friendly)
        # One MultiQuestion (same header)
        self.multi_q = MultiQuestion(rest_header, rest_qs)

        txt = JustText(subprompt % brand)  # Please answer the following...
        lt = qtw.QVBoxLayout()
        lt.addWidget(txt)
        lt.addWidget(self.warm_q)
        lt.addWidget(self.friendly_q)
        lt.addWidget(self.multi_q)
        self.setLayout(lt)
    def __init__(self, device, settings):
        super().__init__(15, device, 0, settings, None)
        lang = settings['language']
        locale = settings['locale']
        translation_path = os.path.join(settings['translation_dir'], '%s.toml' % self.name)
        with open(translation_path, 'r', encoding='utf8') as f:
            translation = toml.load(f)

        translation_path = os.path.join(self.settings['translation_dir'], 'misc.toml')
        with open(translation_path, 'r', encoding='utf8') as f:
            misc_translations = toml.load(f)

        locale_path = os.path.join(settings['locale_dir'], '%s.toml' % self.name)

        with open(locale_path, 'r', encoding='utf8') as f:
            locale_settings = toml.load(f)
        
        try:
            temperature_units = locale_settings['units'][locale]
        except KeyError:
            temperature_units = locale_settings['units']['us']

        first = random.choice([-9, 7])
        second = [-9, 7]
        second.remove(first)
        second = second[0]
        temp_q = translation['temp_q'][lang]
        temp_header = translation['temp_header'][lang]
        room_q = translation['room_q'][lang]
        hot_cold = translation['hot_cold'][lang]
        hot_cold_header = translation['hot_cold_header'][lang]
        comfort_q = translation['comfort_q'][lang]
        comfort_header = translation['comfort_header'][lang]
        
        self.comfort1 = SingleQuestion(temp_header, temp_q)
        self.wait1 = EmbrSection2(misc_translations['wait_until_green'][lang], device, first, 10000)
        self.current_temp1 = CurrentTempQuestion(room_q, temperature_units, device) # resets to 0 at end
        self.heatqs1 = HeatQuestions(hot_cold_header, hot_cold, comfort_header, comfort_q)
        self.idle1 = EmbrSection2(misc_translations['wait_until_green'][lang], device, 0, 5000)
        # part 2 (opposite temperature)
        self.comfort2 = SingleQuestion(temp_header, temp_q)
        self.wait2 = EmbrSection2(misc_translations['wait_until_green'][lang], device, second, 10000)
        self.current_temp2 = CurrentTempQuestion(room_q, temperature_units, device) # resets to 0 at end
        self.heatqs2 = HeatQuestions(hot_cold_header, hot_cold, comfort_header, comfort_q)

        self.add_widgets([self.comfort1, self.wait1, self.current_temp1, self.heatqs1, self.idle1,
                          self.comfort2, self.wait2, self.current_temp2, self.heatqs2])
        self.q_temp_pairs = [(temp_q, first), (room_q, first), (hot_cold, first), (comfort_q, first),
                             (temp_q, second), (room_q, second), (hot_cold, second), (comfort_q, second)]
Beispiel #10
0
class HeatQuestions(qtw.QWidget):
    # how hot or cold did the device feel, and
    # was it comfortable?
    def __init__(self, header1, question1, header2, question2):
        super().__init__()
        self.q1 = SingleQuestion(header1, question1)
        self.q2 = SingleQuestion(header2, question2)
        layout = qtw.QVBoxLayout()
        layout.addWidget(self.q1)
        layout.addWidget(self.q2)
        self.setLayout(layout)
    
    def get_responses(self):
        return [self.q1.get_responses()[0], self.q2.get_responses()[0]]
    
    def all_ans(self):
        return all([x >= 1 for x in self.get_responses()])
Beispiel #11
0
    def __init__(self, block_num, device, temperature, settings):
        super().__init__(block_num, device, temperature, settings)
        lang = settings['language']

        translation_path = os.path.join(settings['translation_dir'],
                                        '%s.toml' % self.name)
        with open(translation_path, 'r', encoding='utf8') as f:
            translation = toml.load(f)

        prompt = translation['prompt'][lang]
        self.question = translation['question'][lang]
        header = translation['header'][lang]

        layout = qtw.QVBoxLayout()
        layout.addWidget(JustText(prompt))

        self.qs = SingleQuestion(header, self.question)
        layout.addWidget(self.qs)

        self.setLayout(layout)
Beispiel #12
0
class UtilitarianQuestion(qtw.QWidget):
    def __init__(self, prompt, header, question):
        super().__init__()
        txt = JustText(prompt)
        self.question = SingleQuestion(header, question)
        layout = qtw.QVBoxLayout()
        layout.addWidget(txt)
        layout.addWidget(self.question)
        self.setLayout(layout)

    def get_responses(self):
        return self.question.get_responses()

    def all_ans(self):
        return all([x >= 1 for x in self.get_responses()])
Beispiel #13
0
class RelationshipQuestion(qtw.QWidget):
    def __init__(self, img_name, header, question):
        super().__init__()
        img = QPixmap(img_name)
        img_holder = qtw.QLabel()
        img_holder.setPixmap(img.scaled(1000, 500, Qt.KeepAspectRatio, Qt.SmoothTransformation))
        img_holder.setAlignment(Qt.AlignCenter)
        self.question = SingleQuestion(header, question)
        layout = qtw.QVBoxLayout()
        layout.addWidget(img_holder)
        layout.addWidget(self.question)
        self.setLayout(layout)

    def get_responses(self):
        return self.question.get_responses()

    def all_ans(self):
        return all([x >= 1 for x in self.get_responses()])
Beispiel #14
0
class EfficacyBlock(StackedDV):
    long_name = 'embrwave_efficacy'
    name = 'efficacy'

    def __init__(self, device, settings):
        super().__init__(15, device, 0, settings, None)
        lang = settings['language']
        locale = settings['locale']
        translation_path = os.path.join(settings['translation_dir'], '%s.toml' % self.name)
        with open(translation_path, 'r', encoding='utf8') as f:
            translation = toml.load(f)

        translation_path = os.path.join(self.settings['translation_dir'], 'misc.toml')
        with open(translation_path, 'r', encoding='utf8') as f:
            misc_translations = toml.load(f)

        locale_path = os.path.join(settings['locale_dir'], '%s.toml' % self.name)

        with open(locale_path, 'r', encoding='utf8') as f:
            locale_settings = toml.load(f)
        
        try:
            temperature_units = locale_settings['units'][locale]
        except KeyError:
            temperature_units = locale_settings['units']['us']

        first = random.choice([-9, 7])
        second = [-9, 7]
        second.remove(first)
        second = second[0]
        temp_q = translation['temp_q'][lang]
        temp_header = translation['temp_header'][lang]
        room_q = translation['room_q'][lang]
        hot_cold = translation['hot_cold'][lang]
        hot_cold_header = translation['hot_cold_header'][lang]
        comfort_q = translation['comfort_q'][lang]
        comfort_header = translation['comfort_header'][lang]
        
        self.comfort1 = SingleQuestion(temp_header, temp_q)
        self.wait1 = EmbrSection2(misc_translations['wait_until_green'][lang], device, first, 10000)
        self.current_temp1 = CurrentTempQuestion(room_q, temperature_units, device) # resets to 0 at end
        self.heatqs1 = HeatQuestions(hot_cold_header, hot_cold, comfort_header, comfort_q)
        self.idle1 = EmbrSection2(misc_translations['wait_until_green'][lang], device, 0, 5000)
        # part 2 (opposite temperature)
        self.comfort2 = SingleQuestion(temp_header, temp_q)
        self.wait2 = EmbrSection2(misc_translations['wait_until_green'][lang], device, second, 10000)
        self.current_temp2 = CurrentTempQuestion(room_q, temperature_units, device) # resets to 0 at end
        self.heatqs2 = HeatQuestions(hot_cold_header, hot_cold, comfort_header, comfort_q)

        self.add_widgets([self.comfort1, self.wait1, self.current_temp1, self.heatqs1, self.idle1,
                          self.comfort2, self.wait2, self.current_temp2, self.heatqs2])
        self.q_temp_pairs = [(temp_q, first), (room_q, first), (hot_cold, first), (comfort_q, first),
                             (temp_q, second), (room_q, second), (hot_cold, second), (comfort_q, second)]
    
    def save_data(self):
        resp_heat1 = self.heatqs1.get_responses()
        resp_heat1 = [ca if ca >= 1 else None for ca in resp_heat1]
        resp_heat2 = self.heatqs2.get_responses()
        resp_heat2 = [ca if ca >= 1 else None for ca in resp_heat2]
        current_answers = [self.comfort1.get_responses()[0], self.current_temp1.get_responses(),
                           resp_heat1[0], resp_heat1[1],
                           self.comfort2.get_responses()[0], self.current_temp2.get_responses(),
                           resp_heat2[0], resp_heat2[1]]
        temps = [v[1] for v in self.q_temp_pairs]
        qs = [v[0] for v in self.q_temp_pairs]
        settings = self.settings
        now = self._start_time.strftime('%y%m%d_%H%M%S')
        csv_name = os.path.join(settings['data_dir'], '%s_%s.csv' % (self.name, now))
        num_q = len(temps)
        data = {'participant_id': num_q * [settings['id']],
                'datetime_start_exp': num_q * [settings['datetime_start']],
                'datetime_start_block': num_q * [now],
                'datetime_end_block': num_q * [self._end_time.strftime('%y%m%d_%H%M%S')],
                'language': num_q * [settings['language']],
                'locale': num_q * [settings['locale']],
                'questions': [q + '...' for q in qs],
                'question_original_order': [('q%s' % x) for x in range(4)] * 2,
                'responses': current_answers,
                'dv': num_q * [self.long_name],
                'block_number': num_q * [self.block_num],
                'embr_temperature': temps}
        keys = sorted(data.keys())
        with open(csv_name, 'w', newline='\n', encoding='utf-8') as f:
            writer = csv.writer(f, delimiter=",")
            writer.writerow(keys)
            writer.writerows(zip(*[data[key] for key in keys]))

    def all_ans(self):
        return self.currentWidget().all_ans()