""" Certification Tests Module Provides pre-built certification exam benchmarks for various domains. """ from typing import List, Dict, Optional, Any import json from pathlib import Path from dataclasses import dataclass, field @dataclass class CertificationQuestion: """A single certification exam question.""" question: str answer: str category: str difficulty: str = "intermediate" points: float = 1.0 explanation: Optional[str] = None metadata: Dict[str, Any] = field(default_factory=dict) class CertificationTestBuilder: """ Base class for building certification tests. """ def __init__(self, name: str, domain: str): """ Initialize certification test. Args: name: Test name domain: Domain (e.g., 'financial', 'medical') """ self.name = name self.domain = domain self.questions: List[CertificationQuestion] = [] self.passing_score = 70.0 self.categories: List[str] = [] def add_question( self, question: str, answer: str, category: str, difficulty: str = "intermediate", explanation: Optional[str] = None ): """Add a question to the test.""" q = CertificationQuestion( question=question, answer=answer, category=category, difficulty=difficulty, explanation=explanation ) self.questions.append(q) if category not in self.categories: self.categories.append(category) def get_questions_by_category(self, category: str) -> List[CertificationQuestion]: """Get all questions in a category.""" return [q for q in self.questions if q.category == category] def to_benchmark_dict(self) -> Dict[str, Any]: """Convert to benchmark format.""" return { 'name': self.name, 'domain': self.domain, 'description': f"{self.name} Certification Exam", 'passing_score': self.passing_score, 'num_questions': len(self.questions), 'categories': self.categories, 'questions': [ { 'question': q.question, 'answer': q.answer, 'category': q.category, 'difficulty': q.difficulty, 'points': q.points, 'explanation': q.explanation, 'metadata': q.metadata } for q in self.questions ] } def save(self, filepath: str): """Save test to JSON.""" Path(filepath).parent.mkdir(parents=True, exist_ok=True) with open(filepath, 'w', encoding='utf-8') as f: json.dump(self.to_benchmark_dict(), f, indent=2, ensure_ascii=False) print(f"Certification test saved to: {filepath}") class FinancialCertificationTests: """ Pre-built financial certification tests. Includes: - CFP (Certified Financial Planner) - CFA (Chartered Financial Analyst) - CPA (Certified Public Accountant) - Series 7, Series 63 """ @staticmethod def create_cfp_exam() -> CertificationTestBuilder: """Create CFP certification exam.""" exam = CertificationTestBuilder("CFP (Certified Financial Planner)", "financial") exam.passing_score = 70.0 # Estate Planning exam.add_question( "What is the primary purpose of a revocable living trust?", "A revocable living trust allows assets to pass to beneficiaries without going through probate while maintaining the grantor's control during their lifetime.", category="Estate Planning", difficulty="intermediate" ) exam.add_question( "What is the annual gift tax exclusion for 2024?", "The annual gift tax exclusion for 2024 is $18,000 per recipient.", category="Estate Planning", difficulty="beginner" ) # Retirement Planning exam.add_question( "What are the contribution limits for a 401(k) plan in 2024 for individuals under 50?", "The contribution limit for 401(k) plans in 2024 is $23,000 for individuals under age 50.", category="Retirement Planning", difficulty="beginner" ) exam.add_question( "Explain the difference between a traditional IRA and a Roth IRA in terms of tax treatment.", "Traditional IRA contributions may be tax-deductible and earnings grow tax-deferred, with distributions taxed as ordinary income. Roth IRA contributions are made with after-tax dollars, but qualified distributions are tax-free.", category="Retirement Planning", difficulty="intermediate" ) # Tax Planning exam.add_question( "What is the long-term capital gains tax rate for high-income earners in 2024?", "The long-term capital gains tax rate for high-income earners is 20%, plus a potential 3.8% Net Investment Income Tax.", category="Tax Planning", difficulty="intermediate" ) # Investment Planning exam.add_question( "What is Modern Portfolio Theory and who developed it?", "Modern Portfolio Theory, developed by Harry Markowitz, suggests that investors can construct an optimal portfolio by considering the relationship between risk and return, focusing on diversification to maximize returns for a given level of risk.", category="Investment Planning", difficulty="advanced" ) exam.add_question( "Explain the concept of asset allocation.", "Asset allocation is the process of dividing investments among different asset classes (stocks, bonds, cash, etc.) to balance risk and reward according to an investor's goals, risk tolerance, and time horizon.", category="Investment Planning", difficulty="intermediate" ) # Insurance Planning exam.add_question( "What is the primary difference between term life insurance and whole life insurance?", "Term life insurance provides coverage for a specific period and has no cash value, while whole life insurance provides lifetime coverage and builds cash value over time.", category="Insurance Planning", difficulty="beginner" ) # Risk Management exam.add_question( "What is an umbrella insurance policy?", "An umbrella insurance policy provides additional liability coverage beyond the limits of homeowners, auto, and other personal insurance policies.", category="Risk Management", difficulty="intermediate" ) # Education Planning exam.add_question( "What are the tax advantages of a 529 college savings plan?", "529 plans offer tax-free growth and tax-free withdrawals when funds are used for qualified education expenses. Some states also provide state tax deductions for contributions.", category="Education Planning", difficulty="intermediate" ) return exam @staticmethod def create_cfa_level_1_exam() -> CertificationTestBuilder: """Create CFA Level I exam.""" exam = CertificationTestBuilder("CFA Level I", "financial") exam.passing_score = 70.0 # Ethics exam.add_question( "What are the six components of the CFA Institute Code of Ethics?", "The six components are: Act with integrity, Place client interests first, Use reasonable care and judgment, Act professionally, Promote integrity of capital markets, and Maintain competence.", category="Ethics", difficulty="intermediate" ) # Quantitative Methods exam.add_question( "What is the formula for calculating the present value of a perpetuity?", "The present value of a perpetuity is calculated as: PV = PMT / r, where PMT is the payment and r is the discount rate.", category="Quantitative Methods", difficulty="intermediate" ) # Economics exam.add_question( "Define GDP and explain the expenditure approach to measuring it.", "GDP (Gross Domestic Product) is the total value of goods and services produced in an economy. The expenditure approach calculates GDP as: GDP = C + I + G + (X - M), where C is consumption, I is investment, G is government spending, X is exports, and M is imports.", category="Economics", difficulty="intermediate" ) # Financial Reporting exam.add_question( "What are the three main financial statements?", "The three main financial statements are the Balance Sheet (Statement of Financial Position), Income Statement (Statement of Comprehensive Income), and Cash Flow Statement.", category="Financial Reporting", difficulty="beginner" ) # Corporate Finance exam.add_question( "What is the Weighted Average Cost of Capital (WACC)?", "WACC is the average rate a company expects to pay to finance its assets, weighted by the proportion of debt and equity in its capital structure.", category="Corporate Finance", difficulty="intermediate" ) # Equity Investments exam.add_question( "Explain the difference between value stocks and growth stocks.", "Value stocks trade at lower prices relative to fundamentals (P/E, P/B) and typically pay dividends. Growth stocks are expected to grow earnings faster than the market average and typically reinvest earnings rather than paying dividends.", category="Equity Investments", difficulty="intermediate" ) # Fixed Income exam.add_question( "What is duration and how does it relate to interest rate risk?", "Duration measures a bond's price sensitivity to interest rate changes. Higher duration means greater price sensitivity. When interest rates rise, bond prices fall more for bonds with higher duration.", category="Fixed Income", difficulty="advanced" ) # Derivatives exam.add_question( "What is a call option?", "A call option gives the holder the right, but not the obligation, to buy an underlying asset at a specified strike price on or before a specified expiration date.", category="Derivatives", difficulty="beginner" ) return exam @staticmethod def create_series_7_exam() -> CertificationTestBuilder: """Create Series 7 General Securities Representative exam.""" exam = CertificationTestBuilder("Series 7", "financial") exam.passing_score = 72.0 # Regulations exam.add_question( "What is Regulation T and what does it govern?", "Regulation T is a Federal Reserve Board regulation that governs customer cash accounts and the amount of credit that broker-dealers may extend to customers for securities purchases (currently 50% initial margin).", category="Regulations", difficulty="intermediate" ) # Securities Products exam.add_question( "What is the difference between common stock and preferred stock?", "Common stock provides voting rights and variable dividends based on company performance. Preferred stock typically has fixed dividends, no voting rights, and priority over common stock in liquidation.", category="Securities Products", difficulty="beginner" ) # Municipal Securities exam.add_question( "What are the two main types of municipal bonds?", "The two main types are General Obligation (GO) bonds, backed by the taxing power of the issuer, and Revenue bonds, backed by specific revenue sources like tolls or utility fees.", category="Municipal Securities", difficulty="intermediate" ) # Options exam.add_question( "What is a covered call strategy?", "A covered call strategy involves owning a stock and selling call options on that stock to generate income from the option premium while capping potential upside gains.", category="Options", difficulty="intermediate" ) # Suitability exam.add_question( "What factors must be considered when determining investment suitability for a client?", "Factors include the client's financial situation, tax status, investment objectives, time horizon, liquidity needs, risk tolerance, and investment experience.", category="Suitability", difficulty="intermediate" ) return exam class MedicalCertificationTests: """ Pre-built medical certification tests. """ @staticmethod def create_usmle_step_1_sample() -> CertificationTestBuilder: """Create USMLE Step 1 sample questions.""" exam = CertificationTestBuilder("USMLE Step 1 Sample", "medical") exam.passing_score = 70.0 # Anatomy exam.add_question( "Which cranial nerve is responsible for facial sensation and motor control of mastication?", "The trigeminal nerve (cranial nerve V) is responsible for facial sensation and motor control of the muscles of mastication.", category="Anatomy", difficulty="intermediate" ) # Physiology exam.add_question( "Describe the Frank-Starling mechanism of the heart.", "The Frank-Starling mechanism states that the force of cardiac contraction is directly proportional to the initial length of cardiac muscle fibers (preload). Increased venous return stretches the ventricle, leading to stronger contraction.", category="Physiology", difficulty="advanced" ) # Pharmacology exam.add_question( "What is the mechanism of action of ACE inhibitors?", "ACE inhibitors block the angiotensin-converting enzyme, preventing the conversion of angiotensin I to angiotensin II, thereby reducing vasoconstriction and aldosterone secretion, which lowers blood pressure.", category="Pharmacology", difficulty="intermediate" ) # Pathology exam.add_question( "What are the four cardinal signs of inflammation?", "The four cardinal signs of inflammation are: rubor (redness), calor (heat), tumor (swelling), and dolor (pain). A fifth sign, loss of function, is sometimes added.", category="Pathology", difficulty="beginner" ) return exam class LegalCertificationTests: """ Pre-built legal certification tests. """ @staticmethod def create_bar_exam_sample() -> CertificationTestBuilder: """Create Bar Exam sample questions.""" exam = CertificationTestBuilder("Bar Exam Sample", "legal") exam.passing_score = 70.0 # Constitutional Law exam.add_question( "What is the difference between strict scrutiny and rational basis review?", "Strict scrutiny requires the government to prove a compelling interest and narrowly tailored means (used for fundamental rights). Rational basis review only requires a legitimate interest and rational relationship (default standard).", category="Constitutional Law", difficulty="advanced" ) # Contracts exam.add_question( "What are the essential elements of a valid contract?", "The essential elements are: offer, acceptance, consideration, mutual assent (meeting of minds), capacity, and legality of purpose.", category="Contracts", difficulty="intermediate" ) # Torts exam.add_question( "What are the elements of negligence?", "The elements of negligence are: duty of care, breach of duty, causation (actual and proximate), and damages.", category="Torts", difficulty="intermediate" ) # Criminal Law exam.add_question( "What is mens rea?", "Mens rea is the mental state or intent element of a crime. It refers to the defendant's guilty mind or criminal intent at the time the criminal act was committed.", category="Criminal Law", difficulty="beginner" ) return exam class EducationCertificationTests: """ Pre-built education certification tests. """ @staticmethod def create_praxis_core_sample() -> CertificationTestBuilder: """Create Praxis Core sample test.""" exam = CertificationTestBuilder("Praxis Core Sample", "education") exam.passing_score = 70.0 # Reading exam.add_question( "What is the main idea vs. supporting details in a passage?", "The main idea is the central point or primary message of a passage, while supporting details provide evidence, examples, or explanations that reinforce the main idea.", category="Reading", difficulty="beginner" ) # Writing exam.add_question( "What is the difference between an independent clause and a dependent clause?", "An independent clause can stand alone as a complete sentence with a subject and predicate. A dependent clause cannot stand alone and depends on an independent clause to form a complete thought.", category="Writing", difficulty="intermediate" ) # Mathematics exam.add_question( "What is the order of operations in mathematics?", "The order of operations is: Parentheses, Exponents, Multiplication and Division (left to right), Addition and Subtraction (left to right), often remembered by PEMDAS.", category="Mathematics", difficulty="beginner" ) return exam def get_certification_tests_for_domain(domain: str) -> List[CertificationTestBuilder]: """ Get all certification tests for a specific domain. Args: domain: Domain name (financial, medical, legal, education) Returns: List of certification tests """ tests = [] if domain.lower() == "financial": tests.append(FinancialCertificationTests.create_cfp_exam()) tests.append(FinancialCertificationTests.create_cfa_level_1_exam()) tests.append(FinancialCertificationTests.create_series_7_exam()) elif domain.lower() == "medical": tests.append(MedicalCertificationTests.create_usmle_step_1_sample()) elif domain.lower() == "legal": tests.append(LegalCertificationTests.create_bar_exam_sample()) elif domain.lower() == "education": tests.append(EducationCertificationTests.create_praxis_core_sample()) return tests def list_available_certification_tests() -> Dict[str, List[str]]: """ List all available certification tests by domain. Returns: Dict mapping domain to test names """ return { 'financial': [ 'CFP (Certified Financial Planner)', 'CFA Level I', 'Series 7' ], 'medical': [ 'USMLE Step 1 Sample' ], 'legal': [ 'Bar Exam Sample' ], 'education': [ 'Praxis Core Sample' ] }