ziadsameh32's picture
final-version
17d0f30
from crewai import Agent, Task, Crew, Process, LLM
import os
import json
from modules import bloom_taxonomy_2, objectives_dimensions, llm_g
from schemas import LearningObjectivesOutput
def get_bloom_verb(level: str) -> str:
"""Returns verbs from the given Bloom's taxonomy level."""
if level not in bloom_taxonomy_2:
raise ValueError(f"Invalid Bloom level: {level}")
verbs_key = [k for k in bloom_taxonomy_2[level].keys() if "_verbs_examples" in k][0]
return bloom_taxonomy_2[level][verbs_key]
def get_verbs_by_domain_and_level(domain, level_name):
"""
استخراج الأفعال المناسبة من قاموس الأبعاد التعليمية
Args:
domain: "Knowledge", "Ability", or "Skills"
level_name: اسم المستوى مثل "Remember", "Response", "Practice"
Returns:
قائمة بالأفعال المتاحة
"""
if domain not in objectives_dimensions:
return []
for level in objectives_dimensions[domain]["levels"]:
if level_name.lower() in level["level_name"].lower():
return level["verbs_examples"]
return []
objectives_generator = Agent(
role="Expert Learning Objectives Designer (Instructional Design Specialist)",
goal=(
"Design a comprehensive list of clear, measurable, and achievable learning objectives in Arabic "
"for each subtopic in the training curriculum. Your objectives must be based on {topic} and the "
"content provided in {outlines}. "
"You must carefully read and analyze every subtopic title, its purpose, and the unit description "
"before writing any objective. "
"Each objective must align with Bloom’s Taxonomy and the three learning domains "
"(cognitive, affective, psychomotor), accurately reflect the intended learning outcome, "
"and meet all 12 professional instructional design standards. "
"**Critical:** You must maximize verb diversity across all objectives — avoid repeating the same "
"verb whenever possible."
),
backstory=(
"You are an expert instructional designer with deep experience in creating professional training programs. "
"You analyze each unit and subtopic to determine the type of knowledge, skill, or attitude learners "
"should achieve. "
"Then, you write one short, measurable, learner-centered objective for each subtopic following Bloom’s "
"Taxonomy sequence (Remember → Understand → Apply → Analyze → Evaluate → Create). "
"**You are exceptionally skilled at selecting diverse and non-repetitive verbs from Bloom’s Taxonomy "
"and the three learning domains.** "
"You maintain a mental tracker of all verbs used and actively avoid repetition across the entire curriculum. "
"You ensure maximum verb diversity, linguistic precision, and that every objective is "
"clear, measurable, realistic, achievable, and free from ambiguity or linguistic complexity. "
"Your objectives must reflect the parameters of {domain}, {content_type}, {audience}, and {material_type}, "
"while covering the cognitive, psychomotor, and affective domains."
),
llm=llm_g,
verbose=True,
max_iter=100,
)
objectives_task = Task(
description=(
"You have a complete and well-structured training curriculum provided in {outlines}. "
"Your task is to create one detailed, measurable learning objective in Arabic for each subtopic, "
"aligned with Bloom’s Taxonomy and the three learning domains, and consistent with the purpose of each subtopic.\n\n"
"### Step-by-Step Process\n"
"1. Read the curriculum overview to understand the full learning journey.\n"
"2. **Before you begin, review the complete list of Bloom’s action verbs and the three domains for each level to plan maximum diversity.**\n"
"3. **Create a mental or written record of verbs as you use them to avoid repetition.**\n"
"4. For each unit:\n"
" a. Analyze the unit description to understand the learning scope and intended outcomes.\n"
" b. For each subtopic within that unit:\n"
" - Carefully read the subtopic title and its purpose.\n"
" - Identify the main learning outcome (Knowledge, Skill, or Attitude/Behavior).\n"
" - **First, determine the appropriate domain: Cognitive (Knowledge), Affective (Attitude), or Psychomotor (Skills).**\n"
" - Choose the most suitable Bloom’s level or the appropriate level of that domain.\n"
" - **From the available verbs at that level, select one that has not been used before (or only minimally used).**\n"
" - Choose three relevant Bloom’s verbs that suit the abilities of {audience}.\n"
" - Write one measurable learning objective in Arabic that accurately reflects the subtopic’s purpose.\n"
" - **Track the chosen verb to prevent reusing it in later objectives.**\n\n"
"### Requirements for the Three Learning Domains\n"
"**Objectives must cover the three domains in a balanced way:**\n\n"
f"**1. Cognitive Domain (Knowledge):**\n"
f"{objectives_dimensions['Knowledge']['description']}\n"
"**Levels:**\n"
+ "\n".join(
[
f" - {level['level_name']}: {level['description']}\n Verbs: {', '.join(level['verbs_examples'])}"
for level in objectives_dimensions["Knowledge"]["levels"]
]
)
+ "\n\n"
f"**2. Affective Domain (Attitude/Ability):**\n"
f"{objectives_dimensions['Ability']['description']}\n"
"**Levels:**\n"
+ "\n".join(
[
f" - {level['level_name']}: {level['description']}\n Verbs: {', '.join(level['verbs_examples'])}"
for level in objectives_dimensions["Ability"]["levels"]
]
)
+ "\n\n"
f"**3. Psychomotor Domain (Skills):**\n"
f"{objectives_dimensions['Skills']['description']}\n"
"**Levels:**\n"
+ "\n".join(
[
f" - {level['level_name']}: {level['description']}\n Verbs: {', '.join(level['verbs_examples'])}"
for level in objectives_dimensions["Skills"]["levels"]
]
)
+ "\n\n"
"### Critical Requirement: Verb Diversity \n"
"**This is a top-priority rule that must be followed precisely:**\n\n"
"**Verb Non-Repetition Rules:**\n"
"1. **Maximize verb diversity** — each objective should ideally use a different verb than all previous ones.\n"
"2. **Before selecting a verb, check:** Have I used this verb before? If yes, choose another.\n"
"3. **Repeat a verb only when:**\n"
" - All suitable alternative verbs in that Bloom level or domain are exhausted.\n"
" - The subtopic’s content explicitly requires that verb for accuracy.\n"
" - You can justify why no other verb fits.\n"
"4. **Prioritize diversity over perfect synonyms** — it’s better to use a slightly different but valid verb than to repeat.\n"
"5. **Use the full range of verbs from Bloom and the three domains** — avoid overusing common ones like 'define' or 'explain'.\n"
"6. **Track verb usage:** after writing each objective, note the verb and consciously avoid it in the next.\n"
"7. **If repetition is necessary:**\n"
" - Space it out by at least 3–5 objectives.\n"
" - Add a justification note in your internal reasoning.\n"
" - Try using it in a different context or content area.\n\n"
"### The 12 Mandatory Design Standards — Each Objective Must Meet All\n"
"**Based on the detailed objectives reference document:**\n\n"
"1. **Linked to the general goal:**\n"
" - Every objective must connect to the course’s overall goal.\n"
" - Example: If the general goal is 'Understand the concept of e-learning', "
"the specific objective could be 'The trainee accurately defines e-learning.'\n\n"
"2. **Measurable:**\n"
" - Objectives must be assessable using measurable performance indicators or outcomes.\n"
" - Correct: 'The trainee compares synchronous and asynchronous learning accurately.'\n"
" - Incorrect: 'The trainee understands e-learning.' (Not measurable)\n\n"
"3. **Achievable:**\n"
" - Realistic, suitable for learner ability and course duration.\n"
" - Correct: 'The trainee applies the steps to create a learning management account.'\n"
" - Incorrect: 'The trainee develops a full e-learning system in one hour.' (Unrealistic)\n\n"
"4. **Covers all three domains (Cognitive, Psychomotor, Affective):**\n"
" - Cognitive: 'The trainee defines e-learning accurately.'\n"
" - Psychomotor: 'The trainee practices using LMS assessment tools.'\n"
" - Affective: 'The trainee demonstrates interest in participating in e-learning activities.'\n\n"
"5. **Aligned with Bloom’s hierarchy:**\n"
" - Objectives must progress logically from lower to higher levels (Remember → Create).\n\n"
"6. **Clarity and precision:** Objective must be completely clear and specific.\n\n"
"7. **Free from ambiguity:** No vague or overly complex phrasing.\n\n"
"8. **Vocabulary clarity:** All terms must be understandable to {audience}.\n\n"
"9. **Single, focused goal:** Each objective expresses only one learning outcome.\n"
" - Correct: 'The trainee identifies the components of a virtual classroom.'\n"
" - Incorrect: 'The trainee identifies and applies virtual classroom components.'\n\n"
"10. **Realistic and feasible:** Achievable within program time and resources.\n\n"
"11. **Consistent with program outcomes:** Must align with the general and specific learning outcomes.\n\n"
"12. **Content-linked:** Directly related to the unit or module content.\n\n"
"### Objective Writing Rules\n"
"- One objective per subtopic — no more, no less.\n"
"- Each must directly and precisely reflect the subtopic’s purpose.\n"
"- Follow Bloom’s sequence within each unit (from lower to higher order thinking).\n"
"- If a level doesn’t logically fit, skip it but maintain general progression.\n"
"- You may combine two levels (e.g., Understand + Apply) if justified by subtopic purpose.\n"
"- Start each objective with '[verb in present]' and keep length between 6–10 words.\n"
"- Use verbs suitable for {audience} — e.g., children cannot 'evaluate' or 'analyze' like professionals.\n"
"- **Core rule: Avoid verb repetition — use the widest possible range from all three domains.**\n"
"- Ensure objectives are **measurable** and **achievable**.\n"
"- Maintain linguistic clarity — no vague or double meanings.\n"
"- Each objective must express only one precise learning outcome.\n\n"
"### Strategies for Verb Diversity\n"
"**Use these strategies to ensure maximum variety:**\n\n"
"- **Alternate synonyms:**\n"
" - Instead of always 'define', use: name, list, mention, identify, classify, select.\n"
"- **Use less common verbs:**\n"
" - Distinguish, infer, demonstrate, interpret, justify, summarize, illustrate.\n"
"- **Match verbs to content type:**\n"
" - Use verbs that capture the learning result precisely.\n"
"- **Consult the full domain verb lists** (above) with 5–7 verbs per level.\n"
"- **Distribute objectives across the three domains** — avoid focusing only on the cognitive domain.\n\n"
"### Examples of Correct and Incorrect Objectives\n\n"
"**Correct Examples (Good verb diversity and domain balance):**\n"
"1. (Cognitive - Remember): The trainee lists five types of e-learning platforms.\n"
"2. (Cognitive - Understand): The trainee distinguishes between various digital assessment tools.\n"
"3. (Cognitive - Apply): The trainee applies active learning strategies in the classroom.\n"
"4. (Cognitive - Understand): The trainee infers the main benefits of blended learning.\n"
"5. (Psychomotor - Practice): The trainee practices designing an interactive learning activity.\n"
"6. (Affective - Respond): The trainee actively participates in collaborative learning discussions.\n"
"7. (Cognitive - Analyze): The trainee compares different instructional design models.\n"
"8. (Psychomotor - Adapt): The trainee adjusts learning activities to meet learner needs.\n\n"
"**Incorrect Examples (Verb repetition — avoid this):**\n"
"1. The trainee defines the types of e-learning platforms.\n"
"2. The trainee defines digital assessment tools.\n"
"3. The trainee defines active learning strategies.\n"
"4. The trainee defines blended learning benefits.\n"
"5. The trainee defines steps of activity design.\n\n"
"**Unclear or Unmeasurable Objectives:**\n"
"- 'The trainee understands e-learning.' (Vague, not measurable)\n"
"- 'The trainee learns how to use tools.' (Unclear — which tools?)\n"
"- 'The trainee becomes an expert in instructional design.' (Unrealistic, not measurable)\n\n"
"**Improved Versions:**\n"
"- 'The trainee accurately defines e-learning.'\n"
"- 'The trainee effectively uses LMS tools.'\n"
"- 'The trainee applies instructional design principles to create a learning unit.'\n\n"
"### Critical Quality Checklist — Verify Before Finalizing Each Objective:\n"
"1. ✓ Is it clear and accurately expresses the intended outcome?\n"
"2. ✓ Does it align with a Bloom’s level or learning domain?\n"
"3. ✓ Is it free from ambiguity?\n"
"4. ✓ Is all vocabulary appropriate for {audience}?\n"
"5. ✓ Does it express only one learning outcome?\n"
"6. ✓ Is it measurable through observable performance?\n"
"7. ✓ Is it realistic and achievable?\n"
"8. ✓ Does it align with the overall outcomes?\n"
"9. ✓ Is it directly linked to the subtopic content?\n"
"10. ✓ Is it sequenced logically (simple → complex)?\n"
"11. ✓ Is it suitable for the learners’ level?\n"
"12. ✓ Do all objectives collectively cover knowledge, skills, and attitudes?\n"
"**13. Verb Check: Have you reused this verb? If yes, can you replace it?**\n"
"**14. Domain Check: Are the objectives balanced across all three domains?**\n\n"
"### Self-Reflection Requirement\n"
"After generating all objectives for a unit, pause and evaluate:\n"
"- Do objectives progress logically through Bloom’s levels?\n"
"- **How many unique verbs did you use? Any repetition?**\n"
"- **Can any repeated verbs be replaced with alternatives?**\n"
"- Are verbs diverse and contextually appropriate?\n"
"- **Do objectives cover all three domains evenly?**\n"
"- Can an external evaluator assess each objective clearly?\n"
"- Are all objectives realistic for {audience} and course duration?\n\n"
"### Final Verification: Verb Diversity & Domain Balance\n"
"**Before submitting your final output:**\n"
"1. Count how many times each verb appears.\n"
"2. If any verb appears more than 2–3 times, review and replace it where possible.\n"
"3. Aim for at least 70–80% unique verbs across the entire curriculum.\n"
"4. Keep a mental record of verb use for ongoing awareness.\n"
"5. **Check balanced distribution:**\n"
" - Cognitive (Knowledge): 50–60% of objectives\n"
" - Affective (Attitude): 20–30% of objectives\n"
" - Psychomotor (Skills): 20–30% of objectives\n"
"6. If imbalance occurs, revisit and adjust classifications.\n\n"
"### Domain-Specific Guidelines\n\n"
"**When writing Cognitive (Knowledge) objectives:**\n"
"- Use for topics focused on information, understanding, applying, analyzing, evaluating, or creating.\n"
"- Examples: 'The trainee defines...', 'The trainee compares...', 'The trainee designs...'.\n\n"
"**When writing Affective (Attitude) objectives:**\n"
"- Use for topics involving values, emotions, interests, or behaviors.\n"
"- Examples: 'The trainee demonstrates interest in...', 'The trainee participates actively...', 'The trainee commits to...'.\n\n"
"**When writing Psychomotor (Skills) objectives:**\n"
"- Use for topics requiring physical, technical, or procedural performance.\n"
"- Examples: 'The trainee practices...', 'The trainee performs...', 'The trainee innovates...'.\n\n"
"### Final Important Notes\n"
"- **Top Priority:** Verb diversity and balanced domain distribution.\n"
"- **Quality over quantity:** One well-crafted, diverse objective is better than several repetitive ones.\n"
"- **Flexibility with precision:** Be flexible in verb choice but never compromise on accuracy.\n"
"- **Continuous review:** Revisit objectives regularly for diversity and balance.\n"
"- **Context matters:** Always choose the verb that best reflects what the learner should achieve in that specific subtopic.\n"
"### OUTPUT\n"
"Return the LearningObjectivesOutput structure in valid JSON format.\n\n"
),
expected_output="""JSON object with this structure:
{
"objectives": [
{
"unit": "Unit title",
"unit_description": "Brief summary of the unit scope",
"subtopic": "subtopic title",
"module_description": "Brief summary of what this subtopic covers",
"level": "Bloom's level assigned based on subtopic analysis",
"verbs": ["verb1", "verb2", "verb3"],
"objective": "One measurable Arabic objective"
}
]
}""",
output_json=LearningObjectivesOutput,
agent=objectives_generator,
human_input=False,
)