Providing better feedback to students when assessing FUNCTION problems in MATLAB Grader

6 visualizaciones (últimos 30 días)
I'm working on some MATLAB coding assignments for students and am using MATLAB Grader to provide assessment and feedback. I would like to have students write functions. This is to achieve two objectives, one to further their understanding of concepts from the course and so that when they are done, they can use their function (that they know and understand) to solve other homework problems, use it in labs, homeworks and exams for computing values, etc.. Much like they might do in industry.
Since within Grader one can't assess intermediate variables within the student's functions I was looking for a way to better help them debug their code. To do this I added a variable to the return variables that is a structure. I called it debug. Then for my assessments I assigned fields to intermediate values that I can check in the assessment to provide feedback to the students if these values are wrong.
For example a snippet of a learner template for a function to perform the inverse DFT is shown below. The reference template would be similar and pass back the variables that I think would be useful to assess and provide feedback on if not correct.
%
% IDFT function
%
% The function definition is locked in the learner template
%
function [xOut, debug] = IDFT( ReX, ImX )
% Create a variable debug that is a structure.
% This line is locked in the learner template
debug = struct;
%
% ... Other code and comments
%
% Save debug return variables for my assessment and checking
% These lines are locked in the learner template
debug.variable1 = variable1; % Save and return for debug and assessment
debug.variable2 = variable2; % Save and return for debug and assessment
% Students can define their own fields to return variables for
% checking in their calling code.
% These lines are written by the learner and not locked
debug.learnerVar1 = learnerVar1;
debug.learnerVar2 = learnerVar2;
The assessment can compare the learner values to the reference values. However I had to do the comparison using the assert function as the assessVariableEqual function wouldn't accept the structure and field format for the first variable (in quotations) (e.g. assessVariableEqual('debug.variable1' , debug_ref.variable1) does not work)
For example:
% Call the learner function. Include both xOut and debug if you want to get both
% the output and the debug values passed back to the calling function
[xOut, debug] = IDFT(ReX, ImX); % Call your function. Include the debug output
% Call the reference function. Include the debug output
[xOut_ref, debug_ref] = reference.IDFT( ReX, ImX )
assert( debug.variable1 == debug_ref.variable1, 'The scaled real values of the IDFT input are incorrect. Check your code starting there' );
This works, but seems complicated. I was wondering if anyone else has solved this in a different way? Any feedback would be great!
Thanks,
Mark

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 10 de En. de 2022
You could assign the value of a specific field to a separate variable, and then check that using assessVariableEqual.
variable1 = debug.variable1;
assessVariableEqual('variable1' , debug_ref.variable1)
One considernation to keep in mind when deciding between assessVariableEqual and assert is the default feedback in assessVariableEqual will include the variable name. This may actually cause confusion with your learners since they did not create this variable - you did.
Some answers that may be insightful are below.
I try to avoid modifying the code to accomodate grading. The idea is they are learning how to do code up some task, so I don't want them to get confused by code added purely for assessment purposes. Also, this can lead to over-constraining a problem, forcing students to solve it the same way I did rather than letting them come up with their own solution. Not saying you are, but just some things to take into consideration as you design your problems.
Some options I might explore would be
  1. Converting the function-type problems to a script-type problem so that intermediate variables can be assessed.
  2. Giving students a way to visualize the output, and including an image of the correct output in the feedback.
  9 comentarios
Cris LaPierre
Cris LaPierre el 16 de En. de 2022
I've inquired about the ctrl+T before, but I believe that is not a shortcut we could repurpose like with ctrl+R. I think the feedback that the 'Code to call your funciton' should have an uncomment button is a good enhancement request.
Mark Thompson
Mark Thompson el 16 de En. de 2022
Ok. Thanks. I already submitted it as a bug. Hopefully that will suffice.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Debugging and Analysis en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by