Beispiel #1
0
    def load_record(self):
        tabs = self.tab.children()[0].children()
        from utils.database_utils import DatabaseConnect
        db = DatabaseConnect()
        answer_list = db.get_answers_by_evaluation(self.selected_productId)

        attachments = db.get_attachments(window=self.temp_window, product_id=self.selected_productId)
        if attachments:
            if attachments["attachment_one"] and attachments["attachment_one"] != 'None' and attachments["attachment_one"] != "":
                self.attachment1_path = attachments["attachment_one"]
                file_path = self.attachment1_path
                self.btn_attachment1.setText(file_path.split("/")[-1][:10]+"..")
            self.btn_attachment1.setAutoFillBackground(True)
            self.btn_attachment1.clicked.disconnect(self.btn_attachment1_clicked)
            self.btn_attachment1.clicked.connect(self.show_attachment1)
            self.btn_attachment1.show()
            self.btn_attachment1.installEventFilter(self.temp_window)

            if attachments["attachment_two"] and attachments["attachment_two"] != 'None' and attachments["attachment_two"] != "":
                self.attachment2_path = attachments["attachment_two"]
                file_path = self.attachment2_path
                self.btn_attachment2.setAutoFillBackground(True)
                self.btn_attachment2.setText(file_path.split("/")[-1][:10]+"..")
            self.btn_attachment2.show()
            self.btn_attachment2.clicked.disconnect(self.btn_attachment2_clicked)
            self.btn_attachment2.clicked.connect(self.show_attachment2)
            self.btn_attachment2.installEventFilter(self.temp_window)

        for tab in tabs:
            if tab and "tab_" in tab.objectName() and tab.objectName() != "tab_overview":
                tab_name = str(tab.objectName())
                dimension = int((tab_name).replace("tab_", ""))

                for quesbox in tab.children():

                    for d in answer_list:
                        if d["question"] == quesbox.title() and d["dimension"] == dimension:
                            final_answer = str(d["answer"])

                            for option in quesbox.children()[1:]:
                                if str(option.text()) == str(final_answer):
                                    option.setChecked(True)
                    quesbox.setDisabled(True)

        self.btn_reset.setDisabled(True)
        self.btn_save.setDisabled(True)
        self.btn_return.setDisabled(True)
def get_scores(product_id):
    """
                        Calculate the score of all dimensions
    :param product_id:
    :return: Dictionary containing the dimention as a key and score as a value.
    """
    from utils.database_utils import DatabaseConnect
    db = DatabaseConnect()
    dimension_scores = {}
    answers = db.get_answers_by_evaluation(
        product_id)  # Get all the answers of an evaluation
    if answers:
        formatted_answers = format_answer_to_get_score(answers)
        for dimension, answers in formatted_answers.items():
            d_score = get_dimension_score(answers)
            dimension_scores.update({dimension: d_score})
    return dimension_scores