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

조회 수: 4 (최근 30일)
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
Jan
Jan 2019년 8월 21일
@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 2019년 8월 21일
편집: John D'Errico 2019년 8월 21일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Cris LaPierre
Cris LaPierre 2019년 8월 27일
There is no built-in way to prevent student solutions from using "\".
  댓글 수: 1
Ales Janka
Ales Janka 2019년 9월 28일
편집: Ales Janka 2019년 9월 28일
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

커뮤니티

더 많은 답변 보기:  원격 교육 커뮤니티

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by