NOTE: To create zyLabs, your zyBook must have zyLabs enabled. If you'd like to enable (or are unsure if zyLabs is already enabled), contact your Account Executive.
NOTE: This article is primarily for zyLabs for C, C++, Java, and Python. zyLabs for Web Programming may have some differences. zyLabs for MATLAB uses a tool provided by Mathworks and may have larger differences. Please refer to Mathwork's resources for creating coding problems.
Getting started
To create a new zyLab, expand the chapter where you want the new zyLab and scroll to the bottom of the section list. (Note: Expanding a chapter can be done in the table of contents on the zyBook homepage or in the content's sidebar.)
Click "Add a zyLab". You'll be asked to create a new zyLab from scratch or to copy an existing zyLab.
This tutorial will create a new zyLab.
Clicking "Create zyLab" takes you to the zyLab editor page for the new zyLab.
You will first be asked to provide a title and a set of instructions for your students. You can use Markdown to format your instructions. Markdown resources are made available to you if you are not familiar with Markdown. Markdown can be used to make text bold, create bulleted lists, add links, and more.
Lab specifications
Start by adding a title and a set of instructions that let students know how to complete the lab.
Instructions can be written using a language called Markdown. A Markdown cheatsheet is provided in the lower-left corner just under the instructions text field.
We do allow light use of HTML in the instructions as well, however, the following tags are not permitted:
- applet
- button
- canvas
- datalist
- embed
- form
- frame
- input
- noframes
- noscript
- optgroup
- option
- script
- select
- style
- attributes beginning with on (such as onblur, oninput, and onmouseover)
- style
Also, markdown code blocks do not support code colorizing. If you are using the ``` code block, do not specify a language.
Unedited labs that were created before August 2021 will continue to support those tags. Any changes made to existing labs or any new labs created after the restriction was introduced will no longer allow forbidden tags to be saved.
LaTeX in Markdown
For math equations, you can use LaTeX in the lab specs. However, please note that the editor uses Markdown, so you may need to escape the Markdown characters in order for the LaTeX to render properly.
Please see our guide on using LaTeX for more details.
Options
On the options card, you can select items to customize your zyLab, such as:
- Select whether students work in our in-book development environment, or in their own IDE and then upload their files.
- Select various compilation flags.
- Enforce a submission limit or submission rate.
- Provide a password to prevent students from viewing the zyLab until you've given the password.
- Hide the lab. Students will see a message that the lab is hidden. Instructors commonly unhide labs at a given time, like at the week's start. (You'll also want to keep the lab hidden while you develop the lab.)
Student files
On the Student files card, you can provide a template for students to get started. You can select our "Use default template" button to generate boilerplate code for the language your zyLab is set to. You can also expand upon this template to include function stubs or any other code you might want the student to have available to them when they begin the zyLab.
You can also create a solution. We highly recommend creating a solution so you can test the zyLab before sharing it with your students. Note that students will not see your solution unless you select that option on the Options card above.
You can click "Add another" file to provide additional files for your students. These files can also be provided with templates and solutions. If needed, you can set an additional file to "Read only" so that students can access functions in the other files without modifying them.
Additional files
On this card, you can upload additional files that students can use for File I/O. (Note: Students can access these files from their programs, but they cannot actually view the files.)
Test bench
Test benches are the true heart and power of zyLabs. You can create two kinds of tests: "Compare output" tests and "Unit" tests. If you are new to zyLabs, we recommend starting with the "Compare output" tests.
Compare output
Start by providing inputs to pass to the student's program. Ex: If the student's program should read two numbers and output the sum, your "input" would be two values to be read. Then, type the output for that input.
If you are confident of your solution and have extensive formatted output, you may wish to use the "Generate output from solution" button to generate the output automatically from your solution. We recommend typing the test case output manually when possible to ensure your solution works correctly.
Unit tests
Unit tests allow you to call a student's code to make sure the function is behaving as expected. Ex: If, for the assignment, students must write a function called "addTwoNumbers(num1, num2)" that returns the sum of the two numbers, you can call their function with appropriate arguments in a Unit test. Then, you can compare the returned value to the value you expect using if/else statements.
Unit tests can return any number of points between [0, points assigned to unit test], even fractional values or a bool.
Returning a Boolean True will award all points - returning False will return 0 points.
Otherwise, integers, doubles, floats, etc. will all be treated as the number of points that should be awarded. Be sure to set the return type of testPassed to either int, double, or float.
Every time we test a student's solution, we compile and run each unit test. Calling a student's function or functions in a single unit case and assigning points can speed up the run time of longer labs as it reduces the number of times the lab compiles.
*Note that C currently only supports returning a bool and cannot give partial credit.
As you write your test cases, we recommend clicking the "Run tests" button found in the lower right-hand corner of the screen. This will help verify that your test cases are able to pass the solution you provided. If the tests fail, you might need to make tweaks to either the test cases or the solution itself.
If you want to give some test cases more weight than others, you can assign a point value to your test cases. You can see in my example above that I left the compare output test at 1 point, but I changed the unit test to be worth 5 points.
Finishing up
Once you have written your instructions, test cases, and optional solution files, you can click "Save and exit" in the lower left hand corner. Your new zyLab will appear at the bottom of the chapter where you initially clicked "Add a zyLab". You can use "Configure" mode to move the zyLab as needed.
Hiding a lab / Toggling a lab's visibility
Instructors commonly hide a lab's contents from students, releasing a lab on a particular date for students to start working. Hiding is also done while a lab is being developed. Hiding/unhiding can be done when in the lab's Edit mode:
For convenience, hiding/unhiding can also be done at the top of the lab, without entering the lab's Edit mode. Just click on the toggle switch next to "Visible to students" to toggle between visible and not visible:
"Deleting" a lab is done by entering a zyBook's configure mode, selecting the lab, and moving it to "Unused". The lab can be "recovered" by entering Configure mode again, selecting the lab in Unused, and moving it to a regular chapter. It is not expected that instructors will move items to Unused and then back to regular chapters on a regular basis; Unused is like a trash can. Because the size of this trash can is quite limited, we do not currently provide a means for instructors to permanently remove an item from Unused; in this way, any deleted item can in the future be restored if necessary.
Advanced grading options
Compare output test has a few additional advanced options for zyLabs power users.
To view the options click "Show advanced options" at the bottom of the test case.
These additional options include
- Reading output from a file instead of standard out
- Adding additional command-line arguments
- Ignoring whitespace and casing in the student's output
- Hiding input and output values from students