Main Content

Create Function-Based Problems

Write a problem that you want learners to solve using a function. The following procedure walks you through all the steps necessary to create a problem; if you need additional help, click the question mark icon or see Example of a Function-Based Problem.


At any time, you can click Choose Different Problem to abandon the draft and return to Add Problem to make a new selection.

  1. Create a title and detailed problem description for the learner. You can include formatted text, equations, links, and images.

    Clearly define the number and type of input variables and the number and type of expected outputs. Be specific about the types of values or measurements to be used (for example, degrees in Celsius or metric values).

  2. In Files Referenced, provide data and code files that the reference solution, learner solution, and assessment tests can use.

  3. Set Problem Type to Function.

  4. The Reference Solution is the instructor’s solution. The learner cannot see this solution. You can use a reference solution in your assessment tests to compare your solution to the learner's.

  5. If you want to help learners with some of the solution, fill out the Learner Template. This template contains code that you provide to learners to guide them in creating a solution. You decide how much code to provide to help them get started.

    You can lock selected lines in the learner solution so that learners cannot edit these lines. To lock a line, select the lock icon next to the line. Or you can drag down the lock column to lock a range of line. To unlock a locked line, select the lock again.

  6. Learners can run their function before submitting it for assessment. You can help learners test their solutions by providing code that calls the learner function with sample inputs. Enter this code in How to Call the Function. The code then appears in the box labeled Code to call your function, shown in the learner view.

  7. To see the actual formatting of your content, click Learner Preview. The preview area displays the view that the learners see.

  8. Click Save as Draft. Learners cannot see the problem while it is in Draft mode. You can continue developing this problem while it is in draft mode.

  9. Write one or more assessments for the problem. See Write Assessments for Function-Based Learner Solutions.

  10. Validate your solution.

  11. Click Save as Final when the problem is complete. Or, click Save as Draft continue working on the problem before publishing it.

    If you want to remove a problem from learner view after publishing it, click Set to Draft.

Example of a Function-Based Problem

In this example, the learner must compute the opposite angles corresponding to two non hypotenuse sides of a right triangle. There are no reference files used in this problem.

  1. Create title and problem description. Use the toolbar to format text.

  2. Set Problem Type to Function.

  3. Fill out the Reference Solution with your solution to the problem.

  4. MATLAB® Grader™ uses the reference solution to fill out the Learner Template. You can remove any code you want the learners to provide, for example, variable values or computations.

    To lock lines of code you do not want the learner to change, click the lock icon.

  5. Provide some sample inputs and a call to the function in How to Call the Function.

    sides = [100,200]; angles=rightTri(sides)

  6. Click Learner Preview. Note the appearance of the problem and make any adjustments.

  7. Write assessment tests for the problem. See Write Assessments for Function-Based Learner Solutions.

  8. Click Save as Draft at any time to save your work.

  9. When you have finished creating the problem, click Save as Final.

Related Topics