Writing the text from a MATLAB Grader student solution to a variable

8 visualizaciones (últimos 30 días)
Matthew Hudson
Matthew Hudson el 18 de Oct. de 2019
Comentada: Cris LaPierre el 16 de Abr. de 2021
I'm trying to write some more complex tests for a MATLAB Grader assignment that would involve analysing a student solution line-by-line and executing defined lines from the student's solution separately as one of the MATLAB Code tests in Grader. Is there any way to do this? For example some way to actually get the student's solution as a char vec or string.

Respuestas (1)

Soham Chakraborty
Soham Chakraborty el 22 de Oct. de 2019
Hi,
You could first read the solution into a variable using "fileread" (Hint: if you are working with Script, the file is named "solution.m", when working with a Function problem, use the function name you specified). Then for example, you can use "regexp" to analyze the text. For example:
% Get reference solution for x.
xReference = referenceVariables.x;
% Compare with learner solution.
f= fileread('solution.m');
expr = '.*:.*';
matchIdx = regexp(f,expr);
length(matches)==1
  2 comentarios
David Rayner
David Rayner el 16 de Abr. de 2021
How is pass/fail determined: is it if the last line evaluates to true? or do you have to raise errors in the case of solutions that fail?
Cris LaPierre
Cris LaPierre el 16 de Abr. de 2021
It is based on if an error is encountered in the assessment test or not.
See my answer here.

Iniciar sesión para comentar.

Comunidades de usuarios

Más respuestas en  Distance Learning Community

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by