🐬MySQL
Last updated
Last updated
In this tutorial we will guide you through all the steps to create your very first MySQL assignment in CodeGrade. For this tutorial we will be considering the example below. The zip folder contains a completed solution and a template file. Please make sure to save this file somewhere accessible on your computer:
A quick note about this example In this assignment, students have been asked to create 3 MySQL queries. Each query should make a selection from the database of a record store:
customers_from_canada.sql - The customer ID, last name, first name, and company of each customer based in Canada
songs_from_hendrix.sql - the name of every song sold by the store that was written by Jimi Hendrix
top_5_tracks.sql - The name and number of purchases of the five most popular tracks sold by the store.
Firstly, we need an assignment to work with. Whether CodeGrade is integrated in your LMS or you are using CodeGrade Standalone, you can follow the steps in the guide below to get started:
➕Create assignmentThe first step in setting up an assignment is to ensure that students can submit their code correctly. Because this example is straightforward and only requires a single solution file, we will offer the students the option to code in the CodeGrade Editor alongside the default File Uploader option.
Navigate to the Assignment Management page by using the ⚙️ icon at the right-hand side of the page header on the submissions page.
Find the Submission settings in the corresponding container under the General tab.
Enable the File uploader and Editor submission methods by clicking the respective check boxes.
Enabling the Editor will reveal the Template files option. Unzip MySQL.zip and upload all the files in the Template folder.
Finalize your settings by clicking the "Submit" button.
It is good practice to provide a template file when enabling the Editor so that your students don't have to create their own files. This also avoids the risk of students submitting a file with the wrong name.
For more information about submission methods, see Submission Settings.
While you can always grade assignments directly by manually setting the Final grade, It's only possible to award points for your automatic tests with Rubrics. Rubrics also allow you to standardize the grading scheme for graders and they allow you to clarify the grading requirements to your students.
CodeGrade offers two types of rubric category:
Discrete category - Specify points in discrete steps (eg. 0, 5 or 10 points)
Continuous category - Specify points as a continuous scale (eg. 0 - 10)
Navigate to the Rubric tab on the Assignment Management page.
Select Create new rubric.
Create 3 new Continuous Categories. Set the parameters as follows:
Category name | Description | Min - Max points |
---|---|---|
Customers from Canada | Do you correctly find the CustomerId, FirstName, LastName and Company attributes for all customers from canada? | 0 - 10 |
Songs from Hendrix | Do you correctly find the name of all songs composed by Jimi Hendrix? | 0 - 10 |
Top 5 tracks | Did you correctly find the name and number of purchases of the top 5 most popular tracks? | 0 - 10 |
Automatic tests are really what gives your students the opportunity to learn in a unique way. The immediate feedback they get from the automatic tests allow them to learn through trial and error by applying the instant feedback and resubmitting their work.
For this tutorial we will be setting up IO tests.
Before actually creating the tests, we need to make sure that we have MySQL installed correctly and that we have prepared the MySQL database and server.
Navigate to the Setup tab under the AutoTest settings.
Add an Upload Files block to your configuration and upload the chinook.sql file from MySQL.zip.
Add a Script block to your configuration and enter the following commands:
Input/Output tests, or "IO tests" for short, are a great way of checking a program's functionality by providing various input cases that should result in a different outputs. You can create IO test cases in AutoTest v2 using the IO Test wrapper block and its corresponding Full match, Substring match, and Regex match blocks.
Add three Connect rubric blocks to your AutoTest configuration.
Add three IO test blocks and nest one within each Connect rubric block.
In each IO test block, provide the following command to run the MySQL query, making sure to adjust the filename appropriately:
Add a Full match block to each IO Test block.
Copy and paste the text below into the Expected output field in their respective match block:
customers_from_canada | songs_from_hendrix | top_5_tracks |
---|---|---|
It's a good idea to give your tests descriptive names so that it's clear to both you and your students what is actually being checked (e.g. "Does customers_from_canada.sql produce the correct output?").
It's important to test your AutoTest configuration before running it on students' submissions to make sure that your tests are running as expected and to check for edge cases. This is easy to do with Snapshots. When you're ready to check your tests, simply press the Build snapshot button at the bottom of the test block sidebar. This will make a test run of your AutoTest configuration on your Test submission.
The first time you build a snapshot, CodeGrade will prompt you to upload a Test submission. Use the "Click here to upload files" option or drag-and-drop all the files in the "Solution" folder from MySQL.zip and click "Submit".
If in the future you need to re-upload your test submission, you can do so by going to Upload Submission option in the General settings tab. Just upload your file and check the "Test Submission" option before clicking "Submit".
Once you're happy with your tests, you need to publish them to your students for them to run on their submissions. Publish your tests by building a snapshot and at the bottom of the pop-up modal click the Publish snapshot button.
You have just built your first Automatically graded assignment, ready for your students to begin submitting work!
This guide is designed to get you started with a completed assignment but doesn't go into explicit detail about all of the features CodeGrade has to offer. For more in-depth information about the product and the various workflows that you can achieve, see Learn more or reach out to our support team at support@codegrade.com.