assessFunctionPresence use in Matlab Grader for checking one out of n functions are present
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Antonio Mele
il 26 Ott 2018
Commentato: Antonio Mele
il 29 Ott 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 Commenti
Risposta accettata
Cris LaPierre
il 29 Ott 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.
Più risposte (0)
Community
Più risposte nel Distance Learning Community
Vedere anche
Categorie
Scopri di più su Logical in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!