This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

assessFunctionPresence

Check for presence of specific functions or keywords in the submission

Syntax

assessFunctionPresence(mustUseFunctions)
assessFunctionPresence(mustUseFunctions,'Feedback',learnerFeedback)
assessFunctionPresence(mustUseFunctions,'FileName',fileName)
assessFunctionPresence(mustUseFunctions,'FileName',fileName,'Feedback',learnerFeedback)

Description

example

assessFunctionPresence(mustUseFunctions) checks a script-based 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 assessment does not pass. Use this syntax for script-based problems.

assessFunctionPresence(mustUseFunctions,'FileName',fileName) checks a function-based 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 assessment does not pass. Use this syntax for function-based problems. You must provide the function name.

Examples

collapse all

Assess whether the specified function is present in a script-based 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-based 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 the learner solution of a function-based problem type.

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, the custom feedback should be relevant to all the functions and keywords.

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

Introduced in R2016a