'''
Created on 13-Jan-2023
@author: b_thakur
'''
import os 

import random
import inspect
import traceback
import sympy
from sympy import (simplify, sympify, log, 
                   symbols, Symbol, Function,
                   Add, Mul,
                   Eq, Matrix, latex, 
                   solve, Rational, diag,
                   Derivative, Integral,
                   UnevaluatedExpr as ueval
                   )

from xv.math.formulae import FormulaSet
from xv.util import list_to_str

from ..helper import BaseHelper

from xv.km.managers import BaseManager
from xv.km.kelements import KProblemTemplate
from xv.km.util import latex_color, latex_fraction

# _integrated_lesson_manager
# IntegratedLessonManager

        
class IntegratedLessonManager(BaseManager):
    '''
    Integrated Lessons in Physics and Math

    Examples
    --------
    ke = IntegratedLessonManager()
    ke 
    
    ke.printProblemTypes()
    ke.helpProblemType(0)
    
    ke.getRandomProblem()
    ke.getRandomProblem(problem_type = 0)

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

    doc_style: xv_doc
    ''' 
    
    def __new__(cls, *args, **kwargs):
        instance = super(IntegratedLessonManager, cls).__new__(cls, *args, **kwargs)
        for base_class in IntegratedLessonManager.__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_learning_1',
            ])
        pass



    def _problem_learning_1(self, *args, **kwargs):
        problemTemplate = KProblemTemplate()
        problemTemplate.problem_type = kwargs.get('problem_type')

        problem_s = f"""
        _problem_learning_1
        """
        problemTemplate.add_problem(problem_s.strip(), 'text/html')
        
        soln_s = f"""
        $\\forall a \\in \\mathbf{{R}} \\cdot a^2 \\geq 0$
        """
        problemTemplate.add_solution(soln_s.strip(), 'text/html')
        
        answer_s = f"""
        _problem_learning_1
        """
        problemTemplate.add_answer(answer_s.strip(), 'text/html')
        
        return problemTemplate


    def _sample(self, *args, **kwargs):
        problemTemplate = KProblemTemplate()
        problemTemplate.problem_type = kwargs.get('problem_type')

        problem_s = f"""
        """
        problemTemplate.add_problem(problem_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

