CodeShuffler empowers instructors to rearrange lines within coding files, regardless of the programming language used, producing an output image that presents the shuffled lines of code. Additionally, it generates multiple-choice options, with one of them signifying the correct sequence of coding lines. This tool simplifies the process of conducting paper-based coding assessments, eliminating the need for manual grading and streamlining the evaluation process for educators.
CodeShuffler, along with all associated coding files, and the assessment template, are copyrighted by Hasan Baig and are made publicly available under the following license terms:
- Go to the Releases tab or press the Download button above
- Download the executable for your operating system
- Launch the application
Supported platforms
- Windows (released)
- macOS (coming v1.1.0)
- Linux (coming v1.1.0)
git clone https://github.com/<your-username>/CodeShuffler.git
cd CodeShuffler
python -m venv venv
source venv/bin/activate # If on Windows: venv\Scripts\activate
pip install -r requirements.txt
python main.pyCodeShuffler provides two primary workflows:
- CodeShuffler: Generates shuffled code-based questions by pairing correct code with structured incorrect variants.
- ExamShuffler: Shuffles full exams (questions and/or answers) while preserving correctness and formatting.
CodeShuffler expects two sections in the source file:
- Correct code snippet
- Incorrect variants dictionary, explicitly marked
The correct implementation must appear first, followed by a dictionary incorrect_lines in format {correct:incorrect}. An example is provided below:
def max_num(nums):
max_val = nums[0]
for n in nums:
if n > max_val:
max_val = n
return max_val
# Incorrect lines below
incorrect_lines = {
"max_val = nums[0]": "max_val = 0",
"return max_val": "return n"
}Note that the incorrect lines delimiter and incorrect_lines variable name must be copied verbatim. More snippets are also available at codeshuffler/codefiles/snippets.
ExamShuffler expects a .docx Word file structured in a standard exam format.
Questions may be numbered or bulleted, each question must contain exactly one set of answer choices, and
formatting should remain consistent across the document. If you'd like to keep track of the correct answer for a given question,
denote a * character at the end of the option. Additionally, if using code snippets within your question, denote
the code block with <code>...<code/> tags. An example is provided below.
1. What is the output of the following code?
<code>
print(2 + 3 * 4)
</code>
A) 20
B) 14*
C) 24
D) 10
When finished, you will have the option to view your shuffled exam with an answer key, without the answer key, or with both. In later versions, users will also have the ability to change their header & footer templates through the Settings menu. As of right now, the default template is the standard University of Connecticut exam template.
"CodeShuffler ©2026 by Hasan Baig is licensed under Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)". To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/.