'''
Created on 03-June-2024

@author: B Thakur

Space time momentum energy

'''
import random
import inspect
import traceback

from ..helper import BaseHelper

from xv.km.managers import BaseManager
from xv.km.kelements import KProblemTemplate



# _transistor_manager
# TransistorManager


class TransistorManager(BaseManager):
    '''
    TransistorManager

    Example:
        ke = TransistorManager()
        ke

        ke.printProblemTypes()

        ke.getRandomProblem()
        ke.getRandomProblem(problem_type = 0)
        ...

        ke.printProblem()
        ke.printAnswer()
        ke.printSolution()



    '''
    def __new__(cls, *args, **kwargs):
        instance = super(TransistorManager, cls).__new__(cls, *args, **kwargs)
        for base_class in TransistorManager.__bases__:
            base_class.__init__(instance, *args, **kwargs)
        return instance

    def __init__(self, *args, **kwargs):
        self.base_helper = BaseHelper(**kwargs)

        pass



    def _init_problem_types(self, *args, **kwargs):

        self._append_problem_types([
            '_problem_overview_of_transistors',
            '_problem_questions_overview_of_transistors',


         ])

        pass


    def _problem_overview_of_transistors(self, *args, **kwargs):
        '''
        '''

        folder_path = "comprehension/physics/electronics"
        search = "overview_of_transistors.txt"

        search_in_content = kwargs.get("search", None)
        file_paths = self.get_comp_factory().search_comprehension_files(folder_path,
                                                                        search_in_name = search,
                                                                        search_in_content = search_in_content)

        file_path = random.choice(file_paths)

        return self.get_comp_factory().PROBLEM_TEMPLATE_COMP_RANDOM_QUESTIONS(file_path, *args, **kwargs)



    def _problem_questions_overview_of_transistors(self, *args, **kwargs):
        """
        """

        folder_path = "comprehension/physics/electronics"
        search_file_paths = [
            "overview_of_transistors.txt"
            ]

        file_paths = self.get_q_bank_factory().search_question_bank_files(folder_path, search_file_paths)
        return self.get_q_bank_factory().PROBLEM_TEMPLATE_Q_BANK_RANDOM_QUESTION(file_paths, *args, **kwargs)


