1 ClassroomCode


Some of this page is for students in programming classes,
and some for instructors of programming classes.

1.1 Practical programming assignment infrastructure

Rather than use toy tools and academic platforms, we use real systems:

  1. Make - for building and running code and tests (autograding).
    https://en.wikipedia.org/wiki/Make_(software)

  2. git software - for locally managing code (saving your work).
    https://en.wikipedia.org/wiki/Git

  3. Gitlab server - for code collaboration (assignment submission).
    https://en.wikipedia.org/wiki/GitLab

  4. Podman/Docker containers - for an isolated development and remote testing environment.
    https://en.wikipedia.org/wiki/Podman

  5. CI/CD - for running tests and seeing feedback.
    https://en.wikipedia.org/wiki/CI/CD

These are industry-wide standards!
I have heard sincere thanks from many students,
who report this infrastructure practice got them through their first jobs and internships.

1.2 What you should know

To learn about autograding, git, containers, Make, and other assignment infrastructure,
read this page, and these links with all of their first-order sub-links:

1.2.1 git

Everyone (students and teachers) should know version control well.
If you do not, please review the following materials before proceeding:

  1. Watch the videos here:
    https://git-scm.com/videos

  2. My intro lecture on VC:
    ../Classes/CompSciTools/Content/VersionControl.html

  3. Read Appendix E - Submitting homework with Git, in the Data Structures Lab manual:
    ../Classes/CompSciTools/Content/tools-for-computer-scientists.pdf

  4. The extras under the version control heading on this page:
    ../Classes/CompSciTools/Content.html

1.2.2 make

Make sure you know Make…
* https://cs-mst.gitlab.io/index/Classes/CompSciTools/Content/05-build_systems.pdf
* https://makefiletutorial.com/
* https://www.gnu.org/software/make/manual/make.html

2 Assignment pipelines:

Managing student work involves two major tasks:
1. Managing the git repositories.
2. Grading itself.

2.1 1. Managing git repositories

Services/software for managing bulk student repositories:

There are numerous cloud-based, server-side tools, like GitHub classroom,
but these are not local software, nor real industry tools!

It is ideal to use local, real-world software engineering tools,
that interface with CI/CD, for grading student work.
Then, assignment testing is realistic, and teaches the tools students will use in the wild.
This is what we use here at MST to manage bulk student repositories:
https://github.com/BehindTheBrain/assigner
This is pre-installed in the container I distribute and in my configuration scripts,
so you don’t need to install yourself if you use it:
WorkingEnvironment.html

2.1.1 assigner

Here I detail both:
1) Student perspective
2) Faculty/TA/Teacher perspective

2.1.1.1 1) Student work-flow example

To prepare for submitting assignments, with your S&T login, log into:
https://git-classes.mst.edu

#!/bin/bash

# In a terminal, make and cd into whatever directory you want to use as the superdirectory, such as
mkdir CS-1500-assignments/
cd CS1500-assignments/

# Using a web browser, sign into https://git-classes.mst.edu with campus credentials.
# First, set up an SSH key (or a password token) in the Gitlab web interface.

# Then, click on the class group for your class.
# Find your git repo in the web interface.
git clone <your-repo>

# Head into the repository:
cd example-assignment

# Make your changes, do assignment:
vim examplecode.py
python3 examplecode.py
make clean && make test && make grade

# add, commit, push to remote:
git add whateveryouchangedoradded.py
git commit -m "commit message"
git push

# In web browser, check https://git-classes.mst.edu CI/CD for your repo,
# to make sure your changes are up and your grade is correct!
echo "Yay, I'm done, and know my grade instantly!"

To summarize all that again, execute once:
git clone <your-repo>

Execute as many times as you like,
from within the directory/repository you cloned to your hard drive (just an example):

