Computer Science Principles
Course Progress
0/0
Objectives in LxD
3.4 Strings
3.4 Strings
3.3 Mathematical Expressions
3.3 Math Expressions
3.2 Data Abstractions
3.2 Data Abstractions
3.1 Variables & Assignments
3.1 Variables and Assignments
3.1 Variables and Assignments (Sample)
Intro to Python
Intro to Javascript
Variables and HTML DOM (Sample)
3.5 Boolean Expressions (PY)
3.5 Boolean Expressions (JS)
3.8 Iterations
3.7 Nested Conditionals
3.6 Conditionals
3.8 Iterations
3.7 Nested Conditionals
3.6 Conditionals
3.13 Developing Procedures
3.12 Calling Procedures
3.10 Lists
3.13 Developing Procedures
3.10 Lists
3.9 Developing Algorithms
3.17 Algorithmic Efficiency
3.9 Algorithms
3.17 Algorithmic Efficiency
3.15 Random Numbers (pseudocode)
3.15 Random Numbers (js)
3.15 Random Numbers (py)
BI 3 Review
Sprint View
Week 17
Code Runner - Examples
Code Runner - Examples
2 min read
Python Lesson: Fix the Syntax Error
Challenge
Fix the syntax error. Run the code to get a hint!
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...
Python Lesson: Complete the Function
Challenge
Complete the function to calculate the area of a rectangle. Replace the ??? with the correct calculation.
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...
Java Lesson: Fix the Compilation Error
Challenge
The code has a compilation error. Fix it!
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...
JavaScript Lesson: Complete the Loop
Challenge
Complete the for loop to print numbers 1 through 5. Fill in the missing parts of the loop.
Lines: 1
Characters: 0
Output
Click "Run" in code control panel to see output ...
Code Runner Reference
Code runner requires defining and passing liquid variables for challenge and code to the include file code-runner.html. Study the source of this markdown file to see how the liquid variables are defined for each example above.
Parameters
- runner_id (required): Unique ID for each runner on the page (e.g., “exercise1”, “exercise2”)
- language (optional): “python”, “java”, or “javascript” (defaults to “python”)
- challenge: Variable containing the challenge/instruction text
- code: Variable containing the starter code
- height (optional): Editor height (defaults to “300px”)
Code Runner Architecture
HTML Component
- File:
_includes/code-runner.html - Reusable component with parameters for customization
- Uses CodeMirror for syntax highlighting
SCSS Styling
- Main file:
_sass/open-coding/forms/code-runner.scss - Uses mixins for consistent styling across lessons:
@mixin control-panel- Top/bottom toolbars with buttons@mixin sub-container- Groups editor/output sections@mixin info-panel- Challenge box styling@mixin output-panel- Code output display@mixin icon-button- Consistent button styling@mixin select-control- Dropdown menus
Color Variables
- File:
_sass/open-coding/user-preferences.scss -
Uses colors that correspond to user preferences
--pref-bg-color- Background color--pref-text-color- Text color--pref-accent-color- Accent/emphasis color--ui-border- Border color--panel- Panel background