Spaces:
Runtime error
Runtime error
File size: 19,983 Bytes
ec8f374 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
"""
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'
]
}
|