Update: You can now run these scripts directly from codePost! Make sure you have your Moss ID and go to
Assignments
->Actions
->Check Moss
. See an example here.
This is a set of short scripts that can be used to connect Moss with codePost. Moss is a tool for assessing similarity between programs provided as an internet service by Stanford University and commonly used to detect instances of plagiarism in programming courses. See a video overview of these scripts in action here.
Use sendToMoss.py
to send the submissions corresponding to a single codePost assignment to Moss for processing. To do this, run
python3 sendToMoss.py <assignment name> [-m] "[optional Moss arguments]"
This script will print to the command line a link which contains the results produced by Moss.
Moss accepts the following optional arguments.
-l language
- the source language of the tested programs-b basefile_1 .... -b basefile_n
- names a "base file"-m #
- sets the maximum number of times a given passage may appear before it is ignored-c "string"
- comment string that will be attached to the report generated by Moss- Note: the
-d
argument (to specify directories) is included by default in this script, as each codePost submission is treated as a directory
Some usage notes:
- In order to run
sendToMoss.py
, you must have amoss
file in the directory from which the script is run. See the Moss website or thesendToMoss.py
file for instructions. Make sure you usechmod
to make this file executable before runningsendToMoss.py
. - Before running, you must edit the
codePost API Key
,courseName
, andcoursePeriod
constants insendToMoss.py
. You can obtain your codePost API key here. - For the most accurate code similarity scores, use the
-l <language type>
optional parameter. For example, if you are comparing Java files for similarity, use the followingpython3 sendToMoss.py <assignmentName> -m "-l java"
. Seemoss
for a full list of languages accepted by the-l
parameter.
After calculating Moss similarity scores using sendToMoss.py
, the processMossResults.py
script will allow you to place a codePost comment on each pair of codePost submissions (sub1, sub2)
for which the similarity between sub1
and sub2
exceeds some threshold.
Run the script as follows.
python3 processMossResults.py <MossURL> <threshold>
Some usage notes:
- Before running, you must edit the
codePost API key
constant inprocessMossResults.py
. - This script assumes that the directories uploaded to Moss are in the format:
/tmp/<submissionID>_<student(s)>/<fileName>
. ThesendToMoss.py
script will automatically upload directories in this format, so if you used that script, you can ignore this instruction. But if you plan to useprocessMossResults.py
independently ofsendToMoss.py
, then you'll want to modifyprocessMossResults.py
by editing the regexs used to parse Moss results to match your file names.