Learning

Learning

Programming Exercises

A programming exercise gives learners a coding problem and a code editor in the browser. When they run their code, it is checked against test cases you set up, so they see right away which cases pass.

Exercises can be written in Python or JavaScript. The code runs on a code runner service called Falcon. By default Learning uses https://falcon.frappe.io. You can point it to your own Falcon server under Settings > Services > Livecode URL. See the Falcon Self-Hosting Guide.


The exercise list

Click Programming Exercises in the sidebar. The list shows each exercise with its Language and when it was last updated. Use Search to find one by title.

At the top right you will find Submissions and New Programming Exercise. To delete exercises, select them and click Delete.

Exercise list


Create an exercise

  1. Go to Programming Exercises and click New Programming Exercise.
  2. On the right, enter a Title and choose the Language.
  3. Write the Problem Statement. Explain what the code should do and what input it receives.
  4. Optionally add Starter Code. This is what learners see in their editor when they first open the exercise. If you leave it empty, they start with a few lines that read the test case input for them.
  5. Add Test Cases. Each row has an Input, an Expected Output and a Hidden checkbox.

The exercise is saved for the first time once it has a title, a problem statement and at least one test case with an expected output. After that the page saves on its own, and the badge at the top shows Saved or Not saved. A test case row without an expected output is not saved.

Exercise form

How test cases work

  • For each test case, the learner's program gets the Input and its printed output is compared with the Expected Output. Spaces and blank lines at the start and end are ignored; everything else must match exactly.
  • A test case marked Hidden still counts, but learners don't see its input or expected output. They only see it in the total, for example "2 of 3 passed". Use hidden cases so learners can't write code that only fits the examples they can see.
  • A run passes only when every test case passes.

Preview the exercise

Click Preview at the top of the exercise page to try it the way learners will. Nothing you run in the preview is saved. Click Back to editing to return.


Add the exercise to a lesson

In the lesson editor, add a Programming Exercise block and pick the exercise. See Interactive Content.


What learners see

In the lesson, the exercise opens as a workspace:

  • On the left, the Problem tab shows the problem statement and the Test cases tab shows the results of the last run.
  • On the right is the code editor, with a Console below it that shows the output of each run.
  • Run code runs the code against every test case. Learners can also press Ctrl+Enter (Cmd+Enter on a Mac).
  • Reset puts the starter code back in the editor and clears the results.

After a run, the Test cases tab shows "X of Y passed" and, for each visible case, the input, the expected output and whether it passed. If a case failed, the learner's output is shown too.

The code in the editor is kept in the learner's browser as they type, so it is still there if they leave and come back.


Review submissions

Go to Programming Exercises and click Submissions, or open an exercise and click Submissions. The list shows the Member, Exercise, Status (Passed or Failed) and when it was last changed. Filter it by exercise, member or status.

Click a submission to see the code that was run and its test results.

A submission is Passed when every test case passed, and Failed otherwise.

Last updated 5 days ago
Was this helpful?
Thanks!