Matlab Grader Assessment Feedback

조회 수: 2 (최근 30일)
Justin Wyss-Gallifent
Justin Wyss-Gallifent 2020년 6월 30일
댓글: Justin Wyss-Gallifent 2020년 6월 30일
It is possible to incorporate Matlab code in an assessment test which gives specific results to the students?
To clarify - suppose the students have to write a function in Grader which adds two numbers, something simple like:
function r = addthem(a,b)
r = a+b;
end
Suppose then my assessment test wants to feed a bunch of sample input in a simple way such as:
% Innocent until proven guilty.
pass = 1
% Run learner solution in multiple sets of inputs.
for count = [1:100]
a = randi([-100,100])
b = randi([-100,100])
% Compare.
if addthem(a,b) != reference.addthem(a,b)
% Guilty.
pass = 0;
end
end
assessVariableEqual('pass',1);
Is it possible for this function to be modified so that it shows the student, when the student submits the code, exactly what input and output are being printed? Putting a disp (or some such) inside the assessment doesn't work - can the assessment be modified to generate feedback in any way?

채택된 답변

Steven Lord
Steven Lord 2020년 6월 30일
I haven't tried this, but something like this should work:
% Innocent until proven guilty.
pass = 1;
feedback = "";
% Run learner solution in multiple sets of inputs.
for count = 1:100
a = randi([-100,100])
b = randi([-100,100])
% Compare.
if addthem(a,b) ~= reference.addthem(a,b)
% Guilty.
pass = 0;
feedback = feedback + "Your function failed for inputs " + a + " and " + b + newline;
end
end
assessVariableEqual('pass',1, 'Feedback', feedback);
Though I might move the assessment into the loop.
% Run learner solution in multiple sets of inputs.
for count = 1:100
a = randi([-100,100]);
b = randi([-100,100]);
% Compare.
result = addthem(a, b);
assessVariableEqual('result', reference.addthem(a,b), 'Feedback', ...
"Your function gave an incorrect answer, " + result + ", for inputs " + a + " and " + b);
end
  댓글 수: 1
Justin Wyss-Gallifent
Justin Wyss-Gallifent 2020년 6월 30일
Come to think of it yes, this is a pretty clean solution. I'm not sure I'd keep the assessment inside the loop though because then it'd throw an error on just the first occurence and then quite, which wouldn't perhaps give sufficient information.
Thanks for that!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Create or Copy Coding Problems에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by