> For the complete documentation index, see [llms.txt](https://help.codegrade.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.codegrade.com/automatic-grading-guides/quizzes/coding-question.md).

# Coding Question

To assess students' understanding of programming concepts effectively, creating specific questions that require them to produce code snippets can be very beneficial. A **Coding Question** follows this precise workflow: students read the question and then write a code snippet as their answer in the Online Editor. As a teacher, you can subsequently run automatic tests on the code produced by the students to evaluate their solutions.

{% hint style="success" %}
Students can fill in Quizzes only by using CodeGrade's Online Editor. For an assignment that includes quizzes, it is therefore necessary to have the Online Editor as the only allowed way of creating submissions. In this case, it is also convenient to enable the [Simple Submission Mode](/setup-assignment/build-assignment/general-settings.md#step-2-set-submission-settings), so that students are navigated to the Editor automatically when launching an assignment.
{% endhint %}

### Create a Coding Question Test

To create a Coding Question, first add a Quiz Block and then include a Coding Question Block within it.

In a Coding Question Block, you can set:

* The name of the Block so that the student knows what the question is about;
* A description of the question, by filling in the **Question** field. This field supports markdown so that you can format the text or include links to external resources, such as in the following example:

```markdown
Complete the following code snippet so that it prints the first 20 [prime numbers](https://en.wikipedia.org/wiki/Prime_number).
```

* The name of the file that the student will produce;
* A **Starter Code Template** that the student will start working with. For instance, you may provide a partially filled code snippet, as in the example below:

```python
def is_prime(num):
    if num < 2:
        return ___
    for i in range(2, ___):
        if num % i == ___:
            return False
    return ___

prime_numbers = []
current_number = ___

while len(prime_numbers) < ___:
    if is_prime(___):
        prime_numbers.append(current_number)
    current_number += 1

print(prime_numbers)
```

* a **Solution,** which can be used to create a Test Submission, and can be revealed to students.

<div data-full-width="true"><figure><img src="/files/flya9UB98QTqXCsDKWFC" alt=""><figcaption><p>The configuration of a Coding Question.</p></figcaption></figure></div>

After the student submits their answer, you can evaluate their code using the full capabilities of AutoTest. Within the Coding Question framework, you have access to all the available Test Blocks that facilitate grading workflows. These are detailed in our guides for different programming languages,  like our [Python](/automatic-grading-guides/python.md) or [Java ](/automatic-grading-guides/java.md)guide for example.

The image below shows an example where, for a Python assignment, an IO Test Block is used to check that the student's code snippet produces the expected output:

<figure><img src="/files/Yw99oB3Kix9uDpdxUEUr" alt=""><figcaption><p>An Input Output test is used to test the student's code snipper for a Coding Question.</p></figcaption></figure>

### Hiding information from the student

As explained in the guides for the different programming languages, teachers can select which information about a Test Block should be revealed or hidden from the student. The same holds for Test Blocks that are part of a Coding Question: it will be sufficient to use Hide Blocks just as with regular Test Blocks! This is especially important to hide the solution.

{% hint style="info" %}
To make Quizzes graded, remember to wrap a Connect Rubric Block around them.
{% endhint %}

{% hint style="info" %}
Also, with Quizzes, you can [limit the number of submissions](/setup-assignment/build-assignment/general-settings.md#step-2-set-submission-settings) that the student can make.
{% endhint %}

{% hint style="info" %}
Quizzes can be used in combination with Run-If blocks. You may, for example, run other tests conditionally on the results of a Quiz.
{% endhint %}

### AutoTest Snapshot and Test Student Submission

With your Coding Question Block now set up, click the bottom right **Build Snapshot** button to build your AutoTest Snapshot. The first time you build a snapshot, you are required to upload a Test Submission; in this case it will be built for you from the solutions filled in the AutoTest setup. Simply click to generate a Test Submission:

<figure><img src="/files/e0ZC4HWzrzHopBz38Vyi" alt=""><figcaption><p>Automatic Test Submission generation.</p></figcaption></figure>

After building and publishing your snapshot, the student can fill in the Coding Question and receive feedback in the Online Editor as shown below:
