'''
Created on 06-Mar-2024

@author: bthakur
'''
import os 
import random
import inspect
import traceback

import sympy as sp
import numpy as np

from sympy import (symbols, Function, Derivative, diff,
                   simplify, latex,
                   Symbol, Sum, binomial, factorial, UnevaluatedExpr
                   )

from xv.util import list_to_str
from xv.km.util import latex_fraction

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

# _iit_geometry_3d_manager
# IitGeometry3dManager
        
class IitGeometry3dManager(BaseManager):
    '''

    doc_style: xv_doc
    ''' 

    def __new__(cls, *args, **kwargs):
        instance = super(IitGeometry3dManager, cls).__new__(cls, *args, **kwargs)
        for base_class in IitGeometry3dManager.__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_equation_line',
                '_problem_multiple_questions_about_planes',
                '_problem_angle_bisector_and_projection_in_a_triangle',
             ])
        pass


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

        doc_style: xv_doc
        """
        g3d_helper = self.base_helper.get_geometry_helper().get_geometry_3d_helper()
        result = g3d_helper.get_problem_3d_line(**kwargs)
        
        problemTemplate = KProblemTemplate()
        problemTemplate.problem_type = kwargs.get('problem_type')
        
        
        prob_s = f"""
        {result['prob_s'].strip()}
        """
        problemTemplate.add_problem(prob_s.strip(), 'text/html')



        soln_s = f"""
        {result['soln_s'].strip()}
        """
        problemTemplate.add_solution(soln_s.strip(), 'text/html')



        answer_s = f"""
        {result['answer_s'].strip()}
        """

        problemTemplate.add_answer(answer_s.strip(), 'text/html')
        
        
        return problemTemplate
        pass

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

        doc_style: xv_doc
        """
        g3d_helper = self.base_helper.get_geometry_helper().get_geometry_3d_helper()
        result = g3d_helper.get_problem_multiple_questions_about_planes(**kwargs)
        
        problemTemplate = KProblemTemplate()
        problemTemplate.problem_type = kwargs.get('problem_type')
        
        
        prob_s = f"""
        {result['prob_s'].strip()}
        """
        problemTemplate.add_problem(prob_s.strip(), 'text/html')



        soln_s = f"""
        {result['soln_s'].strip()}
        """
        problemTemplate.add_solution(soln_s.strip(), 'text/html')



        answer_s = f"""
        {result['answer_s'].strip()}
        """

        problemTemplate.add_answer(answer_s.strip(), 'text/html')
        
        
        return problemTemplate
        pass

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

        doc_style: xv_doc
        """
        g3d_helper = self.base_helper.get_geometry_helper().get_geometry_3d_helper()
        result = g3d_helper.get_problem_angle_bisector_and_projection_in_a_triangle(**kwargs)
        
        problemTemplate = KProblemTemplate()
        problemTemplate.problem_type = kwargs.get('problem_type')
        
        
        prob_s = f"""
        {result['prob_s'].strip()}
        """
        problemTemplate.add_problem(prob_s.strip(), 'text/html')



        soln_s = f"""
        {result['soln_s'].strip()}
        """
        problemTemplate.add_solution(soln_s.strip(), 'text/html')



        answer_s = f"""
        {result['answer_s'].strip()}
        """

        problemTemplate.add_answer(answer_s.strip(), 'text/html')
        
        
        return problemTemplate
        pass

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

        doc_style: xv_doc
        """
        
        problemTemplate = KProblemTemplate()
        problemTemplate.problem_type = kwargs.get('problem_type')
        
        
        prob_s = f"""
        """
        problemTemplate.add_problem(prob_s.strip(), 'text/html')


        soln_s = f"""
                
        """

        
        problemTemplate.add_solution(soln_s.strip(), 'text/html')

        answer_s = f"""
        
        """

        problemTemplate.add_answer(answer_s.strip(), 'text/html')
        
        
        return problemTemplate
        pass


    pass
