Is there a way to forbid using the "\" command in MATLAB Grader submissions?

4 Ansichten (letzte 30 Tage)
When using MATLAB Grader to automatically evaluate submitted functions, I'd like to forbid my students using Matlab's built-in linear system solver (command "\", among other). To achieve this, I tried the assessment test:
assessFunctionAbsence({'\','mldivide'},'FileName','yoursolver.m');
where yoursolver.m is the submitted function. While the use of mldivide(A,b) is correctly identified, the use of "\" (its shorthand equivalent) is not, yoursolver.m containing "\" command passes this test. Any ideas how to identify the use of "\" and forbid its use? Thanks!
  5 Kommentare
Jan
Jan am 21 Aug. 2019
@Ales Janka: What a pity. Bruno's comment shows, that even excluding \ will not solve the problem.
Does the function inmem work in the grader to check, if the mldivide function has been used?
John D'Errico
John D'Errico am 21 Aug. 2019
Bearbeitet: John D'Errico am 21 Aug. 2019
I'd agree with Jan and Bruno. Overloading the mldivide function, first ensuring that your version is on top of the search path will work. You would also need to overload mrdivide too though. Just create new functions on top of the search path that cause an error return when used. So what if a warning arises?
Can the students get around such a kludge? Yes, probably. I could probably come up with multiple hacks. And, worse, if I wanted to do so, there are lots of ways to solve a backslash problem that do not use backslash. Lets see...
lsqr, lscov, regress, inv, pinv, lsqlin, ...
You don't say if the problem is square or not, but all of those functions will work in any case.
The point is, if you want to stop an enterprising student who knows what they are doing and who wants to subvert the system, you won't do so easily if you want it to be a totally automatic solution.
I suppose you could also computationally parse through the code, searching for calls to the possible outlawed solutions. Or you could check to see if ANY of the possible alternatives were woken up. I might need to extend my list above.
Instead, simple inspection seems a good idea. Just glance through the code. Or even better, tell the students they are not allowed to use specific codes to solve the problem. Then check a few random solutions by eye.
Trust works, especially if some inspection is applied to validate that students were worthy of your trust. I'd bet that you even should know which students need to have their work checked. If you have no idea which students cannot be trusted, then it might be you need to know your students better.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 27 Aug. 2019
There is no built-in way to prevent student solutions from using "\".
  1 Kommentar
Ales Janka
Ales Janka am 28 Sep. 2019
Bearbeitet: Ales Janka am 28 Sep. 2019
In the meantime, I found I can open the student solution file as a text file, search through it for forbidden keywords (like the "\") and flag them by the assert function.
Unfortunately, my crude implementation does not distinguish between code and comment, in the student's functions...
Many thanks for your time, anyway!
Best,
Ales

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Communitys

Weitere Antworten in  Distance Learning Community

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by