'''
Created on 16-Apr-2021

@author: bthakur
'''
import os
import numpy as np
import random
import inspect
import traceback

import sympy

from sympy import ( latex,symbols, diff, Symbol, Mul, Matrix, Function,
                    factorial, sympify, Rational, log,
                    Derivative, factor, Eq, simplify, expand,
                    exp, sin, cos, cosh, sinh, pi, sqrt, atan, Limit,
                    expand_trig, trigsimp, srepr, Integer, Pow, Add)

from sympy.core.numbers import One, Integer
from sympy.simplify.fu import TR1, TR2, TR2i, fu, TR16, TR22


from ...helper import BaseHelper, CalculusHelper
from xv.km.managers import BaseManager
from xv.km.kelements import KProblemTemplate

# _differential_equation_overview_manager
# DifferentialEquationOverviewManager

class DifferentialEquationOverviewManager(BaseManager):
    '''
    Differentiation
    Example:
        ke = DifferentialEquationOverviewManager()
        ke

        ke.printProblemTypes()

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

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


    '''
    def __new__(cls, *args, **kwargs):
        instance = super(DifferentialEquationOverviewManager, cls).__new__(cls, *args, **kwargs)
        for base_class in DifferentialEquationOverviewManager.__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_ode_first_order_questions',
            '_problem_ode_second_order_questions',
            '_problem_ode_second_order_series_solution_questions',
            '_problem_linear_first_order_equations',
            '_problem_nonlinear_bifurcation_questions',
            '_problem_partial_differential_equations_questions',

             ])
        pass


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

        """

        folder_path = "question_bank/math/calculus"
        search_file_paths = [
                "ode_first_order_questions.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_ode_second_order_questions(self, *args, **kwargs):
        """

        """

        folder_path = "question_bank/math/calculus"
        search_file_paths = [
                "ode_second_order_questions.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_ode_second_order_series_solution_questions(self, *args, **kwargs):
        """

        """

        folder_path = "question_bank/math/calculus"
        search_file_paths = [
                "ode_second_order_series_solution_questions.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_linear_first_order_equations(self, *args, **kwargs):
        """

        """

        folder_path = "question_bank/math/calculus"
        search_file_paths = [
                "linear_first_order_equations.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_nonlinear_bifurcation_questions(self, *args, **kwargs):
        """

        """

        folder_path = "question_bank/math/calculus"
        search_file_paths = [
                "nonlinear_bifurcation_questions.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_partial_differential_equations_questions(self, *args, **kwargs):
        """

        """

        folder_path = "question_bank/math/calculus"
        search_file_paths = [
                "partial_differential_equations_questions.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)


