Use MkDocs Material's admonitions for callouts, tips, and interactive elements.
1 2 3 4 5 6 7 8 91011
!!! note "Key Concept"
This is an important concept to understand.
!!! example "Try it yourself"
Here's an example to work through on your own.
!!! question "Check Your Understanding"
What would happen if you changed the value of x?
??? tip "Hint (click to reveal)"
Look at the relationship between x and y.
3. MicroSim Integration
MicroSims are small, interactive simulations that demonstrate concepts. Below is the standard structure for embedding a p5.js MicroSim:
<divclass="quiz-container"><divclass="quiz-question"><p>What is the primary advantage of using MicroSims in education?</p><formclass="quiz-options"><div><inputtype="radio"id="opt1"name="q1"value="a"><labelfor="opt1">They look visually appealing</label></div><div><inputtype="radio"id="opt2"name="q1"value="b"><labelfor="opt2">They allow experiential learning through interaction</label></div><div><inputtype="radio"id="opt3"name="q1"value="c"><labelfor="opt3">They're easy to create</label></div><div><inputtype="radio"id="opt4"name="q1"value="d"><labelfor="opt4">They load faster than videos</label></div></form><buttonclass="quiz-check">Check Answer</button><divclass="quiz-feedback"></div></div></div><script>document.querySelector('.quiz-check').addEventListener('click',function(){constselected=document.querySelector('input[name="q1"]:checked');constfeedback=document.querySelector('.quiz-feedback');if(selected){if(selected.value==='b'){feedback.innerHTML='Correct! MicroSims enable learning through hands-on interaction.';feedback.style.color='green';}else{feedback.innerHTML='Not quite. Try thinking about how students learn best.';feedback.style.color='red';}}else{feedback.innerHTML='Please select an answer.';feedback.style.color='orange';}});</script>
5. Glossary Structure
A well-structured glossary helps students quickly reference key terms.
1234567
# Glossary#### Concept A
A detailed explanation of Concept A with examples and related concepts.
#### Concept B
A detailed explanation of Concept B with examples and related concepts.
Best Practices for MicroSim Development
Start with Learning Objectives: Define what you want students to learn before creating the MicroSim.
Keep It Focused: Each MicroSim should focus on demonstrating a single concept or a closely related set of concepts.
Consistent Interface: Use consistent controls and UI elements across all MicroSims.
Responsive Design: Ensure MicroSims work on different screen sizes.
Progressive Enhancement: Start with basic functionality, then add more complex features.
Clear Instructions: Provide clear instructions on how to use the MicroSim.
Meaningful Controls: Each control should have a clear purpose related to the concept being taught.
Visual Feedback: Provide visual feedback when parameters are changed.
Performance Optimization: Optimize for performance to ensure smooth operation.
Accessibility: Make MicroSims accessible to users with disabilities.
letsimulation;functionsetup(){// Create canvas and add it to the microsim-canvas elementconstcanvas=createCanvas(600,400);canvas.parent('microsim-canvas');// Initialize the simulationsimulation=newSimulation();// Set up UI controlssetupControls();// Start in paused statenoLoop();}functiondraw(){background(240);simulation.update();simulation.display();}// Simulation class to encapsulate logicclassSimulation{constructor(){this.parameters={speed:5,// Add other parameters here};this.isRunning=false;// Initialize simulation elementsthis.elements=[];}update(){if(this.isRunning){// Update simulation state based on parameters}}display(){// Display simulation elements}reset(){// Reset simulation to initial state}setParameter(name,value){this.parameters[name]=value;}start(){this.isRunning=true;}pause(){this.isRunning=false;}}// Set up event listeners for controlsfunctionsetupControls(){// Start buttondocument.getElementById('start-btn').addEventListener('click',function(){simulation.start();loop();});// Pause buttondocument.getElementById('pause-btn').addEventListener('click',function(){simulation.pause();noLoop();});// Reset buttondocument.getElementById('reset-btn').addEventListener('click',function(){simulation.reset();redraw();});// Speed sliderdocument.getElementById('speed-slider').addEventListener('input',function(){simulation.setParameter('speed',parseInt(this.value));});}
Metrics for Measuring Textbook Quality
Content Metrics:
Number of markdown files
Total word count
Number of images
Number of MicroSims
Glossary term count
Engagement Metrics:
Page views per section
Average time spent on each page
MicroSim interaction rate
Quiz completion rate
Quiz success rate
Learning Graph Metrics:
Coverage of concepts
Connectedness of concepts
Learning path completeness
Automating Metrics Collection
Create a Python script to analyze repository metrics (similar to your get-metrics-json.py):
#!/usr/bin/env python3importosimportrefrompathlibimportPathimportargparseimportjsondefcount_markdown_files(docs_dir):"""Count total number of markdown files in the docs directory."""returnlen(list(Path(docs_dir).glob('**/*.md')))defcount_images(docs_dir):"""Count total number of image files in the docs directory."""extensions=['*.png','*.jpg','*.jpeg','*.gif','*.svg']count=0forextinextensions:count+=len(list(Path(docs_dir).glob(f'**/{ext}')))returncountdefcount_words_in_markdown(docs_dir):"""Count total number of words in all markdown files."""total_words=0formd_fileinPath(docs_dir).glob('**/*.md'):withopen(md_file,'r',encoding='utf-8')asf:content=f.read()# Remove code blocks, inline code, URLs, HTMLcontent=re.sub(r'```.*?```','',content,flags=re.DOTALL)content=re.sub(r'`.*?`','',content)content=re.sub(r'http[s]?://\S+','',content)content=re.sub(r'<.*?>','',content,flags=re.DOTALL)# Split and count remaining wordswords=content.split()total_words+=len(words)returntotal_wordsdefcount_microsims(docs_dir):"""Count MicroSims by looking for sketch.js files in the sims directory."""sims_dir=Path(docs_dir)/'sims'ifnotsims_dir.exists():return0# Count directories in sims that contain sketch.jsmicrosim_count=0forsim_dirin[dfordinsims_dir.iterdir()ifd.is_dir()]:if(sim_dir/'sketch.js').exists()or(sim_dir/'index.js').exists():microsim_count+=1returnmicrosim_countdefcount_glossary_terms(docs_dir):"""Count level 4 headers in glossary.md."""glossary_path=Path(docs_dir)/'glossary.md'ifnotglossary_path.exists():return0withopen(glossary_path,'r',encoding='utf-8')asf:content=f.read()terms=re.findall(r'^####\s+.*$',content,re.MULTILINE)returnlen(terms)defanalyze_learning_graph(docs_dir):"""Analyze the learning graph complexity."""graph_path=Path(docs_dir)/'learning-graph.md'ifnotgraph_path.exists():return{"nodes":0,"edges":0}withopen(graph_path,'r',encoding='utf-8')asf:content=f.read()# Extract JavaScript node and edge definitionsnode_match=re.search(r'const\s+nodes\s*=\s*\[(.*?)\];',content,re.DOTALL)edge_match=re.search(r'const\s+edges\s*=\s*\[(.*?)\];',content,re.DOTALL)node_count=0edge_count=0ifnode_match:node_section=node_match.group(1)node_count=len(re.findall(r'\{\s*id:',node_section))ifedge_match:edge_section=edge_match.group(1)edge_count=len(re.findall(r'\{\s*from:',edge_section))return{"nodes":node_count,"edges":edge_count}defmain():parser=argparse.ArgumentParser(description='Calculate metrics for an intelligent textbook repository.')parser.add_argument('repo_root',help='Root directory of the repository')parser.add_argument('--output','-o',help='Output JSON file path')args=parser.parse_args()docs_dir=os.path.join(args.repo_root,'docs')ifnotos.path.exists(docs_dir):print(f"Error: docs directory not found at {docs_dir}")return1# Calculate metricsmetrics={'markdown-file-count':count_markdown_files(docs_dir),'image-count':count_images(docs_dir),'word-count':count_words_in_markdown(docs_dir),'microsim-count':count_microsims(docs_dir),'glossary-term-count':count_glossary_terms(docs_dir),'learning-graph':analyze_learning_graph(docs_dir)}# Output resultsifargs.output:withopen(args.output,'w',encoding='utf-8')asf:json.dump(metrics,indent=2,fp=f)else:print(json.dumps(metrics,indent=2))if__name__=="__main__":main()
Conclusion
Creating intelligent textbooks with MkDocs Material and MicroSims requires a thoughtful approach to structure, content, and interactivity. By following these best practices, you can create engaging educational resources that adapt to students' needs and provide interactive learning experiences.
The key to success is maintaining a consistent structure, developing focused MicroSims that address specific learning objectives, and continually measuring the effectiveness of your content through metrics collection and analysis.