Using Moss to Detect Cheating on Assignments

Running the Script

To run Moss on the assignment, navigate to /u/csXXX/mossoutput and run either Moss directory or ./Moss directory, depending on where the Moss script is saved. In either case, the script will look for student submissions in the directory /u/csXXX/handin/directory. This is the default for courses like CS 115, 115, 135, and 234, but is not for many other courses, especially those that use Marmoset. In those courses, you probably have a choice between running Moss on aXX or aXX_autotest; aXX is usually preferred because the GRADED_ASSIGNMENT file can cause some similar code to be flagged twice.

After running the script, a directory /u/csXXX/mossoutput/directory_language will be created. By default language will be ascii, but this can be changed using the -l flag described in the next section. Within the directory_language directory, there should be a file readableIndex.html. This file can be opened in a web browser, and will allow you to view pairs of student files side by side, with coloured highlights indicated what code Moss has flagged as suspicious. Your ISC will give you instructions on what to do with matching students.

  1. CS 116 ISAs should confirm that the files actually match, print the associated student files (printing the GRADED_ASSIGNMENT file may be useful to make this task easier), and indicate where the files match. Pay close attention to copied over typos or other mistakes that both students made.
  2. CS 136 has another script which formats matches so that the ISC can easily go through them to check they are indeed matching

Options for Moss

The script has three optional parameters which you can provide in order to increase its functionality.

  1. -t X will only flag files that match at on at least X% of their lines. This option defaults to 5 if no -t flag is given.
  2. -l specifies running Moss with settings specific to a programming language. This defaults to ascii if no -l flag is given, which seems to find matches better than any specific programming language.
  3. -o allows you to compare output against previous terms. It will look in the directory ??? for the previous term assignments, and can be specified multiple times in order to compare against multiple past terms.
  4. -b allows you to mark the contents of a base file as code that should not be flagged; for example, if students were provided some basic function definitions to use freely in their code, it could be included in the base file so that Moss does not accuse students of cheating when using code. If enough students submit the same code, Moss will assume it was provided and stop flagging it; however, this check is not perfect, and using the -b flag will reduce the number of false positives arising in this manner.

Old Versions

After the assignments, you will use a program called Moss in order to look for students who have copied each other on assignments. There are three scripts that facilitate the use of moss: runMoss, moss_makereadable, and moss_getgroups. They are described at ISGScriptsManPages#Moss


Many tutors find the interactive prompting from runMoss a nuisance. A common and simple way to remove the prompt is to instruct moss to delete any unrecognized students:

yes d | runMoss ...

However, this is a strongly discouraged solution. Any unrecognized students who match will not be found this way. Instead, a renaming pipe is recommended:

perl -e '$count=0; while (1) { print "r\nRENAMED" . ++$count . "\n"; }' | runMoss ...

Some investigation of the submission directories will need to be done to determine who matched in the event that one of the RENAMED students is a high percentage match, but this way such a student will be discovered instead of being discarded.

The actual call of runMoss looks like this:

runMoss a* '-l ascii -d' where * is the assignment number

If there are a large number of matches, moss can be instructed to return more results than normal. The following example will return 600 matches instead of the normal 250.

runMoss -d 1curr -d 1past '-n 600 -l ascii'

This command will send the information to a server where Moss is located. A URL will be returned as the final line of the results.


This web page will be very difficult to read, so the next step is to make the cheaters stand out. Use this code:

moss_makereadable "webpage spit out by runMoss command" xx > filetosave.html

where xx is the threshold percentage (that is, xx% of lines must be the same in at least one of the assignments for Moss to flag the pair). 15 is a reasonable threshold. Save the file as an html file, and make sure to save in the correct directory. Example:

moss_makereadable "./html/index.html" 15 > ./readableIndex.html

moss_makereadable "" 15 > marking/a1/a1moss.html

moss_makereadable can also take in two threshold numbers instead of one. This means that at least one the assignments must pass the first threshold, and the other assignment must have a minimum of the other threshold in common.

Any such double-filter should be used with extreme caution, and possibly only as a second run; there have been cases where over 90% match for one student corresponded to only under 10% for another, because the first student only submitted one question, and chances are that using two thresholds will not catch this case.


Another useful Moss command is moss_getgroups. This command will isolate multiple students whose code looks the same and saves it in a .txt file.

moss_getgroups filetoread.html > filetowrite.txt

where filetoread is the file you create with moss_makereadable and filetowrite is the text file in which you wish to save this information.

Make sure for both the .html and the .txt file, you specify the location to save them, otherwise they will be saved in your present directory.

Interpreting results

As nice as Moss is, it is not perfect, and whatever Moss find should be double checked by a human marker. One suggestion is to run rst suites on each of the groups separately, so that everyone Moss has flagged are isolated together. Then it is just a matter of sitting down with a highlighter and comparing the assignments.

Collecting Submissions

A second script called helps you to collect student submissions.

The syntax is

./ assign [list-of-userids]

where assign is the name of the assignment in the handin folder, and you only need to provide the list of userids of the students you are inspecting.

Do not run this script on assignments with too many files and multiple levels of directories.

Topic attachments
I Attachment Action Size Date Who Comment
Unknown file formatEXT Moss manage 5.2 K 2013-04-26 - 10:32 PeterSinclair The Moss script described above.
Unix shell scriptsh manage 2.0 K 2010-04-03 - 13:50 ZeLong Script assist you to collect student files
Topic revision: r18 - 2018-09-05 - YiLee
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback