Advanced Labs have a number of ways they can be configured from the files in the workspace to the language setup or the UI of the IDE and the formatting of the code.
Usercode Directory
/usercode is the project directory in advanced labs. It contains all files and folders in the workspace that are viewable from the “Files” panel. You can include any files necessary for compiling and running a project.
Anything added by instructors or learners will appear there, unless it is marked as hidden. In the example below, you can also see a file marked as read-only, which can be done when creating/editing your template.
Any edits an instructor makes to the template's usercode will populate in the student's workspace when they first load it. Any changes made to the template after the student has loaded a workspace will require the learner to reset the lab via the settings in the bottom left.
Usercode is also the current, working directory on the virtual machine. ls /usercode will display the files in /usercode as they exist on the machine.
Alternatively, you can navigate to /usercode from the desktop by clicking run. Then, if the language supports it, click the Desktop tab along the bottom left to open the desktop view.
Click “File Manager”, then you can navigate to /usercode to see everything in that directory as it appears on the virtual desktop.
Edits to the files in /usercode do not require a running virtual machine.
Userdata Directory
The /userdata directory is where you can find environment specific files like the settings for VSC or the database for mySQL.
While most files will work from /usercode, you can also place large files in /userdata/zylabfiles. In this Java 17 VSC example you can see how we place large JAR files in /userdata.
Click Open Desktop to view /userdata:
The view here is small, and there are several options to enlarge the desktop view, like the fullscreen button in the top right.
After opening the file manager, you can see several folders:
The JAR is located in the /userdata/zyscripts folder.
To learn more about persisting package installs with /userdata, see this article.
Any edits an instructor makes to the template's /userdata, like adding extensions in VSC or creating a database in MySQL, will populate in the student's workspace when they first load it. Any changes made after that will require the learner to reset the lab.
/userdata is not automatically copied into the autograding environment. If you have a test case that relies on /userdata, you must select the option to “include workspace data” in the Files options.
One exception, are the MySQL environments where this check is toggled on by default and set to "student's workspace".
You may want to create tests to run against your default database, as well as the student's. In those cases, make sure to click the appropriate toggle for each test that needs the template, and each that needs the student's database.
Workspace Settings
The workspace settings in each IDE allow customization of the code editor, the UI, and other settings in the IDE. These settings are unique to the workspace and not shared across workspaces. If you would like your settings to be shared across multiple workspaces, we recommend creating a template with those settings and cloning/importing that template across your course.
Whenever changes are made to the workspace settings, you may see a Reload notification to indicate that the IDE needs to be reloaded before the changes can be made. We recommend making all changes necessary before hitting reload, and waiting a few seconds for the newly made settings to save before hitting reload.
Click the Settings button in the bottom left of the IDE to open workspace settings.
The language, version, and IDE type can be changed at the top of the settings.
For instance, this R environment could be switched to R Studio by clicking in the IDE field, selecting RStudio from the dropdown, then clicking "Change" to confirm.
The .envrc can also be opened just below that. Learn more about the .envrc
The Run Button Options allow you to set a different default file, which is the file that runs when the Run button is clicked. Switch the Run Configuration from default to Custom Command if you want to alter the compile and run commands. For instance, Java workspaces will compile everything by default, but you can choose to set what is compiled. Any custom run commands can be added as well, like the verbose command here.
Make sure to click the Save button at the bottom of the custom command.
The Run Button Dropdown allows files other than the default to be selected in the Run.
Workspace File Options contains options to view hidden files, set new hidden files, set files as read-only, and set files to open in tabs.
Files can also be marked/un-marked as read-only from the three dot menu in files.
Hidden files will not be visible to students in files, but can be referenced in the test bench, or by other files in the template. Instructors can see these files in their template with a slashed-eye icon, and read-only files will appear locked to both instructors and learners. These files can be viewed but not edited, and you can mark them as read-only at any time.
The tabs opened on load will display those files just below the run button.
Code Editor Options is where the indent size and type can be changed, as well as selecting code wrapping for the editor.
IDE Interface Options affect the tabs displayed at the bottom of the IDE, or the buttons at the top of the IDE in Visual Studio.
These tabs have default settings for each language, like the one below for HTML/CSS/JS.
Webview displays any content that can be viewed on the web like the index.html or a react app. Desktop displays a virtual desktop where you can view the output of things like a turtle program or enter commands in the console and view the full file tree. Console displays program output, accepts input, and can be used to enter commands. The Add Console button on the far right is a great place to run commands without interacting with the console's output. These tabs can be renamed, enabled, and disabled from this section.
Specific to the Webview tab's options are settings for the port used in the instance's web URL, and/or changing the path for the URL. That URL is also displayed underneath.
The Open tab on start dropdown assigns what tab remains open when the user clicks run. This defaults to webview for HTML/CSS/JS, and Console for Python and Java. Some languages also default to Desktop to display the visual output of the language. This can be changed.
The Reset Data button appears in SQL languages by default, as users may need to reset the lab data associated with the workspace. That lab data is stored in /userdata, and further explained above. Most languages write to /usercode.
To edit these settings via file, you can add a .zylab in Files and this will enable the Configure settings with .zylab file option at the bottom of workspace settings seen above.
.zylab config file for the IDE’s behavior
Every Coding Rooms IDE interface can be configured using the settings UI or the .zylab file. To edit the settings via the UI, click the settings button and Open Workspace Settings
Here you can edit workspace settings like the language, the behavior of the run button, the indent size, the windows that are opened below the code editor, and much more.
To edit via the .zylab file, create a file named .zylab. The .zylab will not display in the file menu by default, but a new "Edit .zylab file" button will appear at the bottom of the workspace settings.
Click the button to display the .zylab along with current settings in YAML syntax. You may need to change settings before the .zylab populates.
Edits made to the .zylab file will apply to matching options visible in the workspace settings and vice versa.
Here are the basic settings for python:
Any edits made to the .zylab file in a template will be copied when a learner opens that workspace. Edits made after they've opened the workspace would require a reset of the lab.
Each .zylab file is unique to the workspace where it's edited. Download a .zylab file via the file menu and upload it into other workspaces to copy the settings between workspaces. You can also copy and paste the settings, or clone a lab to copy the .zylab settings.
VSC, and other professional IDEs, can be configured directly in the menus of those IDEs. You can learn more about customizing VSC here.
.envrc config file for the virtual environment
Every advanced lab includes an .envrc file that contains the setup environment for the IDE. You can see the contents of this file by opening the workspace settings and "edit .envrc" in the settings menu.
For example, in MySQL, the .envrc includes both MySQL and Python setups:
The "Python310" flake reflects Python version 3.10.
The "mysqlcli8" flake reflects the MySQL client 8.
The services "mysql" and "mysqlworkbench" ensure that both mysql database and workbench start when the machine starts.
Environments can be combined by including the appropriate flake and use commands. Check the supported language’s .envrc file to see the necessary environment settings. Some combinations may not work.
More environment configurations will be available in the future.