'''
Created on 16-Mar-2025

@author: B Thakur

PHYSICS WITH ANSWERS: 500 PROBLEMS AND SOLUTIONS
by A. R. KING AND O. REGEV

'''

import random
import inspect
import traceback

from ..helper import BaseHelper

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

# _physics_advanced_problems_manager
# PhysicsAdvancedProblemsManager

class PhysicsAdvancedProblemsManager(BaseManager):
    '''
    PhysicsAdvancedProblemsManager
    Example:
        ke = PhysicsAdvancedProblemsManager()
        ke.getRandomProblem()
        ke.getRandomProblem(problem_type = 0)
        ...
        
        ke.printProblem()
        ke.printAnswer()
        ke.printSolution()
        
        ke.printProblemTypes()
        
    '''    
    _OPR_TYPE_COUNT = 10
    
    def __new__(cls, *args, **kwargs):
        instance = super(PhysicsAdvancedProblemsManager, cls).__new__(cls, *args, **kwargs)
        for base_class in PhysicsAdvancedProblemsManager.__bases__:
            base_class.__init__(instance, *args, **kwargs)
        return instance
    
    def __init__(self, *args, **kwargs):
        self.base_helper = BaseHelper(**kwargs)
        self.rah = self.base_helper.get_radio_activity_helper()
        pass



    def _init_problem_types(self, *args, **kwargs):
        self._append_problem_types([
            
            '_problem_mechanics_theory',
            '_problem_statics',
            '_problem_kinematics',
            '_problem_newtons_second_law',
            '_problem_work_energy_and_power',
            '_problem_momentum_and_impulse',
            '_problem_circular_and_harmonic_motion',
            '_problem_gravitation',
            '_problem_rigid_body_motion',
            '_problem_electricity_and_magnetism_theory',
            '_problem_electric_forces_and_fields',
            '_problem_electrostatic_potential_and_capacitance',
            '_problem_electric_currents_and_circuits',
            '_problem_magnetic_forces_and_fields',
            '_problem_electromagnetic_induction',
            '_problem_matter_and_waves_theory',
            '_problem_liquids_and_gases',
            '_problem_heat_and_thermodynamics',
            '_problem_light_and_waves',
            '_problem_atomic_and_nuclear_physics',
            '_problem_relativity',

            ])
        pass
    
    
    

    def _problem_mechanics_theory(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "mechanics_theory.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)





    def _problem_statics(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "statics.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)





    def _problem_kinematics(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "kinematics.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)





    def _problem_newtons_second_law(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "newtons_second_law.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)





    def _problem_work_energy_and_power(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "work_energy_and_power.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)





    def _problem_momentum_and_impulse(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "momentum_and_impulse.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)





    def _problem_circular_and_harmonic_motion(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "circular_and_harmonic_motion.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)





    def _problem_gravitation(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "gravitation.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)





    def _problem_rigid_body_motion(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "rigid_body_motion.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)





    def _problem_electricity_and_magnetism_theory(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "electricity_and_magnetism_theory.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)





    def _problem_electric_forces_and_fields(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "electric_forces_and_fields.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)





    def _problem_electrostatic_potential_and_capacitance(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "electrostatic_potential_and_capacitance.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)





    def _problem_electric_currents_and_circuits(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "electric_currents_and_circuits.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)





    def _problem_magnetic_forces_and_fields(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "magnetic_forces_and_fields.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)





    def _problem_electromagnetic_induction(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "electromagnetic_induction.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)





    def _problem_matter_and_waves_theory(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "matter_and_waves_theory.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)





    def _problem_liquids_and_gases(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "liquids_and_gases.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)





    def _problem_heat_and_thermodynamics(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "heat_and_thermodynamics.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)





    def _problem_light_and_waves(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "light_and_waves.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)





    def _problem_atomic_and_nuclear_physics(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "atomic_and_nuclear_physics.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)





    def _problem_relativity(self, *args, **kwargs):
        folder_path = "question_bank/physics/physics_500_problems"
        search_file_paths = [
                "relativity.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)
    