Matlab Grader file solution.m contains learner solution in one exercise, reference solution in another exercise
Afficher commentaires plus anciens
Hello,
Short version of my question : Why do i get the reference solution from fileread('solution.m') in one exercise and the learner solution in another exercise? Both problems are script based problems where the learner template is a copy of the reference solution with some gaps the students have to fill.
Detailed information (if you have the time to read it):
i am trying to create an exercise similar to the one described in this link: MATLAB Grader. How to check vectroization in students solution? - MATLAB Answers - MATLAB Central (mathworks.com). There are two for-loops in my learner template and the inner for-loop should be replaced by a vectorization.
To check if the student performed the vectorization, the test should check how often the keyword "for" is used. However, when i use SolutionFile = fileread('solution.m') the reference solution is saved in SolutionFile and not the learner solution. In another exercise, this works totally fine with the keyword 'plot' (i get the learner solution with fileread('solution.m') in the other exercise). I tried to implement the test for vectorization into a MATLAB Grader Assessment and into a MATLAB-function, which is provided to the exercise in a referenced file. This is my code to check vectorization
SolutionFile = fileread('solution.m')
MaxNumber = 1;
NumberOfforOperators = numel(strfind(SolutionFile,'for'))
if NumberOfforOperators>MaxNumber
error('You used for to often, it seems you did not vectorized your code properly')
end
And these are all the files in the Grader exercise when i call ls() (at the end of the reference solution and clicking on "validate reference solution"):
'+reference ScoringEngineSharedVariable1.m ScoringEngineTestPoint1.p ScoringEngineTestPoint2.p solution.m solutionTest.m testvectorization.m '
With testvectorization.m my MATLAB-function with the code i posted above. If i try to access +reference i receive an error message, solution.m contains the reference solution. The learner solution is not contained in any of the files.
My function counts a total number of 7 "for"s in the reference solution, all the "for"s in the comments are also counted.
Note: When i call my function inside the learner preview, it contains the code of the learner preview. In this way i could create the exercise but still i wonder why solution.m can contain the learner solution or the reference solution?
(In one exercise i get the learner solution only by calling my function which is in a referenced file in the learner template/preview, in the other exercise i can access the learner solution in the same way or in an assessment)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Use Content in an LMS Course dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!