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

조회 수: 8 (최근 30일)
Matthew Hudson
Matthew Hudson 2019년 10월 18일
댓글: Cris LaPierre 2021년 4월 16일
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.

답변 (1개)

Soham Chakraborty
Soham Chakraborty 2019년 10월 22일
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
David Rayner
David Rayner 2021년 4월 16일
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 2021년 4월 16일
It is based on if an error is encountered in the assessment test or not.
See my answer here.

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

커뮤니티

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

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by