Instructor guide to creating coding exercises
Add short, targeted coding practice to your Udemy course with coding exercises.
Learners want approachable ways to practice, assess, and apply what they’ve learned. By adding coding exercises to your course, you can provide these active learning experiences in a convenient way.
Coding Exercise FAQs
What is a coding exercise?
📖 A coding exercise is an exercise for learners to practice a particular coding language or framework. Learners are able to check their understanding of a concept covered in your course through automated grading.
When should I add a coding exercise to my course?
Coding exercises should be provided for all important coding-related topics and skills in your course. Key moments to add these practice activities would be:
- when a course lecture has at least one learning objective related to writing code
- when a concept taught in a lecture can be assessed through a coding exercise
How many coding exercises should I add to my course?
There is no limit to how many coding exercises you can add to one course, but it is advised to intersperse coding exercises throughout your course for distributed practice. Here are some ideas on how to structure your coding exercises within your course:
- Include at least one coding exercise per section.
- Provide multiple exercises on the same learning objective. However, refrain from stacking coding exercises unless you’re providing multiple exercises for the same learning objective.
- Start some sections with an exercise where a learner tries, lead them to a lecture that explains, then provide another coding exercise in a new context to try again. This motivates learners to find out why they need to learn what is in the lectures in that section.
Can I make money off of the coding exercises I create?
If your course is part of a Udemy subscription plan, the time your learners spend on coding exercises gets added to your engagement revenue.
What coding exercises languages are available?
How to create a coding exercise
Get started creating (or updating) your own coding exercises with these steps: Plan the objective and outcome, create the solution, frame the exercise, and add hints and test cases to help your learners.
Plan your coding exercise
Begin creating your coding exercise by defining its learning objective. Start by answering the following questions:
- What should the learner be able to do if they complete this coding exercise correctly?
- What skill(s) does this exercise help a learner practice? What skill(s) does it assess?
From there, come up with a coding exercise problem that aligns the desired learning outcomes from above. This problem should be a short chunk of a true authentic task that an engineer/technical employee would do.
💡 Tip! Keep your coding exercises bite-sized.
- The ideal coding exercise should take an average learner a maximum of 15 minutes to complete. This is the known time frame for microlearning and ensures that this exercise is time accessible.
Start with the solution
Backwards planning is recommended when designing your coding exercise. Therefore, once you’ve decided on a coding exercise problem, author the desired solution in full, which includes the evaluation and solution file.
📖 A solution file is the file that serves as the solution of the provided problem definition. Learners are expected to write a similar solution (not necessarily the same) file for the given problem definition. It verifies the provided evaluation file (unit test) is correct.
📖 An evaluation file is the unit test file that checks whether the learner’s solution is actually solves the problem or not. Assertion statements need to be used to verify the solution.
In order to create a new coding exercise, it is required for you to provide solution and evaluation files that can be verified by the system. As a reminder, the solution file is written to verify the evaluation file itself and evaluation file is written to verify learner’s solution is correct or not.
Frame the exercise
After creating the solution, the next step is to clearly communicate the purpose and problem of this exercise to your learners. We recommend the following steps:
- Describe what the learner should be able to do if they complete this coding exercise correctly and the skills it helps them practice. You should have defined these answers in the planning stage.
- Provide complete and understandable directions on the ‘problem statement’ of the exercise. Make sure that you are providing enough information for your learners to attempt the exercise while still ensuring they are accountable for practicing the skill (or demonstrating their ability to do the work).
- Author the starter file.
📖 A starter file is the code that is needed at the beginning to frame the exercise to keep the learner focused on the targeted skill.
💡 Tip! Establish a clear and consistent naming practice for your coding exercises.
- Use a consistent and easy-to-find naming convention for all of your coding exercises. For example, all coding exercises start with “Coding Exercise” in the name so learners can easily locate them throughout your course.
📝 Note: Like with all communications to your learners, ensure your instructions contain accurate, grammatically correct, and unbiased language.
Enhance with guidance
📖 A unit test is a way of testing a unit – the smallest piece of code that can be logically isolated in a system. In most programming languages, that is a function, a subroutine, a method or property.
You should provide unit tests for solutions to coding exercises so that your learners can receive feedback when they click on “Check solution.” This feedback helps learners identify their mistakes and provides important validation when they succeed.
When creating test cases, we recommend the following best practices:
- Get specific. A unit test should contain only one logical assertion, meaning it checks only one output of the tested code.
- Be comprehensive. Unit tests should mock out all external services and state, meaning all of the required behavior is tested. Unit tests catch corner cases and have good test coverage.
- Clarity is key. Naming of each test should be meaningful, so when learners see the test list, they can easily navigate between them.
Add a recommended lecture in your course that links learners to where they can get more information about the skill they’re practicing.
📖 A hint is a helpful tip to guide learners toward the correct answer when they get stuck in an exercise.
While test case titles already serve as guidance, the “Hints” section should focus more on additional pieces of information that aren’t provided in the instructions or unit tests.
When creating hints, we recommend the following best practices:
- A hint should jog the learner’s memory of a concept.
- A hint should give them part of the answer, but not the whole answer.
- When providing multiple hints, it should be done in a scaffolded order (i.e. smaller hint to more substantial hint) to encourage learners to attempt on their own.
📝 Note: Since hints currently can be shown to learners at all times as they attempt to complete the exercise, only use the “Hints” space to provide extra info that may help the learner complete the exercise without giving away the correct answer to the exercise.
📖 A solution explanation is further clarification of the correct solution to a coding exercise.
A solution explanation can be useful for learners to validate and/or understand issues with their approach. If a learner attempts your coding exercise and isn’t sure why the solution solves the problem correctly, this is the space to explain. Additionally, for those who got the exercise correct but aren’t sure why, this helps them validate what they did to they solidify their understanding of this concept for future applications.
When creating a solution explanation, we recommend the following best practices:
- This section can include step by step instructions with code snippets.
- Always include the “why” behind the steps. This will help the learner reflect on what they did and what they would need to differently if they try again.
To learn more about the improvements we’ve made to coding exercises, check out this Teaching Center article. Additionally, if you have more questions about how to use the coding exercises tool, check out this Help Center article.