git status
git add *.cpp *.h *.hpp *.txt *.py
git add SUBDIRECTORY/*
git commit -m "Informative description of the commit"
git push

Do not add:
Compiled or generated files like a.out, your executable files, etc.
Put the name of these files in a text file in the root of your repository, named: .gitignore

If you see your changes reflected on the git-classes site,
then you have submitted successfully.

If you work from different computers and want to synchronize,
or we make changes to your repository, then do:
git pull

Note: Programs in the repository see the repository itself as the current working directory.

Feedback comes in the form of correct/incorrect results for a variety of unit tests on your code.
Feedback text (results.txt) files can be opened in your text editor.

On the sidebar for your repository, click on
Build -> Jobs
or
Build -> Pipelines
ClassroomCode/ci-jobs.png

Then, in Jobs, click on either the red failed or green passed button.
Or, if you went with Pipelines, you must click on the pipeline,
then the individual job, to display the below result.
ClassroomCode/ci-fail.png
The above screen will show you that either all tests passed (green),
or if one failed, exactly which failed.
You can know which failed, because it will be the last one to have run,
and thus produced a “return code” of not 0 (1 or some other number).

Danger:
You should not change the gitlab-ci.yml file we give you,
unless you’re adding tests of your own,
and should not change it in order to fake a pass
(it won’t pass our security checks, and would be considered cheating).

2.1.1.2 2) Faculty work-flow example

Actually read the assigner documentation before trying to use it :)

Some work is done by the teacher:
a. Just once ever,
b. Some once per semester, and
c. Some is for each assignment

2.1.1.2.1 a. Work done once ever (or until access tokens expire)

Generate an SSH key on the computer you’re going to assign on,
and then copy it into the git-classes web-interface.

In git-classes web-interface, generate an access token,
and save it somewhere safe (you’ll need it later for assigner init).

In Canvas web-interface, generate an access token,
and save it somewhere safe (you’ll need it later for assigner init).

2.1.1.2.2 b. Work done once per semester
#!/bin/bash

# create super-folder on your local computer for each class: e.g.,
mkdir 2019-FS-CS1500-A

# cd into class folder: e.g.,
cd 2019-FS-CS1500-A

# keeps the student code in a sub-folder
mkdir student_submissions

# create git-classes group named the same (or preferably let assigner do it just below).
assigner init
# If you did not create the group manually on gitlab, let assigner do it for you now.

# Find your course
assigner canvas list

# Import students into config file
assigner canvas import classnum section
# where classnum is from the output of previous command, and
# where section is section-letter, if any, else, A
2.1.1.2.3 c. Work done once per assignment
#!/bin/bash

# Head into class folder
cd 2019-FS-CS1500-A

# Make new assignment, and it's grader partner, and clone the empty repos
assigner new assignment01
assigner new assignment01-grader
git clone whateverlinkassignernewgeneratedabove
git clone whateverlinkassignernewgeneratedabove-grader

# head into the grader repo
cd assignment01-grader
# write the solution to your assignment
# write the unit tests and CI for your assignment, checking they all pass
# Head back to class folder
cd ..

# Copy your solution into the student repo
cp -r assignment01-grader ../assignment01
cd ../assignment01
# break/remove your solution (or parts of it) from the solution
# check the CI/tests fail
# Head back to class folder
cd ..

# Assigning actually generates student repos from your template
assigner assign assignment01 # --branch main

# Opening adds them as developers
assigner open assignment01

# You can check on them in bulk:
assigner status assignment01 # --branch main

# When you need to close the assignment, gives students reporter rights only:
assigner lock assignent01

# Pulls all the student repos
assigner get assignment01 student_submissions/ # --branch main

# If you grade locally, then run your autograder,
# modifying the student repos in student_submissions/
assigner commit -S assignment01 "message to students" student_submissions/ -u -a '*' # --branch main
# -S assumes you have a gnupg2 key with an email that matches the listed public email account in gitlab web-interface.
# '*' is all non-hidden files. Alternatively, list any specific files you need.

# Pushes edits to student repos back up:
assigner push assignment01 student_submissions/ # --branch main

# Just shows the scores, if present, in results.txt in student repo
assigner score all assignment01 # --branch main
# You can use gitlab CI/CD to generate the results.txt,
# or push it back manually

# pushes scores from results.txt file in repo to Canvas,
# if assignment is named the same as a canvas assignment
assigner score all --upload assignment01 # --branch main

If you need to make changes it the middle of an assignment’s release

#!/bin/bash

# lock so that your edits don't collide with students, and create remote conflicts
assigner lock assignent01

# get the student code
assigner get assignment01 student_submissions/ # --branch main
# edit assignment

# assumes you have a gnupg2 key with an email that matches the listed public email account in gitlab web-interface.
assigner commit -S assignment01 "message to students" student_submissions/ -u -a '*' # --branch main

# push back
assigner push assignment01 student_submissions/ # --branch main

# give students developer access back
assigner unlock assignment01

2.2 2. Code grading and/or learning platforms

There are several open source, local, and/or self-hosted systems for hosting student work:
https://submitty.org/
RPI’s overly-fancy, overly-GUI system, also does grading.
https://github.com/Submitty/
Self-hosted, web-based student interface, not debug-capable.

https://redkyn.github.io/grader/
https://github.com/redkyn/grader
A system for containing executed code,
which expects you to provide your own grading framework.

If you would like to read about some language-specific testing frameworks:
../Classes/ComputationalThinking/Content/10-DebuggingTesting.html
../Classes/ComputationalThinking/Content/19-TestingFrameworks.html
../Classes/CompSciTools/Content.html
(Section on unit tests)

2.2.1 A generalized auto-grading suite: make grade

Check out our auto-grading suite,
and design your own Gitlab-CI based auto-graded assignments much more easily.
https://git.mst.edu/make-grade
It is ssh/remote capable, open, local, transparent, debug-capable, git compatible.
The current language support includes:
Python3, Rust, C/C++, Bash, Matlab/Octave (partial), Haskell (in progress).

2.2.2 General guidelines to create an assignment and grading suite

Write a script for students to run, as a sanity check,
even if you don’t give out all the tests,
which gives them a feedback file, easily readable.
Write modular small unit tests, which are to be wrapped twice:
once at the project level, and once at the multi-student level
Base the core design pattern of your first wrapper/grader around a single-repo,
single-student script, meant to test one instance of the whole project.
That project-wrapper script should compute the grade.
Then, after that whole-project grading script is done,
write a cross-student wrapper, which should be the most minimal of all,
just running the project grader for each student.

2.2.3 Using GitLab continuous integration for unit testing

Validate modular unit tests,
which return/exit code to parent bash process: (0 pass, 1 fail)
Write a bash script which runs all unit tests for the project,
so students can run this locally.
Mimic that bash script in a .gitlab-ci.yml file,
which kick-starts CI for the repository,
passing if all return codes are 0, and failing if any are not 0.

2.2.4 Grade extraction from repos to Canvas

Alternative 1: Grab the number in each student feedback file, tabulate it, and upload to canvas (easily automated).
Alternative 2: Pushing to Canvas from repositories: in development now. Email me if you want to check it out.

2.3 Cheat/copy checking

To determine whether students copied code from each other, or the internet,
there are several options:

My crude copy-checker is much easier to run than the following two:
https://gitlab.com/classroomcode/copy_checker

Moss does pretty well, and compares to an online,
and bigger database than just students against each other.
It is however, a bit of a pain to run.
https://theory.stanford.edu/%7Eaiken/moss/

Rensselaer’s submission system is called Submitty (https://submitty.org/) as discussed above.
Their plagiarism detection tool is called Lichen (See https://github.com/Submitty/Lichen for Lichen;

2.4 Classroom Response Systems (Alternatives to: Clicker, Kahoot, etc.)

Rather than pay for, or even worse, rent, Clickers, or pay for Kahoot… try these:

Use our Canvas-based (Kahoot mimic), Cahoot:
https://gitlab.com/classroomcode/cahoot

Check out this very cool QR-code based CRS:
https://get.plickers.com

2.5 Generating flowcharts from code

For students learning branching and looping,
generating flowcharts from code can be quite helpful.
Flowcharts are also known as CFGs:
https://en.wikipedia.org/wiki/Control-flow_graph

Check out our project of mine, which turns arbitrary python code into a colorful CFG:
https://gitlab.com/classroomcode/py2cfg