MATLAB: How to hide the Cody Coursework Test Suite from Students

cody courseworkMATLAB

With the introduction of Cody Coursework, I'm often asked how to hide the Test Suite in Cody Coursework.

Best Answer

First, we need to understand why MathWorks has made the Test Suite visible to students. Students are encouraged to use MATLAB on their computer to solve problems. To make this possible, students must be able to copy and paste the Test Suite code into a MATLAB script which, in turn, calls their solution function. Once satisfied, they then copy their solution function into Cody Coursework for assessment. For this reason, if your real concern regards student attempts to cheat the system, please first try the information offered here before using the approach discussed below.
If you're still determined to hide the test suite, I'd recommend hiding some and leaving some public.
First, compile a MATLAB function containing test suite code you'd like hidden as Protected MATLAB code.
Second, post this .p file somewhere online accessible by Cody Coursework. This must not be behind the school's firewall, it must be publicly accessible. One option is to use the public folder of a free dropbox account. If using DropBox, it will help to "copy the public link" using their web interface.
Third, implement a test case of your test suite to call your protected test suite function, for example:
%%Execute Hidden Tests
urlwrite('http://url/ProfsFunction.p','./ProfsFunction.p');
rehash
  assert(ProfsFunction());
Fourth, add a test case to prevent student attempts to call on the .p file themselves, for example by parsing the students' solution file directly,
%%Test for attempts to cheat
found = 0;
fid = fopen('StudentsFunction.m');
while(~feof(fid))
   s = fgetl(fid);
   k = regexp(s,'urlwrite\(|ftp\(|mget\(|web\(|fprintf\(|fwrite\(|sprintf\(');
   if ~isempty(k)
       found = 1;
   end
end
fclose(fid);
assert(isequal(found,0))
Fifth, use the solution map as a "line of last defense." Typically, honest solutions which are correct follow similar patterns. Horizontal bars of these patterns form on the solution map. The few stray solutions below these bars which Cody Coursework has marked correct merit manual code inspection.
There are many possibilities the power of the MATLAB language offers for implementing test suites. We will add more information and examples in future, and I encourage you to share your own insights as answers or comments below.