Main Content

assessFunctionPresence

Check for presence of specific functions or keywords in the submission

Description

assessFunctionPresence(mustUseFunctions) checks a script-type solution for the presence of functions or keywords in the specified list mustUseFunctions. If the submission does not contain one or more of the functions or keywords listed, the learner receives a default feedback message:

The submission must contain the following functions or keywords: <name1>, <name2>, ...<namen>

assessFunctionPresence(mustUseFunctions,'Feedback',learnerFeedback) lets you display specific feedback to the learner if the solution does not pass the conditions in the assessment test. Use this syntax for script-type problems.

assessFunctionPresence(mustUseFunctions,'FileName',fileName) checks a function-type solution for the presence of functions or keywords in the specified list mustUseFunctions. You must provide the function name. If the submission does not contain one or more of the functions or keywords listed, the learner receives a default feedback message:

The submission must contain the following functions or keywords: <name1>, <name2>, ...<namen>

assessFunctionPresence(mustUseFunctions,'FileName',fileName,'Feedback',learnerFeedback) lets you display specific feedback to the learner if the solution does not pass the conditions in the assessment test. Use this syntax for function-type problems. You must provide the function name.

example

Examples

collapse all

Assess whether the specified function is present in a script-type learner solution.

assessFunctionPresence('trapz')

If the function is missing, the learner receives the following default message:

The submission must contain the following functions or keywords: trapz

Assess whether specified function is present in the learner solution. Show a custom feedback message if it is missing.

assessFunctionPresence('trapz','Feedback','Consult the trapz doc page if you need help using this function.')

For example, if the function trapz is missing, the learner receives the following default message along with the custom feedback specified by learnerFeedback:

The submission must contain the following functions or keywords: trapz

Consult the trapz doc page if you need help using this function.

Assess whether specified functions and keywords are present in the learner solution for a script-type problem. Show the default feedback message if any of the functions or keywords are missing.

assessFunctionPresence({'round','while'})

For example, if the function round is missing (though while is present), the learner receives the following default message:

The submission must contain the following functions or keywords: round

Assess whether the specified function is present in a function-type learner solution.

assessFunctionPresence('trapz','FileName','numInteg.m')

If the function is missing, the learner receives the following default message:

The submission must contain the following functions or keywords: trapz

Input Arguments

collapse all

A list of one or more functions or keywords that are required to be in the submission. For a single function or keyword, this value is specified as a character array. For multiple functions or keywords, this value is specified as a comma-delimited series of character arrays within curly braces { }.

Example: {'for','mean','diff'}

The file that contains the function solution to be tested, specified as the comma-separated Name,Value pair consisting of 'FileName' and a character array containing the solution file name.

For script solutions, the auto-grading tool uses the default file name solution.m and you do not need to specify this argument.

Example: 'FileName','myTest.m'

Additional feedback to display to the learner, specified as the comma-separated Name,Value pair consisting of 'Feedback' and a character array containing a message to the learner.

For example, assume a learner did not use the ode45 function as was specified in the problem description. You could direct the learner to the documentation for this function.

assessFunctionPresence('ode45','Feedback','Refer to the documentation for ode45 to understand why it is used to solve this problem.')

If the learner solution does not contain the required function, assessFunctionPresence then returns the following message:

The submission must contain the following functions or keywords: ode45

Refer to the documentation for ode45 to understand why it is used to solve this problem.

Only a single, customized feedback character array is allowed. If you are checking for more than one function or keyword, make the custom feedback relevant to all the functions and keywords.

Example: 'Feedback','Review the handout on numeric integration.'

Version History

Introduced in R2016a