assessFunctionPresence use in Matlab Grader for checking one out of n functions are present
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Antonio Mele
el 26 de Oct. de 2018
Comentada: Antonio Mele
el 29 de Oct. de 2018
I am setting up a test in Matlab Grader to check that students use a for or a while loop in an exercise. They can only use one out of the two. The problem is that there is no way to set up an assessFunctionPresence test for this purpose. Is there any way around it?
0 comentarios
Respuesta aceptada
Cris LaPierre
el 29 de Oct. de 2018
The MATLAB Code assessment type allows you to use any code you want to create an assessment. There are ways to achieve the result you want with assessFunctionPresence combined with assessFunctionAbsence, since it is the combination that is important. For example
try
assessFunctionPresence('while')
assessFunctionAbsence('for')
catch
assessFunctionPresence('for')
try
assessFunctionAbsence('while')
catch
assert(false,'You must use either a for loop or a while loop, but not both')
end
end
Any time a test evaluates false, you are bumped to the next level of the try/catch. If the solution contains both for and while loops, the assert statement will mark the answer false and give the student meaningful feedback on how to correct the code.
Más respuestas (0)
Comunidades de usuarios
Más respuestas en Distance Learning Community
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!