Skip to content
Elise DeitrickOctober 6, 20226 min read

Easier Coding Assignment Creation with Solution Templates & Code Freezing

When testing auto-graded coding assessments, it’s easy to forget to remove the solution coding lines from the starter code file before publishing.

Then, with one click, students have a fully completed coding assessment! This defeats the purpose of helping them to learn to code by creating their own solutions to computer programming assignments. This is a common problem faced by computer science educators and trainers who use auto-graded assignments. 

This becomes even more likely when you go back to check old assignments with coding or have newer authors, such as TAs, helping build the course. Now, Codio lets you automatically use Solution Templating to remove coding lines with solutions from starter code files for your online course. This ensures that students will not be able to access the coding lines with solutions to the coding assignment.

Additionally, when authoring coding assessments and programming homework, it is common to want coding lines inside the student's file that interfaces with auto-graders that you don’t want students to change. While surrounding the code with DO NOT EDIT comments helps – Codio now lets you freeze lines of code so students cannot edit them.

This is now more important as it gives educators full control over the student’s coding environment and creation code. This makes sure that vital parts of the starter code are not edited so the auto-grading still works and the assignment can accurately test the knowledge of students.

Solution Templating: Automatically Remove Solutions from Starter Code Files

To indicate where a solution is within a code file, simply add a ‘Codio Solution Begin’ comment before the solution coding lines and a ‘Codio Solution End’ comment at the end of the solution coding lines.

def main:
    # CODIO SOLUTION BEGIN
    print('Hello world!')
    # CODIO SOLUTION END

When the assignment is published, the student sees the following in the code file:

def main:
    # WRITE YOUR CODE HERE

While the above example is in python, solution templating works in a variety of programming languages:

  • C / C++
  • Java
  • Python
  • HTML / CSS / JS
  • Ruby
  • SQL
  • OCaml
  • PHP
  • Scala

You can see the complete list of file extensions supporting solution templating in our documentation.

Solution templating can be used more than once in a file – for example, if you want students to complete a number of Java methods but you want the method headers declared for them:

public class Driver {
 
  // Instance Variables
  String name;
  String ID;
 
  public Driver(String fullName, String licenseID) {
      // CODIO SOLUTION BEGIN
      name = fullName;
      ID = licenseID;
      // CODIO SOLUTION END  
  }
    public void setName(String newName) {
      // CODIO SOLUTION BEGIN
      name = newName;
      // CODIO SOLUTION END
  }
 
  public String getName() {
      // CODIO SOLUTION BEGIN
      return name;
      // CODIO SOLUTION END
  }
 
  public String getID() {
      // CODIO SOLUTION BEGIN
      return ID;
      // CODIO SOLUTION END
  }
}

 

When the student opens the assignment, they see:

public class Driver {
 
  // Instance Variables
  String name;
  String ID;
 
  public Driver(String fullName, String licenseID) {
      // WRITE YOUR CODE HERE
  }
    public void setName(String newName) {
      // WRITE YOUR CODE HERE
  }
 
  public String getName() {
      // WRITE YOUR CODE HERE
  }
 
  public String getID() {
      // WRITE YOUR CODE HERE
  }
}

 

It is important to note that the publishing process removes these coding lines with solutions – so when teachers and TAs are in a student’s assignment to provide help or grade, these solutions will not be visible. This helps maintain the integrity of the assignment.

To provide a solution or any other help or grading information to teachers or TAs within a student’s assignment, you can use a guidance call-out block or a separate teacher-only page.

Freezing Lines of Code so Students Cannot Change Starter Code

When using Codio’s script-less code auto-grader, coding lines are  frequently included as part of the starter code to parse keyboard input or command line arguments into a student-ready format. Currently, many content authors try their best to clearly communicate not to edit this code to the student through comments:

//DO NOT EDIT////////////////////////////////////////////
  public static void main(String[] args) {             //
    ArrayList<String> list = new ArrayList<String>();  //
    for (String s : args) {                            //
      list.add(s);                                     //
    }                                                  //
    reverseSelectionSort(list);                        //
    for (String s2 : list) {                           //
      System.out.println(s2);                          //
    }                                                  //
  }                                                    //
/////////////////////////////////////////////////////////

Instead of relying on students reading and following directions, teachers can now freeze lines of code that the auto-grader relies on. Similar to Solution Templating, simply add a ‘FREEZE CODE BEGIN’ comment before the lines to be frozen and a ‘FREEZE CODE END’ comment at the end of the lines to be frozen. The example above would then look like this:

// FREEZE CODE BEGIN
  public static void main(String[] args) {            
    ArrayList<String> list = new ArrayList<String>(); 
    for (String s : args) {                           
      list.add(s);                                    
    }                                                 
    reverseSelectionSort(list);                       
    for (String s2 : list) {                          
      System.out.println(s2);                         
    }                                                 
  }                                                   
// FREEZE CODE END

 When students open their assignment with coding, the frozen lines of code are both clearly indicated and un-editable:

While the above example is in Java, freezing lines of code works with a variety of languages:

  • C / C++
  • Java
  • Python
  • HTML / CSS / JS
  • Ruby
  • SQL
  • OCaml
  • PHP
  • Scala

You can see the complete list of file extensions supporting freezing lines of code in our documentation.

You can also have multiple sections of frozen code within the same code file. For example, you can freeze the entirety of the starter creation code:

// FREEZE CODE BEGINS
import java.util.Scanner;

public class Test{

public static void main(String args[]){
 
  Scanner input = new Scanner(System.in);
  //FREEZE CODE ENDS



 
// FREEZE CODE BEGINS
} // closes main method

} // closes Test class
// FREEZE CODE ENDS

 

When the student opens the assignment, they see:

Better Together: Combining Solution Templating and Code Freezing

Solution templating and code freezing can be combined in a single code file to ensure that the solution does not get passed to students and that students do not edit code that connects to the auto-grader. For example:

#include <iostream>
using namespace std;

int main(int argc, char **argv)
{
// FREEZE CODE BEGIN
int num = stoi(argv[1]); // typecast the string to an int
// FREEZE CODE END

// CODIO SOLUTION BEGINS
cout << num * 3;         // print the int multiplied by 3
// CODIO SOLUTION ENDS

return 0;

}

Will be presented to the student as follows:

Create Better Coding Assignments with Codio

It doesn’t matter if you teach coding for beginners, coding languages or development processes for programming experts, you need a solution that can help you to assess your computer science students fairly.

Autograders are designed to assess the coding skills of computer science students while minimizing the manual work for educators and trainers. If the integrity of the assignments are compromised because coding lines with solutions are readily available, then students won’t be graded based on their own skills.

The true mark of a thorough assessment is the integrity and fairness of its grading. Educators should have to do double the work to ensure their assessments reveal coding lines with solutions or that coding problems can be edited accidentally. This is why Solution Templating and the ability to code freeze-specific sections are so important. 

It makes the planning creation process of assignments much easier, especially among teams. All in all, this simplifies the grading process and reduces the time to go back and check for errors in coding lines.

You can foster learning by having students work directly in online environments like Python fiddles to create solutions. Let Codio help you deliver a better user experience with your computer science courses with easy coding environments. 

Get Started Today - schedule a demo, create a free instructor account.

 

avatar

Elise Deitrick

Elise is Codio's VP of Product & Partnerships. She believes in making quality educational experiences available to everyone. With a BS in Computer Science and a PhD in STEM Education, she has spent the last several years teaching robotics, computer science and engineering. Elise now uses that experience and expertise to shape Codio's product and content.